1 /*******************************************************************************
2 * Copyright (c) 2010, 2014 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
.linuxtools
.tmf
.ui
.views
.filter
;
17 import java
.util
.ArrayList
;
19 import java
.util
.Map
.Entry
;
20 import java
.util
.TreeMap
;
22 import org
.eclipse
.core
.runtime
.CoreException
;
23 import org
.eclipse
.core
.runtime
.IConfigurationElement
;
24 import org
.eclipse
.jface
.action
.Action
;
25 import org
.eclipse
.jface
.action
.IMenuListener
;
26 import org
.eclipse
.jface
.action
.IMenuManager
;
27 import org
.eclipse
.jface
.action
.MenuManager
;
28 import org
.eclipse
.jface
.action
.Separator
;
29 import org
.eclipse
.jface
.util
.LocalSelectionTransfer
;
30 import org
.eclipse
.jface
.viewers
.ISelection
;
31 import org
.eclipse
.jface
.viewers
.ISelectionChangedListener
;
32 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
33 import org
.eclipse
.jface
.viewers
.SelectionChangedEvent
;
34 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
35 import org
.eclipse
.jface
.viewers
.TreeViewer
;
36 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.Messages
;
37 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
38 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEventType
;
39 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.ITmfFilterTreeNode
;
40 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterAndNode
;
41 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterCompareNode
;
42 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterCompareNode
.Type
;
43 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterContainsNode
;
44 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterEqualsNode
;
45 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterEventTypeNode
;
46 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterMatchesNode
;
47 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterNode
;
48 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterOrNode
;
49 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterRootNode
;
50 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterTreeNode
;
51 import org
.eclipse
.linuxtools
.tmf
.core
.parsers
.custom
.CustomTraceDefinition
;
52 import org
.eclipse
.linuxtools
.tmf
.core
.parsers
.custom
.CustomTraceDefinition
.OutputColumn
;
53 import org
.eclipse
.linuxtools
.tmf
.core
.parsers
.custom
.CustomTxtEvent
;
54 import org
.eclipse
.linuxtools
.tmf
.core
.parsers
.custom
.CustomTxtTraceDefinition
;
55 import org
.eclipse
.linuxtools
.tmf
.core
.parsers
.custom
.CustomXmlEvent
;
56 import org
.eclipse
.linuxtools
.tmf
.core
.parsers
.custom
.CustomXmlTraceDefinition
;
57 import org
.eclipse
.linuxtools
.tmf
.core
.project
.model
.TmfTraceType
;
58 import org
.eclipse
.swt
.SWT
;
59 import org
.eclipse
.swt
.custom
.SashForm
;
60 import org
.eclipse
.swt
.dnd
.DND
;
61 import org
.eclipse
.swt
.dnd
.DragSource
;
62 import org
.eclipse
.swt
.dnd
.DropTarget
;
63 import org
.eclipse
.swt
.dnd
.Transfer
;
64 import org
.eclipse
.swt
.events
.FocusEvent
;
65 import org
.eclipse
.swt
.events
.FocusListener
;
66 import org
.eclipse
.swt
.events
.ModifyEvent
;
67 import org
.eclipse
.swt
.events
.ModifyListener
;
68 import org
.eclipse
.swt
.events
.PaintEvent
;
69 import org
.eclipse
.swt
.events
.PaintListener
;
70 import org
.eclipse
.swt
.events
.SelectionAdapter
;
71 import org
.eclipse
.swt
.events
.SelectionEvent
;
72 import org
.eclipse
.swt
.layout
.FillLayout
;
73 import org
.eclipse
.swt
.layout
.GridData
;
74 import org
.eclipse
.swt
.layout
.GridLayout
;
75 import org
.eclipse
.swt
.widgets
.Button
;
76 import org
.eclipse
.swt
.widgets
.Combo
;
77 import org
.eclipse
.swt
.widgets
.Composite
;
78 import org
.eclipse
.swt
.widgets
.Control
;
79 import org
.eclipse
.swt
.widgets
.Display
;
80 import org
.eclipse
.swt
.widgets
.Label
;
81 import org
.eclipse
.swt
.widgets
.Menu
;
82 import org
.eclipse
.swt
.widgets
.Text
;
83 import org
.eclipse
.swt
.widgets
.TreeItem
;
85 class FilterViewer
extends Composite
{
87 private static final String SEP
= " : "; //$NON-NLS-1$
89 private TreeViewer fViewer
;
91 private Composite fComposite
;
92 private MenuManager fMenuManager
;
94 public FilterViewer(Composite parent
, int style
) {
97 setLayout(new FillLayout());
98 GridData gd
= new GridData(SWT
.FILL
, SWT
.FILL
, true, true);
101 final SashForm sash
= new SashForm(this, SWT
.HORIZONTAL
);
103 // Create the tree viewer to display the filter tree
104 fViewer
= new TreeViewer(sash
, SWT
.NONE
);
105 fViewer
.setContentProvider(new FilterTreeContentProvider());
106 fViewer
.setLabelProvider(new FilterTreeLabelProvider());
107 fViewer
.setInput(new TmfFilterRootNode());
109 // Create the empty filter node properties panel
110 fComposite
= new Composite(sash
, SWT
.NONE
);
111 GridLayout gl
= new GridLayout();
114 fComposite
.setLayout(gl
);
118 fViewer
.addSelectionChangedListener(new ISelectionChangedListener() {
120 public void selectionChanged(SelectionChangedEvent event
) {
121 if (!(event
.getSelection().isEmpty()) && event
.getSelection() instanceof IStructuredSelection
) {
122 // Update the filter node properties panel to the selection
123 IStructuredSelection selection
= (IStructuredSelection
) event
.getSelection();
124 ITmfFilterTreeNode node
= (ITmfFilterTreeNode
) selection
.getFirstElement();
125 updateFilterNodeComposite(node
);
126 // Highlight the selection's children
127 highlightTreeItems(fViewer
.getTree().getSelection()[0].getItems());
129 updateFilterNodeComposite(null);
134 fViewer
.getTree().addPaintListener(new PaintListener() {
136 public void paintControl(PaintEvent e
) {
137 TmfFilterTreeNode root
= (TmfFilterTreeNode
) fViewer
.getInput();
138 if (root
== null || root
.getChildrenCount() == 0) {
139 e
.gc
.setForeground(Display
.getDefault().getSystemColor(SWT
.COLOR_BLACK
));
140 e
.gc
.drawText(Messages
.FilterViewer_EmptyTreeHintText
, 5, 0);
145 int operations
= DND
.DROP_MOVE
| DND
.DROP_COPY
;
146 DragSource dragSource
= new org
.eclipse
.swt
.dnd
.DragSource(fViewer
.getTree(), operations
);
147 dragSource
.setTransfer(new Transfer
[] { LocalSelectionTransfer
.getTransfer() });
148 dragSource
.addDragListener(new FilterDragSourceAdapter(this));
149 DropTarget dropTarget
= new DropTarget(fViewer
.getTree(), operations
);
150 dropTarget
.setTransfer(new Transfer
[] { LocalSelectionTransfer
.getTransfer() });
151 dropTarget
.addDropListener(new FilterDropTargetAdapter(this));
155 * Create the context menu for the tree viewer
157 private void createContextMenu() {
158 // Adds root context menu
159 fMenuManager
= new MenuManager();
160 fMenuManager
.setRemoveAllWhenShown(true);
161 fMenuManager
.addMenuListener(new IMenuListener() {
163 public void menuAboutToShow(IMenuManager manager
) {
164 fillContextMenu(manager
);
169 Menu contextMenu
= fMenuManager
.createContextMenu(fViewer
.getTree());
172 fViewer
.getTree().setMenu(contextMenu
);
175 public MenuManager
getMenuManager() {
180 * Fill the context menu for the tree viewer.
185 protected void fillContextMenu(IMenuManager manager
) {
186 final ISelection selection
= fViewer
.getSelection();
187 ITmfFilterTreeNode filterTreeNode
= null;
188 if (selection
instanceof StructuredSelection
) {
189 Object element
= ((StructuredSelection
) selection
).getFirstElement();
190 if (element
instanceof ITmfFilterTreeNode
) {
191 filterTreeNode
= (ITmfFilterTreeNode
) element
;
195 if (filterTreeNode
!= null) {
196 fillContextMenuForNode(filterTreeNode
, manager
);
198 manager
.add(new Separator("delete")); //$NON-NLS-1$
199 manager
.add(new Separator("edit")); //$NON-NLS-1$
201 if (fViewer
.getInput() instanceof TmfFilterRootNode
|| filterTreeNode
== null) {
202 manager
.add(new Separator());
203 ITmfFilterTreeNode root
= (ITmfFilterTreeNode
) fViewer
.getInput();
204 fillContextMenuForNode(root
, manager
);
209 * Fill the context menu with the valid children of the provided node
216 protected void fillContextMenuForNode(final ITmfFilterTreeNode node
, IMenuManager manager
) {
217 for (final String child
: node
.getValidChildren()) {
218 final Action action
= new Action() {
221 ITmfFilterTreeNode newNode
= null;
222 if (TmfFilterNode
.NODE_NAME
.equals(child
)) {
223 newNode
= new TmfFilterNode(node
, ""); //$NON-NLS-1$
224 } else if (TmfFilterEventTypeNode
.NODE_NAME
.equals(child
)) {
225 newNode
= new TmfFilterEventTypeNode(node
);
226 } else if (TmfFilterAndNode
.NODE_NAME
.equals(child
)) {
227 newNode
= new TmfFilterAndNode(node
);
228 } else if (TmfFilterOrNode
.NODE_NAME
.equals(child
)) {
229 newNode
= new TmfFilterOrNode(node
);
230 } else if (TmfFilterContainsNode
.NODE_NAME
.equals(child
)) {
231 newNode
= new TmfFilterContainsNode(node
);
232 } else if (TmfFilterEqualsNode
.NODE_NAME
.equals(child
)) {
233 newNode
= new TmfFilterEqualsNode(node
);
234 } else if (TmfFilterMatchesNode
.NODE_NAME
.equals(child
)) {
235 newNode
= new TmfFilterMatchesNode(node
);
236 } else if (TmfFilterCompareNode
.NODE_NAME
.equals(child
)) {
237 newNode
= new TmfFilterCompareNode(node
);
239 if (newNode
!= null) {
241 fViewer
.setSelection(new StructuredSelection(newNode
), true);
245 if (TmfFilterNode
.NODE_NAME
.equals(child
)) {
246 action
.setText(Messages
.FilterViewer_NewPrefix
+ " " + child
); //$NON-NLS-1$
248 action
.setText(child
);
255 * Create the appropriate filter node properties composite
257 private void updateFilterNodeComposite(ITmfFilterTreeNode node
) {
258 for (Control control
: fComposite
.getChildren()) {
262 if (node
instanceof TmfFilterNode
) {
263 new FilterNodeComposite(fComposite
, (TmfFilterNode
) node
);
264 } else if (node
instanceof TmfFilterEventTypeNode
) {
265 new FilterEventTypeNodeComposite(fComposite
, (TmfFilterEventTypeNode
) node
);
266 } else if (node
instanceof TmfFilterAndNode
) {
267 new FilterAndNodeComposite(fComposite
, (TmfFilterAndNode
) node
);
268 } else if (node
instanceof TmfFilterOrNode
) {
269 new FilterOrNodeComposite(fComposite
, (TmfFilterOrNode
) node
);
270 } else if (node
instanceof TmfFilterContainsNode
) {
271 new FilterContainsNodeComposite(fComposite
, (TmfFilterContainsNode
) node
);
272 } else if (node
instanceof TmfFilterEqualsNode
) {
273 new FilterEqualsNodeComposite(fComposite
, (TmfFilterEqualsNode
) node
);
274 } else if (node
instanceof TmfFilterMatchesNode
) {
275 new FilterMatchesNodeComposite(fComposite
, (TmfFilterMatchesNode
) node
);
276 } else if (node
instanceof TmfFilterCompareNode
) {
277 new FilterCompareNodeComposite(fComposite
, (TmfFilterCompareNode
) node
);
279 new FilterBaseNodeComposite(fComposite
);
285 * Highlight the provided tree items
287 private void highlightTreeItems(TreeItem
[] items
) {
288 resetTreeItems(fViewer
.getTree().getItems());
289 for (TreeItem item
: items
) {
290 item
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLUE
));
296 * Reset the provided tree items (remove highlight)
298 private void resetTreeItems(TreeItem
[] items
) {
299 for (TreeItem item
: items
) {
300 item
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
301 resetTreeItems(item
.getItems());
305 public void setInput(ITmfFilterTreeNode root
) {
306 fViewer
.setInput(root
);
309 updateFilterNodeComposite(null);
312 public ITmfFilterTreeNode
getInput() {
313 return (ITmfFilterTreeNode
) fViewer
.getInput();
316 public void refresh() {
320 public void setSelection(ITmfFilterTreeNode node
, boolean reveal
) {
321 fViewer
.setSelection(new StructuredSelection(node
), reveal
);
324 public void setSelection(ITmfFilterTreeNode node
) {
325 fViewer
.setSelection(new StructuredSelection(node
));
328 public ITmfFilterTreeNode
getSelection() {
329 final ISelection selection
= fViewer
.getSelection();
330 ITmfFilterTreeNode filterTreeNode
= null;
331 if (selection
instanceof StructuredSelection
) {
332 Object element
= ((StructuredSelection
) selection
).getFirstElement();
333 if (element
instanceof ITmfFilterTreeNode
) {
334 filterTreeNode
= (ITmfFilterTreeNode
) element
;
338 final ITmfFilterTreeNode selectedNode
= filterTreeNode
;
342 public void addSelectionChangedListener(ISelectionChangedListener listener
) {
343 fViewer
.addSelectionChangedListener(listener
);
346 public void removeSelectionChangedListener(ISelectionChangedListener listener
) {
347 fViewer
.removeSelectionChangedListener(listener
);
351 * Gets the TreeViewer displaying filters
353 * @return a {@link TreeViewer}
355 TreeViewer
getTreeViewer() {
359 private class FilterBaseNodeComposite
extends Composite
{
361 FilterBaseNodeComposite(Composite parent
) {
362 super(parent
, SWT
.NONE
);
363 setLayout(new GridLayout(2, false));
364 setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
365 setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
368 protected Map
<String
, Object
> getEventsTypeMap() {
369 Map
<String
, Object
> eventsTypeMap
= new TreeMap
<>();
370 for (IConfigurationElement ce
: TmfTraceType
.getTypeElements()) {
371 String categoryPrefix
= ""; //$NON-NLS-1$
372 String categoryId
= ce
.getAttribute(TmfTraceType
.CATEGORY_ATTR
);
373 if (categoryId
!= null) {
374 categoryPrefix
= TmfTraceType
.getCategoryName(categoryId
) + SEP
;
376 String text
= categoryPrefix
+ ce
.getAttribute(TmfTraceType
.NAME_ATTR
);
377 eventsTypeMap
.put(text
, ce
);
379 for (CustomTxtTraceDefinition def
: CustomTxtTraceDefinition
.loadAll()) {
380 String text
= def
.categoryName
+ SEP
+ def
.definitionName
;
381 eventsTypeMap
.put(text
, def
);
383 for (CustomXmlTraceDefinition def
: CustomXmlTraceDefinition
.loadAll()) {
384 String text
= def
.categoryName
+ SEP
+ def
.definitionName
;
385 eventsTypeMap
.put(text
, def
);
387 return eventsTypeMap
;
390 protected String
[] getFieldsList(ITmfFilterTreeNode node
) {
391 ArrayList
<String
> fieldsList
= new ArrayList
<>();
392 ITmfFilterTreeNode curNode
= node
;
393 while (curNode
!= null) {
394 if (curNode
instanceof TmfFilterEventTypeNode
) {
395 TmfFilterEventTypeNode eventTypeNode
= (TmfFilterEventTypeNode
) curNode
;
396 for (IConfigurationElement ce
: TmfTraceType
.getTypeElements()) {
397 if (ce
.getAttribute(TmfTraceType
.EVENT_TYPE_ATTR
).equals(eventTypeNode
.getEventType())) {
399 ITmfEvent event
= (ITmfEvent
) ce
.createExecutableExtension(TmfTraceType
.EVENT_TYPE_ATTR
);
400 ITmfEventType eventType
= event
.getType();
401 if (eventType
!= null) {
402 for (String field
: eventType
.getRootField().getFieldNames()) {
403 fieldsList
.add(field
);
406 } catch (CoreException e
) {
408 if (fieldsList
.size() == 0) {
409 fieldsList
.add(ITmfEvent
.EVENT_FIELD_TIMESTAMP
);
410 fieldsList
.add(ITmfEvent
.EVENT_FIELD_SOURCE
);
411 fieldsList
.add(ITmfEvent
.EVENT_FIELD_TYPE
);
412 fieldsList
.add(ITmfEvent
.EVENT_FIELD_REFERENCE
);
413 fieldsList
.add(ITmfEvent
.EVENT_FIELD_CONTENT
);
415 return fieldsList
.toArray(new String
[0]);
418 if (eventTypeNode
.getEventType() != null && eventTypeNode
.getEventType().startsWith(CustomTxtEvent
.class.getCanonicalName())) {
419 for (CustomTxtTraceDefinition def
: CustomTxtTraceDefinition
.loadAll()) {
420 if (eventTypeNode
.getEventType().equals(CustomTxtEvent
.class.getCanonicalName() + ':' + def
.categoryName
+ ':' + def
.definitionName
)) {
421 for (OutputColumn output
: def
.outputs
) {
422 fieldsList
.add(output
.name
);
424 return fieldsList
.toArray(new String
[0]);
428 if (eventTypeNode
.getEventType() != null && eventTypeNode
.getEventType().startsWith(CustomXmlEvent
.class.getCanonicalName())) {
429 for (CustomXmlTraceDefinition def
: CustomXmlTraceDefinition
.loadAll()) {
430 if (eventTypeNode
.getEventType().equals(CustomXmlEvent
.class.getCanonicalName() + ':' + def
.categoryName
+ ':' + def
.definitionName
)) {
431 for (OutputColumn output
: def
.outputs
) {
432 fieldsList
.add(output
.name
);
434 return fieldsList
.toArray(new String
[0]);
439 curNode
= curNode
.getParent();
442 fieldsList
.add(Messages
.FilterViewer_CommonCategory
);
443 fieldsList
.add(ITmfEvent
.EVENT_FIELD_TIMESTAMP
);
444 fieldsList
.add(ITmfEvent
.EVENT_FIELD_SOURCE
);
445 fieldsList
.add(ITmfEvent
.EVENT_FIELD_TYPE
);
446 fieldsList
.add(ITmfEvent
.EVENT_FIELD_REFERENCE
);
447 fieldsList
.add(ITmfEvent
.EVENT_FIELD_CONTENT
);
448 fieldsList
.add(""); //$NON-NLS-1$
450 for (Entry
<String
, Object
> eventTypeEntry
: getEventsTypeMap().entrySet()) {
451 Object value
= eventTypeEntry
.getValue();
452 if (value
instanceof IConfigurationElement
) {
453 IConfigurationElement ce
= (IConfigurationElement
) value
;
455 ITmfEvent event
= (ITmfEvent
) ce
.createExecutableExtension(TmfTraceType
.EVENT_TYPE_ATTR
);
456 ITmfEventType eventType
= event
.getType();
457 if (eventType
!= null && eventType
.getFieldNames().size() > 0) {
458 String categoryId
= ce
.getAttribute(TmfTraceType
.CATEGORY_ATTR
);
459 if (categoryId
!= null) {
460 fieldsList
.add('[' + TmfTraceType
.getCategoryName(categoryId
) + SEP
461 + ce
.getAttribute(TmfTraceType
.NAME_ATTR
) + ']');
463 fieldsList
.add('[' + ce
.getAttribute(TmfTraceType
.NAME_ATTR
) + ']');
465 for (String field
: eventType
.getFieldNames()) {
466 fieldsList
.add(field
);
468 fieldsList
.add(""); //$NON-NLS-1$
470 } catch (CoreException e
) {
472 } else if (value
instanceof CustomTraceDefinition
) {
473 CustomTraceDefinition def
= (CustomTraceDefinition
) value
;
474 if (def
.outputs
.size() > 0) {
475 fieldsList
.add('[' + def
.categoryName
+ SEP
+ def
.definitionName
+ ']');
476 for (OutputColumn output
: def
.outputs
) {
477 fieldsList
.add(output
.name
);
479 fieldsList
.add(""); //$NON-NLS-1$
483 return fieldsList
.toArray(new String
[0]);
487 private class FilterNodeComposite
extends FilterBaseNodeComposite
{
491 FilterNodeComposite(Composite parent
, TmfFilterNode node
) {
495 Label label
= new Label(this, SWT
.NONE
);
496 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
497 label
.setText(Messages
.FilterViewer_NameLabel
);
499 fNameText
= new Text(this, SWT
.BORDER
);
500 fNameText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
501 if (node
.getFilterName() != null && node
.getFilterName().length() > 0) {
502 fNameText
.setText(node
.getFilterName());
504 fNameText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
505 fNameText
.setText(Messages
.FilterViewer_FilterNameHint
);
507 fNameText
.addFocusListener(new FocusListener() {
509 public void focusLost(FocusEvent e
) {
510 if (fNode
.getFilterName() == null || fNode
.getFilterName().length() == 0) {
511 fNameText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
512 fNameText
.setText(Messages
.FilterViewer_FilterNameHint
);
517 public void focusGained(FocusEvent e
) {
518 if (fNameText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
519 fNameText
.setText(""); //$NON-NLS-1$
521 fNameText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
524 fNameText
.addModifyListener(new ModifyListener() {
526 public void modifyText(ModifyEvent e
) {
527 if (!fNameText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
528 fNode
.setFilterName(fNameText
.getText());
529 fViewer
.refresh(fNode
);
536 private class FilterEventTypeNodeComposite
extends FilterBaseNodeComposite
{
537 TmfFilterEventTypeNode fNode
;
539 Map
<String
, Object
> fEventsTypeMap
;
541 FilterEventTypeNodeComposite(Composite parent
, TmfFilterEventTypeNode node
) {
544 fEventsTypeMap
= getEventsTypeMap();
546 Label label
= new Label(this, SWT
.NONE
);
547 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
548 label
.setText(Messages
.FilterViewer_TypeLabel
);
550 fTypeCombo
= new Combo(this, SWT
.DROP_DOWN
| SWT
.READ_ONLY
);
551 fTypeCombo
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
552 fTypeCombo
.setItems(fEventsTypeMap
.keySet().toArray(new String
[0]));
553 if (fNode
.getEventType() != null) {
554 fTypeCombo
.setText(fNode
.getName());
556 fTypeCombo
.addModifyListener(new ModifyListener() {
558 public void modifyText(ModifyEvent e
) {
559 for (Entry
<String
, Object
> eventTypeEntry
: fEventsTypeMap
.entrySet()) {
560 if (eventTypeEntry
.getKey().equals(fTypeCombo
.getText())) {
561 Object value
= eventTypeEntry
.getValue();
562 if (value
instanceof IConfigurationElement
) {
563 IConfigurationElement ce
= (IConfigurationElement
) value
;
564 fNode
.setEventType(ce
.getAttribute(TmfTraceType
.EVENT_TYPE_ATTR
));
565 String categoryId
= ce
.getAttribute(TmfTraceType
.CATEGORY_ATTR
);
566 if (categoryId
!= null) {
567 fNode
.setName(TmfTraceType
.getCategoryName(categoryId
) + SEP
568 + ce
.getAttribute(TmfTraceType
.NAME_ATTR
));
570 fNode
.setName(ce
.getAttribute(TmfTraceType
.NAME_ATTR
));
572 } else if (value
instanceof CustomTxtTraceDefinition
) {
573 CustomTxtTraceDefinition def
= (CustomTxtTraceDefinition
) value
;
574 fNode
.setEventType(CustomTxtEvent
.class.getCanonicalName() + ':' + def
.categoryName
+ ':' + def
.definitionName
);
575 fNode
.setName(def
.categoryName
+ SEP
+ def
.definitionName
);
576 } else if (value
instanceof CustomXmlTraceDefinition
) {
577 CustomXmlTraceDefinition def
= (CustomXmlTraceDefinition
) value
;
578 fNode
.setEventType(CustomXmlEvent
.class.getCanonicalName() + ':' + def
.categoryName
+ ':' + def
.definitionName
);
579 fNode
.setName(def
.categoryName
+ SEP
+ def
.definitionName
);
581 fViewer
.refresh(fNode
);
590 private class FilterAndNodeComposite
extends FilterBaseNodeComposite
{
591 TmfFilterAndNode fNode
;
594 FilterAndNodeComposite(Composite parent
, TmfFilterAndNode node
) {
598 Label label
= new Label(this, SWT
.NONE
);
599 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
600 label
.setText(Messages
.FilterViewer_NotLabel
);
602 fNotButton
= new Button(this, SWT
.CHECK
);
603 fNotButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
604 fNotButton
.setSelection(fNode
.isNot());
605 fNotButton
.addSelectionListener(new SelectionAdapter() {
607 public void widgetSelected(SelectionEvent e
) {
608 fNode
.setNot(fNotButton
.getSelection());
609 fViewer
.refresh(fNode
);
615 private class FilterOrNodeComposite
extends FilterBaseNodeComposite
{
616 TmfFilterOrNode fNode
;
619 FilterOrNodeComposite(Composite parent
, TmfFilterOrNode node
) {
623 Label label
= new Label(this, SWT
.NONE
);
624 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
625 label
.setText(Messages
.FilterViewer_NotLabel
);
627 fNotButton
= new Button(this, SWT
.CHECK
);
628 fNotButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
629 fNotButton
.setSelection(fNode
.isNot());
630 fNotButton
.addSelectionListener(new SelectionAdapter() {
632 public void widgetSelected(SelectionEvent e
) {
633 fNode
.setNot(fNotButton
.getSelection());
634 fViewer
.refresh(fNode
);
640 private class FilterContainsNodeComposite
extends FilterBaseNodeComposite
{
641 TmfFilterContainsNode fNode
;
645 Button fIgnoreCaseButton
;
647 FilterContainsNodeComposite(Composite parent
, TmfFilterContainsNode node
) {
651 Label label
= new Label(this, SWT
.NONE
);
652 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
653 label
.setText(Messages
.FilterViewer_NotLabel
);
655 fNotButton
= new Button(this, SWT
.CHECK
);
656 fNotButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
657 fNotButton
.setSelection(fNode
.isNot());
658 fNotButton
.addSelectionListener(new SelectionAdapter() {
660 public void widgetSelected(SelectionEvent e
) {
661 fNode
.setNot(fNotButton
.getSelection());
662 fViewer
.refresh(fNode
);
666 label
= new Label(this, SWT
.NONE
);
667 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
668 label
.setText(Messages
.FilterViewer_FieldLabel
);
670 fFieldCombo
= new Combo(this, SWT
.DROP_DOWN
);
671 fFieldCombo
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
672 fFieldCombo
.setItems(getFieldsList(fNode
));
673 fFieldCombo
.setToolTipText(Messages
.FilterViewer_Subfilter_ToolTip
);
674 if (fNode
.getField() != null) {
675 fFieldCombo
.setText(fNode
.getField());
677 fFieldCombo
.addModifyListener(new ModifyListener() {
679 public void modifyText(ModifyEvent e
) {
680 fNode
.setField(fFieldCombo
.getText());
681 fViewer
.refresh(fNode
);
685 label
= new Label(this, SWT
.NONE
);
686 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
687 label
.setText(Messages
.FilterViewer_ValueLabel
);
689 fValueText
= new Text(this, SWT
.BORDER
);
690 fValueText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
691 if (node
.getValue() != null && node
.getValue().length() > 0) {
692 fValueText
.setText(node
.getValue());
694 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
695 fValueText
.setText(Messages
.FilterViewer_ValueHint
);
697 fValueText
.addFocusListener(new FocusListener() {
699 public void focusLost(FocusEvent e
) {
700 if (fNode
.getValue() == null || fNode
.getValue().length() == 0) {
701 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
702 fValueText
.setText(Messages
.FilterViewer_ValueHint
);
707 public void focusGained(FocusEvent e
) {
708 if (fValueText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
709 fValueText
.setText(""); //$NON-NLS-1$
711 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
714 fValueText
.addModifyListener(new ModifyListener() {
716 public void modifyText(ModifyEvent e
) {
717 if (!fValueText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
718 fNode
.setValue(fValueText
.getText());
719 fViewer
.refresh(fNode
);
724 label
= new Label(this, SWT
.NONE
);
725 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
727 fIgnoreCaseButton
= new Button(this, SWT
.CHECK
);
728 fIgnoreCaseButton
.setSelection(fNode
.isIgnoreCase());
729 fIgnoreCaseButton
.setText(Messages
.FilterViewer_IgnoreCaseButtonText
);
730 fIgnoreCaseButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
731 fIgnoreCaseButton
.addSelectionListener(new SelectionAdapter() {
733 public void widgetSelected(SelectionEvent e
) {
734 fNode
.setIgnoreCase(fIgnoreCaseButton
.getSelection());
735 fViewer
.refresh(fNode
);
741 private class FilterEqualsNodeComposite
extends FilterBaseNodeComposite
{
742 TmfFilterEqualsNode fNode
;
746 Button fIgnoreCaseButton
;
748 FilterEqualsNodeComposite(Composite parent
, TmfFilterEqualsNode node
) {
752 Label label
= new Label(this, SWT
.NONE
);
753 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
754 label
.setText(Messages
.FilterViewer_NotLabel
);
756 fNotButton
= new Button(this, SWT
.CHECK
);
757 fNotButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
758 fNotButton
.setSelection(fNode
.isNot());
759 fNotButton
.addSelectionListener(new SelectionAdapter() {
761 public void widgetSelected(SelectionEvent e
) {
762 fNode
.setNot(fNotButton
.getSelection());
763 fViewer
.refresh(fNode
);
767 label
= new Label(this, SWT
.NONE
);
768 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
769 label
.setText(Messages
.FilterViewer_FieldLabel
);
771 fFieldCombo
= new Combo(this, SWT
.DROP_DOWN
);
772 fFieldCombo
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
773 fFieldCombo
.setItems(getFieldsList(fNode
));
774 fFieldCombo
.setToolTipText(Messages
.FilterViewer_Subfilter_ToolTip
);
775 if (fNode
.getField() != null) {
776 fFieldCombo
.setText(fNode
.getField());
778 fFieldCombo
.addModifyListener(new ModifyListener() {
780 public void modifyText(ModifyEvent e
) {
781 fNode
.setField(fFieldCombo
.getText());
782 fViewer
.refresh(fNode
);
786 label
= new Label(this, SWT
.NONE
);
787 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
788 label
.setText(Messages
.FilterViewer_ValueLabel
);
790 fValueText
= new Text(this, SWT
.BORDER
);
791 fValueText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
792 if (node
.getValue() != null && node
.getValue().length() > 0) {
793 fValueText
.setText(node
.getValue());
795 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
796 fValueText
.setText(Messages
.FilterViewer_ValueHint
);
798 fValueText
.addFocusListener(new FocusListener() {
800 public void focusLost(FocusEvent e
) {
801 if (fNode
.getValue() == null || fNode
.getValue().length() == 0) {
802 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
803 fValueText
.setText(Messages
.FilterViewer_ValueHint
);
808 public void focusGained(FocusEvent e
) {
809 if (fValueText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
810 fValueText
.setText(""); //$NON-NLS-1$
812 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
815 fValueText
.addModifyListener(new ModifyListener() {
817 public void modifyText(ModifyEvent e
) {
818 if (!fValueText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
819 fNode
.setValue(fValueText
.getText());
820 fViewer
.refresh(fNode
);
825 label
= new Label(this, SWT
.NONE
);
826 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
828 fIgnoreCaseButton
= new Button(this, SWT
.CHECK
);
829 fIgnoreCaseButton
.setSelection(fNode
.isIgnoreCase());
830 fIgnoreCaseButton
.setText(Messages
.FilterViewer_IgnoreCaseButtonText
);
831 fIgnoreCaseButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
832 fIgnoreCaseButton
.addSelectionListener(new SelectionAdapter() {
834 public void widgetSelected(SelectionEvent e
) {
835 fNode
.setIgnoreCase(fIgnoreCaseButton
.getSelection());
836 fViewer
.refresh(fNode
);
842 private class FilterMatchesNodeComposite
extends FilterBaseNodeComposite
{
843 TmfFilterMatchesNode fNode
;
848 FilterMatchesNodeComposite(Composite parent
, TmfFilterMatchesNode node
) {
852 Label label
= new Label(this, SWT
.NONE
);
853 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
854 label
.setText(Messages
.FilterViewer_NotLabel
);
856 fNotButton
= new Button(this, SWT
.CHECK
);
857 fNotButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
858 fNotButton
.setSelection(fNode
.isNot());
859 fNotButton
.addSelectionListener(new SelectionAdapter() {
861 public void widgetSelected(SelectionEvent e
) {
862 fNode
.setNot(fNotButton
.getSelection());
863 fViewer
.refresh(fNode
);
867 label
= new Label(this, SWT
.NONE
);
868 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
869 label
.setText(Messages
.FilterViewer_FieldLabel
);
871 fFieldCombo
= new Combo(this, SWT
.DROP_DOWN
);
872 fFieldCombo
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
873 fFieldCombo
.setItems(getFieldsList(fNode
));
874 fFieldCombo
.setToolTipText(Messages
.FilterViewer_Subfilter_ToolTip
);
875 if (fNode
.getField() != null) {
876 fFieldCombo
.setText(fNode
.getField());
878 fFieldCombo
.addModifyListener(new ModifyListener() {
880 public void modifyText(ModifyEvent e
) {
881 fNode
.setField(fFieldCombo
.getText());
882 fViewer
.refresh(fNode
);
886 label
= new Label(this, SWT
.NONE
);
887 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
888 label
.setText(Messages
.FilterViewer_RegexLabel
);
890 fRegexText
= new Text(this, SWT
.BORDER
);
891 fRegexText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
892 if (node
.getRegex() != null && node
.getRegex().length() > 0) {
893 fRegexText
.setText(node
.getRegex());
895 fRegexText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
896 fRegexText
.setText(Messages
.FilterViewer_RegexHint
);
898 fRegexText
.addFocusListener(new FocusListener() {
900 public void focusLost(FocusEvent e
) {
901 if (fNode
.getRegex() == null || fNode
.getRegex().length() == 0) {
902 fRegexText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
903 fRegexText
.setText(Messages
.FilterViewer_RegexHint
);
908 public void focusGained(FocusEvent e
) {
909 if (fRegexText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
910 fRegexText
.setText(""); //$NON-NLS-1$
912 fRegexText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
915 fRegexText
.addModifyListener(new ModifyListener() {
917 public void modifyText(ModifyEvent e
) {
918 if (!fRegexText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
919 fNode
.setRegex(fRegexText
.getText());
920 fViewer
.refresh(fNode
);
927 private class FilterCompareNodeComposite
extends FilterBaseNodeComposite
{
928 TmfFilterCompareNode fNode
;
937 Button fTimestampButton
;
939 FilterCompareNodeComposite(Composite parent
, TmfFilterCompareNode node
) {
943 Label label
= new Label(this, SWT
.NONE
);
944 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
945 label
.setText(Messages
.FilterViewer_NotLabel
);
947 fNotButton
= new Button(this, SWT
.CHECK
);
948 fNotButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
949 fNotButton
.setSelection(fNode
.isNot());
950 fNotButton
.addSelectionListener(new SelectionAdapter() {
952 public void widgetSelected(SelectionEvent e
) {
953 fNode
.setNot(fNotButton
.getSelection());
954 fViewer
.refresh(fNode
);
958 label
= new Label(this, SWT
.NONE
);
959 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
960 label
.setText(Messages
.FilterViewer_FieldLabel
);
962 fFieldCombo
= new Combo(this, SWT
.DROP_DOWN
);
963 fFieldCombo
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
964 fFieldCombo
.setItems(getFieldsList(fNode
));
965 fFieldCombo
.setToolTipText(Messages
.FilterViewer_Subfilter_ToolTip
);
966 if (fNode
.getField() != null) {
967 fFieldCombo
.setText(fNode
.getField());
969 fFieldCombo
.addModifyListener(new ModifyListener() {
971 public void modifyText(ModifyEvent e
) {
972 fNode
.setField(fFieldCombo
.getText());
973 fViewer
.refresh(fNode
);
977 label
= new Label(this, SWT
.NONE
);
978 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
979 label
.setText(Messages
.FilterViewer_ResultLabel
);
981 Composite resultGroup
= new Composite(this, SWT
.NONE
);
982 GridLayout rggl
= new GridLayout(3, true);
983 rggl
.marginHeight
= 0;
984 rggl
.marginWidth
= 0;
985 resultGroup
.setLayout(rggl
);
986 resultGroup
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
988 fLTButton
= new Button(resultGroup
, SWT
.RADIO
);
989 fLTButton
.setSelection(fNode
.getResult() < 0);
990 fLTButton
.setText("<"); //$NON-NLS-1$
991 fLTButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
992 fLTButton
.addSelectionListener(new SelectionAdapter() {
994 public void widgetSelected(SelectionEvent e
) {
995 if (fLTButton
.getSelection()) {
998 fViewer
.refresh(fNode
);
1002 fEQButton
= new Button(resultGroup
, SWT
.RADIO
);
1003 fEQButton
.setSelection(fNode
.getResult() == 0);
1004 fEQButton
.setText("="); //$NON-NLS-1$
1005 fEQButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1006 fEQButton
.addSelectionListener(new SelectionAdapter() {
1008 public void widgetSelected(SelectionEvent e
) {
1009 if (fEQButton
.getSelection()) {
1012 fViewer
.refresh(fNode
);
1016 fGTButton
= new Button(resultGroup
, SWT
.RADIO
);
1017 fGTButton
.setSelection(fNode
.getResult() > 0);
1018 fGTButton
.setText(">"); //$NON-NLS-1$
1019 fGTButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1020 fGTButton
.addSelectionListener(new SelectionAdapter() {
1022 public void widgetSelected(SelectionEvent e
) {
1023 if (fGTButton
.getSelection()) {
1026 fViewer
.refresh(fNode
);
1030 label
= new Label(this, SWT
.NONE
);
1031 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1032 label
.setText(Messages
.FilterViewer_TypeLabel
);
1034 Composite typeGroup
= new Composite(this, SWT
.NONE
);
1035 GridLayout tggl
= new GridLayout(3, false);
1036 tggl
.marginHeight
= 0;
1037 tggl
.marginWidth
= 0;
1038 typeGroup
.setLayout(tggl
);
1039 typeGroup
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1041 fNumButton
= new Button(typeGroup
, SWT
.RADIO
);
1042 fNumButton
.setSelection(fNode
.getType() == Type
.NUM
);
1043 fNumButton
.setText(Messages
.FilterViewer_NumButtonText
);
1044 fNumButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1045 fNumButton
.addSelectionListener(new SelectionAdapter() {
1047 public void widgetSelected(SelectionEvent e
) {
1048 if (fNumButton
.getSelection()) {
1049 fNode
.setType(Type
.NUM
);
1051 fViewer
.refresh(fNode
);
1055 fAlphaButton
= new Button(typeGroup
, SWT
.RADIO
);
1056 fAlphaButton
.setSelection(fNode
.getType() == Type
.ALPHA
);
1057 fAlphaButton
.setText(Messages
.FilterViewer_AlphaButtonText
);
1058 fAlphaButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1059 fAlphaButton
.addSelectionListener(new SelectionAdapter() {
1061 public void widgetSelected(SelectionEvent e
) {
1062 if (fAlphaButton
.getSelection()) {
1063 fNode
.setType(Type
.ALPHA
);
1065 fViewer
.refresh(fNode
);
1069 fTimestampButton
= new Button(typeGroup
, SWT
.RADIO
);
1070 fTimestampButton
.setSelection(fNode
.getType() == Type
.TIMESTAMP
);
1071 fTimestampButton
.setText(Messages
.FilterViewer_TimestampButtonText
);
1072 fTimestampButton
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1073 fTimestampButton
.addSelectionListener(new SelectionAdapter() {
1075 public void widgetSelected(SelectionEvent e
) {
1076 if (fTimestampButton
.getSelection()) {
1077 fNode
.setType(Type
.TIMESTAMP
);
1079 fViewer
.refresh(fNode
);
1083 label
= new Label(this, SWT
.NONE
);
1084 label
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
1085 label
.setText(Messages
.FilterViewer_ValueLabel
);
1087 fValueText
= new Text(this, SWT
.BORDER
);
1088 fValueText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
1089 if (node
.getValue() != null && node
.getValue().length() > 0) {
1090 fValueText
.setText(node
.getValue());
1092 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
1093 fValueText
.setText(Messages
.FilterViewer_ValueHint
);
1095 fValueText
.addFocusListener(new FocusListener() {
1097 public void focusLost(FocusEvent e
) {
1098 if (fNode
.getValue() == null || fNode
.getValue().length() == 0) {
1099 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
));
1100 fValueText
.setText(Messages
.FilterViewer_ValueHint
);
1105 public void focusGained(FocusEvent e
) {
1106 if (fValueText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
1107 fValueText
.setText(""); //$NON-NLS-1$
1109 fValueText
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
1112 fValueText
.addModifyListener(new ModifyListener() {
1114 public void modifyText(ModifyEvent e
) {
1115 if (!fValueText
.getForeground().equals(Display
.getCurrent().getSystemColor(SWT
.COLOR_GRAY
))) {
1116 fNode
.setValue(fValueText
.getText());
1117 fViewer
.refresh(fNode
);