mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 01:45:33 +02:00
Bug 558474 - CleanUp deprecated methods in org.eclipse.cdt.ui
Reworked SubMonitors (Part2) Fixed percentage counting Removed explicit cancellation checks. Change-Id: Ibd9ef2664885746ab9ac2be556ac5effc994a512 Signed-off-by: Sergey Kovalchuk <sergei.kovalchuk@arsysop.ru>
This commit is contained in:
parent
55e08c0dfa
commit
b74f56878c
3 changed files with 34 additions and 57 deletions
|
@ -61,6 +61,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.jface.wizard.IWizard;
|
||||
import org.eclipse.jface.wizard.IWizardPage;
|
||||
|
@ -576,15 +577,11 @@ public class MBSWizardHandler extends CWizardHandler {
|
|||
@Override
|
||||
public void createProject(IProject project, boolean defaults, boolean onFinish, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
try {
|
||||
monitor.beginTask("", 100); //$NON-NLS-1$
|
||||
setProjectDescription(project, defaults, onFinish, monitor);
|
||||
doTemplatesPostProcess(project);
|
||||
doCustom(project);
|
||||
monitor.worked(30);
|
||||
} finally {
|
||||
monitor.done();
|
||||
}
|
||||
SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
|
||||
setProjectDescription(project, defaults, onFinish, subMonitor.split(70));
|
||||
doTemplatesPostProcess(project);
|
||||
doCustom(project);
|
||||
subMonitor.worked(30);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -594,10 +591,11 @@ public class MBSWizardHandler extends CWizardHandler {
|
|||
|
||||
private void setProjectDescription(IProject project, boolean defaults, boolean onFinish, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
SubMonitor subMonitor = SubMonitor.convert(monitor, 3);
|
||||
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
|
||||
ICProjectDescription des = mngr.createProjectDescription(project, false, !onFinish);
|
||||
ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
|
||||
monitor.worked(10);
|
||||
subMonitor.worked(1);
|
||||
cfgs = getCfgItems(false);
|
||||
if (cfgs == null || cfgs.length == 0)
|
||||
cfgs = CDTConfigWizardPage.getDefaultCfgs(this);
|
||||
|
@ -609,15 +607,15 @@ public class MBSWizardHandler extends CWizardHandler {
|
|||
Configuration cf = (Configuration) cfgs[0].getConfiguration();
|
||||
ManagedProject mProj = new ManagedProject(project, cf.getProjectType());
|
||||
info.setManagedProject(mProj);
|
||||
monitor.worked(10);
|
||||
|
||||
cfgs = CfgHolder.unique(cfgs);
|
||||
cfgs = CfgHolder.reorder(cfgs);
|
||||
|
||||
ICConfigurationDescription cfgDebug = null;
|
||||
ICConfigurationDescription cfgFirst = null;
|
||||
subMonitor.worked(1);
|
||||
|
||||
int work = 50 / cfgs.length;
|
||||
|
||||
SubMonitor cfgMonitor = SubMonitor.convert(subMonitor.split(1), cfgs.length);
|
||||
for (CfgHolder cfg : cfgs) {
|
||||
cf = (Configuration) cfg.getConfiguration();
|
||||
String id = ManagedBuildManager.calculateChildId(cf.getId(), null);
|
||||
|
@ -640,7 +638,7 @@ public class MBSWizardHandler extends CWizardHandler {
|
|||
cfgDebug = cfgDes;
|
||||
if (cfgFirst == null) // select at least first configuration
|
||||
cfgFirst = cfgDes;
|
||||
monitor.worked(work);
|
||||
cfgMonitor.worked(1);
|
||||
}
|
||||
mngr.setProjectDescription(project, des);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,7 @@ import org.eclipse.cdt.core.CProjectNature;
|
|||
import org.eclipse.cdt.internal.ui.newui.Messages;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
|
||||
/**
|
||||
* The wizard to create new MBS C++ Project.
|
||||
|
@ -39,17 +38,11 @@ public class CCProjectWizard extends CDTCommonProjectWizard {
|
|||
|
||||
@Override
|
||||
protected IProject continueCreation(IProject prj) {
|
||||
if (continueCreationMonitor == null) {
|
||||
continueCreationMonitor = new NullProgressMonitor();
|
||||
}
|
||||
|
||||
SubMonitor subMonitor = SubMonitor.convert(continueCreationMonitor, Messages.CCProjectWizard_0, 2);
|
||||
try {
|
||||
continueCreationMonitor.beginTask(Messages.CCProjectWizard_0, 2);
|
||||
CProjectNature.addCNature(prj, new SubProgressMonitor(continueCreationMonitor, 1));
|
||||
CCProjectNature.addCCNature(prj, new SubProgressMonitor(continueCreationMonitor, 1));
|
||||
CProjectNature.addCNature(prj, subMonitor.split(1));
|
||||
CCProjectNature.addCCNature(prj, subMonitor.split(1));
|
||||
} catch (CoreException e) {
|
||||
} finally {
|
||||
continueCreationMonitor.done();
|
||||
}
|
||||
return prj;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ import org.eclipse.core.runtime.IExecutableExtension;
|
|||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
import org.eclipse.core.runtime.content.IContentType;
|
||||
import org.eclipse.core.runtime.content.IContentTypeManager;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
|
@ -242,25 +242,18 @@ public abstract class CDTCommonProjectWizard extends BasicNewResourceWizard
|
|||
final Exception except[] = new Exception[1];
|
||||
getShell().getDisplay().syncExec(() -> {
|
||||
IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(monitor -> {
|
||||
final IProgressMonitor fMonitor;
|
||||
if (monitor == null) {
|
||||
fMonitor = new NullProgressMonitor();
|
||||
} else {
|
||||
fMonitor = monitor;
|
||||
}
|
||||
fMonitor.beginTask(CUIPlugin.getResourceString("CProjectWizard.op_description"), 100); //$NON-NLS-1$
|
||||
fMonitor.worked(10);
|
||||
|
||||
SubMonitor subMonitor = SubMonitor.convert(monitor,
|
||||
CUIPlugin.getResourceString("CProjectWizard.op_description"), 100);//$NON-NLS-1$
|
||||
subMonitor.worked(10);
|
||||
try {
|
||||
newProject = createIProject(lastProjectName, lastProjectLocation,
|
||||
new SubProgressMonitor(fMonitor, 40));
|
||||
if (newProject != null)
|
||||
fMainPage.h_selected.createProject(newProject, defaults, onFinish,
|
||||
new SubProgressMonitor(fMonitor, 40));
|
||||
fMonitor.worked(10);
|
||||
newProject = createIProject(lastProjectName, lastProjectLocation, subMonitor.split(40));
|
||||
if (newProject != null) {
|
||||
fMainPage.h_selected.createProject(newProject, defaults, onFinish, subMonitor.split(40));
|
||||
}
|
||||
subMonitor.worked(10);
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.errorDialog(getShell(), title, message, e, true);
|
||||
} finally {
|
||||
fMonitor.done();
|
||||
}
|
||||
});
|
||||
try {
|
||||
|
@ -301,9 +294,7 @@ public abstract class CDTCommonProjectWizard extends BasicNewResourceWizard
|
|||
@Override
|
||||
public IProject createIProject(final String name, final URI location, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
|
||||
monitor.beginTask(Messages.CDTCommonProjectWizard_creatingProject, 100);
|
||||
|
||||
SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.CDTCommonProjectWizard_creatingProject, 100);
|
||||
if (newProject != null)
|
||||
return newProject;
|
||||
|
||||
|
@ -316,27 +307,22 @@ public abstract class CDTCommonProjectWizard extends BasicNewResourceWizard
|
|||
// workspaceDesc.setAutoBuilding(false);
|
||||
// workspace.setDescription(workspaceDesc);
|
||||
IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
|
||||
if (location != null)
|
||||
if (location != null) {
|
||||
description.setLocationURI(location);
|
||||
newProject = CCorePlugin.getDefault().createCDTProject(description, newProjectHandle,
|
||||
new SubProgressMonitor(monitor, 25));
|
||||
}
|
||||
newProject = CCorePlugin.getDefault().createCDTProject(description, newProjectHandle, subMonitor.split(50));
|
||||
} else {
|
||||
IWorkspaceRunnable runnable = monitor1 -> newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, monitor1);
|
||||
workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, new SubProgressMonitor(monitor, 25));
|
||||
workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, subMonitor.split(50));
|
||||
newProject = newProjectHandle;
|
||||
}
|
||||
|
||||
// Open the project if we have to
|
||||
if (!newProject.isOpen()) {
|
||||
newProject.open(new SubProgressMonitor(monitor, 25));
|
||||
newProject.open(subMonitor.split(25));
|
||||
}
|
||||
|
||||
continueCreationMonitor = new SubProgressMonitor(monitor, 25);
|
||||
IProject proj = continueCreation(newProject);
|
||||
|
||||
monitor.done();
|
||||
|
||||
return proj;
|
||||
continueCreationMonitor = subMonitor.split(25);
|
||||
return continueCreation(newProject);
|
||||
}
|
||||
|
||||
protected abstract IProject continueCreation(IProject prj);
|
||||
|
|
Loading…
Add table
Reference in a new issue