From ae53f82634c0b11f692b690ad27e6d403206c665 Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Fri, 30 Oct 2015 10:41:10 +0200 Subject: [PATCH] autotools: Cleanups in the ui bundle. * Do not check for null variables that are known to be non-null already. * Stop using SubProgressMonitor in favor of SubMonitor. * Non-javadoc removed. * Commented code removed. * Multi-catch. Change-Id: Ib0aa433fbdfa8581c89161225f83a1f1640dd2dc Signed-off-by: Alexander Kurtakov --- .../autotools/ui/LineBreakingReader.java | 2 +- .../ui/actions/InvokeAclocalAction.java | 40 +++++++++--------- .../autotools/ui/actions/InvokeAction.java | 6 +-- .../ui/actions/InvokeAutoconfAction.java | 29 ++++++------- .../ui/actions/InvokeAutoheaderAction.java | 42 ++++++++----------- .../ui/actions/InvokeAutomakeAction.java | 41 +++++++++--------- .../ui/actions/InvokeAutoreconfAction.java | 31 +++++++------- .../ui/actions/InvokeLibtoolizeAction.java | 41 ++++++++---------- .../editors/automake/IWorkingCopyManager.java | 1 - .../ui/editors/automake/StatusTool.java | 1 - .../AutotoolsNewCCProjectWizardV2.java | 37 ++++------------ .../wizards/AutotoolsNewCProjectWizardV2.java | 42 ++++--------------- .../wizards/AutotoolsProjectImportWizard.java | 8 ++-- .../ConvertToAutotoolsProjectWizard.java | 4 +- .../ConvertToAutotoolsProjectWizardPage.java | 35 ++++------------ .../autotools/ui/wizards/ReferenceBlock.java | 4 +- 16 files changed, 138 insertions(+), 226 deletions(-) diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/LineBreakingReader.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/LineBreakingReader.java index 8c6146ad664..82a2daf1bf3 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/LineBreakingReader.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/LineBreakingReader.java @@ -14,8 +14,8 @@ package org.eclipse.cdt.internal.autotools.ui; import java.io.BufferedReader; import java.io.IOException; import java.io.Reader; - import java.text.BreakIterator; + import org.eclipse.swt.graphics.GC; /* diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAclocalAction.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAclocalAction.java index 41b05b11407..19f20fbe94e 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAclocalAction.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAclocalAction.java @@ -28,8 +28,9 @@ public class InvokeAclocalAction extends InvokeAction { public void run(IAction action) { IContainer container = getSelectedContainer(); - if (container == null) + if (container == null) { return; + } IPath execDir = getExecDir(container); String cwd = InvokeMessages.getString("CWD") + getCWD(container); //$NON-NLS-1$ @@ -66,36 +67,33 @@ public class InvokeAclocalAction extends InvokeAction { } int iOption = 0; - if (targetList.length > 0) + if (targetList.length > 0) { iOption = 1; + } - String[] argumentList = new String[targetList.length - + optionsList.length + iOption]; + String[] argumentList = new String[targetList.length + optionsList.length + iOption]; System.arraycopy(optionsList, 0, argumentList, 0, optionsList.length); if (iOption == 1) argumentList[optionsList.length] = "-I"; //$NON-NLS-1$ - System.arraycopy(targetList, 0, argumentList, optionsList.length - + iOption, targetList.length); + System.arraycopy(targetList, 0, argumentList, optionsList.length + iOption, targetList.length); - if (container != null) { - String aclocalCommand = null; - IProject project = getSelectedContainer().getProject(); - try { - aclocalCommand = project.getPersistentProperty(AutotoolsPropertyConstants.ACLOCAL_TOOL); - } catch (CoreException e) { - // do nothing - } - - // If unset, use default system path - if (aclocalCommand == null) - aclocalCommand = DEFAULT_COMMAND; - - executeConsoleCommand(DEFAULT_COMMAND, aclocalCommand, - argumentList, execDir); + String aclocalCommand = null; + IProject project = getSelectedContainer().getProject(); + try { + aclocalCommand = project.getPersistentProperty(AutotoolsPropertyConstants.ACLOCAL_TOOL); + } catch (CoreException e) { + // do nothing } + + // If unset, use default system path + if (aclocalCommand == null) { + aclocalCommand = DEFAULT_COMMAND; + } + + executeConsoleCommand(DEFAULT_COMMAND, aclocalCommand, argumentList, execDir); } @Override diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAction.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAction.java index f44a1a9c59f..8a41776b2b7 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAction.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAction.java @@ -43,7 +43,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.dialogs.InputDialog; @@ -414,8 +414,8 @@ public abstract class InvokeAction extends AbstractTargetAction { } catch (IOException e1) { } - if (launcher.waitAndRead(stdout, stderr, new SubProgressMonitor(monitor1, - IProgressMonitor.UNKNOWN)) != ICommandLauncher.OK) { + if (launcher.waitAndRead(stdout, stderr, + SubMonitor.convert(monitor1)) != ICommandLauncher.OK) { errMsg = launcher.getErrorMessage(); } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAutoconfAction.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAutoconfAction.java index 5a6b692cf6b..59ac2b63696 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAutoconfAction.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAutoconfAction.java @@ -20,9 +20,6 @@ import org.eclipse.jface.action.IAction; /** * Class responsible for invoking autoconf. - * - * @author klee - * */ public class InvokeAutoconfAction extends InvokeAction { @@ -35,21 +32,19 @@ public class InvokeAutoconfAction extends InvokeAction { IPath execDir = getExecDir(container); - if (container != null) { - IProject project = container.getProject(); - String autoconfCommand = null; - try { - autoconfCommand = project.getPersistentProperty(AutotoolsPropertyConstants.AUTOCONF_TOOL); - } catch (CoreException e) { - // do nothing - } - - // If unset for the project, default to system path - if (autoconfCommand == null) - autoconfCommand = DEFAULT_COMMAND; - - executeConsoleCommand(DEFAULT_COMMAND, autoconfCommand, new String[]{}, execDir); + IProject project = container.getProject(); + String autoconfCommand = null; + try { + autoconfCommand = project.getPersistentProperty(AutotoolsPropertyConstants.AUTOCONF_TOOL); + } catch (CoreException e) { + // do nothing } + + // If unset for the project, default to system path + if (autoconfCommand == null) { + autoconfCommand = DEFAULT_COMMAND; + } + executeConsoleCommand(DEFAULT_COMMAND, autoconfCommand, new String[] {}, execDir); } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAutoheaderAction.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAutoheaderAction.java index 7234aeef6e0..8f58c3ca1f6 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAutoheaderAction.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAutoheaderAction.java @@ -29,19 +29,15 @@ public class InvokeAutoheaderAction extends InvokeAction { public void run(IAction action) { IContainer container = getSelectedContainer(); - if (container == null) + if (container == null) { return; - + } IPath execDir = getExecDir(container); String cwd = InvokeMessages.getString("CWD") + getCWD(container); //$NON-NLS-1$ - InputDialog optionDialog = new SingleInputDialog( - new Shell(), - cwd, - InvokeMessages - .getString("InvokeAutoheaderAction.windowTitle.options"), //$NON-NLS-1$ - InvokeMessages - .getString("InvokeAutoheaderAction.message.options.otherOptions"), //$NON-NLS-1$ + InputDialog optionDialog = new SingleInputDialog(new Shell(), cwd, + InvokeMessages.getString("InvokeAutoheaderAction.windowTitle.options"), //$NON-NLS-1$ + InvokeMessages.getString("InvokeAutoheaderAction.message.options.otherOptions"), //$NON-NLS-1$ DEFAULT_OPTION, null); optionDialog.open(); @@ -54,23 +50,21 @@ public class InvokeAutoheaderAction extends InvokeAction { System.arraycopy(optionsList, 0, argumentList, 0, optionsList.length); - if (container != null) { - String autoheaderCommand = null; - IProject project = getSelectedContainer().getProject(); - try { - autoheaderCommand = project.getPersistentProperty(AutotoolsPropertyConstants.AUTOHEADER_TOOL); - } catch (CoreException e) { - // do nothing - } - - // If unset, use default system path - if (autoheaderCommand == null) - autoheaderCommand = DEFAULT_COMMAND; - - executeConsoleCommand(DEFAULT_COMMAND, autoheaderCommand, - argumentList, execDir); + String autoheaderCommand = null; + IProject project = getSelectedContainer().getProject(); + try { + autoheaderCommand = project.getPersistentProperty(AutotoolsPropertyConstants.AUTOHEADER_TOOL); + } catch (CoreException e) { + // do nothing } + // If unset, use default system path + if (autoheaderCommand == null) { + autoheaderCommand = DEFAULT_COMMAND; + } + + executeConsoleCommand(DEFAULT_COMMAND, autoheaderCommand, argumentList, execDir); + } @Override diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAutomakeAction.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAutomakeAction.java index e924fd9d856..e0ceaa82505 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAutomakeAction.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAutomakeAction.java @@ -34,18 +34,17 @@ public class InvokeAutomakeAction extends InvokeAction { public void run(IAction action) { IContainer container = getSelectedContainer(); - if (container == null) + if (container == null) { return; + } IPath execDir = getExecDir(container); String cwd = InvokeMessages.getString("CWD") + getCWD(container); //$NON-NLS-1$ -; TwoInputDialog optionDialog = new TwoInputDialog(new Shell(), cwd, - InvokeMessages - .getString("InvokeAutomakeAction.windowTitle.options"), //$NON-NLS-1$ -InvokeMessages - .getString("InvokeAutomakeAction.message.options.otherOptions"),InvokeMessages //$NON-NLS-1$ - .getString("InvokeAutomakeAction.message.options.makeTargets"), DEFAULT_OPTION, null); //$NON-NLS-1$ + InvokeMessages.getString("InvokeAutomakeAction.windowTitle.options"), //$NON-NLS-1$ + InvokeMessages.getString("InvokeAutomakeAction.message.options.otherOptions"), InvokeMessages //$NON-NLS-1$ + .getString("InvokeAutomakeAction.message.options.makeTargets"), //$NON-NLS-1$ + DEFAULT_OPTION, null); optionDialog.open(); @@ -74,22 +73,20 @@ InvokeMessages System.arraycopy(targetList, 0, argumentList, optionsList.length, targetList.length); - if (container != null) { - IProject project = container.getProject(); - String automakeCommand = null; - try { - automakeCommand = project.getPersistentProperty(AutotoolsPropertyConstants.AUTOMAKE_TOOL); - } catch (CoreException e) { - // do nothing - } - - // If automake path not set for the project, default to system path - if (automakeCommand == null) - automakeCommand = DEFAULT_COMMAND; - - executeConsoleCommand(DEFAULT_COMMAND, automakeCommand, - argumentList, execDir); + IProject project = container.getProject(); + String automakeCommand = null; + try { + automakeCommand = project.getPersistentProperty(AutotoolsPropertyConstants.AUTOMAKE_TOOL); + } catch (CoreException e) { + // do nothing } + + // If automake path not set for the project, default to system path + if (automakeCommand == null) { + automakeCommand = DEFAULT_COMMAND; + } + + executeConsoleCommand(DEFAULT_COMMAND, automakeCommand, argumentList, execDir); } @Override diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAutoreconfAction.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAutoreconfAction.java index f9ceb354d5e..731b7c4694d 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAutoreconfAction.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAutoreconfAction.java @@ -29,8 +29,9 @@ public class InvokeAutoreconfAction extends InvokeAction { public void run(IAction action) { IContainer container = getSelectedContainer(); - if (container == null) + if (container == null) { return; + } IPath execDir = getExecDir(container); String cwd = InvokeMessages.getString("CWD") + getCWD(container); //$NON-NLS-1$ @@ -54,22 +55,20 @@ public class InvokeAutoreconfAction extends InvokeAction { System.arraycopy(optionsList, 0, argumentList, 0, optionsList.length); - if (container != null) { - String autoreconfCommand = null; - IProject project = getSelectedContainer().getProject(); - try { - autoreconfCommand = project.getPersistentProperty(AutotoolsPropertyConstants.AUTORECONF_TOOL); - } catch (CoreException e) { - // do nothing - } - - // If unset, use default system path - if (autoreconfCommand == null) - autoreconfCommand = DEFAULT_COMMAND; - - executeConsoleCommand(DEFAULT_COMMAND, autoreconfCommand, - argumentList, execDir); + String autoreconfCommand = null; + IProject project = getSelectedContainer().getProject(); + try { + autoreconfCommand = project.getPersistentProperty(AutotoolsPropertyConstants.AUTORECONF_TOOL); + } catch (CoreException e) { + // do nothing } + + // If unset, use default system path + if (autoreconfCommand == null) { + autoreconfCommand = DEFAULT_COMMAND; + } + + executeConsoleCommand(DEFAULT_COMMAND, autoreconfCommand, argumentList, execDir); } @Override diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeLibtoolizeAction.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeLibtoolizeAction.java index 03d729a31e9..0548bcce569 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeLibtoolizeAction.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeLibtoolizeAction.java @@ -29,19 +29,16 @@ public class InvokeLibtoolizeAction extends InvokeAction { public void run(IAction action) { IContainer container = getSelectedContainer(); - if (container == null) + if (container == null) { return; + } IPath execDir = getExecDir(container); String cwd = InvokeMessages.getString("CWD") + getCWD(container); //$NON-NLS-1$ - InputDialog optionDialog = new SingleInputDialog( - new Shell(), - cwd, - InvokeMessages - .getString("InvokeLibtoolizeAction.windowTitle.options"), //$NON-NLS-1$ - InvokeMessages - .getString("InvokeLibtoolizeAction.message.options.otherOptions"), //$NON-NLS-1$ + InputDialog optionDialog = new SingleInputDialog(new Shell(), cwd, + InvokeMessages.getString("InvokeLibtoolizeAction.windowTitle.options"), //$NON-NLS-1$ + InvokeMessages.getString("InvokeLibtoolizeAction.message.options.otherOptions"), //$NON-NLS-1$ DEFAULT_OPTION, null); optionDialog.open(); @@ -54,22 +51,20 @@ public class InvokeLibtoolizeAction extends InvokeAction { System.arraycopy(optionsList, 0, argumentList, 0, optionsList.length); - if (container != null) { - String libtoolizeCommand = null; - IProject project = getSelectedContainer().getProject(); - try { - libtoolizeCommand = project.getPersistentProperty(AutotoolsPropertyConstants.LIBTOOLIZE_TOOL); - } catch (CoreException e) { - // do nothing - } - - // If unset, use default system path - if (libtoolizeCommand == null) - libtoolizeCommand = DEFAULT_COMMAND; - - executeConsoleCommand(DEFAULT_COMMAND, libtoolizeCommand, - argumentList, execDir); + String libtoolizeCommand = null; + IProject project = getSelectedContainer().getProject(); + try { + libtoolizeCommand = project.getPersistentProperty(AutotoolsPropertyConstants.LIBTOOLIZE_TOOL); + } catch (CoreException e) { + // do nothing } + + // If unset, use default system path + if (libtoolizeCommand == null) { + libtoolizeCommand = DEFAULT_COMMAND; + } + + executeConsoleCommand(DEFAULT_COMMAND, libtoolizeCommand, argumentList, execDir); } @Override diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/IWorkingCopyManager.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/IWorkingCopyManager.java index a17c1605318..521c8a058d1 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/IWorkingCopyManager.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/IWorkingCopyManager.java @@ -11,7 +11,6 @@ package org.eclipse.cdt.internal.autotools.ui.editors.automake; import org.eclipse.core.runtime.CoreException; - import org.eclipse.ui.IEditorInput; /** diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/StatusTool.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/StatusTool.java index c5e83569f3e..5271fd4dc22 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/StatusTool.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/StatusTool.java @@ -11,7 +11,6 @@ package org.eclipse.cdt.internal.autotools.ui.editors.automake; import org.eclipse.core.runtime.IStatus; - import org.eclipse.jface.dialogs.DialogPage; public class StatusTool { diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsNewCCProjectWizardV2.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsNewCCProjectWizardV2.java index ed5f34d00bb..116343f25db 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsNewCCProjectWizardV2.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsNewCCProjectWizardV2.java @@ -33,20 +33,16 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.PlatformUI; - @SuppressWarnings("deprecation") public class AutotoolsNewCCProjectWizardV2 extends NewCCProjectWizard { - /* (non-Javadoc) - * String constants - */ protected static final String PREFIX = "WizardAutotoolsNewCCProjectV2"; //$NON-NLS-1$ protected static final String OP_ERROR = PREFIX + ".op_error"; //$NON-NLS-1$ protected static final String WZ_TITLE = PREFIX + ".title"; //$NON-NLS-1$ @@ -168,13 +164,13 @@ public class AutotoolsNewCCProjectWizardV2 extends NewCCProjectWizard { protected void addNature(IProgressMonitor monitor) throws CoreException { monitor.beginTask("", 4); monitor.subTask(AutotoolsUIPlugin.getResourceString(MSG_ADD_NATURE)); - ManagedCProjectNature.addManagedNature(newProject, new SubProgressMonitor(monitor, 1)); + ManagedCProjectNature.addManagedNature(newProject, SubMonitor.convert(monitor, 1)); monitor.subTask(AutotoolsUIPlugin.getResourceString(MSG_ADD_BUILDER)); - ManagedCProjectNature.addManagedBuilder(newProject, new SubProgressMonitor(monitor, 1)); + ManagedCProjectNature.addManagedBuilder(newProject, SubMonitor.convert(monitor, 1)); monitor.subTask(AutotoolsUIPlugin.getResourceString(MSG_ADD_NATURE)); - AutotoolsNewProjectNature.addAutotoolsNature(newProject, new SubProgressMonitor(monitor, 1)); + AutotoolsNewProjectNature.addAutotoolsNature(newProject, SubMonitor.convert(monitor, 1)); monitor.subTask(AutotoolsUIPlugin.getResourceString(MSG_ADD_BUILDER)); - AutotoolsNewProjectNature.addAutotoolsBuilder(newProject, new SubProgressMonitor(monitor, 1)); + AutotoolsNewProjectNature.addAutotoolsBuilder(newProject, SubMonitor.convert(monitor, 1)); monitor.done(); } @@ -189,11 +185,11 @@ public class AutotoolsNewCCProjectWizardV2 extends NewCCProjectWizard { } // super.doRun() just creates the project and does not assign a builder to it. - super.doRun(new SubProgressMonitor(monitor, 5)); + super.doRun(SubMonitor.convert(monitor, 5)); // Add the managed build nature and builder try { - addNature(new SubProgressMonitor(monitor, 2)); + addNature(SubMonitor.convert(monitor, 2)); } catch (CoreException e) { AutotoolsUIPlugin.log(e); } @@ -265,7 +261,7 @@ public class AutotoolsNewCCProjectWizardV2 extends NewCCProjectWizard { // Modify the project settings if (newProject != null) { - optionPage.performApply(new SubProgressMonitor(monitor, 2)); + optionPage.performApply(SubMonitor.convert(monitor, 2)); } // Save the build options @@ -284,18 +280,12 @@ public class AutotoolsNewCCProjectWizardV2 extends NewCCProjectWizard { monitor.done(); } - /* (non-Javadoc) - * @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#doRunPrologue(org.eclipse.core.runtime.IProgressMonitor) - */ @Override protected void doRunPrologue(IProgressMonitor monitor) { // Auto-generated method stub } - /* (non-Javadoc) - * @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#doRunEpilogue(org.eclipse.core.runtime.IProgressMonitor) - */ @Override protected void doRunEpilogue(IProgressMonitor monitor) { // Get my initializer to run @@ -318,28 +308,19 @@ public class AutotoolsNewCCProjectWizardV2 extends NewCCProjectWizard { { try { operations[k].run(monitor); - } catch(InvocationTargetException e) { - //TODO: what should we do? - } catch(InterruptedException e) { + } catch (InvocationTargetException | InterruptedException e) { //TODO: what should we do? } } } } - /* (non-Javadoc) - * @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#getProjectID() - */ @Override public String getProjectID() { // return "org.eclipse.cdt.make.core.make"; //$NON-NLS-1$ return ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID; } -// public IProjectType getSelectedProjectType() { -// return projectConfigurationPage.getSelectedProjectType(); -// } - public IConfiguration[] getSelectedConfigurations() { return projectConfigurationPage.getSelectedConfigurations(); } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsNewCProjectWizardV2.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsNewCProjectWizardV2.java index a23714c82f9..227ab1360ab 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsNewCProjectWizardV2.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsNewCProjectWizardV2.java @@ -33,7 +33,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.swt.widgets.Composite; @@ -165,13 +165,13 @@ public class AutotoolsNewCProjectWizardV2 extends NewCProjectWizard { protected void addNature(IProgressMonitor monitor) throws CoreException { monitor.beginTask("", 4); monitor.subTask(AutotoolsUIPlugin.getResourceString(MSG_ADD_NATURE)); - ManagedCProjectNature.addManagedNature(newProject, new SubProgressMonitor(monitor, 1)); + ManagedCProjectNature.addManagedNature(newProject, SubMonitor.convert(monitor, 1)); monitor.subTask(AutotoolsUIPlugin.getResourceString(MSG_ADD_BUILDER)); - ManagedCProjectNature.addManagedBuilder(newProject, new SubProgressMonitor(monitor, 1)); + ManagedCProjectNature.addManagedBuilder(newProject, SubMonitor.convert(monitor, 1)); monitor.subTask(AutotoolsUIPlugin.getResourceString(MSG_ADD_NATURE)); - AutotoolsNewProjectNature.addAutotoolsNature(newProject, new SubProgressMonitor(monitor, 1)); + AutotoolsNewProjectNature.addAutotoolsNature(newProject, SubMonitor.convert(monitor, 1)); monitor.subTask(AutotoolsUIPlugin.getResourceString(MSG_ADD_BUILDER)); - AutotoolsNewProjectNature.addAutotoolsBuilder(newProject, new SubProgressMonitor(monitor, 1)); + AutotoolsNewProjectNature.addAutotoolsBuilder(newProject, SubMonitor.convert(monitor, 1)); monitor.done(); } @@ -186,11 +186,11 @@ public class AutotoolsNewCProjectWizardV2 extends NewCProjectWizard { } // super.doRun() just creates the project and does not assign a builder to it. - super.doRun(new SubProgressMonitor(monitor, 5)); + super.doRun(SubMonitor.convert(monitor, 5)); // Add the managed build nature and builder try { - addNature(new SubProgressMonitor(monitor, 2)); + addNature(SubMonitor.convert(monitor, 2)); } catch (CoreException e) { AutotoolsUIPlugin.log(e); } @@ -251,18 +251,9 @@ public class AutotoolsNewCProjectWizardV2 extends NewCProjectWizard { AutotoolsUIPlugin.log(e); } - // Following is a bit of a hack because changing the project options - // causes a change event to be fired which will try to reindex the project. - // We are in the middle of setting the project indexer which may end up - // being the null indexer. In that case, we don't want the default indexer - // (Fast Indexer) to be invoked. - //IPDOMManager manager = CCorePlugin.getPDOMManager(); - //ICProject cproject = CoreModel.getDefault().create(newProject); - //manager.setIndexerId(cproject, ConvertToAutotoolsProjectWizard.NULL_INDEXER_ID); - // Modify the project settings if (newProject != null) { - optionPage.performApply(new SubProgressMonitor(monitor, 2)); + optionPage.performApply(SubMonitor.convert(monitor, 2)); } // Save the build options @@ -281,18 +272,12 @@ public class AutotoolsNewCProjectWizardV2 extends NewCProjectWizard { monitor.done(); } - /* (non-Javadoc) - * @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#doRunPrologue(org.eclipse.core.runtime.IProgressMonitor) - */ @Override protected void doRunPrologue(IProgressMonitor monitor) { // Auto-generated method stub } - /* (non-Javadoc) - * @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#doRunEpilogue(org.eclipse.core.runtime.IProgressMonitor) - */ @Override protected void doRunEpilogue(IProgressMonitor monitor) { // Get my initializer to run @@ -315,27 +300,18 @@ public class AutotoolsNewCProjectWizardV2 extends NewCProjectWizard { { try { operations[k].run(monitor); - } catch(InvocationTargetException e) { - //TODO: what should we do? - } catch(InterruptedException e) { + } catch (InvocationTargetException | InterruptedException e) { //TODO: what should we do? } } } } - /* (non-Javadoc) - * @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#getProjectID() - */ @Override public String getProjectID() { // return "org.eclipse.cdt.make.core.make"; //$NON-NLS-1$ return ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID; } - -// public IProjectType getSelectedProjectType() { -// return projectConfigurationPage.getSelectedProjectType(); -// } public IConfiguration[] getSelectedConfigurations() { return projectConfigurationPage.getSelectedConfigurations(); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsProjectImportWizard.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsProjectImportWizard.java index b49cf2de0cf..357c153d63a 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsProjectImportWizard.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsProjectImportWizard.java @@ -38,7 +38,7 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IWorkbench; @@ -121,9 +121,9 @@ public class AutotoolsProjectImportWizard extends NewMakeProjFromExisting { project, monitor); // C++ natures - if (isCPP) - CCProjectNature.addCCNature(project, - new SubProgressMonitor(monitor, 1)); + if (isCPP) { + CCProjectNature.addCCNature(project, SubMonitor.convert(monitor, 1)); + } // Set up build information ICProjectDescriptionManager pdMgr = CoreModel.getDefault() diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConvertToAutotoolsProjectWizard.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConvertToAutotoolsProjectWizard.java index 965dfbb1189..c4ce1ab60ca 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConvertToAutotoolsProjectWizard.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConvertToAutotoolsProjectWizard.java @@ -23,7 +23,7 @@ import org.eclipse.cdt.ui.wizards.conversion.ConversionWizard; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.wizard.Wizard; @@ -173,7 +173,7 @@ public class ConvertToAutotoolsProjectWizard extends ConversionWizard { protected void doRun(IProgressMonitor monitor) throws CoreException { monitor.beginTask(AutotoolsUIPlugin.getResourceString("WizardAutotoolsProjectConversion.monitor.convertingToMakeProject"), 2); //$NON-NLS-1$ try { - super.doRun(new SubProgressMonitor(monitor, 5)); + super.doRun(SubMonitor.convert(monitor, 5)); } finally { monitor.done(); } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConvertToAutotoolsProjectWizardPage.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConvertToAutotoolsProjectWizardPage.java index f03673c2a5e..d5238778c3c 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConvertToAutotoolsProjectWizardPage.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConvertToAutotoolsProjectWizardPage.java @@ -29,7 +29,7 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard; @@ -117,7 +117,7 @@ public class ConvertToAutotoolsProjectWizardPage extends ConvertProjectWizardPag IConfiguration defaultCfg = null; Boolean convertingNewAutotoolsProject = false; try { - super.convertProject(project, new SubProgressMonitor(monitor, 1), projectID); + super.convertProject(project, SubMonitor.convert(monitor, 1), projectID); // Bug 289834 - Converting C Autotools project to C++ loses configurations if (project.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)) { convertingNewAutotoolsProject = true; // set this for finally clause @@ -125,13 +125,12 @@ public class ConvertToAutotoolsProjectWizardPage extends ConvertProjectWizardPag } // Otherwise, we must scrap existing configurations as they will have tool settings we cannot use monitor.subTask(AutotoolsUIPlugin.getResourceString(MSG_ADD_NATURE)); - ManagedCProjectNature.addManagedNature(project, new SubProgressMonitor(monitor, 1)); - AutotoolsNewProjectNature.addAutotoolsNature(project, new SubProgressMonitor(monitor, 1)); + ManagedCProjectNature.addManagedNature(project, SubMonitor.convert(monitor, 1)); + AutotoolsNewProjectNature.addAutotoolsNature(project, SubMonitor.convert(monitor, 1)); // We need to remove any old Autotools nature, if one exists. - AutotoolsNewProjectNature.removeOldAutotoolsNature(project, new SubProgressMonitor(monitor, 1)); + AutotoolsNewProjectNature.removeOldAutotoolsNature(project, SubMonitor.convert(monitor, 1)); monitor.subTask(AutotoolsUIPlugin.getResourceString(MSG_ADD_BUILDER)); -// ManagedCProjectNature.addManagedBuilder(project, new SubProgressMonitor(monitor, 1)); - AutotoolsNewProjectNature.addAutotoolsBuilder(project, new SubProgressMonitor(monitor,1)); + AutotoolsNewProjectNature.addAutotoolsBuilder(project, SubMonitor.convert(monitor, 1)); // FIXME: Default scanner property: make -w - eventually we want to use Make core's build scanner project.setPersistentProperty(AutotoolsPropertyConstants.SCANNER_USE_MAKE_W, AutotoolsPropertyConstants.TRUE); // Specify false for override in next call as override can cause the method to throw an @@ -175,31 +174,11 @@ public class ConvertToAutotoolsProjectWizardPage extends ConvertProjectWizardPag AutotoolsUIPlugin.log(e); } - // Following is a bit of a hack because changing the project options - // causes a change event to be fired which will try to reindex the project. - // We are in the middle of setting the project indexer which may end up - // being the null indexer. In that case, we don't want the default indexer - // (Fast Indexer) to be invoked. - //IIndexManager manager = CCorePlugin.getIndexManager(); - //ICProject cproject = CoreModel.getDefault().create(project); - //manager.setIndexerId(cproject, ConvertToAutotoolsProjectWizard.NULL_INDEXER_ID); - // Modify the project settings if (project != null) { - applyOptions(project, new SubProgressMonitor(monitor, 2)); + applyOptions(project, SubMonitor.convert(monitor, 2)); } -// Set the ScannerInfoProvider. We must do this after -// applying the options because changing the ScannerInfoProvider -// is considered a change to the project and a reindex will -// occur. One of the options being applied above is the indexer -// selected by the user. Thus, we wait until now. -// try { -// AutotoolsUIPlugin.setScannerInfoProvider(project); -// } catch (CoreException e) { -// ManagedBuilderUIPlugin.log(e); -// } - // Save the build options monitor.subTask(AutotoolsUIPlugin.getResourceString(MSG_SAVE)); if (info != null) { diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ReferenceBlock.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ReferenceBlock.java index f53a8d6aa81..3cf542c9813 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ReferenceBlock.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ReferenceBlock.java @@ -22,7 +22,7 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.jface.viewers.CheckboxTableViewer; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.swt.SWT; @@ -177,7 +177,7 @@ public class ReferenceBlock extends AbstractCOptionPage { try { IProjectDescription description = project.getDescription(); description.setReferencedProjects(refProjects); - project.setDescription(description, new SubProgressMonitor(monitor, 1)); + project.setDescription(description, SubMonitor.convert(monitor, 1)); } catch (CoreException e) { } }