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
.ITmfEventAspect
;
65 import org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
.TmfEventFieldAspect
;
66 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.ITmfFilterTreeNode
;
67 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterAndNode
;
68 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterAspectNode
;
69 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterCompareNode
;
70 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterCompareNode
.Type
;
71 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterContainsNode
;
72 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterEqualsNode
;
73 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterMatchesNode
;
74 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterNode
;
75 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterOrNode
;
76 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterRootNode
;
77 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterTraceTypeNode
;
78 import org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
.TmfFilterTreeNode
;
79 import org
.eclipse
.tracecompass
.tmf
.core
.project
.model
.TmfTraceType
;
80 import org
.eclipse
.tracecompass
.tmf
.core
.project
.model
.TraceTypeHelper
;
81 import org
.eclipse
.ui
.ISharedImages
;
82 import org
.eclipse
.ui
.PlatformUI
;
84 class FilterViewer
extends Composite
{
86 private static class TraceTypeItem
{
88 public String traceTypeId
;
90 public TraceTypeItem(String label
, String traceTypeId
) {
92 this.traceTypeId
= traceTypeId
;
96 private static class AspectItem
{
98 public ITmfEventAspect eventAspect
;
99 public String traceTypeId
;
101 public AspectItem(String label
) {
105 public AspectItem(String label
, ITmfEventAspect eventAspect
, String traceTypeId
) {
107 this.eventAspect
= eventAspect
;
108 this.traceTypeId
= traceTypeId
;
112 private TreeViewer fViewer
;
114 private Composite fComposite
;
115 private MenuManager fMenuManager
;
117 private boolean fIsDialog
= false;
119 public FilterViewer(Composite parent
, int style
) {
120 this(parent
, style
, false);
123 public FilterViewer(Composite parent
, int style
, boolean isDialog
) {
124 super(parent
, style
);
126 this.fIsDialog
= isDialog
;
128 setLayout(new FillLayout());
129 GridData gd
= new GridData(SWT
.FILL
, SWT
.FILL
, true, true);
132 final SashForm sash
= new SashForm(this, SWT
.HORIZONTAL
);
134 // Create the tree viewer to display the filter tree
135 fViewer
= new TreeViewer(sash
, SWT
.NONE
);
136 fViewer
.setContentProvider(new FilterTreeContentProvider());
137 fViewer
.setLabelProvider(new FilterTreeLabelProvider());
138 fViewer
.setInput(new TmfFilterRootNode());
140 // Create the empty filter node properties panel
141 fComposite
= new Composite(sash
, SWT
.NONE
);
142 GridLayout gl
= new GridLayout();
145 fComposite
.setLayout(gl
);
149 fViewer
.addSelectionChangedListener(new ISelectionChangedListener() {
151 public void selectionChanged(SelectionChangedEvent event
) {
152 if (!(event
.getSelection().isEmpty()) && event
.getSelection() instanceof IStructuredSelection
) {
153 // Update the filter node properties panel to the selection
154 IStructuredSelection selection
= (IStructuredSelection
) event
.getSelection();
155 ITmfFilterTreeNode node
= (ITmfFilterTreeNode
) selection
.getFirstElement();
156 updateFilterNodeComposite(node
);
157 // Highlight the selection's children
158 highlightTreeItems(fViewer
.getTree().getSelection()[0].getItems());
160 updateFilterNodeComposite(null);
165 fViewer
.getTree().addPaintListener(new PaintListener() {
167 public void paintControl(PaintEvent e
) {
168 TmfFilterTreeNode root
= (TmfFilterTreeNode
) fViewer
.getInput();
169 if (root
== null || root
.getChildrenCount() == 0) {
170 e
.gc
.setForeground(Display
.getDefault().getSystemColor(SWT
.COLOR_BLACK
));
171 e
.gc
.drawText(Messages
.FilterViewer_EmptyTreeHintText
, 5, 0);
176 int operations
= DND
.DROP_MOVE
| DND
.DROP_COPY
;
177 DragSource dragSource
= new org
.eclipse
.swt
.dnd
.DragSource(fViewer
.getTree(), operations
);
178 dragSource
.setTransfer(new Transfer
[] { LocalSelectionTransfer
.getTransfer() });
179 dragSource
.addDragListener(new FilterDragSourceAdapter(this));
180 DropTarget dropTarget
= new DropTarget(fViewer
.getTree(), operations
);
181 dropTarget
.setTransfer(new Transfer
[] { LocalSelectionTransfer
.getTransfer() });
182 dropTarget
.addDropListener(new FilterDropTargetAdapter(this));
186 * Create the context menu for the tree viewer
188 private void createContextMenu() {
189 // Adds root context menu
190 fMenuManager
= new MenuManager();
191 fMenuManager
.setRemoveAllWhenShown(true);
192 fMenuManager
.addMenuListener(new IMenuListener() {
194 public void menuAboutToShow(IMenuManager manager
) {
195 fillContextMenu(manager
);
200 Menu contextMenu
= fMenuManager
.createContextMenu(fViewer
.getTree());
203 fViewer
.getTree().setMenu(contextMenu
);
206 public MenuManager
getMenuManager() {
211 * Fill the context menu for the tree viewer.
216 protected void fillContextMenu(IMenuManager manager
) {
217 final ISelection selection
= fViewer
.getSelection();
218 ITmfFilterTreeNode filterTreeNode
= null;
219 if (selection
instanceof StructuredSelection
) {
220 Object element
= ((StructuredSelection
) selection
).getFirstElement();
221 if (element
instanceof ITmfFilterTreeNode
) {
222 filterTreeNode
= (ITmfFilterTreeNode
) element
;
226 final ITmfFilterTreeNode selectedNode
= filterTreeNode
;
227 if (selectedNode
!= null) {
228 fillContextMenuForNode(selectedNode
, manager
);
231 manager
.add(new Separator("delete")); //$NON-NLS-1$
233 if (fIsDialog
&& (selectedNode
!= null)) {
234 Action deleteAction
= new Action(Messages
.FilterViewer_DeleteActionText
) {
237 selectedNode
.remove();
241 deleteAction
.setImageDescriptor(PlatformUI
.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages
.IMG_TOOL_DELETE
));
242 manager
.add(deleteAction
);
244 manager
.add(new Separator("edit")); //$NON-NLS-1$
246 if (fViewer
.getInput() instanceof TmfFilterRootNode
|| filterTreeNode
== null) {
247 manager
.add(new Separator());
248 ITmfFilterTreeNode root
= (ITmfFilterTreeNode
) fViewer
.getInput();
249 fillContextMenuForNode(root
, manager
);
254 * Fill the context menu with the valid children of the provided node
261 protected void fillContextMenuForNode(final ITmfFilterTreeNode node
, IMenuManager manager
) {
262 for (final String child
: node
.getValidChildren()) {
263 final Action action
= new Action() {
266 ITmfFilterTreeNode newNode
= null;
267 if (TmfFilterNode
.NODE_NAME
.equals(child
)) {
268 newNode
= new TmfFilterNode(node
, ""); //$NON-NLS-1$
269 } else if (TmfFilterTraceTypeNode
.NODE_NAME
.equals(child
)) {
270 newNode
= new TmfFilterTraceTypeNode(node
);
271 } else if (TmfFilterAndNode
.NODE_NAME
.equals(child
)) {
272 newNode
= new TmfFilterAndNode(node
);
273 } else if (TmfFilterOrNode
.NODE_NAME
.equals(child
)) {
274 newNode
= new TmfFilterOrNode(node
);
275 } else if (TmfFilterContainsNode
.NODE_NAME
.equals(child
)) {
276 newNode
= new TmfFilterContainsNode(node
);
277 } else if (TmfFilterEqualsNode
.NODE_NAME
.equals(child
)) {
278 newNode
= new TmfFilterEqualsNode(node
);
279 } else if (TmfFilterMatchesNode
.NODE_NAME
.equals(child
)) {
280 newNode
= new TmfFilterMatchesNode(node
);
281 } else if (TmfFilterCompareNode
.NODE_NAME
.equals(child
)) {
282 newNode
= new TmfFilterCompareNode(node
);
284 if (newNode
!= null) {
286 fViewer
.setSelection(new StructuredSelection(newNode
), true);
290 if (TmfFilterNode
.NODE_NAME
.equals(child
)) {
291 action
.setText(Messages
.FilterViewer_NewPrefix
+ " " + child
); //$NON-NLS-1$
293 action
.setText(child
);
300 * Create the appropriate filter node properties composite
302 private void updateFilterNodeComposite(ITmfFilterTreeNode node
) {
303 for (Control control
: fComposite
.getChildren()) {
307 if (node
instanceof TmfFilterNode
) {
308 new FilterNodeComposite(fComposite
, (TmfFilterNode
) node
);
309 } else if (node
instanceof TmfFilterTraceTypeNode
) {
310 new FilterTraceTypeNodeComposite(fComposite
, (TmfFilterTraceTypeNode
) node
);
311 } else if (node
instanceof TmfFilterAndNode
) {
312 new FilterAndNodeComposite(fComposite
, (TmfFilterAndNode
) node
);
313 } else if (node
instanceof TmfFilterOrNode
) {
314 new FilterOrNodeComposite(fComposite
, (TmfFilterOrNode
) node
);
315 } else if (node
instanceof TmfFilterContainsNode
) {
316 new FilterContainsNodeComposite(fComposite
, (TmfFilterContainsNode
) node
);
317 } else if (node
instanceof TmfFilterEqualsNode
) {
318 new FilterEqualsNodeComposite(fComposite
, (TmfFilterEqualsNode
) node
);
319 } else if (node
instanceof TmfFilterMatchesNode
) {
320 new FilterMatchesNodeComposite(fComposite
, (TmfFilterMatchesNode
) node
);
321 } else if (node
instanceof TmfFilterCompareNode
) {
322 new FilterCompareNodeComposite(fComposite
, (TmfFilterCompareNode
) node
);
324 new FilterBaseNodeComposite(fComposite
);
330 * Highlight the provided tree items
332 private void highlightTreeItems(TreeItem
[] items
) {
333 resetTreeItems(fViewer
.getTree().getItems());
334 for (TreeItem item
: items
) {
335 item
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLUE
));
341 * Reset the provided tree items (remove highlight)
343 private void resetTreeItems(TreeItem
[] items
) {
344 for (TreeItem item
: items
) {
345 item
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
346 resetTreeItems(item
.getItems());
350 public void setInput(ITmfFilterTreeNode root
) {
351 fViewer
.setInput(root
);
354 updateFilterNodeComposite(null);
357 public ITmfFilterTreeNode
getInput() {
358 return (ITmfFilterTreeNode
) fViewer
.getInput();
361 public void refresh() {
365 public void setSelection(ITmfFilterTreeNode node
, boolean reveal
) {
366 fViewer
.setSelection(new StructuredSelection(node
), reveal
);
369 public void setSelection(ITmfFilterTreeNode node
) {
370 fViewer
.setSelection(new StructuredSelection(node
));
373 public ITmfFilterTreeNode
getSelection() {
374 final ISelection selection
= fViewer
.getSelection();
375 ITmfFilterTreeNode filterTreeNode
= null;
376 if (selection
instanceof StructuredSelection
) {
377 Object element
= ((StructuredSelection
) selection
).getFirstElement();
378 if (element
instanceof ITmfFilterTreeNode
) {
379 filterTreeNode
= (ITmfFilterTreeNode
) element
;
383 final ITmfFilterTreeNode selectedNode
= filterTreeNode
;
387 public void addSelectionChangedListener(ISelectionChangedListener listener
) {
388 fViewer
.addSelectionChangedListener(listener
);
391 public void removeSelectionChangedListener(ISelectionChangedListener listener
) {
392 fViewer
.removeSelectionChangedListener(listener
);
396 public boolean setFocus() {
397 return fViewer
.getControl().setFocus();
401 * @return whether the tree is in focus or not
403 public boolean isTreeInFocus() {
404 return fViewer
.getControl().isFocusControl();
408 * Gets the TreeViewer displaying filters
410 * @return a {@link TreeViewer}
412 TreeViewer
getTreeViewer() {
416 private class FilterBaseNodeComposite
extends Composite
{
418 FilterBaseNodeComposite(Composite parent
) {
419 super(parent
, SWT
.NONE
);
420 setLayout(new GridLayout(2, false));
421 setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
422 setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
425 protected Map
<String
, TraceTypeHelper
> getTraceTypeMap() {
426 Map
<String
, TraceTypeHelper
> traceTypeMap
= new TreeMap
<>();
427 for (TraceTypeHelper helper
: TmfTraceType
.getTraceTypeHelpers()) {
428 if (!helper
.isExperimentType()) {
429 traceTypeMap
.put(helper
.getLabel(), helper
);
436 private abstract class FilterAspectNodeComposite
extends FilterBaseNodeComposite
{
437 TmfFilterAspectNode fAspectNode
;
438 Combo fTraceTypeCombo
;
442 List
<AspectItem
> fAspectList
= null;
444 FilterAspectNodeComposite(Composite parent
, TmfFilterAspectNode node
) {
449 protected void createAspectControls() {
450 Label label
= new Label(this, SWT
.NONE
);
451 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
452 label
.setText(Messages
.FilterViewer_TypeLabel
);
454 final List
<TraceTypeItem
> traceTypeList
= getTraceTypeList(fAspectNode
);
456 fTraceTypeCombo
= new Combo(this, SWT
.DROP_DOWN
| SWT
.READ_ONLY
);
457 fTraceTypeCombo
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
458 for (TraceTypeItem traceType
: traceTypeList
) {
459 fTraceTypeCombo
.add(traceType
.label
);
461 if (fAspectNode
.getTraceTypeId() == null) {
462 fTraceTypeCombo
.select(0);
463 fAspectNode
.setTraceTypeId(traceTypeList
.get(0).traceTypeId
);
465 for (int i
= 0; i
< traceTypeList
.size(); i
++) {
466 TraceTypeItem traceType
= traceTypeList
.get(i
);
467 if (fAspectNode
.getTraceTypeId().equals(traceType
.traceTypeId
)) {
468 fTraceTypeCombo
.select(i
);
473 fTraceTypeCombo
.addModifyListener(new ModifyListener() {
475 public void modifyText(ModifyEvent e
) {
476 TraceTypeItem traceType
= traceTypeList
.get(fTraceTypeCombo
.getSelectionIndex());
477 fAspectNode
.setTraceTypeId(traceType
.traceTypeId
);
478 fAspectList
= getAspectList(fAspectNode
.getTraceTypeId());
479 String text
= fAspectCombo
.getText();
480 fAspectCombo
.removeAll();
481 for (AspectItem aspect
: fAspectList
) {
482 fAspectCombo
.add(aspect
.label
);
484 int index
= Arrays
.asList(fAspectCombo
.getItems()).indexOf(text
);
485 if (index
>= 0 && !text
.isEmpty()) {
486 fAspectCombo
.select(index
);
488 fViewer
.refresh(fAspectNode
);
492 label
= new Label(this, SWT
.NONE
);
493 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
494 label
.setText(Messages
.FilterViewer_AspectLabel
);
496 fAspectList
= getAspectList(fAspectNode
.getTraceTypeId());
498 fAspectCombo
= new Combo(this, SWT
.DROP_DOWN
| SWT
.READ_ONLY
);
499 fAspectCombo
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
500 for (AspectItem aspect
: fAspectList
) {
501 fAspectCombo
.add(aspect
.label
);
503 if (fAspectNode
.getEventAspect() != null) {
504 for (int i
= 0; i
< fAspectList
.size(); i
++) {
505 AspectItem aspect
= fAspectList
.get(i
);
506 if (aspect
.eventAspect
!= null &&
507 fAspectNode
.getEventAspect().getName().equals(aspect
.eventAspect
.getName()) &&
508 (fAspectNode
.getTraceTypeId().equals(aspect
.traceTypeId
) ||
509 fAspectNode
.getTraceTypeId().equals(TmfFilterAspectNode
.BASE_ASPECT_ID
))) {
510 fAspectCombo
.select(i
);
511 if (fAspectNode
.getEventAspect() instanceof TmfEventFieldAspect
) {
512 aspect
.eventAspect
= fAspectNode
.getEventAspect();
513 createFieldControls((TmfEventFieldAspect
) fAspectNode
.getEventAspect(), aspect
);
519 fAspectCombo
.addModifyListener(new ModifyListener() {
521 public void modifyText(ModifyEvent e
) {
522 int selection
= fAspectCombo
.getSelectionIndex();
523 AspectItem aspect
= null;
524 if (selection
!= -1) {
525 aspect
= fAspectList
.get(fAspectCombo
.getSelectionIndex());
526 fAspectNode
.setEventAspect(aspect
.eventAspect
);
528 fAspectNode
.setEventAspect(null);
530 if (fAspectNode
.getEventAspect() instanceof TmfEventFieldAspect
) {
531 TmfEventFieldAspect eventFieldAspect
= (TmfEventFieldAspect
) fAspectNode
.getEventAspect();
532 createFieldControls(eventFieldAspect
, aspect
);
534 } else if (fFieldLabel
!= null && fFieldText
!= null) {
535 fFieldLabel
.dispose();
537 fFieldText
.dispose();
541 fViewer
.refresh(fAspectNode
);
546 private void createFieldControls(final TmfEventFieldAspect eventFieldAspect
, final AspectItem aspect
) {
547 if (fFieldLabel
!= null) {
548 fFieldLabel
.dispose();
550 fFieldLabel
= new Label(this, SWT
.NONE
);
551 fFieldLabel
.moveBelow(fAspectCombo
);
552 fFieldLabel
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
553 fFieldLabel
.setText(Messages
.FilterViewer_FieldLabel
);
555 if (fFieldText
!= null) {
556 fFieldText
.dispose();
558 fFieldText
= new Text(this, SWT
.BORDER
);
559 fFieldText
.moveBelow(fFieldLabel
);
560 fFieldText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
561 fFieldText
.setToolTipText(Messages
.FilterViewer_Subfield_ToolTip
);
562 if (eventFieldAspect
.getFieldPath() != null) {
563 fFieldText
.setText(eventFieldAspect
.getFieldPath());
565 if (fFieldText
.getText().length() == 0) {
566 fFieldText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
567 fFieldText
.setText(Messages
.FilterViewer_FieldHint
);
569 fFieldText
.addFocusListener(new FocusListener() {
571 public void focusLost(FocusEvent e
) {
572 if (fFieldText
.getText().length() == 0) {
573 fFieldText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
574 fFieldText
.setText(Messages
.FilterViewer_FieldHint
);
579 public void focusGained(FocusEvent e
) {
580 if (fFieldText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
581 fFieldText
.setText(""); //$NON-NLS-1$
583 fFieldText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
586 fFieldText
.addModifyListener(new ModifyListener() {
588 public void modifyText(ModifyEvent e
) {
589 if (!fFieldText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
590 if (fFieldText
.getText().isEmpty()) {
591 fAspectNode
.setEventAspect(eventFieldAspect
.forField(null));
593 fAspectNode
.setEventAspect(eventFieldAspect
.forField(fFieldText
.getText()));
595 aspect
.eventAspect
= fAspectNode
.getEventAspect();
596 fViewer
.refresh(fAspectNode
);
602 private List
<TraceTypeItem
> getTraceTypeList(ITmfFilterTreeNode node
) {
603 ArrayList
<TraceTypeItem
> traceTypeList
= new ArrayList
<>();
604 traceTypeList
.add(new TraceTypeItem(Messages
.FilterViewer_CommonCategory
, TmfFilterAspectNode
.BASE_ASPECT_ID
));
606 ITmfFilterTreeNode curNode
= node
;
607 while (curNode
!= null) {
608 if (curNode
instanceof TmfFilterTraceTypeNode
) {
609 TmfFilterTraceTypeNode traceTypeNode
= (TmfFilterTraceTypeNode
) curNode
;
610 TraceTypeHelper helper
= TmfTraceType
.getTraceType(traceTypeNode
.getTraceTypeId());
611 if (helper
!= null) {
612 traceTypeList
.set(0, new TraceTypeItem(helper
.getLabel(), helper
.getTraceTypeId()));
614 return traceTypeList
;
616 curNode
= curNode
.getParent();
619 for (TraceTypeHelper helper
: getTraceTypeMap().values()) {
620 traceTypeList
.add(new TraceTypeItem(helper
.getLabel(), helper
.getTraceTypeId()));
622 return traceTypeList
;
625 private List
<AspectItem
> getAspectList(String traceTypeId
) {
626 ArrayList
<AspectItem
> aspectList
= new ArrayList
<>();
628 aspectList
.add(new AspectItem(Messages
.FilterViewer_CommonCategory
));
629 for (ITmfEventAspect aspect
: ITmfEventAspect
.BASE_ASPECTS
) {
630 aspectList
.add(new AspectItem(aspect
.getName(), aspect
, TmfFilterAspectNode
.BASE_ASPECT_ID
));
633 TraceTypeHelper helper
= TmfTraceType
.getTraceType(traceTypeId
);
634 if (helper
!= null) {
635 aspectList
.add(new AspectItem("")); //$NON-NLS-1$
636 aspectList
.add(new AspectItem('[' + helper
.getLabel() + ']'));
637 for (ITmfEventAspect aspect
: helper
.getTrace().getEventAspects()) {
638 for (AspectItem baseAspect
: aspectList
) {
639 if (aspect
.equals(baseAspect
.eventAspect
)) {
640 aspectList
.remove(baseAspect
);
644 aspectList
.add(new AspectItem(aspect
.getName(), aspect
, helper
.getTraceTypeId()));
651 private class FilterNodeComposite
extends FilterBaseNodeComposite
{
655 FilterNodeComposite(Composite parent
, TmfFilterNode node
) {
659 Label label
= new Label(this, SWT
.NONE
);
660 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
661 label
.setText(Messages
.FilterViewer_NameLabel
);
663 fNameText
= new Text(this, SWT
.BORDER
);
664 fNameText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
665 if (node
.getFilterName() != null && node
.getFilterName().length() > 0) {
666 fNameText
.setText(node
.getFilterName());
668 fNameText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
669 fNameText
.setText(Messages
.FilterViewer_FilterNameHint
);
671 fNameText
.addFocusListener(new FocusListener() {
673 public void focusLost(FocusEvent e
) {
674 if (fNode
.getFilterName() == null || fNode
.getFilterName().length() == 0) {
675 fNameText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
676 fNameText
.setText(Messages
.FilterViewer_FilterNameHint
);
681 public void focusGained(FocusEvent e
) {
682 if (fNameText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
683 fNameText
.setText(""); //$NON-NLS-1$
685 fNameText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
688 fNameText
.addModifyListener(new ModifyListener() {
690 public void modifyText(ModifyEvent e
) {
691 if (!fNameText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
692 fNode
.setFilterName(fNameText
.getText());
693 fViewer
.refresh(fNode
);
700 private class FilterTraceTypeNodeComposite
extends FilterBaseNodeComposite
{
701 TmfFilterTraceTypeNode fNode
;
703 Map
<String
, TraceTypeHelper
> fTraceTypeMap
;
705 FilterTraceTypeNodeComposite(Composite parent
, TmfFilterTraceTypeNode node
) {
708 fTraceTypeMap
= getTraceTypeMap();
710 Label label
= new Label(this, SWT
.NONE
);
711 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
712 label
.setText(Messages
.FilterViewer_TypeLabel
);
714 fTypeCombo
= new Combo(this, SWT
.DROP_DOWN
| SWT
.READ_ONLY
);
715 fTypeCombo
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
716 fTypeCombo
.setItems(fTraceTypeMap
.keySet().toArray(new String
[0]));
717 if (fNode
.getTraceTypeId() != null) {
718 fTypeCombo
.setText(fNode
.getName());
720 fTypeCombo
.addModifyListener(new ModifyListener() {
722 public void modifyText(ModifyEvent e
) {
723 TraceTypeHelper helper
= checkNotNull(fTraceTypeMap
.get(fTypeCombo
.getText()));
724 fNode
.setTraceTypeId(helper
.getTraceTypeId());
725 fNode
.setTraceClass(helper
.getTraceClass());
726 fNode
.setName(fTypeCombo
.getText());
727 fViewer
.refresh(fNode
);
733 private class FilterAndNodeComposite
extends FilterBaseNodeComposite
{
734 TmfFilterAndNode fNode
;
737 FilterAndNodeComposite(Composite parent
, TmfFilterAndNode node
) {
741 Label label
= new Label(this, SWT
.NONE
);
742 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
743 label
.setText(Messages
.FilterViewer_NotLabel
);
745 fNotButton
= new Button(this, SWT
.CHECK
);
746 fNotButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
747 fNotButton
.setSelection(fNode
.isNot());
748 fNotButton
.addSelectionListener(new SelectionAdapter() {
750 public void widgetSelected(SelectionEvent e
) {
751 fNode
.setNot(fNotButton
.getSelection());
752 fViewer
.refresh(fNode
);
758 private class FilterOrNodeComposite
extends FilterBaseNodeComposite
{
759 TmfFilterOrNode fNode
;
762 FilterOrNodeComposite(Composite parent
, TmfFilterOrNode node
) {
766 Label label
= new Label(this, SWT
.NONE
);
767 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
768 label
.setText(Messages
.FilterViewer_NotLabel
);
770 fNotButton
= new Button(this, SWT
.CHECK
);
771 fNotButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
772 fNotButton
.setSelection(fNode
.isNot());
773 fNotButton
.addSelectionListener(new SelectionAdapter() {
775 public void widgetSelected(SelectionEvent e
) {
776 fNode
.setNot(fNotButton
.getSelection());
777 fViewer
.refresh(fNode
);
783 private class FilterContainsNodeComposite
extends FilterAspectNodeComposite
{
784 TmfFilterContainsNode fNode
;
787 Button fIgnoreCaseButton
;
789 FilterContainsNodeComposite(Composite parent
, TmfFilterContainsNode node
) {
793 Label label
= new Label(this, SWT
.NONE
);
794 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
795 label
.setText(Messages
.FilterViewer_NotLabel
);
797 fNotButton
= new Button(this, SWT
.CHECK
);
798 fNotButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
799 fNotButton
.setSelection(fNode
.isNot());
800 fNotButton
.addSelectionListener(new SelectionAdapter() {
802 public void widgetSelected(SelectionEvent e
) {
803 fNode
.setNot(fNotButton
.getSelection());
804 fViewer
.refresh(fNode
);
808 createAspectControls();
810 label
= new Label(this, SWT
.NONE
);
811 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
812 label
.setText(Messages
.FilterViewer_ValueLabel
);
814 fValueText
= new Text(this, SWT
.BORDER
);
815 fValueText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
816 if (node
.getValue() != null && node
.getValue().length() > 0) {
817 fValueText
.setText(node
.getValue());
819 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
820 fValueText
.setText(Messages
.FilterViewer_ValueHint
);
822 fValueText
.addFocusListener(new FocusListener() {
824 public void focusLost(FocusEvent e
) {
825 if (fNode
.getValue() == null || fNode
.getValue().length() == 0) {
826 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
827 fValueText
.setText(Messages
.FilterViewer_ValueHint
);
832 public void focusGained(FocusEvent e
) {
833 if (fValueText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
834 fValueText
.setText(""); //$NON-NLS-1$
836 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
839 fValueText
.addModifyListener(new ModifyListener() {
841 public void modifyText(ModifyEvent e
) {
842 if (!fValueText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
843 fNode
.setValue(fValueText
.getText());
844 fViewer
.refresh(fNode
);
849 label
= new Label(this, SWT
.NONE
);
850 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
852 fIgnoreCaseButton
= new Button(this, SWT
.CHECK
);
853 fIgnoreCaseButton
.setSelection(fNode
.isIgnoreCase());
854 fIgnoreCaseButton
.setText(Messages
.FilterViewer_IgnoreCaseButtonText
);
855 fIgnoreCaseButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
856 fIgnoreCaseButton
.addSelectionListener(new SelectionAdapter() {
858 public void widgetSelected(SelectionEvent e
) {
859 fNode
.setIgnoreCase(fIgnoreCaseButton
.getSelection());
860 fViewer
.refresh(fNode
);
866 private class FilterEqualsNodeComposite
extends FilterAspectNodeComposite
{
867 TmfFilterEqualsNode fNode
;
870 Button fIgnoreCaseButton
;
872 FilterEqualsNodeComposite(Composite parent
, TmfFilterEqualsNode node
) {
876 Label label
= new Label(this, SWT
.NONE
);
877 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
878 label
.setText(Messages
.FilterViewer_NotLabel
);
880 fNotButton
= new Button(this, SWT
.CHECK
);
881 fNotButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
882 fNotButton
.setSelection(fNode
.isNot());
883 fNotButton
.addSelectionListener(new SelectionAdapter() {
885 public void widgetSelected(SelectionEvent e
) {
886 fNode
.setNot(fNotButton
.getSelection());
887 fViewer
.refresh(fNode
);
891 createAspectControls();
893 label
= new Label(this, SWT
.NONE
);
894 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
895 label
.setText(Messages
.FilterViewer_ValueLabel
);
897 fValueText
= new Text(this, SWT
.BORDER
);
898 fValueText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
899 if (node
.getValue() != null && node
.getValue().length() > 0) {
900 fValueText
.setText(node
.getValue());
902 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
903 fValueText
.setText(Messages
.FilterViewer_ValueHint
);
905 fValueText
.addFocusListener(new FocusListener() {
907 public void focusLost(FocusEvent e
) {
908 if (fNode
.getValue() == null || fNode
.getValue().length() == 0) {
909 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
910 fValueText
.setText(Messages
.FilterViewer_ValueHint
);
915 public void focusGained(FocusEvent e
) {
916 if (fValueText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
917 fValueText
.setText(""); //$NON-NLS-1$
919 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
922 fValueText
.addModifyListener(new ModifyListener() {
924 public void modifyText(ModifyEvent e
) {
925 if (!fValueText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
926 fNode
.setValue(fValueText
.getText());
927 fViewer
.refresh(fNode
);
932 label
= new Label(this, SWT
.NONE
);
933 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
935 fIgnoreCaseButton
= new Button(this, SWT
.CHECK
);
936 fIgnoreCaseButton
.setSelection(fNode
.isIgnoreCase());
937 fIgnoreCaseButton
.setText(Messages
.FilterViewer_IgnoreCaseButtonText
);
938 fIgnoreCaseButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
939 fIgnoreCaseButton
.addSelectionListener(new SelectionAdapter() {
941 public void widgetSelected(SelectionEvent e
) {
942 fNode
.setIgnoreCase(fIgnoreCaseButton
.getSelection());
943 fViewer
.refresh(fNode
);
949 private class FilterMatchesNodeComposite
extends FilterAspectNodeComposite
{
950 TmfFilterMatchesNode fNode
;
954 FilterMatchesNodeComposite(Composite parent
, TmfFilterMatchesNode node
) {
958 Label label
= new Label(this, SWT
.NONE
);
959 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
960 label
.setText(Messages
.FilterViewer_NotLabel
);
962 fNotButton
= new Button(this, SWT
.CHECK
);
963 fNotButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
964 fNotButton
.setSelection(fNode
.isNot());
965 fNotButton
.addSelectionListener(new SelectionAdapter() {
967 public void widgetSelected(SelectionEvent e
) {
968 fNode
.setNot(fNotButton
.getSelection());
969 fViewer
.refresh(fNode
);
973 createAspectControls();
975 label
= new Label(this, SWT
.NONE
);
976 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
977 label
.setText(Messages
.FilterViewer_RegexLabel
);
979 fRegexText
= new Text(this, SWT
.BORDER
);
980 fRegexText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
981 if (node
.getRegex() != null && node
.getRegex().length() > 0) {
982 fRegexText
.setText(node
.getRegex());
984 fRegexText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
985 fRegexText
.setText(Messages
.FilterViewer_RegexHint
);
987 fRegexText
.addFocusListener(new FocusListener() {
989 public void focusLost(FocusEvent e
) {
990 if (fNode
.getRegex() == null || fNode
.getRegex().length() == 0) {
991 fRegexText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
992 fRegexText
.setText(Messages
.FilterViewer_RegexHint
);
997 public void focusGained(FocusEvent e
) {
998 if (fRegexText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
999 fRegexText
.setText(""); //$NON-NLS-1$
1001 fRegexText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
1004 fRegexText
.addModifyListener(new ModifyListener() {
1006 public void modifyText(ModifyEvent e
) {
1007 if (!fRegexText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
1008 fNode
.setRegex(fRegexText
.getText());
1009 fViewer
.refresh(fNode
);
1016 private class FilterCompareNodeComposite
extends FilterAspectNodeComposite
{
1017 TmfFilterCompareNode fNode
;
1024 Button fAlphaButton
;
1025 Button fTimestampButton
;
1027 FilterCompareNodeComposite(Composite parent
, TmfFilterCompareNode node
) {
1028 super(parent
, node
);
1031 Label label
= new Label(this, SWT
.NONE
);
1032 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1033 label
.setText(Messages
.FilterViewer_NotLabel
);
1035 fNotButton
= new Button(this, SWT
.CHECK
);
1036 fNotButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1037 fNotButton
.setSelection(fNode
.isNot());
1038 fNotButton
.addSelectionListener(new SelectionAdapter() {
1040 public void widgetSelected(SelectionEvent e
) {
1041 fNode
.setNot(fNotButton
.getSelection());
1042 fViewer
.refresh(fNode
);
1046 createAspectControls();
1048 label
= new Label(this, SWT
.NONE
);
1049 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1050 label
.setText(Messages
.FilterViewer_ResultLabel
);
1052 Composite resultGroup
= new Composite(this, SWT
.NONE
);
1053 GridLayout rggl
= new GridLayout(3, true);
1054 rggl
.marginHeight
= 0;
1055 rggl
.marginWidth
= 0;
1056 resultGroup
.setLayout(rggl
);
1057 resultGroup
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1059 fLTButton
= new Button(resultGroup
, SWT
.RADIO
);
1060 fLTButton
.setSelection(fNode
.getResult() < 0);
1061 fLTButton
.setText("<"); //$NON-NLS-1$
1062 fLTButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1063 fLTButton
.addSelectionListener(new SelectionAdapter() {
1065 public void widgetSelected(SelectionEvent e
) {
1066 if (fLTButton
.getSelection()) {
1067 fNode
.setResult(-1);
1069 fViewer
.refresh(fNode
);
1073 fEQButton
= new Button(resultGroup
, SWT
.RADIO
);
1074 fEQButton
.setSelection(fNode
.getResult() == 0);
1075 fEQButton
.setText("="); //$NON-NLS-1$
1076 fEQButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1077 fEQButton
.addSelectionListener(new SelectionAdapter() {
1079 public void widgetSelected(SelectionEvent e
) {
1080 if (fEQButton
.getSelection()) {
1083 fViewer
.refresh(fNode
);
1087 fGTButton
= new Button(resultGroup
, SWT
.RADIO
);
1088 fGTButton
.setSelection(fNode
.getResult() > 0);
1089 fGTButton
.setText(">"); //$NON-NLS-1$
1090 fGTButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1091 fGTButton
.addSelectionListener(new SelectionAdapter() {
1093 public void widgetSelected(SelectionEvent e
) {
1094 if (fGTButton
.getSelection()) {
1097 fViewer
.refresh(fNode
);
1101 label
= new Label(this, SWT
.NONE
);
1102 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1103 label
.setText(Messages
.FilterViewer_TypeLabel
);
1105 Composite typeGroup
= new Composite(this, SWT
.NONE
);
1106 GridLayout tggl
= new GridLayout(3, false);
1107 tggl
.marginHeight
= 0;
1108 tggl
.marginWidth
= 0;
1109 typeGroup
.setLayout(tggl
);
1110 typeGroup
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1112 fNumButton
= new Button(typeGroup
, SWT
.RADIO
);
1113 fNumButton
.setSelection(fNode
.getType() == Type
.NUM
);
1114 fNumButton
.setText(Messages
.FilterViewer_NumButtonText
);
1115 fNumButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1116 fNumButton
.addSelectionListener(new SelectionAdapter() {
1118 public void widgetSelected(SelectionEvent e
) {
1119 if (fNumButton
.getSelection()) {
1120 fNode
.setType(Type
.NUM
);
1122 fViewer
.refresh(fNode
);
1126 fAlphaButton
= new Button(typeGroup
, SWT
.RADIO
);
1127 fAlphaButton
.setSelection(fNode
.getType() == Type
.ALPHA
);
1128 fAlphaButton
.setText(Messages
.FilterViewer_AlphaButtonText
);
1129 fAlphaButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1130 fAlphaButton
.addSelectionListener(new SelectionAdapter() {
1132 public void widgetSelected(SelectionEvent e
) {
1133 if (fAlphaButton
.getSelection()) {
1134 fNode
.setType(Type
.ALPHA
);
1136 fViewer
.refresh(fNode
);
1140 fTimestampButton
= new Button(typeGroup
, SWT
.RADIO
);
1141 fTimestampButton
.setSelection(fNode
.getType() == Type
.TIMESTAMP
);
1142 fTimestampButton
.setText(Messages
.FilterViewer_TimestampButtonText
);
1143 fTimestampButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1144 fTimestampButton
.addSelectionListener(new SelectionAdapter() {
1146 public void widgetSelected(SelectionEvent e
) {
1147 if (fTimestampButton
.getSelection()) {
1148 fNode
.setType(Type
.TIMESTAMP
);
1150 fViewer
.refresh(fNode
);
1154 label
= new Label(this, SWT
.NONE
);
1155 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1156 label
.setText(Messages
.FilterViewer_ValueLabel
);
1158 fValueText
= new Text(this, SWT
.BORDER
);
1159 fValueText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
1160 if (node
.getValue() != null && node
.getValue().length() > 0) {
1161 fValueText
.setText(node
.getValue());
1163 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
1164 fValueText
.setText(Messages
.FilterViewer_ValueHint
);
1166 fValueText
.addFocusListener(new FocusListener() {
1168 public void focusLost(FocusEvent e
) {
1169 if (fNode
.getValue() == null || fNode
.getValue().length() == 0) {
1170 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
1171 fValueText
.setText(Messages
.FilterViewer_ValueHint
);
1176 public void focusGained(FocusEvent e
) {
1177 if (fValueText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
1178 fValueText
.setText(""); //$NON-NLS-1$
1180 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
1183 fValueText
.addModifyListener(new ModifyListener() {
1185 public void modifyText(ModifyEvent e
) {
1186 if (!fValueText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
1187 fNode
.setValue(fValueText
.getText());
1188 fViewer
.refresh(fNode
);