### Eclipse Workspace Patch 1.0
#P org.eclipse.pde.core
Index: src/org/eclipse/pde/internal/core/project/BundleProjectService.java
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/project/BundleProjectService.java,v
retrieving revision 1.4
diff -u -r1.4 BundleProjectService.java
--- src/org/eclipse/pde/internal/core/project/BundleProjectService.java 2 Mar 2010 16:56:13 -0000 1.4
+++ src/org/eclipse/pde/internal/core/project/BundleProjectService.java 18 May 2010 16:55:32 -0000
@@ -10,13 +10,6 @@
*******************************************************************************/
package org.eclipse.pde.internal.core.project;
-import org.eclipse.pde.internal.core.importing.provisional.BundleImportDescription;
-
-import org.eclipse.pde.internal.core.importing.IBundleImporter;
-
-import org.eclipse.pde.internal.core.importing.BundleImporterExtension;
-
-
import java.io.*;
import java.util.*;
import java.util.jar.JarFile;
@@ -31,6 +24,9 @@
import org.eclipse.pde.core.project.*;
import org.eclipse.pde.internal.core.ICoreConstants;
import org.eclipse.pde.internal.core.PDECore;
+import org.eclipse.pde.internal.core.importing.BundleImporterExtension;
+import org.eclipse.pde.internal.core.importing.IBundleImporter;
+import org.eclipse.pde.internal.core.importing.provisional.BundleImportDescription;
import org.eclipse.pde.internal.core.target.Messages;
import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle;
import org.osgi.framework.BundleException;
@@ -244,11 +240,13 @@
description.setProperty(PLUGIN, plugins.get(j));
}
}
- result.put(importer, valid.toArray(new BundleImportDescription[valid.size()]));
+ if (!valid.isEmpty()) {
+ result.put(importer, valid.toArray(new BundleImportDescription[valid.size()]));
+ }
}
return result;
}
- return null;
+ return new HashMap();
}
/**
#P org.eclipse.pde.ui
Index: src/org/eclipse/pde/internal/ui/PDEUIMessages.java
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java,v
retrieving revision 1.481
diff -u -r1.481 PDEUIMessages.java
--- src/org/eclipse/pde/internal/ui/PDEUIMessages.java 12 May 2010 15:14:57 -0000 1.481
+++ src/org/eclipse/pde/internal/ui/PDEUIMessages.java 18 May 2010 16:55:34 -0000
@@ -391,8 +391,12 @@
public static String ImportActionGroup_binaryWithLinkedContent;
+ public static String ImportActionGroup_cannot_import;
+
public static String ImportActionGroup_importContributingPlugin;
+ public static String ImportActionGroup_Repository_project;
+
public static String InformationSection_0;
public static String InformationSection_1;
Index: src/org/eclipse/pde/internal/ui/pderesources.properties
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties,v
retrieving revision 1.1142
diff -u -r1.1142 pderesources.properties
--- src/org/eclipse/pde/internal/ui/pderesources.properties 12 May 2010 15:14:57 -0000 1.1142
+++ src/org/eclipse/pde/internal/ui/pderesources.properties 18 May 2010 16:55:34 -0000
@@ -1045,7 +1045,9 @@
TemplateSelectionPage_column_point = Extension Point
ImportActionGroup_binaryWithLinkedContent=Binary Project with &Linked Content
+ImportActionGroup_cannot_import=The selected plug-ins cannot be imported from a repository.
ImportActionGroup_importContributingPlugin=&Import Contributing Plug-in as
+ImportActionGroup_Repository_project=&Repository Project...
####
Index: src/org/eclipse/pde/internal/ui/views/plugins/ImportActionGroup.java
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/plugins/ImportActionGroup.java,v
retrieving revision 1.6
diff -u -r1.6 ImportActionGroup.java
--- src/org/eclipse/pde/internal/ui/views/plugins/ImportActionGroup.java 27 May 2009 20:38:22 -0000 1.6
+++ src/org/eclipse/pde/internal/ui/views/plugins/ImportActionGroup.java 18 May 2010 16:55:34 -0000
@@ -10,16 +10,22 @@
*******************************************************************************/
package org.eclipse.pde.internal.ui.views.plugins;
-import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.*;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.*;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.pde.core.plugin.*;
+import org.eclipse.pde.internal.core.importing.provisional.BundleImportDescription;
+import org.eclipse.pde.internal.core.importing.provisional.IBundleImporterDelegate;
+import org.eclipse.pde.internal.core.project.BundleProjectService;
+import org.eclipse.pde.internal.ui.PDEPlugin;
import org.eclipse.pde.internal.ui.PDEUIMessages;
-import org.eclipse.pde.internal.ui.wizards.imports.PluginImportOperation;
-import org.eclipse.pde.internal.ui.wizards.imports.PluginImportWizard;
+import org.eclipse.pde.internal.ui.wizards.imports.*;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.actions.ActionGroup;
@@ -42,6 +48,9 @@
case PluginImportOperation.IMPORT_WITH_SOURCE :
setText(PDEUIMessages.PluginsView_asSourceProject);
break;
+ case PluginImportOperation.IMPORT_FROM_REPOSITORY :
+ setText(PDEUIMessages.ImportActionGroup_Repository_project);
+ break;
}
}
@@ -64,6 +73,7 @@
importMenu.add(new ImportAction(PluginImportOperation.IMPORT_BINARY, sSelection));
importMenu.add(new ImportAction(PluginImportOperation.IMPORT_BINARY_WITH_LINKS, sSelection));
importMenu.add(new ImportAction(PluginImportOperation.IMPORT_WITH_SOURCE, sSelection));
+ importMenu.add(new ImportAction(PluginImportOperation.IMPORT_FROM_REPOSITORY, sSelection));
menu.add(importMenu);
}
}
@@ -79,8 +89,39 @@
if (display == null)
display = Display.getDefault();
IPluginModelBase[] models = (IPluginModelBase[]) externalModels.toArray(new IPluginModelBase[externalModels.size()]);
+ if (importType == PluginImportOperation.IMPORT_FROM_REPOSITORY) {
+ Map importMap = getImportDescriptions(display.getActiveShell(), models);
+ if (importMap != null) {
+ RepositoryImportWizard wizard = new RepositoryImportWizard(importMap);
+ WizardDialog dialog = new WizardDialog(display.getActiveShell(), wizard);
+ dialog.open();
+ }
+ } else {
+ PluginImportWizard.doImportOperation(display.getActiveShell(), importType, models, false);
+ }
+ }
- PluginImportWizard.doImportOperation(display.getActiveShell(), importType, models, false);
+ /**
+ * Return a map of {@link IBundleImporterDelegate} > Array of {@link BundleImportDescription} to be imported.
+ *
+ * @param shell shell to open message dialogs on, if required
+ * @param models candidate models
+ * @return map of importer delegates to import descriptions
+ */
+ private Map getImportDescriptions(Shell shell, IPluginModelBase[] models) {
+ BundleProjectService service = (BundleProjectService) BundleProjectService.getDefault();
+ try {
+ Map descriptions = service.getImportDescriptions(models); // all possible descriptions
+ if (!descriptions.isEmpty()) {
+ return descriptions;
+ }
+ // no applicable importers for selected models
+ MessageDialog.openInformation(shell, PDEUIMessages.ImportWizard_title, PDEUIMessages.ImportActionGroup_cannot_import);
+ } catch (CoreException e) {
+ PDEPlugin.log(e);
+ MessageDialog.openError(shell, PDEUIMessages.ImportWizard_title, e.getMessage());
+ }
+ return null;
}
public static boolean canImport(IStructuredSelection selection) {
Index: src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportWizard.java
===================================================================
RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportWizard.java,v
retrieving revision 1.60
diff -u -r1.60 PluginImportWizard.java
--- src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportWizard.java 16 Apr 2010 20:21:55 -0000 1.60
+++ src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportWizard.java 18 May 2010 16:55:34 -0000
@@ -106,7 +106,7 @@
if (!page1.finishPages()) {
return false;
}
- doImportOperation(getShell(), page1.getImportType(), models, page2.forceAutoBuild(), launchedConfiguration > 0, page1.getAlternateSourceLocations(), page1.getImportDescriptions());
+ doImportOperation(page1.getImportType(), models, page2.forceAutoBuild(), launchedConfiguration > 0, page1.getAlternateSourceLocations(), page1.getImportDescriptions());
return true;
}
@@ -151,21 +151,23 @@
}
public static void doImportOperation(Shell shell, int importType, IPluginModelBase[] models, boolean forceAutobuild) {
- doImportOperation(shell, importType, models, forceAutobuild, false, null, null);
+ doImportOperation(importType, models, forceAutobuild, false, null, null);
}
/**
+ * Performs the import.
*
- * @param shell
- * @param importType
- * @param models
- * @param forceAutobuild
- * @param launchedConfiguration
+ * @param importType one of the import operation types
+ * @param models models being imported
+ * @param forceAutobuild whether to force a build after the import
+ * @param launchedConfiguration if there is a launched target currently running
* @param alternateSource used to locate source attachments or null
if default
* source locations should be used (from active target platform).
+ * @param importerToDescriptions map of bundle importers to import descriptions if importing
+ * from a repository, else null
*
*/
- private static void doImportOperation(Shell shell, int importType, IPluginModelBase[] models, boolean forceAutobuild, boolean launchedConfiguration, SourceLocationManager alternateSource, Map importerToDescriptions) {
+ public static void doImportOperation(int importType, IPluginModelBase[] models, boolean forceAutobuild, boolean launchedConfiguration, SourceLocationManager alternateSource, Map importerToDescriptions) {
PluginImportOperation job = new PluginImportOperation(models, importType, forceAutobuild);
job.setImportDescriptions(importerToDescriptions);
job.setAlternateSource(alternateSource);
Index: src/org/eclipse/pde/internal/ui/wizards/imports/RepositoryImportWizard.java
===================================================================
RCS file: src/org/eclipse/pde/internal/ui/wizards/imports/RepositoryImportWizard.java
diff -N src/org/eclipse/pde/internal/ui/wizards/imports/RepositoryImportWizard.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/pde/internal/ui/wizards/imports/RepositoryImportWizard.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.pde.internal.ui.wizards.imports;
+
+import java.util.*;
+import java.util.Map.Entry;
+import org.eclipse.core.runtime.*;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.pde.core.plugin.IPluginModelBase;
+import org.eclipse.pde.internal.core.importing.IBundleImporter;
+import org.eclipse.pde.internal.core.importing.provisional.BundleImportDescription;
+import org.eclipse.pde.internal.core.project.BundleProjectService;
+import org.eclipse.pde.internal.ui.*;
+import org.eclipse.pde.internal.ui.provisional.IBundeImportWizardPage;
+
+/**
+ * Wizard to import plug-ins from a repository.
+ *
+ * @since 3.6
+ */
+public class RepositoryImportWizard extends Wizard {
+
+ /**
+ * Map of import delegates to import descriptions as provided by the {@link BundleProjectService}
+ */
+ private Map fImportMap;
+
+ /**
+ * Map of importer identifier to associated wizard import page
+ */
+ private Map fIdToPages = new HashMap();
+
+ private static final String STORE_SECTION = "RepositoryImportWizard"; //$NON-NLS-1$
+
+ /**
+ * Map of import delegates to import descriptions.
+ *
+ * @param importMap
+ */
+ public RepositoryImportWizard(Map importMap) {
+ IDialogSettings masterSettings = PDEPlugin.getDefault().getDialogSettings();
+ setDialogSettings(getSettingsSection(masterSettings));
+ setDefaultPageImageDescriptor(PDEPluginImages.DESC_PLUGIN_IMPORT_WIZ);
+ setWindowTitle(PDEUIMessages.ImportWizard_title);
+ fImportMap = importMap;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
+ */
+ public void addPages() {
+ Iterator iterator = fImportMap.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Entry entry = (Entry) iterator.next();
+ IBundleImporter importer = (IBundleImporter) entry.getKey();
+ BundleImportDescription[] descriptions = (BundleImportDescription[]) entry.getValue();
+ IBundeImportWizardPage page = (IBundeImportWizardPage) fIdToPages.get(importer.getId());
+ if (page == null) {
+ page = getImportPage(importer.getId());
+ if (page != null) {
+ fIdToPages.put(importer.getId(), page);
+ addPage(page);
+ page.setSelection(descriptions);
+ }
+ }
+ }
+ }
+
+ /**
+ * Creates and returns a wizard page associated with the given bundle importer extension identifier
+ * or null
of none.
+ *
+ * @param importerId org.eclipse.pde.core.bundleImporters extension identifier
+ * @return associated bundle import wizard page or null
+ */
+ private IBundeImportWizardPage getImportPage(String importerId) {
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(IPDEUIConstants.EXTENSION_POINT_BUNDLE_IMPORT_PAGES);
+ if (point != null) {
+ IConfigurationElement[] infos = point.getConfigurationElements();
+ for (int i = 0; i < infos.length; i++) {
+ IConfigurationElement element = infos[i];
+ String id = element.getAttribute("bundleImporter"); //$NON-NLS-1$
+ if (id != null && importerId.equals(id)) {
+ try {
+ return (IBundeImportWizardPage) element.createExecutableExtension("class"); //$NON-NLS-1$
+ } catch (CoreException e) {
+ PDEPlugin.log(e);
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ private IDialogSettings getSettingsSection(IDialogSettings master) {
+ IDialogSettings setting = master.getSection(STORE_SECTION);
+ if (setting == null) {
+ setting = master.addNewSection(STORE_SECTION);
+ }
+ return setting;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ public boolean performFinish() {
+ // collect the bundle descriptions from each page and import
+ Map importMap = new HashMap();
+ List plugins = new ArrayList();
+ IWizardPage[] pages = getPages();
+ for (int i = 0; i < pages.length; i++) {
+ IBundeImportWizardPage page = (IBundeImportWizardPage) pages[i];
+ if (page.finish()) {
+ BundleImportDescription[] descriptions = page.getSelection();
+ if (descriptions != null && descriptions.length > 0) {
+ for (int j = 0; j < descriptions.length; j++) {
+ BundleImportDescription description = descriptions[j];
+ if (j == 0) {
+ Object importer = description.getProperty(BundleProjectService.BUNDLE_IMPORTER);
+ if (importer != null) {
+ importMap.put(importer, descriptions);
+ }
+ }
+ Object plugin = description.getProperty(BundleProjectService.PLUGIN);
+ if (plugin != null) {
+ plugins.add(plugin);
+ }
+ }
+ }
+ } else {
+ return false;
+ }
+ }
+ if (!importMap.isEmpty()) {
+ PluginImportWizard.doImportOperation(PluginImportOperation.IMPORT_FROM_REPOSITORY, (IPluginModelBase[]) plugins.toArray(new IPluginModelBase[plugins.size()]), false, false, null, importMap);
+ }
+ return true;
+ }
+}