Merge branch 'master' into lttng-kepler
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / filter / FilterTreeLabelProvider.java
1 /*******************************************************************************
2 * Copyright (c) 2010 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 /*
37 * (non-Javadoc)
38 * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
39 */
40 @Override
41 public void addListener(ILabelProviderListener listener) {
42 // TODO Auto-generated method stub
43 }
44
45 /*
46 * (non-Javadoc)
47 * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
48 */
49 @Override
50 public void dispose() {
51 // TODO Auto-generated method stub
52 }
53
54 /*
55 * (non-Javadoc)
56 * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
57 */
58 @Override
59 public boolean isLabelProperty(Object element, String property) {
60 // TODO Auto-generated method stub
61 return false;
62 }
63
64 /*
65 * (non-Javadoc)
66 * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
67 */
68 @Override
69 public void removeListener(ILabelProviderListener listener) {
70 // TODO Auto-generated method stub
71 }
72
73 /*
74 * (non-Javadoc)
75 * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
76 */
77 @Override
78 public Image getImage(Object element) {
79 // TODO Auto-generated method stub
80 return null;
81 }
82
83 /*
84 * (non-Javadoc)
85 * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
86 */
87 @Override
88 public String getText(Object element) {
89 String label = null;
90
91 if (element instanceof TmfFilterNode) {
92
93 TmfFilterNode node = (TmfFilterNode) element;
94 label = node.getNodeName() + " " + node.getFilterName(); //$NON-NLS-1$
95
96 } else if (element instanceof TmfFilterEventTypeNode) {
97
98 TmfFilterEventTypeNode node = (TmfFilterEventTypeNode) element;
99 label = "WITH " + node.getNodeName() + (node.getName() != null ? " " + node.getName() : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
100
101 } else if (element instanceof TmfFilterAndNode) {
102
103 TmfFilterAndNode node = (TmfFilterAndNode) element;
104 label = (node.isNot() ? "NOT " : "") + node.getNodeName(); //$NON-NLS-1$ //$NON-NLS-2$
105
106 } else if (element instanceof TmfFilterOrNode) {
107
108 TmfFilterOrNode node = (TmfFilterOrNode) element;
109 label = (node.isNot() ? "NOT " : "") + node.getNodeName(); //$NON-NLS-1$ //$NON-NLS-2$
110
111 } else if (element instanceof TmfFilterContainsNode) {
112
113 TmfFilterContainsNode node = (TmfFilterContainsNode) 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.getNodeName() +
117 (node.getValue() != null && node.getValue().length() > 0 ? " \"" + node.getValue() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
118
119 } else if (element instanceof TmfFilterEqualsNode) {
120
121 TmfFilterEqualsNode node = (TmfFilterEqualsNode) element;
122 label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
123 (node.getField() != null ? node.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$
124 node.getNodeName() +
125 (node.getValue() != null && node.getValue().length() > 0 ? " \"" + node.getValue() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
126
127 } else if (element instanceof TmfFilterMatchesNode) {
128
129 TmfFilterMatchesNode node = (TmfFilterMatchesNode) element;
130 label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
131 (node.getField() != null ? node.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$
132 node.getNodeName() +
133 (node.getRegex() != null && node.getRegex().length() > 0 ? " \"" + node.getRegex() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
134
135 } else if (element instanceof TmfFilterCompareNode) {
136
137 TmfFilterCompareNode node = (TmfFilterCompareNode) element;
138 label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
139 (node.getField() != null ? node.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$
140 (node.getResult() < 0 ? "<" : (node.getResult() > 0 ? ">" : "=")) + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
141 (node.getValue() != null && node.getValue().length() > 0 ?
142 (node.getType() == Type.ALPHA ? " \"" + node.getValue() + "\"" : //$NON-NLS-1$ //$NON-NLS-2$
143 (node.getType() == Type.TIMESTAMP ? " [" + node.getValue() + "]" : //$NON-NLS-1$ //$NON-NLS-2$
144 " " + node.getValue())) : ""); //$NON-NLS-1$//$NON-NLS-2$
145
146 }
147 return label;
148 }
149
150 }
This page took 0.040494 seconds and 5 git commands to generate.