Commit | Line | Data |
---|---|---|
be222f56 | 1 | /******************************************************************************* |
60ae41e1 | 2 | * Copyright (c) 2010, 2014 Ericsson |
a0a88f65 | 3 | * |
be222f56 PT |
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 | |
a0a88f65 | 8 | * |
be222f56 PT |
9 | * Contributors: |
10 | * Patrick Tasse - Initial API and implementation | |
ef906471 | 11 | * Xavier Raynaud - add cut/copy/paste/dnd support |
a1bc6c45 | 12 | * Vincent Perot - Add subfield filtering |
be222f56 PT |
13 | *******************************************************************************/ |
14 | ||
15 | package org.eclipse.linuxtools.tmf.ui.views.filter; | |
16 | ||
17 | import java.util.ArrayList; | |
be222f56 PT |
18 | import java.util.Map; |
19 | import java.util.Map.Entry; | |
4b3b667b | 20 | import java.util.TreeMap; |
be222f56 PT |
21 | |
22 | import org.eclipse.core.runtime.CoreException; | |
23 | import org.eclipse.core.runtime.IConfigurationElement; | |
24 | import org.eclipse.jface.action.Action; | |
780fc05e | 25 | import org.eclipse.jface.action.IMenuListener; |
be222f56 | 26 | import org.eclipse.jface.action.IMenuManager; |
780fc05e | 27 | import org.eclipse.jface.action.MenuManager; |
be222f56 | 28 | import org.eclipse.jface.action.Separator; |
ef906471 | 29 | import org.eclipse.jface.util.LocalSelectionTransfer; |
be222f56 PT |
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; | |
be222f56 PT |
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; | |
4b3b667b | 51 | import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomTraceDefinition; |
780fc05e | 52 | import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomTraceDefinition.OutputColumn; |
47aafe74 AM |
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; | |
47aafe74 | 57 | import org.eclipse.linuxtools.tmf.core.project.model.TmfTraceType; |
be222f56 PT |
58 | import org.eclipse.swt.SWT; |
59 | import org.eclipse.swt.custom.SashForm; | |
ef906471 XR |
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; | |
be222f56 PT |
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; | |
780fc05e | 81 | import org.eclipse.swt.widgets.Menu; |
be222f56 PT |
82 | import org.eclipse.swt.widgets.Text; |
83 | import org.eclipse.swt.widgets.TreeItem; | |
84 | ||
85 | class FilterViewer extends Composite { | |
86 | ||
4b3b667b PT |
87 | private static final String SEP = " : "; //$NON-NLS-1$ |
88 | ||
be222f56 | 89 | private TreeViewer fViewer; |
ef906471 | 90 | |
be222f56 | 91 | private Composite fComposite; |
780fc05e | 92 | private MenuManager fMenuManager; |
a0a88f65 | 93 | |
be222f56 PT |
94 | public FilterViewer(Composite parent, int style) { |
95 | super(parent, style); | |
96 | ||
97 | setLayout(new FillLayout()); | |
98 | GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); | |
99 | setLayoutData(gd); | |
a0a88f65 | 100 | |
be222f56 PT |
101 | final SashForm sash = new SashForm(this, SWT.HORIZONTAL); |
102 | ||
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()); | |
a0a88f65 | 108 | |
be222f56 PT |
109 | // Create the empty filter node properties panel |
110 | fComposite = new Composite(sash, SWT.NONE); | |
111 | GridLayout gl = new GridLayout(); | |
112 | gl.marginHeight = 0; | |
113 | gl.marginWidth = 0; | |
114 | fComposite.setLayout(gl); | |
115 | ||
780fc05e MAL |
116 | createContextMenu(); |
117 | ||
be222f56 PT |
118 | fViewer.addSelectionChangedListener(new ISelectionChangedListener() { |
119 | @Override | |
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()); | |
128 | } else { | |
129 | updateFilterNodeComposite(null); | |
130 | } | |
131 | } | |
132 | }); | |
133 | ||
134 | fViewer.getTree().addPaintListener(new PaintListener() { | |
135 | @Override | |
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); | |
141 | } | |
142 | } | |
143 | }); | |
be222f56 | 144 | |
ef906471 XR |
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)); | |
be222f56 | 152 | } |
a0a88f65 | 153 | |
780fc05e MAL |
154 | /** |
155 | * Create the context menu for the tree viewer | |
156 | */ | |
157 | private void createContextMenu() { | |
158 | // Adds root context menu | |
159 | fMenuManager = new MenuManager(); | |
160 | fMenuManager.setRemoveAllWhenShown(true); | |
161 | fMenuManager.addMenuListener(new IMenuListener() { | |
162 | @Override | |
163 | public void menuAboutToShow(IMenuManager manager) { | |
164 | fillContextMenu(manager); | |
165 | } | |
166 | }); | |
167 | ||
168 | // Context | |
169 | Menu contextMenu = fMenuManager.createContextMenu(fViewer.getTree()); | |
170 | ||
171 | // Publish it | |
172 | fViewer.getTree().setMenu(contextMenu); | |
173 | } | |
174 | ||
175 | public MenuManager getMenuManager() { | |
176 | return fMenuManager; | |
177 | } | |
178 | ||
be222f56 | 179 | /** |
a0a88f65 AM |
180 | * Fill the context menu for the tree viewer. |
181 | * | |
182 | * @param manager | |
183 | * The menu manager | |
be222f56 PT |
184 | */ |
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; | |
192 | } | |
193 | } | |
194 | ||
ef906471 XR |
195 | if (filterTreeNode != null) { |
196 | fillContextMenuForNode(filterTreeNode, manager); | |
be222f56 | 197 | } |
ef906471 XR |
198 | manager.add(new Separator("delete")); //$NON-NLS-1$ |
199 | manager.add(new Separator("edit")); //$NON-NLS-1$ | |
be222f56 | 200 | |
ef906471 XR |
201 | if (fViewer.getInput() instanceof TmfFilterRootNode || filterTreeNode == null) { |
202 | manager.add(new Separator()); | |
203 | ITmfFilterTreeNode root = (ITmfFilterTreeNode) fViewer.getInput(); | |
be222f56 PT |
204 | fillContextMenuForNode(root, manager); |
205 | } | |
206 | } | |
a0a88f65 | 207 | |
be222f56 PT |
208 | /** |
209 | * Fill the context menu with the valid children of the provided node | |
a0a88f65 AM |
210 | * |
211 | * @param node | |
212 | * The target node | |
213 | * @param manager | |
214 | * The menu manager | |
be222f56 PT |
215 | */ |
216 | protected void fillContextMenuForNode(final ITmfFilterTreeNode node, IMenuManager manager) { | |
217 | for (final String child : node.getValidChildren()) { | |
218 | final Action action = new Action() { | |
219 | @Override | |
220 | public void run() { | |
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); | |
238 | } | |
239 | if (newNode != null) { | |
240 | fViewer.refresh(); | |
241 | fViewer.setSelection(new StructuredSelection(newNode), true); | |
242 | } | |
243 | } | |
244 | }; | |
245 | if (TmfFilterNode.NODE_NAME.equals(child)) { | |
246 | action.setText(Messages.FilterViewer_NewPrefix + " " + child); //$NON-NLS-1$ | |
247 | } else { | |
248 | action.setText(child); | |
249 | } | |
250 | manager.add(action); | |
251 | } | |
252 | } | |
a0a88f65 | 253 | |
be222f56 PT |
254 | /** |
255 | * Create the appropriate filter node properties composite | |
256 | */ | |
257 | private void updateFilterNodeComposite(ITmfFilterTreeNode node) { | |
258 | for (Control control : fComposite.getChildren()) { | |
259 | control.dispose(); | |
260 | } | |
a0a88f65 | 261 | |
be222f56 PT |
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); | |
278 | } else { | |
279 | new FilterBaseNodeComposite(fComposite); | |
280 | } | |
281 | fComposite.layout(); | |
282 | } | |
a0a88f65 | 283 | |
be222f56 PT |
284 | /** |
285 | * Highlight the provided tree items | |
286 | */ | |
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)); | |
291 | } | |
292 | ||
293 | } | |
a0a88f65 | 294 | |
be222f56 PT |
295 | /** |
296 | * Reset the provided tree items (remove highlight) | |
297 | */ | |
298 | private void resetTreeItems(TreeItem[] items) { | |
299 | for (TreeItem item : items) { | |
300 | item.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); | |
301 | resetTreeItems(item.getItems()); | |
302 | } | |
303 | } | |
a0a88f65 | 304 | |
be222f56 PT |
305 | public void setInput(ITmfFilterTreeNode root) { |
306 | fViewer.setInput(root); | |
307 | fViewer.expandAll(); | |
a0a88f65 | 308 | |
be222f56 PT |
309 | updateFilterNodeComposite(null); |
310 | } | |
a0a88f65 | 311 | |
be222f56 PT |
312 | public ITmfFilterTreeNode getInput() { |
313 | return (ITmfFilterTreeNode) fViewer.getInput(); | |
314 | } | |
a0a88f65 | 315 | |
be222f56 PT |
316 | public void refresh() { |
317 | fViewer.refresh(); | |
318 | } | |
319 | ||
320 | public void setSelection(ITmfFilterTreeNode node, boolean reveal) { | |
321 | fViewer.setSelection(new StructuredSelection(node), reveal); | |
322 | } | |
323 | ||
324 | public void setSelection(ITmfFilterTreeNode node) { | |
325 | fViewer.setSelection(new StructuredSelection(node)); | |
326 | } | |
a0a88f65 | 327 | |
be222f56 PT |
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; | |
335 | } | |
336 | } | |
337 | ||
338 | final ITmfFilterTreeNode selectedNode = filterTreeNode; | |
339 | return selectedNode; | |
340 | } | |
a0a88f65 | 341 | |
be222f56 PT |
342 | public void addSelectionChangedListener(ISelectionChangedListener listener) { |
343 | fViewer.addSelectionChangedListener(listener); | |
344 | } | |
a0a88f65 | 345 | |
be222f56 PT |
346 | public void removeSelectionChangedListener(ISelectionChangedListener listener) { |
347 | fViewer.removeSelectionChangedListener(listener); | |
348 | } | |
a0a88f65 | 349 | |
ef906471 XR |
350 | /** |
351 | * Gets the TreeViewer displaying filters | |
a1bc6c45 | 352 | * |
ef906471 XR |
353 | * @return a {@link TreeViewer} |
354 | */ | |
355 | TreeViewer getTreeViewer() { | |
356 | return fViewer; | |
357 | } | |
358 | ||
be222f56 | 359 | private class FilterBaseNodeComposite extends Composite { |
a0a88f65 | 360 | |
be222f56 PT |
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)); | |
366 | } | |
a0a88f65 | 367 | |
4b3b667b PT |
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; | |
375 | } | |
376 | String text = categoryPrefix + ce.getAttribute(TmfTraceType.NAME_ATTR); | |
377 | eventsTypeMap.put(text, ce); | |
378 | } | |
379 | for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) { | |
380 | String text = def.categoryName + SEP + def.definitionName; | |
381 | eventsTypeMap.put(text, def); | |
382 | } | |
383 | for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) { | |
384 | String text = def.categoryName + SEP + def.definitionName; | |
385 | eventsTypeMap.put(text, def); | |
386 | } | |
387 | return eventsTypeMap; | |
388 | } | |
389 | ||
be222f56 | 390 | protected String[] getFieldsList(ITmfFilterTreeNode node) { |
507b1336 | 391 | ArrayList<String> fieldsList = new ArrayList<>(); |
41b5c37f AM |
392 | ITmfFilterTreeNode curNode = node; |
393 | while (curNode != null) { | |
394 | if (curNode instanceof TmfFilterEventTypeNode) { | |
395 | TmfFilterEventTypeNode eventTypeNode = (TmfFilterEventTypeNode) curNode; | |
be222f56 PT |
396 | for (IConfigurationElement ce : TmfTraceType.getTypeElements()) { |
397 | if (ce.getAttribute(TmfTraceType.EVENT_TYPE_ATTR).equals(eventTypeNode.getEventType())) { | |
398 | try { | |
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); | |
404 | } | |
405 | } | |
406 | } catch (CoreException e) { | |
407 | } | |
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); | |
414 | } | |
415 | return fieldsList.toArray(new String[0]); | |
416 | } | |
417 | } | |
418 | if (eventTypeNode.getEventType() != null && eventTypeNode.getEventType().startsWith(CustomTxtEvent.class.getCanonicalName())) { | |
419 | for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) { | |
4b3b667b | 420 | if (eventTypeNode.getEventType().equals(CustomTxtEvent.class.getCanonicalName() + ':' + def.categoryName + ':' + def.definitionName)) { |
be222f56 PT |
421 | for (OutputColumn output : def.outputs) { |
422 | fieldsList.add(output.name); | |
423 | } | |
424 | return fieldsList.toArray(new String[0]); | |
425 | } | |
426 | } | |
427 | } | |
428 | if (eventTypeNode.getEventType() != null && eventTypeNode.getEventType().startsWith(CustomXmlEvent.class.getCanonicalName())) { | |
429 | for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) { | |
4b3b667b | 430 | if (eventTypeNode.getEventType().equals(CustomXmlEvent.class.getCanonicalName() + ':' + def.categoryName + ':' + def.definitionName)) { |
be222f56 PT |
431 | for (OutputColumn output : def.outputs) { |
432 | fieldsList.add(output.name); | |
433 | } | |
434 | return fieldsList.toArray(new String[0]); | |
435 | } | |
436 | } | |
437 | } | |
438 | } | |
41b5c37f | 439 | curNode = curNode.getParent(); |
be222f56 PT |
440 | } |
441 | ||
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$ | |
449 | ||
4b3b667b PT |
450 | for (Entry<String, Object> eventTypeEntry : getEventsTypeMap().entrySet()) { |
451 | Object value = eventTypeEntry.getValue(); | |
452 | if (value instanceof IConfigurationElement) { | |
453 | IConfigurationElement ce = (IConfigurationElement) value; | |
454 | try { | |
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) + ']'); | |
462 | } else { | |
463 | fieldsList.add('[' + ce.getAttribute(TmfTraceType.NAME_ATTR) + ']'); | |
464 | } | |
465 | for (String field : eventType.getFieldNames()) { | |
466 | fieldsList.add(field); | |
467 | } | |
468 | fieldsList.add(""); //$NON-NLS-1$ | |
09154cfe | 469 | } |
4b3b667b PT |
470 | } catch (CoreException e) { |
471 | } | |
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); | |
be222f56 PT |
478 | } |
479 | fieldsList.add(""); //$NON-NLS-1$ | |
480 | } | |
be222f56 PT |
481 | } |
482 | } | |
483 | return fieldsList.toArray(new String[0]); | |
484 | } | |
485 | } | |
486 | ||
487 | private class FilterNodeComposite extends FilterBaseNodeComposite { | |
488 | TmfFilterNode fNode; | |
489 | Text fNameText; | |
a0a88f65 | 490 | |
be222f56 PT |
491 | FilterNodeComposite(Composite parent, TmfFilterNode node) { |
492 | super(parent); | |
493 | fNode = node; | |
a0a88f65 | 494 | |
be222f56 PT |
495 | Label label = new Label(this, SWT.NONE); |
496 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); | |
497 | label.setText(Messages.FilterViewer_NameLabel); | |
a0a88f65 | 498 | |
be222f56 PT |
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()); | |
503 | } else { | |
504 | fNameText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); | |
505 | fNameText.setText(Messages.FilterViewer_FilterNameHint); | |
506 | } | |
507 | fNameText.addFocusListener(new FocusListener() { | |
508 | @Override | |
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); | |
513 | } | |
514 | } | |
ef906471 | 515 | |
be222f56 PT |
516 | @Override |
517 | public void focusGained(FocusEvent e) { | |
518 | if (fNameText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { | |
519 | fNameText.setText(""); //$NON-NLS-1$ | |
520 | } | |
521 | fNameText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); | |
522 | } | |
523 | }); | |
524 | fNameText.addModifyListener(new ModifyListener() { | |
525 | @Override | |
526 | public void modifyText(ModifyEvent e) { | |
ef906471 | 527 | if (!fNameText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { |
be222f56 PT |
528 | fNode.setFilterName(fNameText.getText()); |
529 | fViewer.refresh(fNode); | |
530 | } | |
531 | } | |
532 | }); | |
533 | } | |
534 | } | |
535 | ||
536 | private class FilterEventTypeNodeComposite extends FilterBaseNodeComposite { | |
537 | TmfFilterEventTypeNode fNode; | |
538 | Combo fTypeCombo; | |
539 | Map<String, Object> fEventsTypeMap; | |
a0a88f65 | 540 | |
be222f56 PT |
541 | FilterEventTypeNodeComposite(Composite parent, TmfFilterEventTypeNode node) { |
542 | super(parent); | |
543 | fNode = node; | |
544 | fEventsTypeMap = getEventsTypeMap(); | |
545 | ||
546 | Label label = new Label(this, SWT.NONE); | |
547 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); | |
548 | label.setText(Messages.FilterViewer_TypeLabel); | |
a0a88f65 | 549 | |
be222f56 PT |
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) { | |
4b3b667b | 554 | fTypeCombo.setText(fNode.getName()); |
be222f56 PT |
555 | } |
556 | fTypeCombo.addModifyListener(new ModifyListener() { | |
557 | @Override | |
558 | public void modifyText(ModifyEvent e) { | |
ef906471 | 559 | for (Entry<String, Object> eventTypeEntry : fEventsTypeMap.entrySet()) { |
be222f56 PT |
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)); | |
4b3b667b PT |
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)); | |
569 | } else { | |
570 | fNode.setName(ce.getAttribute(TmfTraceType.NAME_ATTR)); | |
571 | } | |
be222f56 PT |
572 | } else if (value instanceof CustomTxtTraceDefinition) { |
573 | CustomTxtTraceDefinition def = (CustomTxtTraceDefinition) value; | |
4b3b667b PT |
574 | fNode.setEventType(CustomTxtEvent.class.getCanonicalName() + ':' + def.categoryName + ':' + def.definitionName); |
575 | fNode.setName(def.categoryName + SEP + def.definitionName); | |
be222f56 PT |
576 | } else if (value instanceof CustomXmlTraceDefinition) { |
577 | CustomXmlTraceDefinition def = (CustomXmlTraceDefinition) value; | |
4b3b667b PT |
578 | fNode.setEventType(CustomXmlEvent.class.getCanonicalName() + ':' + def.categoryName + ':' + def.definitionName); |
579 | fNode.setName(def.categoryName + SEP + def.definitionName); | |
be222f56 PT |
580 | } |
581 | fViewer.refresh(fNode); | |
582 | break; | |
583 | } | |
584 | } | |
585 | } | |
586 | }); | |
587 | } | |
be222f56 | 588 | } |
a0a88f65 | 589 | |
be222f56 PT |
590 | private class FilterAndNodeComposite extends FilterBaseNodeComposite { |
591 | TmfFilterAndNode fNode; | |
592 | Button fNotButton; | |
a0a88f65 | 593 | |
be222f56 PT |
594 | FilterAndNodeComposite(Composite parent, TmfFilterAndNode node) { |
595 | super(parent); | |
596 | fNode = node; | |
a0a88f65 | 597 | |
be222f56 PT |
598 | Label label = new Label(this, SWT.NONE); |
599 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); | |
600 | label.setText(Messages.FilterViewer_NotLabel); | |
a0a88f65 | 601 | |
be222f56 PT |
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() { | |
606 | @Override | |
607 | public void widgetSelected(SelectionEvent e) { | |
608 | fNode.setNot(fNotButton.getSelection()); | |
609 | fViewer.refresh(fNode); | |
610 | } | |
611 | }); | |
612 | } | |
613 | } | |
614 | ||
615 | private class FilterOrNodeComposite extends FilterBaseNodeComposite { | |
616 | TmfFilterOrNode fNode; | |
617 | Button fNotButton; | |
a0a88f65 | 618 | |
be222f56 PT |
619 | FilterOrNodeComposite(Composite parent, TmfFilterOrNode node) { |
620 | super(parent); | |
621 | fNode = node; | |
a0a88f65 | 622 | |
be222f56 PT |
623 | Label label = new Label(this, SWT.NONE); |
624 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); | |
625 | label.setText(Messages.FilterViewer_NotLabel); | |
a0a88f65 | 626 | |
be222f56 PT |
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() { | |
631 | @Override | |
632 | public void widgetSelected(SelectionEvent e) { | |
633 | fNode.setNot(fNotButton.getSelection()); | |
634 | fViewer.refresh(fNode); | |
635 | } | |
636 | }); | |
637 | } | |
638 | } | |
a0a88f65 | 639 | |
be222f56 PT |
640 | private class FilterContainsNodeComposite extends FilterBaseNodeComposite { |
641 | TmfFilterContainsNode fNode; | |
642 | Button fNotButton; | |
643 | Combo fFieldCombo; | |
644 | Text fValueText; | |
645 | Button fIgnoreCaseButton; | |
a0a88f65 | 646 | |
be222f56 PT |
647 | FilterContainsNodeComposite(Composite parent, TmfFilterContainsNode node) { |
648 | super(parent); | |
649 | fNode = node; | |
a0a88f65 | 650 | |
be222f56 PT |
651 | Label label = new Label(this, SWT.NONE); |
652 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); | |
653 | label.setText(Messages.FilterViewer_NotLabel); | |
a0a88f65 | 654 | |
be222f56 PT |
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() { | |
659 | @Override | |
660 | public void widgetSelected(SelectionEvent e) { | |
661 | fNode.setNot(fNotButton.getSelection()); | |
662 | fViewer.refresh(fNode); | |
663 | } | |
664 | }); | |
a0a88f65 | 665 | |
be222f56 PT |
666 | label = new Label(this, SWT.NONE); |
667 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); | |
668 | label.setText(Messages.FilterViewer_FieldLabel); | |
a0a88f65 | 669 | |
be222f56 PT |
670 | fFieldCombo = new Combo(this, SWT.DROP_DOWN); |
671 | fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); | |
672 | fFieldCombo.setItems(getFieldsList(fNode)); | |
a1bc6c45 | 673 | fFieldCombo.setToolTipText(Messages.FilterViewer_Subfilter_ToolTip); |
be222f56 PT |
674 | if (fNode.getField() != null) { |
675 | fFieldCombo.setText(fNode.getField()); | |
676 | } | |
677 | fFieldCombo.addModifyListener(new ModifyListener() { | |
678 | @Override | |
679 | public void modifyText(ModifyEvent e) { | |
680 | fNode.setField(fFieldCombo.getText()); | |
681 | fViewer.refresh(fNode); | |
682 | } | |
683 | }); | |
a0a88f65 | 684 | |
be222f56 PT |
685 | label = new Label(this, SWT.NONE); |
686 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); | |
687 | label.setText(Messages.FilterViewer_ValueLabel); | |
a0a88f65 | 688 | |
be222f56 PT |
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()); | |
693 | } else { | |
694 | fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); | |
695 | fValueText.setText(Messages.FilterViewer_ValueHint); | |
696 | } | |
697 | fValueText.addFocusListener(new FocusListener() { | |
698 | @Override | |
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); | |
703 | } | |
704 | } | |
ef906471 | 705 | |
be222f56 PT |
706 | @Override |
707 | public void focusGained(FocusEvent e) { | |
708 | if (fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { | |
709 | fValueText.setText(""); //$NON-NLS-1$ | |
710 | } | |
711 | fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); | |
712 | } | |
713 | }); | |
714 | fValueText.addModifyListener(new ModifyListener() { | |
715 | @Override | |
716 | public void modifyText(ModifyEvent e) { | |
ef906471 | 717 | if (!fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { |
be222f56 PT |
718 | fNode.setValue(fValueText.getText()); |
719 | fViewer.refresh(fNode); | |
720 | } | |
721 | } | |
722 | }); | |
a0a88f65 | 723 | |
be222f56 PT |
724 | label = new Label(this, SWT.NONE); |
725 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); | |
a0a88f65 | 726 | |
be222f56 PT |
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() { | |
732 | @Override | |
733 | public void widgetSelected(SelectionEvent e) { | |
734 | fNode.setIgnoreCase(fIgnoreCaseButton.getSelection()); | |
735 | fViewer.refresh(fNode); | |
736 | } | |
737 | }); | |
738 | } | |
739 | } | |
740 | ||
741 | private class FilterEqualsNodeComposite extends FilterBaseNodeComposite { | |
742 | TmfFilterEqualsNode fNode; | |
743 | Button fNotButton; | |
744 | Combo fFieldCombo; | |
745 | Text fValueText; | |
746 | Button fIgnoreCaseButton; | |
a0a88f65 | 747 | |
be222f56 PT |
748 | FilterEqualsNodeComposite(Composite parent, TmfFilterEqualsNode node) { |
749 | super(parent); | |
750 | fNode = node; | |
a0a88f65 | 751 | |
be222f56 PT |
752 | Label label = new Label(this, SWT.NONE); |
753 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); | |
754 | label.setText(Messages.FilterViewer_NotLabel); | |
a0a88f65 | 755 | |
be222f56 PT |
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() { | |
760 | @Override | |
761 | public void widgetSelected(SelectionEvent e) { | |
762 | fNode.setNot(fNotButton.getSelection()); | |
763 | fViewer.refresh(fNode); | |
764 | } | |
765 | }); | |
a0a88f65 | 766 | |
be222f56 PT |
767 | label = new Label(this, SWT.NONE); |
768 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); | |
769 | label.setText(Messages.FilterViewer_FieldLabel); | |
a0a88f65 | 770 | |
be222f56 PT |
771 | fFieldCombo = new Combo(this, SWT.DROP_DOWN); |
772 | fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); | |
773 | fFieldCombo.setItems(getFieldsList(fNode)); | |
a1bc6c45 | 774 | fFieldCombo.setToolTipText(Messages.FilterViewer_Subfilter_ToolTip); |
be222f56 PT |
775 | if (fNode.getField() != null) { |
776 | fFieldCombo.setText(fNode.getField()); | |
777 | } | |
778 | fFieldCombo.addModifyListener(new ModifyListener() { | |
779 | @Override | |
780 | public void modifyText(ModifyEvent e) { | |
781 | fNode.setField(fFieldCombo.getText()); | |
782 | fViewer.refresh(fNode); | |
783 | } | |
784 | }); | |
a0a88f65 | 785 | |
be222f56 PT |
786 | label = new Label(this, SWT.NONE); |
787 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); | |
788 | label.setText(Messages.FilterViewer_ValueLabel); | |
a0a88f65 | 789 | |
be222f56 PT |
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()); | |
794 | } else { | |
795 | fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); | |
796 | fValueText.setText(Messages.FilterViewer_ValueHint); | |
797 | } | |
798 | fValueText.addFocusListener(new FocusListener() { | |
799 | @Override | |
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); | |
804 | } | |
805 | } | |
ef906471 | 806 | |
be222f56 PT |
807 | @Override |
808 | public void focusGained(FocusEvent e) { | |
809 | if (fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { | |
810 | fValueText.setText(""); //$NON-NLS-1$ | |
811 | } | |
812 | fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); | |
813 | } | |
814 | }); | |
815 | fValueText.addModifyListener(new ModifyListener() { | |
816 | @Override | |
817 | public void modifyText(ModifyEvent e) { | |
ef906471 | 818 | if (!fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { |
be222f56 PT |
819 | fNode.setValue(fValueText.getText()); |
820 | fViewer.refresh(fNode); | |
821 | } | |
822 | } | |
823 | }); | |
a0a88f65 | 824 | |
be222f56 PT |
825 | label = new Label(this, SWT.NONE); |
826 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); | |
a0a88f65 | 827 | |
be222f56 PT |
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() { | |
833 | @Override | |
834 | public void widgetSelected(SelectionEvent e) { | |
835 | fNode.setIgnoreCase(fIgnoreCaseButton.getSelection()); | |
836 | fViewer.refresh(fNode); | |
837 | } | |
838 | }); | |
839 | } | |
840 | } | |
841 | ||
842 | private class FilterMatchesNodeComposite extends FilterBaseNodeComposite { | |
843 | TmfFilterMatchesNode fNode; | |
844 | Button fNotButton; | |
845 | Combo fFieldCombo; | |
846 | Text fRegexText; | |
a0a88f65 | 847 | |
be222f56 PT |
848 | FilterMatchesNodeComposite(Composite parent, TmfFilterMatchesNode node) { |
849 | super(parent); | |
850 | fNode = node; | |
a0a88f65 | 851 | |
be222f56 PT |
852 | Label label = new Label(this, SWT.NONE); |
853 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); | |
854 | label.setText(Messages.FilterViewer_NotLabel); | |
a0a88f65 | 855 | |
be222f56 PT |
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() { | |
860 | @Override | |
861 | public void widgetSelected(SelectionEvent e) { | |
862 | fNode.setNot(fNotButton.getSelection()); | |
863 | fViewer.refresh(fNode); | |
864 | } | |
865 | }); | |
a0a88f65 | 866 | |
be222f56 PT |
867 | label = new Label(this, SWT.NONE); |
868 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); | |
869 | label.setText(Messages.FilterViewer_FieldLabel); | |
a0a88f65 | 870 | |
be222f56 PT |
871 | fFieldCombo = new Combo(this, SWT.DROP_DOWN); |
872 | fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); | |
873 | fFieldCombo.setItems(getFieldsList(fNode)); | |
a1bc6c45 | 874 | fFieldCombo.setToolTipText(Messages.FilterViewer_Subfilter_ToolTip); |
be222f56 PT |
875 | if (fNode.getField() != null) { |
876 | fFieldCombo.setText(fNode.getField()); | |
877 | } | |
878 | fFieldCombo.addModifyListener(new ModifyListener() { | |
879 | @Override | |
880 | public void modifyText(ModifyEvent e) { | |
881 | fNode.setField(fFieldCombo.getText()); | |
882 | fViewer.refresh(fNode); | |
883 | } | |
884 | }); | |
a0a88f65 | 885 | |
be222f56 PT |
886 | label = new Label(this, SWT.NONE); |
887 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); | |
888 | label.setText(Messages.FilterViewer_RegexLabel); | |
a0a88f65 | 889 | |
be222f56 PT |
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()); | |
894 | } else { | |
895 | fRegexText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); | |
896 | fRegexText.setText(Messages.FilterViewer_RegexHint); | |
897 | } | |
898 | fRegexText.addFocusListener(new FocusListener() { | |
899 | @Override | |
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); | |
904 | } | |
905 | } | |
ef906471 | 906 | |
be222f56 PT |
907 | @Override |
908 | public void focusGained(FocusEvent e) { | |
909 | if (fRegexText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { | |
910 | fRegexText.setText(""); //$NON-NLS-1$ | |
911 | } | |
912 | fRegexText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); | |
913 | } | |
914 | }); | |
915 | fRegexText.addModifyListener(new ModifyListener() { | |
916 | @Override | |
917 | public void modifyText(ModifyEvent e) { | |
ef906471 | 918 | if (!fRegexText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { |
be222f56 PT |
919 | fNode.setRegex(fRegexText.getText()); |
920 | fViewer.refresh(fNode); | |
921 | } | |
922 | } | |
923 | }); | |
924 | } | |
925 | } | |
926 | ||
927 | private class FilterCompareNodeComposite extends FilterBaseNodeComposite { | |
928 | TmfFilterCompareNode fNode; | |
929 | Button fNotButton; | |
930 | Combo fFieldCombo; | |
931 | Text fValueText; | |
932 | Button fLTButton; | |
933 | Button fEQButton; | |
934 | Button fGTButton; | |
935 | Button fNumButton; | |
936 | Button fAlphaButton; | |
937 | Button fTimestampButton; | |
a0a88f65 | 938 | |
be222f56 PT |
939 | FilterCompareNodeComposite(Composite parent, TmfFilterCompareNode node) { |
940 | super(parent); | |
941 | fNode = node; | |
a0a88f65 | 942 | |
be222f56 PT |
943 | Label label = new Label(this, SWT.NONE); |
944 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); | |
945 | label.setText(Messages.FilterViewer_NotLabel); | |
a0a88f65 | 946 | |
be222f56 PT |
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() { | |
951 | @Override | |
952 | public void widgetSelected(SelectionEvent e) { | |
953 | fNode.setNot(fNotButton.getSelection()); | |
954 | fViewer.refresh(fNode); | |
955 | } | |
956 | }); | |
a0a88f65 | 957 | |
be222f56 PT |
958 | label = new Label(this, SWT.NONE); |
959 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); | |
960 | label.setText(Messages.FilterViewer_FieldLabel); | |
a0a88f65 | 961 | |
be222f56 PT |
962 | fFieldCombo = new Combo(this, SWT.DROP_DOWN); |
963 | fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); | |
964 | fFieldCombo.setItems(getFieldsList(fNode)); | |
a1bc6c45 | 965 | fFieldCombo.setToolTipText(Messages.FilterViewer_Subfilter_ToolTip); |
be222f56 PT |
966 | if (fNode.getField() != null) { |
967 | fFieldCombo.setText(fNode.getField()); | |
968 | } | |
969 | fFieldCombo.addModifyListener(new ModifyListener() { | |
970 | @Override | |
971 | public void modifyText(ModifyEvent e) { | |
972 | fNode.setField(fFieldCombo.getText()); | |
973 | fViewer.refresh(fNode); | |
974 | } | |
975 | }); | |
a0a88f65 | 976 | |
be222f56 PT |
977 | label = new Label(this, SWT.NONE); |
978 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); | |
979 | label.setText(Messages.FilterViewer_ResultLabel); | |
a0a88f65 | 980 | |
be222f56 PT |
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)); | |
a0a88f65 | 987 | |
be222f56 PT |
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() { | |
993 | @Override | |
994 | public void widgetSelected(SelectionEvent e) { | |
995 | if (fLTButton.getSelection()) { | |
996 | fNode.setResult(-1); | |
997 | } | |
998 | fViewer.refresh(fNode); | |
999 | } | |
1000 | }); | |
a0a88f65 | 1001 | |
be222f56 PT |
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() { | |
1007 | @Override | |
1008 | public void widgetSelected(SelectionEvent e) { | |
1009 | if (fEQButton.getSelection()) { | |
1010 | fNode.setResult(0); | |
1011 | } | |
1012 | fViewer.refresh(fNode); | |
1013 | } | |
1014 | }); | |
a0a88f65 | 1015 | |
be222f56 PT |
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() { | |
1021 | @Override | |
1022 | public void widgetSelected(SelectionEvent e) { | |
1023 | if (fGTButton.getSelection()) { | |
1024 | fNode.setResult(1); | |
1025 | } | |
1026 | fViewer.refresh(fNode); | |
1027 | } | |
1028 | }); | |
a0a88f65 | 1029 | |
be222f56 PT |
1030 | label = new Label(this, SWT.NONE); |
1031 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); | |
1032 | label.setText(Messages.FilterViewer_TypeLabel); | |
a0a88f65 | 1033 | |
be222f56 PT |
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)); | |
a0a88f65 | 1040 | |
be222f56 PT |
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() { | |
1046 | @Override | |
1047 | public void widgetSelected(SelectionEvent e) { | |
1048 | if (fNumButton.getSelection()) { | |
1049 | fNode.setType(Type.NUM); | |
1050 | } | |
1051 | fViewer.refresh(fNode); | |
1052 | } | |
1053 | }); | |
a0a88f65 | 1054 | |
be222f56 PT |
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() { | |
1060 | @Override | |
1061 | public void widgetSelected(SelectionEvent e) { | |
1062 | if (fAlphaButton.getSelection()) { | |
1063 | fNode.setType(Type.ALPHA); | |
1064 | } | |
1065 | fViewer.refresh(fNode); | |
1066 | } | |
1067 | }); | |
a0a88f65 | 1068 | |
be222f56 PT |
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() { | |
1074 | @Override | |
1075 | public void widgetSelected(SelectionEvent e) { | |
1076 | if (fTimestampButton.getSelection()) { | |
1077 | fNode.setType(Type.TIMESTAMP); | |
1078 | } | |
1079 | fViewer.refresh(fNode); | |
1080 | } | |
1081 | }); | |
a0a88f65 | 1082 | |
be222f56 PT |
1083 | label = new Label(this, SWT.NONE); |
1084 | label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); | |
1085 | label.setText(Messages.FilterViewer_ValueLabel); | |
a0a88f65 | 1086 | |
be222f56 PT |
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()); | |
1091 | } else { | |
1092 | fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); | |
1093 | fValueText.setText(Messages.FilterViewer_ValueHint); | |
1094 | } | |
1095 | fValueText.addFocusListener(new FocusListener() { | |
1096 | @Override | |
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); | |
1101 | } | |
1102 | } | |
ef906471 | 1103 | |
be222f56 PT |
1104 | @Override |
1105 | public void focusGained(FocusEvent e) { | |
1106 | if (fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { | |
1107 | fValueText.setText(""); //$NON-NLS-1$ | |
1108 | } | |
1109 | fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); | |
1110 | } | |
1111 | }); | |
1112 | fValueText.addModifyListener(new ModifyListener() { | |
1113 | @Override | |
1114 | public void modifyText(ModifyEvent e) { | |
ef906471 | 1115 | if (!fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) { |
be222f56 PT |
1116 | fNode.setValue(fValueText.getText()); |
1117 | fViewer.refresh(fNode); | |
1118 | } | |
1119 | } | |
1120 | }); | |
1121 | } | |
1122 | } | |
1123 | ||
1124 | } |