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