summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrzysztof Daniel2013-08-09 08:58:47 (EDT)
committerGerrit Code Review @ Eclipse.org2013-08-12 16:36:10 (EDT)
commit7c94729ac1e9053b9e0d752659380c06c44de009 (patch)
treed3007b46c4061ba7f12b7d6f691fe76b5734001a
parent7ac29f34dc785ec602e33970f6db0673da54beab (diff)
downloadeclipse.pde.ui-7c94729ac1e9053b9e0d752659380c06c44de009.zip
eclipse.pde.ui-7c94729ac1e9053b9e0d752659380c06c44de009.tar.gz
eclipse.pde.ui-7c94729ac1e9053b9e0d752659380c06c44de009.tar.bz2
Bug 322352: Feature selection dialog should list features containingrefs/changes/85/15285/6
plugins matched by the filter Change-Id: I1c858e9e7e5b1e17c26b5c18f737b22e45619643 Signed-off-by: Krzysztof Daniel <kdaniel@redhat.com>
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java4
-rwxr-xr-xui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/dialogs/FeatureSelectionDialog.java70
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties2
3 files changed, 70 insertions, 6 deletions
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java
index 729c31c..850e38b 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java
@@ -1186,9 +1186,13 @@ public class PDEUIMessages extends NLS {
public static String NewFeaturePatch_SpecPage_name;
public static String NewFeaturePatch_SpecPage_provider;
public static String NewFeaturePatch_SpecPage_notFound;
+ public static String FeatureSelectionDialog_IdMatched;
+
public static String FeatureSelectionDialog_title;
public static String FeatureSelectionDialog_message;
+ public static String FeatureSelectionDialog_PluginMatched;
+
public static String VersionSyncWizard_wtitle;
public static String VersionSyncWizard_title;
public static String VersionSyncWizard_desc;
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/dialogs/FeatureSelectionDialog.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/dialogs/FeatureSelectionDialog.java
index 9819dd4..56adc05 100755
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/dialogs/FeatureSelectionDialog.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/dialogs/FeatureSelectionDialog.java
@@ -9,6 +9,7 @@
* IBM Corporation - initial API and implementation
* Lars Vogel <Lars.Vogel@vogella.com> - Fix for bug 376057 - Wildcard suport
* for adding features in product configuration editor
+ * Red Hat, Inc - 322352
*******************************************************************************/
package org.eclipse.pde.internal.ui.dialogs;
@@ -16,8 +17,9 @@ package org.eclipse.pde.internal.ui.dialogs;
import java.util.Comparator;
import org.eclipse.core.runtime.*;
import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.pde.internal.core.ifeature.IFeature;
-import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.pde.internal.core.ifeature.*;
import org.eclipse.pde.internal.ui.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.PlatformUI;
@@ -27,23 +29,68 @@ public class FeatureSelectionDialog extends FilteredItemsSelectionDialog {
private static final String DIALOG_SETTINGS = "org.eclipse.pde.ui.dialogs.FeatureSelectionDialog"; //$NON-NLS-1$
private IFeatureModel[] fModels;
+ private FeatureSearchItemsFilter filter;
+
+ private final class FeatureDetailsLabelProvider extends LabelProvider {
+ @Override
+ public String getText(Object element) {
+ if (element instanceof IFeatureModel) {
+ IFeatureModel featureModel = (IFeatureModel) element;
+ if (filter.matchesFeatureId(featureModel)) {
+ return NLS.bind(PDEUIMessages.FeatureSelectionDialog_IdMatched, featureModel.getFeature().getId());
+ }
+ String pluginMatch = filter.matchesPluginId((IFeatureModel) element);
+ if (pluginMatch != null) {
+ return NLS.bind(PDEUIMessages.FeatureSelectionDialog_PluginMatched, pluginMatch);
+ }
+ }
+ return super.getText(element);
+ }
+ }
private class FeatureSearchItemsFilter extends ItemsFilter {
+ @Override
public boolean isConsistentItem(Object item) {
return true;
}
+ @Override
public boolean matchItem(Object item) {
- String id = null;
if (item instanceof IFeatureModel) {
IFeatureModel model = (IFeatureModel) item;
- id = model.getFeature().getId();
+ if (matchesFeatureId(model))
+ return true;
+ return matchesPluginId(model) != null;
}
+ return false;
+ }
- return (matches(id));
+ /**
+ *
+ * @param model
+ * @return id of matched plugin or null if no match
+ */
+ public String matchesPluginId(IFeatureModel model) {
+ IFeaturePlugin[] plugins = model.getFeature().getPlugins();
+ for (int i = 0; i < plugins.length; i++) {
+ if (matches(plugins[i].getId())) {
+ return plugins[i].getId();
+ }
+ }
+ return null;
+ }
+
+ public boolean matchesFeatureId(IFeatureModel model) {
+ String id;
+ id = model.getFeature().getId();
+ if (matches(id)) {
+ return true;
+ }
+ return false;
}
+ @Override
protected boolean matches(String text) {
String pattern = patternMatcher.getPattern();
if (pattern.indexOf("*") != 0 & pattern.indexOf("?") != 0 & pattern.indexOf(".") != 0) {//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -95,6 +142,7 @@ public class FeatureSelectionDialog extends FilteredItemsSelectionDialog {
super(parent, multiSelect);
setTitle(PDEUIMessages.FeatureSelectionDialog_title);
setMessage(PDEUIMessages.FeatureSelectionDialog_message);
+ setDetailsLabelProvider(new FeatureDetailsLabelProvider());
this.fModels = models;
PDEPlugin.getDefault().getLabelProvider().connect(this);
setListLabelProvider(PDEPlugin.getDefault().getLabelProvider());
@@ -103,20 +151,24 @@ public class FeatureSelectionDialog extends FilteredItemsSelectionDialog {
/*
* @see org.eclipse.jface.window.Window#configureShell(Shell)
*/
+ @Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IHelpContextIds.FEATURE_SELECTION);
}
+ @Override
public boolean close() {
PDEPlugin.getDefault().getLabelProvider().disconnect(this);
return super.close();
}
+ @Override
protected Control createExtendedContentArea(Composite parent) {
return null;
}
+ @Override
protected IDialogSettings getDialogSettings() {
IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(DIALOG_SETTINGS);
@@ -130,18 +182,23 @@ public class FeatureSelectionDialog extends FilteredItemsSelectionDialog {
/* (non-Javadoc)
* @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#validateItem(java.lang.Object)
*/
+ @Override
protected IStatus validateItem(Object item) {
return new Status(IStatus.OK, IPDEUIConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
}
+ @Override
protected ItemsFilter createFilter() {
- return new FeatureSearchItemsFilter();
+ filter = new FeatureSearchItemsFilter();
+ return filter;
}
+ @Override
protected Comparator<?> getItemsComparator() {
return new FeatureSearchComparator();
}
+ @Override
protected void fillContentProvider(AbstractContentProvider contentProvider, ItemsFilter itemsFilter, IProgressMonitor progressMonitor) throws CoreException {
for (int i = 0; i < fModels.length; i++) {
contentProvider.add(fModels[i], itemsFilter);
@@ -151,6 +208,7 @@ public class FeatureSelectionDialog extends FilteredItemsSelectionDialog {
}
+ @Override
public String getElementName(Object item) {
if (item instanceof IFeatureModel) {
IFeatureModel model = (IFeatureModel) item;
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties
index 603c9e5..87b3e68 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties
@@ -863,6 +863,8 @@ NewFeaturePatch_SpecPage_id = Patc&h ID:
NewFeaturePatch_SpecPage_name = Patch N&ame:
NewFeaturePatch_SpecPage_provider = Patch Vendo&r:
NewFeaturePatch_SpecPage_notFound = Feature {0} {1} not found.
+FeatureSelectionDialog_IdMatched=Feature {0}.
+FeatureSelectionDialog_PluginMatched =Feature contains plug-in {0}.
FeatureSelectionDialog_title = Feature Selection
FeatureSelectionDialog_message = &Select a feature: