Changeset 1094
- Timestamp:
- 02/20/13 10:42:59 (12 years ago)
- Location:
- trunk/autoquest-ui-swt
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-ui-swt/pom.xml
r1015 r1094 46 46 <groupId>de.ugoe.cs.autoquest</groupId> 47 47 <artifactId>autoquest-core-usageprofiles</artifactId> 48 <version>${project.parent.version}</version> 49 </dependency> 50 <dependency> 51 <groupId>de.ugoe.cs.autoquest</groupId> 52 <artifactId>autoquest-core-tasktrees</artifactId> 48 53 <version>${project.parent.version}</version> 49 54 </dependency> -
trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/ModelsTabComposite.java
r927 r1094 23 23 import org.eclipse.swt.layout.GridData; 24 24 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree; 25 26 import de.ugoe.cs.autoquest.usageprofiles.FirstOrderMarkovModel; 26 27 import de.ugoe.cs.autoquest.usageprofiles.IDotCompatible; … … 34 35 public class ModelsTabComposite extends Composite { 35 36 37 /** */ 36 38 List modelList; 37 39 40 /** */ 41 Button btnShow; 42 43 /** */ 44 Button btnDelete_1; 45 46 /** */ 47 Button btnGenSequences; 48 49 /** */ 50 Button btnProperties; 51 52 /** */ 53 Button btnCreateDot; 54 38 55 /** 39 56 * Create the composite. … … 47 64 } 48 65 66 /** 67 * 68 */ 49 69 private void createContents() { 50 70 setLayout(new GridLayout(5, false)); … … 52 72 modelList = new List(this, SWT.BORDER | SWT.V_SCROLL); 53 73 modelList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1)); 54 55 Button btnShow = new Button(this, SWT.NONE); 74 modelList.addSelectionListener(new SelectionAdapter() { 75 @Override 76 public void widgetSelected(SelectionEvent e) { 77 String[] selectedStrings = modelList.getSelection(); 78 if (selectedStrings.length == 1) { 79 btnShow.setEnabled(true); 80 btnDelete_1.setEnabled(true); 81 Object obj = GlobalDataContainer.getInstance().getData(selectedStrings[0]); 82 if (obj instanceof IStochasticProcess) { 83 btnGenSequences.setEnabled(true); 84 btnProperties.setEnabled(true); 85 btnCreateDot.setEnabled(true); 86 } 87 else { 88 btnGenSequences.setEnabled(false); 89 btnProperties.setEnabled(false); 90 btnCreateDot.setEnabled(false); 91 } 92 } 93 else if (selectedStrings.length > 1) { 94 btnShow.setEnabled(false); 95 btnDelete_1.setEnabled(true); 96 btnProperties.setEnabled(false); 97 btnCreateDot.setEnabled(false); 98 99 boolean enableSequenceGeneration = true; 100 for (String selectedString : selectedStrings) { 101 Object obj = GlobalDataContainer.getInstance().getData(selectedString); 102 if (!(obj instanceof IStochasticProcess)) { 103 enableSequenceGeneration = false; 104 break; 105 } 106 } 107 btnGenSequences.setEnabled(enableSequenceGeneration); 108 } 109 } 110 }); 111 112 btnShow = new Button(this, SWT.NONE); 56 113 btnShow.addSelectionListener(new SelectionAdapter() { 57 114 @Override … … 62 119 return; 63 120 } 64 IStochasticProcess process = 65 (IStochasticProcess) GlobalDataContainer.getInstance() 66 .getData(selectedStrings[0]); 67 if (process instanceof FirstOrderMarkovModel) { 121 else if (selectedStrings.length > 1) { 122 SWTHelpers.moreThanOneSelectedError(getShell()); 123 return; 124 } 125 126 Object obj = GlobalDataContainer.getInstance().getData(selectedStrings[0]); 127 128 if (obj instanceof FirstOrderMarkovModel) { 68 129 String command = "showMarkovModel " + selectedStrings[0]; 69 130 CommandExecuter.getInstance().exec(command); 70 131 } 132 else if (obj instanceof ITaskTree) { 133 ShowTaskTreeDialog showTaskTreeDialog = new ShowTaskTreeDialog 134 (getShell(), SWT.NONE, (ITaskTree) obj, selectedStrings[0]); 135 showTaskTreeDialog.open(); 136 } 71 137 else { 72 138 MessageBox messageBox = new MessageBox(getShell(), SWT.NONE); 73 139 messageBox.setText("Feature Not Available"); 74 messageBox 75 .setMessage("The feature is currently only available for first-order Markov models.");140 messageBox.setMessage("This feature is currently only available for " + 141 "first-order Markov models and task trees."); 76 142 messageBox.open(); 77 143 } … … 79 145 }); 80 146 btnShow.setText("Visualize"); 81 82 Button btnDelete_1 = new Button(this, SWT.NONE); 147 btnShow.setEnabled(false); 148 149 btnDelete_1 = new Button(this, SWT.NONE); 83 150 btnDelete_1.addSelectionListener(new SelectionAdapter() { 84 151 @Override … … 93 160 }); 94 161 btnDelete_1.setText("Delete"); 95 96 Button btnGenSequences = new Button(this, SWT.NONE); 162 btnDelete_1.setEnabled(false); 163 164 btnGenSequences = new Button(this, SWT.NONE); 97 165 btnGenSequences.addSelectionListener(new SelectionAdapter() { 98 166 @Override … … 103 171 return; 104 172 } 105 GenerateSequencesDialog generateSequencesDialog = 106 new GenerateSequencesDialog(getShell(), SWT.NONE); 107 generateSequencesDialog.setProcessName(selectedStrings[0]); 108 generateSequencesDialog.open(); 173 174 boolean enableSequenceGeneration = true; 175 for (String selectedString : selectedStrings) { 176 Object obj = GlobalDataContainer.getInstance().getData(selectedString); 177 if (!(obj instanceof IStochasticProcess)) { 178 enableSequenceGeneration = false; 179 break; 180 } 181 } 182 183 if (enableSequenceGeneration) { 184 GenerateSequencesDialog generateSequencesDialog = 185 new GenerateSequencesDialog(getShell(), SWT.NONE); 186 generateSequencesDialog.setProcessName(selectedStrings[0]); 187 generateSequencesDialog.open(); 188 } 189 else { 190 MessageBox messageBox = new MessageBox(getShell(), SWT.NONE); 191 messageBox.setText("Feature Not Available"); 192 messageBox.setMessage("This feature is not available for task trees. Please " + 193 "deselect the selected task tree(s)!"); 194 messageBox.open(); 195 } 109 196 } 110 197 }); 111 198 btnGenSequences.setText("Gen. Sequences"); 112 113 Button btnProperties = new Button(this, SWT.NONE); 199 btnGenSequences.setEnabled(false); 200 201 btnProperties = new Button(this, SWT.NONE); 114 202 btnProperties.addSelectionListener(new SelectionAdapter() { 115 203 @Override … … 120 208 return; 121 209 } 122 IStochasticProcess process = 123 (IStochasticProcess) GlobalDataContainer.getInstance() 124 .getData(selectedStrings[0]); 125 ModelPropertiesDialog modelPropertiesDialog = 126 new ModelPropertiesDialog(getShell(), SWT.NONE); 127 modelPropertiesDialog.setStochasticProcess(process); 128 modelPropertiesDialog.open(); 210 else if (selectedStrings.length > 1) { 211 SWTHelpers.moreThanOneSelectedError(getShell()); 212 return; 213 } 214 215 Object obj = GlobalDataContainer.getInstance().getData(selectedStrings[0]); 216 217 if (obj instanceof IStochasticProcess) { 218 IStochasticProcess process = (IStochasticProcess) obj; 219 ModelPropertiesDialog modelPropertiesDialog = 220 new ModelPropertiesDialog(getShell(), SWT.NONE); 221 modelPropertiesDialog.setStochasticProcess(process); 222 modelPropertiesDialog.open(); 223 } 224 else { 225 MessageBox messageBox = new MessageBox(getShell(), SWT.NONE); 226 messageBox.setText("Feature Not Available"); 227 messageBox.setMessage("The feature is currently only available for " + 228 "stochastic processes. Please select a model that " + 229 "is a stochastic process."); 230 messageBox.open(); 231 } 129 232 } 130 233 }); 131 234 btnProperties.setText("Properties"); 132 133 Button btnCreateDot = new Button(this, SWT.NONE); 235 btnProperties.setEnabled(false); 236 237 btnCreateDot = new Button(this, SWT.NONE); 134 238 btnCreateDot.addSelectionListener(new SelectionAdapter() { 135 239 @Override … … 140 244 return; 141 245 } 142 IStochasticProcess process = 143 (IStochasticProcess) GlobalDataContainer.getInstance() 144 .getData(selectedStrings[0]); 145 String command = ""; 146 if (process instanceof IDotCompatible) { 147 command = "printDot "; 148 } 149 else { 150 command = "printTrieDot "; 151 } 152 command += selectedStrings[0]; 153 CommandExecuter.getInstance().exec(command); 246 else if (selectedStrings.length > 1) { 247 SWTHelpers.moreThanOneSelectedError(getShell()); 248 return; 249 } 250 251 Object obj = GlobalDataContainer.getInstance().getData(selectedStrings[0]); 252 253 if (obj instanceof IStochasticProcess) { 254 String command; 255 if (obj instanceof IDotCompatible) { 256 command = "printDot "; 257 } 258 else { 259 command = "printTrieDot "; 260 } 261 command += selectedStrings[0]; 262 CommandExecuter.getInstance().exec(command); 263 } 264 else { 265 MessageBox messageBox = new MessageBox(getShell(), SWT.NONE); 266 messageBox.setText("Feature Not Available"); 267 messageBox.setMessage("The feature is currently only available for " + 268 "stochastic processes. Please select a model that " + 269 "is a stochastic process."); 270 messageBox.open(); 271 } 154 272 } 155 273 }); 156 274 btnCreateDot.setText("Create DOT"); 275 btnCreateDot.setEnabled(false); 157 276 } 158 277 278 /** 279 * 280 */ 159 281 @Override 160 282 protected void checkSubclass() { … … 162 284 } 163 285 286 /** 287 * 288 */ 164 289 public void updateModelList() { 165 290 modelList.removeAll(); 166 for(String key : GlobalDataContainer.getInstance().getAllKeys()) { 167 if( GlobalDataContainer.getInstance().getData(key) instanceof IStochasticProcess ) { 291 for (String key : GlobalDataContainer.getInstance().getAllKeys()) { 292 if ((GlobalDataContainer.getInstance().getData(key) instanceof IStochasticProcess) || 293 (GlobalDataContainer.getInstance().getData(key) instanceof ITaskTree)) 294 { 168 295 modelList.add(key); 169 296 } -
trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/SWTHelpers.java
r927 r1094 22 22 import de.ugoe.cs.util.console.CommandExecuter; 23 23 24 /** 25 * TODO comment 26 * 27 * @author Steffen Herbold, Patrick Harms 28 */ 24 29 public class SWTHelpers { 25 30 31 /** 32 * 33 */ 26 34 public static boolean deleteSelectedFromStorage(final List list) { 27 35 String[] selectedStrings = list.getSelection(); … … 38 46 } 39 47 48 /** 49 * 50 */ 40 51 public static void noSelectionError(final Shell shell) { 41 52 MessageBox messageBox = new MessageBox(shell, SWT.ERROR); 42 messageBox.setMessage("No objects selected!"); 53 messageBox.setMessage 54 ("No objects selected! Please select at least one object to execute this function"); 55 messageBox.setText("Error"); 56 messageBox.open(); 57 } 58 59 /** 60 * 61 */ 62 public static void moreThanOneSelectedError(final Shell shell) { 63 MessageBox messageBox = new MessageBox(shell, SWT.ERROR); 64 messageBox.setMessage("Too many objects selected for this function! Select only one!"); 43 65 messageBox.setText("Error"); 44 66 messageBox.open();
Note: See TracChangeset
for help on using the changeset viewer.