Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNitin Dahyabhai2016-02-25 23:35:09 +0000
committerThomas Watson2016-08-17 20:02:31 +0000
commit30280243e9f2431fc009ff143878810898d92503 (patch)
treeb2d46e50b4301cc388fd8fb6f48ea15becb7a420 /bundles
parent258e4b40ab8ac916b6832bb0d24200f870f64cf3 (diff)
downloadrt.equinox.p2-30280243e9f2431fc009ff143878810898d92503.tar.gz
rt.equinox.p2-30280243e9f2431fc009ff143878810898d92503.tar.xz
rt.equinox.p2-30280243e9f2431fc009ff143878810898d92503.zip
Bug 488504 - [ui] Allow the filter for available IUs to also match on their descriptionY20160818-1000I20160823-1359I20160823-0759
Signed-off-by: Nitin Dahyabhai <nitind@us.ibm.com> Change-Id: I19d173c5fdad89705d966c954343eda607409f46
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUGroup.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUPatternFilter.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/DelayedFilterCheckboxTree.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUDetailsGroup.java33
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/misc/StringMatcher.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUColumnConfig.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUDetailsLabelProvider.java8
8 files changed, 87 insertions, 15 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUGroup.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUGroup.java
index 26cc67738..f3747d482 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUGroup.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUGroup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2008, 2016 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
@@ -429,6 +429,10 @@ public class AvailableIUGroup extends StructuredIUGroup {
return null;
}
+ protected String getFilterString() {
+ return filteredTree.getFilterString();
+ }
+
protected GridData getViewerGridData() {
GridData data = super.getViewerGridData();
data.heightHint = convertHeightInCharsToPixels(ILayoutConstants.DEFAULT_TABLE_HEIGHT);
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUPatternFilter.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUPatternFilter.java
index d663c37fb..5dcdeb64b 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUPatternFilter.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUPatternFilter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 IBM Corporation and others.
+ * Copyright (c) 2008, 2016 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
@@ -26,7 +26,7 @@ import org.eclipse.ui.dialogs.PatternFilter;
*/
public class AvailableIUPatternFilter extends PatternFilter {
- boolean checkName, checkVersion, checkId = false;
+ boolean checkName, checkDescription, checkVersion, checkId = false;
String patternString;
/**
@@ -40,6 +40,8 @@ public class AvailableIUPatternFilter extends PatternFilter {
checkId = true;
else if (field == IUColumnConfig.COLUMN_NAME)
checkName = true;
+ else if (field == IUColumnConfig.COLUMN_DESCRIPTION)
+ checkDescription = true;
else if (field == IUColumnConfig.COLUMN_VERSION)
checkVersion = true;
}
@@ -93,6 +95,10 @@ public class AvailableIUPatternFilter extends PatternFilter {
text = iu.getProperty(IInstallableUnit.PROP_NAME, null);
if (text != null && wordMatches(text))
return true;
+ // Get the iu description in the default locale
+ text = iu.getProperty(IInstallableUnit.PROP_DESCRIPTION, null);
+ if (text != null && wordMatches(text))
+ return true;
}
if (checkId || (checkName && text == null)) {
text = iu.getId();
@@ -100,6 +106,12 @@ public class AvailableIUPatternFilter extends PatternFilter {
return true;
}
}
+ if (!checkName && checkDescription) {
+ // Get the iu description in the default locale
+ text = iu.getProperty(IInstallableUnit.PROP_DESCRIPTION, null);
+ if (text != null && wordMatches(text))
+ return true;
+ }
if (checkVersion) {
text = iu.getVersion().toString();
if (wordMatches(text))
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java
index d58bf391a..b6a770ffc 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2012 IBM Corporation and others.
+ * Copyright (c) 2007, 2016 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
@@ -23,8 +23,9 @@ import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.*;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.*;
import org.eclipse.osgi.util.NLS;
@@ -141,6 +142,19 @@ public class AvailableIUsPage extends ProvisioningWizardPage implements ISelecta
// Details area
iuDetailsGroup = new IUDetailsGroup(sashForm, availableIUGroup.getStructuredViewer(), SWT.DEFAULT, true);
+ // Clear highlighted text pattern
+ availableIUGroup.getCheckboxTreeViewer().getTree().addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusLost(FocusEvent e) {
+ iuDetailsGroup.setDetailHighlight(null);
+ }
+ });
+ availableIUGroup.getDefaultFocusControl().addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusGained(FocusEvent e) {
+ iuDetailsGroup.setDetailHighlight(null);
+ }
+ });
sashForm.setWeights(getSashWeights());
@@ -578,6 +592,7 @@ public class AvailableIUsPage extends ProvisioningWizardPage implements ISelecta
java.util.List<IInstallableUnit> selected = getSelectedIUs();
if (selected.size() == 1) {
StringBuffer result = new StringBuffer();
+ String filterString = availableIUGroup.getFilterString();
String description = selected.get(0).getProperty(IInstallableUnit.PROP_DESCRIPTION, null);
if (description != null) {
result.append(description);
@@ -593,6 +608,9 @@ public class AvailableIUsPage extends ProvisioningWizardPage implements ISelecta
}
iuDetailsGroup.setDetailText(result.toString());
+ if (result.length() > 0) {
+ iuDetailsGroup.setDetailHighlight(filterString);
+ }
return;
}
iuDetailsGroup.setDetailText(""); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/DelayedFilterCheckboxTree.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/DelayedFilterCheckboxTree.java
index 9bb1c51ba..f9101172d 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/DelayedFilterCheckboxTree.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/DelayedFilterCheckboxTree.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 IBM Corporation and others.
+ * Copyright (c) 2008, 2016 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
@@ -365,4 +365,8 @@ public class DelayedFilterCheckboxTree extends FilteredTree {
}
return new Object[0];
}
+
+ protected String getFilterString() {
+ return super.getFilterString();
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUDetailsGroup.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUDetailsGroup.java
index 442e7dd65..474ffaf41 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUDetailsGroup.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUDetailsGroup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2009, 2010 EclipseSource and others. All rights reserved. This
+* Copyright (c) 2009, 2016 EclipseSource 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
@@ -12,6 +12,7 @@ package org.eclipse.equinox.internal.p2.ui.dialogs;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.internal.p2.ui.actions.PropertyDialogAction;
+import org.eclipse.equinox.internal.p2.ui.misc.StringMatcher;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
@@ -19,6 +20,8 @@ import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.window.SameShellProvider;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.layout.GridData;
@@ -33,7 +36,7 @@ public class IUDetailsGroup {
private static final String LINKACTION = "linkAction"; //$NON-NLS-1$
private GridLayout layout;
- private Text detailsArea;
+ private StyledText detailsArea;
private GridData gd;
private Link propLink;
private ISelectionProvider selectionProvider;
@@ -76,9 +79,9 @@ public class IUDetailsGroup {
gd.minimumHeight = Dialog.convertHeightInCharsToPixels(fontMetrics, ILayoutConstants.MINIMUM_DESCRIPTION_HEIGHT);
gd.widthHint = widthHint;
if (scrollable)
- detailsArea = new Text(detailsComposite, SWT.WRAP | SWT.READ_ONLY | SWT.V_SCROLL);
+ detailsArea = new StyledText(detailsComposite, SWT.WRAP | SWT.READ_ONLY | SWT.V_SCROLL);
else
- detailsArea = new Text(detailsComposite, SWT.WRAP | SWT.READ_ONLY);
+ detailsArea = new StyledText(detailsComposite, SWT.WRAP | SWT.READ_ONLY);
detailsArea.setLayoutData(gd);
gd = new GridData(SWT.END, SWT.BOTTOM, true, false);
@@ -98,12 +101,32 @@ public class IUDetailsGroup {
// If the string is the same but the user has scrolled, the text
// widget will reset the selection. This makes it look like the text
// has changed when it hasn't. For this reason, we check equality first.
- if (lastText == null || !lastText.equals(text))
+ if (lastText == null || !lastText.equals(text)) {
detailsArea.setText(text);
+ }
lastText = text;
}
/**
+ * Set the pattern to highlight in the detail text
+ */
+ public void setDetailHighlight(String pattern) {
+ detailsArea.setStyleRanges(new StyleRange[0]);
+ if (pattern != null) {
+ StringMatcher matcher = new StringMatcher(pattern, true, false);
+ int i = 0;
+ StringMatcher.Position match = null;
+ do {
+ match = matcher.find(lastText, i, lastText.length());
+ if (match != null) {
+ i = match.getEnd();
+ detailsArea.setStyleRange(new StyleRange(match.getStart(), match.getEnd() - match.getStart(), null, null, SWT.BOLD));
+ }
+ } while (match != null);
+ }
+ }
+
+ /**
* Toggles the property link for the details area.
*/
public void enablePropertyLink(boolean enable) {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/misc/StringMatcher.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/misc/StringMatcher.java
index d0ca81bcc..feaecf03e 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/misc/StringMatcher.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/misc/StringMatcher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -40,7 +40,7 @@ public class StringMatcher {
protected static final char fSingleWildCard = '\u0000';
- static class Position {
+ public static class Position {
int start; //inclusive
int end; //exclusive
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUColumnConfig.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUColumnConfig.java
index 9a5a8196d..78f6e1b34 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUColumnConfig.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUColumnConfig.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * Copyright (c) 2007, 2016 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
@@ -48,6 +48,11 @@ public class IUColumnConfig {
*/
public final static int COLUMN_PROVIDER = 4;
+ /**
+ * Constant indicating that the column represents an IInstallableUnit's description
+ */
+ public final static int COLUMN_DESCRIPTION = 5;
+
private String columnTitle;
private int columnType;
private int columnWidth;
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUDetailsLabelProvider.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUDetailsLabelProvider.java
index 02fa62a94..d3c516912 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUDetailsLabelProvider.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUDetailsLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * Copyright (c) 2007, 2016 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
@@ -100,6 +100,12 @@ public class IUDetailsLabelProvider extends ColumnLabelProvider implements ITabl
if (showingId)
return BLANK;
return iu.getId();
+ case IUColumnConfig.COLUMN_DESCRIPTION :
+ // Get the iu description in the current locale
+ String description = iu.getProperty(IInstallableUnit.PROP_DESCRIPTION, null);
+ if (description != null)
+ return description;
+ return BLANK;
case IUColumnConfig.COLUMN_VERSION :
// If it's an element, determine if version should be shown
if (element instanceof IIUElement) {

Back to the top