Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 117150 Details for
Bug 245565
Importing a plug-in as binary project should not extract the source bundle
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Work in progress
clipboard.txt (text/plain), 39.21 KB, created by
Curtis Windatt
on 2008-11-05 17:44:22 EST
(
hide
)
Description:
Work in progress
Filename:
MIME Type:
Creator:
Curtis Windatt
Created:
2008-11-05 17:44:22 EST
Size:
39.21 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.ui >Index: src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportWizard.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportWizard.java,v >retrieving revision 1.52 >diff -u -r1.52 PluginImportWizard.java >--- src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportWizard.java 11 Jan 2008 20:00:06 -0000 1.52 >+++ src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportWizard.java 5 Nov 2008 22:41:40 -0000 >@@ -136,7 +136,7 @@ > PluginImportOperation.IImportQuery query = new ImportQuery(shell); > PluginImportOperation.IImportQuery executionQuery = new ImportQuery(shell); > final PluginImportOperation op = new PluginImportOperation(models, importType, query, executionQuery, forceAutobuild); >- op.setLaunchedConfiguration(launchedConfiguration); >+ op.setPluginsInUse(launchedConfiguration); > Job job = new Job(PDEUIMessages.ImportWizard_title) { > protected IStatus run(IProgressMonitor monitor) { > try { >Index: src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportOperation.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportOperation.java,v >retrieving revision 1.122 >diff -u -r1.122 PluginImportOperation.java >--- src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportOperation.java 24 Oct 2008 14:55:21 -0000 1.122 >+++ src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportOperation.java 5 Nov 2008 22:41:40 -0000 >@@ -38,7 +38,6 @@ > import org.eclipse.pde.internal.core.util.CoreUtility; > import org.eclipse.pde.internal.ui.PDEPlugin; > import org.eclipse.pde.internal.ui.PDEUIMessages; >-import org.eclipse.swt.widgets.Display; > import org.eclipse.team.core.RepositoryProvider; > import org.eclipse.team.core.TeamException; > import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider; >@@ -63,11 +62,7 @@ > private boolean fForceAutobuild; > private IImportQuery fExecutionQuery; > >- private boolean fLaunchedConfigurations = false; >- /** >- * A list of plugins that were unable to be deleted >- */ >- private ArrayList fUnableToDeletePlugins; >+ private boolean fPluginsAreInUse = false; > > public interface IImportQuery { > public static final int CANCEL = 0; >@@ -83,26 +78,25 @@ > * @param importType one of three types specified by constants, binary, binary with links, source > * @param replaceQuery defines what to do if the project already exists in the workspace > * @param executionQuery defines what to do if the project requires an unsupported execution environment >+ * @param forceAutobuild whether to force a build after the import > */ >- public PluginImportOperation(IPluginModelBase[] models, int importType, IImportQuery replaceQuery, IImportQuery executionQuery) { >+ public PluginImportOperation(IPluginModelBase[] models, int importType, IImportQuery replaceQuery, IImportQuery executionQuery, boolean forceAutobuild) { > fModels = models; > fImportType = importType; > fReplaceQuery = replaceQuery; > fExecutionQuery = executionQuery; >- fUnableToDeletePlugins = new ArrayList(); >+ fForceAutobuild = forceAutobuild; > } > > /** >- * Constructor >- * @param models models of plugins to import >- * @param importType one of three types specified by constants, binary, binary with links, source >- * @param replaceQuery defines what to do if the project already exists in the workspace >- * @param executionQuery defines what to do if the project requires an unsupported execution environment >- * @param forceAutobuild whether to force a build after the import >+ * Sets whether some of the plug-ins being imported are currently in use by a launched >+ * Eclipse instance. Setting this to true will force an additional check before deleting >+ * a plug-in. >+ * @param pluginsInUse > */ >- public PluginImportOperation(IPluginModelBase[] models, int importType, IImportQuery replaceQuery, IImportQuery executionQuery, boolean forceAutobuild) { >- this(models, importType, replaceQuery, executionQuery); >- fForceAutobuild = forceAutobuild; >+ public void setPluginsInUse(boolean pluginsInUse) { >+ // TODO Determine if this is actually necessary. >+ fPluginsAreInUse = pluginsInUse; > } > > /* (non-Javadoc) >@@ -123,55 +117,24 @@ > multiStatus.merge(e.getStatus()); > } > if (monitor.isCanceled()) { >+// TODO Set classpaths individually > setClasspaths(new SubProgressMonitor(monitor, 1)); > throw new OperationCanceledException(); > } > } >+// TODO Set classpaths individually? > setClasspaths(new SubProgressMonitor(monitor, 1)); > if (!ResourcesPlugin.getWorkspace().isAutoBuilding() && fForceAutobuild) > runBuildJob(); >+ // TODO Test that non-deleted plug-ins throw nice error status > if (!multiStatus.isOK()) > throw new CoreException(multiStatus); > } finally { > monitor.done(); >- if (!fUnableToDeletePlugins.isEmpty()) { >- final Display display = Display.getDefault(); >- display.syncExec(new Runnable() { >- public void run() { >- PluginImportFinishDialog dialog = new PluginImportFinishDialog(display.getActiveShell()); >- dialog.setTitle(PDEUIMessages.PluginImportInfoDialog_title); >- dialog.setMessage(PDEUIMessages.PluginImportInfoDialog_message); >- dialog.setInput(fUnableToDeletePlugins); >- dialog.open(); >- } >- >- }); >- } > } > } > > /** >- * Starts a job that will build the workspace >- */ >- private void runBuildJob() { >- Job buildJob = new Job(PDEUIMessages.CompilersConfigurationBlock_building) { >- public boolean belongsTo(Object family) { >- return ResourcesPlugin.FAMILY_AUTO_BUILD == family; >- } >- >- protected IStatus run(IProgressMonitor monitor) { >- try { >- PDEPlugin.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); >- } catch (CoreException e) { >- } >- return Status.OK_STATUS; >- } >- }; >- buildJob.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule()); >- buildJob.schedule(); >- } >- >- /** > * Sets the raw classpath of projects that need to be updated > * @param monitor > * @throws JavaModelException if a classpath could not be set >@@ -197,54 +160,18 @@ > */ > private void importPlugin(IPluginModelBase model, IProgressMonitor monitor) throws CoreException { > String id = model.getPluginBase().getId(); >- monitor.beginTask(NLS.bind(PDEUIMessages.ImportWizard_operation_creating2, id), 6); > try { >- BundleDescription desc = model.getBundleDescription(); >- if (desc != null) { >- IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager(); >- String[] envs = desc.getExecutionEnvironments(); >- boolean found = false; >- for (int i = 0; i < envs.length; i++) { >- if (manager.getEnvironment(envs[i]) != null) { >- found = true; >- break; >- } >- } >- if (envs.length > 0 && !found) { >- String message = NLS.bind(PDEUIMessages.PluginImportOperation_executionEnvironment, id, envs[0]); >- if (!queryExecutionEnvironment(message)) >- return; >- } >- } >- >- IProject project = findProject(id); >+ monitor.beginTask(NLS.bind(PDEUIMessages.ImportWizard_operation_creating2, id), 6); > >- if (project.exists() || new File(project.getParent().getLocation().toFile(), project.getName()).exists()) { >- if (!queryReplace(project)) >- return; >- if (RepositoryProvider.isShared(project)) >- RepositoryProvider.unmap(project); >- if (!project.exists()) >- project.create(new SubProgressMonitor(monitor, 1)); >- if (!safeDeleteCheck(project, monitor)) { >- fUnableToDeletePlugins.add(model); >- return; >- } >- try { >- project.delete(true, true, monitor); >- } catch (CoreException e) { >- fUnableToDeletePlugins.add(model); >- return; >- } >+ // Test is the required execution environment is supported >+ if (!testExecutionEnvironment(model)) { >+ return; > } >+ // Create the project or ask to overwrite if project exists >+ IProject project = createProject(model, new SubProgressMonitor(monitor, 1)); > >- project.create(monitor); >- if (!project.isOpen()) >- project.open(monitor); >- monitor.worked(1); >- >+ // Target Weaving: if we are importing plug-ins in the runtime workbench from the host workbench, import everything as-is and return > if (Platform.inDevelopmentMode()) { >- // if we are importing plug-ins in the runtime workbench from the host workbench, import everything as-is and return > File location = new File(model.getInstallLocation()); > if (location.isDirectory()) { > File classpathFile = new File(location, ".classpath"); //$NON-NLS-1$ >@@ -256,31 +183,77 @@ > } > } > >+ // Perform the import >+ Map sourceMap = null; > switch (fImportType) { > case IMPORT_BINARY : >- importAsBinary(project, model, true, new SubProgressMonitor(monitor, 4)); >+ sourceMap = importAsBinary(project, model, new SubProgressMonitor(monitor, 4)); > break; > case IMPORT_BINARY_WITH_LINKS : > if (id.startsWith("org.eclipse.swt") && !isJARd(model)) { //$NON-NLS-1$ >- importAsBinary(project, model, true, monitor); >+ importAsBinary(project, model, monitor); > } else { > importAsBinaryWithLinks(project, model, new SubProgressMonitor(monitor, 4)); > } > break; > case IMPORT_WITH_SOURCE : > if (isExempt(model)) { >- importAsBinary(project, model, true, new SubProgressMonitor(monitor, 4)); >+ importAsBinary(project, model, new SubProgressMonitor(monitor, 4)); > } else { > importAsSource(project, model, new SubProgressMonitor(monitor, 4)); > } > } > >- setProjectDescription(project, model); >+ setProjectNatures(project, model); > >+ // Set the classpath > if (project.hasNature(JavaCore.NATURE_ID) && project.findMember(".classpath") == null) //$NON-NLS-1$ >- fProjectClasspaths.put(project, ClasspathComputer.getClasspath(project, model, true, false)); >- } catch (CoreException e) { >- PDEPlugin.logException(e); >+ fProjectClasspaths.put(project, ClasspathComputer.getClasspath(project, model, sourceMap, true, false)); >+ } finally { >+ monitor.done(); >+ } >+ } >+ >+ /** >+ * Creates the project to add to the workspace. If the project already exists in >+ * the workspace ask the user if it is ok to overwrite. Will return <code>null</code> >+ * if no project could be created for the import (i.e. the user chooses to not overwrite). >+ * >+ * @param model plug-in being imported >+ * @param monitor progress monitor >+ * @return the project to use or <code>null</code> if no project could be created/overwritten >+ * @throws TeamException if an existing project is shared and an error occurs disconnecting it >+ * @throws CoreException if an error occurs when working with the project >+ */ >+ private IProject createProject(IPluginModelBase model, IProgressMonitor monitor) throws TeamException, CoreException { >+ try { >+ monitor.beginTask("Creating the project", 2); >+ IProject project = findProject(model.getPluginBase().getId()); >+ if (project.exists() || new File(project.getParent().getLocation().toFile(), project.getName()).exists()) { >+ // Query the user to see if we should overwrite >+ switch (fReplaceQuery.doQuery(NLS.bind(PDEUIMessages.ImportWizard_messages_exists, project.getName()))) { >+ case IImportQuery.CANCEL : >+ throw new OperationCanceledException(); >+ case IImportQuery.NO : >+ return null; >+ } >+ if (RepositoryProvider.isShared(project)) >+ RepositoryProvider.unmap(project); >+ if (!project.exists()) >+ project.create(new SubProgressMonitor(monitor, 1)); >+ if (!safeDeleteCheck(project, monitor)) { >+ throw new CoreException(new Status(IStatus.ERROR, PDEPlugin.getPluginId(), NLS.bind(PDEUIMessages.PluginImportOperation_could_not_delete_project, project.getName()))); >+ } >+ project.delete(true, true, monitor); >+ } >+ >+ project.create(monitor); >+ if (!project.isOpen()) >+ project.open(monitor); >+ monitor.worked(1); >+ >+ return project; >+ > } finally { > monitor.done(); > } >@@ -305,10 +278,16 @@ > return id + "_" + version; //$NON-NLS-1$ > } > >- // returns true if it is safe to delete the project. It is not safe to delete if >- // one of its libraries is locked by a running launch configuration. >+ /** >+ * Returns true if it is safe to delete the project. It is not safe to delete if >+ * one of its libraries is locked by a running launch configuration. >+ * >+ * @param project project to test >+ * @param monitor progress monitor >+ * @return true is it is safe to delete the project, false otherwise >+ */ > private boolean safeDeleteCheck(IProject project, IProgressMonitor monitor) { >- if (!fLaunchedConfigurations) >+ if (!fPluginsAreInUse) > return true; > IPluginModelBase base = PluginRegistry.findModel(project); > if (base != null) { >@@ -372,41 +351,73 @@ > * Imports the contents of the plugin and imports source files as binary files that will not be compiled. > * @param project destination project of the import > * @param model model representing the plugin to import >- * @param markAsBinary whether to mark the project as a binary project > * @param monitor progress monitor >+ * @return a mapping of libraries to source locations to use in the classpath > * @throws CoreException if there is a problem completing the import > */ >- private void importAsBinary(IProject project, IPluginModelBase model, boolean markAsBinary, IProgressMonitor monitor) throws CoreException { >- monitor.beginTask("", 4); //$NON-NLS-1$ >- if (isJARd(model)) { >- extractJARdPlugin(project, model, new SubProgressMonitor(monitor, 3)); >- } else { >- importContent(new File(model.getInstallLocation()), project.getFullPath(), FileSystemStructureProvider.INSTANCE, null, new SubProgressMonitor(monitor, 1)); >- importSourceArchives(project, model, new SubProgressMonitor(monitor, 1)); >+ private Map importAsBinary(IProject project, IPluginModelBase model, IProgressMonitor monitor) throws CoreException { >+ >+ try { >+ monitor.beginTask(NLS.bind("Importing {0}", model.getPluginBase().getId()), 4); >+ >+ // Import the plug-in content >+ File srcFile = new File(model.getInstallLocation()); >+ if (isJARd(model)) { >+ importArchive(project, srcFile, new Path(srcFile.getName())); >+ } else { >+ importContent(new File(model.getInstallLocation()), project.getFullPath(), FileSystemStructureProvider.INSTANCE, null, new SubProgressMonitor(monitor, 1)); >+ } >+ >+ // Import source from known source locations >+ Map sourceMap = copySourceArchives(project, model, new SubProgressMonitor(monitor, 1)); > >- // make sure all libraries have been imported >- // if any are missing, check in fragments >+ // Import missing libraries from fragments >+ // TODO Needs testing, might be obsolete > IFragment[] fragments = getFragmentsFor(model); > IPluginLibrary[] libraries = model.getPluginBase().getLibraries(); > >- IProgressMonitor fragmentMonitor = new SubProgressMonitor(monitor, 1); >- fragmentMonitor.beginTask("", libraries.length); //$NON-NLS-1$ > for (int i = 0; i < libraries.length; i++) { >- String libraryName = libraries[i].getName(); >- if (ClasspathUtilCore.containsVariables(libraryName) && !project.exists(new Path(ClasspathUtilCore.expandLibraryName(libraryName)))) { >+ String libraryName = ClasspathUtilCore.expandLibraryName(libraries[i].getName()); >+ Path libPath = new Path(libraryName); >+ if (!project.exists(libPath)) { > for (int j = 0; j < fragments.length; j++) { >- importJarFromFragment(project, fragments[j], libraryName); >- importSourceFromFragment(project, fragments[j], libraryName, new SubProgressMonitor(monitor, 1)); >+ // TODO Fragments are always a specific shape? >+ // Import the fragment >+ File jar = new File(fragments[i].getModel().getInstallLocation(), libPath.toString()); >+ if (jar.exists()) { >+ importArchive(project, jar, libPath); >+ } >+ // Import the source >+ // TODO Edit copySourceArchives to handle fragments to save the code duplication, don't forget the source map >+ SourceLocationManager manager = PDECore.getDefault().getSourceLocationManager(); >+ String zipName = ClasspathUtilCore.getSourceZipName(libraryName); >+ IPath srcPath = manager.findSourcePath(fragments[i], new Path(zipName)); >+ if (srcPath != null) { >+ // TODO Determine the best way to make the name, can be just the source location. >+ if ("src.zip".equals(zipName) && isJARd(model)) { //$NON-NLS-1$ >+ // We want a more meaningful name than src.zip >+ zipName = ClasspathUtilCore.getSourceZipName(new File(model.getInstallLocation()).getName()); >+ } >+ IPath dstPath = new Path(zipName); >+ sourceMap.put(libraries[i], dstPath); >+ if (project.findMember(dstPath) == null) { >+ importArchive(project, new File(srcPath.toOSString()), dstPath); >+ } >+ } > } >- } else { >- monitor.worked(1); > } > } >- } >- if (markAsBinary) { >+ monitor.worked(1); >+ >+ // Mark the project as binary > project.setPersistentProperty(PDECore.EXTERNAL_PROJECT_PROPERTY, PDECore.BINARY_PROJECT_VALUE); >- importAdditionalResources(project, model, new SubProgressMonitor(monitor, 1)); >- } else { >+ >+ // TODO Test if schema extraction is necessary >+// importAdditionalResources(project, model, new SubProgressMonitor(monitor, 1)); >+ >+ return sourceMap; >+ >+ } finally { > monitor.done(); > } > } >@@ -420,7 +431,7 @@ > */ > private void importAsSource(IProject project, IPluginModelBase model, SubProgressMonitor monitor) throws CoreException { > monitor.beginTask("", 4); //$NON-NLS-1$ >- importAsBinary(project, model, false, new SubProgressMonitor(monitor, 2)); >+// importAsBinary(project, model, false, new SubProgressMonitor(monitor, 2)); > List list = importAdditionalResources(project, model, new SubProgressMonitor(monitor, 1)); > WorkspaceBuildModel buildModel = new WorkspaceBuildModel(project.getFile("build.properties")); //$NON-NLS-1$ > if (!isJARd(model) || containsCode(new File(model.getInstallLocation()))) { >@@ -739,74 +750,36 @@ > monitor.done(); > } > >- private void importSourceArchives(IProject project, IPluginModelBase model, IProgressMonitor monitor) throws CoreException { >+ private Map copySourceArchives(IProject project, IPluginModelBase model, IProgressMonitor monitor) throws CoreException { > String[] libraries = getLibraryNames(model, true); >- monitor.beginTask(PDEUIMessages.ImportWizard_operation_copyingSource, libraries.length); >- >- SourceLocationManager manager = PDECore.getDefault().getSourceLocationManager(); >- >- Set roots = null; >- if (manager.hasBundleManifestLocation(model.getPluginBase())) >- roots = manager.findSourceRoots(model.getPluginBase()); >- >- for (int i = 0; i < libraries.length; i++) { >- String zipName = ClasspathUtilCore.getSourceZipName(libraries[i]); >- IPath path = new Path(zipName); >- if (project.findMember(path) == null) { >- // if we are importing the source through a sourceBundle header... >- if (roots != null) { >- IPath sourceLocation = manager.findSourcePath(model.getPluginBase(), null); >- String currentRoot = ".".equals(libraries[i]) ? "." : path.removeFileExtension().toString(); //$NON-NLS-1$ //$NON-NLS-2$ >- if (roots.contains(currentRoot)) { >- if (".".equals(currentRoot)) { //$NON-NLS-1$ >- // Save to a special folder name based on the install location >- IPath sourceName = getDefaultSourceNameForProject(model); >- sourceName = sourceName.removeFileExtension(); >- IFolder dest = project.getFolder(sourceName); >- if (!dest.exists()) { >- dest.create(true, true, null); >- } >- >- // List all of the other source roots so they are not included when importing source from the root, ".", of the jar >- Set allBundleRoots = manager.findAllSourceRootsInSourceLocation(model.getPluginBase()); >- List rootsToExclude = new ArrayList(allBundleRoots.size() - 1); >- for (Iterator iterator2 = allBundleRoots.iterator(); iterator2.hasNext();) { >- String rootString = (String) iterator2.next(); >- if (!".".equals(rootString)) { //$NON-NLS-1$ >- rootsToExclude.add(new Path(rootString)); >- } >- } >+ try { >+ monitor.beginTask(PDEUIMessages.ImportWizard_operation_copyingSource, libraries.length); > >- // Extract folders containing java source >- extractJavaSource(new File(sourceLocation.toOSString()), rootsToExclude, dest, monitor); >- } else { >- // Extract the specific library from it's folder >- extractResourcesFromFolder(new File(sourceLocation.toOSString()), new Path(currentRoot), project, monitor); >- } >- } >- } else { >- IPath srcPath = manager.findSourcePath(model.getPluginBase(), path); >- if (srcPath != null) { >- if ("src.zip".equals(zipName) && isJARd(model)) { //$NON-NLS-1$ >- path = getDefaultSourceNameForProject(model); >- } >- importArchive(project, new File(srcPath.toOSString()), path); >+ Map sourceMap = new HashMap(libraries.length); >+ SourceLocationManager manager = PDECore.getDefault().getSourceLocationManager(); >+ for (int i = 0; i < libraries.length; i++) { >+ String zipName = ClasspathUtilCore.getSourceZipName(libraries[i]); >+ IPath srcPath = manager.findSourcePath(model.getPluginBase(), new Path(zipName)); >+ if (srcPath != null) { >+ zipName = srcPath.lastSegment(); >+ // TODO Determine the best way to make the name, can be just the source location. >+ if ("src.zip".equals(zipName)) { //$NON-NLS-1$ >+ // We want a more meaningful name than src.zip >+ zipName = ClasspathUtilCore.getSourceZipName(new File(model.getInstallLocation()).getName()); >+ } >+ IPath dstPath = new Path(zipName); >+ sourceMap.put(libraries[i], dstPath); >+ if (project.findMember(dstPath) == null) { >+ importArchive(project, new File(srcPath.toOSString()), dstPath); > } >+ > } >+ monitor.worked(1); > } >- monitor.worked(1); >+ return sourceMap; >+ } finally { >+ monitor.done(); > } >- monitor.done(); >- } >- >- /** >- * Creates a path representing a zip file that is named based on the plugin install location. >- * Used to replace src.zip with a more unique and meaningful name. >- * @param model model that the src.zip containg source for >- * @return a new path describing the zip file >- */ >- private IPath getDefaultSourceNameForProject(IPluginModelBase model) { >- return new Path(ClasspathUtilCore.getSourceZipName(new File(model.getInstallLocation()).getName())); > } > > private String[] getLibraryNames(IPluginModelBase model, boolean expand) { >@@ -854,7 +827,7 @@ > if (fImportType == IMPORT_BINARY_WITH_LINKS) { > linkSourceArchives(project, model, new SubProgressMonitor(monitor, 1)); > } else { >- importSourceArchives(project, model, new SubProgressMonitor(monitor, 1)); >+ copySourceArchives(project, model, new SubProgressMonitor(monitor, 1)); > } > } > } >@@ -926,27 +899,38 @@ > return PDEPlugin.getWorkspace().getRoot().getProject(id); > } > >- private boolean queryReplace(IProject project) throws OperationCanceledException { >- switch (fReplaceQuery.doQuery(NLS.bind(PDEUIMessages.ImportWizard_messages_exists, project.getName()))) { >- case IImportQuery.CANCEL : >- throw new OperationCanceledException(); >- case IImportQuery.NO : >- return false; >- } >- return true; >- } >- >- private boolean queryExecutionEnvironment(String message) throws OperationCanceledException { >- switch (fExecutionQuery.doQuery(message)) { >- case IImportQuery.CANCEL : >- throw new OperationCanceledException(); >- case IImportQuery.NO : >- return false; >+ /** >+ * Tests whether the required execution environment of the given plugin is supported by >+ * the current known JREs. If not, ask the user whether to continue. >+ * @param model the plug-in model to test >+ * @return true is the import should continue, false if the plug-in should be skipped >+ * @throws OperationCanceledException if the user chooses to cancel the operation >+ */ >+ private boolean testExecutionEnvironment(IPluginModelBase model) throws OperationCanceledException { >+ BundleDescription desc = model.getBundleDescription(); >+ if (desc != null) { >+ IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager(); >+ String[] envs = desc.getExecutionEnvironments(); >+ boolean found = false; >+ for (int i = 0; i < envs.length; i++) { >+ if (manager.getEnvironment(envs[i]) != null) { >+ found = true; >+ break; >+ } >+ } >+ if (envs.length > 0 && !found) { >+ switch (fExecutionQuery.doQuery(NLS.bind(PDEUIMessages.PluginImportOperation_executionEnvironment, model.getPluginBase().getId(), envs[0]))) { >+ case IImportQuery.CANCEL : >+ throw new OperationCanceledException(); >+ case IImportQuery.NO : >+ return false; >+ } >+ } > } > return true; > } > >- private void setProjectDescription(IProject project, IPluginModelBase model) throws CoreException { >+ private void setProjectNatures(IProject project, IPluginModelBase model) throws CoreException { > IProjectDescription desc = project.getDescription(); > if (!desc.hasNature(PDE.PLUGIN_NATURE)) > CoreUtility.addNatureToProject(project, PDE.PLUGIN_NATURE, null); >@@ -1027,43 +1011,43 @@ > return (IFragment[]) result.toArray(new IFragment[result.size()]); > } > >- private void importJarFromFragment(IProject project, IFragment fragment, String name) throws CoreException { >- IPath jarPath = new Path(ClasspathUtilCore.expandLibraryName(name)); >- File jar = new File(fragment.getModel().getInstallLocation(), jarPath.toString()); >- if (jar.exists()) { >- importArchive(project, jar, jarPath); >- } >- } >- >- /** >- * Imports the source for a library from a fragment. >- * @param project destination project of the import >- * @param fragment fragment to import the library from >- * @param libraryName name of the library to import, >- * @param monitor progress monitor >- * @throws CoreException if there is a problem completing the import >- */ >- private void importSourceFromFragment(IProject project, IFragment fragment, String libraryName, IProgressMonitor monitor) throws CoreException { >- try { >- IPath jarPath = new Path(ClasspathUtilCore.expandLibraryName(libraryName)); >- String zipName = ClasspathUtilCore.getSourceZipName(jarPath.toString()); >- IPath path = new Path(zipName); >- if (project.findMember(path) == null) { >- SourceLocationManager manager = PDECore.getDefault().getSourceLocationManager(); >- IPath srcPath = manager.findSourcePath(fragment, path); >- if (srcPath != null) { >- if (manager.hasBundleManifestLocation(fragment)) { >- // Extract the specific library from it's folder >- extractResourcesFromFolder(new File(srcPath.toOSString()), path.removeFileExtension(), project, monitor); >- } else { >- importArchive(project, new File(srcPath.toOSString()), path); >- } >- } >- } >- } finally { >- monitor.done(); >- } >- } >+// private void importJarFromFragment(IProject project, IFragment fragment, String name) throws CoreException { >+// IPath jarPath = new Path(ClasspathUtilCore.expandLibraryName(name)); >+// File jar = new File(fragment.getModel().getInstallLocation(), jarPath.toString()); >+// if (jar.exists()) { >+// importArchive(project, jar, jarPath); >+// } >+// } >+ >+// /** >+// * Imports the source for a library from a fragment. >+// * @param project destination project of the import >+// * @param fragment fragment to import the library from >+// * @param libraryName name of the library to import, >+// * @param monitor progress monitor >+// * @throws CoreException if there is a problem completing the import >+// */ >+// private void importSourceFromFragment(IProject project, IFragment fragment, String libraryName, IProgressMonitor monitor) throws CoreException { >+// try { >+// IPath jarPath = new Path(ClasspathUtilCore.expandLibraryName(libraryName)); >+// String zipName = ClasspathUtilCore.getSourceZipName(jarPath.toString()); >+// IPath path = new Path(zipName); >+// if (project.findMember(path) == null) { >+// SourceLocationManager manager = PDECore.getDefault().getSourceLocationManager(); >+// IPath srcPath = manager.findSourcePath(fragment, path); >+// if (srcPath != null) { >+// if (manager.hasBundleManifestLocation(fragment)) { >+// // Extract the specific library from it's folder >+// extractResourcesFromFolder(new File(srcPath.toOSString()), path.removeFileExtension(), project, monitor); >+// } else { >+// importArchive(project, new File(srcPath.toOSString()), path); >+// } >+// } >+// } >+// } finally { >+// monitor.done(); >+// } >+// } > > protected void collectAdditionalResources(ZipFileStructureProvider provider, Object element, ArrayList collected, IProject project) { > collectAdditionalResources(provider, element, collected); >@@ -1093,8 +1077,25 @@ > } > } > >- public void setLaunchedConfiguration(boolean launchedConfiguration) { >- fLaunchedConfigurations = launchedConfiguration; >+ /** >+ * Starts a job that will build the workspace >+ */ >+ private void runBuildJob() { >+ Job buildJob = new Job(PDEUIMessages.CompilersConfigurationBlock_building) { >+ public boolean belongsTo(Object family) { >+ return ResourcesPlugin.FAMILY_AUTO_BUILD == family; >+ } >+ >+ protected IStatus run(IProgressMonitor monitor) { >+ try { >+ PDEPlugin.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); >+ } catch (CoreException e) { >+ } >+ return Status.OK_STATUS; >+ } >+ }; >+ buildJob.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule()); >+ buildJob.schedule(); > } > > } >Index: src/org/eclipse/pde/internal/ui/pderesources.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties,v >retrieving revision 1.1010 >diff -u -r1.1010 pderesources.properties >--- src/org/eclipse/pde/internal/ui/pderesources.properties 26 Oct 2008 18:24:02 -0000 1.1010 >+++ src/org/eclipse/pde/internal/ui/pderesources.properties 5 Nov 2008 22:41:40 -0000 >@@ -1070,8 +1070,7 @@ > PluginSelectionDialog_title = Plug-in Selection > PluginStructureCreator_name=Plug-in Structure Compare > PluginSelectionDialog_message = &Select a Plug-in: >-PluginImportInfoDialog_message=Could not fully delete existing plug-ins with the same name.\nImporting the following plug-ins failed: >-PluginImportInfoDialog_title=Deleting Plug-ins Failed >+PluginImportOperation_could_not_delete_project=Import operation could not delete the following project: {0} > PluginImportOperation_linking=Linking content... > PluginImportOperation_executionEnvironment=Plug-in ''{0}'' requires an ''{1}'' execution environment that is not supported by any of the installed JREs. Import anyway? > PluginImportWizard_runningConfigDesc=An application is currently running. Some of the selected plug-ins may not be imported if they are locked by it. Do you want to continue? >Index: src/org/eclipse/pde/internal/ui/PDEUIMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java,v >retrieving revision 1.387 >diff -u -r1.387 PDEUIMessages.java >--- src/org/eclipse/pde/internal/ui/PDEUIMessages.java 26 Oct 2008 18:24:03 -0000 1.387 >+++ src/org/eclipse/pde/internal/ui/PDEUIMessages.java 5 Nov 2008 22:41:40 -0000 >@@ -1594,9 +1594,7 @@ > > public static String PluginSelectionDialog_title; > public static String PluginSelectionDialog_message; >- public static String PluginImportInfoDialog_message; >- >- public static String PluginImportInfoDialog_title; >+ public static String PluginImportOperation_could_not_delete_project; > > public static String PluginImportOperation_linking; > public static String PluginContentPage_appQuestion; >#P org.eclipse.pde.core >Index: src/org/eclipse/pde/internal/core/ClasspathComputer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ClasspathComputer.java,v >retrieving revision 1.9 >diff -u -r1.9 ClasspathComputer.java >--- src/org/eclipse/pde/internal/core/ClasspathComputer.java 6 Mar 2008 19:39:28 -0000 1.9 >+++ src/org/eclipse/pde/internal/core/ClasspathComputer.java 5 Nov 2008 22:41:42 -0000 >@@ -34,11 +34,12 @@ > private static final int SEVERITY_IGNORE = 1; > > public static void setClasspath(IProject project, IPluginModelBase model) throws CoreException { >- IClasspathEntry[] entries = getClasspath(project, model, false, true); >+ IClasspathEntry[] entries = getClasspath(project, model, null, false, true); > JavaCore.create(project).setRawClasspath(entries, null); > } > >- public static IClasspathEntry[] getClasspath(IProject project, IPluginModelBase model, boolean clear, boolean overrideCompliance) throws CoreException { >+ // TODO Javadoc >+ public static IClasspathEntry[] getClasspath(IProject project, IPluginModelBase model, Map sourceLibraryMap, boolean clear, boolean overrideCompliance) throws CoreException { > IJavaProject javaProject = JavaCore.create(project); > ArrayList result = new ArrayList(); > IBuild build = getBuild(project); >@@ -52,7 +53,7 @@ > result.add(createEntryUsingPreviousEntry(javaProject, ee, PDECore.REQUIRED_PLUGINS_CONTAINER_PATH)); > > // add own libraries/source >- addSourceAndLibraries(project, model, build, clear, result); >+ addSourceAndLibraries(project, model, build, clear, sourceLibraryMap, result); > > IClasspathEntry[] entries = (IClasspathEntry[]) result.toArray(new IClasspathEntry[result.size()]); > IJavaModelStatus validation = JavaConventions.validateClasspath(javaProject, entries, javaProject.getOutputLocation()); >@@ -63,7 +64,7 @@ > return (IClasspathEntry[]) result.toArray(new IClasspathEntry[result.size()]); > } > >- public static void addSourceAndLibraries(IProject project, IPluginModelBase model, IBuild build, boolean clear, ArrayList result) throws CoreException { >+ private static void addSourceAndLibraries(IProject project, IPluginModelBase model, IBuild build, boolean clear, Map sourceLibraryMap, ArrayList result) throws CoreException { > > HashSet paths = new HashSet(); > >@@ -86,10 +87,11 @@ > if (buildEntry != null) { > addSourceFolder(buildEntry, project, paths, result); > } else { >+ IPath sourceAttachment = sourceLibraryMap != null ? (IPath) sourceLibraryMap.get(libraries[i].getName()) : null; > if (libraries[i].getName().equals(".")) //$NON-NLS-1$ >- addJARdPlugin(project, ClasspathUtilCore.getFilename(model), attrs, result); >+ addJARdPlugin(project, ClasspathUtilCore.getFilename(model), sourceAttachment, attrs, result); > else >- addLibraryEntry(project, libraries[i], attrs, result); >+ addLibraryEntry(project, libraries[i], sourceAttachment, attrs, result); > } > } > if (libraries.length == 0) { >@@ -99,7 +101,8 @@ > addSourceFolder(buildEntry, project, paths, result); > } > } else if (ClasspathUtilCore.hasBundleStructure(model)) { >- addJARdPlugin(project, ClasspathUtilCore.getFilename(model), attrs, result); >+ IPath sourceAttachment = sourceLibraryMap != null ? (IPath) sourceLibraryMap.get(".") : null; //$NON-NLS-1$ >+ addJARdPlugin(project, ClasspathUtilCore.getFilename(model), sourceAttachment, attrs, result); > } > } > } >@@ -146,7 +149,7 @@ > return (buildModel != null) ? buildModel.getBuild() : null; > } > >- private static void addLibraryEntry(IProject project, IPluginLibrary library, IClasspathAttribute[] attrs, ArrayList result) throws JavaModelException { >+ private static void addLibraryEntry(IProject project, IPluginLibrary library, IPath sourceAttachment, IClasspathAttribute[] attrs, ArrayList result) throws JavaModelException { > String name = ClasspathUtilCore.expandLibraryName(library.getName()); > IResource jarFile = project.findMember(name); > if (jarFile == null) >@@ -161,34 +164,29 @@ > } > } > >- IClasspathEntry entry = createClasspathEntry(project, jarFile, name, attrs, library.isExported()); >+ IClasspathEntry entry = createClasspathEntry(project, jarFile, name, sourceAttachment, attrs, library.isExported()); > if (!result.contains(entry)) > result.add(entry); > } > >- private static void addJARdPlugin(IProject project, String filename, IClasspathAttribute[] attrs, ArrayList result) { >+ private static void addJARdPlugin(IProject project, String filename, IPath sourceAttachment, IClasspathAttribute[] attrs, ArrayList result) { > String name = ClasspathUtilCore.expandLibraryName(filename); > IResource jarFile = project.findMember(name); > if (jarFile != null) { >- IClasspathEntry entry = createClasspathEntry(project, jarFile, filename, attrs, true); >+ IClasspathEntry entry = createClasspathEntry(project, jarFile, filename, sourceAttachment, attrs, true); > if (!result.contains(entry)) > result.add(entry); > } > } > >- private static IClasspathEntry createClasspathEntry(IProject project, IResource library, String fileName, IClasspathAttribute[] attrs, boolean isExported) { >- String sourceZipName = ClasspathUtilCore.getSourceZipName(fileName); >- IResource resource = project.findMember(sourceZipName); >- // if zip file does not exist, see if a directory with the source does. This in necessary how we import source for individual source bundles. >- if (resource == null && sourceZipName.endsWith(".zip")) { //$NON-NLS-1$ >- resource = project.findMember(sourceZipName.substring(0, sourceZipName.length() - 4)); >- if (resource == null) >- // if we can't find the the source for a library, then try to find the common source location set up to share source from one jar to all libraries. >- // see PluginImportOperation.linkSourceArchives >- resource = project.getFile(project.getName() + "src.zip"); //$NON-NLS-1$ >- } >- IPath srcAttachment = resource != null ? resource.getFullPath() : library.getFullPath(); >- return JavaCore.newLibraryEntry(library.getFullPath(), srcAttachment, null, new IAccessRule[0], attrs, isExported); >+ private static IClasspathEntry createClasspathEntry(IProject project, IResource library, String fileName, IPath sourceAttachment, IClasspathAttribute[] attrs, boolean isExported) { >+ IResource resource = sourceAttachment != null ? project.findMember(sourceAttachment) : project.findMember(ClasspathUtilCore.getSourceZipName(fileName)); >+ // TODO This case may no longer be needed as the source can be any name, the source attachment should be specified in this case >+// if (resource == null) { >+// // If a specific library zip can't be found, look for the common source jar as is may have multiple source roots >+// resource = project.getFile(project.getName() + "src.zip"); //$NON-NLS-1$ >+// } >+ return JavaCore.newLibraryEntry(library.getFullPath(), resource == null ? null : resource.getFullPath(), null, new IAccessRule[0], attrs, isExported); > } > > private static String getExecutionEnvironment(BundleDescription bundleDescription) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 245565
: 117150 |
117151
|
117958
|
118301