From 7720848b6410412260f869120af3dd384c8e76f4 Mon Sep 17 00:00:00 2001 From: Jean-Christian Kouame Date: Mon, 16 Nov 2015 15:45:37 -0500 Subject: [PATCH] tmf : remove occurrences of literals in FilterTreeLabelProvider.java Change-Id: Ic30315e1bed6f360ec4760341ddee873891e43ee Signed-off-by: Jean-Christian Kouame Reviewed-on: https://git.eclipse.org/r/60555 Reviewed-by: Hudson CI Reviewed-by: Bernd Hufmann Tested-by: Bernd Hufmann Reviewed-by: Matthew Khouzam --- .../views/filter/FilterTreeLabelProvider.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/filter/FilterTreeLabelProvider.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/filter/FilterTreeLabelProvider.java index b1a557636b..c211d3c669 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/filter/FilterTreeLabelProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/filter/FilterTreeLabelProvider.java @@ -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; -- 2.34.1