1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-29 11:55:40 +02:00

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 <akurtako@redhat.com>
This commit is contained in:
Alexander Kurtakov 2015-10-30 10:41:10 +02:00 committed by Gerrit Code Review @ Eclipse.org
parent 7cc28b5400
commit ae53f82634
16 changed files with 138 additions and 226 deletions

View file

@ -14,8 +14,8 @@ package org.eclipse.cdt.internal.autotools.ui;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.Reader; import java.io.Reader;
import java.text.BreakIterator; import java.text.BreakIterator;
import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.GC;
/* /*

View file

@ -28,8 +28,9 @@ public class InvokeAclocalAction extends InvokeAction {
public void run(IAction action) { public void run(IAction action) {
IContainer container = getSelectedContainer(); IContainer container = getSelectedContainer();
if (container == null) if (container == null) {
return; return;
}
IPath execDir = getExecDir(container); IPath execDir = getExecDir(container);
String cwd = InvokeMessages.getString("CWD") + getCWD(container); //$NON-NLS-1$ String cwd = InvokeMessages.getString("CWD") + getCWD(container); //$NON-NLS-1$
@ -66,36 +67,33 @@ public class InvokeAclocalAction extends InvokeAction {
} }
int iOption = 0; int iOption = 0;
if (targetList.length > 0) if (targetList.length > 0) {
iOption = 1; iOption = 1;
}
String[] argumentList = new String[targetList.length String[] argumentList = new String[targetList.length + optionsList.length + iOption];
+ optionsList.length + iOption];
System.arraycopy(optionsList, 0, argumentList, 0, optionsList.length); System.arraycopy(optionsList, 0, argumentList, 0, optionsList.length);
if (iOption == 1) if (iOption == 1)
argumentList[optionsList.length] = "-I"; //$NON-NLS-1$ argumentList[optionsList.length] = "-I"; //$NON-NLS-1$
System.arraycopy(targetList, 0, argumentList, optionsList.length System.arraycopy(targetList, 0, argumentList, optionsList.length + iOption, targetList.length);
+ iOption, targetList.length);
if (container != null) { String aclocalCommand = null;
String aclocalCommand = null; IProject project = getSelectedContainer().getProject();
IProject project = getSelectedContainer().getProject(); try {
try { aclocalCommand = project.getPersistentProperty(AutotoolsPropertyConstants.ACLOCAL_TOOL);
aclocalCommand = project.getPersistentProperty(AutotoolsPropertyConstants.ACLOCAL_TOOL); } catch (CoreException e) {
} catch (CoreException e) { // do nothing
// do nothing
}
// If unset, use default system path
if (aclocalCommand == null)
aclocalCommand = DEFAULT_COMMAND;
executeConsoleCommand(DEFAULT_COMMAND, aclocalCommand,
argumentList, execDir);
} }
// If unset, use default system path
if (aclocalCommand == null) {
aclocalCommand = DEFAULT_COMMAND;
}
executeConsoleCommand(DEFAULT_COMMAND, aclocalCommand, argumentList, execDir);
} }
@Override @Override

View file

@ -43,7 +43,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status; 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.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.InputDialog; import org.eclipse.jface.dialogs.InputDialog;
@ -414,8 +414,8 @@ public abstract class InvokeAction extends AbstractTargetAction {
} catch (IOException e1) { } catch (IOException e1) {
} }
if (launcher.waitAndRead(stdout, stderr, new SubProgressMonitor(monitor1, if (launcher.waitAndRead(stdout, stderr,
IProgressMonitor.UNKNOWN)) != ICommandLauncher.OK) { SubMonitor.convert(monitor1)) != ICommandLauncher.OK) {
errMsg = launcher.getErrorMessage(); errMsg = launcher.getErrorMessage();
} }

View file

@ -20,9 +20,6 @@ import org.eclipse.jface.action.IAction;
/** /**
* Class responsible for invoking autoconf. * Class responsible for invoking autoconf.
*
* @author klee
*
*/ */
public class InvokeAutoconfAction extends InvokeAction { public class InvokeAutoconfAction extends InvokeAction {
@ -35,21 +32,19 @@ public class InvokeAutoconfAction extends InvokeAction {
IPath execDir = getExecDir(container); IPath execDir = getExecDir(container);
if (container != null) { IProject project = container.getProject();
IProject project = container.getProject(); String autoconfCommand = null;
String autoconfCommand = null; try {
try { autoconfCommand = project.getPersistentProperty(AutotoolsPropertyConstants.AUTOCONF_TOOL);
autoconfCommand = project.getPersistentProperty(AutotoolsPropertyConstants.AUTOCONF_TOOL); } catch (CoreException e) {
} catch (CoreException e) { // do nothing
// do nothing
}
// If unset for the project, default to system path
if (autoconfCommand == null)
autoconfCommand = DEFAULT_COMMAND;
executeConsoleCommand(DEFAULT_COMMAND, autoconfCommand, new String[]{}, execDir);
} }
// If unset for the project, default to system path
if (autoconfCommand == null) {
autoconfCommand = DEFAULT_COMMAND;
}
executeConsoleCommand(DEFAULT_COMMAND, autoconfCommand, new String[] {}, execDir);
} }

View file

@ -29,19 +29,15 @@ public class InvokeAutoheaderAction extends InvokeAction {
public void run(IAction action) { public void run(IAction action) {
IContainer container = getSelectedContainer(); IContainer container = getSelectedContainer();
if (container == null) if (container == null) {
return; return;
}
IPath execDir = getExecDir(container); IPath execDir = getExecDir(container);
String cwd = InvokeMessages.getString("CWD") + getCWD(container); //$NON-NLS-1$ String cwd = InvokeMessages.getString("CWD") + getCWD(container); //$NON-NLS-1$
InputDialog optionDialog = new SingleInputDialog( InputDialog optionDialog = new SingleInputDialog(new Shell(), cwd,
new Shell(), InvokeMessages.getString("InvokeAutoheaderAction.windowTitle.options"), //$NON-NLS-1$
cwd, InvokeMessages.getString("InvokeAutoheaderAction.message.options.otherOptions"), //$NON-NLS-1$
InvokeMessages
.getString("InvokeAutoheaderAction.windowTitle.options"), //$NON-NLS-1$
InvokeMessages
.getString("InvokeAutoheaderAction.message.options.otherOptions"), //$NON-NLS-1$
DEFAULT_OPTION, null); DEFAULT_OPTION, null);
optionDialog.open(); optionDialog.open();
@ -54,23 +50,21 @@ public class InvokeAutoheaderAction extends InvokeAction {
System.arraycopy(optionsList, 0, argumentList, 0, optionsList.length); System.arraycopy(optionsList, 0, argumentList, 0, optionsList.length);
if (container != null) { String autoheaderCommand = null;
String autoheaderCommand = null; IProject project = getSelectedContainer().getProject();
IProject project = getSelectedContainer().getProject(); try {
try { autoheaderCommand = project.getPersistentProperty(AutotoolsPropertyConstants.AUTOHEADER_TOOL);
autoheaderCommand = project.getPersistentProperty(AutotoolsPropertyConstants.AUTOHEADER_TOOL); } catch (CoreException e) {
} catch (CoreException e) { // do nothing
// do nothing
}
// If unset, use default system path
if (autoheaderCommand == null)
autoheaderCommand = DEFAULT_COMMAND;
executeConsoleCommand(DEFAULT_COMMAND, autoheaderCommand,
argumentList, execDir);
} }
// If unset, use default system path
if (autoheaderCommand == null) {
autoheaderCommand = DEFAULT_COMMAND;
}
executeConsoleCommand(DEFAULT_COMMAND, autoheaderCommand, argumentList, execDir);
} }
@Override @Override

View file

@ -34,18 +34,17 @@ public class InvokeAutomakeAction extends InvokeAction {
public void run(IAction action) { public void run(IAction action) {
IContainer container = getSelectedContainer(); IContainer container = getSelectedContainer();
if (container == null) if (container == null) {
return; return;
}
IPath execDir = getExecDir(container); IPath execDir = getExecDir(container);
String cwd = InvokeMessages.getString("CWD") + getCWD(container); //$NON-NLS-1$ String cwd = InvokeMessages.getString("CWD") + getCWD(container); //$NON-NLS-1$
;
TwoInputDialog optionDialog = new TwoInputDialog(new Shell(), cwd, TwoInputDialog optionDialog = new TwoInputDialog(new Shell(), cwd,
InvokeMessages InvokeMessages.getString("InvokeAutomakeAction.windowTitle.options"), //$NON-NLS-1$
.getString("InvokeAutomakeAction.windowTitle.options"), //$NON-NLS-1$ InvokeMessages.getString("InvokeAutomakeAction.message.options.otherOptions"), InvokeMessages //$NON-NLS-1$
InvokeMessages .getString("InvokeAutomakeAction.message.options.makeTargets"), //$NON-NLS-1$
.getString("InvokeAutomakeAction.message.options.otherOptions"),InvokeMessages //$NON-NLS-1$ DEFAULT_OPTION, null);
.getString("InvokeAutomakeAction.message.options.makeTargets"), DEFAULT_OPTION, null); //$NON-NLS-1$
optionDialog.open(); optionDialog.open();
@ -74,22 +73,20 @@ InvokeMessages
System.arraycopy(targetList, 0, argumentList, optionsList.length, System.arraycopy(targetList, 0, argumentList, optionsList.length,
targetList.length); targetList.length);
if (container != null) { IProject project = container.getProject();
IProject project = container.getProject(); String automakeCommand = null;
String automakeCommand = null; try {
try { automakeCommand = project.getPersistentProperty(AutotoolsPropertyConstants.AUTOMAKE_TOOL);
automakeCommand = project.getPersistentProperty(AutotoolsPropertyConstants.AUTOMAKE_TOOL); } catch (CoreException e) {
} catch (CoreException e) { // do nothing
// 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);
} }
// 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 @Override

View file

@ -29,8 +29,9 @@ public class InvokeAutoreconfAction extends InvokeAction {
public void run(IAction action) { public void run(IAction action) {
IContainer container = getSelectedContainer(); IContainer container = getSelectedContainer();
if (container == null) if (container == null) {
return; return;
}
IPath execDir = getExecDir(container); IPath execDir = getExecDir(container);
String cwd = InvokeMessages.getString("CWD") + getCWD(container); //$NON-NLS-1$ 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); System.arraycopy(optionsList, 0, argumentList, 0, optionsList.length);
if (container != null) { String autoreconfCommand = null;
String autoreconfCommand = null; IProject project = getSelectedContainer().getProject();
IProject project = getSelectedContainer().getProject(); try {
try { autoreconfCommand = project.getPersistentProperty(AutotoolsPropertyConstants.AUTORECONF_TOOL);
autoreconfCommand = project.getPersistentProperty(AutotoolsPropertyConstants.AUTORECONF_TOOL); } catch (CoreException e) {
} catch (CoreException e) { // do nothing
// do nothing
}
// If unset, use default system path
if (autoreconfCommand == null)
autoreconfCommand = DEFAULT_COMMAND;
executeConsoleCommand(DEFAULT_COMMAND, autoreconfCommand,
argumentList, execDir);
} }
// If unset, use default system path
if (autoreconfCommand == null) {
autoreconfCommand = DEFAULT_COMMAND;
}
executeConsoleCommand(DEFAULT_COMMAND, autoreconfCommand, argumentList, execDir);
} }
@Override @Override

View file

@ -29,19 +29,16 @@ public class InvokeLibtoolizeAction extends InvokeAction {
public void run(IAction action) { public void run(IAction action) {
IContainer container = getSelectedContainer(); IContainer container = getSelectedContainer();
if (container == null) if (container == null) {
return; return;
}
IPath execDir = getExecDir(container); IPath execDir = getExecDir(container);
String cwd = InvokeMessages.getString("CWD") + getCWD(container); //$NON-NLS-1$ String cwd = InvokeMessages.getString("CWD") + getCWD(container); //$NON-NLS-1$
InputDialog optionDialog = new SingleInputDialog( InputDialog optionDialog = new SingleInputDialog(new Shell(), cwd,
new Shell(), InvokeMessages.getString("InvokeLibtoolizeAction.windowTitle.options"), //$NON-NLS-1$
cwd, InvokeMessages.getString("InvokeLibtoolizeAction.message.options.otherOptions"), //$NON-NLS-1$
InvokeMessages
.getString("InvokeLibtoolizeAction.windowTitle.options"), //$NON-NLS-1$
InvokeMessages
.getString("InvokeLibtoolizeAction.message.options.otherOptions"), //$NON-NLS-1$
DEFAULT_OPTION, null); DEFAULT_OPTION, null);
optionDialog.open(); optionDialog.open();
@ -54,22 +51,20 @@ public class InvokeLibtoolizeAction extends InvokeAction {
System.arraycopy(optionsList, 0, argumentList, 0, optionsList.length); System.arraycopy(optionsList, 0, argumentList, 0, optionsList.length);
if (container != null) { String libtoolizeCommand = null;
String libtoolizeCommand = null; IProject project = getSelectedContainer().getProject();
IProject project = getSelectedContainer().getProject(); try {
try { libtoolizeCommand = project.getPersistentProperty(AutotoolsPropertyConstants.LIBTOOLIZE_TOOL);
libtoolizeCommand = project.getPersistentProperty(AutotoolsPropertyConstants.LIBTOOLIZE_TOOL); } catch (CoreException e) {
} catch (CoreException e) { // do nothing
// do nothing
}
// If unset, use default system path
if (libtoolizeCommand == null)
libtoolizeCommand = DEFAULT_COMMAND;
executeConsoleCommand(DEFAULT_COMMAND, libtoolizeCommand,
argumentList, execDir);
} }
// If unset, use default system path
if (libtoolizeCommand == null) {
libtoolizeCommand = DEFAULT_COMMAND;
}
executeConsoleCommand(DEFAULT_COMMAND, libtoolizeCommand, argumentList, execDir);
} }
@Override @Override

View file

@ -11,7 +11,6 @@
package org.eclipse.cdt.internal.autotools.ui.editors.automake; package org.eclipse.cdt.internal.autotools.ui.editors.automake;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorInput;
/** /**

View file

@ -11,7 +11,6 @@
package org.eclipse.cdt.internal.autotools.ui.editors.automake; package org.eclipse.cdt.internal.autotools.ui.editors.automake;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.DialogPage; import org.eclipse.jface.dialogs.DialogPage;
public class StatusTool { public class StatusTool {

View file

@ -33,20 +33,16 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor; 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.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class AutotoolsNewCCProjectWizardV2 extends NewCCProjectWizard { public class AutotoolsNewCCProjectWizardV2 extends NewCCProjectWizard {
/* (non-Javadoc)
* String constants
*/
protected static final String PREFIX = "WizardAutotoolsNewCCProjectV2"; //$NON-NLS-1$ 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 OP_ERROR = PREFIX + ".op_error"; //$NON-NLS-1$
protected static final String WZ_TITLE = PREFIX + ".title"; //$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 { protected void addNature(IProgressMonitor monitor) throws CoreException {
monitor.beginTask("", 4); monitor.beginTask("", 4);
monitor.subTask(AutotoolsUIPlugin.getResourceString(MSG_ADD_NATURE)); 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)); 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)); 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)); monitor.subTask(AutotoolsUIPlugin.getResourceString(MSG_ADD_BUILDER));
AutotoolsNewProjectNature.addAutotoolsBuilder(newProject, new SubProgressMonitor(monitor, 1)); AutotoolsNewProjectNature.addAutotoolsBuilder(newProject, SubMonitor.convert(monitor, 1));
monitor.done(); 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() 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 // Add the managed build nature and builder
try { try {
addNature(new SubProgressMonitor(monitor, 2)); addNature(SubMonitor.convert(monitor, 2));
} catch (CoreException e) { } catch (CoreException e) {
AutotoolsUIPlugin.log(e); AutotoolsUIPlugin.log(e);
} }
@ -265,7 +261,7 @@ public class AutotoolsNewCCProjectWizardV2 extends NewCCProjectWizard {
// Modify the project settings // Modify the project settings
if (newProject != null) { if (newProject != null) {
optionPage.performApply(new SubProgressMonitor(monitor, 2)); optionPage.performApply(SubMonitor.convert(monitor, 2));
} }
// Save the build options // Save the build options
@ -284,18 +280,12 @@ public class AutotoolsNewCCProjectWizardV2 extends NewCCProjectWizard {
monitor.done(); monitor.done();
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#doRunPrologue(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override @Override
protected void doRunPrologue(IProgressMonitor monitor) { protected void doRunPrologue(IProgressMonitor monitor) {
// Auto-generated method stub // Auto-generated method stub
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#doRunEpilogue(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override @Override
protected void doRunEpilogue(IProgressMonitor monitor) { protected void doRunEpilogue(IProgressMonitor monitor) {
// Get my initializer to run // Get my initializer to run
@ -318,28 +308,19 @@ public class AutotoolsNewCCProjectWizardV2 extends NewCCProjectWizard {
{ {
try { try {
operations[k].run(monitor); operations[k].run(monitor);
} catch(InvocationTargetException e) { } catch (InvocationTargetException | InterruptedException e) {
//TODO: what should we do?
} catch(InterruptedException e) {
//TODO: what should we do? //TODO: what should we do?
} }
} }
} }
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#getProjectID()
*/
@Override @Override
public String getProjectID() { public String getProjectID() {
// return "org.eclipse.cdt.make.core.make"; //$NON-NLS-1$ // return "org.eclipse.cdt.make.core.make"; //$NON-NLS-1$
return ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID; return ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID;
} }
// public IProjectType getSelectedProjectType() {
// return projectConfigurationPage.getSelectedProjectType();
// }
public IConfiguration[] getSelectedConfigurations() { public IConfiguration[] getSelectedConfigurations() {
return projectConfigurationPage.getSelectedConfigurations(); return projectConfigurationPage.getSelectedConfigurations();
} }

View file

@ -33,7 +33,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor; 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.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
@ -165,13 +165,13 @@ public class AutotoolsNewCProjectWizardV2 extends NewCProjectWizard {
protected void addNature(IProgressMonitor monitor) throws CoreException { protected void addNature(IProgressMonitor monitor) throws CoreException {
monitor.beginTask("", 4); monitor.beginTask("", 4);
monitor.subTask(AutotoolsUIPlugin.getResourceString(MSG_ADD_NATURE)); 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)); 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)); 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)); monitor.subTask(AutotoolsUIPlugin.getResourceString(MSG_ADD_BUILDER));
AutotoolsNewProjectNature.addAutotoolsBuilder(newProject, new SubProgressMonitor(monitor, 1)); AutotoolsNewProjectNature.addAutotoolsBuilder(newProject, SubMonitor.convert(monitor, 1));
monitor.done(); 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() 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 // Add the managed build nature and builder
try { try {
addNature(new SubProgressMonitor(monitor, 2)); addNature(SubMonitor.convert(monitor, 2));
} catch (CoreException e) { } catch (CoreException e) {
AutotoolsUIPlugin.log(e); AutotoolsUIPlugin.log(e);
} }
@ -251,18 +251,9 @@ public class AutotoolsNewCProjectWizardV2 extends NewCProjectWizard {
AutotoolsUIPlugin.log(e); 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 // Modify the project settings
if (newProject != null) { if (newProject != null) {
optionPage.performApply(new SubProgressMonitor(monitor, 2)); optionPage.performApply(SubMonitor.convert(monitor, 2));
} }
// Save the build options // Save the build options
@ -281,18 +272,12 @@ public class AutotoolsNewCProjectWizardV2 extends NewCProjectWizard {
monitor.done(); monitor.done();
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#doRunPrologue(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override @Override
protected void doRunPrologue(IProgressMonitor monitor) { protected void doRunPrologue(IProgressMonitor monitor) {
// Auto-generated method stub // Auto-generated method stub
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#doRunEpilogue(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override @Override
protected void doRunEpilogue(IProgressMonitor monitor) { protected void doRunEpilogue(IProgressMonitor monitor) {
// Get my initializer to run // Get my initializer to run
@ -315,27 +300,18 @@ public class AutotoolsNewCProjectWizardV2 extends NewCProjectWizard {
{ {
try { try {
operations[k].run(monitor); operations[k].run(monitor);
} catch(InvocationTargetException e) { } catch (InvocationTargetException | InterruptedException e) {
//TODO: what should we do?
} catch(InterruptedException e) {
//TODO: what should we do? //TODO: what should we do?
} }
} }
} }
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#getProjectID()
*/
@Override @Override
public String getProjectID() { public String getProjectID() {
// return "org.eclipse.cdt.make.core.make"; //$NON-NLS-1$ // return "org.eclipse.cdt.make.core.make"; //$NON-NLS-1$
return ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID; return ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID;
} }
// public IProjectType getSelectedProjectType() {
// return projectConfigurationPage.getSelectedProjectType();
// }
public IConfiguration[] getSelectedConfigurations() { public IConfiguration[] getSelectedConfigurations() {
return projectConfigurationPage.getSelectedConfigurations(); return projectConfigurationPage.getSelectedConfigurations();

View file

@ -38,7 +38,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path; 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.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbench;
@ -121,9 +121,9 @@ public class AutotoolsProjectImportWizard extends NewMakeProjFromExisting {
project, monitor); project, monitor);
// C++ natures // C++ natures
if (isCPP) if (isCPP) {
CCProjectNature.addCCNature(project, CCProjectNature.addCCNature(project, SubMonitor.convert(monitor, 1));
new SubProgressMonitor(monitor, 1)); }
// Set up build information // Set up build information
ICProjectDescriptionManager pdMgr = CoreModel.getDefault() ICProjectDescriptionManager pdMgr = CoreModel.getDefault()

View file

@ -23,7 +23,7 @@ import org.eclipse.cdt.ui.wizards.conversion.ConversionWizard;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; 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.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.Wizard; import org.eclipse.jface.wizard.Wizard;
@ -173,7 +173,7 @@ public class ConvertToAutotoolsProjectWizard extends ConversionWizard {
protected void doRun(IProgressMonitor monitor) throws CoreException { protected void doRun(IProgressMonitor monitor) throws CoreException {
monitor.beginTask(AutotoolsUIPlugin.getResourceString("WizardAutotoolsProjectConversion.monitor.convertingToMakeProject"), 2); //$NON-NLS-1$ monitor.beginTask(AutotoolsUIPlugin.getResourceString("WizardAutotoolsProjectConversion.monitor.convertingToMakeProject"), 2); //$NON-NLS-1$
try { try {
super.doRun(new SubProgressMonitor(monitor, 5)); super.doRun(SubMonitor.convert(monitor, 5));
} finally { } finally {
monitor.done(); monitor.done();
} }

View file

@ -29,7 +29,7 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; 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.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard; import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
@ -117,7 +117,7 @@ public class ConvertToAutotoolsProjectWizardPage extends ConvertProjectWizardPag
IConfiguration defaultCfg = null; IConfiguration defaultCfg = null;
Boolean convertingNewAutotoolsProject = false; Boolean convertingNewAutotoolsProject = false;
try { 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 // Bug 289834 - Converting C Autotools project to C++ loses configurations
if (project.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)) { if (project.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)) {
convertingNewAutotoolsProject = true; // set this for finally clause 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 // Otherwise, we must scrap existing configurations as they will have tool settings we cannot use
monitor.subTask(AutotoolsUIPlugin.getResourceString(MSG_ADD_NATURE)); monitor.subTask(AutotoolsUIPlugin.getResourceString(MSG_ADD_NATURE));
ManagedCProjectNature.addManagedNature(project, new SubProgressMonitor(monitor, 1)); ManagedCProjectNature.addManagedNature(project, SubMonitor.convert(monitor, 1));
AutotoolsNewProjectNature.addAutotoolsNature(project, new SubProgressMonitor(monitor, 1)); AutotoolsNewProjectNature.addAutotoolsNature(project, SubMonitor.convert(monitor, 1));
// We need to remove any old Autotools nature, if one exists. // 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)); monitor.subTask(AutotoolsUIPlugin.getResourceString(MSG_ADD_BUILDER));
// ManagedCProjectNature.addManagedBuilder(project, new SubProgressMonitor(monitor, 1)); AutotoolsNewProjectNature.addAutotoolsBuilder(project, SubMonitor.convert(monitor, 1));
AutotoolsNewProjectNature.addAutotoolsBuilder(project, new SubProgressMonitor(monitor,1));
// FIXME: Default scanner property: make -w - eventually we want to use Make core's build scanner // 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); 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 // 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); 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 // Modify the project settings
if (project != null) { 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 // Save the build options
monitor.subTask(AutotoolsUIPlugin.getResourceString(MSG_SAVE)); monitor.subTask(AutotoolsUIPlugin.getResourceString(MSG_SAVE));
if (info != null) { if (info != null) {

View file

@ -22,7 +22,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor; 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.CheckboxTableViewer;
import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
@ -177,7 +177,7 @@ public class ReferenceBlock extends AbstractCOptionPage {
try { try {
IProjectDescription description = project.getDescription(); IProjectDescription description = project.getDescription();
description.setReferencedProjects(refProjects); description.setReferencedProjects(refProjects);
project.setDescription(description, new SubProgressMonitor(monitor, 1)); project.setDescription(description, SubMonitor.convert(monitor, 1));
} catch (CoreException e) { } catch (CoreException e) {
} }
} }