[1094] | 1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany |
---|
| 2 | // |
---|
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
---|
| 4 | // you may not use this file except in compliance with the License. |
---|
| 5 | // You may obtain a copy of the License at |
---|
| 6 | // |
---|
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 8 | // |
---|
| 9 | // Unless required by applicable law or agreed to in writing, software |
---|
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 12 | // See the License for the specific language governing permissions and |
---|
| 13 | // limitations under the License. |
---|
| 14 | |
---|
| 15 | package de.ugoe.cs.autoquest.ui.swt; |
---|
| 16 | |
---|
[2033] | 17 | import java.awt.Frame; |
---|
[1424] | 18 | import java.awt.GraphicsDevice; |
---|
| 19 | import java.awt.GraphicsEnvironment; |
---|
[2127] | 20 | import java.awt.Toolkit; |
---|
| 21 | import java.awt.datatransfer.Clipboard; |
---|
| 22 | import java.awt.datatransfer.StringSelection; |
---|
[2033] | 23 | import java.lang.reflect.Method; |
---|
[2127] | 24 | import java.util.ArrayList; |
---|
[1153] | 25 | import java.util.Collection; |
---|
[1262] | 26 | import java.util.Collections; |
---|
| 27 | import java.util.Comparator; |
---|
| 28 | import java.util.LinkedList; |
---|
[1146] | 29 | import java.util.List; |
---|
[2147] | 30 | import java.util.TreeMap; |
---|
[1146] | 31 | |
---|
[1094] | 32 | import org.eclipse.swt.SWT; |
---|
[2033] | 33 | import org.eclipse.swt.awt.SWT_AWT; |
---|
[1146] | 34 | import org.eclipse.swt.custom.SashForm; |
---|
[2033] | 35 | import org.eclipse.swt.custom.StackLayout; |
---|
[1094] | 36 | import org.eclipse.swt.events.SelectionAdapter; |
---|
| 37 | import org.eclipse.swt.events.SelectionEvent; |
---|
[1424] | 38 | import org.eclipse.swt.events.ShellAdapter; |
---|
| 39 | import org.eclipse.swt.events.ShellEvent; |
---|
| 40 | import org.eclipse.swt.events.ShellListener; |
---|
[2033] | 41 | import org.eclipse.swt.graphics.Color; |
---|
[1094] | 42 | import org.eclipse.swt.layout.GridData; |
---|
| 43 | import org.eclipse.swt.layout.GridLayout; |
---|
| 44 | import org.eclipse.swt.widgets.Button; |
---|
[1424] | 45 | import org.eclipse.swt.widgets.Composite; |
---|
[2033] | 46 | import org.eclipse.swt.widgets.Control; |
---|
[1094] | 47 | import org.eclipse.swt.widgets.Dialog; |
---|
| 48 | import org.eclipse.swt.widgets.Display; |
---|
[1153] | 49 | import org.eclipse.swt.widgets.Event; |
---|
[2033] | 50 | import org.eclipse.swt.widgets.FileDialog; |
---|
[1424] | 51 | import org.eclipse.swt.widgets.Label; |
---|
[1153] | 52 | import org.eclipse.swt.widgets.Listener; |
---|
[2033] | 53 | import org.eclipse.swt.widgets.Menu; |
---|
| 54 | import org.eclipse.swt.widgets.MenuItem; |
---|
[1094] | 55 | import org.eclipse.swt.widgets.Shell; |
---|
[1424] | 56 | import org.eclipse.swt.widgets.TabFolder; |
---|
| 57 | import org.eclipse.swt.widgets.TabItem; |
---|
[1094] | 58 | import org.eclipse.swt.widgets.Tree; |
---|
[1424] | 59 | import org.eclipse.swt.widgets.TreeColumn; |
---|
[1094] | 60 | import org.eclipse.swt.widgets.TreeItem; |
---|
[2033] | 61 | import org.jfree.chart.ChartPanel; |
---|
| 62 | import org.jfree.chart.JFreeChart; |
---|
[1094] | 63 | |
---|
[1424] | 64 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; |
---|
[1146] | 65 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IMarkingTemporalRelationship; |
---|
[1424] | 66 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; |
---|
[1294] | 67 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; |
---|
[1424] | 68 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; |
---|
[1294] | 69 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; |
---|
[1424] | 70 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; |
---|
[1146] | 71 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IStructuringTemporalRelationship; |
---|
| 72 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; |
---|
| 73 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; |
---|
| 74 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList; |
---|
| 75 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; |
---|
| 76 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; |
---|
[1636] | 77 | import de.ugoe.cs.autoquest.tasktrees.treeifc.TaskMetric; |
---|
[2033] | 78 | import de.ugoe.cs.util.console.Console; |
---|
[1094] | 79 | |
---|
| 80 | /** |
---|
| 81 | * <p> |
---|
[1275] | 82 | * a dialog to inspect the tasks and task instances of a task model |
---|
[1094] | 83 | * </p> |
---|
| 84 | * |
---|
| 85 | * @author Patrick Harms |
---|
| 86 | */ |
---|
| 87 | public class ShowTaskTreeDialog extends Dialog { |
---|
| 88 | |
---|
[1275] | 89 | /** the main shell */ |
---|
[1424] | 90 | private Shell shell; |
---|
[1094] | 91 | |
---|
[1424] | 92 | /** the listener for the main shell to prevent disposing required */ |
---|
| 93 | private ShellListener shellListener; |
---|
| 94 | |
---|
[2033] | 95 | /** the tab folder containing the instance tree, the model tree, and the visualizations list */ |
---|
[1424] | 96 | private TabFolder tabFolder; |
---|
| 97 | |
---|
[1275] | 98 | /** the tree of task instances on the left */ |
---|
[1146] | 99 | private Tree instanceTree; |
---|
| 100 | |
---|
[1424] | 101 | /** the tree of tasks on the left */ |
---|
[1146] | 102 | private Tree modelTree; |
---|
[1424] | 103 | |
---|
[2033] | 104 | /** the tree of possible visualizations on the left */ |
---|
| 105 | private Tree modelVisualizationTree; |
---|
| 106 | |
---|
| 107 | /** the right hand composite containing either task details or a visualization */ |
---|
| 108 | private Composite rightHandComposite; |
---|
| 109 | |
---|
| 110 | /** the stack layout displaying either the task details or a visualization */ |
---|
| 111 | private StackLayout rightHandLayout; |
---|
| 112 | |
---|
| 113 | /** the task details composite containing the task details tree, the execution variants, etc.*/ |
---|
| 114 | private Composite detailsComposite; |
---|
| 115 | |
---|
[1424] | 116 | /** the tree of a specific task on the right */ |
---|
| 117 | private Tree taskDetailsTree; |
---|
[1094] | 118 | |
---|
[1424] | 119 | /** the tree of execution variants of a specific task on the right */ |
---|
| 120 | private Tree executionVariantsTree; |
---|
| 121 | |
---|
| 122 | /** the tree of involved GUI elements of a specific task on the right bottom */ |
---|
[1495] | 123 | private Tree involvedTargetsTree; |
---|
[1424] | 124 | |
---|
| 125 | /** the table containing the parents tasks of a displayed task */ |
---|
| 126 | private Tree parentTasks; |
---|
[2033] | 127 | |
---|
| 128 | /** the visualization composite on the right hand side toggled with the details composite */ |
---|
| 129 | private Composite visualizationsComposite; |
---|
[1424] | 130 | |
---|
[1275] | 131 | /** the displayed task model */ |
---|
[1424] | 132 | private ITaskModel taskModel; |
---|
| 133 | |
---|
[2033] | 134 | /** a boolean indicating if the CTTE export of a task is possible */ |
---|
| 135 | private boolean taskExportAvailable = false; |
---|
| 136 | |
---|
[1424] | 137 | /** default expansion listener */ |
---|
| 138 | private Listener defaultExpansionListener = new Listener() { |
---|
| 139 | public void handleEvent(final Event event) { |
---|
| 140 | ensureChildren((TreeItem) event.item); |
---|
| 141 | ((TreeItem) event.item).setExpanded(true); |
---|
| 142 | } |
---|
| 143 | }; |
---|
[1094] | 144 | |
---|
| 145 | /** |
---|
[1275] | 146 | * creates the dialog |
---|
[1094] | 147 | */ |
---|
[1146] | 148 | public ShowTaskTreeDialog(Shell parent, int style, ITaskModel taskModel, String taskTreeName) { |
---|
[1094] | 149 | super(parent, style); |
---|
[1146] | 150 | setText("Task Model " + taskTreeName); |
---|
| 151 | this.taskModel = taskModel; |
---|
[1094] | 152 | } |
---|
| 153 | |
---|
| 154 | /** |
---|
[1275] | 155 | * displays the dialog |
---|
[1424] | 156 | * @param task |
---|
[1094] | 157 | */ |
---|
| 158 | public void open() { |
---|
[2033] | 159 | // check, if export to CTTE is possible |
---|
| 160 | try { |
---|
| 161 | Class<?> exportClass = this.getClass().getClassLoader().loadClass |
---|
| 162 | ("de.ugoe.cs.autoquest.plugin.exports.tasktree.CTTExportUtils"); |
---|
| 163 | |
---|
| 164 | if (exportClass != null) { |
---|
| 165 | taskExportAvailable = true; |
---|
| 166 | } |
---|
| 167 | } |
---|
| 168 | catch (ClassNotFoundException e) { |
---|
| 169 | // ignore. No export available |
---|
| 170 | } |
---|
| 171 | |
---|
[1424] | 172 | open(null); |
---|
| 173 | } |
---|
| 174 | |
---|
| 175 | /** |
---|
| 176 | * displays the dialog with a specific task opened |
---|
| 177 | * @param task |
---|
| 178 | */ |
---|
| 179 | public void open(ITask task) { |
---|
| 180 | if (shell == null) { |
---|
| 181 | createContents(); |
---|
| 182 | shell.open(); |
---|
| 183 | shell.layout(); |
---|
| 184 | |
---|
| 185 | VisualizationUtils.updateColumnWidths(taskDetailsTree); |
---|
| 186 | } |
---|
| 187 | else { |
---|
| 188 | shell.setVisible(true); |
---|
| 189 | } |
---|
| 190 | |
---|
| 191 | if (task != null) { |
---|
| 192 | shellListener = new ShellAdapter() { |
---|
| 193 | @Override |
---|
| 194 | public void shellClosed(ShellEvent e) { |
---|
| 195 | e.doit = false; |
---|
| 196 | shell.setVisible(false); |
---|
| 197 | } |
---|
| 198 | }; |
---|
| 199 | |
---|
| 200 | shell.addShellListener(shellListener); |
---|
| 201 | } |
---|
| 202 | |
---|
| 203 | if (task != null) { |
---|
| 204 | navigateTo(task); |
---|
| 205 | } |
---|
| 206 | |
---|
[1094] | 207 | Display display = getParent().getDisplay(); |
---|
[1424] | 208 | while (!shell.isDisposed() && shell.isVisible()) { |
---|
[1094] | 209 | if (!display.readAndDispatch()) { |
---|
| 210 | display.sleep(); |
---|
| 211 | } |
---|
| 212 | } |
---|
[1424] | 213 | |
---|
| 214 | if (task == null) { |
---|
| 215 | dispose(); |
---|
| 216 | } |
---|
[1094] | 217 | } |
---|
| 218 | |
---|
| 219 | /** |
---|
[1424] | 220 | * disposes the dialog if it is not used anymore |
---|
| 221 | */ |
---|
| 222 | public void dispose() { |
---|
| 223 | if ((shell != null) && (!shell.isDisposed())) { |
---|
| 224 | if (shellListener != null) { |
---|
| 225 | shell.removeShellListener(shellListener); |
---|
| 226 | } |
---|
| 227 | |
---|
| 228 | shell.dispose(); |
---|
| 229 | } |
---|
| 230 | } |
---|
| 231 | |
---|
| 232 | /** |
---|
[1275] | 233 | * creates the two views, one on the task instances on the left, on on the task models on the |
---|
| 234 | * right. Also adds a selection adapter to the task instances so that for a selected task |
---|
| 235 | * instance always the respective model is presented. |
---|
[1094] | 236 | */ |
---|
| 237 | private void createContents() { |
---|
[1424] | 238 | shell = new Shell(getParent(), SWT.SHELL_TRIM | SWT.BORDER); |
---|
| 239 | |
---|
| 240 | GraphicsDevice gd = |
---|
| 241 | GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); |
---|
| 242 | |
---|
| 243 | shell.setSize(gd.getDisplayMode().getWidth(), gd.getDisplayMode().getHeight()); |
---|
[1094] | 244 | shell.setText(getText()); |
---|
| 245 | |
---|
| 246 | shell.setLayout(new GridLayout(4, false)); |
---|
[1146] | 247 | |
---|
[1424] | 248 | SashForm mainSashForm = new SashForm(shell, SWT.HORIZONTAL); |
---|
| 249 | mainSashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1)); |
---|
[1146] | 250 | |
---|
[2033] | 251 | createLeftHandSideTabs(mainSashForm); |
---|
| 252 | createRightHandSideView(mainSashForm); |
---|
[1424] | 253 | |
---|
| 254 | mainSashForm.setWeights(new int[] { 1, 3 }); |
---|
| 255 | |
---|
| 256 | Button btnExpandAll = new Button(shell, SWT.NONE); |
---|
| 257 | btnExpandAll.addSelectionListener(new SelectionAdapter() { |
---|
| 258 | @Override |
---|
| 259 | public void widgetSelected(SelectionEvent e) { |
---|
| 260 | if (tabFolder.getSelectionIndex() == 0) { |
---|
| 261 | VisualizationUtils.expandAll(instanceTree, true); |
---|
| 262 | } |
---|
| 263 | else { |
---|
| 264 | VisualizationUtils.expandAll(modelTree, true); |
---|
| 265 | } |
---|
| 266 | } |
---|
| 267 | }); |
---|
| 268 | btnExpandAll.setText("Expand all"); |
---|
| 269 | |
---|
| 270 | Button btnCollapseAll = new Button(shell, SWT.NONE); |
---|
| 271 | btnCollapseAll.addSelectionListener(new SelectionAdapter() { |
---|
| 272 | @Override |
---|
| 273 | public void widgetSelected(SelectionEvent e) { |
---|
| 274 | if (tabFolder.getSelectionIndex() == 0) { |
---|
| 275 | VisualizationUtils.expandAll(instanceTree, false); |
---|
| 276 | } |
---|
| 277 | else { |
---|
| 278 | VisualizationUtils.expandAll(modelTree, false); |
---|
| 279 | } |
---|
| 280 | } |
---|
| 281 | }); |
---|
| 282 | btnCollapseAll.setText("Collapse all"); |
---|
| 283 | |
---|
| 284 | new Label(shell, SWT.NONE); |
---|
| 285 | new Label(shell, SWT.NONE); |
---|
| 286 | } |
---|
| 287 | |
---|
| 288 | /** |
---|
| 289 | * |
---|
| 290 | */ |
---|
[2033] | 291 | private void createLeftHandSideTabs(final SashForm mainSashForm) { |
---|
[1424] | 292 | tabFolder = new TabFolder(mainSashForm, SWT.NONE); |
---|
| 293 | tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); |
---|
| 294 | tabFolder.addSelectionListener(new SelectionAdapter() { |
---|
| 295 | @Override |
---|
| 296 | public void widgetSelected(SelectionEvent e) { |
---|
[2033] | 297 | if (tabFolder.getSelectionIndex() == 0) { |
---|
| 298 | // task instances tab selected |
---|
| 299 | rightHandLayout.topControl = detailsComposite; |
---|
| 300 | } |
---|
| 301 | else if (tabFolder.getSelectionIndex() == 1) { |
---|
| 302 | // task model tab selected |
---|
| 303 | rightHandLayout.topControl = detailsComposite; |
---|
| 304 | VisualizationUtils.updateColumnWidths(modelTree); |
---|
| 305 | } |
---|
| 306 | else { |
---|
| 307 | rightHandLayout.topControl = visualizationsComposite; |
---|
| 308 | } |
---|
| 309 | |
---|
| 310 | rightHandComposite.layout(); |
---|
| 311 | rightHandComposite.redraw(); |
---|
| 312 | rightHandComposite.update(); |
---|
[1424] | 313 | } |
---|
| 314 | }); |
---|
| 315 | |
---|
| 316 | TabItem instanceTreeTab = new TabItem(tabFolder, SWT.NONE); |
---|
| 317 | instanceTreeTab.setText("Task Instances"); |
---|
| 318 | |
---|
| 319 | instanceTree = new Tree(tabFolder, SWT.BORDER | SWT.SINGLE | SWT.VIRTUAL); |
---|
[1146] | 320 | instanceTree.addSelectionListener(new SelectionAdapter() { |
---|
| 321 | @Override |
---|
| 322 | public void widgetSelected(SelectionEvent e) { |
---|
| 323 | TreeItem[] selectedItems = instanceTree.getSelection(); |
---|
[1424] | 324 | if ((selectedItems.length == 1) && |
---|
| 325 | (selectedItems[0].getData() instanceof ITaskInstance)) |
---|
| 326 | { |
---|
| 327 | displayTaskDetails(((ITaskInstance) selectedItems[0].getData()).getTask()); |
---|
[1146] | 328 | } |
---|
[1424] | 329 | else { |
---|
| 330 | clearTaskDetails(); |
---|
| 331 | } |
---|
[1146] | 332 | } |
---|
| 333 | }); |
---|
[1094] | 334 | |
---|
[1424] | 335 | VisualizationUtils.addItemSpecificContextMenu |
---|
| 336 | (instanceTree, ITaskInstance.class, "show in task list", new SelectionAdapter() |
---|
| 337 | { |
---|
| 338 | @Override |
---|
| 339 | public void widgetSelected(SelectionEvent e) { |
---|
| 340 | navigateTo(((ITaskInstance) instanceTree.getSelection()[0].getData()).getTask()); |
---|
| 341 | } |
---|
| 342 | }); |
---|
[2033] | 343 | |
---|
| 344 | if (taskExportAvailable) { |
---|
| 345 | VisualizationUtils.addItemSpecificContextMenu |
---|
| 346 | (instanceTree, ITask.class, "export to ConcurTaskTree", new SelectionAdapter() |
---|
| 347 | { |
---|
| 348 | @Override |
---|
| 349 | public void widgetSelected(SelectionEvent e) { |
---|
| 350 | export((ITask) taskDetailsTree.getSelection()[0].getData()); |
---|
| 351 | } |
---|
| 352 | }); |
---|
| 353 | } |
---|
[1424] | 354 | |
---|
[2127] | 355 | VisualizationUtils.addItemSpecificContextMenu |
---|
| 356 | (instanceTree, ITask.class, "copy to clipboard", new SelectionAdapter() |
---|
| 357 | { |
---|
| 358 | @Override |
---|
| 359 | public void widgetSelected(SelectionEvent e) { |
---|
| 360 | StringSelection stringSelection = new StringSelection |
---|
| 361 | (taskDetailsTree.getSelection()[0].getData().toString()); |
---|
| 362 | Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); |
---|
| 363 | clpbrd.setContents(stringSelection, null); |
---|
| 364 | } |
---|
| 365 | }); |
---|
| 366 | |
---|
[1146] | 367 | buildInstanceTree(); |
---|
[1424] | 368 | instanceTreeTab.setControl(instanceTree); |
---|
[1094] | 369 | |
---|
[1424] | 370 | TabItem modelTreeTab = new TabItem(tabFolder, SWT.NONE); |
---|
| 371 | modelTreeTab.setText("Tasks"); |
---|
| 372 | |
---|
| 373 | modelTree = |
---|
| 374 | VisualizationUtils.createTaskDetailsTree(tabFolder, "tasks in model", taskModel); |
---|
| 375 | |
---|
| 376 | // show task details if requested |
---|
| 377 | modelTree.addSelectionListener(new SelectionAdapter() { |
---|
| 378 | @Override |
---|
| 379 | public void widgetSelected(SelectionEvent e) { |
---|
| 380 | TreeItem[] selectedItems = modelTree.getSelection(); |
---|
| 381 | if ((selectedItems.length == 1) && (selectedItems[0].getData() instanceof ITask)) { |
---|
| 382 | displayTaskDetails((ITask) selectedItems[0].getData()); |
---|
| 383 | } |
---|
| 384 | else { |
---|
| 385 | clearTaskDetails(); |
---|
| 386 | } |
---|
| 387 | } |
---|
| 388 | }); |
---|
| 389 | |
---|
[1153] | 390 | buildModelTree(taskModel); |
---|
[1424] | 391 | |
---|
| 392 | modelTreeTab.setControl(modelTree); |
---|
[2033] | 393 | |
---|
| 394 | TabItem modelVisualizationTab = new TabItem(tabFolder, SWT.NONE); |
---|
| 395 | modelVisualizationTab.setText("Visualizations"); |
---|
| 396 | |
---|
| 397 | modelVisualizationTree = new Tree(tabFolder, SWT.BORDER | SWT.SINGLE | SWT.VIRTUAL); |
---|
| 398 | |
---|
| 399 | TreeItem item1 = new TreeItem(modelVisualizationTree, SWT.NULL); |
---|
| 400 | item1.setText(TaskTreePlotUtils.TASK_COUNT__EVENT_COVERAGE_PLOT); |
---|
| 401 | |
---|
| 402 | item1 = new TreeItem(modelVisualizationTree, SWT.NULL); |
---|
| 403 | item1.setText(TaskTreePlotUtils.ORDERED_TASK_COUNT_PLOT); |
---|
| 404 | |
---|
| 405 | item1 = new TreeItem(modelVisualizationTree, SWT.NULL); |
---|
| 406 | item1.setText(TaskTreePlotUtils.CUMULATIVE_TASK_COVERAGE_PLOT); |
---|
| 407 | |
---|
| 408 | Menu menu = modelVisualizationTree.getMenu(); |
---|
| 409 | |
---|
| 410 | if (menu == null) { |
---|
| 411 | menu = new Menu(modelVisualizationTree); |
---|
| 412 | modelVisualizationTree.setMenu(menu); |
---|
| 413 | } |
---|
| 414 | |
---|
| 415 | // show visualization if requested |
---|
| 416 | modelVisualizationTree.addSelectionListener(new SelectionAdapter() { |
---|
| 417 | @Override |
---|
| 418 | public void widgetSelected(SelectionEvent e) { |
---|
| 419 | clearVisualization(); |
---|
| 420 | TreeItem[] selectedItems = modelVisualizationTree.getSelection(); |
---|
| 421 | if (selectedItems.length == 1) { |
---|
| 422 | showVisualization(selectedItems[0].getText()); |
---|
| 423 | } |
---|
| 424 | } |
---|
| 425 | }); |
---|
| 426 | |
---|
| 427 | modelVisualizationTab.setControl(modelVisualizationTree); |
---|
| 428 | |
---|
| 429 | // add a context menu for PDF export |
---|
| 430 | final Menu finalMenu = menu; |
---|
| 431 | MenuItem newItem = new MenuItem(finalMenu, SWT.NONE); |
---|
| 432 | newItem.setText("save as PDF"); |
---|
| 433 | newItem.addSelectionListener(new SelectionAdapter() { |
---|
| 434 | @Override |
---|
| 435 | public void widgetSelected(SelectionEvent e) { |
---|
| 436 | try { |
---|
| 437 | FileDialog dialog = new FileDialog(shell, SWT.SAVE); |
---|
| 438 | dialog.setFilterExtensions(new String [] {"*.pdf"}); |
---|
| 439 | TaskTreePlotUtils.saveChartToPDF |
---|
| 440 | ((JFreeChart) modelVisualizationTree.getSelection()[0].getData(), |
---|
| 441 | dialog.open(), 500, 500); |
---|
| 442 | } |
---|
| 443 | catch (Exception e1) { |
---|
| 444 | // TODO Auto-generated catch block |
---|
| 445 | e1.printStackTrace(); |
---|
| 446 | } |
---|
| 447 | } |
---|
| 448 | }); |
---|
[1424] | 449 | } |
---|
[2033] | 450 | |
---|
[1424] | 451 | /** |
---|
| 452 | * |
---|
| 453 | */ |
---|
[2033] | 454 | private void createRightHandSideView(SashForm mainSashForm) { |
---|
| 455 | rightHandComposite = new Composite(mainSashForm, SWT.NO_BACKGROUND); |
---|
| 456 | rightHandLayout = new StackLayout(); |
---|
| 457 | rightHandComposite.setLayout(rightHandLayout); |
---|
| 458 | |
---|
| 459 | detailsComposite = new Composite(rightHandComposite, SWT.NO_BACKGROUND); |
---|
[1424] | 460 | detailsComposite.setLayout(new GridLayout(1, false)); |
---|
| 461 | detailsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); |
---|
| 462 | |
---|
| 463 | new Label(detailsComposite, SWT.NONE).setText("Task Details:"); |
---|
| 464 | |
---|
| 465 | SashForm detailsSashForm = new SashForm(detailsComposite, SWT.VERTICAL); |
---|
| 466 | detailsSashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); |
---|
| 467 | |
---|
| 468 | SashForm detailsTopSashForm = new SashForm(detailsSashForm, SWT.HORIZONTAL); |
---|
| 469 | detailsTopSashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); |
---|
| 470 | |
---|
| 471 | taskDetailsTree = |
---|
| 472 | VisualizationUtils.createTaskDetailsTree(detailsTopSashForm, "task details", taskModel); |
---|
| 473 | |
---|
| 474 | VisualizationUtils.addExpansionListener(taskDetailsTree, defaultExpansionListener); |
---|
| 475 | |
---|
[2033] | 476 | VisualizationUtils.addItemSpecificContextMenu |
---|
| 477 | (taskDetailsTree, ITask.class, "show in task list", new SelectionAdapter() |
---|
[1424] | 478 | { |
---|
[1094] | 479 | @Override |
---|
| 480 | public void widgetSelected(SelectionEvent e) { |
---|
[1424] | 481 | navigateTo((ITask) taskDetailsTree.getSelection()[0].getData()); |
---|
[1094] | 482 | } |
---|
| 483 | }); |
---|
[1424] | 484 | |
---|
[2033] | 485 | if (taskExportAvailable) { |
---|
| 486 | VisualizationUtils.addItemSpecificContextMenu |
---|
| 487 | (taskDetailsTree, ITask.class, "export to ConcurTaskTree", new SelectionAdapter() |
---|
| 488 | { |
---|
| 489 | @Override |
---|
| 490 | public void widgetSelected(SelectionEvent e) { |
---|
| 491 | export((ITask) taskDetailsTree.getSelection()[0].getData()); |
---|
| 492 | } |
---|
| 493 | }); |
---|
| 494 | } |
---|
[2127] | 495 | |
---|
| 496 | VisualizationUtils.addItemSpecificContextMenu |
---|
| 497 | (taskDetailsTree, ITask.class, "copy to clipboard", new SelectionAdapter() |
---|
| 498 | { |
---|
| 499 | @Override |
---|
| 500 | public void widgetSelected(SelectionEvent e) { |
---|
| 501 | StringSelection stringSelection = new StringSelection |
---|
| 502 | (taskDetailsTree.getSelection()[0].getData().toString()); |
---|
| 503 | Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); |
---|
| 504 | clpbrd.setContents(stringSelection, null); |
---|
| 505 | } |
---|
| 506 | }); |
---|
[2033] | 507 | |
---|
[1424] | 508 | executionVariantsTree = new Tree(detailsTopSashForm, SWT.BORDER | SWT.SINGLE | SWT.WRAP); |
---|
| 509 | executionVariantsTree.setHeaderVisible(true); |
---|
| 510 | |
---|
| 511 | TreeColumn taskColumn = new TreeColumn(executionVariantsTree, SWT.NONE); |
---|
| 512 | taskColumn.setText("instance variants"); |
---|
| 513 | taskColumn.setAlignment(SWT.LEFT); |
---|
[1094] | 514 | |
---|
[1424] | 515 | // load the correct children on expansion |
---|
| 516 | VisualizationUtils.addExpansionListener(executionVariantsTree, defaultExpansionListener); |
---|
| 517 | |
---|
| 518 | detailsTopSashForm.setWeights(new int[] { 3, 2 }); |
---|
| 519 | |
---|
| 520 | SashForm detailsBottomSashForm = new SashForm(detailsSashForm, SWT.HORIZONTAL); |
---|
| 521 | detailsBottomSashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); |
---|
| 522 | |
---|
| 523 | parentTasks = VisualizationUtils.createTaskDetailsTree |
---|
| 524 | (detailsBottomSashForm, "parent tasks", taskModel); |
---|
| 525 | |
---|
[2033] | 526 | VisualizationUtils.addItemSpecificContextMenu |
---|
| 527 | (parentTasks, ITask.class, "show in task list", new SelectionAdapter() |
---|
[1424] | 528 | { |
---|
[1094] | 529 | @Override |
---|
| 530 | public void widgetSelected(SelectionEvent e) { |
---|
[1424] | 531 | navigateTo((ITask) parentTasks.getSelection()[0].getData()); |
---|
[1094] | 532 | } |
---|
| 533 | }); |
---|
| 534 | |
---|
[2033] | 535 | if (taskExportAvailable) { |
---|
| 536 | VisualizationUtils.addItemSpecificContextMenu |
---|
| 537 | (parentTasks, ITask.class, "export to ConcurTaskTree", new SelectionAdapter() |
---|
| 538 | { |
---|
| 539 | @Override |
---|
| 540 | public void widgetSelected(SelectionEvent e) { |
---|
| 541 | export((ITask) taskDetailsTree.getSelection()[0].getData()); |
---|
| 542 | } |
---|
| 543 | }); |
---|
| 544 | } |
---|
[2127] | 545 | |
---|
| 546 | VisualizationUtils.addItemSpecificContextMenu |
---|
| 547 | (parentTasks, ITask.class, "copy to clipboard", new SelectionAdapter() |
---|
| 548 | { |
---|
| 549 | @Override |
---|
| 550 | public void widgetSelected(SelectionEvent e) { |
---|
| 551 | StringSelection stringSelection = new StringSelection |
---|
| 552 | (taskDetailsTree.getSelection()[0].getData().toString()); |
---|
| 553 | Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); |
---|
| 554 | clpbrd.setContents(stringSelection, null); |
---|
| 555 | } |
---|
| 556 | }); |
---|
[2033] | 557 | |
---|
[1495] | 558 | involvedTargetsTree = |
---|
| 559 | VisualizationUtils.createTargetsTree(detailsBottomSashForm, "involved GUI elements"); |
---|
[1424] | 560 | |
---|
[2033] | 561 | visualizationsComposite = new Composite(rightHandComposite, SWT.NO_BACKGROUND); |
---|
| 562 | visualizationsComposite.setLayout(new GridLayout(1, false)); |
---|
| 563 | visualizationsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); |
---|
| 564 | |
---|
| 565 | new Label(visualizationsComposite, SWT.NONE).setText("Visualization:"); |
---|
| 566 | |
---|
| 567 | rightHandLayout.topControl = detailsComposite; |
---|
| 568 | |
---|
[1424] | 569 | detailsBottomSashForm.setWeights(new int[] { 2, 3 }); |
---|
| 570 | detailsSashForm.setWeights(new int[] { 1, 1 }); |
---|
[1094] | 571 | } |
---|
| 572 | |
---|
| 573 | /** |
---|
[1275] | 574 | * convenience method for creating the display of the instances |
---|
[1094] | 575 | */ |
---|
[1146] | 576 | private void buildInstanceTree() { |
---|
| 577 | List<IUserSession> sessions = taskModel.getUserSessions(); |
---|
[1424] | 578 | |
---|
| 579 | // load the correct children on expansion |
---|
| 580 | VisualizationUtils.addExpansionListener(instanceTree, defaultExpansionListener); |
---|
| 581 | |
---|
[1146] | 582 | TreeItem root = new TreeItem(instanceTree, SWT.NULL); |
---|
| 583 | root.setText(sessions.size() + " sessions"); |
---|
[1153] | 584 | root.setData(taskModel); |
---|
[1146] | 585 | |
---|
[2127] | 586 | // simulate a child |
---|
| 587 | new TreeItem(root, SWT.NULL); |
---|
| 588 | |
---|
| 589 | /*for (IUserSession session : sessions) { |
---|
[1146] | 590 | buildInstanceTree(root, session); |
---|
[2127] | 591 | }*/ |
---|
[1424] | 592 | |
---|
[2127] | 593 | root.setExpanded(false); |
---|
[1094] | 594 | } |
---|
| 595 | |
---|
| 596 | /** |
---|
[1275] | 597 | * convenience method for creating the display of the instances |
---|
[1094] | 598 | */ |
---|
[1294] | 599 | private void buildInstanceTree(TreeItem currentParent, IUserSession session) { |
---|
[1424] | 600 | TreeItem item = new TreeItem(currentParent, SWT.NULL); |
---|
| 601 | item.setText(session.toString()); |
---|
| 602 | item.setData(session); |
---|
[1146] | 603 | |
---|
[1424] | 604 | // simulate a child |
---|
| 605 | new TreeItem(item, SWT.NULL); |
---|
[1146] | 606 | } |
---|
| 607 | |
---|
| 608 | /** |
---|
[1275] | 609 | * convenience method for creating the display of the task model |
---|
[1146] | 610 | */ |
---|
[1153] | 611 | private void buildModelTree(ITaskModel taskModel) { |
---|
[2127] | 612 | VisualizationUtils.addExpansionListener(modelTree, defaultExpansionListener); |
---|
| 613 | |
---|
[1424] | 614 | Collection<ITask> allTasks = taskModel.getTasks(); |
---|
[1153] | 615 | |
---|
[2147] | 616 | TreeMap<Integer, ITask> sequences = new TreeMap<>(); |
---|
| 617 | TreeMap<Integer, ITask> iterations = new TreeMap<>(); |
---|
| 618 | TreeMap<Integer, ITask> selections = new TreeMap<>(); |
---|
| 619 | TreeMap<Integer, ITask> optionals = new TreeMap<>(); |
---|
| 620 | TreeMap<Integer, ITask> others = new TreeMap<>(); |
---|
[1153] | 621 | |
---|
| 622 | TreeItem root = new TreeItem(modelTree, SWT.NULL); |
---|
[1424] | 623 | root.setText(allTasks.size() + " tasks in model"); |
---|
[1153] | 624 | root.setData(taskModel); |
---|
| 625 | |
---|
[2147] | 626 | createSortedTaskMaps(allTasks, sequences, iterations, selections, optionals, others); |
---|
[1153] | 627 | |
---|
[1424] | 628 | //allTasks = createSortedTaskList(allTasks); |
---|
[1153] | 629 | |
---|
[1424] | 630 | createModelTreeItemFor(sequences, sequences.size() + " Sequences", root); |
---|
| 631 | createModelTreeItemFor(iterations, iterations.size() + " Iterations", root); |
---|
| 632 | createModelTreeItemFor(selections, selections.size() + " Selections", root); |
---|
| 633 | createModelTreeItemFor(optionals, optionals.size() + " Optionals", root); |
---|
| 634 | createModelTreeItemFor(others, others.size() + " other Tasks", root); |
---|
| 635 | |
---|
[1153] | 636 | root.setExpanded(true); |
---|
| 637 | } |
---|
| 638 | |
---|
| 639 | /** |
---|
[1424] | 640 | * |
---|
[1153] | 641 | */ |
---|
[2147] | 642 | private void createSortedTaskMaps(Collection<ITask> allTasks, |
---|
| 643 | TreeMap<Integer, ITask> sequences, |
---|
| 644 | TreeMap<Integer, ITask> iterations, |
---|
| 645 | TreeMap<Integer, ITask> selections, |
---|
| 646 | TreeMap<Integer, ITask> optionals, |
---|
| 647 | TreeMap<Integer, ITask> others) |
---|
[1424] | 648 | { |
---|
[2147] | 649 | TreeMap<Integer, ITask> toAdd; |
---|
[1153] | 650 | |
---|
[1424] | 651 | for (ITask task : allTasks) { |
---|
| 652 | if (task instanceof ISequence) { |
---|
| 653 | toAdd = sequences; |
---|
| 654 | } |
---|
| 655 | else if (task instanceof IIteration) { |
---|
| 656 | toAdd = iterations; |
---|
| 657 | } |
---|
| 658 | else if (task instanceof ISelection) { |
---|
| 659 | toAdd = selections; |
---|
| 660 | } |
---|
| 661 | else if (task instanceof IOptional) { |
---|
| 662 | toAdd = optionals; |
---|
| 663 | } |
---|
| 664 | else { |
---|
| 665 | toAdd = others; |
---|
| 666 | } |
---|
| 667 | |
---|
[1636] | 668 | int taskValue = taskModel.getTaskInfo(task).getMeasureValue(TaskMetric.EVENT_COVERAGE); |
---|
[2147] | 669 | toAdd.put(taskValue, task); |
---|
[1424] | 670 | } |
---|
[1146] | 671 | } |
---|
| 672 | |
---|
| 673 | /** |
---|
[1424] | 674 | * |
---|
[1146] | 675 | */ |
---|
[1424] | 676 | private void clearTaskDetails() { |
---|
| 677 | taskDetailsTree.removeAll(); |
---|
| 678 | executionVariantsTree.removeAll(); |
---|
[1495] | 679 | involvedTargetsTree.removeAll(); |
---|
[1424] | 680 | parentTasks.removeAll(); |
---|
| 681 | } |
---|
| 682 | |
---|
| 683 | /** |
---|
| 684 | * |
---|
| 685 | */ |
---|
| 686 | private void displayTaskDetails(ITask task) { |
---|
| 687 | clearTaskDetails(); |
---|
[1146] | 688 | |
---|
[1424] | 689 | VisualizationUtils.createTreeItemFor(task, taskDetailsTree, taskModel, true); |
---|
| 690 | VisualizationUtils.expandAll(taskDetailsTree, true); |
---|
[1153] | 691 | |
---|
[1424] | 692 | // do it twice. Otherwise, it doesn't work |
---|
| 693 | VisualizationUtils.updateColumnWidths(taskDetailsTree); |
---|
[1262] | 694 | |
---|
[1424] | 695 | Collection<Collection<ITaskInstance>> executionVariants = task.getExecutionVariants(); |
---|
| 696 | List<Collection<ITaskInstance>> sortedExecutionVariants = |
---|
| 697 | new LinkedList<Collection<ITaskInstance>>(executionVariants); |
---|
| 698 | |
---|
| 699 | Collections.sort(sortedExecutionVariants, new Comparator<Collection<ITaskInstance>>() { |
---|
[1262] | 700 | @Override |
---|
[1424] | 701 | public int compare(Collection<ITaskInstance> list1, Collection<ITaskInstance> list2) { |
---|
| 702 | return list2.size() - list1.size(); |
---|
[1262] | 703 | } |
---|
| 704 | }); |
---|
| 705 | |
---|
[1424] | 706 | int counter = 1; |
---|
| 707 | for (Collection<ITaskInstance> variant : sortedExecutionVariants) { |
---|
| 708 | TreeItem item = new TreeItem(executionVariantsTree, SWT.NULL); |
---|
| 709 | if (variant.size() > 1) { |
---|
| 710 | item.setText("variant " + counter++ + " (executed " + variant.size() + " times)"); |
---|
| 711 | } |
---|
| 712 | else { |
---|
| 713 | item.setText("variant " + counter++ + " (executed once)"); |
---|
| 714 | } |
---|
| 715 | item.setData(variant); |
---|
| 716 | |
---|
| 717 | createTreeItemFor(variant.iterator().next(), item); |
---|
| 718 | } |
---|
| 719 | |
---|
| 720 | VisualizationUtils.expandAll(executionVariantsTree, true); |
---|
| 721 | VisualizationUtils.updateColumnWidths(executionVariantsTree); |
---|
| 722 | |
---|
| 723 | addParentTasks(task); |
---|
| 724 | VisualizationUtils.updateColumnWidths(parentTasks); |
---|
| 725 | |
---|
[1495] | 726 | VisualizationUtils.addInvolvedTargets(involvedTargetsTree, task); |
---|
[1153] | 727 | } |
---|
| 728 | |
---|
| 729 | /** |
---|
[1424] | 730 | * |
---|
[1153] | 731 | */ |
---|
[1424] | 732 | private void addParentTasks(ITask task) { |
---|
| 733 | for (ITask candidate : taskModel.getTasks()) { |
---|
| 734 | if (((candidate instanceof IStructuringTemporalRelationship) && |
---|
| 735 | (((IStructuringTemporalRelationship) candidate).getChildren().contains(task))) || |
---|
| 736 | ((candidate instanceof IMarkingTemporalRelationship) && |
---|
| 737 | (((IMarkingTemporalRelationship) candidate).getMarkedTask().equals(task)))) |
---|
| 738 | { |
---|
| 739 | VisualizationUtils.createTreeItemFor(candidate, parentTasks, taskModel, false); |
---|
[1094] | 740 | } |
---|
| 741 | } |
---|
| 742 | } |
---|
| 743 | |
---|
| 744 | /** |
---|
[1424] | 745 | * |
---|
[1094] | 746 | */ |
---|
[1424] | 747 | private void navigateTo(ITask task) { |
---|
| 748 | tabFolder.setSelection(1); |
---|
[1153] | 749 | |
---|
[1424] | 750 | OUTER: |
---|
| 751 | for (TreeItem sublist : modelTree.getItem(0).getItems()) { |
---|
| 752 | for (TreeItem taskItem : sublist.getItems()) { |
---|
| 753 | if (task.equals(taskItem.getData())) { |
---|
| 754 | modelTree.setSelection(taskItem); |
---|
| 755 | sublist.setExpanded(true); |
---|
| 756 | VisualizationUtils.updateColumnWidths(modelTree); |
---|
| 757 | break OUTER; |
---|
| 758 | } |
---|
[1153] | 759 | } |
---|
| 760 | } |
---|
[1424] | 761 | |
---|
| 762 | displayTaskDetails(task); |
---|
[1094] | 763 | } |
---|
[2033] | 764 | |
---|
| 765 | /** |
---|
| 766 | * |
---|
| 767 | */ |
---|
| 768 | private void export(ITask task) { |
---|
| 769 | try { |
---|
| 770 | Class<?> exportClass = this.getClass().getClassLoader().loadClass |
---|
| 771 | ("de.ugoe.cs.autoquest.plugin.exports.tasktree.CTTExportUtils"); |
---|
| 772 | |
---|
| 773 | Method method = exportClass.getDeclaredMethod("exportToCTT", ITask.class, String.class); |
---|
| 774 | |
---|
| 775 | method.invoke(null, task, task.getId() + "_ctte.xml"); |
---|
| 776 | } |
---|
| 777 | catch (Exception e) { |
---|
| 778 | Console.logException(e); |
---|
| 779 | } |
---|
| 780 | } |
---|
[1094] | 781 | |
---|
[1153] | 782 | /** |
---|
[1275] | 783 | * ensures, that the children of a specific node are loaded |
---|
[1153] | 784 | */ |
---|
| 785 | private void ensureChildren(TreeItem parent) { |
---|
[1424] | 786 | TreeItem[] items = parent.getItems(); |
---|
| 787 | if ((items == null) || (items.length == 0) || (items[0].getData() == null)) { |
---|
| 788 | if (items != null) { |
---|
| 789 | for (int i = 0; i < items.length; i++) { |
---|
| 790 | items[i].dispose(); |
---|
[1153] | 791 | } |
---|
[1424] | 792 | } |
---|
[1153] | 793 | |
---|
[1424] | 794 | if (parent.getData() instanceof ITask) { |
---|
[1153] | 795 | ITask task = (ITask) parent.getData(); |
---|
| 796 | |
---|
| 797 | if (task instanceof IStructuringTemporalRelationship) { |
---|
| 798 | for (ITask subTask : ((IStructuringTemporalRelationship) task).getChildren()) { |
---|
[1424] | 799 | VisualizationUtils.createTreeItemFor(subTask, parent, taskModel, true); |
---|
[1153] | 800 | } |
---|
| 801 | } |
---|
| 802 | else if (task instanceof IMarkingTemporalRelationship) { |
---|
[1424] | 803 | VisualizationUtils.createTreeItemFor |
---|
| 804 | (((IMarkingTemporalRelationship) task).getMarkedTask(), parent, |
---|
| 805 | taskModel, true); |
---|
[1153] | 806 | } |
---|
| 807 | } |
---|
[1424] | 808 | else if (parent.getData() instanceof List<?>) { |
---|
| 809 | @SuppressWarnings("unchecked") |
---|
| 810 | List<ITask> tasks = (List<ITask>) parent.getData(); |
---|
| 811 | for (ITask task : tasks) { |
---|
| 812 | VisualizationUtils.createTreeItemFor(task, parent, taskModel, false); |
---|
| 813 | } |
---|
| 814 | } |
---|
| 815 | else if (parent.getData() instanceof ITaskInstanceList) { |
---|
| 816 | for (ITaskInstance subInstance : (ITaskInstanceList) parent.getData()) { |
---|
| 817 | createTreeItemFor(subInstance, parent); |
---|
| 818 | } |
---|
| 819 | } |
---|
| 820 | else if (parent.getData() instanceof ITaskInstance) { |
---|
| 821 | ITaskInstance instance = (ITaskInstance) parent.getData(); |
---|
| 822 | |
---|
| 823 | if (instance instanceof ISelectionInstance) { |
---|
| 824 | if (((ISelectionInstance) instance).getChild() != null) { |
---|
| 825 | createTreeItemFor(((ISelectionInstance) instance).getChild(), parent); |
---|
| 826 | } |
---|
| 827 | } |
---|
| 828 | else if (instance instanceof IOptionalInstance) { |
---|
| 829 | if (((IOptionalInstance) instance).getChild() != null) { |
---|
| 830 | createTreeItemFor(((IOptionalInstance) instance).getChild(), parent); |
---|
| 831 | } |
---|
| 832 | } |
---|
| 833 | } |
---|
[2127] | 834 | else if (parent.getData() instanceof ITaskModel) { |
---|
| 835 | ITaskModel taskModel = (ITaskModel) parent.getData(); |
---|
| 836 | |
---|
| 837 | for (IUserSession session : taskModel.getUserSessions()) { |
---|
| 838 | buildInstanceTree(parent, session); |
---|
| 839 | } |
---|
| 840 | } |
---|
[1153] | 841 | } |
---|
| 842 | } |
---|
| 843 | |
---|
| 844 | /** |
---|
[1424] | 845 | * |
---|
| 846 | */ |
---|
[2147] | 847 | private void createModelTreeItemFor(TreeMap<Integer, ITask> taskMap, |
---|
| 848 | String name, |
---|
| 849 | TreeItem parent) |
---|
| 850 | { |
---|
| 851 | ITask[] tasks = new ITask[taskMap.size()]; |
---|
| 852 | |
---|
| 853 | // reverse the order |
---|
| 854 | int i = 1; |
---|
| 855 | for (ITask task : taskMap.values()) { |
---|
| 856 | tasks[tasks.length - i++] = task; |
---|
| 857 | } |
---|
| 858 | |
---|
| 859 | // create an array list for efficient access |
---|
| 860 | List<ITask> taskList = new ArrayList<ITask>(); |
---|
| 861 | |
---|
| 862 | for (ITask task : tasks) { |
---|
| 863 | taskList.add(task); |
---|
| 864 | } |
---|
| 865 | |
---|
| 866 | |
---|
[1424] | 867 | TreeItem item = new TreeItem(parent, SWT.NULL); |
---|
| 868 | item.setText(name); |
---|
| 869 | item.setData(taskList); |
---|
| 870 | |
---|
| 871 | // simulate a child |
---|
| 872 | if (taskList.size() > 0) { |
---|
[2127] | 873 | new TreeItem(item, SWT.NULL); |
---|
| 874 | /*for (ITask task : taskList) { |
---|
[1424] | 875 | VisualizationUtils.createTreeItemFor(task, item, taskModel, false); |
---|
[2127] | 876 | }*/ |
---|
[1424] | 877 | } |
---|
| 878 | } |
---|
| 879 | |
---|
| 880 | /** |
---|
[1275] | 881 | * convenience method to create a tree item for a task |
---|
[1153] | 882 | */ |
---|
[1424] | 883 | private void createTreeItemFor(ITaskInstance taskInstance, |
---|
| 884 | TreeItem parent) |
---|
| 885 | { |
---|
[1153] | 886 | TreeItem item = new TreeItem(parent, SWT.NULL); |
---|
[1424] | 887 | item.setText(taskInstance.toString()); |
---|
| 888 | item.setData(taskInstance); |
---|
[1153] | 889 | |
---|
| 890 | // simulate a child |
---|
[1424] | 891 | if ((taskInstance instanceof ITaskInstanceList) || |
---|
| 892 | (taskInstance instanceof ISelectionInstance) || |
---|
| 893 | (taskInstance instanceof IOptionalInstance)) |
---|
[1153] | 894 | { |
---|
| 895 | new TreeItem(item, SWT.NULL); |
---|
| 896 | } |
---|
| 897 | } |
---|
[2033] | 898 | |
---|
| 899 | /** |
---|
| 900 | * |
---|
| 901 | */ |
---|
| 902 | private void showVisualization(String name) { |
---|
| 903 | Color backgroundColor = visualizationsComposite.getBackground(); |
---|
| 904 | Composite parent = new Composite(visualizationsComposite, SWT.EMBEDDED); |
---|
| 905 | parent.setLayout(new GridLayout(1, false)); |
---|
| 906 | parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); |
---|
| 907 | |
---|
| 908 | Frame chartFrame = SWT_AWT.new_Frame(parent); |
---|
| 909 | chartFrame.setBackground(new java.awt.Color(backgroundColor.getRed(), |
---|
| 910 | backgroundColor.getGreen(), |
---|
| 911 | backgroundColor.getBlue())); |
---|
| 912 | |
---|
| 913 | chartFrame.setLayout(new java.awt.GridLayout()); |
---|
| 914 | |
---|
| 915 | List<ITaskModel> models = new LinkedList<>(); |
---|
| 916 | models.add(taskModel); |
---|
| 917 | |
---|
| 918 | List<String> names = new LinkedList<>(); |
---|
| 919 | names.add(name); |
---|
| 920 | |
---|
| 921 | List<Integer> groups = new LinkedList<>(); |
---|
| 922 | groups.add(0); |
---|
| 923 | |
---|
| 924 | JFreeChart chart = TaskTreePlotUtils.createPlot(name, models, names, groups); |
---|
| 925 | chartFrame.add(new ChartPanel(chart)); |
---|
| 926 | |
---|
| 927 | modelVisualizationTree.getSelection()[0].setData(chart); |
---|
| 928 | |
---|
| 929 | rightHandComposite.layout(); |
---|
| 930 | rightHandComposite.redraw(); |
---|
| 931 | rightHandComposite.update(); |
---|
| 932 | } |
---|
| 933 | |
---|
| 934 | /** |
---|
| 935 | * |
---|
| 936 | */ |
---|
| 937 | private void clearVisualization() { |
---|
| 938 | for (Control child : visualizationsComposite.getChildren()) { |
---|
| 939 | child.dispose(); |
---|
| 940 | } |
---|
| 941 | |
---|
| 942 | visualizationsComposite.pack(); |
---|
| 943 | } |
---|
[1094] | 944 | } |
---|