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