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