Commit | Line | Data |
---|---|---|
90e2b925 FC |
1 | /*******************************************************************************\r |
2 | * Copyright (c) 2010 Ericsson\r | |
013a5f1c | 3 | *\r |
90e2b925 FC |
4 | * All rights reserved. This program and the accompanying materials are\r |
5 | * made available under the terms of the Eclipse Public License v1.0 which\r | |
6 | * accompanies this distribution, and is available at\r | |
7 | * http://www.eclipse.org/legal/epl-v10.html\r | |
013a5f1c | 8 | *\r |
90e2b925 FC |
9 | * Contributors:\r |
10 | * Yuriy Vashchuk - Initial API and implementation\r | |
11 | *******************************************************************************/\r | |
12 | \r | |
13 | package org.eclipse.linuxtools.tmf.ui.views.filter;\r | |
14 | \r | |
15 | import org.eclipse.jface.viewers.ILabelProvider;\r | |
16 | import org.eclipse.jface.viewers.ILabelProviderListener;\r | |
6c13869b FC |
17 | import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterAndNode;\r |
18 | import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterCompareNode;\r | |
013a5f1c | 19 | import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterCompareNode.Type;\r |
6c13869b FC |
20 | import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterContainsNode;\r |
21 | import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterEqualsNode;\r | |
22 | import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterEventTypeNode;\r | |
23 | import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterMatchesNode;\r | |
24 | import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterNode;\r | |
25 | import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterOrNode;\r | |
90e2b925 FC |
26 | import org.eclipse.swt.graphics.Image;\r |
27 | \r | |
28 | /**\r | |
90e2b925 | 29 | * This is the Label Provider for our Filter Tree\r |
013a5f1c AM |
30 | *\r |
31 | * @version 1.0\r | |
32 | * @author Yuriy Vashchuk\r | |
90e2b925 FC |
33 | */\r |
34 | public class FilterTreeLabelProvider implements ILabelProvider {\r | |
35 | \r | |
36 | /*\r | |
37 | * (non-Javadoc)\r | |
38 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)\r | |
39 | */\r | |
40 | @Override\r | |
41 | public void addListener(ILabelProviderListener listener) {\r | |
42 | // TODO Auto-generated method stub\r | |
43 | }\r | |
44 | \r | |
45 | /*\r | |
46 | * (non-Javadoc)\r | |
47 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()\r | |
48 | */\r | |
49 | @Override\r | |
50 | public void dispose() {\r | |
51 | // TODO Auto-generated method stub\r | |
52 | }\r | |
53 | \r | |
54 | /*\r | |
55 | * (non-Javadoc)\r | |
56 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)\r | |
57 | */\r | |
58 | @Override\r | |
59 | public boolean isLabelProperty(Object element, String property) {\r | |
60 | // TODO Auto-generated method stub\r | |
61 | return false;\r | |
62 | }\r | |
63 | \r | |
64 | /*\r | |
65 | * (non-Javadoc)\r | |
66 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)\r | |
67 | */\r | |
68 | @Override\r | |
69 | public void removeListener(ILabelProviderListener listener) {\r | |
70 | // TODO Auto-generated method stub\r | |
71 | }\r | |
72 | \r | |
73 | /*\r | |
74 | * (non-Javadoc)\r | |
75 | * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)\r | |
76 | */\r | |
77 | @Override\r | |
78 | public Image getImage(Object element) {\r | |
79 | // TODO Auto-generated method stub\r | |
80 | return null;\r | |
81 | }\r | |
82 | \r | |
83 | /*\r | |
84 | * (non-Javadoc)\r | |
85 | * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)\r | |
86 | */\r | |
87 | @Override\r | |
88 | public String getText(Object element) {\r | |
89 | String label = null;\r | |
013a5f1c | 90 | \r |
90e2b925 | 91 | if (element instanceof TmfFilterNode) {\r |
013a5f1c | 92 | \r |
90e2b925 FC |
93 | TmfFilterNode node = (TmfFilterNode) element;\r |
94 | label = node.getNodeName() + " " + node.getFilterName(); //$NON-NLS-1$\r | |
013a5f1c | 95 | \r |
90e2b925 | 96 | } else if (element instanceof TmfFilterEventTypeNode) {\r |
013a5f1c | 97 | \r |
90e2b925 FC |
98 | TmfFilterEventTypeNode node = (TmfFilterEventTypeNode) element;\r |
99 | label = "WITH " + node.getNodeName() + (node.getName() != null ? " " + node.getName() : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r | |
013a5f1c | 100 | \r |
90e2b925 | 101 | } else if (element instanceof TmfFilterAndNode) {\r |
013a5f1c | 102 | \r |
90e2b925 FC |
103 | TmfFilterAndNode node = (TmfFilterAndNode) element;\r |
104 | label = (node.isNot() ? "NOT " : "") + node.getNodeName(); //$NON-NLS-1$ //$NON-NLS-2$\r | |
013a5f1c | 105 | \r |
90e2b925 | 106 | } else if (element instanceof TmfFilterOrNode) {\r |
013a5f1c | 107 | \r |
90e2b925 FC |
108 | TmfFilterOrNode node = (TmfFilterOrNode) element;\r |
109 | label = (node.isNot() ? "NOT " : "") + node.getNodeName(); //$NON-NLS-1$ //$NON-NLS-2$\r | |
013a5f1c | 110 | \r |
90e2b925 | 111 | } else if (element instanceof TmfFilterContainsNode) {\r |
013a5f1c | 112 | \r |
90e2b925 FC |
113 | TmfFilterContainsNode node = (TmfFilterContainsNode) element;\r |
114 | label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$\r | |
115 | (node.getField() != null ? node.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$\r | |
116 | node.getNodeName() +\r | |
117 | (node.getValue() != null && node.getValue().length() > 0 ? " \"" + node.getValue() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r | |
013a5f1c | 118 | \r |
90e2b925 | 119 | } else if (element instanceof TmfFilterEqualsNode) {\r |
013a5f1c | 120 | \r |
90e2b925 FC |
121 | TmfFilterEqualsNode node = (TmfFilterEqualsNode) element;\r |
122 | label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$\r | |
123 | (node.getField() != null ? node.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$\r | |
124 | node.getNodeName() +\r | |
125 | (node.getValue() != null && node.getValue().length() > 0 ? " \"" + node.getValue() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r | |
013a5f1c | 126 | \r |
90e2b925 | 127 | } else if (element instanceof TmfFilterMatchesNode) {\r |
013a5f1c | 128 | \r |
90e2b925 FC |
129 | TmfFilterMatchesNode node = (TmfFilterMatchesNode) element;\r |
130 | label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$\r | |
131 | (node.getField() != null ? node.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$\r | |
132 | node.getNodeName() +\r | |
133 | (node.getRegex() != null && node.getRegex().length() > 0 ? " \"" + node.getRegex() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r | |
013a5f1c | 134 | \r |
90e2b925 | 135 | } else if (element instanceof TmfFilterCompareNode) {\r |
013a5f1c | 136 | \r |
90e2b925 FC |
137 | TmfFilterCompareNode node = (TmfFilterCompareNode) element;\r |
138 | label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$\r | |
139 | (node.getField() != null ? node.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$\r | |
140 | (node.getResult() < 0 ? "<" : (node.getResult() > 0 ? ">" : "=")) + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r | |
141 | (node.getValue() != null && node.getValue().length() > 0 ?\r | |
142 | (node.getType() == Type.ALPHA ? " \"" + node.getValue() + "\"" : //$NON-NLS-1$ //$NON-NLS-2$\r | |
143 | (node.getType() == Type.TIMESTAMP ? " [" + node.getValue() + "]" : //$NON-NLS-1$ //$NON-NLS-2$\r | |
144 | " " + node.getValue())) : ""); //$NON-NLS-1$//$NON-NLS-2$\r | |
013a5f1c | 145 | \r |
90e2b925 FC |
146 | }\r |
147 | return label;\r | |
148 | }\r | |
149 | \r | |
150 | }\r |