Skip to content

Commit aeb906f

Browse files
committed
Files not present in branch but changes are visible in github commit
1 parent 204c26f commit aeb906f

File tree

4 files changed

+68
-14
lines changed

4 files changed

+68
-14
lines changed

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDELabelProvider.java

+17
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*******************************************************************************/
1717
package org.eclipse.pde.internal.ui;
1818

19+
import java.util.HashMap;
1920
import java.util.Locale;
2021

2122
import org.eclipse.core.resources.IProject;
@@ -86,6 +87,7 @@
8687
import org.eclipse.pde.internal.core.text.bundle.ImportPackageObject;
8788
import org.eclipse.pde.internal.core.text.bundle.PackageObject;
8889
import org.eclipse.pde.internal.core.util.VersionUtil;
90+
import org.eclipse.pde.internal.ui.dialogs.PluginSelectionDialog;
8991
import org.eclipse.pde.internal.ui.elements.NamedElement;
9092
import org.eclipse.pde.internal.ui.util.SWTUtil;
9193
import org.eclipse.pde.internal.ui.util.SharedLabelProvider;
@@ -96,6 +98,11 @@
9698

9799
public class PDELabelProvider extends SharedLabelProvider {
98100
private static final String SYSTEM_BUNDLE = "system.bundle"; //$NON-NLS-1$
101+
private IPluginModelBase currentModel;
102+
103+
public IPluginModelBase getCurrentPluginModel() {
104+
return currentModel;
105+
}
99106

100107
public PDELabelProvider() {
101108
}
@@ -203,6 +210,13 @@ public String getObjectText(IPluginBase pluginBase) {
203210
}
204211
if (pluginBase.getModel() != null && !pluginBase.getModel().isInSync())
205212
text += " " + PDEUIMessages.PluginModelManager_outOfSync; //$NON-NLS-1$
213+
214+
HashMap<String, Boolean> existingImports = PluginSelectionDialog.getExistingImports(currentModel, false);
215+
if (existingImports.get(pluginBase.getId()) != null && existingImports.get(pluginBase.getId())) {
216+
text += " " + PDEUIMessages.PluginModelManager_alreadyAddedViaReexport; //$NON-NLS-1$
217+
} else if (existingImports.get(pluginBase.getId()) != null && !existingImports.get(pluginBase.getId())) {
218+
text += " " + PDEUIMessages.PluginModelManager_alreadyAdded; //$NON-NLS-1$
219+
}
206220
return text;
207221
}
208222

@@ -952,4 +966,7 @@ public static String formatVersion(String versionRange) {
952966
return versionRange;
953967
}
954968

969+
public void setCurrentModel(IPluginModelBase currentModel) {
970+
this.currentModel = currentModel;
971+
}
955972
}

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java

+8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
public class PDEUIMessages extends NLS {
2727
private static final String BUNDLE_NAME = "org.eclipse.pde.internal.ui.pderesources";//$NON-NLS-1$
2828

29+
public static String PluginModelManager_alreadyImported;
30+
31+
public static String PluginModelManager_alreadyAdded;
32+
33+
public static String PluginModelManager_alreadyAddedViaReexport;
34+
35+
public static String PluginModelManager_alreadyExported;
36+
2937
public static String AbstractLauncherToolbar_noProblems;
3038

3139
public static String AbstractLauncherToolbar_noSelection;

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/dialogs/PluginSelectionDialog.java

+39-14
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818

1919
import java.util.Comparator;
2020
import java.util.HashMap;
21-
import java.util.HashSet;
2221

2322
import org.eclipse.core.runtime.CoreException;
2423
import org.eclipse.core.runtime.IProgressMonitor;
2524
import org.eclipse.core.runtime.IStatus;
2625
import org.eclipse.core.runtime.Status;
2726
import org.eclipse.jface.dialogs.IDialogConstants;
2827
import org.eclipse.jface.dialogs.IDialogSettings;
28+
import org.eclipse.jface.viewers.StructuredSelection;
2929
import org.eclipse.osgi.service.resolver.ExportPackageDescription;
3030
import org.eclipse.pde.core.plugin.IFragment;
3131
import org.eclipse.pde.core.plugin.IFragmentModel;
@@ -42,6 +42,7 @@
4242
import org.eclipse.pde.internal.ui.IHelpContextIds;
4343
import org.eclipse.pde.internal.ui.PDEPlugin;
4444
import org.eclipse.pde.internal.ui.PDEUIMessages;
45+
import org.eclipse.swt.widgets.Button;
4546
import org.eclipse.swt.widgets.Composite;
4647
import org.eclipse.swt.widgets.Control;
4748
import org.eclipse.swt.widgets.Shell;
@@ -137,6 +138,11 @@ public PluginSelectionDialog(Shell parentShell, IPluginModelBase[] models, boole
137138
setListLabelProvider(PDEPlugin.getDefault().getLabelProvider());
138139
}
139140

141+
public PluginSelectionDialog(Shell activeWorkbenchShell, IPluginModelBase[] availablePlugins,
142+
boolean multipleSelection, IPluginModelBase model) {
143+
this(activeWorkbenchShell, availablePlugins, multipleSelection);
144+
PDEPlugin.getDefault().getLabelProvider().setCurrentModel(model);
145+
}
140146
@Override
141147
protected void configureShell(Shell newShell) {
142148
super.configureShell(newShell);
@@ -153,8 +159,8 @@ private static IPluginModelBase[] getElements(boolean includeFragments) {
153159
return PluginRegistry.getActiveModels(includeFragments);
154160
}
155161

156-
public static HashSet<String> getExistingImports(IPluginModelBase model, boolean includeImportPkg) {
157-
HashSet<String> existingImports = new HashSet<>();
162+
public static HashMap<String, Boolean> getExistingImports(IPluginModelBase model, boolean includeImportPkg) {
163+
HashMap<String, Boolean> existingImports = new HashMap<>();
158164
addSelfAndDirectImports(existingImports, model);
159165
if (model instanceof IFragmentModel) {
160166
IFragment fragment = ((IFragmentModel) model).getFragment();
@@ -169,33 +175,34 @@ public static HashSet<String> getExistingImports(IPluginModelBase model, boolean
169175
return existingImports;
170176
}
171177

172-
private static void addSelfAndDirectImports(HashSet<String> set, IPluginModelBase model) {
178+
private static void addSelfAndDirectImports(HashMap<String, Boolean> existingImports, IPluginModelBase model) {
173179
if (model == null) {
174180
return;
175181
}
176-
set.add(model.getPluginBase().getId());
182+
existingImports.put(model.getPluginBase().getId(), false);
177183
IPluginImport[] imports = model.getPluginBase().getImports();
178184
for (IPluginImport pImport : imports) {
179185
String id = pImport.getId();
180-
if (set.add(id)) {
181-
addReexportedImport(set, id);
182-
}
186+
existingImports.put(id, false);
187+
addReexportedImport(existingImports, id);
188+
183189
}
184190
}
185191

186-
private static void addReexportedImport(HashSet<String> set, String id) {
192+
private static void addReexportedImport(HashMap<String, Boolean> existingImports, String id) {
187193
IPluginModelBase model = PluginRegistry.findModel(id);
188194
if (model != null) {
189195
IPluginImport[] imports = model.getPluginBase().getImports();
190196
for (IPluginImport pImport : imports) {
191-
if (pImport.isReexported() && set.add(pImport.getId())) {
192-
addReexportedImport(set, pImport.getId());
197+
if (pImport.isReexported()) {
198+
existingImports.put(pImport.getId(), true);
199+
addReexportedImport(existingImports, pImport.getId());
193200
}
194201
}
195202
}
196203
}
197204

198-
private static void addImportedPackages(IBundlePluginModelBase base, HashSet<String> existingImports) {
205+
private static void addImportedPackages(IBundlePluginModelBase base, HashMap<String, Boolean> existingImports) {
199206
HashMap<String, ImportPackageObject> map = getImportPackages(base);
200207
if (map == null) {
201208
return;
@@ -221,7 +228,7 @@ private static void addImportedPackages(IBundlePluginModelBase base, HashSet<Str
221228
continue;
222229
}
223230
}
224-
existingImports.add(exported[i].getSupplier().getSymbolicName());
231+
existingImports.put(exported[i].getSupplier().getSymbolicName(), false);
225232
}
226233
}
227234
}
@@ -298,4 +305,22 @@ protected void createButtonsForButtonBar(Composite parent) {
298305
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
299306
}
300307

301-
}
308+
@Override
309+
protected void updateButtonsEnableState(IStatus status) {
310+
super.updateButtonsEnableState(status);
311+
Button okButton = getOkButton();
312+
StructuredSelection currentSelection = super.getSelectedItems();
313+
HashMap<String, Boolean> existingImports = PluginSelectionDialog
314+
.getExistingImports(PDEPlugin.getDefault().getLabelProvider().getCurrentPluginModel(), false);
315+
if (!currentSelection.isEmpty())
316+
okButton.setEnabled(false);
317+
for (Object selection : currentSelection) {
318+
if (selection instanceof IPluginModelBase
319+
&& !(existingImports.keySet().contains(((IPluginModelBase) selection).getPluginBase().getId()))) {
320+
okButton.setEnabled(true);
321+
break;
322+
}
323+
324+
}
325+
}
326+
}

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ UpdateManager_op_change= Property Change
4646
########################################################
4747

4848
PluginModelManager_outOfSync = (out of sync)
49+
PluginModelManager_alreadyImported = [already imported]
50+
PluginModelManager_alreadyAdded = [already added]
51+
PluginModelManager_alreadyAddedViaReexport = [already added via re-export]
52+
PluginModelManager_alreadyExported = [already exported]
4953

5054
###### Status text #####################################
5155
ExportDestinationTab_InstallIntoCurrentPlatform=&Install into host. Repository:

0 commit comments

Comments
 (0)