author | ryall |
Fri, 05 Jun 2009 14:27:40 -0500 | |
changeset 19 | 89d3c8eb71dd |
parent 15 | 3ac8c55882b5 |
child 23 | 7357eeb2874f |
permissions | -rw-r--r-- |
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
1 |
/******************************************************************************* |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2008 Nokia and others. |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. This program and the accompanying materials |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
5 |
* which accompanies this distribution, and is available at |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
7 |
* |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
8 |
* Contributors: |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
9 |
* Nokia - Initial API and implementation |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
10 |
*******************************************************************************/ |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
11 |
|
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
12 |
package org.eclipse.cdt.debug.core.executables; |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
13 |
|
14 | 14 |
import java.text.DateFormat; |
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
15 |
import java.util.ArrayList; |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
16 |
import java.util.Collection; |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
17 |
import java.util.Collections; |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
18 |
import java.util.Comparator; |
14 | 19 |
import java.util.Date; |
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
20 |
import java.util.HashMap; |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
21 |
import java.util.List; |
14 | 22 |
import java.util.Map; |
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
23 |
|
14 | 24 |
import org.eclipse.cdt.core.model.CoreModel; |
25 |
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; |
|
26 |
import org.eclipse.cdt.core.settings.model.ICProjectDescription; |
|
27 |
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener; |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
28 |
import org.eclipse.cdt.debug.core.CDebugCorePlugin; |
14 | 29 |
import org.eclipse.core.resources.IProject; |
30 |
import org.eclipse.core.resources.IProjectDescription; |
|
31 |
import org.eclipse.core.resources.IResource; |
|
32 |
import org.eclipse.core.resources.IResourceChangeEvent; |
|
33 |
import org.eclipse.core.resources.IResourceChangeListener; |
|
34 |
import org.eclipse.core.resources.IResourceDelta; |
|
35 |
import org.eclipse.core.resources.IResourceDeltaVisitor; |
|
36 |
import org.eclipse.core.resources.ResourcesPlugin; |
|
37 |
import org.eclipse.core.runtime.CoreException; |
|
38 |
import org.eclipse.core.runtime.IConfigurationElement; |
|
39 |
import org.eclipse.core.runtime.IExtension; |
|
40 |
import org.eclipse.core.runtime.IExtensionPoint; |
|
41 |
import org.eclipse.core.runtime.IExtensionRegistry; |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
42 |
import org.eclipse.core.runtime.IPath; |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
43 |
import org.eclipse.core.runtime.IProgressMonitor; |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
44 |
import org.eclipse.core.runtime.IStatus; |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
45 |
import org.eclipse.core.runtime.MultiStatus; |
14 | 46 |
import org.eclipse.core.runtime.Platform; |
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
47 |
import org.eclipse.core.runtime.PlatformObject; |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
48 |
import org.eclipse.core.runtime.Status; |
14 | 49 |
import org.eclipse.core.runtime.SubMonitor; |
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
50 |
import org.eclipse.core.runtime.SubProgressMonitor; |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
51 |
import org.eclipse.core.runtime.jobs.Job; |
14 | 52 |
import org.eclipse.osgi.service.debug.DebugOptions; |
53 |
import org.osgi.framework.BundleContext; |
|
54 |
import org.osgi.framework.ServiceReference; |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
55 |
|
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
56 |
/** |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
57 |
* The Executables Manager maintains a collection of executables built by all of |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
58 |
* the projects in the workspace. Executables are contributed by instances of |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
59 |
* IExecutablesProvider. |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
60 |
* |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
61 |
* @author Ken Ryall |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
62 |
* |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
63 |
*/ |
14 | 64 |
public class ExecutablesManager extends PlatformObject implements IResourceChangeListener, ICProjectDescriptionListener { |
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
65 |
|
14 | 66 |
private static final String EXECUTABLES_MANAGER_DEBUG_TRACING = CDebugCorePlugin.PLUGIN_ID + "EXECUTABLES_MANAGER_DEBUG_TRACING"; //$NON-NLS-1$ |
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
67 |
|
14 | 68 |
private Map<IProject, IProjectExecutablesProvider> executablesProviderMap = new HashMap<IProject, IProjectExecutablesProvider>(); |
69 |
private Map<IProject, List<Executable>> executablesMap = new HashMap<IProject, List<Executable>>(); |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
70 |
private List<IExecutablesChangeListener> changeListeners = Collections.synchronizedList(new ArrayList<IExecutablesChangeListener>()); |
14 | 71 |
private List<IProjectExecutablesProvider> executableProviders; |
72 |
private List<ISourceFilesProvider> sourceFileProviders; |
|
73 |
private List<ISourceFileRemapping> sourceFileRemappings; |
|
74 |
private List<IExecutableImporter> executableImporters; |
|
75 |
||
76 |
private boolean DEBUG; |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
77 |
|
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
78 |
private Job refreshJob = new Job("Get Executables") { |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
79 |
|
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
80 |
@Override |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
81 |
public IStatus run(IProgressMonitor monitor) { |
14 | 82 |
|
83 |
trace("Get Executables job started at " + getStringFromTimestamp(System.currentTimeMillis())); |
|
84 |
||
85 |
List<IProject> projects = getProjectsToCheck(); |
|
86 |
||
87 |
SubMonitor subMonitor = SubMonitor.convert(monitor, projects.size()); |
|
88 |
||
89 |
for (IProject project : projects) { |
|
90 |
if (subMonitor.isCanceled()) { |
|
91 |
trace("Get Executables job cancelled at " + getStringFromTimestamp(System.currentTimeMillis())); |
|
92 |
return Status.CANCEL_STATUS; |
|
93 |
} |
|
94 |
||
95 |
subMonitor.subTask("Checking project: " + project.getName()); |
|
96 |
||
97 |
// get the executables provider for this project |
|
98 |
IProjectExecutablesProvider provider = getExecutablesProviderForProject(project); |
|
99 |
if (provider != null) { |
|
100 |
trace("Getting executables for project: " + project.getName() + " using " + provider.toString()); |
|
101 |
||
102 |
// store the list of executables for this project |
|
103 |
synchronized (executablesMap) { |
|
104 |
executablesMap.put(project, provider.getExecutables(project, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE))); |
|
105 |
} |
|
106 |
} |
|
107 |
} |
|
108 |
||
109 |
// notify the listeners |
|
110 |
synchronized (changeListeners) { |
|
111 |
for (IExecutablesChangeListener listener : changeListeners) { |
|
112 |
listener.executablesListChanged(); |
|
113 |
} |
|
114 |
} |
|
115 |
||
116 |
trace("Get Executables job finished at " + getStringFromTimestamp(System.currentTimeMillis())); |
|
117 |
||
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
118 |
return Status.OK_STATUS; |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
119 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
120 |
}; |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
121 |
|
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
122 |
private static ExecutablesManager executablesManager = null; |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
123 |
|
14 | 124 |
/** |
125 |
* Get the executables manager instance |
|
126 |
* @return the executables manager |
|
127 |
*/ |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
128 |
public static ExecutablesManager getExecutablesManager() { |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
129 |
if (executablesManager == null) |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
130 |
executablesManager = new ExecutablesManager(); |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
131 |
return executablesManager; |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
132 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
133 |
|
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
134 |
public ExecutablesManager() { |
14 | 135 |
|
136 |
// check if debugging is enabled |
|
137 |
BundleContext context = CDebugCorePlugin.getDefault().getBundle().getBundleContext(); |
|
138 |
if (context != null) { |
|
139 |
ServiceReference reference = CDebugCorePlugin.getDefault().getBundle().getBundleContext().getServiceReference(DebugOptions.class.getName()); |
|
140 |
if (reference != null) { |
|
141 |
DebugOptions service = (DebugOptions) context.getService(reference); |
|
142 |
if (service != null) { |
|
143 |
try { |
|
144 |
DEBUG = service.getBooleanOption(EXECUTABLES_MANAGER_DEBUG_TRACING, false); |
|
145 |
} finally { |
|
146 |
// we have what we want - release the service |
|
147 |
context.ungetService(reference); |
|
148 |
} |
|
149 |
} |
|
150 |
} |
|
151 |
} |
|
152 |
||
153 |
refreshJob.setPriority(Job.SHORT); |
|
154 |
||
155 |
// load the extension points |
|
156 |
loadExecutableProviderExtensions(); |
|
157 |
loadSoureFileProviderExtensions(); |
|
158 |
loadSoureRemappingExtensions(); |
|
159 |
loadExecutableImporterExtensions(); |
|
160 |
||
161 |
// add the standard providers |
|
162 |
executableProviders.add(0, new StandardExecutableProvider()); |
|
163 |
sourceFileProviders.add(0, new StandardSourceFilesProvider()); |
|
164 |
sourceFileRemappings.add(0, new StandardSourceFileRemapping()); |
|
165 |
executableImporters.add(0, new StandardExecutableImporter()); |
|
166 |
||
167 |
// listen for events we're interested in |
|
168 |
ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE | IResourceChangeEvent.POST_BUILD); |
|
169 |
CoreModel.getDefault().getProjectDescriptionManager().addCProjectDescriptionListener(this, |
|
170 |
CProjectDescriptionEvent.DATA_APPLIED); |
|
171 |
||
172 |
// schedule a refresh so we get up to date |
|
173 |
scheduleRefresh(); |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
174 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
175 |
|
14 | 176 |
/** |
177 |
* Adds an executable listener |
|
178 |
* @param listener the listener to add |
|
179 |
*/ |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
180 |
public void addExecutablesChangeListener(IExecutablesChangeListener listener) { |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
181 |
changeListeners.add(listener); |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
182 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
183 |
|
14 | 184 |
/** |
185 |
* Removes an executable listener |
|
186 |
* @param listener the listener to remove |
|
187 |
*/ |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
188 |
public void removeExecutablesChangeListener(IExecutablesChangeListener listener) { |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
189 |
changeListeners.remove(listener); |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
190 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
191 |
|
14 | 192 |
/** |
193 |
* Gets the list of executables in the workspace. |
|
194 |
* @return the list of executables which may be empty |
|
195 |
*/ |
|
196 |
public Collection<Executable> getExecutables() { |
|
197 |
||
198 |
trace("getExecutables called at " + getStringFromTimestamp(System.currentTimeMillis())); |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
199 |
|
14 | 200 |
List<Executable> executables = new ArrayList<Executable>(); |
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
201 |
|
14 | 202 |
synchronized (executablesMap) { |
203 |
for (List<Executable> exes : executablesMap.values()) { |
|
204 |
for (Executable exe : exes) { |
|
205 |
if (!executables.contains(exe)) { |
|
206 |
executables.add(exe); |
|
207 |
} |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
208 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
209 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
210 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
211 |
|
14 | 212 |
trace("getExecutables returned at " + getStringFromTimestamp(System.currentTimeMillis())); |
213 |
||
214 |
return executables; |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
215 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
216 |
|
14 | 217 |
/** |
218 |
* Gets the collection of executables for the given project |
|
219 |
* @param project the project |
|
220 |
* @return collection of executables which may be empty |
|
221 |
*/ |
|
222 |
public Collection<Executable> getExecutablesForProject(IProject project) { |
|
223 |
List<Executable> executables = new ArrayList<Executable>(); |
|
224 |
||
225 |
synchronized (executablesMap) { |
|
226 |
List<Executable> exes = executablesMap.get(project); |
|
227 |
if (exes != null) { |
|
228 |
for (Executable exe : exes) { |
|
229 |
if (!executables.contains(exe)) { |
|
230 |
executables.add(exe); |
|
231 |
} |
|
232 |
} |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
233 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
234 |
} |
14 | 235 |
|
236 |
return executables; |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
237 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
238 |
|
14 | 239 |
/** |
240 |
* Attempt to remap the path to the given source file in the given executable using |
|
241 |
* source file mapping extensions |
|
242 |
* @param executable the executable |
|
243 |
* @param filePath the absolute path to the source file |
|
244 |
* @return the new path to the source file, which was remapped if possible |
|
245 |
*/ |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
246 |
public String remapSourceFile(Executable executable, String filePath) { |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
247 |
synchronized (sourceFileRemappings) { |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
248 |
for (ISourceFileRemapping remapping : sourceFileRemappings) { |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
249 |
String remappedPath = remapping.remapSourceFile(executable.getPath(), filePath); |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
250 |
if (!remappedPath.equals(filePath)) |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
251 |
return remappedPath; |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
252 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
253 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
254 |
return filePath; |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
255 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
256 |
|
14 | 257 |
/** |
258 |
* Import the given executables into the manager |
|
259 |
* @param fileNames the absolute paths of the executables to import |
|
260 |
* @param monitor progress monitor |
|
261 |
*/ |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
262 |
public void importExecutables(final String[] fileNames, IProgressMonitor monitor) { |
14 | 263 |
|
19
89d3c8eb71dd
Only react if the select change is new. Don't refresh the exe list if ImportExecutables doesn't do anything.
ryall
parents:
15
diff
changeset
|
264 |
boolean handled = false; |
14 | 265 |
monitor.beginTask("Import Executables", executableImporters.size()); |
266 |
synchronized (executableImporters) { |
|
267 |
Collections.sort(executableImporters, new Comparator<IExecutableImporter>() { |
|
268 |
||
269 |
public int compare(IExecutableImporter arg0, IExecutableImporter arg1) { |
|
270 |
int p0 = arg0.getPriority(fileNames); |
|
271 |
int p1 = arg1.getPriority(fileNames); |
|
272 |
if (p0 < p1) |
|
273 |
return 1; |
|
274 |
if (p0 > p1) |
|
275 |
return -1; |
|
276 |
return 0; |
|
277 |
}}); |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
278 |
|
14 | 279 |
for (IExecutableImporter importer : executableImporters) { |
19
89d3c8eb71dd
Only react if the select change is new. Don't refresh the exe list if ImportExecutables doesn't do anything.
ryall
parents:
15
diff
changeset
|
280 |
handled = importer.importExecutables(fileNames, new SubProgressMonitor(monitor, 1)); |
14 | 281 |
if (handled || monitor.isCanceled()) { |
282 |
break; |
|
283 |
} |
|
284 |
} |
|
285 |
} |
|
286 |
||
19
89d3c8eb71dd
Only react if the select change is new. Don't refresh the exe list if ImportExecutables doesn't do anything.
ryall
parents:
15
diff
changeset
|
287 |
if (handled) |
89d3c8eb71dd
Only react if the select change is new. Don't refresh the exe list if ImportExecutables doesn't do anything.
ryall
parents:
15
diff
changeset
|
288 |
scheduleRefresh(); |
14 | 289 |
} |
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
290 |
|
14 | 291 |
/** |
292 |
* Determines if the given executable is currently known by the manager |
|
293 |
* @param exePath the absolute path to the executable |
|
294 |
* @return true if the manager knows about it, false otherwise |
|
295 |
*/ |
|
296 |
public boolean executableExists(IPath exePath) { |
|
297 |
synchronized (executablesMap) { |
|
298 |
for (List<Executable> exes : executablesMap.values()) { |
|
299 |
for (Executable exe : exes) { |
|
300 |
if (exe.getPath().equals(exePath)) { |
|
301 |
return true; |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
302 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
303 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
304 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
305 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
306 |
|
14 | 307 |
return false; |
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
308 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
309 |
|
14 | 310 |
/** |
311 |
* Get the list of source files for the given executable |
|
312 |
* @param executable the executable |
|
313 |
* @param monitor progress monitor |
|
314 |
* @return an array of source files which may be empty |
|
315 |
*/ |
|
316 |
public String[] getSourceFiles(final Executable executable, IProgressMonitor monitor) { |
|
317 |
String[] result = new String[0]; |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
318 |
|
14 | 319 |
trace("getSourceFiles called at " + getStringFromTimestamp(System.currentTimeMillis()) + " for " + executable.getPath().toOSString()); |
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
320 |
|
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
321 |
synchronized (sourceFileProviders) { |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
322 |
Collections.sort(sourceFileProviders, new Comparator<ISourceFilesProvider>() { |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
323 |
|
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
324 |
public int compare(ISourceFilesProvider arg0, ISourceFilesProvider arg1) { |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
325 |
int p0 = arg0.getPriority(executable); |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
326 |
int p1 = arg1.getPriority(executable); |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
327 |
if (p0 < p1) |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
328 |
return 1; |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
329 |
if (p0 > p1) |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
330 |
return -1; |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
331 |
return 0; |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
332 |
}}); |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
333 |
|
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
334 |
monitor.beginTask("Finding source files in " + executable.getName(), sourceFileProviders.size()); |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
335 |
for (ISourceFilesProvider provider : sourceFileProviders) { |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
336 |
String[] sourceFiles = provider.getSourceFiles(executable, new SubProgressMonitor(monitor, 1)); |
14 | 337 |
if (sourceFiles.length > 0) { |
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
338 |
result = sourceFiles; |
14 | 339 |
|
340 |
trace("getSourceFiles got " + sourceFiles.length + " files from " + provider.toString()); |
|
341 |
||
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
342 |
break; |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
343 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
344 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
345 |
monitor.done(); |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
346 |
} |
14 | 347 |
|
348 |
trace("getSourceFiles returned at " + getStringFromTimestamp(System.currentTimeMillis())); |
|
349 |
||
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
350 |
return result; |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
351 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
352 |
|
14 | 353 |
/** |
354 |
* Removes the given executables |
|
355 |
* @param executables the array of executables to be removed |
|
356 |
* @param monitor progress monitor |
|
357 |
* @return IStatus of the operation |
|
358 |
*/ |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
359 |
public IStatus removeExecutables(Executable[] executables, IProgressMonitor monitor) { |
14 | 360 |
MultiStatus status = new MultiStatus(CDebugCorePlugin.PLUGIN_ID, IStatus.WARNING, "Couldn't remove all of the selected executables", null); |
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
361 |
|
14 | 362 |
monitor.beginTask("Remove Executables", executables.length); |
363 |
for (Executable executable : executables) { |
|
364 |
||
365 |
IProjectExecutablesProvider provider = getExecutablesProviderForProject(executable.getProject()); |
|
366 |
if (provider != null) { |
|
367 |
IStatus result = provider.removeExecutable(executable, new SubProgressMonitor(monitor, 1)); |
|
368 |
if (result.isOK()) { |
|
369 |
// remove the exe from the list |
|
370 |
List<Executable> exes = executablesMap.get(executable.getProject()); |
|
371 |
if (exes != null) { |
|
372 |
exes.remove(executable); |
|
373 |
} |
|
374 |
} else { |
|
375 |
status.add(result); |
|
376 |
} |
|
377 |
} |
|
378 |
} |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
379 |
|
14 | 380 |
// notify listeners that the list has changed. only do this if at least one delete succeeded. |
381 |
if (status.getChildren().length != executables.length) { |
|
382 |
synchronized (changeListeners) { |
|
383 |
for (IExecutablesChangeListener listener : changeListeners) { |
|
384 |
listener.executablesListChanged(); |
|
385 |
} |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
386 |
} |
14 | 387 |
} |
388 |
||
389 |
return status; |
|
390 |
} |
|
391 |
||
392 |
/** |
|
393 |
* Refresh the list of executables for the given projects |
|
394 |
* @param projects the list of projects, or null. if null or the list |
|
395 |
* is empty, all projects will be refreshed. |
|
396 |
*/ |
|
397 |
public void refresh(List<IProject> projects) { |
|
398 |
if (projects == null || projects.size() == 0) { |
|
399 |
// clear the entire cache |
|
400 |
executablesMap.clear(); |
|
401 |
} else { |
|
402 |
for (IProject project : projects) { |
|
403 |
executablesMap.remove(project); |
|
404 |
} |
|
405 |
} |
|
406 |
||
407 |
scheduleRefresh(); |
|
408 |
} |
|
409 |
||
410 |
public void resourceChanged(IResourceChangeEvent event) { |
|
411 |
||
412 |
synchronized (executablesMap) { |
|
413 |
// project needs to be refreshed after a build/clean as the binary may |
|
414 |
// be added/removed/renamed etc. |
|
415 |
if (event.getType() == IResourceChangeEvent.POST_BUILD) { |
|
416 |
Object obj = event.getSource(); |
|
417 |
if (obj != null && obj instanceof IProject) { |
|
418 |
if (executablesMap.containsKey(obj)) { |
|
419 |
List<Executable> executables = executablesMap.remove(obj); |
|
420 |
||
421 |
trace("Scheduling refresh because project " + ((IProject)obj).getName() + " built or cleaned"); |
|
422 |
||
423 |
scheduleRefresh(); |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
424 |
|
14 | 425 |
// notify the listeners that these executables have possibly changed |
426 |
if (executables != null && executables.size() > 0) { |
|
427 |
synchronized (changeListeners) { |
|
428 |
for (IExecutablesChangeListener listener : changeListeners) { |
|
429 |
listener.executablesChanged(executables); |
|
430 |
} |
|
431 |
} |
|
432 |
} |
|
433 |
} |
|
434 |
} |
|
435 |
return; |
|
436 |
} |
|
437 |
||
438 |
// refresh when projects are opened or closed. note that deleted |
|
439 |
// projects are handled later in this method. new projects are handled |
|
440 |
// in handleEvent. resource changed events always start at the workspace |
|
441 |
// root, so projects are the next level down |
|
442 |
boolean refreshNeeded = false; |
|
443 |
IResourceDelta[] projects = event.getDelta().getAffectedChildren(); |
|
444 |
for (IResourceDelta projectDelta : projects) { |
|
445 |
if ((projectDelta.getFlags() & IResourceDelta.OPEN) != 0) { |
|
446 |
if (projectDelta.getKind() == IResourceDelta.CHANGED) { |
|
447 |
// project was opened or closed |
|
448 |
if (executablesMap.containsKey(projectDelta.getResource())) { |
|
449 |
executablesMap.remove(projectDelta.getResource()); |
|
450 |
} |
|
451 |
refreshNeeded = true; |
|
452 |
} |
|
453 |
} |
|
454 |
} |
|
455 |
||
456 |
if (refreshNeeded) { |
|
457 |
trace("Scheduling refresh because project(s) opened or closed"); |
|
458 |
||
459 |
scheduleRefresh(); |
|
460 |
return; |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
461 |
} |
14 | 462 |
|
463 |
try { |
|
464 |
event.getDelta().accept(new IResourceDeltaVisitor() { |
|
465 |
||
466 |
public boolean visit(IResourceDelta delta) throws CoreException { |
|
467 |
if (delta.getKind() == IResourceDelta.ADDED || delta.getKind() == IResourceDelta.REMOVED) { |
|
468 |
IResource deltaResource = delta.getResource(); |
|
469 |
if (deltaResource != null) { |
|
470 |
boolean refresh = false; |
|
471 |
if (delta.getKind() == IResourceDelta.REMOVED && deltaResource instanceof IProject) { |
|
472 |
// project deleted |
|
473 |
if (executablesMap.containsKey(deltaResource)) { |
|
474 |
executablesMap.remove(deltaResource); |
|
475 |
refresh = true; |
|
476 |
||
477 |
trace("Scheduling refresh because project " + deltaResource.getName() + " deleted"); |
|
478 |
} |
|
479 |
} else { |
|
480 |
// see if a binary has been added/removed |
|
481 |
IPath resourcePath = deltaResource.getLocation(); |
|
482 |
if (resourcePath != null && Executable.isExecutableFile(resourcePath)) { |
|
483 |
if (executablesMap.containsKey(deltaResource.getProject())) { |
|
484 |
executablesMap.remove(deltaResource.getProject()); |
|
485 |
refresh = true; |
|
486 |
||
487 |
trace("Scheduling refresh because a binary was added/removed"); |
|
488 |
} |
|
489 |
} |
|
490 |
} |
|
491 |
||
492 |
if (refresh) { |
|
493 |
scheduleRefresh(); |
|
494 |
return false; |
|
495 |
} |
|
496 |
} |
|
497 |
} |
|
498 |
return true; |
|
499 |
} |
|
500 |
}); |
|
501 |
} catch (CoreException e) { |
|
502 |
} |
|
503 |
} |
|
504 |
} |
|
505 |
||
506 |
public void handleEvent(CProjectDescriptionEvent event) { |
|
507 |
// this handles the cases where the active build configuration changes, |
|
508 |
// and when new projects are created or loaded at startup. |
|
509 |
boolean refresh = false; |
|
510 |
||
511 |
int eventType = event.getEventType(); |
|
512 |
||
513 |
if (eventType == CProjectDescriptionEvent.DATA_APPLIED) { |
|
514 |
||
515 |
synchronized (executablesMap) { |
|
516 |
// see if the active build config has changed |
|
517 |
ICProjectDescription newDesc = event.getNewCProjectDescription(); |
|
518 |
ICProjectDescription oldDesc = event.getOldCProjectDescription(); |
|
519 |
if (oldDesc != null && newDesc != null) { |
|
520 |
String newConfigName = newDesc.getActiveConfiguration().getName(); |
|
521 |
String oldConfigName = oldDesc.getActiveConfiguration().getName(); |
|
522 |
if (!newConfigName.equals(oldConfigName)) { |
|
523 |
if (executablesMap.containsKey(newDesc.getProject())) { |
|
524 |
executablesMap.remove(newDesc.getProject()); |
|
525 |
refresh = true; |
|
526 |
||
527 |
trace("Scheduling refresh because active build configuration changed"); |
|
528 |
} |
|
529 |
} |
|
530 |
} else if (newDesc != null && oldDesc == null) { |
|
531 |
// project just created |
|
532 |
refresh = true; |
|
533 |
||
534 |
trace("Scheduling refresh because project " + newDesc.getProject().getName() + " created"); |
|
535 |
} |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
536 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
537 |
} |
14 | 538 |
|
539 |
if (refresh) { |
|
540 |
scheduleRefresh(); |
|
541 |
} |
|
542 |
} |
|
543 |
||
544 |
private List<IProject> getProjectsToCheck() { |
|
545 |
||
546 |
List<IProject> projects = new ArrayList<IProject>(); |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
547 |
|
14 | 548 |
synchronized (executablesMap) { |
549 |
// look for any CDT projects not in our cache |
|
550 |
for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { |
|
551 |
if (!executablesMap.containsKey(project)) { |
|
552 |
if (CoreModel.hasCNature(project)) { |
|
553 |
projects.add(project); |
|
554 |
} |
|
555 |
} |
|
556 |
} |
|
557 |
} |
|
558 |
||
559 |
return projects; |
|
560 |
} |
|
561 |
||
562 |
private void scheduleRefresh() { |
|
563 |
trace("scheduleRefresh called at " + getStringFromTimestamp(System.currentTimeMillis())); |
|
564 |
||
565 |
refreshJob.cancel(); |
|
566 |
refreshJob.schedule(); |
|
567 |
} |
|
568 |
||
569 |
private IProjectExecutablesProvider getExecutablesProviderForProject(IProject project) { |
|
570 |
IProjectExecutablesProvider provider = executablesProviderMap.get(project); |
|
571 |
if (provider == null) { |
|
572 |
// not cached yet. get the list of project natures from the providers and |
|
573 |
// pick the one with the closest match |
|
574 |
try { |
|
575 |
IProjectDescription description = project.getDescription(); |
|
576 |
int mostNaturesMatched = 0; |
|
577 |
for (IProjectExecutablesProvider exeProvider : executableProviders) { |
|
578 |
List<String> natures = exeProvider.getProjectNatures(); |
|
579 |
||
580 |
int naturesMatched = 0; |
|
581 |
for (String nature : description.getNatureIds()) { |
|
582 |
if (natures.contains(nature)) { |
|
583 |
naturesMatched++; |
|
584 |
} |
|
585 |
} |
|
586 |
||
587 |
if (naturesMatched > mostNaturesMatched) { |
|
588 |
provider = exeProvider; |
|
589 |
mostNaturesMatched = naturesMatched; |
|
590 |
} |
|
591 |
} |
|
592 |
||
593 |
// cache it |
|
594 |
executablesProviderMap.put(project, provider); |
|
595 |
||
596 |
} catch (CoreException e) { |
|
597 |
e.printStackTrace(); |
|
598 |
} |
|
599 |
} |
|
600 |
||
601 |
return provider; |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
602 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
603 |
|
14 | 604 |
private void loadExecutableProviderExtensions() { |
605 |
executableProviders = Collections.synchronizedList(new ArrayList<IProjectExecutablesProvider>()); |
|
606 |
||
607 |
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); |
|
608 |
IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(CDebugCorePlugin.PLUGIN_ID + ".ExecutablesProvider"); //$NON-NLS-1$ |
|
609 |
IExtension[] extensions = extensionPoint.getExtensions(); |
|
610 |
||
611 |
for (int i = 0; i < extensions.length; i++) { |
|
612 |
IExtension extension = extensions[i]; |
|
613 |
IConfigurationElement[] elements = extension.getConfigurationElements(); |
|
614 |
IConfigurationElement element = elements[0]; |
|
615 |
||
616 |
boolean failed = false; |
|
617 |
try { |
|
618 |
Object extObject = element.createExecutableExtension("class"); //$NON-NLS-1$ |
|
619 |
if (extObject instanceof IProjectExecutablesProvider) { |
|
620 |
executableProviders.add((IProjectExecutablesProvider)extObject); |
|
621 |
} else { |
|
622 |
failed = true; |
|
623 |
} |
|
624 |
} |
|
625 |
catch (CoreException e) { |
|
626 |
failed = true; |
|
627 |
} |
|
628 |
||
629 |
if (failed) { |
|
630 |
CDebugCorePlugin.log("Unable to load ExecutablesProvider extension from " + extension.getContributor().getName()); |
|
631 |
} |
|
632 |
} |
|
633 |
} |
|
634 |
||
635 |
private void loadSoureFileProviderExtensions() { |
|
636 |
sourceFileProviders = Collections.synchronizedList(new ArrayList<ISourceFilesProvider>()); |
|
637 |
||
638 |
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); |
|
639 |
IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(CDebugCorePlugin.PLUGIN_ID + ".SourceFilesProvider"); //$NON-NLS-1$ |
|
640 |
IExtension[] extensions = extensionPoint.getExtensions(); |
|
641 |
||
642 |
for (int i = 0; i < extensions.length; i++) { |
|
643 |
IExtension extension = extensions[i]; |
|
644 |
IConfigurationElement[] elements = extension.getConfigurationElements(); |
|
645 |
IConfigurationElement element = elements[0]; |
|
646 |
||
647 |
boolean failed = false; |
|
648 |
try { |
|
649 |
Object extObject = element.createExecutableExtension("class"); //$NON-NLS-1$ |
|
650 |
if (extObject instanceof ISourceFilesProvider) { |
|
651 |
sourceFileProviders.add((ISourceFilesProvider)extObject); |
|
652 |
} else { |
|
653 |
failed = true; |
|
654 |
} |
|
655 |
} |
|
656 |
catch (CoreException e) { |
|
657 |
failed = true; |
|
658 |
} |
|
659 |
||
660 |
if (failed) { |
|
661 |
CDebugCorePlugin.log("Unable to load SourceFilesProvider extension from " + extension.getContributor().getName()); |
|
662 |
} |
|
663 |
} |
|
0
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
664 |
} |
0e6d23e2b466
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
665 |
|
14 | 666 |
private void loadSoureRemappingExtensions() { |
667 |
sourceFileRemappings = Collections.synchronizedList(new ArrayList<ISourceFileRemapping>()); |
|
668 |
||
669 |
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); |
|
670 |
IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(CDebugCorePlugin.PLUGIN_ID + ".SourceRemappingProvider"); //$NON-NLS-1$ |
|
671 |
IExtension[] extensions = extensionPoint.getExtensions(); |
|
672 |
||
673 |
for (int i = 0; i < extensions.length; i++) { |
|
674 |
IExtension extension = extensions[i]; |
|
675 |
IConfigurationElement[] elements = extension.getConfigurationElements(); |
|
676 |
IConfigurationElement element = elements[0]; |
|
677 |
||
678 |
boolean failed = false; |
|
679 |
try { |
|
680 |
Object extObject = element.createExecutableExtension("class"); //$NON-NLS-1$ |
|
681 |
if (extObject instanceof ISourceFileRemapping) { |
|
682 |
sourceFileRemappings.add((ISourceFileRemapping)extObject); |
|
683 |
} else { |
|
684 |
failed = true; |
|
685 |
} |
|
686 |
} |
|
687 |
catch (CoreException e) { |
|
688 |
failed = true; |
|
689 |
} |
|
690 |
||
691 |
if (failed) { |
|
692 |
CDebugCorePlugin.log("Unable to load SourceRemappingProvider extension from " + extension.getContributor().getName()); |
|
693 |
} |
|
694 |
} |
|
695 |
} |
|
696 |
||
697 |
private void loadExecutableImporterExtensions() { |
|
698 |
executableImporters = Collections.synchronizedList(new ArrayList<IExecutableImporter>()); |
|
699 |
||
700 |
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); |
|
701 |
IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(CDebugCorePlugin.PLUGIN_ID + ".ExecutablesImporter"); //$NON-NLS-1$ |
|
702 |
IExtension[] extensions = extensionPoint.getExtensions(); |
|
703 |
||
704 |
for (int i = 0; i < extensions.length; i++) { |
|
705 |
IExtension extension = extensions[i]; |
|
706 |
IConfigurationElement[] elements = extension.getConfigurationElements(); |
|
707 |
IConfigurationElement element = elements[0]; |
|
708 |
||
709 |
boolean failed = false; |
|
710 |
try { |
|
711 |
Object extObject = element.createExecutableExtension("class"); //$NON-NLS-1$ |
|
712 |
if (extObject instanceof IExecutableImporter) { |
|
713 |
executableImporters.add((IExecutableImporter)extObject); |
|
714 |
} else { |
|
715 |
failed = true; |
|
716 |
} |
|
717 |
} |
|
718 |
catch (CoreException e) { |
|
719 |
failed = true; |
|
720 |
} |
|
721 |
||
722 |
if (failed) { |
|
723 |
CDebugCorePlugin.log("Unable to load ExecutablesImporter extension from " + extension.getContributor().getName()); |
|
724 |
} |
|
725 |
} |
|
726 |
} |
|
727 |
||
728 |
private void trace(String msg) { |
|
729 |
if (DEBUG) { |
|
730 |
// TODO use Logger? |
|
731 |
System.out.println(msg); |
|
732 |
} |
|
733 |
} |
|
734 |
||
735 |
private String getStringFromTimestamp(long timestamp) { |
|
736 |
return DateFormat.getTimeInstance(DateFormat.MEDIUM).format(new Date(timestamp)); |
|
737 |
} |
|
738 |
} |