1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

Fix build break caused by incomplete commit.

This commit is contained in:
Ken Ryall 2008-08-13 13:27:20 +00:00
parent 5ff757551b
commit 037111a067
3 changed files with 75 additions and 19 deletions

View file

@ -117,24 +117,43 @@ public class ExecutablesManager extends PlatformObject {
if (tempDisableRefresh) {
return Status.OK_STATUS;
}
synchronized (executables) {
ArrayList<Executable> oldList = new ArrayList<Executable>(executables);
HashMap<String, Executable> oldList = new HashMap<String, Executable>(executables);
executables.clear();
synchronized (executableProviders) {
monitor.beginTask("Refresh Executables", executableProviders.size());
for (IExecutableProvider provider : executableProviders) {
executables.addAll(provider.getExecutables(new SubProgressMonitor(monitor, 1)));
}
monitor.done();
}
IExecutableProvider[] exeProviders = getExecutableProviders();
Arrays.sort(exeProviders, new Comparator<IExecutableProvider>() {
public int compare(IExecutableProvider arg0, IExecutableProvider arg1) {
int p0 = arg0.getPriority();
int p1 = arg1.getPriority();
if (p0 > p1)
return 1;
if (p0 < p1)
return -1;
return 0;
}});
refreshNeeded = false;
monitor.beginTask("Refresh Executables", exeProviders.length);
for (IExecutableProvider provider : exeProviders) {
Executable[] exes = provider.getExecutables(new SubProgressMonitor(monitor, 1));
for (Executable executable : exes) {
executables.put(executable.getPath().toOSString(), executable);
}
}
monitor.done();
synchronized (changeListeners) {
Collection<Executable> newExes = executables.values();
Executable[] exeArray = newExes.toArray(new Executable[newExes.size()]);
Collection<Executable> oldExes = oldList.values();
Executable[] oldArray = oldExes.toArray(new Executable[oldExes.size()]);
for (IExecutablesChangeListener listener : changeListeners) {
listener.executablesChanged(new ExecutablesChangeEvent(oldList, executables) {
});
listener.executablesChanged(new ExecutablesChangeEvent(oldArray, exeArray));
}
}
}
@ -166,19 +185,32 @@ public class ExecutablesManager extends PlatformObject {
return filePath;
}
public void importExecutables(String[] fileNames, IProgressMonitor monitor) {
public void importExecutables(final String[] fileNames, IProgressMonitor monitor) {
try {
tempDisableRefresh = true;
monitor.beginTask("Import Executables", executableImporters.size());
synchronized (executableImporters) {
tempDisableRefresh = true;
Collections.sort(executableImporters, new Comparator<IExecutableImporter>() {
public int compare(IExecutableImporter arg0, IExecutableImporter arg1) {
int p0 = arg0.getPriority(fileNames);
int p1 = arg1.getPriority(fileNames);
if (p0 < p1)
return 1;
if (p0 > p1)
return -1;
return 0;
}});
monitor.beginTask("Import Executables", executableImporters.size());
for (IExecutableImporter importer : executableImporters) {
importer.importExecutables(fileNames, new SubProgressMonitor(monitor, 1));
if (monitor.isCanceled()) {
boolean handled = importer.importExecutables(fileNames, new SubProgressMonitor(monitor, 1));
if (handled || monitor.isCanceled()) {
break;
}
}
}
} finally {
tempDisableRefresh = false;
}

View file

@ -14,6 +14,21 @@ import org.eclipse.core.runtime.IProgressMonitor;
public interface IExecutableImporter {
public abstract void importExecutables(String[] fileNames, IProgressMonitor monitor);
static int LOW_PRIORITY = 25;
static int NORMAL_PRIORITY = 50;
static int HIGH_PRIORITY = 75;
/**
* Gets the priority to be used when importing these executables.
* The priority is used by the Executables Manager when multiple IExecutableImporters are available.
* IExecutableImporter.importExecutables will be called for each one in priority order and will
* stop with the first one that returns TRUE.
*
* @param executable
* @return the priority level to be used for this ISourceFilesProvider
*/
int getPriority(String[] fileNames);
public abstract boolean importExecutables(String[] fileNames, IProgressMonitor monitor);
}

View file

@ -51,7 +51,7 @@ public class StandardExecutableImporter implements IExecutableImporter {
* @see org.eclipse.cdt.debug.core.executables.IExecutableImporter#importExecutables(java.lang.String[],
* org.eclipse.core.runtime.IProgressMonitor)
*/
public void importExecutables(String[] fileNames, IProgressMonitor monitor) {
public boolean importExecutables(String[] fileNames, IProgressMonitor monitor) {
monitor.beginTask("Import Executables", fileNames.length);
IProject exeProject = null;
@ -63,7 +63,7 @@ public class StandardExecutableImporter implements IExecutableImporter {
path = new File(path).getCanonicalPath();
} catch (IOException e1) {
}
if (!ExecutablesManager.getExecutablesManager().executableExists(Path.fromOSString(path))) {
if (AllowImport(Path.fromOSString(path))) {
if (!checkProject) {
// See if the default project exists
String defaultProjectName = "Executables";
@ -115,9 +115,14 @@ public class StandardExecutableImporter implements IExecutableImporter {
}
}
monitor.done();
return true;
}
private IContainer createFromRoot(IProject exeProject, IPath path) throws CoreException {
public boolean AllowImport(IPath path) {
return (!ExecutablesManager.getExecutablesManager().executableExists(path));
}
private IContainer createFromRoot(IProject exeProject, IPath path) throws CoreException {
int segmentCount = path.segmentCount() - 1;
IContainer currentFolder = exeProject;
@ -224,4 +229,8 @@ public class StandardExecutableImporter implements IExecutableImporter {
return false;
}
public int getPriority(String[] fileNames) {
return NORMAL_PRIORITY;
}
}