Commit | Line | Data |
---|---|---|
90e2b925 FC |
1 | /*******************************************************************************\r |
2 | * Copyright (c) 2010 Ericsson\r | |
3 | * \r | |
4 | * All rights reserved. This program and the accompanying materials are\r | |
5 | * made available under the terms of the Eclipse Public License v1.0 which\r | |
6 | * accompanies this distribution, and is available at\r | |
7 | * http://www.eclipse.org/legal/epl-v10.html\r | |
8 | * \r | |
9 | * Contributors:\r | |
10 | * Patrick Tasse - Initial API and implementation\r | |
11 | *******************************************************************************/\r | |
12 | \r | |
13 | package org.eclipse.linuxtools.tmf.ui.views.filter;\r | |
14 | \r | |
15 | import java.util.ArrayList;\r | |
16 | import java.util.LinkedHashMap;\r | |
17 | import java.util.Map;\r | |
18 | import java.util.Map.Entry;\r | |
19 | \r | |
4bf17f4a | 20 | import org.eclipse.core.runtime.CoreException;\r |
21 | import org.eclipse.core.runtime.IConfigurationElement;\r | |
90e2b925 FC |
22 | import org.eclipse.jface.action.Action;\r |
23 | import org.eclipse.jface.action.IMenuListener;\r | |
24 | import org.eclipse.jface.action.IMenuManager;\r | |
25 | import org.eclipse.jface.action.MenuManager;\r | |
26 | import org.eclipse.jface.action.Separator;\r | |
27 | import org.eclipse.jface.viewers.ISelection;\r | |
28 | import org.eclipse.jface.viewers.ISelectionChangedListener;\r | |
29 | import org.eclipse.jface.viewers.IStructuredSelection;\r | |
30 | import org.eclipse.jface.viewers.SelectionChangedEvent;\r | |
31 | import org.eclipse.jface.viewers.StructuredSelection;\r | |
32 | import org.eclipse.jface.viewers.TreeViewer;\r | |
4bf17f4a | 33 | import org.eclipse.linuxtools.tmf.event.TmfEvent;\r |
34 | import org.eclipse.linuxtools.tmf.event.TmfEventType;\r | |
90e2b925 FC |
35 | import org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode;\r |
36 | import org.eclipse.linuxtools.tmf.filter.model.TmfFilterAndNode;\r | |
37 | import org.eclipse.linuxtools.tmf.filter.model.TmfFilterCompareNode;\r | |
38 | import org.eclipse.linuxtools.tmf.filter.model.TmfFilterCompareNode.Type;\r | |
39 | import org.eclipse.linuxtools.tmf.filter.model.TmfFilterContainsNode;\r | |
40 | import org.eclipse.linuxtools.tmf.filter.model.TmfFilterEqualsNode;\r | |
41 | import org.eclipse.linuxtools.tmf.filter.model.TmfFilterEventTypeNode;\r | |
42 | import org.eclipse.linuxtools.tmf.filter.model.TmfFilterMatchesNode;\r | |
43 | import org.eclipse.linuxtools.tmf.filter.model.TmfFilterNode;\r | |
44 | import org.eclipse.linuxtools.tmf.filter.model.TmfFilterOrNode;\r | |
45 | import org.eclipse.linuxtools.tmf.filter.model.TmfFilterRootNode;\r | |
46 | import org.eclipse.linuxtools.tmf.ui.internal.Messages;\r | |
4bf17f4a | 47 | import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn;\r |
48 | import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtEvent;\r | |
49 | import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTrace;\r | |
50 | import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTraceDefinition;\r | |
51 | import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomXmlEvent;\r | |
52 | import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomXmlTrace;\r | |
53 | import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomXmlTraceDefinition;\r | |
54 | import org.eclipse.linuxtools.tmf.util.TmfTraceType;\r | |
90e2b925 FC |
55 | import org.eclipse.swt.SWT;\r |
56 | import org.eclipse.swt.custom.SashForm;\r | |
57 | import org.eclipse.swt.events.FocusEvent;\r | |
58 | import org.eclipse.swt.events.FocusListener;\r | |
59 | import org.eclipse.swt.events.ModifyEvent;\r | |
60 | import org.eclipse.swt.events.ModifyListener;\r | |
61 | import org.eclipse.swt.events.SelectionAdapter;\r | |
62 | import org.eclipse.swt.events.SelectionEvent;\r | |
63 | import org.eclipse.swt.layout.FillLayout;\r | |
64 | import org.eclipse.swt.layout.GridData;\r | |
65 | import org.eclipse.swt.layout.GridLayout;\r | |
66 | import org.eclipse.swt.widgets.Button;\r | |
67 | import org.eclipse.swt.widgets.Combo;\r | |
68 | import org.eclipse.swt.widgets.Composite;\r | |
69 | import org.eclipse.swt.widgets.Control;\r | |
70 | import org.eclipse.swt.widgets.Display;\r | |
71 | import org.eclipse.swt.widgets.Label;\r | |
72 | import org.eclipse.swt.widgets.Menu;\r | |
73 | import org.eclipse.swt.widgets.Text;\r | |
74 | import org.eclipse.swt.widgets.TreeItem;\r | |
75 | \r | |
76 | class FilterViewer extends Composite {\r | |
77 | \r | |
4bf17f4a | 78 | private static final String CUSTOM_TXT_CATEGORY = "Custom Text"; //$NON-NLS-1$\r |
79 | private static final String CUSTOM_XML_CATEGORY = "Custom XML"; //$NON-NLS-1$\r | |
80 | \r | |
90e2b925 FC |
81 | private TreeViewer fViewer;\r |
82 | private Composite fComposite;\r | |
83 | \r | |
4bf17f4a | 84 | public FilterViewer(Composite parent, int style) {\r |
85 | super(parent, style);\r | |
90e2b925 | 86 | \r |
4bf17f4a | 87 | setLayout(new FillLayout());\r |
88 | GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);\r | |
89 | setLayoutData(gd);\r | |
90 | \r | |
90e2b925 FC |
91 | final SashForm sash = new SashForm(this, SWT.HORIZONTAL);\r |
92 | \r | |
4bf17f4a | 93 | // Create the tree viewer to display the filter tree\r |
94 | fViewer = new TreeViewer(sash, SWT.NONE);\r | |
95 | fViewer.setContentProvider(new FilterTreeContentProvider());\r | |
96 | fViewer.setLabelProvider(new FilterTreeLabelProvider());\r | |
97 | fViewer.setInput(new TmfFilterRootNode());\r | |
98 | \r | |
99 | // Create the empty filter node properties panel\r | |
100 | fComposite = new Composite(sash, SWT.NONE);\r | |
101 | GridLayout gl = new GridLayout();\r | |
102 | gl.marginHeight = 0;\r | |
103 | gl.marginWidth = 0;\r | |
104 | fComposite.setLayout(gl);\r | |
90e2b925 | 105 | \r |
4bf17f4a | 106 | createContextMenu();\r |
107 | \r | |
108 | fViewer.addSelectionChangedListener(new ISelectionChangedListener() {\r | |
109 | @Override\r | |
90e2b925 | 110 | public void selectionChanged(SelectionChangedEvent event) {\r |
4bf17f4a | 111 | if (!(event.getSelection().isEmpty()) && event.getSelection() instanceof IStructuredSelection) {\r |
112 | // Update the filter node properties panel to the selection\r | |
113 | IStructuredSelection selection = (IStructuredSelection) event.getSelection();\r | |
114 | ITmfFilterTreeNode node = (ITmfFilterTreeNode) selection.getFirstElement();\r | |
115 | updateFilterNodeComposite(node);\r | |
116 | // Highlight the selection's children\r | |
117 | highlightTreeItems(fViewer.getTree().getSelection()[0].getItems());\r | |
118 | } else {\r | |
119 | updateFilterNodeComposite(null);\r | |
120 | }\r | |
121 | }\r | |
122 | });\r | |
123 | }\r | |
124 | \r | |
125 | /**\r | |
126 | * Create the context menu for the tree viewer\r | |
127 | */\r | |
128 | private void createContextMenu() {\r | |
129 | // Adds root context menu\r | |
130 | MenuManager menuManager = new MenuManager();\r | |
131 | menuManager.setRemoveAllWhenShown(true);\r | |
132 | menuManager.addMenuListener(new IMenuListener() {\r | |
133 | @Override\r | |
90e2b925 | 134 | public void menuAboutToShow(IMenuManager manager) {\r |
4bf17f4a | 135 | fillContextMenu(manager);\r |
136 | }\r | |
137 | });\r | |
90e2b925 | 138 | \r |
4bf17f4a | 139 | // Context\r |
140 | Menu contextMenu = menuManager.createContextMenu(fViewer.getTree());\r | |
90e2b925 | 141 | \r |
4bf17f4a | 142 | // Publish it\r |
143 | fViewer.getTree().setMenu(contextMenu);\r | |
144 | }\r | |
145 | \r | |
146 | /**\r | |
147 | * Fill the context menu for the tree viewer\r | |
148 | */\r | |
149 | protected void fillContextMenu(IMenuManager manager) {\r | |
150 | final ISelection selection = fViewer.getSelection();\r | |
151 | ITmfFilterTreeNode filterTreeNode = null;\r | |
152 | if (selection instanceof StructuredSelection) {\r | |
153 | Object element = ((StructuredSelection) selection).getFirstElement();\r | |
154 | if (element instanceof ITmfFilterTreeNode) {\r | |
155 | filterTreeNode = (ITmfFilterTreeNode) element;\r | |
156 | }\r | |
157 | }\r | |
90e2b925 | 158 | \r |
4bf17f4a | 159 | final ITmfFilterTreeNode selectedNode = filterTreeNode;\r |
160 | \r | |
161 | if (selectedNode != null) {\r | |
162 | \r | |
163 | fillContextMenuForNode(selectedNode, manager);\r | |
164 | \r | |
165 | if (selectedNode.getValidChildren().size() > 0) {\r | |
166 | manager.add(new Separator());\r | |
167 | }\r | |
90e2b925 | 168 | \r |
4bf17f4a | 169 | Action deleteAction = new Action() {\r |
170 | @Override\r | |
171 | public void run() {\r | |
172 | selectedNode.remove();\r | |
173 | fViewer.refresh();\r | |
174 | }\r | |
175 | };\r | |
176 | deleteAction.setText(Messages.FilterViewer_DeleteActionText);\r | |
177 | manager.add(deleteAction);\r | |
178 | \r | |
179 | manager.add(new Separator());\r | |
180 | }\r | |
90e2b925 | 181 | \r |
4bf17f4a | 182 | if (fViewer.getInput() instanceof TmfFilterRootNode || selectedNode == null) {\r |
183 | final ITmfFilterTreeNode root = (ITmfFilterTreeNode) fViewer.getInput();\r | |
184 | \r | |
185 | fillContextMenuForNode(root, manager);\r | |
186 | }\r | |
187 | }\r | |
188 | \r | |
189 | /**\r | |
190 | * Fill the context menu with the valid children of the provided node\r | |
191 | */\r | |
192 | protected void fillContextMenuForNode(final ITmfFilterTreeNode node, IMenuManager manager) {\r | |
193 | for (final String child : node.getValidChildren()) {\r | |
194 | final Action action = new Action() {\r | |
195 | @Override\r | |
196 | public void run() {\r | |
197 | ITmfFilterTreeNode newNode = null;\r | |
198 | if (TmfFilterNode.NODE_NAME.equals(child)) {\r | |
199 | newNode = new TmfFilterNode(node, ""); //$NON-NLS-1$\r | |
200 | } else if (TmfFilterEventTypeNode.NODE_NAME.equals(child)) {\r | |
201 | newNode = new TmfFilterEventTypeNode(node);\r | |
202 | } else if (TmfFilterAndNode.NODE_NAME.equals(child)) {\r | |
203 | newNode = new TmfFilterAndNode(node);\r | |
204 | } else if (TmfFilterOrNode.NODE_NAME.equals(child)) {\r | |
205 | newNode = new TmfFilterOrNode(node);\r | |
206 | } else if (TmfFilterContainsNode.NODE_NAME.equals(child)) {\r | |
207 | newNode = new TmfFilterContainsNode(node);\r | |
208 | } else if (TmfFilterEqualsNode.NODE_NAME.equals(child)) {\r | |
209 | newNode = new TmfFilterEqualsNode(node);\r | |
210 | } else if (TmfFilterMatchesNode.NODE_NAME.equals(child)) {\r | |
211 | newNode = new TmfFilterMatchesNode(node);\r | |
212 | } else if (TmfFilterCompareNode.NODE_NAME.equals(child)) {\r | |
213 | newNode = new TmfFilterCompareNode(node);\r | |
214 | }\r | |
215 | if (newNode != null) {\r | |
216 | fViewer.refresh();\r | |
217 | fViewer.setSelection(new StructuredSelection(newNode), true);\r | |
218 | }\r | |
219 | }\r | |
220 | };\r | |
221 | if (TmfFilterNode.NODE_NAME.equals(child)) {\r | |
222 | action.setText(Messages.FilterViewer_NewPrefix + " " + child); //$NON-NLS-1$\r | |
223 | } else {\r | |
224 | action.setText(child);\r | |
225 | }\r | |
226 | manager.add(action);\r | |
227 | }\r | |
228 | }\r | |
229 | \r | |
230 | /**\r | |
231 | * Create the appropriate filter node properties composite\r | |
232 | */\r | |
233 | private void updateFilterNodeComposite(ITmfFilterTreeNode node) {\r | |
234 | for (Control control : fComposite.getChildren()) {\r | |
235 | control.dispose();\r | |
236 | }\r | |
237 | \r | |
238 | if (node instanceof TmfFilterNode) {\r | |
239 | new FilterNodeComposite(fComposite, (TmfFilterNode) node);\r | |
240 | } else if (node instanceof TmfFilterEventTypeNode) {\r | |
241 | new FilterEventTypeNodeComposite(fComposite, (TmfFilterEventTypeNode) node);\r | |
242 | } else if (node instanceof TmfFilterAndNode) {\r | |
243 | new FilterAndNodeComposite(fComposite, (TmfFilterAndNode) node);\r | |
244 | } else if (node instanceof TmfFilterOrNode) {\r | |
245 | new FilterOrNodeComposite(fComposite, (TmfFilterOrNode) node);\r | |
246 | } else if (node instanceof TmfFilterContainsNode) {\r | |
247 | new FilterContainsNodeComposite(fComposite, (TmfFilterContainsNode) node);\r | |
248 | } else if (node instanceof TmfFilterEqualsNode) {\r | |
249 | new FilterEqualsNodeComposite(fComposite, (TmfFilterEqualsNode) node);\r | |
250 | } else if (node instanceof TmfFilterMatchesNode) {\r | |
251 | new FilterMatchesNodeComposite(fComposite, (TmfFilterMatchesNode) node);\r | |
252 | } else if (node instanceof TmfFilterCompareNode) {\r | |
253 | new FilterCompareNodeComposite(fComposite, (TmfFilterCompareNode) node);\r | |
254 | } else {\r | |
255 | new FilterBaseNodeComposite(fComposite);\r | |
256 | }\r | |
257 | fComposite.layout();\r | |
258 | }\r | |
259 | \r | |
260 | /**\r | |
261 | * Highlight the provided tree items\r | |
262 | */\r | |
263 | private void highlightTreeItems(TreeItem[] items) {\r | |
264 | resetTreeItems(fViewer.getTree().getItems());\r | |
265 | for (TreeItem item : items) {\r | |
266 | item.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));\r | |
267 | }\r | |
90e2b925 | 268 | \r |
4bf17f4a | 269 | }\r |
270 | \r | |
271 | /**\r | |
272 | * Reset the provided tree items (remove highlight)\r | |
273 | */\r | |
274 | private void resetTreeItems(TreeItem[] items) {\r | |
275 | for (TreeItem item : items) {\r | |
276 | item.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));\r | |
277 | resetTreeItems(item.getItems());\r | |
278 | }\r | |
279 | }\r | |
280 | \r | |
281 | public void setInput(ITmfFilterTreeNode root) {\r | |
282 | fViewer.setInput(root);\r | |
283 | fViewer.expandAll();\r | |
284 | \r | |
285 | updateFilterNodeComposite(null);\r | |
286 | }\r | |
287 | \r | |
288 | public ITmfFilterTreeNode getInput() {\r | |
289 | return (ITmfFilterTreeNode) fViewer.getInput();\r | |
290 | }\r | |
291 | \r | |
292 | public void refresh() {\r | |
293 | fViewer.refresh();\r | |
294 | }\r | |
90e2b925 | 295 | \r |
4bf17f4a | 296 | public void setSelection(ITmfFilterTreeNode node, boolean reveal) {\r |
297 | fViewer.setSelection(new StructuredSelection(node), reveal);\r | |
298 | }\r | |
90e2b925 | 299 | \r |
4bf17f4a | 300 | public void setSelection(ITmfFilterTreeNode node) {\r |
301 | fViewer.setSelection(new StructuredSelection(node));\r | |
302 | }\r | |
303 | \r | |
304 | public ITmfFilterTreeNode getSelection() {\r | |
305 | final ISelection selection = fViewer.getSelection();\r | |
306 | ITmfFilterTreeNode filterTreeNode = null;\r | |
307 | if (selection instanceof StructuredSelection) {\r | |
308 | Object element = ((StructuredSelection) selection).getFirstElement();\r | |
309 | if (element instanceof ITmfFilterTreeNode) {\r | |
310 | filterTreeNode = (ITmfFilterTreeNode) element;\r | |
311 | }\r | |
312 | }\r | |
90e2b925 | 313 | \r |
4bf17f4a | 314 | final ITmfFilterTreeNode selectedNode = filterTreeNode;\r |
315 | return selectedNode;\r | |
316 | }\r | |
317 | \r | |
318 | public void addSelectionChangedListener(ISelectionChangedListener listener) {\r | |
319 | fViewer.addSelectionChangedListener(listener);\r | |
320 | }\r | |
321 | \r | |
322 | public void removeSelectionChangedListener(ISelectionChangedListener listener) {\r | |
323 | fViewer.removeSelectionChangedListener(listener);\r | |
324 | }\r | |
325 | \r | |
326 | private class FilterBaseNodeComposite extends Composite {\r | |
327 | \r | |
328 | FilterBaseNodeComposite(Composite parent) {\r | |
329 | super(parent, SWT.NONE);\r | |
330 | setLayout(new GridLayout(2, false));\r | |
331 | setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r | |
332 | setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
333 | }\r | |
334 | \r | |
335 | protected String[] getFieldsList(ITmfFilterTreeNode node) {\r | |
336 | ArrayList<String> fieldsList = new ArrayList<String>();\r | |
337 | while (node != null) {\r | |
338 | if (node instanceof TmfFilterEventTypeNode) {\r | |
339 | TmfFilterEventTypeNode eventTypeNode = (TmfFilterEventTypeNode) node;\r | |
340 | for (IConfigurationElement ce : TmfTraceType.getTypeElements()) {\r | |
341 | if (ce.getAttribute(TmfTraceType.EVENT_TYPE_ATTR).equals(eventTypeNode.getEventType())) {\r | |
342 | try {\r | |
343 | TmfEvent event = (TmfEvent) ce.createExecutableExtension(TmfTraceType.EVENT_TYPE_ATTR);\r | |
344 | TmfEventType eventType = event.getType();\r | |
345 | if (eventType != null) {\r | |
346 | for (String field : eventType.getLabels()) {\r | |
347 | fieldsList.add(field);\r | |
348 | }\r | |
349 | }\r | |
350 | } catch (CoreException e) {\r | |
351 | }\r | |
352 | return fieldsList.toArray(new String[0]);\r | |
353 | }\r | |
354 | }\r | |
355 | if (eventTypeNode.getEventType().startsWith(CustomTxtEvent.class.getCanonicalName())) {\r | |
356 | for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {\r | |
357 | if (eventTypeNode.getEventType().equals(CustomTxtEvent.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$\r | |
358 | for (OutputColumn output : def.outputs) {\r | |
359 | fieldsList.add(output.name);\r | |
360 | }\r | |
361 | return fieldsList.toArray(new String[0]);\r | |
362 | }\r | |
363 | }\r | |
364 | }\r | |
365 | if (eventTypeNode.getEventType().startsWith(CustomXmlEvent.class.getCanonicalName())) {\r | |
366 | for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {\r | |
367 | if (eventTypeNode.getEventType().equals(CustomXmlEvent.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$\r | |
368 | for (OutputColumn output : def.outputs) {\r | |
369 | fieldsList.add(output.name);\r | |
370 | }\r | |
371 | return fieldsList.toArray(new String[0]);\r | |
372 | }\r | |
373 | }\r | |
374 | }\r | |
375 | }\r | |
376 | node = node.getParent();\r | |
377 | }\r | |
378 | for (IConfigurationElement ce : TmfTraceType.getTypeElements()) {\r | |
379 | try {\r | |
380 | TmfEvent event = (TmfEvent) ce.createExecutableExtension(TmfTraceType.EVENT_TYPE_ATTR);\r | |
381 | TmfEventType eventType = event.getType();\r | |
382 | if (eventType != null) {\r | |
383 | fieldsList.add("[" + TmfTraceType.getCategoryName(ce.getAttribute(TmfTraceType.CATEGORY_ATTR)) + //$NON-NLS-1$\r | |
384 | " : " + ce.getAttribute(TmfTraceType.NAME_ATTR) + "]"); //$NON-NLS-1$ //$NON-NLS-2$\r | |
385 | for (String field : eventType.getLabels()) {\r | |
386 | fieldsList.add(field);\r | |
387 | }\r | |
388 | fieldsList.add(""); //$NON-NLS-1$\r | |
389 | }\r | |
390 | } catch (CoreException e) {\r | |
391 | }\r | |
392 | }\r | |
393 | for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {\r | |
394 | fieldsList.add("[" + CUSTOM_TXT_CATEGORY + //$NON-NLS-1$\r | |
395 | " : " + def.definitionName + "]"); //$NON-NLS-1$ //$NON-NLS-2$\r | |
396 | for (OutputColumn output : def.outputs) {\r | |
397 | fieldsList.add(output.name);\r | |
398 | }\r | |
399 | fieldsList.add(""); //$NON-NLS-1$\r | |
400 | }\r | |
401 | for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {\r | |
402 | fieldsList.add("[" + CUSTOM_XML_CATEGORY + //$NON-NLS-1$\r | |
403 | " : " + def.definitionName + "]"); //$NON-NLS-1$ //$NON-NLS-2$\r | |
404 | for (OutputColumn output : def.outputs) {\r | |
405 | fieldsList.add(output.name);\r | |
406 | }\r | |
407 | fieldsList.add(""); //$NON-NLS-1$\r | |
408 | }\r | |
409 | return fieldsList.toArray(new String[0]);\r | |
410 | }\r | |
411 | }\r | |
90e2b925 | 412 | \r |
4bf17f4a | 413 | private class FilterNodeComposite extends FilterBaseNodeComposite {\r |
414 | TmfFilterNode fNode;\r | |
415 | Text fNameText;\r | |
416 | \r | |
417 | FilterNodeComposite(Composite parent, TmfFilterNode node) {\r | |
418 | super(parent);\r | |
419 | fNode = node;\r | |
420 | \r | |
421 | Label label = new Label(this, SWT.NONE);\r | |
422 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
423 | label.setText(Messages.FilterViewer_NameLabel);\r | |
424 | \r | |
425 | fNameText = new Text(this, SWT.BORDER);\r | |
426 | fNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r | |
427 | if (node.getFilterName() != null && node.getFilterName().length() > 0) {\r | |
428 | fNameText.setText(node.getFilterName());\r | |
429 | } else {\r | |
430 | fNameText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));\r | |
431 | fNameText.setText(Messages.FilterViewer_FilterNameHint);\r | |
432 | }\r | |
433 | fNameText.addFocusListener(new FocusListener() {\r | |
434 | @Override\r | |
90e2b925 | 435 | public void focusLost(FocusEvent e) {\r |
4bf17f4a | 436 | if (fNode.getFilterName() == null || fNode.getFilterName().length() == 0) {\r |
437 | fNameText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));\r | |
438 | fNameText.setText(Messages.FilterViewer_FilterNameHint);\r | |
439 | }\r | |
440 | }\r | |
441 | @Override\r | |
90e2b925 | 442 | public void focusGained(FocusEvent e) {\r |
4bf17f4a | 443 | if (fNameText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {\r |
444 | fNameText.setText(""); //$NON-NLS-1$\r | |
445 | }\r | |
446 | fNameText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));\r | |
447 | }\r | |
448 | });\r | |
449 | fNameText.addModifyListener(new ModifyListener() {\r | |
450 | @Override\r | |
90e2b925 | 451 | public void modifyText(ModifyEvent e) {\r |
4bf17f4a | 452 | if (! fNameText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {\r |
453 | fNode.setFilterName(fNameText.getText());\r | |
454 | fViewer.refresh(fNode);\r | |
455 | }\r | |
456 | }\r | |
457 | });\r | |
458 | }\r | |
459 | }\r | |
90e2b925 | 460 | \r |
4bf17f4a | 461 | private class FilterEventTypeNodeComposite extends FilterBaseNodeComposite {\r |
462 | TmfFilterEventTypeNode fNode;\r | |
463 | Combo fTypeCombo;\r | |
464 | Map<String, Object> fEventsTypeMap;\r | |
465 | \r | |
466 | FilterEventTypeNodeComposite(Composite parent, TmfFilterEventTypeNode node) {\r | |
467 | super(parent);\r | |
468 | fNode = node;\r | |
469 | fEventsTypeMap = getEventsTypeMap();\r | |
90e2b925 | 470 | \r |
4bf17f4a | 471 | Label label = new Label(this, SWT.NONE);\r |
472 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
473 | label.setText(Messages.FilterViewer_TypeLabel);\r | |
474 | \r | |
475 | fTypeCombo = new Combo(this, SWT.DROP_DOWN | SWT.READ_ONLY);\r | |
476 | fTypeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r | |
477 | fTypeCombo.setItems(fEventsTypeMap.keySet().toArray(new String[0]));\r | |
478 | if (fNode.getEventType() != null) {\r | |
479 | for (Entry <String, Object> eventTypeEntry : fEventsTypeMap.entrySet()) {\r | |
480 | Object value = eventTypeEntry.getValue();\r | |
481 | if (value instanceof IConfigurationElement) {\r | |
482 | IConfigurationElement ce = (IConfigurationElement) value;\r | |
483 | if (ce.getAttribute(TmfTraceType.EVENT_TYPE_ATTR).equals(fNode.getEventType())) {\r | |
484 | fTypeCombo.setText(eventTypeEntry.getKey());\r | |
485 | }\r | |
486 | } else if (value instanceof CustomTxtTraceDefinition) {\r | |
487 | CustomTxtTraceDefinition def = (CustomTxtTraceDefinition) value;\r | |
488 | String eventType = CustomTxtEvent.class.getCanonicalName() + ":" + def.definitionName; //$NON-NLS-1$\r | |
489 | if (eventType.equals(fNode.getEventType())) {\r | |
490 | fTypeCombo.setText(eventTypeEntry.getKey());\r | |
491 | }\r | |
492 | } else if (value instanceof CustomXmlTraceDefinition) {\r | |
493 | CustomXmlTraceDefinition def = (CustomXmlTraceDefinition) value;\r | |
494 | String eventType = CustomXmlEvent.class.getCanonicalName() + ":" + def.definitionName; //$NON-NLS-1$\r | |
495 | if (eventType.equals(fNode.getEventType())) {\r | |
496 | fTypeCombo.setText(eventTypeEntry.getKey());\r | |
497 | }\r | |
498 | }\r | |
499 | }\r | |
500 | }\r | |
501 | fTypeCombo.addModifyListener(new ModifyListener() {\r | |
502 | @Override\r | |
90e2b925 | 503 | public void modifyText(ModifyEvent e) {\r |
4bf17f4a | 504 | for (Entry <String, Object> eventTypeEntry : fEventsTypeMap.entrySet()) {\r |
505 | if (eventTypeEntry.getKey().equals(fTypeCombo.getText())) {\r | |
506 | Object value = eventTypeEntry.getValue();\r | |
507 | if (value instanceof IConfigurationElement) {\r | |
508 | IConfigurationElement ce = (IConfigurationElement) value;\r | |
509 | fNode.setEventType(ce.getAttribute(TmfTraceType.EVENT_TYPE_ATTR));\r | |
510 | fNode.setName(ce.getAttribute(TmfTraceType.NAME_ATTR));\r | |
511 | } else if (value instanceof CustomTxtTraceDefinition) {\r | |
512 | CustomTxtTraceDefinition def = (CustomTxtTraceDefinition) value;\r | |
513 | fNode.setEventType(CustomTxtEvent.class.getCanonicalName() + ":" + def.definitionName); //$NON-NLS-1$\r | |
514 | fNode.setName(def.definitionName);\r | |
515 | } else if (value instanceof CustomXmlTraceDefinition) {\r | |
516 | CustomXmlTraceDefinition def = (CustomXmlTraceDefinition) value;\r | |
517 | fNode.setEventType(CustomXmlEvent.class.getCanonicalName() + ":" + def.definitionName); //$NON-NLS-1$\r | |
518 | fNode.setName(def.definitionName);\r | |
519 | }\r | |
520 | fViewer.refresh(fNode);\r | |
521 | break;\r | |
522 | }\r | |
523 | }\r | |
524 | }\r | |
525 | });\r | |
526 | }\r | |
527 | \r | |
528 | protected Map<String, Object> getEventsTypeMap() {\r | |
529 | Map<String, Object> eventsTypeMap = new LinkedHashMap<String, Object>();\r | |
530 | for (IConfigurationElement ce : TmfTraceType.getTypeElements()) {\r | |
531 | String categoryName = TmfTraceType.getCategoryName(ce.getAttribute(TmfTraceType.CATEGORY_ATTR));\r | |
532 | String text = categoryName + " : " + ce.getAttribute(TmfTraceType.NAME_ATTR); //$NON-NLS-1$\r | |
533 | eventsTypeMap.put(text, ce);\r | |
534 | }\r | |
535 | for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {\r | |
536 | String text = CUSTOM_TXT_CATEGORY + " : " + def.definitionName; //$NON-NLS-1$\r | |
537 | eventsTypeMap.put(text, def);\r | |
538 | }\r | |
539 | for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {\r | |
540 | String text = CUSTOM_XML_CATEGORY + " : " + def.definitionName; //$NON-NLS-1$\r | |
541 | eventsTypeMap.put(text, def);\r | |
542 | }\r | |
543 | return eventsTypeMap;\r | |
544 | }\r | |
545 | }\r | |
546 | \r | |
547 | private class FilterAndNodeComposite extends FilterBaseNodeComposite {\r | |
548 | TmfFilterAndNode fNode;\r | |
549 | Button fNotButton;\r | |
550 | \r | |
551 | FilterAndNodeComposite(Composite parent, TmfFilterAndNode node) {\r | |
552 | super(parent);\r | |
553 | fNode = node;\r | |
554 | \r | |
555 | Label label = new Label(this, SWT.NONE);\r | |
556 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
557 | label.setText(Messages.FilterViewer_NotLabel);\r | |
558 | \r | |
559 | fNotButton = new Button(this, SWT.CHECK);\r | |
560 | fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
561 | fNotButton.setSelection(fNode.isNot());\r | |
562 | fNotButton.addSelectionListener(new SelectionAdapter() {\r | |
563 | @Override\r | |
564 | public void widgetSelected(SelectionEvent e) {\r | |
565 | fNode.setNot(fNotButton.getSelection());\r | |
566 | fViewer.refresh(fNode);\r | |
567 | }\r | |
568 | });\r | |
569 | }\r | |
570 | }\r | |
90e2b925 | 571 | \r |
4bf17f4a | 572 | private class FilterOrNodeComposite extends FilterBaseNodeComposite {\r |
573 | TmfFilterOrNode fNode;\r | |
574 | Button fNotButton;\r | |
575 | \r | |
576 | FilterOrNodeComposite(Composite parent, TmfFilterOrNode node) {\r | |
577 | super(parent);\r | |
578 | fNode = node;\r | |
579 | \r | |
580 | Label label = new Label(this, SWT.NONE);\r | |
581 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
582 | label.setText(Messages.FilterViewer_NotLabel);\r | |
583 | \r | |
584 | fNotButton = new Button(this, SWT.CHECK);\r | |
585 | fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
586 | fNotButton.setSelection(fNode.isNot());\r | |
587 | fNotButton.addSelectionListener(new SelectionAdapter() {\r | |
588 | @Override\r | |
589 | public void widgetSelected(SelectionEvent e) {\r | |
590 | fNode.setNot(fNotButton.getSelection());\r | |
591 | fViewer.refresh(fNode);\r | |
592 | }\r | |
593 | });\r | |
594 | }\r | |
595 | }\r | |
596 | \r | |
597 | private class FilterContainsNodeComposite extends FilterBaseNodeComposite {\r | |
598 | TmfFilterContainsNode fNode;\r | |
599 | Button fNotButton;\r | |
600 | Combo fFieldCombo;\r | |
601 | Text fValueText;\r | |
602 | Button fIgnoreCaseButton;\r | |
603 | \r | |
604 | FilterContainsNodeComposite(Composite parent, TmfFilterContainsNode node) {\r | |
605 | super(parent);\r | |
606 | fNode = node;\r | |
607 | \r | |
608 | Label label = new Label(this, SWT.NONE);\r | |
609 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
610 | label.setText(Messages.FilterViewer_NotLabel);\r | |
611 | \r | |
612 | fNotButton = new Button(this, SWT.CHECK);\r | |
613 | fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
614 | fNotButton.setSelection(fNode.isNot());\r | |
615 | fNotButton.addSelectionListener(new SelectionAdapter() {\r | |
616 | @Override\r | |
617 | public void widgetSelected(SelectionEvent e) {\r | |
618 | fNode.setNot(fNotButton.getSelection());\r | |
619 | fViewer.refresh(fNode);\r | |
620 | }\r | |
621 | });\r | |
622 | \r | |
623 | label = new Label(this, SWT.NONE);\r | |
624 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
625 | label.setText(Messages.FilterViewer_FieldLabel);\r | |
626 | \r | |
627 | fFieldCombo = new Combo(this, SWT.DROP_DOWN);\r | |
628 | fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r | |
629 | fFieldCombo.setItems(getFieldsList(fNode));\r | |
630 | if (fNode.getField() != null) {\r | |
631 | fFieldCombo.setText(fNode.getField());\r | |
632 | }\r | |
633 | fFieldCombo.addModifyListener(new ModifyListener() {\r | |
634 | @Override\r | |
90e2b925 | 635 | public void modifyText(ModifyEvent e) {\r |
4bf17f4a | 636 | fNode.setField(fFieldCombo.getText());\r |
637 | fViewer.refresh(fNode);\r | |
638 | }\r | |
639 | });\r | |
640 | \r | |
641 | label = new Label(this, SWT.NONE);\r | |
642 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
643 | label.setText(Messages.FilterViewer_ValueLabel);\r | |
644 | \r | |
645 | fValueText = new Text(this, SWT.BORDER);\r | |
646 | fValueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r | |
647 | if (node.getValue() != null && node.getValue().length() > 0) {\r | |
648 | fValueText.setText(node.getValue());\r | |
649 | } else {\r | |
650 | fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));\r | |
651 | fValueText.setText(Messages.FilterViewer_ValueHint);\r | |
652 | }\r | |
653 | fValueText.addFocusListener(new FocusListener() {\r | |
654 | @Override\r | |
90e2b925 | 655 | public void focusLost(FocusEvent e) {\r |
4bf17f4a | 656 | if (fNode.getValue() == null || fNode.getValue().length() == 0) {\r |
657 | fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));\r | |
658 | fValueText.setText(Messages.FilterViewer_ValueHint);\r | |
659 | }\r | |
660 | }\r | |
661 | @Override\r | |
90e2b925 | 662 | public void focusGained(FocusEvent e) {\r |
4bf17f4a | 663 | if (fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {\r |
664 | fValueText.setText(""); //$NON-NLS-1$\r | |
665 | }\r | |
666 | fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));\r | |
667 | }\r | |
668 | });\r | |
669 | fValueText.addModifyListener(new ModifyListener() {\r | |
670 | @Override\r | |
90e2b925 | 671 | public void modifyText(ModifyEvent e) {\r |
4bf17f4a | 672 | if (! fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {\r |
673 | fNode.setValue(fValueText.getText());\r | |
674 | fViewer.refresh(fNode);\r | |
675 | }\r | |
676 | }\r | |
677 | });\r | |
678 | \r | |
679 | label = new Label(this, SWT.NONE);\r | |
680 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
681 | \r | |
682 | fIgnoreCaseButton = new Button(this, SWT.CHECK);\r | |
683 | fIgnoreCaseButton.setSelection(fNode.isIgnoreCase());\r | |
684 | fIgnoreCaseButton.setText(Messages.FilterViewer_IgnoreCaseButtonText);\r | |
685 | fIgnoreCaseButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
686 | fIgnoreCaseButton.addSelectionListener(new SelectionAdapter() {\r | |
687 | @Override\r | |
688 | public void widgetSelected(SelectionEvent e) {\r | |
689 | fNode.setIgnoreCase(fIgnoreCaseButton.getSelection());\r | |
690 | fViewer.refresh(fNode);\r | |
691 | }\r | |
692 | });\r | |
693 | }\r | |
694 | }\r | |
90e2b925 | 695 | \r |
4bf17f4a | 696 | private class FilterEqualsNodeComposite extends FilterBaseNodeComposite {\r |
697 | TmfFilterEqualsNode fNode;\r | |
698 | Button fNotButton;\r | |
699 | Combo fFieldCombo;\r | |
700 | Text fValueText;\r | |
701 | Button fIgnoreCaseButton;\r | |
702 | \r | |
703 | FilterEqualsNodeComposite(Composite parent, TmfFilterEqualsNode node) {\r | |
704 | super(parent);\r | |
705 | fNode = node;\r | |
706 | \r | |
707 | Label label = new Label(this, SWT.NONE);\r | |
708 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
709 | label.setText(Messages.FilterViewer_NotLabel);\r | |
710 | \r | |
711 | fNotButton = new Button(this, SWT.CHECK);\r | |
712 | fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
713 | fNotButton.setSelection(fNode.isNot());\r | |
714 | fNotButton.addSelectionListener(new SelectionAdapter() {\r | |
715 | @Override\r | |
716 | public void widgetSelected(SelectionEvent e) {\r | |
717 | fNode.setNot(fNotButton.getSelection());\r | |
718 | fViewer.refresh(fNode);\r | |
719 | }\r | |
720 | });\r | |
721 | \r | |
722 | label = new Label(this, SWT.NONE);\r | |
723 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
724 | label.setText(Messages.FilterViewer_FieldLabel);\r | |
725 | \r | |
726 | fFieldCombo = new Combo(this, SWT.DROP_DOWN);\r | |
727 | fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r | |
728 | fFieldCombo.setItems(getFieldsList(fNode));\r | |
729 | if (fNode.getField() != null) {\r | |
730 | fFieldCombo.setText(fNode.getField());\r | |
731 | }\r | |
732 | fFieldCombo.addModifyListener(new ModifyListener() {\r | |
733 | @Override\r | |
90e2b925 | 734 | public void modifyText(ModifyEvent e) {\r |
4bf17f4a | 735 | fNode.setField(fFieldCombo.getText());\r |
736 | fViewer.refresh(fNode);\r | |
737 | }\r | |
738 | });\r | |
739 | \r | |
740 | label = new Label(this, SWT.NONE);\r | |
741 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
742 | label.setText(Messages.FilterViewer_ValueLabel);\r | |
743 | \r | |
744 | fValueText = new Text(this, SWT.BORDER);\r | |
745 | fValueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r | |
746 | if (node.getValue() != null && node.getValue().length() > 0) {\r | |
747 | fValueText.setText(node.getValue());\r | |
748 | } else {\r | |
749 | fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));\r | |
750 | fValueText.setText(Messages.FilterViewer_ValueHint);\r | |
751 | }\r | |
752 | fValueText.addFocusListener(new FocusListener() {\r | |
753 | @Override\r | |
90e2b925 | 754 | public void focusLost(FocusEvent e) {\r |
4bf17f4a | 755 | if (fNode.getValue() == null || fNode.getValue().length() == 0) {\r |
756 | fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));\r | |
757 | fValueText.setText(Messages.FilterViewer_ValueHint);\r | |
758 | }\r | |
759 | }\r | |
760 | @Override\r | |
90e2b925 | 761 | public void focusGained(FocusEvent e) {\r |
4bf17f4a | 762 | if (fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {\r |
763 | fValueText.setText(""); //$NON-NLS-1$\r | |
764 | }\r | |
765 | fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));\r | |
766 | }\r | |
767 | });\r | |
768 | fValueText.addModifyListener(new ModifyListener() {\r | |
769 | @Override\r | |
90e2b925 | 770 | public void modifyText(ModifyEvent e) {\r |
4bf17f4a | 771 | if (! fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {\r |
772 | fNode.setValue(fValueText.getText());\r | |
773 | fViewer.refresh(fNode);\r | |
774 | }\r | |
775 | }\r | |
776 | });\r | |
777 | \r | |
778 | label = new Label(this, SWT.NONE);\r | |
779 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
780 | \r | |
781 | fIgnoreCaseButton = new Button(this, SWT.CHECK);\r | |
782 | fIgnoreCaseButton.setSelection(fNode.isIgnoreCase());\r | |
783 | fIgnoreCaseButton.setText(Messages.FilterViewer_IgnoreCaseButtonText);\r | |
784 | fIgnoreCaseButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
785 | fIgnoreCaseButton.addSelectionListener(new SelectionAdapter() {\r | |
786 | @Override\r | |
787 | public void widgetSelected(SelectionEvent e) {\r | |
788 | fNode.setIgnoreCase(fIgnoreCaseButton.getSelection());\r | |
789 | fViewer.refresh(fNode);\r | |
790 | }\r | |
791 | });\r | |
792 | }\r | |
793 | }\r | |
90e2b925 | 794 | \r |
4bf17f4a | 795 | private class FilterMatchesNodeComposite extends FilterBaseNodeComposite {\r |
796 | TmfFilterMatchesNode fNode;\r | |
797 | Button fNotButton;\r | |
798 | Combo fFieldCombo;\r | |
799 | Text fRegexText;\r | |
800 | \r | |
801 | FilterMatchesNodeComposite(Composite parent, TmfFilterMatchesNode node) {\r | |
802 | super(parent);\r | |
803 | fNode = node;\r | |
804 | \r | |
805 | Label label = new Label(this, SWT.NONE);\r | |
806 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
807 | label.setText(Messages.FilterViewer_NotLabel);\r | |
808 | \r | |
809 | fNotButton = new Button(this, SWT.CHECK);\r | |
810 | fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
811 | fNotButton.setSelection(fNode.isNot());\r | |
812 | fNotButton.addSelectionListener(new SelectionAdapter() {\r | |
813 | @Override\r | |
814 | public void widgetSelected(SelectionEvent e) {\r | |
815 | fNode.setNot(fNotButton.getSelection());\r | |
816 | fViewer.refresh(fNode);\r | |
817 | }\r | |
818 | });\r | |
819 | \r | |
820 | label = new Label(this, SWT.NONE);\r | |
821 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
822 | label.setText(Messages.FilterViewer_FieldLabel);\r | |
823 | \r | |
824 | fFieldCombo = new Combo(this, SWT.DROP_DOWN);\r | |
825 | fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r | |
826 | fFieldCombo.setItems(getFieldsList(fNode));\r | |
827 | if (fNode.getField() != null) {\r | |
828 | fFieldCombo.setText(fNode.getField());\r | |
829 | }\r | |
830 | fFieldCombo.addModifyListener(new ModifyListener() {\r | |
831 | @Override\r | |
90e2b925 | 832 | public void modifyText(ModifyEvent e) {\r |
4bf17f4a | 833 | fNode.setField(fFieldCombo.getText());\r |
834 | fViewer.refresh(fNode);\r | |
835 | }\r | |
836 | });\r | |
837 | \r | |
838 | label = new Label(this, SWT.NONE);\r | |
839 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
840 | label.setText(Messages.FilterViewer_RegexLabel);\r | |
841 | \r | |
842 | fRegexText = new Text(this, SWT.BORDER);\r | |
843 | fRegexText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r | |
844 | if (node.getRegex() != null && node.getRegex().length() > 0) {\r | |
845 | fRegexText.setText(node.getRegex());\r | |
846 | } else {\r | |
847 | fRegexText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));\r | |
848 | fRegexText.setText(Messages.FilterViewer_RegexHint);\r | |
849 | }\r | |
850 | fRegexText.addFocusListener(new FocusListener() {\r | |
851 | @Override\r | |
90e2b925 | 852 | public void focusLost(FocusEvent e) {\r |
4bf17f4a | 853 | if (fNode.getRegex() == null || fNode.getRegex().length() == 0) {\r |
854 | fRegexText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));\r | |
855 | fRegexText.setText(Messages.FilterViewer_RegexHint);\r | |
856 | }\r | |
857 | }\r | |
858 | @Override\r | |
90e2b925 | 859 | public void focusGained(FocusEvent e) {\r |
4bf17f4a | 860 | if (fRegexText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {\r |
861 | fRegexText.setText(""); //$NON-NLS-1$\r | |
862 | }\r | |
863 | fRegexText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));\r | |
864 | }\r | |
865 | });\r | |
866 | fRegexText.addModifyListener(new ModifyListener() {\r | |
867 | @Override\r | |
90e2b925 | 868 | public void modifyText(ModifyEvent e) {\r |
4bf17f4a | 869 | if (! fRegexText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {\r |
870 | fNode.setRegex(fRegexText.getText());\r | |
871 | fViewer.refresh(fNode);\r | |
872 | }\r | |
873 | }\r | |
874 | });\r | |
875 | }\r | |
876 | }\r | |
90e2b925 | 877 | \r |
4bf17f4a | 878 | private class FilterCompareNodeComposite extends FilterBaseNodeComposite {\r |
879 | TmfFilterCompareNode fNode;\r | |
880 | Button fNotButton;\r | |
881 | Combo fFieldCombo;\r | |
882 | Text fValueText;\r | |
883 | Button fLTButton;\r | |
884 | Button fEQButton;\r | |
885 | Button fGTButton;\r | |
886 | Button fNumButton;\r | |
887 | Button fAlphaButton;\r | |
888 | Button fTimestampButton;\r | |
889 | \r | |
890 | FilterCompareNodeComposite(Composite parent, TmfFilterCompareNode node) {\r | |
891 | super(parent);\r | |
892 | fNode = node;\r | |
893 | \r | |
894 | Label label = new Label(this, SWT.NONE);\r | |
895 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
896 | label.setText(Messages.FilterViewer_NotLabel);\r | |
897 | \r | |
898 | fNotButton = new Button(this, SWT.CHECK);\r | |
899 | fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
900 | fNotButton.setSelection(fNode.isNot());\r | |
901 | fNotButton.addSelectionListener(new SelectionAdapter() {\r | |
902 | @Override\r | |
903 | public void widgetSelected(SelectionEvent e) {\r | |
904 | fNode.setNot(fNotButton.getSelection());\r | |
905 | fViewer.refresh(fNode);\r | |
906 | }\r | |
907 | });\r | |
908 | \r | |
909 | label = new Label(this, SWT.NONE);\r | |
910 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
911 | label.setText(Messages.FilterViewer_FieldLabel);\r | |
912 | \r | |
913 | fFieldCombo = new Combo(this, SWT.DROP_DOWN);\r | |
914 | fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r | |
915 | fFieldCombo.setItems(getFieldsList(fNode));\r | |
916 | if (fNode.getField() != null) {\r | |
917 | fFieldCombo.setText(fNode.getField());\r | |
918 | }\r | |
919 | fFieldCombo.addModifyListener(new ModifyListener() {\r | |
920 | @Override\r | |
90e2b925 | 921 | public void modifyText(ModifyEvent e) {\r |
4bf17f4a | 922 | fNode.setField(fFieldCombo.getText());\r |
923 | fViewer.refresh(fNode);\r | |
924 | }\r | |
925 | });\r | |
926 | \r | |
927 | label = new Label(this, SWT.NONE);\r | |
928 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
929 | label.setText(Messages.FilterViewer_ResultLabel);\r | |
930 | \r | |
931 | Composite resultGroup = new Composite(this, SWT.NONE);\r | |
932 | GridLayout rggl = new GridLayout(3, true);\r | |
933 | rggl.marginHeight = 0;\r | |
934 | rggl.marginWidth = 0;\r | |
935 | resultGroup.setLayout(rggl);\r | |
936 | resultGroup.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
937 | \r | |
938 | fLTButton = new Button(resultGroup, SWT.RADIO);\r | |
939 | fLTButton.setSelection(fNode.getResult() < 0);\r | |
940 | fLTButton.setText("<"); //$NON-NLS-1$\r | |
941 | fLTButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
942 | fLTButton.addSelectionListener(new SelectionAdapter() {\r | |
943 | @Override\r | |
944 | public void widgetSelected(SelectionEvent e) {\r | |
945 | if (fLTButton.getSelection()) {\r | |
946 | fNode.setResult(-1);\r | |
947 | }\r | |
948 | fViewer.refresh(fNode);\r | |
949 | }\r | |
950 | });\r | |
951 | \r | |
952 | fEQButton = new Button(resultGroup, SWT.RADIO);\r | |
953 | fEQButton.setSelection(fNode.getResult() == 0);\r | |
954 | fEQButton.setText("="); //$NON-NLS-1$\r | |
955 | fEQButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
956 | fEQButton.addSelectionListener(new SelectionAdapter() {\r | |
957 | @Override\r | |
958 | public void widgetSelected(SelectionEvent e) {\r | |
959 | if (fEQButton.getSelection()) {\r | |
960 | fNode.setResult(0);\r | |
961 | }\r | |
962 | fViewer.refresh(fNode);\r | |
963 | }\r | |
964 | });\r | |
965 | \r | |
966 | fGTButton = new Button(resultGroup, SWT.RADIO);\r | |
967 | fGTButton.setSelection(fNode.getResult() > 0);\r | |
968 | fGTButton.setText(">"); //$NON-NLS-1$\r | |
969 | fGTButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
970 | fGTButton.addSelectionListener(new SelectionAdapter() {\r | |
971 | @Override\r | |
972 | public void widgetSelected(SelectionEvent e) {\r | |
973 | if (fGTButton.getSelection()) {\r | |
974 | fNode.setResult(1);\r | |
975 | }\r | |
976 | fViewer.refresh(fNode);\r | |
977 | }\r | |
978 | });\r | |
979 | \r | |
980 | label = new Label(this, SWT.NONE);\r | |
981 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
982 | label.setText(Messages.FilterViewer_TypeLabel);\r | |
983 | \r | |
984 | Composite typeGroup = new Composite(this, SWT.NONE);\r | |
985 | GridLayout tggl = new GridLayout(3, false);\r | |
986 | tggl.marginHeight = 0;\r | |
987 | tggl.marginWidth = 0;\r | |
988 | typeGroup.setLayout(tggl);\r | |
989 | typeGroup.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
990 | \r | |
991 | fNumButton = new Button(typeGroup, SWT.RADIO);\r | |
992 | fNumButton.setSelection(fNode.getType() == Type.NUM);\r | |
993 | fNumButton.setText(Messages.FilterViewer_NumButtonText);\r | |
994 | fNumButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
995 | fNumButton.addSelectionListener(new SelectionAdapter() {\r | |
996 | @Override\r | |
997 | public void widgetSelected(SelectionEvent e) {\r | |
998 | if (fNumButton.getSelection()) {\r | |
999 | fNode.setType(Type.NUM);\r | |
1000 | }\r | |
1001 | fViewer.refresh(fNode);\r | |
1002 | }\r | |
1003 | });\r | |
1004 | \r | |
1005 | fAlphaButton = new Button(typeGroup, SWT.RADIO);\r | |
1006 | fAlphaButton.setSelection(fNode.getType() == Type.ALPHA);\r | |
1007 | fAlphaButton.setText(Messages.FilterViewer_AlphaButtonText);\r | |
1008 | fAlphaButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
1009 | fAlphaButton.addSelectionListener(new SelectionAdapter() {\r | |
1010 | @Override\r | |
1011 | public void widgetSelected(SelectionEvent e) {\r | |
1012 | if (fAlphaButton.getSelection()) {\r | |
1013 | fNode.setType(Type.ALPHA);\r | |
1014 | }\r | |
1015 | fViewer.refresh(fNode);\r | |
1016 | }\r | |
1017 | });\r | |
1018 | \r | |
1019 | fTimestampButton = new Button(typeGroup, SWT.RADIO);\r | |
1020 | fTimestampButton.setSelection(fNode.getType() == Type.TIMESTAMP);\r | |
1021 | fTimestampButton.setText(Messages.FilterViewer_TimestampButtonText);\r | |
1022 | fTimestampButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
1023 | fTimestampButton.addSelectionListener(new SelectionAdapter() {\r | |
1024 | @Override\r | |
1025 | public void widgetSelected(SelectionEvent e) {\r | |
1026 | if (fTimestampButton.getSelection()) {\r | |
1027 | fNode.setType(Type.TIMESTAMP);\r | |
1028 | }\r | |
1029 | fViewer.refresh(fNode);\r | |
1030 | }\r | |
1031 | });\r | |
1032 | \r | |
1033 | label = new Label(this, SWT.NONE);\r | |
1034 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r | |
1035 | label.setText(Messages.FilterViewer_ValueLabel);\r | |
1036 | \r | |
1037 | fValueText = new Text(this, SWT.BORDER);\r | |
1038 | fValueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r | |
1039 | if (node.getValue() != null && node.getValue().length() > 0) {\r | |
1040 | fValueText.setText(node.getValue());\r | |
1041 | } else {\r | |
1042 | fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));\r | |
1043 | fValueText.setText(Messages.FilterViewer_ValueHint);\r | |
1044 | }\r | |
1045 | fValueText.addFocusListener(new FocusListener() {\r | |
1046 | @Override\r | |
90e2b925 | 1047 | public void focusLost(FocusEvent e) {\r |
4bf17f4a | 1048 | if (fNode.getValue() == null || fNode.getValue().length() == 0) {\r |
1049 | fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));\r | |
1050 | fValueText.setText(Messages.FilterViewer_ValueHint);\r | |
1051 | }\r | |
1052 | }\r | |
1053 | @Override\r | |
90e2b925 | 1054 | public void focusGained(FocusEvent e) {\r |
4bf17f4a | 1055 | if (fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {\r |
1056 | fValueText.setText(""); //$NON-NLS-1$\r | |
1057 | }\r | |
1058 | fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));\r | |
1059 | }\r | |
1060 | });\r | |
1061 | fValueText.addModifyListener(new ModifyListener() {\r | |
1062 | @Override\r | |
90e2b925 | 1063 | public void modifyText(ModifyEvent e) {\r |
4bf17f4a | 1064 | if (! fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {\r |
1065 | fNode.setValue(fValueText.getText());\r | |
1066 | fViewer.refresh(fNode);\r | |
1067 | }\r | |
1068 | }\r | |
1069 | });\r | |
1070 | }\r | |
1071 | }\r | |
90e2b925 FC |
1072 | \r |
1073 | }\r |