32 import org.eclipse.debug.core.DebugPlugin; |
32 import org.eclipse.debug.core.DebugPlugin; |
33 |
33 |
34 public class StandardExecutableProvider implements IProjectExecutablesProvider { |
34 public class StandardExecutableProvider implements IProjectExecutablesProvider { |
35 |
35 |
36 List<String> supportedNatureIds = new ArrayList<String>(); |
36 List<String> supportedNatureIds = new ArrayList<String>(); |
37 |
37 |
38 public StandardExecutableProvider() { |
38 public StandardExecutableProvider() { |
39 supportedNatureIds.add(CProjectNature.C_NATURE_ID); |
39 supportedNatureIds.add(CProjectNature.C_NATURE_ID); |
40 supportedNatureIds.add(CCProjectNature.CC_NATURE_ID); |
40 supportedNatureIds.add(CCProjectNature.CC_NATURE_ID); |
41 } |
41 } |
42 |
42 |
43 public List<String> getProjectNatures() { |
43 public List<String> getProjectNatures() { |
44 return supportedNatureIds; |
44 return supportedNatureIds; |
45 } |
45 } |
46 |
46 |
47 |
47 public List<Executable> getExecutables(IProject project, IProgressMonitor monitor) { |
48 public List<Executable> getExecutables(IProject project, |
|
49 IProgressMonitor monitor) { |
|
50 List<Executable> executables = new ArrayList<Executable>(); |
48 List<Executable> executables = new ArrayList<Executable>(); |
51 |
49 |
52 ICProject cproject = CModelManager.getDefault().create(project); |
50 ICProject cproject = CModelManager.getDefault().create(project); |
53 try { |
51 try { |
54 IBinary[] binaries = cproject.getBinaryContainer().getBinaries(); |
52 IBinary[] binaries = cproject.getBinaryContainer().getBinaries(); |
55 |
53 |
56 SubMonitor progress = SubMonitor.convert(monitor, binaries.length); |
54 SubMonitor progress = SubMonitor.convert(monitor, binaries.length); |
62 |
60 |
63 if (binary.isExecutable() || binary.isSharedLib()) { |
61 if (binary.isExecutable() || binary.isSharedLib()) { |
64 IPath exePath = binary.getResource().getLocation(); |
62 IPath exePath = binary.getResource().getLocation(); |
65 if (exePath == null) |
63 if (exePath == null) |
66 exePath = binary.getPath(); |
64 exePath = binary.getPath(); |
67 executables.add(new Executable(exePath, project, binary |
65 executables.add(new Executable(exePath, project, binary.getResource())); |
68 .getResource())); |
|
69 } |
66 } |
70 |
67 |
71 progress.worked(1); |
68 progress.worked(1); |
72 |
|
73 } |
69 } |
74 } catch (CModelException e) { |
70 } catch (CModelException e) { |
75 } |
71 } |
76 |
72 |
77 return executables; |
73 return executables; |
78 } |
74 } |
79 |
75 |
80 public IStatus removeExecutable(Executable executable, |
76 public IStatus removeExecutable(Executable executable, IProgressMonitor monitor) { |
81 IProgressMonitor monitor) { |
|
82 IResource exeResource = executable.getResource(); |
77 IResource exeResource = executable.getResource(); |
83 if (exeResource != null) { |
78 if (exeResource != null) { |
84 try { |
79 try { |
85 exeResource.delete(true, monitor); |
80 exeResource.delete(true, monitor); |
86 } catch (CoreException e) { |
81 } catch (CoreException e) { |
87 DebugPlugin.log(e); |
82 DebugPlugin.log( e ); |
88 |
|
89 } |
83 } |
90 return Status.OK_STATUS; |
84 return Status.OK_STATUS; |
91 } |
85 } |
92 return new Status(IStatus.WARNING, CDebugCorePlugin.PLUGIN_ID, |
86 return new Status(IStatus.WARNING, CDebugCorePlugin.PLUGIN_ID, "Can't remove " + executable.getName() + ": it is built by project \"" + executable.getProject().getName() + "\""); |
93 "Can't remove " + executable.getName() |
|
94 + ": it is built by project \"" |
|
95 + executable.getProject().getName() + "\""); |
|
96 } |
87 } |
97 |
|
98 } |
88 } |