4657a34b324da049a524e2246e6cfdf19799a0fa
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / filter / FilterTreeLabelProvider.java
1 /*******************************************************************************
2 * Copyright (c) 2010, 2013 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Yuriy Vashchuk - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.ui.views.filter;
14
15 import org.eclipse.jface.viewers.ILabelProvider;
16 import org.eclipse.jface.viewers.ILabelProviderListener;
17 import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterAndNode;
18 import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterCompareNode;
19 import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterCompareNode.Type;
20 import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterContainsNode;
21 import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterEqualsNode;
22 import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterEventTypeNode;
23 import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterMatchesNode;
24 import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterNode;
25 import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterOrNode;
26 import org.eclipse.swt.graphics.Image;
27
28 /**
29 * This is the Label Provider for our Filter Tree
30 *
31 * @version 1.0
32 * @author Yuriy Vashchuk
33 */
34 public class FilterTreeLabelProvider implements ILabelProvider {
35
36 @Override
37 public void addListener(ILabelProviderListener listener) {
38 // TODO Auto-generated method stub
39 }
40
41 @Override
42 public void dispose() {
43 // TODO Auto-generated method stub
44 }
45
46 @Override
47 public boolean isLabelProperty(Object element, String property) {
48 // TODO Auto-generated method stub
49 return false;
50 }
51
52 @Override
53 public void removeListener(ILabelProviderListener listener) {
54 // TODO Auto-generated method stub
55 }
56
57 @Override
58 public Image getImage(Object element) {
59 // TODO Auto-generated method stub
60 return null;
61 }
62
63 @Override
64 public String getText(Object element) {
65 String label = null;
66
67 if (element instanceof TmfFilterNode) {
68
69 TmfFilterNode node = (TmfFilterNode) element;
70 label = node.getNodeName() + " " + node.getFilterName(); //$NON-NLS-1$
71
72 } else if (element instanceof TmfFilterEventTypeNode) {
73
74 TmfFilterEventTypeNode node = (TmfFilterEventTypeNode) element;
75 label = "WITH " + node.getNodeName() + (node.getName() != null ? " " + node.getName() : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
76
77 } else if (element instanceof TmfFilterAndNode) {
78
79 TmfFilterAndNode node = (TmfFilterAndNode) element;
80 label = (node.isNot() ? "NOT " : "") + node.getNodeName(); //$NON-NLS-1$ //$NON-NLS-2$
81
82 } else if (element instanceof TmfFilterOrNode) {
83
84 TmfFilterOrNode node = (TmfFilterOrNode) element;
85 label = (node.isNot() ? "NOT " : "") + node.getNodeName(); //$NON-NLS-1$ //$NON-NLS-2$
86
87 } else if (element instanceof TmfFilterContainsNode) {
88
89 TmfFilterContainsNode node = (TmfFilterContainsNode) element;
90 label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
91 (node.getField() != null ? node.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$
92 node.getNodeName() +
93 (node.getValue() != null && node.getValue().length() > 0 ? " \"" + node.getValue() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
94
95 } else if (element instanceof TmfFilterEqualsNode) {
96
97 TmfFilterEqualsNode node = (TmfFilterEqualsNode) element;
98 label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
99 (node.getField() != null ? node.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$
100 node.getNodeName() +
101 (node.getValue() != null && node.getValue().length() > 0 ? " \"" + node.getValue() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
102
103 } else if (element instanceof TmfFilterMatchesNode) {
104
105 TmfFilterMatchesNode node = (TmfFilterMatchesNode) element;
106 label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
107 (node.getField() != null ? node.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$
108 node.getNodeName() +
109 (node.getRegex() != null && node.getRegex().length() > 0 ? " \"" + node.getRegex() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
110
111 } else if (element instanceof TmfFilterCompareNode) {
112
113 TmfFilterCompareNode node = (TmfFilterCompareNode) element;
114 label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
115 (node.getField() != null ? node.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$
116 (node.getResult() < 0 ? "<" : (node.getResult() > 0 ? ">" : "=")) + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
117 (node.getValue() != null && node.getValue().length() > 0 ?
118 (node.getType() == Type.ALPHA ? " \"" + node.getValue() + "\"" : //$NON-NLS-1$ //$NON-NLS-2$
119 (node.getType() == Type.TIMESTAMP ? " [" + node.getValue() + "]" : //$NON-NLS-1$ //$NON-NLS-2$
120 " " + node.getValue())) : ""); //$NON-NLS-1$//$NON-NLS-2$
121
122 }
123 return label;
124 }
125
126 }
This page took 0.03314 seconds and 4 git commands to generate.