Lines 10-30
Link Here
|
10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.pde.internal.ui.wizards.imports; |
11 |
package org.eclipse.pde.internal.ui.wizards.imports; |
12 |
|
12 |
|
|
|
13 |
import java.util.HashMap; |
14 |
import java.util.Iterator; |
15 |
import java.util.Map; |
13 |
import org.eclipse.core.runtime.CoreException; |
16 |
import org.eclipse.core.runtime.CoreException; |
14 |
import org.eclipse.core.runtime.IProgressMonitor; |
17 |
import org.eclipse.core.runtime.IProgressMonitor; |
15 |
import org.eclipse.core.runtime.IStatus; |
18 |
import org.eclipse.core.runtime.IStatus; |
16 |
import org.eclipse.core.runtime.Status; |
19 |
import org.eclipse.core.runtime.Status; |
17 |
import org.eclipse.core.runtime.jobs.Job; |
20 |
import org.eclipse.core.runtime.jobs.Job; |
|
|
21 |
import org.eclipse.debug.core.DebugPlugin; |
22 |
import org.eclipse.debug.core.ILaunch; |
23 |
import org.eclipse.debug.core.ILaunchConfiguration; |
24 |
import org.eclipse.debug.core.ILaunchManager; |
18 |
import org.eclipse.jface.dialogs.IDialogConstants; |
25 |
import org.eclipse.jface.dialogs.IDialogConstants; |
19 |
import org.eclipse.jface.dialogs.IDialogSettings; |
26 |
import org.eclipse.jface.dialogs.IDialogSettings; |
20 |
import org.eclipse.jface.dialogs.MessageDialog; |
27 |
import org.eclipse.jface.dialogs.MessageDialog; |
21 |
import org.eclipse.jface.viewers.IStructuredSelection; |
28 |
import org.eclipse.jface.viewers.IStructuredSelection; |
22 |
import org.eclipse.jface.wizard.IWizardPage; |
29 |
import org.eclipse.jface.wizard.IWizardPage; |
23 |
import org.eclipse.jface.wizard.Wizard; |
30 |
import org.eclipse.jface.wizard.Wizard; |
|
|
31 |
import org.eclipse.osgi.service.resolver.BundleDescription; |
24 |
import org.eclipse.pde.core.plugin.IPluginModelBase; |
32 |
import org.eclipse.pde.core.plugin.IPluginModelBase; |
25 |
import org.eclipse.pde.internal.ui.PDEPlugin; |
33 |
import org.eclipse.pde.internal.ui.PDEPlugin; |
26 |
import org.eclipse.pde.internal.ui.PDEPluginImages; |
34 |
import org.eclipse.pde.internal.ui.PDEPluginImages; |
27 |
import org.eclipse.pde.internal.ui.PDEUIMessages; |
35 |
import org.eclipse.pde.internal.ui.PDEUIMessages; |
|
|
36 |
import org.eclipse.pde.internal.ui.launcher.BundleLauncherHelper; |
28 |
import org.eclipse.pde.internal.ui.wizards.imports.PluginImportOperation.IImportQuery; |
37 |
import org.eclipse.pde.internal.ui.wizards.imports.PluginImportOperation.IImportQuery; |
29 |
import org.eclipse.swt.widgets.Display; |
38 |
import org.eclipse.swt.widgets.Display; |
30 |
import org.eclipse.swt.widgets.Shell; |
39 |
import org.eclipse.swt.widgets.Shell; |
Lines 35-50
Link Here
|
35 |
|
44 |
|
36 |
private static final String STORE_SECTION = "PluginImportWizard"; //$NON-NLS-1$ |
45 |
private static final String STORE_SECTION = "PluginImportWizard"; //$NON-NLS-1$ |
37 |
|
46 |
|
38 |
private IStructuredSelection selection; |
47 |
private IStructuredSelection selection; |
39 |
private PluginImportWizardFirstPage page1; |
48 |
private PluginImportWizardFirstPage page1; |
40 |
private BaseImportWizardSecondPage page2; |
49 |
private BaseImportWizardSecondPage page2; |
41 |
private BaseImportWizardSecondPage page3; |
50 |
private BaseImportWizardSecondPage page3; |
42 |
|
51 |
|
43 |
public PluginImportWizard() { |
52 |
public PluginImportWizard() { |
44 |
IDialogSettings masterSettings = PDEPlugin.getDefault().getDialogSettings(); |
53 |
IDialogSettings masterSettings = PDEPlugin.getDefault() |
|
|
54 |
.getDialogSettings(); |
45 |
setDialogSettings(getSettingsSection(masterSettings)); |
55 |
setDialogSettings(getSettingsSection(masterSettings)); |
46 |
setDefaultPageImageDescriptor(PDEPluginImages.DESC_PLUGIN_IMPORT_WIZ); |
56 |
setDefaultPageImageDescriptor(PDEPluginImages.DESC_PLUGIN_IMPORT_WIZ); |
47 |
setWindowTitle(PDEUIMessages.ImportWizard_title); |
57 |
setWindowTitle(PDEUIMessages.ImportWizard_title); |
48 |
} |
58 |
} |
49 |
|
59 |
|
50 |
public void init(IWorkbench workbench, IStructuredSelection selection) { |
60 |
public void init(IWorkbench workbench, IStructuredSelection selection) { |
Lines 77-98
Link Here
|
77 |
|
87 |
|
78 |
public boolean performFinish() { |
88 |
public boolean performFinish() { |
79 |
page1.storeSettings(); |
89 |
page1.storeSettings(); |
80 |
((BaseImportWizardSecondPage)page1.getNextPage()).storeSettings(); |
90 |
((BaseImportWizardSecondPage) page1.getNextPage()).storeSettings(); |
81 |
|
91 |
boolean launchedConfiguration = false; |
|
|
92 |
if (!doCheckLaunches()) { |
93 |
if (!MessageDialog |
94 |
.openConfirm(getShell(), "Choosen plug-ins can be locked", |
95 |
"Some of the selected plug-ins my not be imported. Do you want to continue?")) { |
96 |
return false; |
97 |
} |
98 |
launchedConfiguration = true; |
99 |
} |
82 |
final IPluginModelBase[] models = getModelsToImport(); |
100 |
final IPluginModelBase[] models = getModelsToImport(); |
83 |
doImportOperation(getShell(), page1.getImportType(), models, page2.forceAutoBuild()); |
101 |
doImportOperation(getShell(), page1.getImportType(), models, page2 |
|
|
102 |
.forceAutoBuild(), launchedConfiguration); |
84 |
return true; |
103 |
return true; |
85 |
} |
104 |
} |
86 |
|
105 |
|
87 |
public static void doImportOperation( |
106 |
/** |
88 |
final Shell shell, |
107 |
* @return <code>true</code> if there is no problem with locked plugins |
89 |
final int importType, |
108 |
*/ |
90 |
final IPluginModelBase[] models, |
109 |
private boolean doCheckLaunches() { |
|
|
110 |
ILaunchManager launchManager = DebugPlugin.getDefault() |
111 |
.getLaunchManager(); |
112 |
ILaunch[] launches = launchManager.getLaunches(); |
113 |
IPluginModelBase[] modelsToImport = getModelsToImport(); |
114 |
HashMap imported = new HashMap(); |
115 |
for (int j = 0; j < modelsToImport.length; ++j) { |
116 |
BundleDescription bd = modelsToImport[j].getBundleDescription(); |
117 |
if (bd != null) { |
118 |
imported.put(bd.getSymbolicName(), modelsToImport[j]); |
119 |
} |
120 |
} |
121 |
for (int i = 0; i < launches.length; ++i) { |
122 |
if (!launches[i].isTerminated()) { |
123 |
ILaunchConfiguration configuration = launches[i] |
124 |
.getLaunchConfiguration(); |
125 |
try { |
126 |
Map workspaceBundleMap = BundleLauncherHelper |
127 |
.getWorkspaceBundleMap(configuration, null); |
128 |
for (Iterator iter = workspaceBundleMap.keySet().iterator(); iter |
129 |
.hasNext();) { |
130 |
IPluginModelBase bm = (IPluginModelBase) iter.next(); |
131 |
BundleDescription description = bm |
132 |
.getBundleDescription(); |
133 |
if (description != null) { |
134 |
imported.remove(description.getSymbolicName()); |
135 |
} |
136 |
if (imported.size() == 0) //there is no need to check next bundles |
137 |
return false; |
138 |
} |
139 |
return imported.size() == modelsToImport.length; |
140 |
} catch (CoreException e) { |
141 |
PDEPlugin.logException(e); |
142 |
return false; |
143 |
} |
144 |
} |
145 |
} |
146 |
return true; |
147 |
} |
148 |
|
149 |
public static void doImportOperation(final Shell shell, |
150 |
final int importType, final IPluginModelBase[] models, |
91 |
final boolean forceAutobuild) { |
151 |
final boolean forceAutobuild) { |
|
|
152 |
doImportOperation(shell, importType, models, forceAutobuild, false); |
153 |
} |
154 |
|
155 |
|
156 |
private static void doImportOperation(final Shell shell, |
157 |
final int importType, final IPluginModelBase[] models, |
158 |
final boolean forceAutobuild, final boolean launchedConfiguration) { |
92 |
PluginImportOperation.IImportQuery query = new ImportQuery(shell); |
159 |
PluginImportOperation.IImportQuery query = new ImportQuery(shell); |
93 |
PluginImportOperation.IImportQuery executionQuery = new ImportQuery(shell); |
160 |
PluginImportOperation.IImportQuery executionQuery = new ImportQuery( |
94 |
final PluginImportOperation op = |
161 |
shell); |
95 |
new PluginImportOperation(models, importType, query, executionQuery, forceAutobuild); |
162 |
final PluginImportOperation op = new PluginImportOperation(models, |
|
|
163 |
importType, query, executionQuery, forceAutobuild); |
164 |
op.setLaunchedConfiguration(launchedConfiguration); |
96 |
Job job = new Job(PDEUIMessages.ImportWizard_title) { |
165 |
Job job = new Job(PDEUIMessages.ImportWizard_title) { |
97 |
protected IStatus run(IProgressMonitor monitor) { |
166 |
protected IStatus run(IProgressMonitor monitor) { |
98 |
try { |
167 |
try { |
Lines 108-143
Link Here
|
108 |
job.schedule(); |
177 |
job.schedule(); |
109 |
} |
178 |
} |
110 |
|
179 |
|
111 |
|
|
|
112 |
private static class ReplaceDialog extends MessageDialog { |
180 |
private static class ReplaceDialog extends MessageDialog { |
113 |
public ReplaceDialog(Shell parentShell, String dialogMessage) { |
181 |
public ReplaceDialog(Shell parentShell, String dialogMessage) { |
114 |
super( |
182 |
super(parentShell, PDEUIMessages.ImportWizard_messages_title, null, |
115 |
parentShell, |
183 |
dialogMessage, MessageDialog.QUESTION, new String[] { |
116 |
PDEUIMessages.ImportWizard_messages_title, |
|
|
117 |
null, |
118 |
dialogMessage, |
119 |
MessageDialog.QUESTION, |
120 |
new String[] { |
121 |
IDialogConstants.YES_LABEL, |
184 |
IDialogConstants.YES_LABEL, |
122 |
IDialogConstants.YES_TO_ALL_LABEL, |
185 |
IDialogConstants.YES_TO_ALL_LABEL, |
123 |
IDialogConstants.NO_LABEL, |
186 |
IDialogConstants.NO_LABEL, |
124 |
PDEUIMessages.ImportWizard_noToAll, |
187 |
PDEUIMessages.ImportWizard_noToAll, |
125 |
IDialogConstants.CANCEL_LABEL }, |
188 |
IDialogConstants.CANCEL_LABEL }, 0); |
126 |
0); |
|
|
127 |
} |
189 |
} |
128 |
} |
190 |
} |
129 |
|
191 |
|
130 |
public static class ImportQuery implements IImportQuery { |
192 |
public static class ImportQuery implements IImportQuery { |
131 |
public ImportQuery(Shell shell) {} |
193 |
public ImportQuery(Shell shell) { |
|
|
194 |
} |
132 |
|
195 |
|
133 |
private int yesToAll = 0; |
196 |
private int yesToAll = 0; |
134 |
private int[] RETURNCODES = |
197 |
private int[] RETURNCODES = { IImportQuery.YES, IImportQuery.YES, |
135 |
{ |
198 |
IImportQuery.NO, IImportQuery.NO, IImportQuery.CANCEL }; |
136 |
IImportQuery.YES, |
|
|
137 |
IImportQuery.YES, |
138 |
IImportQuery.NO, |
139 |
IImportQuery.NO, |
140 |
IImportQuery.CANCEL }; |
141 |
|
199 |
|
142 |
public int doQuery(final String message) { |
200 |
public int doQuery(final String message) { |
143 |
if (yesToAll != 0) { |
201 |
if (yesToAll != 0) { |
Lines 147-153
Link Here
|
147 |
final int[] result = { IImportQuery.CANCEL }; |
205 |
final int[] result = { IImportQuery.CANCEL }; |
148 |
Display.getDefault().syncExec(new Runnable() { |
206 |
Display.getDefault().syncExec(new Runnable() { |
149 |
public void run() { |
207 |
public void run() { |
150 |
ReplaceDialog dialog = new ReplaceDialog(Display.getDefault().getActiveShell(), message); |
208 |
ReplaceDialog dialog = new ReplaceDialog(Display |
|
|
209 |
.getDefault().getActiveShell(), message); |
151 |
int retVal = dialog.open(); |
210 |
int retVal = dialog.open(); |
152 |
if (retVal >= 0) { |
211 |
if (retVal >= 0) { |
153 |
result[0] = RETURNCODES[retVal]; |
212 |
result[0] = RETURNCODES[retVal]; |
Lines 168-174
Link Here
|
168 |
if (page1.getScanAllPlugins()) { |
227 |
if (page1.getScanAllPlugins()) { |
169 |
return page3; |
228 |
return page3; |
170 |
} |
229 |
} |
171 |
return page2; |
230 |
return page2; |
172 |
} |
231 |
} |
173 |
return null; |
232 |
return null; |
174 |
} |
233 |
} |