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 83439 Details for
Bug 185502
Plug-in Import Should Check for Running target
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
second version
patch_pde_185502v2.txt (text/plain), 11.34 KB, created by
bartosz michalik
on 2007-11-21 11:30:03 EST
(
hide
)
Description:
second version
Filename:
MIME Type:
Creator:
bartosz michalik
Created:
2007-11-21 11:30:03 EST
Size:
11.34 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.45 >diff -u -r1.45 PluginImportWizard.java >--- src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportWizard.java 8 Jun 2007 16:43:37 -0000 1.45 >+++ src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportWizard.java 21 Nov 2007 16:26:06 -0000 >@@ -10,21 +10,30 @@ > *******************************************************************************/ > package org.eclipse.pde.internal.ui.wizards.imports; > >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.Map; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Status; > import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.ILaunch; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchManager; > import org.eclipse.jface.dialogs.IDialogConstants; > import org.eclipse.jface.dialogs.IDialogSettings; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.viewers.IStructuredSelection; > import org.eclipse.jface.wizard.IWizardPage; > import org.eclipse.jface.wizard.Wizard; >+import org.eclipse.osgi.service.resolver.BundleDescription; > import org.eclipse.pde.core.plugin.IPluginModelBase; > import org.eclipse.pde.internal.ui.PDEPlugin; > import org.eclipse.pde.internal.ui.PDEPluginImages; > import org.eclipse.pde.internal.ui.PDEUIMessages; >+import org.eclipse.pde.internal.ui.launcher.BundleLauncherHelper; > import org.eclipse.pde.internal.ui.wizards.imports.PluginImportOperation.IImportQuery; > import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.Shell; >@@ -35,16 +44,17 @@ > > private static final String STORE_SECTION = "PluginImportWizard"; //$NON-NLS-1$ > >- private IStructuredSelection selection; >+ private IStructuredSelection selection; > private PluginImportWizardFirstPage page1; > private BaseImportWizardSecondPage page2; > private BaseImportWizardSecondPage page3; > > public PluginImportWizard() { >- IDialogSettings masterSettings = PDEPlugin.getDefault().getDialogSettings(); >+ IDialogSettings masterSettings = PDEPlugin.getDefault() >+ .getDialogSettings(); > setDialogSettings(getSettingsSection(masterSettings)); > setDefaultPageImageDescriptor(PDEPluginImages.DESC_PLUGIN_IMPORT_WIZ); >- setWindowTitle(PDEUIMessages.ImportWizard_title); >+ setWindowTitle(PDEUIMessages.ImportWizard_title); > } > > public void init(IWorkbench workbench, IStructuredSelection selection) { >@@ -77,22 +87,81 @@ > > public boolean performFinish() { > page1.storeSettings(); >- ((BaseImportWizardSecondPage)page1.getNextPage()).storeSettings(); >- >+ ((BaseImportWizardSecondPage) page1.getNextPage()).storeSettings(); >+ boolean launchedConfiguration = false; >+ if (!doCheckLaunches()) { >+ if (!MessageDialog >+ .openConfirm(getShell(), "Choosen plug-ins can be locked", >+ "Some of the selected plug-ins my not be imported. Do you want to continue?")) { >+ return false; >+ } >+ launchedConfiguration = true; >+ } > final IPluginModelBase[] models = getModelsToImport(); >- doImportOperation(getShell(), page1.getImportType(), models, page2.forceAutoBuild()); >+ doImportOperation(getShell(), page1.getImportType(), models, page2 >+ .forceAutoBuild(), launchedConfiguration); > return true; > } > >- public static void doImportOperation( >- final Shell shell, >- final int importType, >- final IPluginModelBase[] models, >+ /** >+ * @return <code>true</code> if there is no problem with locked plugins >+ */ >+ private boolean doCheckLaunches() { >+ ILaunchManager launchManager = DebugPlugin.getDefault() >+ .getLaunchManager(); >+ ILaunch[] launches = launchManager.getLaunches(); >+ IPluginModelBase[] modelsToImport = getModelsToImport(); >+ HashMap imported = new HashMap(); >+ for (int j = 0; j < modelsToImport.length; ++j) { >+ BundleDescription bd = modelsToImport[j].getBundleDescription(); >+ if (bd != null) { >+ imported.put(bd.getSymbolicName(), modelsToImport[j]); >+ } >+ } >+ for (int i = 0; i < launches.length; ++i) { >+ if (!launches[i].isTerminated()) { >+ ILaunchConfiguration configuration = launches[i] >+ .getLaunchConfiguration(); >+ try { >+ Map workspaceBundleMap = BundleLauncherHelper >+ .getWorkspaceBundleMap(configuration, null); >+ for (Iterator iter = workspaceBundleMap.keySet().iterator(); iter >+ .hasNext();) { >+ IPluginModelBase bm = (IPluginModelBase) iter.next(); >+ BundleDescription description = bm >+ .getBundleDescription(); >+ if (description != null) { >+ imported.remove(description.getSymbolicName()); >+ } >+ if (imported.size() == 0) //there is no need to check next bundles >+ return false; >+ } >+ return imported.size() == modelsToImport.length; >+ } catch (CoreException e) { >+ PDEPlugin.logException(e); >+ return false; >+ } >+ } >+ } >+ return true; >+ } >+ >+ public static void doImportOperation(final Shell shell, >+ final int importType, final IPluginModelBase[] models, > final boolean forceAutobuild) { >+ doImportOperation(shell, importType, models, forceAutobuild, false); >+ } >+ >+ >+ private static void doImportOperation(final Shell shell, >+ final int importType, final IPluginModelBase[] models, >+ final boolean forceAutobuild, final boolean launchedConfiguration) { > PluginImportOperation.IImportQuery query = new ImportQuery(shell); >- PluginImportOperation.IImportQuery executionQuery = new ImportQuery(shell); >- final PluginImportOperation op = >- new PluginImportOperation(models, importType, query, executionQuery, forceAutobuild); >+ PluginImportOperation.IImportQuery executionQuery = new ImportQuery( >+ shell); >+ final PluginImportOperation op = new PluginImportOperation(models, >+ importType, query, executionQuery, forceAutobuild); >+ op.setLaunchedConfiguration(launchedConfiguration); > Job job = new Job(PDEUIMessages.ImportWizard_title) { > protected IStatus run(IProgressMonitor monitor) { > try { >@@ -108,36 +177,25 @@ > job.schedule(); > } > >- > private static class ReplaceDialog extends MessageDialog { > public ReplaceDialog(Shell parentShell, String dialogMessage) { >- super( >- parentShell, >- PDEUIMessages.ImportWizard_messages_title, >- null, >- dialogMessage, >- MessageDialog.QUESTION, >- new String[] { >+ super(parentShell, PDEUIMessages.ImportWizard_messages_title, null, >+ dialogMessage, MessageDialog.QUESTION, new String[] { > IDialogConstants.YES_LABEL, > IDialogConstants.YES_TO_ALL_LABEL, > IDialogConstants.NO_LABEL, >- PDEUIMessages.ImportWizard_noToAll, >- IDialogConstants.CANCEL_LABEL }, >- 0); >+ PDEUIMessages.ImportWizard_noToAll, >+ IDialogConstants.CANCEL_LABEL }, 0); > } > } > > public static class ImportQuery implements IImportQuery { >- public ImportQuery(Shell shell) {} >+ public ImportQuery(Shell shell) { >+ } > > private int yesToAll = 0; >- private int[] RETURNCODES = >- { >- IImportQuery.YES, >- IImportQuery.YES, >- IImportQuery.NO, >- IImportQuery.NO, >- IImportQuery.CANCEL }; >+ private int[] RETURNCODES = { IImportQuery.YES, IImportQuery.YES, >+ IImportQuery.NO, IImportQuery.NO, IImportQuery.CANCEL }; > > public int doQuery(final String message) { > if (yesToAll != 0) { >@@ -147,7 +205,8 @@ > final int[] result = { IImportQuery.CANCEL }; > Display.getDefault().syncExec(new Runnable() { > public void run() { >- ReplaceDialog dialog = new ReplaceDialog(Display.getDefault().getActiveShell(), message); >+ ReplaceDialog dialog = new ReplaceDialog(Display >+ .getDefault().getActiveShell(), message); > int retVal = dialog.open(); > if (retVal >= 0) { > result[0] = RETURNCODES[retVal]; >@@ -168,7 +227,7 @@ > if (page1.getScanAllPlugins()) { > return page3; > } >- return page2; >+ return page2; > } > return null; > } >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.109 >diff -u -r1.109 PluginImportOperation.java >--- src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportOperation.java 8 Jun 2007 16:43:37 -0000 1.109 >+++ src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportOperation.java 21 Nov 2007 16:26:06 -0000 >@@ -44,6 +44,7 @@ > import org.eclipse.core.runtime.SubProgressMonitor; > import org.eclipse.core.runtime.jobs.Job; > import org.eclipse.jdt.core.IClasspathEntry; >+import org.eclipse.jdt.core.IPackageFragmentRoot; > import org.eclipse.jdt.core.JavaCore; > import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jdt.launching.JavaRuntime; >@@ -96,6 +97,8 @@ > private boolean fForceAutobuild; > > private IImportQuery fExecutionQuery; >+ >+ private boolean launchedConfiguration; > > public interface IImportQuery { > public static final int CANCEL = 0; >@@ -213,7 +216,11 @@ > RepositoryProvider.unmap(project); > if (!project.exists()) > project.create(new SubProgressMonitor(monitor, 1)); >- project.delete(true, true, monitor); >+ if(safeDeleteCheck(project, monitor)) { >+ project.delete(true, true, monitor); >+ } else { >+ return; >+ } > } > > project.create(monitor); >@@ -245,11 +252,39 @@ > if (project.hasNature(JavaCore.NATURE_ID) && project.findMember(".classpath") == null) //$NON-NLS-1$ > fProjectClasspaths .put(project, ClasspathComputer.getClasspath(project, model, true)); > } catch (CoreException e) { >+ PDEPlugin.logException(e); > } finally { > monitor.done(); > } > } > >+ private boolean safeDeleteCheck(IProject project, IProgressMonitor monitor) { >+ if(! launchedConfiguration) return true; >+ try { >+ IClasspathEntry[] rawClasspath = JavaCore.create(project) >+ .getRawClasspath(); >+ for (int i = 0; i < rawClasspath.length; ++i) { >+ if (rawClasspath[i].getContentKind() == IPackageFragmentRoot.K_BINARY) { >+ IPath path = rawClasspath[i].getPath(); >+ IResource member = ResourcesPlugin.getWorkspace().getRoot() >+ .findMember(path); >+ if (member != null) { >+ try { >+ ResourcesPlugin.getWorkspace().delete( >+ new IResource[] { member }, true, monitor); >+ return true; >+ } catch (CoreException e) { >+ return false; >+ } >+ } >+ } >+ } >+ } catch (JavaModelException e) { >+ PDEPlugin.logException(e); >+ } >+ return true; >+ } >+ > private void importAsBinaryWithLinks(IProject project, IPluginModelBase model, IProgressMonitor monitor) throws CoreException { > if (isJARd(model)) { > extractJARdPlugin( >@@ -874,5 +909,9 @@ > li.remove(); > } > } >+ >+ public void setLaunchedConfiguration(boolean launchedConfiguration) { >+ this.launchedConfiguration = launchedConfiguration; >+ } > > }
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 185502
:
68520
|
83240
|
83241
| 83439 |
83440