tmf : remove occurrences of literals in FilterTreeLabelProvider.java
authorJean-Christian Kouame <jean-christian.kouame@ericsson.com>
Mon, 16 Nov 2015 20:45:37 +0000 (15:45 -0500)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Tue, 8 Dec 2015 16:10:41 +0000 (11:10 -0500)
Change-Id: Ic30315e1bed6f360ec4760341ddee873891e43ee
Signed-off-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/60555
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/filter/FilterTreeLabelProvider.java

index b1a557636b13bcaa7c75f946af3cefea8fdd5986..c211d3c669c9d69148d767797e356c20025bf76e 100644 (file)
@@ -35,6 +35,11 @@ import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterTraceTypeNode;
  */
 public class FilterTreeLabelProvider implements ILabelProvider {
 
+    private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+    private static final String QUOTE = "\""; //$NON-NLS-1$
+    private static final String SPACE_QUOTE = " \""; //$NON-NLS-1$
+    private static final String NOT = "NOT "; //$NON-NLS-1$
+
     @Override
     public void addListener(ILabelProviderListener listener) {
         // TODO Auto-generated method stub
@@ -80,46 +85,46 @@ public class FilterTreeLabelProvider implements ILabelProvider {
         } else if (element instanceof TmfFilterAndNode) {
 
             TmfFilterAndNode node = (TmfFilterAndNode) element;
-            label = (node.isNot() ? "NOT " : "") + node.getNodeName(); //$NON-NLS-1$ //$NON-NLS-2$
+            label = (node.isNot() ? NOT : EMPTY_STRING) + node.getNodeName();
 
         } else if (element instanceof TmfFilterOrNode) {
 
             TmfFilterOrNode node = (TmfFilterOrNode) element;
-            label = (node.isNot() ? "NOT " : "") + node.getNodeName(); //$NON-NLS-1$ //$NON-NLS-2$
+            label = (node.isNot() ? NOT : EMPTY_STRING) + node.getNodeName();
 
         } else if (element instanceof TmfFilterContainsNode) {
 
             TmfFilterContainsNode node = (TmfFilterContainsNode) element;
-            label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
+            label = (node.isNot() ? NOT : EMPTY_STRING) +
                     (node.getEventAspect() != null ? node.getAspectLabel(false) : Messages.FilterTreeLabelProvider_AspectHint) +
                     ' ' + node.getNodeName() +
-                    (node.getValue() != null ? " \"" + node.getValue() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                    (node.getValue() != null ? SPACE_QUOTE + node.getValue() + QUOTE : EMPTY_STRING);
 
         } else if (element instanceof TmfFilterEqualsNode) {
 
             TmfFilterEqualsNode node = (TmfFilterEqualsNode) element;
-            label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
+            label = (node.isNot() ? NOT : EMPTY_STRING) +
                     (node.getEventAspect() != null ? node.getAspectLabel(false) : Messages.FilterTreeLabelProvider_AspectHint) +
                     ' ' + node.getNodeName() +
-                    (node.getValue() != null ? " \"" + node.getValue() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                    (node.getValue() != null ? SPACE_QUOTE + node.getValue() + QUOTE : EMPTY_STRING);
 
         } else if (element instanceof TmfFilterMatchesNode) {
 
             TmfFilterMatchesNode node = (TmfFilterMatchesNode) element;
-            label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
+            label = (node.isNot() ? NOT : EMPTY_STRING) +
                     (node.getEventAspect() != null ? node.getAspectLabel(false) : Messages.FilterTreeLabelProvider_AspectHint) +
                     ' ' + node.getNodeName() +
-                    (node.getRegex() != null ? " \"" + node.getRegex() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                    (node.getRegex() != null ? SPACE_QUOTE + node.getRegex() + QUOTE : EMPTY_STRING);
 
         } else if (element instanceof TmfFilterCompareNode) {
 
             TmfFilterCompareNode node = (TmfFilterCompareNode) element;
-            label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
+            label = (node.isNot() ? NOT : EMPTY_STRING) +
                     (node.getEventAspect() != null ? node.getAspectLabel(false) : Messages.FilterTreeLabelProvider_AspectHint) +
                     (node.getResult() < 0 ? " <" : (node.getResult() > 0 ? " >" : " =")) + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-                    (node.getType() == Type.ALPHA ? " \"" : node.getType() == Type.TIMESTAMP ? " [" : ' ') + //$NON-NLS-1$ //$NON-NLS-2$
+                    (node.getType() == Type.ALPHA ? SPACE_QUOTE : node.getType() == Type.TIMESTAMP ? " [" : ' ') + //$NON-NLS-1$
                     (node.hasValidValue() ? node.getValue() : Messages.FilterTreeLabelProvider_ValueHint) +
-                    (node.getType() == Type.ALPHA ? '\"' : node.getType() == Type.TIMESTAMP ? ']' : ""); //$NON-NLS-1$
+                    (node.getType() == Type.ALPHA ? '\"' : node.getType() == Type.TIMESTAMP ? ']' : EMPTY_STRING);
 
         }
         return label;
This page took 0.027002 seconds and 5 git commands to generate.