executables view changes
authorwpaul
Mon, 01 Jun 2009 19:15:12 -0500
changeset 194 5dd39ff8dbd0
parent 180 b9966f222431
child 195 ab6393bd82aa
executables view changes
debuggercdi/com.nokia.cdt.debug.cw.symbian/plugin.xml
debuggercdi/com.nokia.cdt.debug.cw.symbian/src/com/nokia/cdt/debug/cw/symbian/CarbideExecutableImporter.java
debuggercdi/com.nokia.cdt.debug.cw.symbian/src/com/nokia/cdt/debug/cw/symbian/CarbideExecutablesProvider.java
debuggercdi/com.nokia.cdt.debug.cw.symbian/src/com/nokia/cdt/debug/cw/symbian/ui/executables/CarbideSourceFilesProvider.java
debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/CarbideSourceFilesProvider.java
debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/LaunchPlugin.java
debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/NokiaAbstractLaunchDelegate.java
debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/ui/ExecutablesTab.java
--- a/debuggercdi/com.nokia.cdt.debug.cw.symbian/plugin.xml	Wed May 20 17:31:27 2009 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.cw.symbian/plugin.xml	Mon Jun 01 19:15:12 2009 -0500
@@ -183,5 +183,21 @@
          </action>
       </viewerContribution>
    </extension>   
-    
+
+   <!-- *************** Executables manager extensions **************** -->
+   <extension
+       point="org.eclipse.cdt.debug.core.ExecutablesProvider">
+      <provider class="com.nokia.cdt.debug.cw.symbian.CarbideExecutablesProvider"/>
+   </extension>
+
+   <extension
+       point="org.eclipse.cdt.debug.core.SourceFilesProvider">
+      <provider class="com.nokia.cdt.debug.cw.symbian.ui.executables.CarbideSourceFilesProvider"/>
+   </extension>
+
+   <extension
+       point="org.eclipse.cdt.debug.core.SourceRemappingProvider">
+      <provider class="com.nokia.cdt.debug.cw.symbian.ui.executables.SymbianSourceFileRemapping"/>
+   </extension>
+
 </plugin>
--- a/debuggercdi/com.nokia.cdt.debug.cw.symbian/src/com/nokia/cdt/debug/cw/symbian/CarbideExecutableImporter.java	Wed May 20 17:31:27 2009 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of the License "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
-
-package com.nokia.cdt.debug.cw.symbian;
-
-import org.eclipse.cdt.debug.core.executables.StandardExecutableImporter;
-import org.eclipse.core.runtime.IPath;
-
-public class CarbideExecutableImporter extends StandardExecutableImporter {
-
-	private CarbideExecutablesProvider exeProvider;
-
-	public CarbideExecutableImporter(CarbideExecutablesProvider provider ) {
-		exeProvider = provider;
-	}
-
-	@Override
-	public boolean AllowImport(IPath path) {
-		if ( super.AllowImport(path) )
-		{
-			 return (!exeProvider.executableExists(path));			
-		}
-		return false;
-	}
-
-	public int getPriority(String[] fileNames) {
-		return HIGH_PRIORITY;
-	}
-
-}
--- a/debuggercdi/com.nokia.cdt.debug.cw.symbian/src/com/nokia/cdt/debug/cw/symbian/CarbideExecutablesProvider.java	Wed May 20 17:31:27 2009 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.cw.symbian/src/com/nokia/cdt/debug/cw/symbian/CarbideExecutablesProvider.java	Mon Jun 01 19:15:12 2009 -0500
@@ -21,139 +21,80 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.core.CProjectNature;
 import org.eclipse.cdt.debug.core.executables.Executable;
-import org.eclipse.cdt.debug.core.executables.ExecutablesManager;
-import org.eclipse.cdt.debug.core.executables.StandardExecutableProvider;
+import org.eclipse.cdt.debug.core.executables.IProjectExecutablesProvider;
 import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.core.runtime.jobs.IJobChangeListener;
-import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
 
 import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin;
 import com.nokia.carbide.cdt.builder.EpocEngineHelper;
-import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration;
 import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo;
 
-public class CarbideExecutablesProvider extends StandardExecutableProvider implements IJobChangeListener {
+public class CarbideExecutablesProvider implements IProjectExecutablesProvider {
 
-	private ArrayList<Executable> executables = new ArrayList<Executable>();
-	private ArrayList<Executable> activeExecutables = new ArrayList<Executable>();
+	List<String> supportedNatureIds = new ArrayList<String>();
 
 	public CarbideExecutablesProvider() {
-		super();
-		Job.getJobManager().addJobChangeListener(this);		
-	}
-
-	public int getPriority() {
-		return HIGH_PRIORITY;
+		supportedNatureIds.add(CProjectNature.C_NATURE_ID);
+		supportedNatureIds.add(CCProjectNature.CC_NATURE_ID);
+		supportedNatureIds.add(CarbideBuilderPlugin.CARBIDE_PROJECT_NATURE_ID);
+		supportedNatureIds.add(CarbideBuilderPlugin.CARBIDE_SBSV2_PROJECT_NATURE_ID);
 	}
-
-	public boolean executableExists(IPath exePath) {
-		for (Executable executable : executables) {
-			if (executable.getPath().equals(exePath))
-				return true;
-		}
-		return false;
+	
+	public List<String> getProjectNatures() {
+		return supportedNatureIds;
 	}
 
-	public Executable[] getExecutables(IProgressMonitor monitor) {
+	public List<Executable> getExecutables(IProject project, IProgressMonitor monitor) {
+		List<Executable> executables = new ArrayList<Executable>();
 
-		synchronized (executables) {
-			executables.clear();
-			activeExecutables.clear();
-			
-			IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
-			IProject[] projects = root.getProjects();
+		if (CarbideBuilderPlugin.getBuildManager().isCarbideProject(project)) {
+			ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(project);
+			if (cpi != null) {
+				List<IPath> mmps = EpocEngineHelper.getMMPFilesForBuildConfiguration(cpi.getDefaultConfiguration());
 
-			monitor.beginTask("Checking Carbide Projects", projects.length);
-
-			for (IProject project : projects) {
-
-				if (monitor.isCanceled())
-					break;
+				SubMonitor progress = SubMonitor.convert(monitor, mmps.size());
 
-				try {
-					if (CarbideBuilderPlugin.getBuildManager().isCarbideProject(project)) {
-						ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(project);
-						if (cpi != null) {
-							ICarbideBuildConfiguration defaultConfig = cpi.getDefaultConfiguration();
-							List<ICarbideBuildConfiguration> buildConfigList = cpi.getBuildConfigurations();
-							for (ICarbideBuildConfiguration currConfig : buildConfigList) {
-								if (monitor.isCanceled())
-									break;
+				for (IPath mmp : mmps) {
+					if (progress.isCanceled()) {
+						break;
+					}
+					
+					progress.subTask("Parsing " + mmp.lastSegment());
 
-								for (IPath mmp : EpocEngineHelper.getMMPFilesForBuildConfiguration(currConfig)) {
-									if (monitor.isCanceled())
-										break;
-
-									IPath hp = EpocEngineHelper.getHostPathForExecutable(currConfig, mmp);
-									if (hp != null) {
-										File hpFile = hp.toFile();
-										if (hpFile.exists())
-										{
-											Executable exe = new Executable(new Path(hpFile.getCanonicalPath()), project, null);
-											executables.add(exe);
-											if (currConfig == defaultConfig)
-												activeExecutables.add(exe);										
-										}
-									}
-								}
+ 					IPath hp = EpocEngineHelper.getHostPathForExecutable(cpi.getDefaultConfiguration(), mmp);
+					if (hp != null) {
+						File hpFile = hp.toFile();
+						if (hpFile.exists()) {
+							try {
+								Executable exe = new Executable(new Path(hpFile.getCanonicalPath()), project, null);
+								executables.add(exe);
+							} catch (Exception e) {
 							}
 						}
-
 					}
-				} catch (Exception e) {
-					e.printStackTrace();
-				}
-				monitor.worked(1);
-			}
-
-			monitor.done();
-		}
-		return activeExecutables.toArray(new Executable[activeExecutables.size()]);
-	}
-
-	public void aboutToRun(IJobChangeEvent event) {}
-
-	public void awake(IJobChangeEvent event) {}
-
-	/**
-	 * This is the lower case name of the build job for "Build Target Only". This is used here to avoid
-	 * having a reference to com.nokia.cdt.carbide.builder.utils.
-	 * @see com.nokia.carbide.cdt.build.utils.popup.actions.AbldCommandAction#runAbldActionOnProject(...)
-	 */
-	private static final String BUILD_TARGET_ONLY_JOB_NAME_LOWER = "performing targeted build for configuration";
-	
-	/**
-	 * This is the lower case name of the build job for "Build Symbian Component". This is used here to avoid
-	 * having a reference to com.nokia.cdt.carbide.builder.utils.
-	 * @see com.nokia.carbide.cdt.build.utils.popup.actions.AbldCommandAction#doBuildSingleMMPComponent(...)
-	 */
-	private static final String BUILD_SYMBIAN_COMPONENT_JOB_NAME_LOWER = "building selected component";
-
-	private static final String BUILD_ALL_CONFIGURATIONS_JOB_NAME_LOWER = "building all configurations for project";
-
-	public void done(IJobChangeEvent event) {
-
-		if (event.getJob().belongsTo(ResourcesPlugin.FAMILY_MANUAL_BUILD) ||
-				event.getJob().getName().toLowerCase().startsWith(BUILD_TARGET_ONLY_JOB_NAME_LOWER) ||
-				event.getJob().getName().toLowerCase().startsWith(BUILD_ALL_CONFIGURATIONS_JOB_NAME_LOWER) ||
-				event.getJob().getName().toLowerCase().startsWith(BUILD_SYMBIAN_COMPONENT_JOB_NAME_LOWER)) {
-				{
-					ExecutablesManager.getExecutablesManager().scheduleRefresh(this, 1000);
+					
+					progress.worked(1);
 				}
 			}
 		}
-
-	public void running(IJobChangeEvent event) {}
+		
+		return executables;
+	}
 
-	public void scheduled(IJobChangeEvent event) {}
-
-	public void sleeping(IJobChangeEvent event) {}
-
+	public IStatus removeExecutable(Executable executable, IProgressMonitor monitor) {
+		try {
+			executable.getPath().toFile().delete();
+		} catch (Exception e) {
+			return new Status(IStatus.WARNING, SymbianPlugin.PLUGIN_ID, "An error occured trying to delete " + executable.getPath().toOSString());
+		}
+		return Status.OK_STATUS;
+	}
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debuggercdi/com.nokia.cdt.debug.cw.symbian/src/com/nokia/cdt/debug/cw/symbian/ui/executables/CarbideSourceFilesProvider.java	Mon Jun 01 19:15:12 2009 -0500
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+package com.nokia.cdt.debug.cw.symbian.ui.executables;
+
+import java.util.ArrayList;
+
+import org.eclipse.cdt.debug.core.executables.Executable;
+import org.eclipse.cdt.debug.core.executables.ISourceFilesProvider;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.PlatformObject;
+
+import com.nokia.cdt.debug.cw.symbian.symbolreader.ISymbolFile;
+import com.nokia.cdt.debug.cw.symbian.symbolreader.SymbolReaderManager;
+
+public class CarbideSourceFilesProvider extends PlatformObject implements
+		ISourceFilesProvider {
+
+	public String[] getSourceFiles(Executable executable,
+			IProgressMonitor monitor) {	
+		ArrayList<String> sourceFiles = new ArrayList<String>();
+		ISymbolFile symFile = SymbolReaderManager.getSymbolReaderManager().openSymbolFile(executable.getPath().toOSString());
+		String[] sourceArray = symFile.getSourceFiles();
+		symFile.close();
+		return sourceArray;
+	}
+
+	public int getPriority(Executable executable) {
+		return ISourceFilesProvider.HIGH_PRIORITY;
+	}
+
+}
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/CarbideSourceFilesProvider.java	Wed May 20 17:31:27 2009 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of the License "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
-package com.nokia.cdt.internal.debug.launch;
-
-import java.util.ArrayList;
-
-import org.eclipse.cdt.debug.core.executables.Executable;
-import org.eclipse.cdt.debug.core.executables.ISourceFilesProvider;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.PlatformObject;
-
-import com.nokia.cdt.debug.cw.symbian.symbolreader.ISymbolFile;
-import com.nokia.cdt.debug.cw.symbian.symbolreader.SymbolReaderManager;
-
-public class CarbideSourceFilesProvider extends PlatformObject implements
-		ISourceFilesProvider {
-
-	public String[] getSourceFiles(Executable executable,
-			IProgressMonitor monitor) {	
-		ArrayList<String> sourceFiles = new ArrayList<String>();
-		ISymbolFile symFile = SymbolReaderManager.getSymbolReaderManager().openSymbolFile(executable.getPath().toOSString());
-		String[] sourceArray = symFile.getSourceFiles();
-		symFile.close();
-		return sourceArray;
-	}
-
-	public int getPriority(Executable executable) {
-		return ISourceFilesProvider.HIGH_PRIORITY;
-	}
-
-}
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/LaunchPlugin.java	Wed May 20 17:31:27 2009 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/LaunchPlugin.java	Mon Jun 01 19:15:12 2009 -0500
@@ -21,7 +21,6 @@
 import org.eclipse.cdt.core.model.*;
 import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
 import org.eclipse.cdt.debug.core.executables.Executable;
-import org.eclipse.cdt.debug.core.executables.ExecutablesManager;
 import org.eclipse.cdt.ui.CUIPlugin;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.*;
@@ -46,10 +45,8 @@
 import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo;
 import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext;
 import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
-import com.nokia.carbide.remoteconnections.interfaces.IConnectionTypeProvider;
 import com.nokia.carbide.remoteconnections.interfaces.IService;
 import com.nokia.cdt.debug.cw.symbian.*;
-import com.nokia.cdt.debug.cw.symbian.ui.executables.SymbianSourceFileRemapping;
 import com.nokia.cdt.internal.debug.launch.wizard.LaunchCreationWizard;
 import com.nokia.cpp.internal.api.utils.core.Logging;
 
@@ -435,15 +432,6 @@
 			@Override
 			public IStatus runInUIThread(IProgressMonitor monitor) {
 				listenForVariablesView();
-				
-				CarbideExecutablesProvider provider = new CarbideExecutablesProvider();
-				ExecutablesManager em = ExecutablesManager.getExecutablesManager();
-				em.addSourceFileRemapping(new SymbianSourceFileRemapping());
-				em.addExecutablesProvider(provider);
-				em.addExecutableImporter(new CarbideExecutableImporter(provider));
-				em.scheduleRefresh(provider, 0);
-				em.addSourceFilesProvider(new CarbideSourceFilesProvider());
-				
 				return Status.OK_STATUS;
 			}};
 			earlyJob.schedule();
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/NokiaAbstractLaunchDelegate.java	Wed May 20 17:31:27 2009 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/NokiaAbstractLaunchDelegate.java	Mon Jun 01 19:15:12 2009 -0500
@@ -30,7 +30,6 @@
 import org.eclipse.cdt.core.model.CModelException;
 import org.eclipse.cdt.core.model.IBinary;
 import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.debug.core.executables.ExecutablesManager;
 import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
 import org.eclipse.cdt.ui.CUIPlugin;
 import org.eclipse.core.resources.IProject;
@@ -221,7 +220,6 @@
 	protected IPath[] getOtherExecutables(ICProject project, IPath exePath,
 			ILaunchConfiguration config, IProgressMonitor monitor) throws CModelException {
 		ArrayList<IPath> targetedBinaries = new ArrayList<IPath>();
-		ExecutablesManager.getExecutablesManager().setRefreshNeeded(true);
 		targetedBinaries.addAll(getBldInfExecutables(project, exePath, config, monitor));
 		return (IPath[]) targetedBinaries.toArray(new IPath[targetedBinaries
 				.size()]);
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/ui/ExecutablesTab.java	Wed May 20 17:31:27 2009 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/ui/ExecutablesTab.java	Mon Jun 01 19:15:12 2009 -0500
@@ -26,7 +26,6 @@
 import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
 import org.eclipse.cdt.debug.core.executables.Executable;
 import org.eclipse.cdt.debug.core.executables.ExecutablesManager;
-import org.eclipse.cdt.debug.core.executables.IExecutablesChangeEvent;
 import org.eclipse.cdt.debug.core.executables.IExecutablesChangeListener;
 import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
 import org.eclipse.cdt.launch.ui.CLaunchConfigurationTab;
@@ -124,7 +123,7 @@
 
 	public ExecutablesTab(boolean supportsTargetAll) {
 		this.supportsTargetAll = supportsTargetAll;
-		executablesToTarget = Collections.EMPTY_LIST; // avoid NPE if accessed before filled
+		executablesToTarget = Collections.emptyList(); // avoid NPE if accessed before filled
 	}
 
 	/* (non-Javadoc)
@@ -401,14 +400,12 @@
 		try {
 			String launchExeName = AbstractCLaunchDelegate.getProgramName(configuration);
 			if (launchExeName == null)
-				return Collections.EMPTY_LIST;
+				return Collections.emptyList();
 			
 			// ignore 'urel', 'udeb' and 'lib' directories when getting the binaries for the same target
 			// removeLastSegments(2) will strip the filename and 'urel', 'udeb' or 'lib'
 			IPath launchExeTargetPath = new Path(new File(launchExeName).getCanonicalPath()).removeLastSegments(2); 
-			Executable[] exes = ExecutablesManager.getExecutablesManager().getExecutables();
-			for (int i = 0; i < exes.length; i++) {
-				Executable executable = exes[i];
+			for (Executable executable : ExecutablesManager.getExecutablesManager().getExecutables()) {
 				IPath exePath = executable.getPath();
 				if (launchExeTargetPath.isPrefixOf(exePath))
 						files.add(new ExeFileToDebug(exePath.toOSString(), true));
@@ -447,11 +444,14 @@
 		getControl().setFocus();
 	}
 
-	public void executablesChanged(IExecutablesChangeEvent event) {
-		changeTargetingRule(targetingRule);
-	}
-
 	public ILaunchConfiguration getLaunchConfiguration() {
 		return configuration;
 	}
+
+	public void executablesChanged(List<Executable> executables) {
+	}
+
+	public void executablesListChanged() {
+		changeTargetingRule(targetingRule);
+	}
 }