Skip to content

Commit

Permalink
Improve text fields layout in Launch configuration tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
franco-maroni committed Oct 3, 2017
1 parent 2454802 commit bd18004
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void createControl(Composite parent) {
Group group = new Group(topComposite, SWT.NONE);
group.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, false, false));

group.setLayout(new GridLayout(4, true));
group.setLayout(new GridLayout(4, false));
group.setText("Task Details");

Label taskNameLabel = new Label(group, SWT.BORDER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ public int compare(Viewer viewer, Object e1, Object e2) {
}

private class FormData {
private String taskName;
private String taskDescription;
private String inputFile;
private String intermediateFilesDir;
private int timeBound;
Expand All @@ -141,6 +143,28 @@ private class FormData {
setConfig(VtConfigFactory.eINSTANCE.createVerificationToolConfig());
}

public String getTaskName() {
return taskName;
}

public void setTaskName(String taskName, boolean refresh) {
this.taskName = taskName;
if (refresh)
taskNameText.setText(taskName);
setDirty(true);
}

public String getTaskDescription() {
return taskDescription;
}

public void setTaskDescription(String taskDescription, boolean refresh) {
this.taskDescription = taskDescription;
if (refresh)
taskDescriptionText.setText(taskDescription);
setDirty(true);
}

protected String getInputFile() {
return inputFile;
}
Expand All @@ -154,12 +178,6 @@ protected void setInputFileBoolean(String inputFile) {
for (String var : vars) {
config.getMonitoredBolts().put(var, false);
}
/*
* for (Map.Entry<String, Boolean> entry :
* config.getMonitoredBolts().entrySet()) {
* DiceLogger.logError(DiceVerificationUiPlugin.getDefault(),
* "Key: "+ entry.getKey() + " - Value: " + entry.getValue()); }
*/
viewerBoolean.refresh();
// config.setZotPlugin(ZotPlugin.AE2BVZOT);
setDirty(true);
Expand Down Expand Up @@ -330,6 +348,9 @@ protected void setValue(Object element, Object userInputValue) {
}
}


protected Text taskNameText;
protected Text taskDescriptionText;
protected Text inputFileText;
protected Button keepIntermediateFilesButton;
protected Text timeBoundText;
Expand Down Expand Up @@ -358,6 +379,55 @@ public void createControl(Composite parent) {
GridData buttonsGridDataIntermediate = new GridData(SWT.CENTER, SWT.CENTER, false, false);
buttonsGridDataIntermediate.widthHint = 100;


{ // Task Details Group
Group group = new Group(topComposite, SWT.NONE);
group.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, false, false));

group.setLayout(new GridLayout(4, false));
group.setText("Task Details");

Label taskNameLabel = new Label(group, SWT.BORDER);
taskNameLabel.setText("Task Name");
taskNameLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false));
taskNameLabel.setToolTipText("Optional custom identifier for the verification task. Default value is UML file name.");

taskNameText = new Text(group, SWT.BORDER);
taskNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
taskNameText.setEditable(true);
taskNameText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
// Get the widget whose text was modified
Text text = (Text) event.widget;
data.setTaskName(text.getText(), false);
setDirty(true);
updateLaunchConfigurationDialog();
}
});

Label taskDescriptionLabel = new Label(group, SWT.BORDER);
taskDescriptionLabel.setText("Task Description");
taskDescriptionLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false));
taskDescriptionLabel.setToolTipText("Optional description about the verification task.");

taskDescriptionText = new Text(group, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
gridData.heightHint = 2 * taskDescriptionText.getLineHeight();
taskDescriptionText.setLayoutData(gridData);
taskDescriptionText.setEditable(true);
taskDescriptionText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
// Get the widget whose text was modified
Text text = (Text) event.widget;
data.setTaskDescription(text.getText(), false);
setDirty(true);
updateLaunchConfigurationDialog();
}
});

}


{ // Model Group
Group group = new Group(topComposite, SWT.NONE);
group.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
Expand Down Expand Up @@ -664,6 +734,8 @@ public void modifyText(ModifyEvent event) {

@Override
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(VerificationLaunchConfigurationAttributes.TASK_NAME, StringUtils.EMPTY);
configuration.setAttribute(VerificationLaunchConfigurationAttributes.TASK_DESCRIPTION, StringUtils.EMPTY);
configuration.removeAttribute(VerificationLaunchConfigurationAttributes.INPUT_FILE);
configuration.setAttribute(VerificationLaunchConfigurationAttributes.KEEP_INTERMEDIATE_FILES, false);
configuration.removeAttribute(VerificationLaunchConfigurationAttributes.INTERMEDIATE_FILES_DIR);
Expand All @@ -678,6 +750,14 @@ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
@Override
public void initializeFrom(ILaunchConfiguration configuration) {
try {
if (configuration.hasAttribute(VerificationLaunchConfigurationAttributes.TASK_NAME)) {
data.setTaskName(configuration.getAttribute(VerificationLaunchConfigurationAttributes.TASK_NAME,
StringUtils.EMPTY), true);
}
if (configuration.hasAttribute(VerificationLaunchConfigurationAttributes.TASK_DESCRIPTION)) {
data.setTaskDescription(configuration.getAttribute(
VerificationLaunchConfigurationAttributes.TASK_DESCRIPTION, StringUtils.EMPTY), true);
}
if (configuration.hasAttribute(VerificationLaunchConfigurationAttributes.INPUT_FILE)) {
// data.setInputFileFloat(configuration.getAttribute(VerificationLaunchConfigurationAttributes.INPUT_FILE,
// StringUtils.EMPTY));
Expand Down Expand Up @@ -725,6 +805,9 @@ public void initializeFrom(ILaunchConfiguration configuration) {

@Override
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(VerificationLaunchConfigurationAttributes.TASK_NAME, data.getTaskName());
configuration.setAttribute(VerificationLaunchConfigurationAttributes.TASK_DESCRIPTION,
data.getTaskDescription());
configuration.setAttribute(VerificationLaunchConfigurationAttributes.INPUT_FILE, data.getInputFile());
configuration.setAttribute(VerificationLaunchConfigurationAttributes.KEEP_INTERMEDIATE_FILES,
data.keepIntermediateFiles());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,13 @@

public class StormVerificationJsonContext extends VerificationJsonContext{

/* @SerializedName(value="app_name")
private String applicationName;
private String description;
private String version;
*/ private StormTopology topology;
/* @SerializedName(value="verification_params")
private VerificationParameters verificationParameters;
*/
private StormTopology topology;

public StormVerificationJsonContext(StormTopology t, VerificationParameters vp){
super(vp);
this.topology = t;
}


/* public String getApplicationName() {
return applicationName;
}
public void setApplicationName(String applicationName) {
this.applicationName = applicationName;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
*/
public StormTopology getTopology() {
return topology;
}
Expand All @@ -56,15 +18,4 @@ public void setTopology(StormTopology topology) {
this.topology = topology;
}


/* public VerificationParameters getVerificationParameters() {
return verificationParameters;
}
public void setVerificationParameters(VerificationParameters verificationParameters) {
this.verificationParameters = verificationParameters;
}
*/

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ public class VerificationJsonContext {
@SerializedName(value="verification_params")
private VerificationParameters verificationParameters;

public VerificationJsonContext(/*StormTopology t, */VerificationParameters vp){
// this.topology = t;
public VerificationJsonContext(VerificationParameters vp){
this.verificationParameters = vp;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,27 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun
Map<String, String> verificationAttrs = new HashMap<>();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd__HH_mm_ss");
LocalDateTime now = LocalDateTime.now();
verificationAttrs.put(DebugPlugin.ATTR_LAUNCH_TIMESTAMP, now.format(formatter));
verificationAttrs.put(DebugPlugin.ATTR_LAUNCH_TIMESTAMP, now.format(formatter));
VerificationToolConfig vtConfig = getVerificationToolConfig(configuration);

final String taskName = configuration.getAttribute(VerificationLaunchConfigurationAttributes.TASK_NAME, "");
final String taskDescription = configuration.getAttribute(VerificationLaunchConfigurationAttributes.TASK_DESCRIPTION, "");
final String trimmedTaskName = taskName.trim().replaceAll("\\s+", "_");
verificationAttrs.put("TASK_NAME", trimmedTaskName);
verificationAttrs.put("TASK_DESCR", taskDescription);

final boolean keepIntermediateFiles = configuration.getAttribute(VerificationLaunchConfigurationAttributes.KEEP_INTERMEDIATE_FILES, false);
final File intermediateFilesDir = Utils.getIntermediateFilesDir(configuration);


final File umlFile = Utils.getInputFile(configuration);
final File configFile = Paths.get(intermediateFilesDir.toURI()).resolve("dump.vtconfig").toFile(); //$NON-NLS-1$
// final File configFile = Paths.get(intermediateFilesDir.toURI()).resolve("dump.vtconfig").toFile(); //$NON-NLS-1$
final File jsonFile = Paths.get(intermediateFilesDir.toURI()).resolve("context.json").toFile(); //$NON-NLS-1$

try {
try {
dumpConfig(vtConfig, configFile, new SubProgressMonitor(monitor, 1));
// dumpConfig(vtConfig, configFile, new SubProgressMonitor(monitor, 1));
transformUmlToJson(umlFile, vtConfig, jsonFile, new SubProgressMonitor(monitor, 1), verificationAttrs, configuration);
} finally {
// Refresh workspace if intermediate files were stored in it
Expand Down Expand Up @@ -195,7 +201,9 @@ private void transformUmlToJson(File umlFile, VerificationToolConfig vtConfig, F
int pos = filename.lastIndexOf(".");
String justName = pos > 0 ? filename.substring(0, pos) : filename;
String timestamp = attributes.get(DebugPlugin.ATTR_LAUNCH_TIMESTAMP);
String verificationIdentifier = justName + "_" + timestamp;
String taskName = attributes.get("TASK_NAME");
String taskDescription = attributes.get("TASK_DESCR");
String verificationIdentifier = justName + "_" + taskName + "_" + timestamp;


if (monitor == null) {
Expand Down Expand Up @@ -245,6 +253,7 @@ else if (UML2ModelHelper.isBolt((Element)eObject)) {
vp.setStrictlyMonotonicQueues(monitoredBoltsList);
jsonContext = new StormVerificationJsonContext(topology, vp);
jsonContext.setApplicationName(verificationIdentifier);
jsonContext.setDescription(taskDescription);

DiceLogger.logInfo(DiceVerificationPlugin.getDefault(), "JSON CONTEXT CREATED:\n" + gson.toJson(jsonContext));

Expand Down

0 comments on commit bd18004

Please sign in to comment.