cdt/cdt_5_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java
changeset 24 b00fe9004252
parent 23 7357eeb2874f
equal deleted inserted replaced
23:7357eeb2874f 24:b00fe9004252
   189 		changeListeners.remove(listener);
   189 		changeListeners.remove(listener);
   190 	}
   190 	}
   191 
   191 
   192 	/**
   192 	/**
   193 	 * Gets the list of executables in the workspace.
   193 	 * Gets the list of executables in the workspace.
       
   194 	 * @param wait whether or not to wait if the list is being refreshed when this
       
   195 	 * method is called.  when true, this call will not return until the list is
       
   196 	 * complete.  when false, it will return with the last known list.  if calling
       
   197 	 * from any UI, you should not block the UI waiting for this to return, but rather
       
   198 	 * register as an {@link IExecutablesChangeListener} to get notifications when the
       
   199 	 * list changes.
   194 	 * @return the list of executables which may be empty
   200 	 * @return the list of executables which may be empty
   195 	 */
   201 	 */
   196 	public Collection<Executable> getExecutables() {
   202 	public Collection<Executable> getExecutables(boolean wait) {
   197 		
   203 		
   198 		trace("getExecutables called at " + getStringFromTimestamp(System.currentTimeMillis()));
   204 		trace("getExecutables called at " + getStringFromTimestamp(System.currentTimeMillis()));
   199 
   205 
   200 		List<Executable> executables = new ArrayList<Executable>();
   206 		List<Executable> executables = new ArrayList<Executable>();
   201 
   207 
       
   208 		if (wait && refreshJob.getState() != Job.NONE) {
       
   209 			trace("waiting for refresh job to finish at " + getStringFromTimestamp(System.currentTimeMillis()));
       
   210 			try {
       
   211 				refreshJob.join();
       
   212 			} catch (InterruptedException e) {
       
   213 			}
       
   214 			trace("refresh job finished at " + getStringFromTimestamp(System.currentTimeMillis()));
       
   215 		}
       
   216 		
   202 		synchronized (executablesMap) {
   217 		synchronized (executablesMap) {
   203 			for (List<Executable> exes : executablesMap.values()) {
   218 			for (List<Executable> exes : executablesMap.values()) {
   204 				for (Executable exe : exes) {
   219 				for (Executable exe : exes) {
   205 					if (!executables.contains(exe)) {
   220 					if (!executables.contains(exe)) {
   206 						executables.add(exe);
   221 						executables.add(exe);
   212 		trace("getExecutables returned at " + getStringFromTimestamp(System.currentTimeMillis()));
   227 		trace("getExecutables returned at " + getStringFromTimestamp(System.currentTimeMillis()));
   213 
   228 
   214 		return executables;
   229 		return executables;
   215 	}
   230 	}
   216 
   231 
       
   232 	/**
       
   233 	 * Gets the list of executables in the workspace.  Equivalent to {@link ExecutablesManager}{@link #getExecutables(false)}.
       
   234 	 * Just kept for older API compatibility.
       
   235 	 * @return the list of executables which may be empty
       
   236 	 */
       
   237 	public Collection<Executable> getExecutables() {
       
   238 		return getExecutables(false);
       
   239 	}
       
   240 	
   217 	/**
   241 	/**
   218 	 * Gets the collection of executables for the given project
   242 	 * Gets the collection of executables for the given project
   219 	 * @param project the project
   243 	 * @param project the project
   220 	 * @return collection of executables which may be empty
   244 	 * @return collection of executables which may be empty
   221 	 */
   245 	 */