Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 125646 Details for
Bug 264840
[IDE] Indicate match in Open Resource dialog
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch (needs correct impl of SearchPattern.getMatchingRegions)
patch.txt (text/plain), 13.34 KB, created by
Dani Megert
on 2009-02-13 09:54:38 EST
(
hide
)
Description:
Patch (needs correct impl of SearchPattern.getMatchingRegions)
Filename:
MIME Type:
Creator:
Dani Megert
Created:
2009-02-13 09:54:38 EST
Size:
13.34 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.ide >Index: extensions/org/eclipse/ui/dialogs/FilteredResourcesSelectionDialog.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/FilteredResourcesSelectionDialog.java,v >retrieving revision 1.19 >diff -u -r1.19 FilteredResourcesSelectionDialog.java >--- extensions/org/eclipse/ui/dialogs/FilteredResourcesSelectionDialog.java 8 May 2008 21:15:22 -0000 1.19 >+++ extensions/org/eclipse/ui/dialogs/FilteredResourcesSelectionDialog.java 13 Feb 2009 14:53:44 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 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 >@@ -18,24 +18,36 @@ > import java.util.Comparator; > import java.util.List; > >-import org.eclipse.core.resources.IContainer; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.resources.IResourceProxy; >-import org.eclipse.core.resources.IResourceProxyVisitor; >-import org.eclipse.core.resources.IWorkspace; >-import org.eclipse.core.resources.ResourcesPlugin; >+import com.ibm.icu.text.Collator; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.graphics.FontData; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.TextStyle; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Shell; >+ > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.ListenerList; > import org.eclipse.core.runtime.Status; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.IResourceProxy; >+import org.eclipse.core.resources.IResourceProxyVisitor; >+import org.eclipse.core.resources.IWorkspace; >+import org.eclipse.core.resources.ResourcesPlugin; >+ > import org.eclipse.jface.action.Action; > import org.eclipse.jface.action.IAction; > import org.eclipse.jface.action.IMenuManager; > import org.eclipse.jface.action.Separator; > import org.eclipse.jface.dialogs.IDialogSettings; >-import org.eclipse.jface.text.ITextSelection; > import org.eclipse.jface.util.IPropertyChangeListener; > import org.eclipse.jface.util.PropertyChangeEvent; > import org.eclipse.jface.viewers.ILabelProviderListener; >@@ -46,10 +58,10 @@ > import org.eclipse.jface.viewers.Viewer; > import org.eclipse.jface.viewers.ViewerFilter; > import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Control; >-import org.eclipse.swt.widgets.Shell; >+import org.eclipse.jface.viewers.StyledString.Styler; >+ >+import org.eclipse.jface.text.ITextSelection; >+ > import org.eclipse.ui.IMemento; > import org.eclipse.ui.IWorkbenchPage; > import org.eclipse.ui.IWorkbenchWindow; >@@ -68,8 +80,6 @@ > import org.eclipse.ui.model.WorkbenchLabelProvider; > import org.eclipse.ui.statushandlers.StatusManager; > >-import com.ibm.icu.text.Collator; >- > /** > * Shows a list of resources to the user with a text entry field for a string > * pattern used to filter the list of resources. >@@ -103,6 +113,8 @@ > > private boolean isDerived; > >+ private SearchPattern searchPattern; >+ > /** > * Creates a new instance of the class > * >@@ -377,7 +389,9 @@ > * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createFilter() > */ > protected ItemsFilter createFilter() { >- return new ResourceFilter(container, isDerived, typeMask); >+ ItemsFilter filter= new ResourceFilter(container, isDerived, typeMask); >+ searchPattern= filter.getPatternMatcher(); >+ return filter; > } > > /* (non-Javadoc) >@@ -478,12 +492,21 @@ > > WorkbenchLabelProvider provider = new WorkbenchLabelProvider(); > >+ private Font fBoldFont; >+ >+ private Styler boldStyler; >+ >+ private Styler boldQualifierStyler; >+ >+ > /** > * Creates a new instance of the class > */ > public ResourceItemLabelProvider() { > super(); > provider.addListener(this); >+ boldStyler= createBoldStyler(); >+ boldQualifierStyler= createBoldQualifierStyler(); > } > > /* >@@ -533,16 +556,64 @@ > > IResource res = (IResource) element; > >+ String name= res.getName(); > StyledString str = new StyledString(res.getName()); >+ markMatchingRegions(str, 0, searchPattern.getMatchingRegions(name), boldStyler); > > // extra info for duplicates > if (isDuplicateElement(element)) { > str.append(" - ", StyledString.QUALIFIER_STYLER); //$NON-NLS-1$ >- str.append(res.getParent().getFullPath().makeRelative().toString(), StyledString.QUALIFIER_STYLER); >+ final String fullPath= res.getParent().getFullPath().makeRelative().toString(); >+ int index= str.length(); >+ str.append(fullPath, StyledString.QUALIFIER_STYLER); >+ markMatchingRegions(str, index, searchPattern.getMatchingRegions(fullPath), boldQualifierStyler); > } > return str; > } > >+ private void markMatchingRegions(StyledString string, int index, int[] matchingRegions, Styler styler) { >+ if (matchingRegions != null) { >+ for (int i= 0; i + 1 < matchingRegions.length; i= i + 2) >+ string.setStyle(index + matchingRegions[i], matchingRegions[i + 1], styler); >+ } >+ } >+ >+ private Styler createBoldStyler() { >+ return new Styler() { >+ public void applyStyles(TextStyle textStyle) { >+ textStyle.font= getBoldFont(); >+ } >+ }; >+ } >+ >+ private Styler createBoldQualifierStyler() { >+ return new Styler() { >+ public void applyStyles(TextStyle textStyle) { >+ StyledString.QUALIFIER_STYLER.applyStyles(textStyle); >+ textStyle.font= getBoldFont(); >+ } >+ }; >+ } >+ >+ >+ /** >+ * Create the bold variant of the currently used font. >+ * >+ * @return the bold font >+ * @since 3.5 >+ */ >+ private Font getBoldFont() { >+ if (fBoldFont == null) { >+ Font font= getDialogArea().getFont(); >+ FontData[] data= font.getFontData(); >+ for (int i= 0; i < data.length; i++) { >+ data[i].setStyle(SWT.BOLD); >+ } >+ fBoldFont= new Font(font.getDevice(), data); >+ } >+ return fBoldFont; >+ } >+ > /* > * (non-Javadoc) > * >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/dialogs/FilteredItemsSelectionDialog.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/dialogs/FilteredItemsSelectionDialog.java,v >retrieving revision 1.72 >diff -u -r1.72 FilteredItemsSelectionDialog.java >--- Eclipse UI/org/eclipse/ui/dialogs/FilteredItemsSelectionDialog.java 13 Feb 2009 07:25:02 -0000 1.72 >+++ Eclipse UI/org/eclipse/ui/dialogs/FilteredItemsSelectionDialog.java 13 Feb 2009 14:53:47 -0000 >@@ -28,6 +28,43 @@ > import java.util.List; > import java.util.Set; > >+import org.eclipse.osgi.util.NLS; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.accessibility.AccessibleAdapter; >+import org.eclipse.swt.accessibility.AccessibleEvent; >+import org.eclipse.swt.custom.CLabel; >+import org.eclipse.swt.custom.ViewForm; >+import org.eclipse.swt.events.KeyAdapter; >+import org.eclipse.swt.events.KeyEvent; >+import org.eclipse.swt.events.ModifyEvent; >+import org.eclipse.swt.events.ModifyListener; >+import org.eclipse.swt.events.MouseAdapter; >+import org.eclipse.swt.events.MouseEvent; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.TraverseEvent; >+import org.eclipse.swt.events.TraverseListener; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Menu; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.Table; >+import org.eclipse.swt.widgets.Text; >+import org.eclipse.swt.widgets.ToolBar; >+import org.eclipse.swt.widgets.ToolItem; >+ > import org.eclipse.core.commands.AbstractHandler; > import org.eclipse.core.commands.ExecutionEvent; > import org.eclipse.core.commands.IHandler; >@@ -74,41 +111,7 @@ > import org.eclipse.jface.viewers.ViewerCell; > import org.eclipse.jface.viewers.ViewerFilter; > import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider; >-import org.eclipse.osgi.util.NLS; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.accessibility.AccessibleAdapter; >-import org.eclipse.swt.accessibility.AccessibleEvent; >-import org.eclipse.swt.custom.CLabel; >-import org.eclipse.swt.custom.ViewForm; >-import org.eclipse.swt.events.KeyAdapter; >-import org.eclipse.swt.events.KeyEvent; >-import org.eclipse.swt.events.ModifyEvent; >-import org.eclipse.swt.events.ModifyListener; >-import org.eclipse.swt.events.MouseAdapter; >-import org.eclipse.swt.events.MouseEvent; >-import org.eclipse.swt.events.SelectionAdapter; >-import org.eclipse.swt.events.SelectionEvent; >-import org.eclipse.swt.events.TraverseEvent; >-import org.eclipse.swt.events.TraverseListener; >-import org.eclipse.swt.graphics.Color; >-import org.eclipse.swt.graphics.Font; >-import org.eclipse.swt.graphics.GC; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.swt.graphics.Point; >-import org.eclipse.swt.graphics.Rectangle; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.layout.GridLayout; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Control; >-import org.eclipse.swt.widgets.Display; >-import org.eclipse.swt.widgets.Event; >-import org.eclipse.swt.widgets.Label; >-import org.eclipse.swt.widgets.Menu; >-import org.eclipse.swt.widgets.Shell; >-import org.eclipse.swt.widgets.Table; >-import org.eclipse.swt.widgets.Text; >-import org.eclipse.swt.widgets.ToolBar; >-import org.eclipse.swt.widgets.ToolItem; >+ > import org.eclipse.ui.ActiveShellExpression; > import org.eclipse.ui.IMemento; > import org.eclipse.ui.IWorkbenchPreferenceConstants; >@@ -2543,6 +2546,16 @@ > */ > public abstract boolean isConsistentItem(Object item); > >+ /** >+ * Returns the search pattern patcher. >+ * >+ * @return the search pattern matcher >+ * @since 3.5 >+ */ >+ public SearchPattern getPatternMatcher() { >+ return patternMatcher; >+ } >+ > } > > /** >Index: Eclipse UI/org/eclipse/ui/dialogs/SearchPattern.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/dialogs/SearchPattern.java,v >retrieving revision 1.20 >diff -u -r1.20 SearchPattern.java >--- Eclipse UI/org/eclipse/ui/dialogs/SearchPattern.java 21 Oct 2008 13:16:56 -0000 1.20 >+++ Eclipse UI/org/eclipse/ui/dialogs/SearchPattern.java 13 Feb 2009 14:53:47 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 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 >@@ -183,6 +183,37 @@ > } > } > >+ /** >+ * Answers all the regions in a given name matching a given pattern using a specified match >+ * rule. >+ * >+ * !!! FIXME: more Javadoc needed !!! >+ * >+ * @param string the string for which to compute the match regions >+ * @return an array of <code>int</code> having two slots per returned regions (the first one is >+ * the region starting index and the second one is the region length or >+ * <code>null</code> if the given name does not match the given pattern). >+ * <p> >+ * The returned regions may be empty (<code>new int[0]</code>) if the pattern is >+ * <code>null</code> (whatever the match rule is). The returned regions will also be >+ * empty if the pattern is only made of <code>'?'</code> and/or <code>'*'</code> >+ * character(s) (e.g. <code>'*'</code>, <code>'?*'</code>, <code>'???'</code>, etc.) when using a pattern match >+ * rule. >+ * </p> >+ * @since 3.5 >+ */ >+ public int[] getMatchingRegions(String string) { >+ >+ // !!! FIXME: to be implemented correctly !!! >+ >+ if (string == null || stringPattern == null) >+ return null; >+ int i= string.toLowerCase().indexOf(stringPattern.toLowerCase()); >+ if (i == -1) >+ return null; >+ return new int[] { i, stringPattern.length() }; >+ } >+ > private void initializePatternAndMatchRule(String pattern) { > int length = pattern.length(); > if (length == 0) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 264840
:
125646
|
125715