Lines 10-25
Link Here
|
10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.pde.internal.ui.views.plugins; |
11 |
package org.eclipse.pde.internal.ui.views.plugins; |
12 |
|
12 |
|
13 |
import java.util.ArrayList; |
13 |
import java.util.*; |
14 |
import java.util.Iterator; |
14 |
import org.eclipse.core.runtime.CoreException; |
15 |
import org.eclipse.jface.action.*; |
15 |
import org.eclipse.jface.action.*; |
|
|
16 |
import org.eclipse.jface.dialogs.MessageDialog; |
16 |
import org.eclipse.jface.viewers.ISelection; |
17 |
import org.eclipse.jface.viewers.ISelection; |
17 |
import org.eclipse.jface.viewers.IStructuredSelection; |
18 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
|
19 |
import org.eclipse.jface.wizard.WizardDialog; |
18 |
import org.eclipse.pde.core.plugin.*; |
20 |
import org.eclipse.pde.core.plugin.*; |
|
|
21 |
import org.eclipse.pde.internal.core.importing.provisional.BundleImportDescription; |
22 |
import org.eclipse.pde.internal.core.importing.provisional.IBundleImporterDelegate; |
23 |
import org.eclipse.pde.internal.core.project.BundleProjectService; |
24 |
import org.eclipse.pde.internal.ui.PDEPlugin; |
19 |
import org.eclipse.pde.internal.ui.PDEUIMessages; |
25 |
import org.eclipse.pde.internal.ui.PDEUIMessages; |
20 |
import org.eclipse.pde.internal.ui.wizards.imports.PluginImportOperation; |
26 |
import org.eclipse.pde.internal.ui.wizards.imports.*; |
21 |
import org.eclipse.pde.internal.ui.wizards.imports.PluginImportWizard; |
|
|
22 |
import org.eclipse.swt.widgets.Display; |
27 |
import org.eclipse.swt.widgets.Display; |
|
|
28 |
import org.eclipse.swt.widgets.Shell; |
23 |
import org.eclipse.ui.actions.ActionContext; |
29 |
import org.eclipse.ui.actions.ActionContext; |
24 |
import org.eclipse.ui.actions.ActionGroup; |
30 |
import org.eclipse.ui.actions.ActionGroup; |
25 |
|
31 |
|
Lines 42-47
Link Here
|
42 |
case PluginImportOperation.IMPORT_WITH_SOURCE : |
48 |
case PluginImportOperation.IMPORT_WITH_SOURCE : |
43 |
setText(PDEUIMessages.PluginsView_asSourceProject); |
49 |
setText(PDEUIMessages.PluginsView_asSourceProject); |
44 |
break; |
50 |
break; |
|
|
51 |
case PluginImportOperation.IMPORT_FROM_REPOSITORY : |
52 |
setText(PDEUIMessages.ImportActionGroup_Repository_project); |
53 |
break; |
45 |
} |
54 |
} |
46 |
} |
55 |
} |
47 |
|
56 |
|
Lines 64-69
Link Here
|
64 |
importMenu.add(new ImportAction(PluginImportOperation.IMPORT_BINARY, sSelection)); |
73 |
importMenu.add(new ImportAction(PluginImportOperation.IMPORT_BINARY, sSelection)); |
65 |
importMenu.add(new ImportAction(PluginImportOperation.IMPORT_BINARY_WITH_LINKS, sSelection)); |
74 |
importMenu.add(new ImportAction(PluginImportOperation.IMPORT_BINARY_WITH_LINKS, sSelection)); |
66 |
importMenu.add(new ImportAction(PluginImportOperation.IMPORT_WITH_SOURCE, sSelection)); |
75 |
importMenu.add(new ImportAction(PluginImportOperation.IMPORT_WITH_SOURCE, sSelection)); |
|
|
76 |
importMenu.add(new ImportAction(PluginImportOperation.IMPORT_FROM_REPOSITORY, sSelection)); |
67 |
menu.add(importMenu); |
77 |
menu.add(importMenu); |
68 |
} |
78 |
} |
69 |
} |
79 |
} |
Lines 79-86
Link Here
|
79 |
if (display == null) |
89 |
if (display == null) |
80 |
display = Display.getDefault(); |
90 |
display = Display.getDefault(); |
81 |
IPluginModelBase[] models = (IPluginModelBase[]) externalModels.toArray(new IPluginModelBase[externalModels.size()]); |
91 |
IPluginModelBase[] models = (IPluginModelBase[]) externalModels.toArray(new IPluginModelBase[externalModels.size()]); |
|
|
92 |
if (importType == PluginImportOperation.IMPORT_FROM_REPOSITORY) { |
93 |
Map importMap = getImportDescriptions(display.getActiveShell(), models); |
94 |
if (importMap != null) { |
95 |
RepositoryImportWizard wizard = new RepositoryImportWizard(importMap); |
96 |
WizardDialog dialog = new WizardDialog(display.getActiveShell(), wizard); |
97 |
dialog.open(); |
98 |
} |
99 |
} else { |
100 |
PluginImportWizard.doImportOperation(display.getActiveShell(), importType, models, false); |
101 |
} |
102 |
} |
82 |
|
103 |
|
83 |
PluginImportWizard.doImportOperation(display.getActiveShell(), importType, models, false); |
104 |
/** |
|
|
105 |
* Return a map of {@link IBundleImporterDelegate} > Array of {@link BundleImportDescription} to be imported. |
106 |
* |
107 |
* @param shell shell to open message dialogs on, if required |
108 |
* @param models candidate models |
109 |
* @return map of importer delegates to import descriptions |
110 |
*/ |
111 |
private Map getImportDescriptions(Shell shell, IPluginModelBase[] models) { |
112 |
BundleProjectService service = (BundleProjectService) BundleProjectService.getDefault(); |
113 |
try { |
114 |
Map descriptions = service.getImportDescriptions(models); // all possible descriptions |
115 |
if (!descriptions.isEmpty()) { |
116 |
return descriptions; |
117 |
} |
118 |
// no applicable importers for selected models |
119 |
MessageDialog.openInformation(shell, PDEUIMessages.ImportWizard_title, PDEUIMessages.ImportActionGroup_cannot_import); |
120 |
} catch (CoreException e) { |
121 |
PDEPlugin.log(e); |
122 |
MessageDialog.openError(shell, PDEUIMessages.ImportWizard_title, e.getMessage()); |
123 |
} |
124 |
return null; |
84 |
} |
125 |
} |
85 |
|
126 |
|
86 |
public static boolean canImport(IStructuredSelection selection) { |
127 |
public static boolean canImport(IStructuredSelection selection) { |