1 /*******************************************************************************
2 * Copyright (c) 2010, 2015 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Patrick Tasse - Initial API and implementation
11 * Xavier Raynaud - add cut/copy/paste/dnd support
12 * Vincent Perot - Add subfield filtering
13 *******************************************************************************/
15 package org
.eclipse
.tracecompass
.tmf
.ui
.views
.filter
;
17 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
19 import java
.util
.ArrayList
;
20 import java
.util
.Arrays
;
21 import java
.util
.List
;
23 import java
.util
.TreeMap
;
25 import org
.eclipse
.jface
.action
.Action
;
26 import org
.eclipse
.jface
.action
.IMenuListener
;
27 import org
.eclipse
.jface
.action
.IMenuManager
;
28 import org
.eclipse
.jface
.action
.MenuManager
;
29 import org
.eclipse
.jface
.action
.Separator
;
30 import org
.eclipse
.jface
.util
.LocalSelectionTransfer
;
31 import org
.eclipse
.jface
.viewers
.ISelection
;
32 import org
.eclipse
.jface
.viewers
.ISelectionChangedListener
;
33 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
34 import org
.eclipse
.jface
.viewers
.SelectionChangedEvent
;
35 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
36 import org
.eclipse
.jface
.viewers
.TreeViewer
;
37 import org
.eclipse
.swt
.SWT
;
38 import org
.eclipse
.swt
.custom
.SashForm
;
39 import org
.eclipse
.swt
.dnd
.DND
;
40 import org
.eclipse
.swt
.dnd
.DragSource
;
41 import org
.eclipse
.swt
.dnd
.DropTarget
;
42 import org
.eclipse
.swt
.dnd
.Transfer
;
43 import org
.eclipse
.swt
.events
.FocusEvent
;
44 import org
.eclipse
.swt
.events
.FocusListener
;
45 import org
.eclipse
.swt
.events
.ModifyEvent
;
46 import org
.eclipse
.swt
.events
.ModifyListener
;
47 import org
.eclipse
.swt
.events
.PaintEvent
;
48 import org
.eclipse
.swt
.events
.PaintListener
;
49 import org
.eclipse
.swt
.events
.SelectionAdapter
;
50 import org
.eclipse
.swt
.events
.SelectionEvent
;
51 import org
.eclipse
.swt
.layout
.FillLayout
;
52 import org
.eclipse
.swt
.layout
.GridData
;
53 import org
.eclipse
.swt
.layout
.GridLayout
;
54 import org
.eclipse
.swt
.widgets
.Button
;
55 import org
.eclipse
.swt
.widgets
.Combo
;
56 import org
.eclipse
.swt
.widgets
.Composite
;
57 import org
.eclipse
.swt
.widgets
.Control
;
58 import org
.eclipse
.swt
.widgets
.Display
;
59 import org
.eclipse
.swt
.widgets
.Label
;
60 import org
.eclipse
.swt
.widgets
.Menu
;
61 import org
.eclipse
.swt
.widgets
.Text
;
62 import org
.eclipse
.swt
.widgets
.TreeItem
;
63 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.Messages
;
64 import org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
.TmfBaseAspects
;
65 import org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
.ITmfEventAspect
;
66 import org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
.TmfEventFieldAspect
;
67 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.ITmfFilterTreeNode
;
68 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterAndNode
;
69 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterAspectNode
;
70 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterCompareNode
;
71 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterCompareNode
.Type
;
72 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterContainsNode
;
73 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterEqualsNode
;
74 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterMatchesNode
;
75 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterNode
;
76 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterOrNode
;
77 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterRootNode
;
78 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterTraceTypeNode
;
79 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterTreeNode
;
80 import org
.eclipse
.tracecompass
.tmf
.core
.project
.model
.TmfTraceType
;
81 import org
.eclipse
.tracecompass
.tmf
.core
.project
.model
.TraceTypeHelper
;
82 import org
.eclipse
.ui
.ISharedImages
;
83 import org
.eclipse
.ui
.PlatformUI
;
85 class FilterViewer
extends Composite
{
87 private static class TraceTypeItem
{
89 public String traceTypeId
;
91 public TraceTypeItem(String label
, String traceTypeId
) {
93 this.traceTypeId
= traceTypeId
;
97 private static class AspectItem
{
99 public ITmfEventAspect
<?
> eventAspect
;
100 public String traceTypeId
;
102 public AspectItem(String label
) {
106 public AspectItem(String label
, ITmfEventAspect
<?
> eventAspect
, String traceTypeId
) {
108 this.eventAspect
= eventAspect
;
109 this.traceTypeId
= traceTypeId
;
113 private TreeViewer fViewer
;
115 private Composite fComposite
;
116 private MenuManager fMenuManager
;
118 private boolean fIsDialog
= false;
120 public FilterViewer(Composite parent
, int style
) {
121 this(parent
, style
, false);
124 public FilterViewer(Composite parent
, int style
, boolean isDialog
) {
125 super(parent
, style
);
127 this.fIsDialog
= isDialog
;
129 setLayout(new FillLayout());
130 GridData gd
= new GridData(SWT
.FILL
, SWT
.FILL
, true, true);
133 final SashForm sash
= new SashForm(this, SWT
.HORIZONTAL
);
135 // Create the tree viewer to display the filter tree
136 fViewer
= new TreeViewer(sash
, SWT
.NONE
);
137 fViewer
.setContentProvider(new FilterTreeContentProvider());
138 fViewer
.setLabelProvider(new FilterTreeLabelProvider());
139 fViewer
.setInput(new TmfFilterRootNode());
141 // Create the empty filter node properties panel
142 fComposite
= new Composite(sash
, SWT
.NONE
);
143 GridLayout gl
= new GridLayout();
146 fComposite
.setLayout(gl
);
150 fViewer
.addSelectionChangedListener(new ISelectionChangedListener() {
152 public void selectionChanged(SelectionChangedEvent event
) {
153 if (!(event
.getSelection().isEmpty()) && event
.getSelection() instanceof IStructuredSelection
) {
154 // Update the filter node properties panel to the selection
155 IStructuredSelection selection
= (IStructuredSelection
) event
.getSelection();
156 ITmfFilterTreeNode node
= (ITmfFilterTreeNode
) selection
.getFirstElement();
157 updateFilterNodeComposite(node
);
158 // Highlight the selection's children
159 highlightTreeItems(fViewer
.getTree().getSelection()[0].getItems());
161 updateFilterNodeComposite(null);
166 fViewer
.getTree().addPaintListener(new PaintListener() {
168 public void paintControl(PaintEvent e
) {
169 TmfFilterTreeNode root
= (TmfFilterTreeNode
) fViewer
.getInput();
170 if (root
== null || root
.getChildrenCount() == 0) {
171 e
.gc
.setForeground(Display
.getDefault().getSystemColor(SWT
.COLOR_BLACK
));
172 e
.gc
.drawText(Messages
.FilterViewer_EmptyTreeHintText
, 5, 0);
177 int operations
= DND
.DROP_MOVE
| DND
.DROP_COPY
;
178 DragSource dragSource
= new org
.eclipse
.swt
.dnd
.DragSource(fViewer
.getTree(), operations
);
179 dragSource
.setTransfer(new Transfer
[] { LocalSelectionTransfer
.getTransfer() });
180 dragSource
.addDragListener(new FilterDragSourceAdapter(this));
181 DropTarget dropTarget
= new DropTarget(fViewer
.getTree(), operations
);
182 dropTarget
.setTransfer(new Transfer
[] { LocalSelectionTransfer
.getTransfer() });
183 dropTarget
.addDropListener(new FilterDropTargetAdapter(this));
187 * Create the context menu for the tree viewer
189 private void createContextMenu() {
190 // Adds root context menu
191 fMenuManager
= new MenuManager();
192 fMenuManager
.setRemoveAllWhenShown(true);
193 fMenuManager
.addMenuListener(new IMenuListener() {
195 public void menuAboutToShow(IMenuManager manager
) {
196 fillContextMenu(manager
);
201 Menu contextMenu
= fMenuManager
.createContextMenu(fViewer
.getTree());
204 fViewer
.getTree().setMenu(contextMenu
);
207 public MenuManager
getMenuManager() {
212 * Fill the context menu for the tree viewer.
217 protected void fillContextMenu(IMenuManager manager
) {
218 final ISelection selection
= fViewer
.getSelection();
219 ITmfFilterTreeNode filterTreeNode
= null;
220 if (selection
instanceof StructuredSelection
) {
221 Object element
= ((StructuredSelection
) selection
).getFirstElement();
222 if (element
instanceof ITmfFilterTreeNode
) {
223 filterTreeNode
= (ITmfFilterTreeNode
) element
;
227 final ITmfFilterTreeNode selectedNode
= filterTreeNode
;
228 if (selectedNode
!= null) {
229 fillContextMenuForNode(selectedNode
, manager
);
232 manager
.add(new Separator("delete")); //$NON-NLS-1$
234 if (fIsDialog
&& (selectedNode
!= null)) {
235 Action deleteAction
= new Action(Messages
.FilterViewer_DeleteActionText
) {
238 selectedNode
.remove();
242 deleteAction
.setImageDescriptor(PlatformUI
.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages
.IMG_TOOL_DELETE
));
243 manager
.add(deleteAction
);
245 manager
.add(new Separator("edit")); //$NON-NLS-1$
247 if (fViewer
.getInput() instanceof TmfFilterRootNode
|| filterTreeNode
== null) {
248 manager
.add(new Separator());
249 ITmfFilterTreeNode root
= (ITmfFilterTreeNode
) fViewer
.getInput();
250 fillContextMenuForNode(root
, manager
);
255 * Fill the context menu with the valid children of the provided node
262 protected void fillContextMenuForNode(final ITmfFilterTreeNode node
, IMenuManager manager
) {
263 for (final String child
: node
.getValidChildren()) {
264 final Action action
= new Action() {
267 ITmfFilterTreeNode newNode
= null;
268 if (TmfFilterNode
.NODE_NAME
.equals(child
)) {
269 newNode
= new TmfFilterNode(node
, ""); //$NON-NLS-1$
270 } else if (TmfFilterTraceTypeNode
.NODE_NAME
.equals(child
)) {
271 newNode
= new TmfFilterTraceTypeNode(node
);
272 } else if (TmfFilterAndNode
.NODE_NAME
.equals(child
)) {
273 newNode
= new TmfFilterAndNode(node
);
274 } else if (TmfFilterOrNode
.NODE_NAME
.equals(child
)) {
275 newNode
= new TmfFilterOrNode(node
);
276 } else if (TmfFilterContainsNode
.NODE_NAME
.equals(child
)) {
277 newNode
= new TmfFilterContainsNode(node
);
278 } else if (TmfFilterEqualsNode
.NODE_NAME
.equals(child
)) {
279 newNode
= new TmfFilterEqualsNode(node
);
280 } else if (TmfFilterMatchesNode
.NODE_NAME
.equals(child
)) {
281 newNode
= new TmfFilterMatchesNode(node
);
282 } else if (TmfFilterCompareNode
.NODE_NAME
.equals(child
)) {
283 newNode
= new TmfFilterCompareNode(node
);
285 if (newNode
!= null) {
287 fViewer
.setSelection(new StructuredSelection(newNode
), true);
291 if (TmfFilterNode
.NODE_NAME
.equals(child
)) {
292 action
.setText(Messages
.FilterViewer_NewPrefix
+ " " + child
); //$NON-NLS-1$
294 action
.setText(child
);
301 * Create the appropriate filter node properties composite
303 private void updateFilterNodeComposite(ITmfFilterTreeNode node
) {
304 for (Control control
: fComposite
.getChildren()) {
308 if (node
instanceof TmfFilterNode
) {
309 new FilterNodeComposite(fComposite
, (TmfFilterNode
) node
);
310 } else if (node
instanceof TmfFilterTraceTypeNode
) {
311 new FilterTraceTypeNodeComposite(fComposite
, (TmfFilterTraceTypeNode
) node
);
312 } else if (node
instanceof TmfFilterAndNode
) {
313 new FilterAndNodeComposite(fComposite
, (TmfFilterAndNode
) node
);
314 } else if (node
instanceof TmfFilterOrNode
) {
315 new FilterOrNodeComposite(fComposite
, (TmfFilterOrNode
) node
);
316 } else if (node
instanceof TmfFilterContainsNode
) {
317 new FilterContainsNodeComposite(fComposite
, (TmfFilterContainsNode
) node
);
318 } else if (node
instanceof TmfFilterEqualsNode
) {
319 new FilterEqualsNodeComposite(fComposite
, (TmfFilterEqualsNode
) node
);
320 } else if (node
instanceof TmfFilterMatchesNode
) {
321 new FilterMatchesNodeComposite(fComposite
, (TmfFilterMatchesNode
) node
);
322 } else if (node
instanceof TmfFilterCompareNode
) {
323 new FilterCompareNodeComposite(fComposite
, (TmfFilterCompareNode
) node
);
325 new FilterBaseNodeComposite(fComposite
);
331 * Highlight the provided tree items
333 private void highlightTreeItems(TreeItem
[] items
) {
334 resetTreeItems(fViewer
.getTree().getItems());
335 for (TreeItem item
: items
) {
336 item
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLUE
));
342 * Reset the provided tree items (remove highlight)
344 private void resetTreeItems(TreeItem
[] items
) {
345 for (TreeItem item
: items
) {
346 item
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
347 resetTreeItems(item
.getItems());
351 public void setInput(ITmfFilterTreeNode root
) {
352 fViewer
.setInput(root
);
355 updateFilterNodeComposite(null);
358 public ITmfFilterTreeNode
getInput() {
359 return (ITmfFilterTreeNode
) fViewer
.getInput();
362 public void refresh() {
366 public void setSelection(ITmfFilterTreeNode node
, boolean reveal
) {
367 fViewer
.setSelection(new StructuredSelection(node
), reveal
);
370 public void setSelection(ITmfFilterTreeNode node
) {
371 fViewer
.setSelection(new StructuredSelection(node
));
374 public ITmfFilterTreeNode
getSelection() {
375 final ISelection selection
= fViewer
.getSelection();
376 ITmfFilterTreeNode filterTreeNode
= null;
377 if (selection
instanceof StructuredSelection
) {
378 Object element
= ((StructuredSelection
) selection
).getFirstElement();
379 if (element
instanceof ITmfFilterTreeNode
) {
380 filterTreeNode
= (ITmfFilterTreeNode
) element
;
384 final ITmfFilterTreeNode selectedNode
= filterTreeNode
;
388 public void addSelectionChangedListener(ISelectionChangedListener listener
) {
389 fViewer
.addSelectionChangedListener(listener
);
392 public void removeSelectionChangedListener(ISelectionChangedListener listener
) {
393 fViewer
.removeSelectionChangedListener(listener
);
397 public boolean setFocus() {
398 return fViewer
.getControl().setFocus();
402 * @return whether the tree is in focus or not
404 public boolean isTreeInFocus() {
405 return fViewer
.getControl().isFocusControl();
409 * Gets the TreeViewer displaying filters
411 * @return a {@link TreeViewer}
413 TreeViewer
getTreeViewer() {
417 private class FilterBaseNodeComposite
extends Composite
{
419 FilterBaseNodeComposite(Composite parent
) {
420 super(parent
, SWT
.NONE
);
421 setLayout(new GridLayout(2, false));
422 setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
423 setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
426 protected Map
<String
, TraceTypeHelper
> getTraceTypeMap() {
427 Map
<String
, TraceTypeHelper
> traceTypeMap
= new TreeMap
<>();
428 for (TraceTypeHelper helper
: TmfTraceType
.getTraceTypeHelpers()) {
429 if (!helper
.isExperimentType()) {
430 traceTypeMap
.put(helper
.getLabel(), helper
);
437 private abstract class FilterAspectNodeComposite
extends FilterBaseNodeComposite
{
438 TmfFilterAspectNode fAspectNode
;
439 Combo fTraceTypeCombo
;
443 List
<AspectItem
> fAspectList
= null;
445 FilterAspectNodeComposite(Composite parent
, TmfFilterAspectNode node
) {
450 protected void createAspectControls() {
451 Label label
= new Label(this, SWT
.NONE
);
452 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
453 label
.setText(Messages
.FilterViewer_TypeLabel
);
455 final List
<TraceTypeItem
> traceTypeList
= getTraceTypeList(fAspectNode
);
457 fTraceTypeCombo
= new Combo(this, SWT
.DROP_DOWN
| SWT
.READ_ONLY
);
458 fTraceTypeCombo
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
459 for (TraceTypeItem traceType
: traceTypeList
) {
460 fTraceTypeCombo
.add(traceType
.label
);
462 if (fAspectNode
.getTraceTypeId() == null) {
463 fTraceTypeCombo
.select(0);
464 fAspectNode
.setTraceTypeId(traceTypeList
.get(0).traceTypeId
);
466 for (int i
= 0; i
< traceTypeList
.size(); i
++) {
467 TraceTypeItem traceType
= traceTypeList
.get(i
);
468 if (fAspectNode
.getTraceTypeId().equals(traceType
.traceTypeId
)) {
469 fTraceTypeCombo
.select(i
);
474 fTraceTypeCombo
.addModifyListener(new ModifyListener() {
476 public void modifyText(ModifyEvent e
) {
477 TraceTypeItem traceType
= traceTypeList
.get(fTraceTypeCombo
.getSelectionIndex());
478 fAspectNode
.setTraceTypeId(traceType
.traceTypeId
);
479 fAspectList
= getAspectList(fAspectNode
.getTraceTypeId());
480 String text
= fAspectCombo
.getText();
481 fAspectCombo
.removeAll();
482 for (AspectItem aspect
: fAspectList
) {
483 fAspectCombo
.add(aspect
.label
);
485 int index
= Arrays
.asList(fAspectCombo
.getItems()).indexOf(text
);
486 if (index
>= 0 && !text
.isEmpty()) {
487 fAspectCombo
.select(index
);
489 fViewer
.refresh(fAspectNode
);
493 label
= new Label(this, SWT
.NONE
);
494 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
495 label
.setText(Messages
.FilterViewer_AspectLabel
);
497 fAspectList
= getAspectList(fAspectNode
.getTraceTypeId());
499 fAspectCombo
= new Combo(this, SWT
.DROP_DOWN
| SWT
.READ_ONLY
);
500 fAspectCombo
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
501 for (AspectItem aspect
: fAspectList
) {
502 fAspectCombo
.add(aspect
.label
);
504 if (fAspectNode
.getEventAspect() != null) {
505 for (int i
= 0; i
< fAspectList
.size(); i
++) {
506 AspectItem aspect
= fAspectList
.get(i
);
507 if (aspect
.eventAspect
!= null &&
508 fAspectNode
.getEventAspect().getName().equals(aspect
.eventAspect
.getName()) &&
509 (fAspectNode
.getTraceTypeId().equals(aspect
.traceTypeId
) ||
510 fAspectNode
.getTraceTypeId().equals(TmfFilterAspectNode
.BASE_ASPECT_ID
))) {
511 fAspectCombo
.select(i
);
512 if (fAspectNode
.getEventAspect() instanceof TmfEventFieldAspect
) {
513 aspect
.eventAspect
= fAspectNode
.getEventAspect();
514 createFieldControls((TmfEventFieldAspect
) fAspectNode
.getEventAspect(), aspect
);
520 fAspectCombo
.addModifyListener(new ModifyListener() {
522 public void modifyText(ModifyEvent e
) {
523 int selection
= fAspectCombo
.getSelectionIndex();
524 AspectItem aspect
= null;
525 if (selection
!= -1) {
526 aspect
= fAspectList
.get(fAspectCombo
.getSelectionIndex());
527 fAspectNode
.setEventAspect(aspect
.eventAspect
);
529 fAspectNode
.setEventAspect(null);
531 if (fAspectNode
.getEventAspect() instanceof TmfEventFieldAspect
) {
532 TmfEventFieldAspect eventFieldAspect
= (TmfEventFieldAspect
) fAspectNode
.getEventAspect();
533 createFieldControls(eventFieldAspect
, aspect
);
535 } else if (fFieldLabel
!= null && fFieldText
!= null) {
536 fFieldLabel
.dispose();
538 fFieldText
.dispose();
542 fViewer
.refresh(fAspectNode
);
547 private void createFieldControls(final TmfEventFieldAspect eventFieldAspect
, final AspectItem aspect
) {
548 if (fFieldLabel
!= null) {
549 fFieldLabel
.dispose();
551 fFieldLabel
= new Label(this, SWT
.NONE
);
552 fFieldLabel
.moveBelow(fAspectCombo
);
553 fFieldLabel
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
554 fFieldLabel
.setText(Messages
.FilterViewer_FieldLabel
);
556 if (fFieldText
!= null) {
557 fFieldText
.dispose();
559 fFieldText
= new Text(this, SWT
.BORDER
);
560 fFieldText
.moveBelow(fFieldLabel
);
561 fFieldText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
562 fFieldText
.setToolTipText(Messages
.FilterViewer_Subfield_ToolTip
);
563 if (eventFieldAspect
.getFieldPath() != null) {
564 fFieldText
.setText(eventFieldAspect
.getFieldPath());
566 if (fFieldText
.getText().length() == 0) {
567 fFieldText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
568 fFieldText
.setText(Messages
.FilterViewer_FieldHint
);
570 fFieldText
.addFocusListener(new FocusListener() {
572 public void focusLost(FocusEvent e
) {
573 if (fFieldText
.getText().length() == 0) {
574 fFieldText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
575 fFieldText
.setText(Messages
.FilterViewer_FieldHint
);
580 public void focusGained(FocusEvent e
) {
581 if (fFieldText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
582 fFieldText
.setText(""); //$NON-NLS-1$
584 fFieldText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
587 fFieldText
.addModifyListener(new ModifyListener() {
589 public void modifyText(ModifyEvent e
) {
590 if (!fFieldText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
591 if (fFieldText
.getText().isEmpty()) {
592 fAspectNode
.setEventAspect(eventFieldAspect
.forField(null));
594 fAspectNode
.setEventAspect(eventFieldAspect
.forField(fFieldText
.getText()));
596 aspect
.eventAspect
= fAspectNode
.getEventAspect();
597 fViewer
.refresh(fAspectNode
);
603 private List
<TraceTypeItem
> getTraceTypeList(ITmfFilterTreeNode node
) {
604 ArrayList
<TraceTypeItem
> traceTypeList
= new ArrayList
<>();
605 traceTypeList
.add(new TraceTypeItem(Messages
.FilterViewer_CommonCategory
, TmfFilterAspectNode
.BASE_ASPECT_ID
));
607 ITmfFilterTreeNode curNode
= node
;
608 while (curNode
!= null) {
609 if (curNode
instanceof TmfFilterTraceTypeNode
) {
610 TmfFilterTraceTypeNode traceTypeNode
= (TmfFilterTraceTypeNode
) curNode
;
611 TraceTypeHelper helper
= TmfTraceType
.getTraceType(traceTypeNode
.getTraceTypeId());
612 if (helper
!= null) {
613 traceTypeList
.set(0, new TraceTypeItem(helper
.getLabel(), helper
.getTraceTypeId()));
615 return traceTypeList
;
617 curNode
= curNode
.getParent();
620 for (TraceTypeHelper helper
: getTraceTypeMap().values()) {
621 traceTypeList
.add(new TraceTypeItem(helper
.getLabel(), helper
.getTraceTypeId()));
623 return traceTypeList
;
626 private List
<AspectItem
> getAspectList(String traceTypeId
) {
627 ArrayList
<AspectItem
> aspectList
= new ArrayList
<>();
629 aspectList
.add(new AspectItem(Messages
.FilterViewer_CommonCategory
));
630 for (ITmfEventAspect
<?
> aspect
: TmfBaseAspects
.getBaseAspects()) {
631 aspectList
.add(new AspectItem(aspect
.getName(), aspect
, TmfFilterAspectNode
.BASE_ASPECT_ID
));
634 TraceTypeHelper helper
= TmfTraceType
.getTraceType(traceTypeId
);
635 if (helper
!= null) {
636 aspectList
.add(new AspectItem("")); //$NON-NLS-1$
637 aspectList
.add(new AspectItem('[' + helper
.getLabel() + ']'));
638 for (ITmfEventAspect
<?
> aspect
: helper
.getTrace().getEventAspects()) {
639 for (AspectItem baseAspect
: aspectList
) {
640 if (aspect
.equals(baseAspect
.eventAspect
)) {
641 aspectList
.remove(baseAspect
);
645 aspectList
.add(new AspectItem(aspect
.getName(), aspect
, helper
.getTraceTypeId()));
652 private class FilterNodeComposite
extends FilterBaseNodeComposite
{
656 FilterNodeComposite(Composite parent
, TmfFilterNode node
) {
660 Label label
= new Label(this, SWT
.NONE
);
661 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
662 label
.setText(Messages
.FilterViewer_NameLabel
);
664 fNameText
= new Text(this, SWT
.BORDER
);
665 fNameText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
666 if (node
.getFilterName() != null && node
.getFilterName().length() > 0) {
667 fNameText
.setText(node
.getFilterName());
669 fNameText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
670 fNameText
.setText(Messages
.FilterViewer_FilterNameHint
);
672 fNameText
.addFocusListener(new FocusListener() {
674 public void focusLost(FocusEvent e
) {
675 if (fNode
.getFilterName() == null || fNode
.getFilterName().length() == 0) {
676 fNameText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
677 fNameText
.setText(Messages
.FilterViewer_FilterNameHint
);
682 public void focusGained(FocusEvent e
) {
683 if (fNameText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
684 fNameText
.setText(""); //$NON-NLS-1$
686 fNameText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
689 fNameText
.addModifyListener(new ModifyListener() {
691 public void modifyText(ModifyEvent e
) {
692 if (!fNameText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
693 fNode
.setFilterName(fNameText
.getText());
694 fViewer
.refresh(fNode
);
701 private class FilterTraceTypeNodeComposite
extends FilterBaseNodeComposite
{
702 TmfFilterTraceTypeNode fNode
;
704 Map
<String
, TraceTypeHelper
> fTraceTypeMap
;
706 FilterTraceTypeNodeComposite(Composite parent
, TmfFilterTraceTypeNode node
) {
709 fTraceTypeMap
= getTraceTypeMap();
711 Label label
= new Label(this, SWT
.NONE
);
712 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
713 label
.setText(Messages
.FilterViewer_TypeLabel
);
715 fTypeCombo
= new Combo(this, SWT
.DROP_DOWN
| SWT
.READ_ONLY
);
716 fTypeCombo
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
717 fTypeCombo
.setItems(fTraceTypeMap
.keySet().toArray(new String
[0]));
718 if (fNode
.getTraceTypeId() != null) {
719 fTypeCombo
.setText(fNode
.getName());
721 fTypeCombo
.addModifyListener(new ModifyListener() {
723 public void modifyText(ModifyEvent e
) {
724 TraceTypeHelper helper
= checkNotNull(fTraceTypeMap
.get(fTypeCombo
.getText()));
725 fNode
.setTraceTypeId(helper
.getTraceTypeId());
726 fNode
.setTraceClass(helper
.getTraceClass());
727 fNode
.setName(fTypeCombo
.getText());
728 fViewer
.refresh(fNode
);
734 private class FilterAndNodeComposite
extends FilterBaseNodeComposite
{
735 TmfFilterAndNode fNode
;
738 FilterAndNodeComposite(Composite parent
, TmfFilterAndNode node
) {
742 Label label
= new Label(this, SWT
.NONE
);
743 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
744 label
.setText(Messages
.FilterViewer_NotLabel
);
746 fNotButton
= new Button(this, SWT
.CHECK
);
747 fNotButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
748 fNotButton
.setSelection(fNode
.isNot());
749 fNotButton
.addSelectionListener(new SelectionAdapter() {
751 public void widgetSelected(SelectionEvent e
) {
752 fNode
.setNot(fNotButton
.getSelection());
753 fViewer
.refresh(fNode
);
759 private class FilterOrNodeComposite
extends FilterBaseNodeComposite
{
760 TmfFilterOrNode fNode
;
763 FilterOrNodeComposite(Composite parent
, TmfFilterOrNode node
) {
767 Label label
= new Label(this, SWT
.NONE
);
768 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
769 label
.setText(Messages
.FilterViewer_NotLabel
);
771 fNotButton
= new Button(this, SWT
.CHECK
);
772 fNotButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
773 fNotButton
.setSelection(fNode
.isNot());
774 fNotButton
.addSelectionListener(new SelectionAdapter() {
776 public void widgetSelected(SelectionEvent e
) {
777 fNode
.setNot(fNotButton
.getSelection());
778 fViewer
.refresh(fNode
);
784 private class FilterContainsNodeComposite
extends FilterAspectNodeComposite
{
785 TmfFilterContainsNode fNode
;
788 Button fIgnoreCaseButton
;
790 FilterContainsNodeComposite(Composite parent
, TmfFilterContainsNode node
) {
794 Label label
= new Label(this, SWT
.NONE
);
795 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
796 label
.setText(Messages
.FilterViewer_NotLabel
);
798 fNotButton
= new Button(this, SWT
.CHECK
);
799 fNotButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
800 fNotButton
.setSelection(fNode
.isNot());
801 fNotButton
.addSelectionListener(new SelectionAdapter() {
803 public void widgetSelected(SelectionEvent e
) {
804 fNode
.setNot(fNotButton
.getSelection());
805 fViewer
.refresh(fNode
);
809 createAspectControls();
811 label
= new Label(this, SWT
.NONE
);
812 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
813 label
.setText(Messages
.FilterViewer_ValueLabel
);
815 fValueText
= new Text(this, SWT
.BORDER
);
816 fValueText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
817 if (node
.getValue() != null && node
.getValue().length() > 0) {
818 fValueText
.setText(node
.getValue());
820 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
821 fValueText
.setText(Messages
.FilterViewer_ValueHint
);
823 fValueText
.addFocusListener(new FocusListener() {
825 public void focusLost(FocusEvent e
) {
826 if (fNode
.getValue() == null || fNode
.getValue().length() == 0) {
827 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
828 fValueText
.setText(Messages
.FilterViewer_ValueHint
);
833 public void focusGained(FocusEvent e
) {
834 if (fValueText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
835 fValueText
.setText(""); //$NON-NLS-1$
837 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
840 fValueText
.addModifyListener(new ModifyListener() {
842 public void modifyText(ModifyEvent e
) {
843 if (!fValueText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
844 fNode
.setValue(fValueText
.getText());
845 fViewer
.refresh(fNode
);
850 label
= new Label(this, SWT
.NONE
);
851 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
853 fIgnoreCaseButton
= new Button(this, SWT
.CHECK
);
854 fIgnoreCaseButton
.setSelection(fNode
.isIgnoreCase());
855 fIgnoreCaseButton
.setText(Messages
.FilterViewer_IgnoreCaseButtonText
);
856 fIgnoreCaseButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
857 fIgnoreCaseButton
.addSelectionListener(new SelectionAdapter() {
859 public void widgetSelected(SelectionEvent e
) {
860 fNode
.setIgnoreCase(fIgnoreCaseButton
.getSelection());
861 fViewer
.refresh(fNode
);
867 private class FilterEqualsNodeComposite
extends FilterAspectNodeComposite
{
868 TmfFilterEqualsNode fNode
;
871 Button fIgnoreCaseButton
;
873 FilterEqualsNodeComposite(Composite parent
, TmfFilterEqualsNode node
) {
877 Label label
= new Label(this, SWT
.NONE
);
878 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
879 label
.setText(Messages
.FilterViewer_NotLabel
);
881 fNotButton
= new Button(this, SWT
.CHECK
);
882 fNotButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
883 fNotButton
.setSelection(fNode
.isNot());
884 fNotButton
.addSelectionListener(new SelectionAdapter() {
886 public void widgetSelected(SelectionEvent e
) {
887 fNode
.setNot(fNotButton
.getSelection());
888 fViewer
.refresh(fNode
);
892 createAspectControls();
894 label
= new Label(this, SWT
.NONE
);
895 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
896 label
.setText(Messages
.FilterViewer_ValueLabel
);
898 fValueText
= new Text(this, SWT
.BORDER
);
899 fValueText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
900 if (node
.getValue() != null && node
.getValue().length() > 0) {
901 fValueText
.setText(node
.getValue());
903 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
904 fValueText
.setText(Messages
.FilterViewer_ValueHint
);
906 fValueText
.addFocusListener(new FocusListener() {
908 public void focusLost(FocusEvent e
) {
909 if (fNode
.getValue() == null || fNode
.getValue().length() == 0) {
910 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
911 fValueText
.setText(Messages
.FilterViewer_ValueHint
);
916 public void focusGained(FocusEvent e
) {
917 if (fValueText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
918 fValueText
.setText(""); //$NON-NLS-1$
920 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
923 fValueText
.addModifyListener(new ModifyListener() {
925 public void modifyText(ModifyEvent e
) {
926 if (!fValueText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
927 fNode
.setValue(fValueText
.getText());
928 fViewer
.refresh(fNode
);
933 label
= new Label(this, SWT
.NONE
);
934 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
936 fIgnoreCaseButton
= new Button(this, SWT
.CHECK
);
937 fIgnoreCaseButton
.setSelection(fNode
.isIgnoreCase());
938 fIgnoreCaseButton
.setText(Messages
.FilterViewer_IgnoreCaseButtonText
);
939 fIgnoreCaseButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
940 fIgnoreCaseButton
.addSelectionListener(new SelectionAdapter() {
942 public void widgetSelected(SelectionEvent e
) {
943 fNode
.setIgnoreCase(fIgnoreCaseButton
.getSelection());
944 fViewer
.refresh(fNode
);
950 private class FilterMatchesNodeComposite
extends FilterAspectNodeComposite
{
951 TmfFilterMatchesNode fNode
;
955 FilterMatchesNodeComposite(Composite parent
, TmfFilterMatchesNode node
) {
959 Label label
= new Label(this, SWT
.NONE
);
960 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
961 label
.setText(Messages
.FilterViewer_NotLabel
);
963 fNotButton
= new Button(this, SWT
.CHECK
);
964 fNotButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
965 fNotButton
.setSelection(fNode
.isNot());
966 fNotButton
.addSelectionListener(new SelectionAdapter() {
968 public void widgetSelected(SelectionEvent e
) {
969 fNode
.setNot(fNotButton
.getSelection());
970 fViewer
.refresh(fNode
);
974 createAspectControls();
976 label
= new Label(this, SWT
.NONE
);
977 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
978 label
.setText(Messages
.FilterViewer_RegexLabel
);
980 fRegexText
= new Text(this, SWT
.BORDER
);
981 fRegexText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
982 if (node
.getRegex() != null && node
.getRegex().length() > 0) {
983 fRegexText
.setText(node
.getRegex());
985 fRegexText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
986 fRegexText
.setText(Messages
.FilterViewer_RegexHint
);
988 fRegexText
.addFocusListener(new FocusListener() {
990 public void focusLost(FocusEvent e
) {
991 if (fNode
.getRegex() == null || fNode
.getRegex().length() == 0) {
992 fRegexText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
993 fRegexText
.setText(Messages
.FilterViewer_RegexHint
);
998 public void focusGained(FocusEvent e
) {
999 if (fRegexText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
1000 fRegexText
.setText(""); //$NON-NLS-1$
1002 fRegexText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
1005 fRegexText
.addModifyListener(new ModifyListener() {
1007 public void modifyText(ModifyEvent e
) {
1008 if (!fRegexText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
1009 fNode
.setRegex(fRegexText
.getText());
1010 fViewer
.refresh(fNode
);
1017 private class FilterCompareNodeComposite
extends FilterAspectNodeComposite
{
1018 TmfFilterCompareNode fNode
;
1025 Button fAlphaButton
;
1026 Button fTimestampButton
;
1028 FilterCompareNodeComposite(Composite parent
, TmfFilterCompareNode node
) {
1029 super(parent
, node
);
1032 Label label
= new Label(this, SWT
.NONE
);
1033 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1034 label
.setText(Messages
.FilterViewer_NotLabel
);
1036 fNotButton
= new Button(this, SWT
.CHECK
);
1037 fNotButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1038 fNotButton
.setSelection(fNode
.isNot());
1039 fNotButton
.addSelectionListener(new SelectionAdapter() {
1041 public void widgetSelected(SelectionEvent e
) {
1042 fNode
.setNot(fNotButton
.getSelection());
1043 fViewer
.refresh(fNode
);
1047 createAspectControls();
1049 label
= new Label(this, SWT
.NONE
);
1050 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1051 label
.setText(Messages
.FilterViewer_ResultLabel
);
1053 Composite resultGroup
= new Composite(this, SWT
.NONE
);
1054 GridLayout rggl
= new GridLayout(3, true);
1055 rggl
.marginHeight
= 0;
1056 rggl
.marginWidth
= 0;
1057 resultGroup
.setLayout(rggl
);
1058 resultGroup
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1060 fLTButton
= new Button(resultGroup
, SWT
.RADIO
);
1061 fLTButton
.setSelection(fNode
.getResult() < 0);
1062 fLTButton
.setText("<"); //$NON-NLS-1$
1063 fLTButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1064 fLTButton
.addSelectionListener(new SelectionAdapter() {
1066 public void widgetSelected(SelectionEvent e
) {
1067 if (fLTButton
.getSelection()) {
1068 fNode
.setResult(-1);
1070 fViewer
.refresh(fNode
);
1074 fEQButton
= new Button(resultGroup
, SWT
.RADIO
);
1075 fEQButton
.setSelection(fNode
.getResult() == 0);
1076 fEQButton
.setText("="); //$NON-NLS-1$
1077 fEQButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1078 fEQButton
.addSelectionListener(new SelectionAdapter() {
1080 public void widgetSelected(SelectionEvent e
) {
1081 if (fEQButton
.getSelection()) {
1084 fViewer
.refresh(fNode
);
1088 fGTButton
= new Button(resultGroup
, SWT
.RADIO
);
1089 fGTButton
.setSelection(fNode
.getResult() > 0);
1090 fGTButton
.setText(">"); //$NON-NLS-1$
1091 fGTButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1092 fGTButton
.addSelectionListener(new SelectionAdapter() {
1094 public void widgetSelected(SelectionEvent e
) {
1095 if (fGTButton
.getSelection()) {
1098 fViewer
.refresh(fNode
);
1102 label
= new Label(this, SWT
.NONE
);
1103 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1104 label
.setText(Messages
.FilterViewer_TypeLabel
);
1106 Composite typeGroup
= new Composite(this, SWT
.NONE
);
1107 GridLayout tggl
= new GridLayout(3, false);
1108 tggl
.marginHeight
= 0;
1109 tggl
.marginWidth
= 0;
1110 typeGroup
.setLayout(tggl
);
1111 typeGroup
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1113 fNumButton
= new Button(typeGroup
, SWT
.RADIO
);
1114 fNumButton
.setSelection(fNode
.getType() == Type
.NUM
);
1115 fNumButton
.setText(Messages
.FilterViewer_NumButtonText
);
1116 fNumButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1117 fNumButton
.addSelectionListener(new SelectionAdapter() {
1119 public void widgetSelected(SelectionEvent e
) {
1120 if (fNumButton
.getSelection()) {
1121 fNode
.setType(Type
.NUM
);
1123 fViewer
.refresh(fNode
);
1127 fAlphaButton
= new Button(typeGroup
, SWT
.RADIO
);
1128 fAlphaButton
.setSelection(fNode
.getType() == Type
.ALPHA
);
1129 fAlphaButton
.setText(Messages
.FilterViewer_AlphaButtonText
);
1130 fAlphaButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1131 fAlphaButton
.addSelectionListener(new SelectionAdapter() {
1133 public void widgetSelected(SelectionEvent e
) {
1134 if (fAlphaButton
.getSelection()) {
1135 fNode
.setType(Type
.ALPHA
);
1137 fViewer
.refresh(fNode
);
1141 fTimestampButton
= new Button(typeGroup
, SWT
.RADIO
);
1142 fTimestampButton
.setSelection(fNode
.getType() == Type
.TIMESTAMP
);
1143 fTimestampButton
.setText(Messages
.FilterViewer_TimestampButtonText
);
1144 fTimestampButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1145 fTimestampButton
.addSelectionListener(new SelectionAdapter() {
1147 public void widgetSelected(SelectionEvent e
) {
1148 if (fTimestampButton
.getSelection()) {
1149 fNode
.setType(Type
.TIMESTAMP
);
1151 fViewer
.refresh(fNode
);
1155 label
= new Label(this, SWT
.NONE
);
1156 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1157 label
.setText(Messages
.FilterViewer_ValueLabel
);
1159 fValueText
= new Text(this, SWT
.BORDER
);
1160 fValueText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
1161 if (node
.getValue() != null && node
.getValue().length() > 0) {
1162 fValueText
.setText(node
.getValue());
1164 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
1165 fValueText
.setText(Messages
.FilterViewer_ValueHint
);
1167 fValueText
.addFocusListener(new FocusListener() {
1169 public void focusLost(FocusEvent e
) {
1170 if (fNode
.getValue() == null || fNode
.getValue().length() == 0) {
1171 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
1172 fValueText
.setText(Messages
.FilterViewer_ValueHint
);
1177 public void focusGained(FocusEvent e
) {
1178 if (fValueText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
1179 fValueText
.setText(""); //$NON-NLS-1$
1181 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
1184 fValueText
.addModifyListener(new ModifyListener() {
1186 public void modifyText(ModifyEvent e
) {
1187 if (!fValueText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
1188 fNode
.setValue(fValueText
.getText());
1189 fViewer
.refresh(fNode
);