From 4f338c8d058add881bde9463f3d3b4bfcb979f9d Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Tue, 29 Apr 2014 10:03:26 +0300 Subject: More cleanups. * Empty statements * This final field could be made static * Member could be replaced by local variable * 'static' modifier out of order with the JLS suggestions. * strings handling * unused parameters * unnecessary local before return Change-Id: I7e6b45466178696345a057f75278c6c5c8a670ad Signed-off-by: Alexander Kurtakov Reviewed-on: https://git.eclipse.org/r/25708 Tested-by: Hudson CI --- .../callgraph/core/CallgraphCorePlugin.java | 2 +- .../internal/callgraph/core/SystemTapView.java | 3 +- .../internal/callgraph/launch/LaunchStapGraph.java | 7 +- .../internal/callgraph/launch/LaunchWizard.java | 3 +- .../internal/callgraph/CallgraphView.java | 13 +-- .../internal/callgraph/StapGraphParser.java | 4 +- .../graphing/core/structures/GraphData.java | 14 +-- .../listeners/BarChartMouseMoveListener.java | 10 ++ .../charts/listeners/ChartMouseMoveListener.java | 10 ++ .../listeners/ChartWithAxisMouseMoveListener.java | 13 ++- .../listeners/PieChartMouseMoveListener.java | 10 ++ .../listeners/ToolTipChartMouseMoveListener.java | 12 ++- .../graph/SelectGraphAndSeriesWizardPage.java | 115 +++++++++++---------- .../ui/consolelog/dialogs/SelectServerDialog.java | 20 ++-- .../ui/editor/SimpleDocumentProvider.java | 20 +--- .../systemtap/ui/editor/SimpleEditor.java | 5 +- .../internal/systemtap/ui/ide/IDEPerspective.java | 2 +- .../internal/systemtap/ui/ide/IDEPlugin.java | 11 +- .../systemtap/ui/ide/actions/IndentHandler.java | 15 ++- .../systemtap/ui/ide/editors/stp/IndentUtil.java | 16 +-- .../ui/ide/editors/stp/STPAutoEditStrategy.java | 66 +++++++----- .../ui/ide/editors/stp/STPCompletionProcessor.java | 3 +- .../ui/ide/editors/stp/STPConfiguration.java | 7 +- .../systemtap/ui/ide/editors/stp/STPEditor.java | 3 +- .../systemtap/ui/ide/editors/stp/STPIndenter.java | 18 ++-- .../ui/ide/editors/stp/STPPartitionScanner.java | 12 +-- .../ui/ide/editors/stp/STPProbeScanner.java | 12 +-- .../launcher/SystemTapScriptGraphOptionsTab.java | 21 ++-- 28 files changed, 236 insertions(+), 211 deletions(-) (limited to 'systemtap') diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/CallgraphCorePlugin.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/CallgraphCorePlugin.java index 23aa440a6a..463e612e21 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/CallgraphCorePlugin.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/CallgraphCorePlugin.java @@ -90,7 +90,7 @@ public class CallgraphCorePlugin extends AbstractUIPlugin { } catch (IOException e) { e.printStackTrace(); } - return new String(); + return ""; //$NON-NLS-1$ } /** diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapView.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapView.java index 5294858310..82efd3b851 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapView.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapView.java @@ -46,7 +46,6 @@ public abstract class SystemTapView extends ViewPart { private final String NEW_LINE = Messages.getString("SystemTapView.1"); //$NON-NLS-1$ public Composite masterComposite; - private IMenuManager help; private Action kill; protected String viewID; @@ -220,7 +219,7 @@ public abstract class SystemTapView extends ViewPart { public void addHelpMenu() { IMenuManager menu = getViewSite().getActionBars().getMenuManager(); - help = new MenuManager(Messages.getString("SystemTapView.Help")); //$NON-NLS-1$ + IMenuManager help = new MenuManager(Messages.getString("SystemTapView.Help")); //$NON-NLS-1$ menu.add(help); createHelpActions(); diff --git a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchStapGraph.java b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchStapGraph.java index 0c7b671dd6..b5b7a2c455 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchStapGraph.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchStapGraph.java @@ -109,8 +109,7 @@ public class LaunchStapGraph extends SystemTapLaunchShortcut { * @return */ private String generateProbe(String function) { - String output = "probe process(@1).function(\"" + function + "\").call ? { if ( ! isinstr(\"" + function + "\", \"___STAP_MARKER___\")) { callFunction(\"" + function + "\",tid()) } } probe process(@1).function(\"" + function + "\").return ? { if ( ! isinstr(\"" + function + "\", \"___STAP_MARKER___\")) returnFunction(\"" + function + "\",tid()) else { printf(\"?%d,,%s\\n\", tid(), user_string(strtol(tokenize($$return, \"return=\"),16)))}}\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ - return output; + return "probe process(@1).function(\"" + function + "\").call ? { if ( ! isinstr(\"" + function + "\", \"___STAP_MARKER___\")) { callFunction(\"" + function + "\",tid()) } } probe process(@1).function(\"" + function + "\").return ? { if ( ! isinstr(\"" + function + "\", \"___STAP_MARKER___\")) returnFunction(\"" + function + "\",tid()) else { printf(\"?%d,,%s\\n\", tid(), user_string(strtol(tokenize($$return, \"return=\"),16)))}}\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ } /** @@ -122,14 +121,14 @@ public class LaunchStapGraph extends SystemTapLaunchShortcut { private String writeFunctionListToScript(String resourceToSearchFor) { String toWrite = getFunctionsFromBinary(bin, resourceToSearchFor); - if (toWrite == null || toWrite.length() < 1) { + if (toWrite == null || toWrite.isEmpty()) { return null; } StringBuffer output = new StringBuffer(); for (String func : toWrite.split(" ")) { //$NON-NLS-1$ - if (func.length() > 0 + if (!func.isEmpty() && (exclusions == null || exclusions.size() < 1 || exclusions .contains(func))) { output.append(generateProbe(func)); diff --git a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchWizard.java b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchWizard.java index dc517d134c..97c1fd4a66 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchWizard.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchWizard.java @@ -53,7 +53,6 @@ public class LaunchWizard extends SystemTapLaunchShortcut { private String mode; private Shell sh; - private Composite fileComp; private static final int WIDTH = 670; private static final int HEIGHT = 630; @@ -151,7 +150,7 @@ public class LaunchWizard extends SystemTapLaunchShortcut { imageCmp.setLayoutData(imageData); imageCmp.setBackgroundImage(img); - fileComp = new Composite(sh, SWT.NONE); + Composite fileComp = new Composite(sh, SWT.NONE); fileComp.setLayout(new GridLayout(2, false)); fileComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); diff --git a/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/CallgraphView.java b/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/CallgraphView.java index f7506eb8ba..46e3c6b4a0 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/CallgraphView.java +++ b/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/CallgraphView.java @@ -88,9 +88,7 @@ public class CallgraphView extends SystemTapView { private Composite treeComp; private StapGraph g; - private int treeSize = 200; - - + private static final int TREE_SIZE = 200; /** * Initializes the view by creating composites (if necessary) and canvases @@ -107,8 +105,7 @@ public class CallgraphView extends SystemTapView { Display.getDefault(); } - treeSize = 200; - makeTreeComp(treeSize); + makeTreeComp(); makeGraphComp(); graphComp.setBackgroundMode(SWT.INHERIT_FORCE); @@ -149,7 +146,7 @@ public class CallgraphView extends SystemTapView { //Initialize graph g = new StapGraph(graphComp, SWT.BORDER, treeComp, papaCanvas, this); - g.setLayoutData(new GridData(masterComposite.getBounds().width,Display.getCurrent().getBounds().height - treeSize)); + g.setLayoutData(new GridData(masterComposite.getBounds().width,Display.getCurrent().getBounds().height - TREE_SIZE)); up.addSelectionListener(new AutoScrollSelectionListener( AutoScrollSelectionListener.AUTO_SCROLL_UP, g)); @@ -359,14 +356,14 @@ public class CallgraphView extends SystemTapView { - private void makeTreeComp(int treeSize) { + private void makeTreeComp() { if (treeComp != null && !treeComp.isDisposed()) { treeComp.dispose(); } treeComp = new Composite(this.masterComposite, SWT.NONE); GridData treegd = new GridData(SWT.BEGINNING, SWT.FILL, false, true); - treegd.widthHint = treeSize; + treegd.widthHint = TREE_SIZE; treeComp.setLayout(new FillLayout()); treeComp.setLayoutData(treegd); } diff --git a/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/StapGraphParser.java b/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/StapGraphParser.java index d3fbbc1bcc..3d63e82539 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/StapGraphParser.java +++ b/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/StapGraphParser.java @@ -456,9 +456,9 @@ public class StapGraphParser extends SystemTapParser { firstNode = id; } int index = args[1].indexOf("=\""); //$NON-NLS-1$ - String name = args[1].substring(index + 2, args[1].indexOf(" ", index)); //$NON-NLS-1$ + String name = args[1].substring(index + 2, args[1].indexOf(' ', index)); double dtime = 0.0; - dtime = Double.parseDouble(args[1].substring(args[1].indexOf(" ") + 1, args[1].indexOf("%"))); //$NON-NLS-1$ //$NON-NLS-2$ + dtime = Double.parseDouble(args[1].substring(args[1].indexOf(' ') + 1, args[1].indexOf('%'))); long time = (long) (dtime*100); nameList.add(name); diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphing.core/src/org/eclipse/linuxtools/systemtap/graphing/core/structures/GraphData.java b/systemtap/org.eclipse.linuxtools.systemtap.graphing.core/src/org/eclipse/linuxtools/systemtap/graphing/core/structures/GraphData.java index e0fcb2c308..eb4f64e3e5 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.graphing.core/src/org/eclipse/linuxtools/systemtap/graphing/core/structures/GraphData.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphing.core/src/org/eclipse/linuxtools/systemtap/graphing/core/structures/GraphData.java @@ -18,18 +18,14 @@ public class GraphData { public String graphID; public String title; - /** - * Creates and returns a copy of this GraphData instance. - * @return A copy of this GraphData. - * @since 1.1 - */ - public GraphData getCopy() { + @Override + public GraphData clone() { GraphData gd = new GraphData(); gd.xSeries = this.xSeries; gd.ySeries = this.ySeries == null ? null : this.ySeries.clone(); - gd.key = this.key == null ? null : this.key.substring(0); - gd.graphID = this.graphID == null ? null : this.graphID.substring(0); - gd.title = this.title == null ? null : this.title.substring(0); + gd.key = this.key == null ? null : this.key; + gd.graphID = this.graphID == null ? null : this.graphID; + gd.title = this.title == null ? null : this.title; return gd; } diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/listeners/BarChartMouseMoveListener.java b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/listeners/BarChartMouseMoveListener.java index 81164b964f..4da22d9cda 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/listeners/BarChartMouseMoveListener.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/listeners/BarChartMouseMoveListener.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2014 Red Hat, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat - Initial API and implementation. + *******************************************************************************/ package org.eclipse.linuxtools.internal.systemtap.graphing.ui.charts.listeners; import java.text.MessageFormat; diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/listeners/ChartMouseMoveListener.java b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/listeners/ChartMouseMoveListener.java index 7e0e9baf8b..0e4933f406 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/listeners/ChartMouseMoveListener.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/listeners/ChartMouseMoveListener.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2014 Red Hat, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat - Initial API and implementation. + *******************************************************************************/ package org.eclipse.linuxtools.internal.systemtap.graphing.ui.charts.listeners; import org.eclipse.swt.events.MouseEvent; diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/listeners/ChartWithAxisMouseMoveListener.java b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/listeners/ChartWithAxisMouseMoveListener.java index 806bf5f853..8d353a4c76 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/listeners/ChartWithAxisMouseMoveListener.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/listeners/ChartWithAxisMouseMoveListener.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2014 Red Hat, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat - Initial API and implementation. + *******************************************************************************/ package org.eclipse.linuxtools.internal.systemtap.graphing.ui.charts.listeners; import java.text.MessageFormat; @@ -13,11 +23,10 @@ import org.swtchart.ISeries; * This is a specialized mouse listener for displaying the coordinates of a data point on * the chart that the user hovers over with the mouse. The coordinates are displayed in a * tooltip popup near the mouse. - * @author aferrazz * @since 3.0 */ public class ChartWithAxisMouseMoveListener extends ToolTipChartMouseMoveListener { - private final double DIST_TOLERANCE = 20.0; + private static final double DIST_TOLERANCE = 20.0; public ChartWithAxisMouseMoveListener(Chart chart, Composite hoverArea) { super(chart, hoverArea); diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/listeners/PieChartMouseMoveListener.java b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/listeners/PieChartMouseMoveListener.java index 6a2de4f9c9..5c65c450d5 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/listeners/PieChartMouseMoveListener.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/listeners/PieChartMouseMoveListener.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2014 Red Hat, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat - Initial API and implementation. + *******************************************************************************/ package org.eclipse.linuxtools.internal.systemtap.graphing.ui.charts.listeners; import java.text.MessageFormat; diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/listeners/ToolTipChartMouseMoveListener.java b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/listeners/ToolTipChartMouseMoveListener.java index 2d7ba2efd9..3df72c91a8 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/listeners/ToolTipChartMouseMoveListener.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/charts/listeners/ToolTipChartMouseMoveListener.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2014 Red Hat, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat - Initial API and implementation. + *******************************************************************************/ package org.eclipse.linuxtools.internal.systemtap.graphing.ui.charts.listeners; import org.eclipse.swt.SWT; @@ -12,7 +22,7 @@ import org.swtchart.Chart; * @since 3.0 */ public class ToolTipChartMouseMoveListener extends ChartMouseMoveListener { - private final int TIP_OFFSET = 20; + private static final int TIP_OFFSET = 20; protected final Shell tipShell; protected final Text tipText; diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/wizards/graph/SelectGraphAndSeriesWizardPage.java b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/wizards/graph/SelectGraphAndSeriesWizardPage.java index 0eb1c72d63..79975de946 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/wizards/graph/SelectGraphAndSeriesWizardPage.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/systemtap/graphing/ui/wizards/graph/SelectGraphAndSeriesWizardPage.java @@ -36,7 +36,18 @@ import org.eclipse.swt.widgets.Text; /** * @since 2.1 */ -public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listener { +public class SelectGraphAndSeriesWizardPage extends WizardPage implements + Listener { + private Button[] btnGraphs; + private SelectGraphAndSeriesWizard wizard; + + private Text txtTitle; + private Combo cboXItem; + private Combo[] cboYItems; + private Label[] lblYItems; + private GraphModel model; + private boolean[] deleted; + public SelectGraphAndSeriesWizardPage() { super("selectGraphAndSeries"); //$NON-NLS-1$ setTitle(Localization.getString("SelectGraphAndSeriesWizardPage.SelectGraphAndSeries")); //$NON-NLS-1$ @@ -44,11 +55,11 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listen @Override public void createControl(Composite parent) { - wizard = (SelectGraphAndSeriesWizard)getWizard(); + wizard = (SelectGraphAndSeriesWizard) getWizard(); model = wizard.model; - edit = wizard.isEditing(); + boolean edit = wizard.isEditing(); - //Set the layout data + // Set the layout data Composite comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout()); @@ -100,7 +111,7 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listen } }); - //Add the data series widgets + // Add the data series widgets String[] labels = model.getSeries(); cboYItems = new Combo[!edit ? labels.length : Math.max(labels.length, model.getYSeries().length)]; @@ -110,7 +121,7 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listen Label lblXItem = new Label(cmpGraphOptsSeries, SWT.NONE); lblXItem.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); lblXItem.setText(Localization.getString("SelectGraphAndSeriesWizardPage.XSeries")); //$NON-NLS-1$ - cboXItem = new Combo(cmpGraphOptsSeries, SWT.DROP_DOWN|SWT.READ_ONLY); + cboXItem = new Combo(cmpGraphOptsSeries, SWT.DROP_DOWN | SWT.READ_ONLY); cboXItem.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); cboXItem.addSelectionListener(new ComboSelectionListener()); cboXItem.add(Localization.getString("SelectGraphAndSeriesWizardPage.RowID")); //$NON-NLS-1$ @@ -119,7 +130,7 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listen lblYItems[i] = new Label(cmpGraphOptsSeries, SWT.NONE); lblYItems[i].setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); lblYItems[i].setText(MessageFormat.format(Localization.getString("SelectGraphAndSeriesWizardPage.YSeries"), i)); //$NON-NLS-1$ - cboYItems[i] = new Combo(cmpGraphOptsSeries, SWT.DROP_DOWN|SWT.READ_ONLY); + cboYItems[i] = new Combo(cmpGraphOptsSeries, SWT.DROP_DOWN | SWT.READ_ONLY); cboYItems[i].setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); cboYItems[i].addSelectionListener(new ComboSelectionListener()); @@ -143,7 +154,7 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listen cboYItems[0].select(0); } else { selected = model.getXSeries(); - if (selected < labels.length){ + if (selected < labels.length) { cboXItem.select(selected + 1); } else { cboXItem.add(Localization.getString("SelectGraphAndSeriesWizardPage.Deleted"), 0); //$NON-NLS-1$ @@ -165,12 +176,13 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listen cboYItems[i].select(selected = 0); } else { selected = model.getYSeries()[i]; - if (selected < labels.length){ + if (selected < labels.length) { cboYItems[i].select(selected + 1); } else { - cboYItems[i].add(Localization.getString("SelectGraphAndSeriesWizardPage.Deleted"), 0); //$NON-NLS-1$ + cboYItems[i].add(Localization + .getString("SelectGraphAndSeriesWizardPage.Deleted"), 0); //$NON-NLS-1$ cboYItems[i].select(0); - deleted[i+1] = true; + deleted[i + 1] = true; } } cboYItems[i].setVisible(cvisible); @@ -178,7 +190,7 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listen cvisible = (selected > 0); } - //Select one of the graph types by default, rather than blank choice + // Select one of the graph types by default, rather than blank choice if (!edit) { btnGraphs[0].setSelection(true); saveDataToModelGraph(graphIDs[0]); @@ -194,7 +206,7 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listen @Override public void handleEvent(Event event) { if (event.widget instanceof Button) { - saveDataToModelGraph(((Button)event.widget).getData().toString()); + saveDataToModelGraph(((Button) event.widget).getData().toString()); checkErrors(false); wizard.getContainer().updateButtons(); } @@ -226,17 +238,18 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listen private boolean saveDataToModelSeries() { if (getErrorMessage() == null) { model.setTitle(txtTitle.getText()); - model.setXSeries(cboXItem.getSelectionIndex()-1); + model.setXSeries(cboXItem.getSelectionIndex() - 1); int i, count; - for (i = 1, count = 1; i < cboYItems.length && 0 != cboYItems[i].getSelectionIndex(); i++) { + for (i = 1, count = 1; i < cboYItems.length + && 0 != cboYItems[i].getSelectionIndex(); i++) { count++; } int[] ySeries = new int[count]; ySeries[0] = cboYItems[0].getSelectionIndex(); for (i = 1; i < count; i++) { - ySeries[i] = cboYItems[i].getSelectionIndex()-1; + ySeries[i] = cboYItems[i].getSelectionIndex() - 1; } model.setYSeries(ySeries); return true; @@ -245,15 +258,16 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listen } private void markAsDuplicate(Combo item, Boolean bad) { - item.setForeground(item.getDisplay().getSystemColor(bad ? SWT.COLOR_RED : SWT.COLOR_BLACK)); + item.setForeground(item.getDisplay().getSystemColor( + bad ? SWT.COLOR_RED : SWT.COLOR_BLACK)); } private boolean isSeriesUnique() { Combo item = cboXItem; int i = 0; do { - if (item.isVisible() && - item.getForeground().equals(item.getDisplay().getSystemColor(SWT.COLOR_RED))) { + if (item.isVisible() && item.getForeground().equals( + item.getDisplay().getSystemColor(SWT.COLOR_RED))) { return false; } if (i == cboYItems.length) { @@ -278,16 +292,18 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listen } for (int j, i = 0; i < cboYItems.length; i++) { - if (cboYItems[i].isVisible() && !deleted[i+1]) { + if (cboYItems[i].isVisible() && !deleted[i + 1]) { // Find duplicates by comparing selection indices. Every combo has an // extra selection before column names (Row Num or NA), except Y-series 0. int offset = (i == 0 ? 1 : 0); - for (j = i+1; j < cboYItems.length; j++) { + for (j = i + 1; j < cboYItems.length; j++) { try { - if (!deleted[j+1] && cboYItems[j].isVisible() - && cboYItems[i].getSelectionIndex() + offset == cboYItems[j].getSelectionIndex()) { + if (!deleted[j + 1] + && cboYItems[j].isVisible() + && cboYItems[i].getSelectionIndex() + offset == cboYItems[j] + .getSelectionIndex()) { markAsDuplicate(cboYItems[i], true); markAsDuplicate(cboYItems[j], true); foundDuplicate = true; @@ -371,7 +387,8 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listen */ private class ComboSelectionListener implements SelectionListener { @Override - public void widgetDefaultSelected(SelectionEvent e) {} + public void widgetDefaultSelected(SelectionEvent e) { + } @Override public void widgetSelected(SelectionEvent e) { @@ -381,12 +398,12 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listen cboXItem.remove(0); deleted[0] = false; } - } - else { + } else { for (int i = 0; i < cboYItems.length; i++) { - if (deleted[i+1] && cboYItems[i].equals(source) && cboYItems[i].getSelectionIndex() != 0) { + if (deleted[i + 1] && cboYItems[i].equals(source) + && cboYItems[i].getSelectionIndex() != 0) { cboYItems[i].remove(0); - deleted[i+1] = false; + deleted[i + 1] = false; break; } } @@ -395,12 +412,14 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listen for (int i = 1; i < cboYItems.length; i++) { cboYItems[i].setVisible(setVisible); lblYItems[i].setVisible(setVisible); - if (!setVisible && deleted[i+1]) { + if (!setVisible && deleted[i + 1]) { cboYItems[i].remove(0); - deleted[i+1] = false; + deleted[i + 1] = false; cboYItems[i].select(0); } - if (deleted[i+1] || (cboYItems[i].getSelectionIndex() > 0 && cboYItems[i].isVisible())) { + if (deleted[i + 1] + || (cboYItems[i].getSelectionIndex() > 0 + && cboYItems[i].isVisible())) { setVisible = true; } else { setVisible = false; @@ -415,31 +434,21 @@ public class SelectGraphAndSeriesWizardPage extends WizardPage implements Listen private void checkErrors(boolean markDuplicates) { boolean isUnique = markDuplicates ? findAndMarkDuplicates() : isSeriesUnique(); if (model.getGraphID() == null) { - setErrorMessage(Localization.getString("SelectGraphAndSeriesWizardPage.NoGraphType")); //$NON-NLS-1$ - } - else if (!isUnique) { - setErrorMessage(Localization.getString("SelectGraphAndSeriesWizardPage.SeriesNotUnique")); //$NON-NLS-1$ - } - else if (isSeriesDeleted()) { - setErrorMessage(Localization.getString("SelectGraphAndSeriesWizardPage.SeriesDeleted")); //$NON-NLS-1$ - } - else if (txtTitle.getText().length() == 0) { - setErrorMessage(Localization.getString("SelectGraphAndSeriesWizardPage.TitleNotSet")); //$NON-NLS-1$ - } - else { + setErrorMessage(Localization + .getString("SelectGraphAndSeriesWizardPage.NoGraphType")); //$NON-NLS-1$ + } else if (!isUnique) { + setErrorMessage(Localization + .getString("SelectGraphAndSeriesWizardPage.SeriesNotUnique")); //$NON-NLS-1$ + } else if (isSeriesDeleted()) { + setErrorMessage(Localization + .getString("SelectGraphAndSeriesWizardPage.SeriesDeleted")); //$NON-NLS-1$ + } else if (txtTitle.getText().length() == 0) { + setErrorMessage(Localization + .getString("SelectGraphAndSeriesWizardPage.TitleNotSet")); //$NON-NLS-1$ + } else { setErrorMessage(null); } getWizard().getContainer().updateButtons(); } - private Button[] btnGraphs; - private SelectGraphAndSeriesWizard wizard; - - private Text txtTitle; //TODO: Move this to another page once graphs get more detail - private Combo cboXItem; - private Combo[] cboYItems; - private Label[] lblYItems; - private GraphModel model; - private boolean[] deleted; - private boolean edit; } \ No newline at end of file diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/dialogs/SelectServerDialog.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/dialogs/SelectServerDialog.java index 86ab23206a..cd5c5f8c8f 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/dialogs/SelectServerDialog.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/dialogs/SelectServerDialog.java @@ -25,15 +25,7 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; - - public class SelectServerDialog extends Dialog { - private Text hostText; - private Text userText; - private Text passwordText; - private Button rememberButton; - private Button connectButton; - private Button cancelButton; private boolean result; public SelectServerDialog(Shell parent) { @@ -66,7 +58,7 @@ public class SelectServerDialog extends Dialog { GridData dataFill = new GridData(); dataFill.grabExcessHorizontalSpace = true; dataFill.horizontalAlignment = SWT.FILL; - hostText = new Text(shell, SWT.SINGLE | SWT.BORDER); + final Text hostText = new Text(shell, SWT.SINGLE | SWT.BORDER); hostText.setLayoutData(dataFill); hostText.setText(ConsoleLogPlugin.getDefault().getPreferenceStore().getString(ConsoleLogPreferenceConstants.HOST_NAME)); @@ -74,7 +66,7 @@ public class SelectServerDialog extends Dialog { userLabel.setText(Messages.SelectServerDialog_User); userLabel.setLayoutData(dataLeft); - userText = new Text(shell, SWT.SINGLE | SWT.BORDER); + final Text userText = new Text(shell, SWT.SINGLE | SWT.BORDER); userText.setLayoutData(dataFill); userText.setText(ConsoleLogPlugin.getDefault().getPreferenceStore().getString(ConsoleLogPreferenceConstants.SCP_USER)); @@ -82,7 +74,7 @@ public class SelectServerDialog extends Dialog { passwordLabel.setText(Messages.SelectServerDialog_Password); passwordLabel.setLayoutData(dataLeft); - passwordText = new Text(shell, SWT.SINGLE | SWT.BORDER); + final Text passwordText = new Text(shell, SWT.SINGLE | SWT.BORDER); passwordText.setEchoChar('*'); passwordText.setLayoutData(dataFill); passwordText.setText(ConsoleLogPlugin.getDefault().getPreferenceStore().getString(ConsoleLogPreferenceConstants.SCP_PASSWORD)); @@ -91,13 +83,13 @@ public class SelectServerDialog extends Dialog { GridData data = new GridData(); data.horizontalAlignment = SWT.LEFT; data.horizontalSpan = 2; - rememberButton = new Button(shell, SWT.CHECK); + final Button rememberButton = new Button(shell, SWT.CHECK); rememberButton.setLayoutData(data); rememberButton.setText(Messages.SelectServerDialog_AlwaysConnectToHost); data = new GridData(); data.horizontalAlignment = SWT.RIGHT; - cancelButton = new Button(shell, SWT.PUSH); + Button cancelButton = new Button(shell, SWT.PUSH); cancelButton.setLayoutData(data); cancelButton.setSize(50, 100); cancelButton.setText(Messages.SelectServerDialog_Cancel); @@ -111,7 +103,7 @@ public class SelectServerDialog extends Dialog { data = new GridData(); data.horizontalAlignment = SWT.RIGHT; - connectButton = new Button(shell, SWT.PUSH); + Button connectButton = new Button(shell, SWT.PUSH); connectButton.setLayoutData(data); connectButton.setSize(50, 100); connectButton.setText(Messages.SelectServerDialog_Connect); diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.editor/src/org/eclipse/linuxtools/systemtap/ui/editor/SimpleDocumentProvider.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.editor/src/org/eclipse/linuxtools/systemtap/ui/editor/SimpleDocumentProvider.java index 5a10e96aae..c67c2dfae9 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.editor/src/org/eclipse/linuxtools/systemtap/ui/editor/SimpleDocumentProvider.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.editor/src/org/eclipse/linuxtools/systemtap/ui/editor/SimpleDocumentProvider.java @@ -118,9 +118,6 @@ public class SimpleDocumentProvider extends AbstractDocumentProvider { return null; } - /* - * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#doSaveDocument(org.eclipse.core.runtime.IProgressMonitor, java.lang.Object, org.eclipse.jface.text.IDocument, boolean) - */ @Override protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException { if (element instanceof IPathEditorInput) { @@ -134,7 +131,7 @@ public class SimpleDocumentProvider extends AbstractDocumentProvider { if (file.exists()) { if (file.canWrite()) { Writer writer= new FileWriter(file); - writeDocumentContent(document, writer, monitor); + writeDocumentContent(document, writer); } else { throw new CoreException(new Status(IStatus.ERROR, EditorPlugin.ID, IStatus.OK, "file is read-only", null)); //$NON-NLS-1$ } @@ -152,26 +149,19 @@ public class SimpleDocumentProvider extends AbstractDocumentProvider { * * @param document the document to save * @param writer the stream to save it to - * @param monitor a progress monitor to report progress * @throws IOException if writing fails */ - private static void writeDocumentContent(IDocument document, Writer writer, IProgressMonitor monitor) throws IOException { + private static void writeDocumentContent(IDocument document, Writer writer) throws IOException { try (Writer out= new BufferedWriter(writer)) { out.write(document.get()); } } - /* - * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#getOperationRunner(org.eclipse.core.runtime.IProgressMonitor) - */ @Override protected IRunnableContext getOperationRunner(IProgressMonitor monitor) { return null; } - /* - * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#isModifiable(java.lang.Object) - */ @Override public boolean isModifiable(Object element) { if (element instanceof IPathEditorInput) { @@ -182,17 +172,11 @@ public class SimpleDocumentProvider extends AbstractDocumentProvider { return false; } - /* - * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#isReadOnly(java.lang.Object) - */ @Override public boolean isReadOnly(Object element) { return !isModifiable(element); } - /* - * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#isStateValidated(java.lang.Object) - */ @Override public boolean isStateValidated(Object element) { return true; diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.editor/src/org/eclipse/linuxtools/systemtap/ui/editor/SimpleEditor.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.editor/src/org/eclipse/linuxtools/systemtap/ui/editor/SimpleEditor.java index 031a2ddfba..eb740d76a5 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.editor/src/org/eclipse/linuxtools/systemtap/ui/editor/SimpleEditor.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.editor/src/org/eclipse/linuxtools/systemtap/ui/editor/SimpleEditor.java @@ -152,8 +152,7 @@ public class SimpleEditor extends TextEditor { */ private static IEditorInput createEditorInput(File file) { IPath location= new Path(file.getAbsolutePath()); - PathEditorInput input= new PathEditorInput(location); - return input; + return new PathEditorInput(location); } /** @@ -191,7 +190,7 @@ public class SimpleEditor extends TextEditor { FileDialog dialog= new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.SAVE); dialog.setText(Localization.getString("NewFileAction.NewFile")); //$NON-NLS-1$ String path= dialog.open(); - if (path != null && path.length() > 0) { + if (path != null && !path.isEmpty()) { return new File(path); } return null; diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDEPerspective.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDEPerspective.java index 2fd6152339..6a9d12e262 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDEPerspective.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDEPerspective.java @@ -29,7 +29,7 @@ import org.eclipse.ui.console.IConsoleConstants; * @author Ryan Morse */ public class IDEPerspective implements IPerspectiveFactory { - public static String ID = "org.eclipse.linuxtools.systemtap.ui.ide.IDEPerspective"; //$NON-NLS-1$ + public static final String ID = "org.eclipse.linuxtools.systemtap.ui.ide.IDEPerspective"; //$NON-NLS-1$ @Override public void createInitialLayout(IPageLayout layout) { diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDEPlugin.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDEPlugin.java index efcf6ebe28..52ace35be4 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDEPlugin.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDEPlugin.java @@ -100,8 +100,7 @@ public class IDEPlugin extends AbstractUIPlugin { path = ""; //$NON-NLS-1$ } try { - URI uri = new URI("ssh", user, host, -1, path, null, null); //$NON-NLS-1$ - return uri; + return new URI("ssh", user, host, -1, path, null, null); //$NON-NLS-1$ } catch (URISyntaxException uri) { return null; } @@ -112,13 +111,15 @@ public class IDEPlugin extends AbstractUIPlugin { } public static void log(Throwable e) { - if (e instanceof InvocationTargetException) + if (e instanceof InvocationTargetException) { e = ((InvocationTargetException) e).getTargetException(); + } IStatus status = null; - if (e instanceof CoreException) + if (e instanceof CoreException) { status = ((CoreException) e).getStatus(); - else + } else { status = new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, e.getMessage(), e); + } log(status); } diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/IndentHandler.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/IndentHandler.java index 449ee316c4..5684166c8f 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/IndentHandler.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/IndentHandler.java @@ -381,8 +381,7 @@ public class IndentHandler extends AbstractHandler { * @return the tab size as defined in the current formatter preferences */ private int getTabSize() { - return getCoreFormatterOption( - STPDefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 4); + return getCoreFormatterOption(4); } /** @@ -394,7 +393,7 @@ public class IndentHandler extends AbstractHandler { */ private boolean indentEmptyLines() { return STPDefaultCodeFormatterConstants.TRUE - .equals(getCoreFormatterOption(STPDefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES)); + .equals(getCoreFormatterOption()); } /** @@ -406,7 +405,7 @@ public class IndentHandler extends AbstractHandler { */ private boolean indentInsideLineComments() { return STPDefaultCodeFormatterConstants.TRUE - .equals(getCoreFormatterOption(STPDefaultCodeFormatterConstants.FORMATTER_INDENT_INSIDE_LINE_COMMENTS)); + .equals(getCoreFormatterOption()); } /** @@ -417,7 +416,7 @@ public class IndentHandler extends AbstractHandler { * the key of the preference * @return the value of the preference */ - private String getCoreFormatterOption(String key) { + private String getCoreFormatterOption() { return "false"; //$NON-NLS-1$ } @@ -425,15 +424,13 @@ public class IndentHandler extends AbstractHandler { * Returns the possibly project-specific core preference defined under * key, or def if the value is not a integer. * - * @param key - * the key of the preference * @param def * the default value * @return the value of the preference */ - private int getCoreFormatterOption(String key, int def) { + private int getCoreFormatterOption(int def) { try { - return Integer.parseInt(getCoreFormatterOption(key)); + return Integer.parseInt(getCoreFormatterOption()); } catch (NumberFormatException e) { return def; } diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/IndentUtil.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/IndentUtil.java index 15d6e125ea..c33193ad2a 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/IndentUtil.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/IndentUtil.java @@ -226,10 +226,11 @@ public final class IndentUtil { // standard C code indentation if (indent == null) { StringBuilder computed= indenter.computeIndentation(offset); - if (computed != null) + if (computed != null) { indent= computed.toString(); - else - indent= new String(); + } else { + indent= ""; //$NON-NLS-1$ + } } return indent; } @@ -245,8 +246,9 @@ public final class IndentUtil { * @throws BadLocationException */ public static String computeCommentIndent(IDocument document, int line, STPHeuristicScanner scanner, ITypedRegion partition) throws BadLocationException { - if (line == 0) // impossible - the first line is never inside a comment + if (line == 0) { // impossible - the first line is never inside a comment return null; + } // don't make any assumptions if the line does not start with \s*\* - it might be // commented out code, for which we don't want to change the indent @@ -256,8 +258,9 @@ public final class IndentUtil { final int lineEnd= lineStart + lineLength; int nonWS= scanner.findNonWhitespaceForwardInAnyPartition(lineStart, lineEnd); if (nonWS == STPHeuristicScanner.NOT_FOUND || document.getChar(nonWS) != '*') { - if (nonWS == STPHeuristicScanner.NOT_FOUND) + if (nonWS == STPHeuristicScanner.NOT_FOUND) { return document.get(lineStart, lineLength); + } return document.get(lineStart, nonWS - lineStart); } @@ -276,8 +279,9 @@ public final class IndentUtil { previousLineLength= previousLine.getLength(); previousLineEnd= previousLineStart + previousLineLength; previousLineNonWS= scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd); - if (previousLineNonWS == STPHeuristicScanner.NOT_FOUND) + if (previousLineNonWS == STPHeuristicScanner.NOT_FOUND) { previousLineNonWS= previousLineEnd; + } // add the initial space // TODO this may be controlled by a formatter preference in the future diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPAutoEditStrategy.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPAutoEditStrategy.java index 11efa8bcc1..fe56a2b6e2 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPAutoEditStrategy.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPAutoEditStrategy.java @@ -49,14 +49,15 @@ public class STPAutoEditStrategy extends * * @param document * @param offset - * @param partitioning * @return the block balance */ - private static int getBlockBalance(IDocument document, int offset, String partitioning) { - if (offset < 1) + private static int getBlockBalance(IDocument document, int offset) { + if (offset < 1) { return -1; - if (offset >= document.getLength()) + } + if (offset >= document.getLength()) { return 1; + } int begin = offset; int end = offset - 1; @@ -213,7 +214,7 @@ public class STPAutoEditStrategy extends // copy old content of line behind insertion point to new line // unless we think we are inserting an anonymous type definition - if (c.offset == 0 || !(computeAnonymousPosition(d, c.offset - 1, fPartitioning, lineEnd) != -1)) { + if (c.offset == 0 || !(computeAnonymousPosition(d, c.offset - 1, lineEnd) != -1)) { if (lineEnd - contentStart > 0) { c.length = lineEnd - c.offset; buf.append(d.get(contentStart, lineEnd - contentStart).toCharArray()); @@ -223,12 +224,14 @@ public class STPAutoEditStrategy extends buf.append(TextUtilities.getDefaultLineDelimiter(d)); StringBuilder reference = null; int nonWS = findEndOfWhiteSpace(d, start, lineEnd); - if (nonWS < c.offset && d.getChar(nonWS) == '{') + if (nonWS < c.offset && d.getChar(nonWS) == '{') { reference = new StringBuilder(d.get(start, nonWS - start)); - else + } else { reference = indenter.getReferenceIndentation(c.offset); - if (reference != null) + } + if (reference != null) { buf.append(reference); + } buf.append('}'); int bound= c.offset > 200 ? c.offset - 200 : STPHeuristicScanner.UNBOUND; int bracePos = scanner.findOpeningPeer(c.offset - 1, bound, '{', '}'); @@ -248,15 +251,17 @@ public class STPAutoEditStrategy extends StringBuilder reference = null; int nonWS = findEndOfWhiteSpace(d, start, lineEnd); - if (nonWS < c.offset && d.getChar(nonWS) == '{') + if (nonWS < c.offset && d.getChar(nonWS) == '{') { reference = new StringBuilder(d.get(start, nonWS - start)); - else + } else { reference = indenter.getReferenceIndentation(c.offset); + } buf.append(TextUtilities.getDefaultLineDelimiter(d)); - if (reference != null) + if (reference != null) { buf.append(reference); + } } } c.text = buf.toString(); @@ -267,8 +272,9 @@ public class STPAutoEditStrategy extends } private void smartIndentUponE(IDocument doc, DocumentCommand c) { - if (c.offset < 4 || doc.getLength() == 0) + if (c.offset < 4 || doc.getLength() == 0) { return; + } try { String content = doc.get(c.offset - 3, 3); @@ -281,21 +287,24 @@ public class STPAutoEditStrategy extends int lineOffset = doc.getLineOffset(line); // make sure we don't have any leading comments etc. - if (doc.get(lineOffset, p - lineOffset).trim().length() != 0) + if (doc.get(lineOffset, p - lineOffset).trim().length() != 0) { return; + } // Line of last C code int pos = scanner.findNonWhitespaceBackward(p - 1, STPHeuristicScanner.UNBOUND); - if (pos == -1) + if (pos == -1) { return; + } int lastLine = doc.getLineOfOffset(pos); // Only shift if the last C line is further up and is a braceless block candidate if (lastLine < line) { STPIndenter indenter = new STPIndenter(doc, scanner, fProject); int ref = indenter.findReferencePosition(p, true, MatchMode.REGULAR); - if (ref == STPHeuristicScanner.NOT_FOUND) + if (ref == STPHeuristicScanner.NOT_FOUND) { return; + } int refLine = doc.getLineOfOffset(ref); String indent = getIndentOfLine(doc, refLine); @@ -305,7 +314,6 @@ public class STPAutoEditStrategy extends c.offset = lineOffset; } } - return; } @@ -318,31 +326,35 @@ public class STPAutoEditStrategy extends int lineOffset = doc.getLineOffset(line); // make sure we don't have any leading comments etc. - if (doc.get(lineOffset, p - lineOffset).trim().length() != 0) + if (doc.get(lineOffset, p - lineOffset).trim().length() != 0) { return; + } // Line of last C code int pos = scanner.findNonWhitespaceBackward(p - 1, STPHeuristicScanner.UNBOUND); - if (pos == -1) + if (pos == -1) { return; + } int lastLine = doc.getLineOfOffset(pos); // Only shift if the last C line is further up and is a braceless block candidate if (lastLine < line) { STPIndenter indenter = new STPIndenter(doc, scanner, fProject); int ref = indenter.findReferencePosition(p, false, MatchMode.MATCH_CASE); - if (ref == STPHeuristicScanner.NOT_FOUND) + if (ref == STPHeuristicScanner.NOT_FOUND) { return; + } int refLine = doc.getLineOfOffset(ref); int nextToken = scanner.nextToken(ref, STPHeuristicScanner.UNBOUND); String indent; - if (nextToken == STPSymbols.TokenCASE || nextToken == STPSymbols.TokenDEFAULT) + if (nextToken == STPSymbols.TokenCASE || nextToken == STPSymbols.TokenDEFAULT) { indent = getIndentOfLine(doc, refLine); - else // at the brace of the switch + } else {// at the brace of the switch indent = indenter.computeIndentation(p).toString(); + } if (indent != null) { - c.text = indent.toString() + "case"; //$NON-NLS-1$ + c.text = indent + "case"; //$NON-NLS-1$ c.length += c.offset - lineOffset; c.offset = lineOffset; } @@ -360,11 +372,10 @@ public class STPAutoEditStrategy extends * * @param document the document being modified * @param offset the offset of the caret position, relative to the line start. - * @param partitioning the document partitioning * @param max the max position * @return an insert position relative to the line start if line contains a parenthesized expression that can be followed by a block, -1 otherwise */ - private static int computeAnonymousPosition(IDocument document, int offset, String partitioning, int max) { + private static int computeAnonymousPosition(IDocument document, int offset, int max) { // find the opening parenthesis for every closing parenthesis on the current line after offset // return the position behind the closing parenthesis if it looks like a method declaration // or an expression for an if, while, for, catch statement @@ -373,8 +384,9 @@ public class STPAutoEditStrategy extends int pos = offset; int length = max; int scanTo = scanner.scanForward(pos, length, '}'); - if (scanTo == -1) + if (scanTo == -1) { scanTo = length; + } int closingParen = findClosingParenToLeft(scanner, pos) - 1; @@ -416,7 +428,7 @@ public class STPAutoEditStrategy extends } private boolean isClosedBrace(IDocument document, int offset) { - return getBlockBalance(document, offset, fPartitioning) <= 0; + return getBlockBalance(document, offset) <= 0; } private void smartIndentOnKeypress(IDocument document, DocumentCommand command) { @@ -1082,4 +1094,4 @@ public class STPAutoEditStrategy extends } } } -} \ No newline at end of file +} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPCompletionProcessor.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPCompletionProcessor.java index feb2a11635..0ef28f1db3 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPCompletionProcessor.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPCompletionProcessor.java @@ -349,8 +349,7 @@ public class STPCompletionProcessor implements IContentAssistProcessor, ITextHov for (int n = offset - 1; n >= 0; n--) { char c = doc.getChar(n); if (isTokenDelimiter(c)) { - String word = doc.get(n + 1, offset - n - 1); - return word; + return doc.get(n + 1, offset - n - 1); } } return ""; //$NON-NLS-1$ diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPConfiguration.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPConfiguration.java index 498aa99bbb..afef2384b7 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPConfiguration.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPConfiguration.java @@ -100,8 +100,7 @@ public class STPConfiguration extends SourceViewerConfiguration { { STPReconcilingStrategy strategy = new STPReconcilingStrategy(); strategy.setEditor(editor); - MonoReconciler reconciler = new MonoReconciler(strategy,false); - return reconciler; + return new MonoReconciler(strategy,false); } /** @@ -116,10 +115,6 @@ public class STPConfiguration extends SourceViewerConfiguration { return doubleClickStrategy; } - - /* (non-Javadoc) - * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer) - */ @Override public IPresentationReconciler getPresentationReconciler( ISourceViewer sourceViewer) { diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPEditor.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPEditor.java index 045cfd537b..8a812fe752 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPEditor.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPEditor.java @@ -38,7 +38,6 @@ public class STPEditor extends SimpleEditor { private ColorManager colorManager; - private ProjectionSupport stpProjectionSupport; private Annotation[] stpOldAnnotations; private ProjectionAnnotationModel stpAnnotationModel; @@ -69,7 +68,7 @@ public class STPEditor extends SimpleEditor { { super.createPartControl(parent); ProjectionViewer viewer =(ProjectionViewer)getSourceViewer(); - stpProjectionSupport = new ProjectionSupport(viewer,getAnnotationAccess(),getSharedColors()); + ProjectionSupport stpProjectionSupport = new ProjectionSupport(viewer,getAnnotationAccess(),getSharedColors()); stpProjectionSupport.install(); viewer.doOperation(ProjectionViewer.TOGGLE); stpAnnotationModel = viewer.getProjectionAnnotationModel(); diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPIndenter.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPIndenter.java index 743a5adc17..e5d2efcafc 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPIndenter.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPIndenter.java @@ -699,8 +699,7 @@ public final class STPIndenter { try { IRegion line= fDocument.getLineInformationOfOffset(offset); int lineEnd= line.getOffset() + line.getLength(); - int next= fScanner.nextToken(offset, lineEnd); - return next; + return fScanner.nextToken(offset, lineEnd); } catch (BadLocationException e) { } } @@ -720,8 +719,7 @@ public final class STPIndenter { IRegion line= fDocument.getLineInformationOfOffset(offset); int lineEnd= line.getOffset() + line.getLength(); fScanner.nextToken(offset, lineEnd); - int next = fScanner.nextToken(fScanner.getPosition(), lineEnd); - return next; + return fScanner.nextToken(fScanner.getPosition(), lineEnd); } catch (BadLocationException e) { } } @@ -781,15 +779,17 @@ public final class STPIndenter { case STPSymbols.TokenCASE: case STPSymbols.TokenDEFAULT: - if (isFirstTokenOnLine) + if (isFirstTokenOnLine) { matchMode = MatchMode.MATCH_CASE; + } break; case STPSymbols.TokenPUBLIC: case STPSymbols.TokenPROTECTED: case STPSymbols.TokenPRIVATE: - if (isFirstTokenOnLine && peekSecondToken(offset) != STPSymbols.TokenIDENT) + if (isFirstTokenOnLine && peekSecondToken(offset) != STPSymbols.TokenIDENT) { matchMode = MatchMode.MATCH_ACCESS_SPECIFIER; + } break; case STPSymbols.TokenLBRACE: // for opening-brace-on-new-line style @@ -816,13 +816,15 @@ public final class STPIndenter { break; case STPSymbols.TokenRBRACE: // closing braces get unindented - if (isFirstTokenOnLine || prevToken != STPSymbols.TokenLBRACE) + if (isFirstTokenOnLine || prevToken != STPSymbols.TokenLBRACE) { matchMode = MatchMode.MATCH_BRACE; + } break; case STPSymbols.TokenRPAREN: - if (isFirstTokenOnLine) + if (isFirstTokenOnLine) { matchMode = MatchMode.MATCH_PAREN; + } break; } } catch (BadLocationException e) { diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPPartitionScanner.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPPartitionScanner.java index de959ce0e8..8f31ec3747 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPPartitionScanner.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPPartitionScanner.java @@ -24,14 +24,14 @@ import org.eclipse.jface.text.rules.Token; import org.eclipse.jface.text.rules.WordRule; public class STPPartitionScanner extends RuleBasedPartitionScanner { - public final static String STP_PARTITIONING = "__stp_partitioning"; //$NON-NLS-1$ + public static final String STP_PARTITIONING = "__stp_partitioning"; //$NON-NLS-1$ - public final static String STP_STRING = "__stp_string"; //$NON-NLS-1$ - public final static String STP_COMMENT = "__stp_comment"; //$NON-NLS-1$ - public final static String STP_CONDITIONAL = "__stp_conditional"; //$NON-NLS-1$ - public final static String STP_MULTILINE_COMMENT = "__stp_multiline_comment"; //$NON-NLS-1$ + public static final String STP_STRING = "__stp_string"; //$NON-NLS-1$ + public static final String STP_COMMENT = "__stp_comment"; //$NON-NLS-1$ + public static final String STP_CONDITIONAL = "__stp_conditional"; //$NON-NLS-1$ + public static final String STP_MULTILINE_COMMENT = "__stp_multiline_comment"; //$NON-NLS-1$ - public static String[] STP_PARTITION_TYPES = { IDocument.DEFAULT_CONTENT_TYPE, + public static final String[] STP_PARTITION_TYPES = { IDocument.DEFAULT_CONTENT_TYPE, STP_COMMENT, STP_MULTILINE_COMMENT, STP_STRING, STP_CONDITIONAL}; /** diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPProbeScanner.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPProbeScanner.java index 7e96af4e25..b194acfa7c 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPProbeScanner.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPProbeScanner.java @@ -22,14 +22,14 @@ import org.eclipse.jface.text.rules.SingleLineRule; import org.eclipse.jface.text.rules.Token; public class STPProbeScanner extends RuleBasedPartitionScanner { - public final static String STP_STRING = "__stp_string"; //$NON-NLS-1$ - public final static String STP_PROBE = "__stp_probe"; //$NON-NLS-1$ - public final static String STP_CONDITIONAL = "__stp_conditional"; //$NON-NLS-1$ - public final static String STP_COMMENT = "__stp_comment"; //$NON-NLS-1$ + public static final String STP_STRING = "__stp_string"; //$NON-NLS-1$ + public static final String STP_PROBE = "__stp_probe"; //$NON-NLS-1$ + public static final String STP_CONDITIONAL = "__stp_conditional"; //$NON-NLS-1$ + public static final String STP_COMMENT = "__stp_comment"; //$NON-NLS-1$ - public final static String STP_PROBE_PARTITIONING = "__stp_probe_partitioning"; //$NON-NLS-1$ + public static final String STP_PROBE_PARTITIONING = "__stp_probe_partitioning"; //$NON-NLS-1$ - public static String[] STP_PROBE_PARTITION_TYPES = { IDocument.DEFAULT_CONTENT_TYPE, + public static final String[] STP_PROBE_PARTITION_TYPES = { IDocument.DEFAULT_CONTENT_TYPE, STP_COMMENT, STP_STRING, STP_PROBE, STP_CONDITIONAL}; public STPProbeScanner() { diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptGraphOptionsTab.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptGraphOptionsTab.java index 05321a2374..4b325e5e3f 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptGraphOptionsTab.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptGraphOptionsTab.java @@ -112,7 +112,6 @@ public class SystemTapScriptGraphOptionsTab extends private Combo regularExpressionCombo; private Button removeRegexButton; - private Button generateExpsButton; private Text sampleOutputText; private Composite textFieldsComposite; @@ -124,7 +123,6 @@ public class SystemTapScriptGraphOptionsTab extends */ private boolean textListenersEnabled = true; - private ScrolledComposite regexTextScrolledComposite; private Group outputParsingGroup; private Button runWithChartCheckButton; @@ -155,7 +153,7 @@ public class SystemTapScriptGraphOptionsTab extends * the names of all of a regex's groups that have been deleted, so each name may be * restored (without having to retype it) when a group is added again. */ - private Stack cachedNames; + private Stack cachedNames = new Stack<>(); /** * A list of cachedNames stacks, containing one entry for each regular expression stored. @@ -651,7 +649,7 @@ public class SystemTapScriptGraphOptionsTab extends topLayout.setLayout(new GridLayout(1, false)); topLayout.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); - generateExpsButton = new Button(topLayout, SWT.PUSH); + Button generateExpsButton = new Button(topLayout, SWT.PUSH); generateExpsButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); generateExpsButton.setText(Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsButton); generateExpsButton.setToolTipText(Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsTooltip); @@ -768,7 +766,7 @@ public class SystemTapScriptGraphOptionsTab extends label2.setAlignment(SWT.LEFT); label2.setText(Messages.SystemTapScriptGraphOptionsTab_extractedValueLabel); - this.regexTextScrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.BORDER); + ScrolledComposite regexTextScrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.BORDER); GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); data.heightHint = 200; regexTextScrolledComposite.setLayoutData(data); @@ -781,7 +779,7 @@ public class SystemTapScriptGraphOptionsTab extends // To position the column labels properly, add a dummy column and use its children's sizes for reference. // This is necessary since expressionTableLabels can't share a layout with textFieldsComposite. textListenersEnabled = false; - addColumn(""); //$NON-NLS-1$ + addColumn(null); data = new GridData(SWT.FILL, SWT.FILL, false, false); data.horizontalIndent = textFieldsComposite.getChildren()[2].getLocation().x; data.widthHint = textFieldsComposite.getChildren()[2].getSize().x; @@ -872,7 +870,7 @@ public class SystemTapScriptGraphOptionsTab extends duplicateGraphButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - GraphData gd = ((GraphData) selectedTableItem.getData()).getCopy(); + GraphData gd = ((GraphData) selectedTableItem.getData()).clone(); TableItem item = new TableItem(graphsTable, SWT.NONE); graphsData.add(gd); @@ -1085,7 +1083,7 @@ public class SystemTapScriptGraphOptionsTab extends * the active stack of cached names, or a default name if one doesn't exist. */ private void addColumn(String nameToAdd) { - // Show the "shift" buttons of the previous column, if it exists. + // Show the "shift" buttons of the previous column, if they exist. if (this.numberOfVisibleColumns > 0) { textFieldsComposite.getChildren()[(this.numberOfVisibleColumns - 1) * 4].setVisible(true); textFieldsComposite.getChildren()[(this.numberOfVisibleColumns - 1) * 4 + 1].setVisible(true); @@ -1125,11 +1123,6 @@ public class SystemTapScriptGraphOptionsTab extends textFieldsComposite.layout(); textFieldsComposite.pack(); - // Special value: if an empty string is given, don't add button listeners. - if (nameToAdd == "") { //$NON-NLS-1$ - return; - } - // Add button listeners for shifting column names. buttonUp.addSelectionListener(new SelectionAdapter() { @Override @@ -1176,7 +1169,7 @@ public class SystemTapScriptGraphOptionsTab extends * @param saveNames Set to true if the contents of removed * columns are to be saved in a stack for later use. */ - private void removeColumn(Boolean saveNames) { + private void removeColumn(boolean saveNames) { Control[] children = textFieldsComposite.getChildren(); int i = this.numberOfVisibleColumns*4 - 1; -- cgit v1.2.3