Commit | Line | Data |
---|---|---|
8f91a789 | 1 | /******************************************************************************* |
ed902a2b | 2 | * Copyright (c) 2000, 2014 IBM Corporation and others. |
8f91a789 AM |
3 | * All rights reserved. This program and the accompanying materials |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
7 | * | |
8 | * Contributors: | |
9 | * IBM Corporation - initial API and implementation | |
10 | * Sebastian Davids <sdavids@gmx.de> - Fix for bug 19346 - Dialog font should be | |
11 | * activated and used by other components. | |
12 | * Lubomir Marinov <lubomir.marinov@gmail.com> - Fix for bug 182122 -[Dialogs] | |
13 | * CheckedTreeSelectionDialog#createSelectionButtons(Composite) fails to | |
14 | * align the selection buttons to the right | |
15 | * François Rajotte - Support for multiple columns + selection control | |
f1fae91f | 16 | * Patrick Tasse - Fix Sonar warnings |
40b7b614 | 17 | * Generoso Pagano - Add tree filter |
8f91a789 AM |
18 | *******************************************************************************/ |
19 | ||
2bdf0193 | 20 | package org.eclipse.tracecompass.tmf.ui.widgets.timegraph.dialogs; |
8f91a789 AM |
21 | |
22 | import java.util.ArrayList; | |
23 | import java.util.Arrays; | |
24 | import java.util.List; | |
25 | ||
26 | import org.eclipse.core.runtime.IStatus; | |
27 | import org.eclipse.core.runtime.Status; | |
28 | import org.eclipse.jface.dialogs.IDialogConstants; | |
29 | import org.eclipse.jface.viewers.CheckStateChangedEvent; | |
30 | import org.eclipse.jface.viewers.CheckboxTreeViewer; | |
31 | import org.eclipse.jface.viewers.IBaseLabelProvider; | |
32 | import org.eclipse.jface.viewers.ICheckStateListener; | |
33 | import org.eclipse.jface.viewers.ITreeContentProvider; | |
8906e53c | 34 | import org.eclipse.jface.viewers.TreeSelection; |
8f91a789 AM |
35 | import org.eclipse.jface.viewers.ViewerComparator; |
36 | import org.eclipse.jface.viewers.ViewerFilter; | |
8f91a789 AM |
37 | import org.eclipse.swt.SWT; |
38 | import org.eclipse.swt.custom.BusyIndicator; | |
39 | import org.eclipse.swt.events.SelectionAdapter; | |
40 | import org.eclipse.swt.events.SelectionEvent; | |
8f91a789 AM |
41 | import org.eclipse.swt.layout.GridData; |
42 | import org.eclipse.swt.layout.GridLayout; | |
43 | import org.eclipse.swt.widgets.Button; | |
44 | import org.eclipse.swt.widgets.Composite; | |
45 | import org.eclipse.swt.widgets.Control; | |
46 | import org.eclipse.swt.widgets.Label; | |
47 | import org.eclipse.swt.widgets.Shell; | |
48 | import org.eclipse.swt.widgets.Tree; | |
49 | import org.eclipse.swt.widgets.TreeColumn; | |
2bdf0193 AM |
50 | import org.eclipse.tracecompass.internal.tmf.ui.Messages; |
51 | import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry; | |
8f91a789 | 52 | import org.eclipse.ui.PlatformUI; |
8f91a789 | 53 | import org.eclipse.ui.dialogs.ISelectionStatusValidator; |
40b7b614 | 54 | import org.eclipse.ui.dialogs.PatternFilter; |
8f91a789 AM |
55 | import org.eclipse.ui.dialogs.SelectionStatusDialog; |
56 | ||
57 | /** | |
40b7b614 GP |
58 | * Filter dialog for the time graphs This class is derived from the |
59 | * CheckedTreeSelectionDialog It was necessary to develop this similar dialog to | |
60 | * allow multiple columns | |
8f91a789 AM |
61 | * |
62 | * @version 1.0 | |
63 | * @since 2.0 | |
64 | * @author François Rajotte | |
65 | */ | |
66 | public class TimeGraphFilterDialog extends SelectionStatusDialog { | |
f1fae91f PT |
67 | private static final int BUTTON_CHECK_SELECTED_ID = IDialogConstants.CLIENT_ID; |
68 | private static final int BUTTON_UNCHECK_SELECTED_ID = IDialogConstants.CLIENT_ID + 1; | |
69 | private static final int BUTTON_CHECK_SUBTREE_ID = IDialogConstants.CLIENT_ID + 2; | |
70 | private static final int BUTTON_UNCHECK_SUBTREE_ID = IDialogConstants.CLIENT_ID + 3; | |
03beb743 | 71 | |
f1fae91f PT |
72 | private static final int DEFAULT_WIDTH = 60; |
73 | private static final int DEFAULT_HEIGHT = 18; | |
8f91a789 | 74 | |
40b7b614 | 75 | private FilteredCheckboxTree fTree; |
8f91a789 AM |
76 | |
77 | private IBaseLabelProvider fLabelProvider; | |
78 | ||
79 | private ITreeContentProvider fContentProvider; | |
80 | ||
81 | private String[] fColumnNames; | |
82 | ||
83 | private ISelectionStatusValidator fValidator = null; | |
84 | ||
85 | private ViewerComparator fComparator; | |
86 | ||
87 | private String fEmptyListMessage = ""; //$NON-NLS-1$ | |
88 | ||
89 | private IStatus fCurrStatus = new Status(IStatus.OK, PlatformUI.PLUGIN_ID, | |
90 | 0, "", null); //$NON-NLS-1$ | |
91 | ||
92 | private List<ViewerFilter> fFilters; | |
93 | ||
94 | private Object fInput; | |
95 | ||
96 | private boolean fIsEmpty; | |
97 | ||
f1fae91f | 98 | private int fWidth = DEFAULT_WIDTH; |
8f91a789 | 99 | |
f1fae91f | 100 | private int fHeight = DEFAULT_HEIGHT; |
8f91a789 | 101 | |
8f91a789 AM |
102 | private Object[] fExpandedElements; |
103 | ||
104 | /** | |
105 | * Constructs an instance of <code>ElementTreeSelectionDialog</code>. | |
106 | * | |
107 | * @param parent | |
108 | * The shell to parent from. | |
109 | */ | |
110 | public TimeGraphFilterDialog(Shell parent) { | |
111 | super(parent); | |
507b1336 | 112 | setResult(new ArrayList<>(0)); |
8f91a789 AM |
113 | setStatusLineAboveButtons(true); |
114 | setHelpAvailable(false); | |
8f91a789 AM |
115 | fExpandedElements = null; |
116 | } | |
117 | ||
8f91a789 AM |
118 | /** |
119 | * Sets the initial selection. Convenience method. | |
120 | * | |
121 | * @param selection | |
122 | * the initial selection. | |
123 | */ | |
124 | public void setInitialSelection(Object selection) { | |
125 | setInitialSelections(new Object[] { selection }); | |
126 | } | |
127 | ||
128 | /** | |
129 | * Sets the message to be displayed if the list is empty. | |
130 | * | |
131 | * @param message | |
132 | * the message to be displayed. | |
133 | */ | |
134 | public void setEmptyListMessage(String message) { | |
135 | fEmptyListMessage = message; | |
136 | } | |
137 | ||
138 | /** | |
139 | * Sets the comparator used by the tree viewer. | |
140 | * | |
141 | * @param comparator | |
142 | * The comparator | |
143 | */ | |
144 | public void setComparator(ViewerComparator comparator) { | |
145 | fComparator = comparator; | |
146 | } | |
147 | ||
148 | /** | |
149 | * Adds a filter to the tree viewer. | |
150 | * | |
151 | * @param filter | |
152 | * a filter. | |
153 | */ | |
154 | public void addFilter(ViewerFilter filter) { | |
155 | if (fFilters == null) { | |
507b1336 | 156 | fFilters = new ArrayList<>(); |
8f91a789 AM |
157 | } |
158 | fFilters.add(filter); | |
159 | } | |
160 | ||
161 | /** | |
162 | * Sets an optional validator to check if the selection is valid. The | |
163 | * validator is invoked whenever the selection changes. | |
164 | * | |
165 | * @param validator | |
166 | * the validator to validate the selection. | |
167 | */ | |
168 | public void setValidator(ISelectionStatusValidator validator) { | |
169 | fValidator = validator; | |
170 | } | |
171 | ||
172 | /** | |
173 | * Sets the tree input. | |
174 | * | |
175 | * @param input | |
176 | * the tree input. | |
177 | */ | |
178 | public void setInput(Object input) { | |
179 | fInput = input; | |
180 | } | |
181 | ||
182 | /** | |
183 | * Expands elements in the tree. | |
184 | * | |
185 | * @param elements | |
186 | * The elements that will be expanded. | |
187 | */ | |
188 | public void setExpandedElements(Object[] elements) { | |
f1fae91f PT |
189 | if (elements != null) { |
190 | fExpandedElements = Arrays.copyOf(elements, elements.length); | |
191 | } else { | |
192 | fExpandedElements = null; | |
193 | } | |
8f91a789 AM |
194 | } |
195 | ||
196 | /** | |
197 | * Sets the size of the tree in unit of characters. | |
198 | * | |
199 | * @param width | |
200 | * the width of the tree. | |
201 | * @param height | |
202 | * the height of the tree. | |
203 | */ | |
204 | public void setSize(int width, int height) { | |
205 | fWidth = width; | |
206 | fHeight = height; | |
207 | } | |
208 | ||
209 | /** | |
40b7b614 GP |
210 | * @param contentProvider |
211 | * The content provider for the table | |
8f91a789 AM |
212 | */ |
213 | public void setContentProvider(ITreeContentProvider contentProvider) { | |
214 | fContentProvider = contentProvider; | |
215 | } | |
216 | ||
217 | /** | |
40b7b614 GP |
218 | * @param labelProvider |
219 | * The label provider for the table | |
8f91a789 AM |
220 | */ |
221 | public void setLabelProvider(IBaseLabelProvider labelProvider) { | |
222 | fLabelProvider = labelProvider; | |
223 | } | |
224 | ||
225 | /** | |
40b7b614 GP |
226 | * @param columnNames |
227 | * An array of column names to display | |
8f91a789 AM |
228 | */ |
229 | public void setColumnNames(String[] columnNames) { | |
f1fae91f PT |
230 | if (columnNames != null) { |
231 | fColumnNames = Arrays.copyOf(columnNames, columnNames.length); | |
232 | } else { | |
233 | fColumnNames = null; | |
234 | } | |
8f91a789 AM |
235 | } |
236 | ||
237 | /** | |
238 | * Validate the receiver and update the status with the result. | |
239 | * | |
240 | */ | |
241 | protected void updateOKStatus() { | |
242 | if (!fIsEmpty) { | |
243 | if (fValidator != null) { | |
40b7b614 | 244 | fCurrStatus = fValidator.validate(fTree.getCheckedElements()); |
8f91a789 AM |
245 | updateStatus(fCurrStatus); |
246 | } else if (!fCurrStatus.isOK()) { | |
247 | fCurrStatus = new Status(IStatus.OK, PlatformUI.PLUGIN_ID, | |
248 | IStatus.OK, "", //$NON-NLS-1$ | |
249 | null); | |
250 | } | |
251 | } else { | |
252 | fCurrStatus = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, | |
253 | IStatus.OK, fEmptyListMessage, null); | |
254 | } | |
255 | updateStatus(fCurrStatus); | |
256 | } | |
257 | ||
258 | @Override | |
259 | public int open() { | |
260 | fIsEmpty = evaluateIfTreeEmpty(fInput); | |
261 | super.open(); | |
262 | return getReturnCode(); | |
263 | } | |
264 | ||
8f91a789 AM |
265 | @Override |
266 | protected void cancelPressed() { | |
267 | setResult(null); | |
268 | super.cancelPressed(); | |
269 | } | |
270 | ||
271 | @Override | |
272 | protected void computeResult() { | |
40b7b614 | 273 | setResult(Arrays.asList(fTree.getCheckedElements())); |
8f91a789 AM |
274 | } |
275 | ||
276 | @Override | |
277 | public void create() { | |
278 | BusyIndicator.showWhile(null, new Runnable() { | |
279 | @Override | |
280 | public void run() { | |
f1fae91f | 281 | TimeGraphFilterDialog.super.create(); |
40b7b614 | 282 | fTree.setCheckedElements(getInitialElementSelections() |
8f91a789 AM |
283 | .toArray()); |
284 | if (fExpandedElements != null) { | |
40b7b614 | 285 | fTree.getViewer().setExpandedElements(fExpandedElements); |
8f91a789 AM |
286 | } |
287 | updateOKStatus(); | |
288 | } | |
289 | }); | |
290 | } | |
291 | ||
292 | @Override | |
293 | protected Control createDialogArea(Composite parent) { | |
294 | Composite composite = (Composite) super.createDialogArea(parent); | |
295 | Label messageLabel = createMessageArea(composite); | |
296 | CheckboxTreeViewer treeViewer = createTreeViewer(composite); | |
297 | Control buttonComposite = createSelectionButtons(composite); | |
298 | GridData data = new GridData(GridData.FILL_BOTH); | |
299 | data.widthHint = convertWidthInCharsToPixels(fWidth); | |
300 | data.heightHint = convertHeightInCharsToPixels(fHeight); | |
301 | Tree treeWidget = treeViewer.getTree(); | |
302 | treeWidget.setLayoutData(data); | |
303 | treeWidget.setFont(parent.getFont()); | |
304 | if (fIsEmpty) { | |
305 | messageLabel.setEnabled(false); | |
306 | treeWidget.setEnabled(false); | |
307 | buttonComposite.setEnabled(false); | |
308 | } | |
309 | return composite; | |
310 | } | |
311 | ||
312 | /** | |
313 | * Creates the tree viewer. | |
314 | * | |
315 | * @param parent | |
316 | * the parent composite | |
317 | * @return the tree viewer | |
318 | */ | |
319 | protected CheckboxTreeViewer createTreeViewer(Composite parent) { | |
40b7b614 GP |
320 | PatternFilter filter = new TreePatternFilter(); |
321 | filter.setIncludeLeadingWildcard(true); | |
322 | fTree = new FilteredCheckboxTree(parent, SWT.BORDER | SWT.MULTI, filter, true); | |
8f91a789 | 323 | |
40b7b614 | 324 | Tree tree = fTree.getViewer().getTree(); |
8f91a789 AM |
325 | tree.setHeaderVisible(true); |
326 | for (String columnName : fColumnNames) { | |
327 | TreeColumn column = new TreeColumn(tree, SWT.LEFT); | |
328 | column.setText(columnName); | |
329 | column.pack(); | |
330 | } | |
331 | ||
40b7b614 GP |
332 | fTree.getViewer().setContentProvider(fContentProvider); |
333 | fTree.getViewer().setLabelProvider(fLabelProvider); | |
334 | fTree.addCheckStateListener(new CheckStateListener()); | |
335 | fTree.getViewer().setComparator(fComparator); | |
8f91a789 AM |
336 | if (fFilters != null) { |
337 | for (int i = 0; i != fFilters.size(); i++) { | |
40b7b614 | 338 | fTree.getViewer().addFilter(fFilters.get(i)); |
8f91a789 AM |
339 | } |
340 | } | |
40b7b614 | 341 | fTree.getViewer().setInput(fInput); |
8f91a789 | 342 | |
40b7b614 | 343 | // pack the columns again for a nice view... |
8f91a789 AM |
344 | for (TreeColumn column : tree.getColumns()) { |
345 | column.pack(); | |
346 | } | |
40b7b614 | 347 | return (CheckboxTreeViewer) fTree.getViewer(); |
8f91a789 AM |
348 | } |
349 | ||
350 | /** | |
351 | * Returns the tree viewer. | |
352 | * | |
353 | * @return the tree viewer | |
354 | */ | |
355 | protected CheckboxTreeViewer getTreeViewer() { | |
40b7b614 | 356 | return (CheckboxTreeViewer) fTree.getViewer(); |
8f91a789 AM |
357 | } |
358 | ||
359 | /** | |
360 | * Adds the selection and deselection buttons to the dialog. | |
361 | * | |
362 | * @param composite | |
363 | * the parent composite | |
364 | * @return Composite the composite the buttons were created in. | |
365 | */ | |
366 | protected Composite createSelectionButtons(Composite composite) { | |
367 | Composite buttonComposite = new Composite(composite, SWT.RIGHT); | |
368 | GridLayout layout = new GridLayout(); | |
8f91a789 AM |
369 | layout.marginWidth = 0; |
370 | layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); | |
371 | buttonComposite.setLayout(layout); | |
372 | buttonComposite.setFont(composite.getFont()); | |
373 | GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END | |
374 | | GridData.GRAB_HORIZONTAL); | |
375 | data.grabExcessHorizontalSpace = true; | |
376 | buttonComposite.setLayoutData(data); | |
8906e53c SM |
377 | |
378 | /* Create the buttons in the good order to place them as we want */ | |
03beb743 SM |
379 | Button checkSelectedButton = createButton(buttonComposite, |
380 | BUTTON_CHECK_SELECTED_ID, Messages.TmfTimeFilterDialog_CHECK_SELECTED, | |
381 | false); | |
382 | Button checkSubtreeButton = createButton(buttonComposite, | |
383 | BUTTON_CHECK_SUBTREE_ID, Messages.TmfTimeFilterDialog_CHECK_SUBTREE, | |
384 | false); | |
8906e53c SM |
385 | Button checkAllButton = createButton(buttonComposite, |
386 | IDialogConstants.SELECT_ALL_ID, Messages.TmfTimeFilterDialog_CHECK_ALL, | |
387 | false); | |
03beb743 SM |
388 | |
389 | Button uncheckSelectedButton = createButton(buttonComposite, | |
390 | BUTTON_UNCHECK_SELECTED_ID, Messages.TmfTimeFilterDialog_UNCHECK_SELECTED, | |
391 | false); | |
392 | Button uncheckSubtreeButton = createButton(buttonComposite, | |
393 | BUTTON_UNCHECK_SUBTREE_ID, Messages.TmfTimeFilterDialog_UNCHECK_SUBTREE, | |
8906e53c SM |
394 | false); |
395 | Button uncheckAllButton = createButton(buttonComposite, | |
396 | IDialogConstants.DESELECT_ALL_ID, Messages.TmfTimeFilterDialog_UNCHECK_ALL, | |
397 | false); | |
03beb743 | 398 | |
8906e53c SM |
399 | /* |
400 | * Apply the layout again after creating the buttons to override | |
401 | * createButton messing with the columns | |
402 | */ | |
03beb743 | 403 | layout.numColumns = 3; |
8906e53c SM |
404 | buttonComposite.setLayout(layout); |
405 | ||
406 | /* Add a listener to each button */ | |
03beb743 | 407 | checkSelectedButton.addSelectionListener(new SelectionAdapter() { |
8f91a789 AM |
408 | @Override |
409 | public void widgetSelected(SelectionEvent e) { | |
40b7b614 | 410 | TreeSelection selection = (TreeSelection) fTree.getViewer().getSelection(); |
8906e53c | 411 | |
03beb743 SM |
412 | for (Object element : selection.toArray()) { |
413 | checkElement(element); | |
8f91a789 | 414 | } |
8906e53c | 415 | |
8f91a789 AM |
416 | updateOKStatus(); |
417 | } | |
8906e53c SM |
418 | }); |
419 | ||
03beb743 | 420 | checkSubtreeButton.addSelectionListener(new SelectionAdapter() { |
8f91a789 AM |
421 | @Override |
422 | public void widgetSelected(SelectionEvent e) { | |
40b7b614 | 423 | TreeSelection selection = (TreeSelection) fTree.getViewer().getSelection(); |
03beb743 SM |
424 | |
425 | for (Object element : selection.toArray()) { | |
426 | checkElementAndSubtree(element); | |
427 | } | |
428 | } | |
429 | }); | |
430 | ||
431 | checkAllButton.addSelectionListener(new SelectionAdapter() { | |
432 | @Override | |
433 | public void widgetSelected(SelectionEvent e) { | |
434 | Object[] viewerElements = fContentProvider.getElements(fInput); | |
435 | ||
436 | for (int i = 0; i < viewerElements.length; i++) { | |
40b7b614 | 437 | fTree.setSubtreeChecked(viewerElements[i], true); |
03beb743 SM |
438 | } |
439 | ||
8f91a789 AM |
440 | updateOKStatus(); |
441 | } | |
8906e53c SM |
442 | }); |
443 | ||
03beb743 | 444 | uncheckSelectedButton.addSelectionListener(new SelectionAdapter() { |
8906e53c SM |
445 | @Override |
446 | public void widgetSelected(SelectionEvent e) { | |
40b7b614 | 447 | TreeSelection selection = (TreeSelection) fTree.getViewer().getSelection(); |
8906e53c SM |
448 | |
449 | for (Object element : selection.toArray()) { | |
03beb743 | 450 | uncheckElement(element); |
8906e53c SM |
451 | } |
452 | ||
453 | updateOKStatus(); | |
454 | } | |
455 | }); | |
456 | ||
03beb743 | 457 | uncheckSubtreeButton.addSelectionListener(new SelectionAdapter() { |
8906e53c SM |
458 | @Override |
459 | public void widgetSelected(SelectionEvent e) { | |
40b7b614 | 460 | TreeSelection selection = (TreeSelection) fTree.getViewer().getSelection(); |
8906e53c SM |
461 | |
462 | for (Object element : selection.toArray()) { | |
463 | uncheckElement(element); | |
464 | } | |
465 | ||
466 | updateOKStatus(); | |
467 | } | |
468 | }); | |
469 | ||
03beb743 SM |
470 | uncheckAllButton.addSelectionListener(new SelectionAdapter() { |
471 | @Override | |
472 | public void widgetSelected(SelectionEvent e) { | |
40b7b614 GP |
473 | Object[] viewerElements = fContentProvider.getElements(fInput); |
474 | for (Object element : viewerElements) { | |
475 | if (fTree.getViewer().testFindItem(element) != null) { | |
476 | // uncheck only visible roots and their children | |
477 | uncheckElement(element); | |
478 | } | |
479 | } | |
03beb743 SM |
480 | updateOKStatus(); |
481 | } | |
482 | }); | |
483 | ||
8f91a789 AM |
484 | return buttonComposite; |
485 | } | |
486 | ||
03beb743 SM |
487 | /** |
488 | * Check an element and all its parents. | |
489 | * | |
490 | * @param element | |
491 | * The element to check. | |
492 | */ | |
8906e53c | 493 | private void checkElement(Object element) { |
40b7b614 | 494 | fTree.setChecked(element, true); |
03beb743 SM |
495 | |
496 | Object parent = fContentProvider.getParent(element); | |
497 | ||
40b7b614 | 498 | if (parent != null && !fTree.getChecked(parent)) { |
03beb743 | 499 | checkElement(parent); |
8906e53c SM |
500 | } |
501 | } | |
502 | ||
03beb743 SM |
503 | /** |
504 | * Check an element, all its parents and all its children. | |
505 | * | |
506 | * @param element | |
507 | * The element to check. | |
508 | */ | |
509 | private void checkElementAndSubtree(Object element) { | |
510 | checkElement(element); | |
511 | ||
512 | for (Object child : fContentProvider.getChildren(element)) { | |
513 | checkElementAndSubtree(child); | |
514 | } | |
515 | } | |
8906e53c | 516 | |
03beb743 SM |
517 | /** |
518 | * Uncheck an element and all its children. | |
519 | * | |
520 | * @param element | |
521 | * The element to uncheck. | |
522 | */ | |
523 | private void uncheckElement(Object element) { | |
40b7b614 | 524 | fTree.setChecked(element, false); |
8906e53c | 525 | |
03beb743 | 526 | for (Object child : fContentProvider.getChildren(element)) { |
8906e53c SM |
527 | uncheckElement(child); |
528 | } | |
529 | } | |
530 | ||
8f91a789 AM |
531 | private boolean evaluateIfTreeEmpty(Object input) { |
532 | Object[] elements = fContentProvider.getElements(input); | |
f1fae91f PT |
533 | if (elements.length > 0 && fFilters != null) { |
534 | for (int i = 0; i < fFilters.size(); i++) { | |
535 | ViewerFilter curr = fFilters.get(i); | |
40b7b614 | 536 | elements = curr.filter(fTree.getViewer(), input, elements); |
8f91a789 AM |
537 | } |
538 | } | |
539 | return elements.length == 0; | |
540 | } | |
541 | ||
542 | /** | |
543 | * Private classes | |
544 | */ | |
545 | ||
546 | private class CheckStateListener implements ICheckStateListener { | |
547 | ||
548 | CheckStateListener() { | |
549 | } | |
8906e53c | 550 | |
8f91a789 AM |
551 | @Override |
552 | public void checkStateChanged(CheckStateChangedEvent event) { | |
553 | try { | |
554 | ITimeGraphEntry entry = (ITimeGraphEntry) event.getElement(); | |
555 | boolean checked = event.getChecked(); | |
8906e53c SM |
556 | if (checked) { |
557 | checkElement(entry); | |
558 | } else { | |
559 | uncheckElement(entry); | |
8f91a789 AM |
560 | } |
561 | } catch (ClassCastException e) { | |
562 | return; | |
40b7b614 GP |
563 | } finally { |
564 | updateOKStatus(); | |
8f91a789 AM |
565 | } |
566 | } | |
40b7b614 | 567 | |
8f91a789 | 568 | } |
40b7b614 | 569 | } |