mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-12 18:55:38 +02:00
Removed use of SubProgressMonitor.
Change-Id: Ibb44a6e12f147a69a8a32e243831f5d4ac1468ec
This commit is contained in:
parent
e371ba0919
commit
bc1d5f3d2d
1 changed files with 58 additions and 83 deletions
|
@ -73,23 +73,22 @@ import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IProjectDescription;
|
import org.eclipse.core.resources.IProjectDescription;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IWorkspace;
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
|
import org.eclipse.core.runtime.ICoreRunnable;
|
||||||
import org.eclipse.core.runtime.IExtension;
|
import org.eclipse.core.runtime.IExtension;
|
||||||
import org.eclipse.core.runtime.IExtensionPoint;
|
import org.eclipse.core.runtime.IExtensionPoint;
|
||||||
import org.eclipse.core.runtime.IExtensionRegistry;
|
import org.eclipse.core.runtime.IExtensionRegistry;
|
||||||
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.OperationCanceledException;
|
import org.eclipse.core.runtime.OperationCanceledException;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.Plugin;
|
import org.eclipse.core.runtime.Plugin;
|
||||||
import org.eclipse.core.runtime.Preferences;
|
import org.eclipse.core.runtime.Preferences;
|
||||||
import org.eclipse.core.runtime.QualifiedName;
|
import org.eclipse.core.runtime.QualifiedName;
|
||||||
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.content.IContentType;
|
import org.eclipse.core.runtime.content.IContentType;
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||||
|
@ -477,7 +476,6 @@ public class CCorePlugin extends Plugin {
|
||||||
* @see CCorePlugin#getDefaultOptions
|
* @see CCorePlugin#getDefaultOptions
|
||||||
*/
|
*/
|
||||||
public static String getOption(String optionName) {
|
public static String getOption(String optionName) {
|
||||||
|
|
||||||
if (CORE_ENCODING.equals(optionName)) {
|
if (CORE_ENCODING.equals(optionName)) {
|
||||||
return ResourcesPlugin.getEncoding();
|
return ResourcesPlugin.getEncoding();
|
||||||
}
|
}
|
||||||
|
@ -902,34 +900,26 @@ public class CCorePlugin extends Plugin {
|
||||||
*/
|
*/
|
||||||
public IProject createCProject(final IProjectDescription description, final IProject projectHandle,
|
public IProject createCProject(final IProjectDescription description, final IProject projectHandle,
|
||||||
IProgressMonitor monitor, final String projectID)
|
IProgressMonitor monitor, final String projectID)
|
||||||
throws CoreException, OperationCanceledException {
|
throws CoreException, OperationCanceledException {
|
||||||
|
getWorkspace().run(new ICoreRunnable() {
|
||||||
getWorkspace().run(new IWorkspaceRunnable() {
|
|
||||||
@Override
|
@Override
|
||||||
public void run(IProgressMonitor monitor) throws CoreException {
|
public void run(IProgressMonitor monitor) throws CoreException {
|
||||||
try {
|
SubMonitor progress = SubMonitor.convert(monitor, "Creating C Project...", 3); //$NON-NLS-1$
|
||||||
if (monitor == null) {
|
if (!projectHandle.exists()) {
|
||||||
monitor = new NullProgressMonitor();
|
projectHandle.create(description, progress.split(1));
|
||||||
}
|
|
||||||
monitor.beginTask("Creating C Project...", 3); //$NON-NLS-1$
|
|
||||||
if (!projectHandle.exists()) {
|
|
||||||
projectHandle.create(description, new SubProgressMonitor(monitor, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (monitor.isCanceled()) {
|
|
||||||
throw new OperationCanceledException();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open first.
|
|
||||||
projectHandle.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(monitor, 1));
|
|
||||||
|
|
||||||
mapCProjectOwner(projectHandle, projectID, false);
|
|
||||||
|
|
||||||
// Add C Nature ... does not add duplicates
|
|
||||||
CProjectNature.addCNature(projectHandle, new SubProgressMonitor(monitor, 1));
|
|
||||||
} finally {
|
|
||||||
monitor.done();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (progress.isCanceled()) {
|
||||||
|
throw new OperationCanceledException();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open first.
|
||||||
|
projectHandle.open(IResource.BACKGROUND_REFRESH, progress.split(1));
|
||||||
|
|
||||||
|
mapCProjectOwner(projectHandle, projectID, false);
|
||||||
|
|
||||||
|
// Add C Nature ... does not add duplicates
|
||||||
|
CProjectNature.addCNature(projectHandle, progress.split(1));
|
||||||
}
|
}
|
||||||
}, getWorkspace().getRoot(), 0, monitor);
|
}, getWorkspace().getRoot(), 0, monitor);
|
||||||
return projectHandle;
|
return projectHandle;
|
||||||
|
@ -942,56 +932,48 @@ public class CCorePlugin extends Plugin {
|
||||||
|
|
||||||
public IProject createCDTProject(final IProjectDescription description, final IProject projectHandle,
|
public IProject createCDTProject(final IProjectDescription description, final IProject projectHandle,
|
||||||
final String bsId, IProgressMonitor monitor) throws CoreException, OperationCanceledException {
|
final String bsId, IProgressMonitor monitor) throws CoreException, OperationCanceledException {
|
||||||
|
getWorkspace().run(new ICoreRunnable() {
|
||||||
getWorkspace().run(new IWorkspaceRunnable() {
|
|
||||||
@Override
|
@Override
|
||||||
public void run(IProgressMonitor monitor) throws CoreException {
|
public void run(IProgressMonitor monitor) throws CoreException {
|
||||||
try {
|
SubMonitor progress = SubMonitor.convert(monitor, "Creating C Project...", 3); //$NON-NLS-1$
|
||||||
if (monitor == null) {
|
if (!projectHandle.exists()) {
|
||||||
monitor = new NullProgressMonitor();
|
projectHandle.create(description, progress.split(1));
|
||||||
}
|
}
|
||||||
monitor.beginTask("Creating C Project...", 3); //$NON-NLS-1$
|
|
||||||
if (!projectHandle.exists()) {
|
|
||||||
projectHandle.create(description, new SubProgressMonitor(monitor, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (monitor.isCanceled()) {
|
if (progress.isCanceled()) {
|
||||||
throw new OperationCanceledException();
|
throw new OperationCanceledException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open first.
|
// Open first.
|
||||||
projectHandle.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(monitor, 1));
|
projectHandle.open(IResource.BACKGROUND_REFRESH, progress.split(1));
|
||||||
|
|
||||||
// mapCProjectOwner(projectHandle, projectID, false);
|
// mapCProjectOwner(projectHandle, projectID, false);
|
||||||
|
|
||||||
// Add C Nature ... does not add duplicates
|
// Add C Nature ... does not add duplicates
|
||||||
CProjectNature.addCNature(projectHandle, new SubProgressMonitor(monitor, 1));
|
CProjectNature.addCNature(projectHandle, progress.split(1));
|
||||||
|
|
||||||
if (bsId != null) {
|
if (bsId != null) {
|
||||||
ICProjectDescription projDes = createProjectDescription(projectHandle, true);
|
ICProjectDescription projDes = createProjectDescription(projectHandle, true);
|
||||||
ICConfigurationDescription cfgs[] = projDes.getConfigurations();
|
ICConfigurationDescription cfgs[] = projDes.getConfigurations();
|
||||||
ICConfigurationDescription cfg = null;
|
ICConfigurationDescription cfg = null;
|
||||||
for (ICConfigurationDescription cfg2 : cfgs) {
|
for (ICConfigurationDescription cfg2 : cfgs) {
|
||||||
if (bsId.equals(cfg2.getBuildSystemId())) {
|
if (bsId.equals(cfg2.getBuildSystemId())) {
|
||||||
cfg = cfg2;
|
cfg = cfg2;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cfg == null) {
|
|
||||||
ICConfigurationDescription prefCfg = getPreferenceConfiguration(bsId);
|
|
||||||
if (prefCfg != null) {
|
|
||||||
cfg = projDes.createConfiguration(CDataUtil.genId(prefCfg.getId()),
|
|
||||||
prefCfg.getName(), prefCfg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cfg != null) {
|
|
||||||
setProjectDescription(projectHandle, projDes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
monitor.done();
|
if (cfg == null) {
|
||||||
|
ICConfigurationDescription prefCfg = getPreferenceConfiguration(bsId);
|
||||||
|
if (prefCfg != null) {
|
||||||
|
cfg = projDes.createConfiguration(CDataUtil.genId(prefCfg.getId()),
|
||||||
|
prefCfg.getName(), prefCfg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cfg != null) {
|
||||||
|
setProjectDescription(projectHandle, projDes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, getWorkspace().getRoot(), 0, monitor);
|
}, getWorkspace().getRoot(), 0, monitor);
|
||||||
|
@ -1023,7 +1005,7 @@ public class CCorePlugin extends Plugin {
|
||||||
*/
|
*/
|
||||||
public void convertProjectToC(IProject projectHandle, IProgressMonitor monitor, String projectID)
|
public void convertProjectToC(IProject projectHandle, IProgressMonitor monitor, String projectID)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
if ((projectHandle == null) || (monitor == null) || (projectID == null)) {
|
if (projectHandle == null || projectID == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||||
|
@ -1034,7 +1016,7 @@ public class CCorePlugin extends Plugin {
|
||||||
|
|
||||||
public void convertProjectToNewC(IProject projectHandle, String bsId, IProgressMonitor monitor)
|
public void convertProjectToNewC(IProject projectHandle, String bsId, IProgressMonitor monitor)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
if ((projectHandle == null) || (monitor == null) || (bsId == null)) {
|
if (projectHandle == null || bsId == null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
}
|
}
|
||||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||||
|
@ -1048,7 +1030,7 @@ public class CCorePlugin extends Plugin {
|
||||||
*/
|
*/
|
||||||
public void convertProjectToCC(IProject projectHandle, IProgressMonitor monitor, String projectID)
|
public void convertProjectToCC(IProject projectHandle, IProgressMonitor monitor, String projectID)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
if ((projectHandle == null) || (monitor == null) || (projectID == null)) {
|
if (projectHandle == null || projectID == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
createCProject(projectHandle.getDescription(), projectHandle, monitor, projectID);
|
createCProject(projectHandle.getDescription(), projectHandle, monitor, projectID);
|
||||||
|
@ -1058,7 +1040,7 @@ public class CCorePlugin extends Plugin {
|
||||||
|
|
||||||
public void convertProjectToNewCC(IProject projectHandle, String bsId, IProgressMonitor monitor)
|
public void convertProjectToNewCC(IProject projectHandle, String bsId, IProgressMonitor monitor)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
if ((projectHandle == null) || (monitor == null) || (bsId == null)) {
|
if (projectHandle == null || bsId == null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
}
|
}
|
||||||
createCDTProject(projectHandle.getDescription(), projectHandle, bsId, monitor);
|
createCDTProject(projectHandle.getDescription(), projectHandle, bsId, monitor);
|
||||||
|
@ -1102,10 +1084,7 @@ public class CCorePlugin extends Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated since CDT 6.1. Use
|
* @deprecated since CDT 6.1. Use {@link ErrorParserManager#getErrorParserAvailableIds()} instead
|
||||||
* {@link ErrorParserManager#getErrorParserAvailableIds()}
|
|
||||||
* instead
|
|
||||||
* @return array of error parsers ids
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String[] getAllErrorParsersIDs() {
|
public String[] getAllErrorParsersIDs() {
|
||||||
|
@ -1115,11 +1094,7 @@ public class CCorePlugin extends Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated since CDT 6.1. Use
|
* @deprecated since CDT 6.1. Use {@link ErrorParserManager#getErrorParserCopy(String)} instead
|
||||||
* {@link ErrorParserManager#getErrorParserCopy(String)} instead
|
|
||||||
* @param id
|
|
||||||
* - id of error parser
|
|
||||||
* @return array of error parsers
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public IErrorParser[] getErrorParser(String id) {
|
public IErrorParser[] getErrorParser(String id) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue