|
From: <caw...@us...> - 2007-05-15 17:36:20
|
Revision: 2479
http://svn.sourceforge.net/rubyeclipse/?rev=2479&view=rev
Author: cawilliams
Date: 2007-05-15 10:36:12 -0700 (Tue, 15 May 2007)
Log Message:
-----------
new Ruby Search UI for our brand spanking-new search engine
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF
trunk/org.rubypeople.rdt.ui/plugin.xml
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/SearchUtils.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/IRubyHelpContextIds.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/IRubyConstants.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/TS_InternalUi.java
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/search/TS_InternalUiRubySearch.java
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/ui/tests/TS_Ui.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/prj_mode.gif
trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/type_mode.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/prj_mode.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/type_mode.gif
trunk/org.rubypeople.rdt.ui/icons/full/obj16/rsearch_obj.gif
trunk/org.rubypeople.rdt.ui/icons/full/obj16/search_decl_obj.gif
trunk/org.rubypeople.rdt.ui/icons/full/obj16/search_ref_obj.gif
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/dnd/
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/ColorDecoratingLabelProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/FilterAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/FiltersDialog.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/FiltersDialogAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/GroupAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/IOccurrencesFinder.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/LRUWorkingSetsList.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/LevelTreeContentProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/MatchFilter.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/NewSearchResultCollector.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/NewSearchViewActionGroup.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/PatternStrings.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/PostfixLabelProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubyElementMatch.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchContentProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchEditorOpener.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchPage.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchQuery.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchResult.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchResultPage.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchScopeFactory.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchTableContentProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchLabelProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchParticipantDescriptor.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchParticipantRecord.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchParticipantsExtensionPoint.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchUtil.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SortAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SortingLabelProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/WorkingSetComparator.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/WorkingSetsComparator.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/IProblemChangedListener.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/ProblemMarkerManager.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/ProblemTableViewer.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/ProblemTreeViewer.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/ResourceToItemsMapper.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/IWorkingCopyProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/ProblemsLabelDecorator.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/NavigateActionGroup.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/GroupByAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/GroupByPathStrategy.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/GroupByScopeStrategy.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/IGroupByStrategy.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchLabelProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchPage.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchQuery.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchResult.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchResultPage.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchTreeContentProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/Scope.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/symbols/BlockingSymbolFinder.java
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/search/TC_GroupByScopeStrategy.java
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/search/TC_RubySearchTreeContentProvider.java
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/search/TC_Scope.java
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/symbols/TC_BlockingSymbolFinder.java
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/symbols/TS_UiSymbols.java
Modified: trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF 2007-05-15 17:34:21 UTC (rev 2478)
+++ trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF 2007-05-15 17:36:12 UTC (rev 2479)
@@ -21,7 +21,6 @@
org.rubypeople.rdt.internal.ui.resourcesview,
org.rubypeople.rdt.internal.ui.rubyeditor,
org.rubypeople.rdt.internal.ui.search,
- org.rubypeople.rdt.internal.ui.symbols,
org.rubypeople.rdt.internal.ui.text,
org.rubypeople.rdt.internal.ui.text.folding,
org.rubypeople.rdt.internal.ui.text.ruby,
Added: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/prj_mode.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/prj_mode.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/type_mode.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/type_mode.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/prj_mode.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/prj_mode.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/type_mode.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/type_mode.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/obj16/rsearch_obj.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/obj16/rsearch_obj.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/obj16/search_decl_obj.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/obj16/search_decl_obj.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/obj16/search_ref_obj.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/obj16/search_ref_obj.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/org.rubypeople.rdt.ui/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.xml 2007-05-15 17:34:21 UTC (rev 2478)
+++ trunk/org.rubypeople.rdt.ui/plugin.xml 2007-05-15 17:36:12 UTC (rev 2479)
@@ -908,20 +908,6 @@
fileNames="%EditorRubyFile.filenames">
</participant>
</extension>
- <extension
- point="org.eclipse.search.searchPages">
- <page
- class="org.rubypeople.rdt.internal.ui.search.RubySearchPage"
- id="org.rubypeople.rdt.ui.RubySearchPage"
- label="%RubySearchPage.label"/>
- </extension>
- <extension
- point="org.eclipse.search.searchResultViewPages">
- <viewPage
- class="org.rubypeople.rdt.internal.ui.search.RubySearchResultPage"
- id="org.rubypeople.rdt.ui.search.RubySearchResultPage"
- searchResultClass="org.rubypeople.rdt.internal.ui.search.RubySearchResult"/>
- </extension>
<extension point="org.rubypeople.rdt.ui.rubyEditorTextHovers">
<hover
@@ -1019,4 +1005,41 @@
class="org.rubypeople.rdt.internal.ui.text.hyperlinks.RubyElementsHyperlinkProvider">
</hyperlinkProvider>
</extension>
+
+<!-- =========================================================================== -->
+<!-- Ruby Search Page -->
+<!-- =========================================================================== -->
+ <extension
+ point="org.eclipse.search.searchPages">
+ <page
+ showScopeSection="true"
+ canSearchEnclosingProjects="true"
+ label="%RubySearchPage.label"
+ icon="$nl$/icons/full/obj16/rsearch_obj.gif"
+ extensions="rb:90,rbw:90"
+ class="org.rubypeople.rdt.internal.ui.search.RubySearchPage"
+ sizeHint="460,160"
+ id="org.rubypeople.rdt.ui.RubySearchPage">
+ </page>
+ </extension>
+
+ <extension
+ id="RubySearchResultPage"
+ point="org.eclipse.search.searchResultViewPages">
+ <viewPage
+ id="org.rubypeople.rdt.ui.RubySearchResultPage"
+ searchResultClass="org.rubypeople.rdt.internal.ui.search.RubySearchResult"
+ class="org.rubypeople.rdt.internal.ui.search.RubySearchResultPage">
+ </viewPage>
+ </extension>
+<!-- <extension
+ id="OccurrencesSearchResultPage"
+ point="org.eclipse.search.searchResultViewPages">
+ <viewPage
+ id="org.rubypeople.rdt.internal.ui.search.OccurrencesSearchResultPage"
+ searchResultClass="org.rubypeople.rdt.internal.ui.search.OccurrencesSearchResult"
+ class="org.rubypeople.rdt.internal.ui.search.OccurrencesSearchResultPage">
+ </viewPage>
+ </extension>
+ -->
</plugin>
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/SearchUtils.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/SearchUtils.java 2007-05-15 17:34:21 UTC (rev 2478)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/SearchUtils.java 2007-05-15 17:36:12 UTC (rev 2479)
@@ -1,10 +1,18 @@
package org.rubypeople.rdt.internal.corext.util;
+import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.search.SearchPattern;
public class SearchUtils {
/**
+ * Constant for use as matchRule in {@link SearchPattern#createPattern(IRubyElement, int, int)}
+ * to get search behavior as of 3.1M3 (all generic instantiations are found).
+ */
+ public final static int GENERICS_AGNOSTIC_MATCH_RULE= SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE | SearchPattern.R_ERASURE_MATCH;
+
+
+ /**
* Returns whether the given pattern is a camel case pattern or not.
*
* @param pattern the pattern to inspect
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/IRubyHelpContextIds.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/IRubyHelpContextIds.java 2007-05-15 17:34:21 UTC (rev 2478)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/IRubyHelpContextIds.java 2007-05-15 17:36:12 UTC (rev 2479)
@@ -224,7 +224,7 @@
public static final String EXCLUSION_PATTERN_DIALOG= PREFIX + "exclusion_pattern_dialog_context"; //$NON-NLS-1$
public static final String OUTPUT_LOCATION_DIALOG= PREFIX + "output_location_dialog_context"; //$NON-NLS-1$
public static final String VARIABLE_CREATION_DIALOG= PREFIX + "variable_creation_dialog_context"; //$NON-NLS-1$
- public static final String JAVA_SEARCH_PAGE= PREFIX + "java_search_page_context"; //$NON-NLS-1$
+ public static final String RUBY_SEARCH_PAGE= PREFIX + "java_search_page_context"; //$NON-NLS-1$
public static final String NLS_SEARCH_PAGE= PREFIX + "nls_search_page_context"; //$NON-NLS-1$
public static final String JAVA_EDITOR= PREFIX + "java_editor_context"; //$NON-NLS-1$
public static final String GOTO_RESOURCE_DIALOG= PREFIX + "goto_resource_dialog"; //$NON-NLS-1$
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java 2007-05-15 17:34:21 UTC (rev 2478)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java 2007-05-15 17:36:12 UTC (rev 2479)
@@ -54,7 +54,6 @@
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.WorkingCopyOwner;
-import org.rubypeople.rdt.internal.core.util.EclipseJobScheduler;
import org.rubypeople.rdt.internal.corext.util.TypeFilter;
import org.rubypeople.rdt.internal.formatter.OldCodeFormatter;
import org.rubypeople.rdt.internal.ui.preferences.MembersOrderPreferenceCache;
@@ -64,12 +63,12 @@
import org.rubypeople.rdt.internal.ui.rubyeditor.RubyDocumentProvider;
import org.rubypeople.rdt.internal.ui.rubyeditor.RubyScriptDocumentProvider;
import org.rubypeople.rdt.internal.ui.rubyeditor.WorkingCopyManager;
-import org.rubypeople.rdt.internal.ui.symbols.BlockingSymbolFinder;
import org.rubypeople.rdt.internal.ui.text.IRubyColorConstants;
import org.rubypeople.rdt.internal.ui.text.PreferencesAdapter;
import org.rubypeople.rdt.internal.ui.text.folding.RubyFoldingStructureProviderRegistry;
import org.rubypeople.rdt.internal.ui.text.ruby.hover.RubyEditorTextHoverDescriptor;
import org.rubypeople.rdt.internal.ui.text.template.contentassist.RubyTemplateAccess;
+import org.rubypeople.rdt.internal.ui.viewsupport.ProblemMarkerManager;
import org.rubypeople.rdt.ui.PreferenceConstants;
import org.rubypeople.rdt.ui.text.RubyTextTools;
@@ -115,6 +114,7 @@
* @since 1.0
*/
private TypeFilter fTypeFilter;
+ private ProblemMarkerManager fProblemMarkerManager;
public RubyPlugin() {
super();
@@ -167,10 +167,6 @@
fMembersOrderPreferenceCache = new MembersOrderPreferenceCache();
fMembersOrderPreferenceCache.install(store);
- RubyCore rubyCore = RubyCore.getPlugin();
- BlockingSymbolFinder symbolFinder = new BlockingSymbolFinder(rubyCore.getSymbolFinder(), new EclipseJobScheduler());
- rubyCore.setSymbolFinder(symbolFinder);
-
listenForNewProjects();
upgradeOldProjects();
String generateRdocOption = Platform.getDebugOption(RubyPlugin.PLUGIN_ID + "/generaterdoc");
@@ -622,5 +618,11 @@
}
return fRubyEditorTextHoverDescriptors;
- }
+ }
+
+ public synchronized ProblemMarkerManager getProblemMarkerManager() {
+ if (fProblemMarkerManager == null)
+ fProblemMarkerManager= new ProblemMarkerManager();
+ return fProblemMarkerManager;
+ }
}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java 2007-05-15 17:34:21 UTC (rev 2478)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java 2007-05-15 17:36:12 UTC (rev 2479)
@@ -43,6 +43,8 @@
public static final String IMG_OBJS_INFO = NAME_PREFIX + "info_obj.gif";
public static final String IMG_OBJS_HELP= NAME_PREFIX + "help.gif"; //$NON-NLS-1$
private static final String IMG_OBJS_GHOST= NAME_PREFIX + "ghost.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_SEARCH_DECL= NAME_PREFIX + "search_decl_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_SEARCH_REF= NAME_PREFIX + "search_ref_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_CLASS= NAME_PREFIX + "class_obj.gif"; //$NON-NLS-1$
private static final String IMG_OBJS_INNER_CLASS= NAME_PREFIX + "innerclass_obj.gif"; //$NON-NLS-1$
@@ -103,6 +105,8 @@
public static final ImageDescriptor DESC_OBJS_EXTJAR= createManagedFromKey(T_OBJ, IMG_OBJS_EXTJAR);
public static final ImageDescriptor DESC_OBJS_EXTJAR_WSRC= createManagedFromKey(T_OBJ, IMG_OBJS_EXTJAR_WSRC);
public static final ImageDescriptor DESC_OBJS_ENV_VAR= createManagedFromKey(T_OBJ, IMG_OBJS_ENV_VAR);
+ public static final ImageDescriptor DESC_OBJS_SEARCH_DECL= createManagedFromKey(T_OBJ, IMG_OBJS_SEARCH_DECL);
+ public static final ImageDescriptor DESC_OBJS_SEARCH_REF= createManagedFromKey(T_OBJ, IMG_OBJS_SEARCH_REF);
public static final ImageDescriptor DESC_OBJS_EXCLUSION_FILTER_ATTRIB= createUnManaged(T_OBJ, "exclusion_filter_attrib.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJS_INCLUSION_FILTER_ATTRIB= createUnManaged(T_OBJ, "inclusion_filter_attrib.gif"); //$NON-NLS-1$
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/ColorDecoratingLabelProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/ColorDecoratingLabelProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/ColorDecoratingLabelProvider.java 2007-05-15 17:36:12 UTC (rev 2479)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.ui.search;
+
+import org.eclipse.jface.viewers.DecoratingLabelProvider;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.swt.graphics.Color;
+
+public class ColorDecoratingLabelProvider extends DecoratingLabelProvider implements IColorProvider {
+
+ public ColorDecoratingLabelProvider(ILabelProvider provider, ILabelDecorator decorator) {
+ super(provider, decorator);
+ }
+
+ public Color getForeground(Object element) {
+ ILabelProvider labelProvider = getLabelProvider();
+ if (labelProvider instanceof IColorProvider)
+ return ((IColorProvider)labelProvider).getForeground(element);
+ return null;
+ }
+
+ public Color getBackground(Object element) {
+ ILabelProvider labelProvider = getLabelProvider();
+ if (labelProvider instanceof IColorProvider)
+ return ((IColorProvider)labelProvider).getBackground(element);
+ return null;
+ }
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/FilterAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/FilterAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/FilterAction.java 2007-05-15 17:36:12 UTC (rev 2479)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.ui.search;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+
+
+public class FilterAction extends Action {
+ private MatchFilter fFilter;
+ private RubySearchResultPage fPage;
+
+ public FilterAction(RubySearchResultPage page, MatchFilter filter) {
+ super(filter.getActionLabel(), IAction.AS_CHECK_BOX);
+ fPage= page;
+ fFilter= filter;
+ }
+
+ public void run() {
+ if (fPage.hasMatchFilter(getFilter())) {
+ fPage.removeMatchFilter(fFilter);
+ } else {
+ fPage.addMatchFilter(fFilter);
+ }
+ }
+
+ public MatchFilter getFilter() {
+ return fFilter;
+ }
+
+ public void updateCheckState() {
+ setChecked(fPage.hasMatchFilter(getFilter()));
+ }
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/FiltersDialog.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/FiltersDialog.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/FiltersDialog.java 2007-05-15 17:36:12 UTC (rev 2479)
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.rubypeople.rdt.internal.ui.search;
+
+import java.util.Arrays;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.SelectionStatusDialog;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+
+public class FiltersDialog extends SelectionStatusDialog {
+
+ private CheckboxTableViewer fListViewer;
+ private RubySearchResultPage fPage;
+ private Button fLimitElementsCheckbox;
+ private Text fLimitElementsField;
+
+ private int fLimitElementCount= 1000;
+ private boolean fLimitElements= false;
+
+ public FiltersDialog(RubySearchResultPage page) {
+ super(page.getSite().getShell());
+ setTitle(org.rubypeople.rdt.internal.ui.search.SearchMessages.FiltersDialog_title);
+ setStatusLineAboveButtons(true);
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ fPage = page;
+ }
+
+ public MatchFilter[] getEnabledFilters() {
+ Object[] result = getResult();
+ MatchFilter[] filters = new MatchFilter[result.length];
+ System.arraycopy(result, 0, filters, 0, filters.length);
+ return filters;
+ }
+
+ public boolean isLimitEnabled() {
+ return fLimitElements;
+ }
+
+ /**
+ * @return returns the number of entries to limit the filters entry to
+ */
+ public int getElementLimit() {
+ return fLimitElementCount;
+ }
+
+ /*
+ * (non-Rubydoc) Method declared on Dialog.
+ */
+ protected Control createDialogArea(Composite composite) {
+ Composite parent = (Composite) super.createDialogArea(composite);
+ initializeDialogUnits(composite);
+
+ createTableLimit(parent);
+ // Create list viewer
+ Label l= new Label(parent, SWT.NONE);
+ l.setFont(parent.getFont());
+ l.setText(org.rubypeople.rdt.internal.ui.search.SearchMessages.FiltersDialog_filters_label);
+
+ Table table = new Table(parent, SWT.CHECK | SWT.BORDER);
+ table.setFont(parent.getFont());
+ fListViewer = new CheckboxTableViewer(table);
+
+
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.minimumHeight= convertHeightInCharsToPixels(8);
+ table.setLayoutData(data);
+
+ fListViewer.setLabelProvider(new LabelProvider() {
+ public String getText(Object element) {
+ // Return the features's label.
+ return ((MatchFilter) element).getName();
+ }
+ });
+
+ // Set the content provider
+ ArrayContentProvider cp = new ArrayContentProvider();
+ fListViewer.setContentProvider(cp);
+ fListViewer.setInput(MatchFilter.allFilters());
+ fListViewer.setCheckedElements(fPage.getMatchFilters());
+
+ l= new Label(parent, SWT.NONE);
+ l.setFont(parent.getFont());
+ l.setText(org.rubypeople.rdt.internal.ui.search.SearchMessages.FiltersDialog_description_label);
+ final Text description = new Text(parent, SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL);
+ description.setFont(parent.getFont());
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.heightHint = convertHeightInCharsToPixels(3);
+ description.setLayoutData(data);
+ fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ Object selectedElement = ((IStructuredSelection) event.getSelection()).getFirstElement();
+ if (selectedElement != null)
+ description.setText(((MatchFilter) selectedElement).getDescription());
+ else
+ description.setText(""); //$NON-NLS-1$
+ }
+ });
+ return parent;
+ }
+
+
+ private void createTableLimit(Composite ancestor) {
+ Composite parent = new Composite(ancestor, SWT.NONE);
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 2;
+ gl.marginWidth = 0;
+ gl.marginHeight = 0;
+ parent.setLayout(gl);
+ GridData gd = new GridData();
+ gd.horizontalSpan = 2;
+ parent.setLayoutData(gd);
+
+ fLimitElementsCheckbox = new Button(parent, SWT.CHECK);
+ fLimitElementsCheckbox.setText(org.rubypeople.rdt.internal.ui.search.SearchMessages.FiltersDialog_limit_label);
+ fLimitElementsCheckbox.setLayoutData(new GridData());
+
+ fLimitElementsField = new Text(parent, SWT.BORDER);
+ gd = new GridData();
+ gd.widthHint = convertWidthInCharsToPixels(6);
+ fLimitElementsField.setLayoutData(gd);
+
+ applyDialogFont(parent);
+
+ fLimitElementsCheckbox.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ updateLimitValueEnablement();
+ }
+
+ });
+
+ fLimitElementsField.addKeyListener(new KeyAdapter() {
+ public void keyReleased(KeyEvent e) {
+ validateText();
+ }
+ });
+ initLimit();
+ }
+
+ private void initLimit() {
+ boolean limit = fPage.limitElements();
+ int count = fPage.getElementLimit();
+ fLimitElementsCheckbox.setSelection(limit);
+ fLimitElementsField.setText(String.valueOf(count));
+
+ updateLimitValueEnablement();
+ }
+
+ private void updateLimitValueEnablement() {
+ fLimitElementsField.setEnabled(fLimitElementsCheckbox.getSelection());
+ }
+
+ protected void validateText() {
+ String text = fLimitElementsField.getText();
+ int value = -1;
+ try {
+ value = Integer.valueOf(text).intValue();
+ } catch (NumberFormatException e) {
+
+ }
+ if (fLimitElementsCheckbox.getSelection() && value <= 0)
+ updateStatus(new Status(IStatus.ERROR, RubyPlugin.getPluginId(), 0, org.rubypeople.rdt.internal.ui.search.SearchMessages.FiltersDialog_limit_error, null));
+ else
+ updateStatus(new Status(IStatus.OK, RubyPlugin.getPluginId(), 0, "", null)); //$NON-NLS-1$
+ }
+
+ protected void computeResult() {
+ fLimitElementCount= Integer.valueOf(fLimitElementsField.getText()).intValue();
+ fLimitElements= fLimitElementsCheckbox.getSelection();
+
+ setResult(Arrays.asList(fListViewer.getCheckedElements()));
+ }
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/FiltersDialogAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/FiltersDialogAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/FiltersDialogAction.java 2007-05-15 17:36:12 UTC (rev 2479)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.ui.search;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.window.Window;
+
+
+public class FiltersDialogAction extends Action {
+ private RubySearchResultPage fPage;
+
+ public FiltersDialogAction(RubySearchResultPage page) {
+ super(SearchMessages.FiltersDialogAction_label);
+ fPage= page;
+ }
+
+ public void run() {
+ FiltersDialog dialog = new FiltersDialog(fPage);
+
+ if (dialog.open() == Window.OK) {
+ fPage.setFilters(dialog.getEnabledFilters());
+ fPage.enableLimit(dialog.isLimitEnabled());
+ fPage.setElementLimit(dialog.getElementLimit());
+ }
+ }
+
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/GroupAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/GroupAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/GroupAction.java 2007-05-15 17:36:12 UTC (rev 2479)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.ui.search;
+
+import org.eclipse.jface.action.Action;
+
+
+public class GroupAction extends Action {
+ private int fGrouping;
+ private RubySearchResultPage fPage;
+
+ public GroupAction(String label, String tooltip, RubySearchResultPage page, int grouping) {
+ super(label);
+ setToolTipText(tooltip);
+ fPage= page;
+ fGrouping= grouping;
+ }
+
+ public void run() {
+ fPage.setGrouping(fGrouping);
+ }
+
+ public int getGrouping() {
+ return fGrouping;
+ }
+}
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/GroupByAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/GroupByAction.java 2007-05-15 17:34:21 UTC (rev 2478)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/GroupByAction.java 2007-05-15 17:36:12 UTC (rev 2479)
@@ -1,14 +0,0 @@
-package org.rubypeople.rdt.internal.ui.search;
-
-import org.eclipse.jface.action.Action;
-import org.rubypeople.rdt.internal.ui.RubyPluginImages;
-
-
-public class GroupByAction extends Action {
-
- public GroupByAction(String label, String image) {
- super(label) ;
- this.setToolTipText(label) ;
- RubyPluginImages.setLocalImageDescriptors(this, image) ;
- }
-}
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/GroupByPathStrategy.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/GroupByPathStrategy.java 2007-05-15 17:34:21 UTC (rev 2478)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/GroupByPathStrategy.java 2007-05-15 17:36:12 UTC (rev 2479)
@@ -1,12 +0,0 @@
-package org.rubypeople.rdt.internal.ui.search;
-
-import org.rubypeople.rdt.internal.core.symbols.SearchResult;
-
-public class GroupByPathStrategy implements IGroupByStrategy {
-
- public Object getParent(Object element) {
- if (!(element instanceof SearchResult)) { return null; }
- SearchResult result = (SearchResult) element;
- return result.getLocation().getSourceFile().getFullPath();
- }
-}
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/GroupByScopeStrategy.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/GroupByScopeStrategy.java 2007-05-15 17:34:21 UTC (rev 2478)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/GroupByScopeStrategy.java 2007-05-15 17:36:12 UTC (rev 2479)
@@ -1,30 +0,0 @@
-package org.rubypeople.rdt.internal.ui.search;
-
-import org.rubypeople.rdt.internal.core.symbols.SearchResult;
-
-
-
-public class GroupByScopeStrategy implements IGroupByStrategy {
-
- private Scope createScope(String qualifiedName) {
- int index = qualifiedName.lastIndexOf("::") ;
- if (index == -1) {
- return null ;
- }
- String packageName = qualifiedName.substring(0, index) ;
- return new Scope(packageName);
- }
-
- public Object getParent(Object element) {
- if (element instanceof SearchResult) {
- SearchResult result = (SearchResult) element ;
- return this.createScope(result.getSymbol().getName()) ;
- }
- if (element instanceof Scope) {
- Scope scope = (Scope) element ;
- return this.createScope(scope.getQualifiedName()) ;
- }
- return null ;
- }
-
-}
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/IGroupByStrategy.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/IGroupByStrategy.java 2007-05-15 17:34:21 UTC (rev 2478)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/IGroupByStrategy.java 2007-05-15 17:36:12 UTC (rev 2479)
@@ -1,6 +0,0 @@
-package org.rubypeople.rdt.internal.ui.search;
-
-
-public interface IGroupByStrategy {
- public Object getParent(Object element) ;
-}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/IOccurrencesFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/IOccurrencesFinder.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/IOccurrencesFinder.java 2007-05-15 17:36:12 UTC (rev 2479)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.ui.search;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.jface.text.IDocument;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.internal.core.RubyScript;
+
+public interface IOccurrencesFinder {
+
+ public String initialize(RubyScript root, int offset, int length);
+
+ public List perform();
+
+ public String getJobLabel();
+
+ /**
+ * Returns the plural label for this finder with 3 placeholders:
+ * <ul>
+ * <li>{0} for the {@link #getElementName() element name}</li>
+ * <li>{1} for the number of results found</li>
+ * <li>{2} for the scope (name of the compilation unit)</li>
+ * </ul>
+ * @return the unformatted label
+ */
+ public String getUnformattedPluralLabel();
+
+ /**
+ * Returns the singular label for this finder with 2 placeholders:
+ * <ul>
+ * <li>{0} for the {@link #getElementName() element name}</li>
+ * <li>{1} for the scope (name of the compilation unit)</li>
+ * </ul>
+ * @return the unformatted label
+ */
+ public String getUnformattedSingularLabel();
+
+ /**
+ * Returns the name of the lement to look for or <code>null</code> if the finder hasn't
+ * been initialized yet.
+ * @return the name of the element
+ */
+ public String getElementName();
+
+ public void collectOccurrenceMatches(IRubyElement element, IDocument document, Collection resultingMatches);
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/LRUWorkingSetsList.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/LRUWorkingSetsList.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/LRUWorkingSetsList.java 2007-05-15 17:36:12 UTC (rev 2479)
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.ui.search;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.PlatformUI;
+
+public class LRUWorkingSetsList {
+
+ private final ArrayList fLRUList;
+ private final int fSize;
+ private final WorkingSetsComparator fComparator= new WorkingSetsComparator();
+
+ public LRUWorkingSetsList(int size) {
+ fSize= size;
+ fLRUList= new ArrayList(size);
+ }
+
+ public void add(IWorkingSet[] workingSets) {
+ removeDeletedWorkingSets();
+ IWorkingSet[] existingWorkingSets= find(fLRUList, workingSets);
+ if (existingWorkingSets != null)
+ fLRUList.remove(existingWorkingSets);
+ else if (fLRUList.size() == fSize)
+ fLRUList.remove(fSize - 1);
+ fLRUList.add(0, workingSets);
+
+ }
+
+ public Iterator iterator() {
+ removeDeletedWorkingSets();
+ return fLRUList.iterator();
+ }
+
+ public Iterator sortedIterator() {
+ removeDeletedWorkingSets();
+ ArrayList sortedList= new ArrayList(fLRUList);
+ Collections.sort(sortedList, fComparator);
+ return sortedList.iterator();
+ }
+
+ private void removeDeletedWorkingSets() {
+ Iterator iter= new ArrayList(fLRUList).iterator();
+ while (iter.hasNext()) {
+ IWorkingSet[] workingSets= (IWorkingSet[])iter.next();
+ for (int i= 0; i < workingSets.length; i++) {
+ if (PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(workingSets[i].getName()) == null) {
+ fLRUList.remove(workingSets);
+ break;
+ }
+ }
+ }
+ }
+
+ private IWorkingSet[] find(ArrayList list, IWorkingSet[] workingSets) {
+ Set workingSetList= new HashSet(Arrays.asList(workingSets));
+ Iterator iter= list.iterator();
+ while (iter.hasNext()) {
+ IWorkingSet[] lruWorkingSets= (IWorkingSet[])iter.next();
+ Set lruWorkingSetList= new HashSet(Arrays.asList(lruWorkingSets));
+ if (lruWorkingSetList.equals(workingSetList))
+ return lruWorkingSets;
+ }
+ return null;
+ }
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/LevelTreeContentProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/LevelTreeContentProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/LevelTreeContentProvider.java 2007-05-15 17:36:12 UTC (rev 2479)
@@ -0,0 +1,241 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.rubypeople.rdt.internal.ui.search;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.ui.StandardRubyElementContentProvider;
+
+public class LevelTreeContentProvider extends RubySearchContentProvider implements ITreeContentProvider {
+ private Map fChildrenMap;
+ private StandardRubyElementContentProvider fContentProvider;
+
+ public static final int LEVEL_TYPE= 1;
+ public static final int LEVEL_FILE= 2;
+ public static final int LEVEL_PACKAGE= 3;
+ public static final int LEVEL_PROJECT= 4;
+
+ private static int[][] JAVA_ELEMENT_TYPES= {{IRubyElement.TYPE},
+ {IRubyElement.SCRIPT},
+ {IRubyElement.SOURCE_FOLDER},
+ {IRubyElement.RUBY_PROJECT, IRubyElement.SOURCE_FOLDER_ROOT},
+ {IRubyElement.RUBY_MODEL}};
+ private static int[][] RESOURCE_TYPES= {
+ {},
+ {IResource.FILE},
+ {IResource.FOLDER},
+ {IResource.PROJECT},
+ {IResource.ROOT}};
+
+ private static final int MAX_LEVEL= JAVA_ELEMENT_TYPES.length - 1;
+ private int fCurrentLevel;
+ static class FastRubyElementProvider extends StandardRubyElementContentProvider {
+ public Object getParent(Object element) {
+ return internalGetParent(element);
+ }
+ }
+
+ public LevelTreeContentProvider(RubySearchResultPage page, int level) {
+ super(page);
+ fCurrentLevel= level;
+ fContentProvider= new FastRubyElementProvider();
+ }
+
+ public Object getParent(Object child) {
+ Object possibleParent= internalGetParent(child);
+ if (possibleParent instanceof IRubyElement) {
+ IRubyElement javaElement= (IRubyElement) possibleParent;
+ for (int j= fCurrentLevel; j < MAX_LEVEL + 1; j++) {
+ for (int i= 0; i < JAVA_ELEMENT_TYPES[j].length; i++) {
+ if (javaElement.getElementType() == JAVA_ELEMENT_TYPES[j][i]) {
+ return null;
+ }
+ }
+ }
+ } else if (possibleParent instanceof IResource) {
+ IResource resource= (IResource) possibleParent;
+ for (int j= fCurrentLevel; j < MAX_LEVEL + 1; j++) {
+ for (int i= 0; i < RESOURCE_TYPES[j].length; i++) {
+ if (resource.getType() == RESOURCE_TYPES[j][i]) {
+ return null;
+ }
+ }
+ }
+ }
+ if (fCurrentLevel != LEVEL_FILE && child instanceof IType) {
+ IType type= (IType) child;
+ if (possibleParent instanceof IRubyScript)
+ possibleParent= type.getSourceFolder();
+ }
+ return possibleParent;
+ }
+
+ private Object internalGetParent(Object child) {
+ return fContentProvider.getParent(child);
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ protected synchronized void initialize(RubySearchResult result) {
+ super.initialize(result);
+ fChildrenMap= new HashMap();
+ if (result != null) {
+ Object[] elements= result.getElements();
+ for (int i= 0; i < elements.length; i++) {
+ if (getPage().getDisplayedMatchCount(elements[i]) > 0) {
+ insert(null, null, elements[i]);
+ }
+ }
+ }
+ }
+
+ protected void insert(Map toAdd, Set toUpdate, Object child) {
+ Object parent= getParent(child);
+ while (parent != null) {
+ if (insertChild(parent, child)) {
+ if (toAdd != null)
+ insertInto(parent, child, toAdd);
+ } else {
+ if (toUpdate != null)
+ toUpdate.add(parent);
+ return;
+ }
+ child= parent;
+ parent= getParent(child);
+ }
+ if (insertChild(fResult, child)) {
+ if (toAdd != null)
+ insertInto(fResult, child, toAdd);
+ }
+ }
+
+ private boolean insertChild(Object parent, Object child) {
+ return insertInto(parent, child, fChildrenMap);
+ }
+
+ private boolean insertInto(Object parent, Object child, Map map) {
+ Set children= (Set) map.get(parent);
+ if (children == null) {
+ children= new HashSet();
+ map.put(parent, children);
+ }
+ return children.add(child);
+ }
+
+ protected void remove(Set toRemove, Set toUpdate, Object element) {
+ // precondition here: fResult.getMatchCount(child) <= 0
+
+ if (hasChildren(element)) {
+ if (toUpdate != null)
+ toUpdate.add(element);
+ } else {
+ if (getPage().getDisplayedMatchCount(element) == 0) {
+ fChildrenMap.remove(element);
+ Object parent= getParent(element);
+ if (parent != null) {
+ if (removeFromSiblings(element, parent)) {
+ remove(toRemove, toUpdate, parent);
+ }
+ } else {
+ if (removeFromSiblings(element, fResult)) {
+ if (toRemove != null)
+ toRemove.add(element);
+ }
+ }
+ } else {
+ if (toUpdate != null) {
+ toUpdate.add(element);
+ }
+ }
+ }
+ }
+
+ /**
+ * @param element
+ * @param parent
+ * @return returns true if it really was a remove (i.e. element was a child of parent).
+ */
+ private boolean removeFromSiblings(Object element, Object parent) {
+ Set siblings= (Set) fChildrenMap.get(parent);
+ if (siblings != null) {
+ return siblings.remove(element);
+ } else {
+ return false;
+ }
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ Set children= (Set) fChildrenMap.get(parentElement);
+ if (children == null)
+ return EMPTY_ARR;
+ return children.toArray();
+ }
+
+ public boolean hasChildren(Object element) {
+ return getChildren(element).length > 0;
+ }
+
+ public synchronized void elementsChanged(Object[] updatedElements) {
+ AbstractTreeViewer viewer= (AbstractTreeViewer) getPage().getViewer();
+ if (fResult == null)
+ return;
+ Set toRemove= new HashSet();
+ Set toUpdate= new HashSet();
+ Map toAdd= new HashMap();
+ for (int i= 0; i < updatedElements.length; i++) {
+ if (getPage().getDisplayedMatchCount(updatedElements[i]) > 0)
+ insert(toAdd, toUpdate, updatedElements[i]);
+ else
+ remove(toRemove, toUpdate, updatedElements[i]);
+ }
+
+ viewer.remove(toRemove.toArray());
+ for (Iterator iter= toAdd.keySet().iterator(); iter.hasNext();) {
+ Object parent= iter.next();
+ HashSet children= (HashSet) toAdd.get(parent);
+ viewer.add(parent, children.toArray());
+ }
+ for (Iterator elementsToUpdate= toUpdate.iterator(); elementsToUpdate.hasNext();) {
+ viewer.refresh(elementsToUpdate.next());
+ }
+
+ }
+
+ public void clear() {
+ initialize(fResult);
+ getPage().getViewer().refresh();
+ }
+
+ public void setLevel(int level) {
+ fCurrentLevel= level;
+ initialize(fResult);
+ getPage().getViewer().refresh();
+ }
+
+ public void filtersChanged(MatchFilter[] filters) {
+ super.filtersChanged(filters);
+ initialize(fResult);
+ getPage().getViewer().refresh();
+ }
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/MatchFilter.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/MatchFilter.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/MatchFilter.java 2007-05-15 17:36:12 UTC (rev 2479)
@@ -0,0 +1,244 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.ui.search;
+
+import java.util.StringTokenizer;
+
+import org.rubypeople.rdt.core.IField;
+import org.rubypeople.rdt.core.IImportDeclaration;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.search.IRubySearchConstants;
+import org.rubypeople.rdt.core.search.SearchMatch;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.ui.search.ElementQuerySpecification;
+import org.rubypeople.rdt.ui.search.PatternQuerySpecification;
+import org.rubypeople.rdt.ui.search.QuerySpecification;
+
+abstract class MatchFilter {
+
+ private static final String SETTINGS_LAST_USED_FILTERS= "filters_last_used"; //$NON-NLS-1$
+
+ public static MatchFilter[] getLastUsedFilters() {
+ String string= RubyPlugin.getDefault().getDialogSettings().get(SETTINGS_LAST_USED_FILTERS);
+ if (string != null && string.length() > 0) {
+ return decodeFiltersString(string);
+ }
+ return getDefaultFilters();
+ }
+
+ public static void setLastUsedFilters(MatchFilter[] filters) {
+ String encoded= encodeFilters(filters);
+ RubyPlugin.getDefault().getDialogSettings().put(SETTINGS_LAST_USED_FILTERS, encoded);
+ }
+
+ public static MatchFilter[] getDefaultFilters() {
+ return new MatchFilter[] { IMPORT_FILTER };
+ }
+
+ private static String encodeFilters(MatchFilter[] enabledFilters) {
+ StringBuffer buf= new StringBuffer();
+ buf.append(enabledFilters.length);
+ for (int i= 0; i < enabledFilters.length; i++) {
+ buf.append(';');
+ buf.append(enabledFilters[i].getID());
+ }
+ return buf.toString();
+ }
+
+ private static MatchFilter[] decodeFiltersString(String encodedString) {
+ StringTokenizer tokenizer= new StringTokenizer(encodedString, String.valueOf(';'));
+ MatchFilter[] res;
+ try {
+ int count= Integer.valueOf(tokenizer.nextToken()).intValue();
+ res= new MatchFilter[count];
+ for (int i= 0; i < count; i++) {
+ res[i]= findMatchFilter(tokenizer.nextToken());
+ }
+ } catch (NumberFormatException e) {
+ res= getDefaultFilters();
+ }
+ return res;
+ }
+
+
+ public abstract boolean isApplicable(RubySearchQuery query);
+
+ public abstract boolean filters(RubyElementMatch match);
+
+ public abstract String getName();
+ public abstract String getActionLabel();
+
+ public abstract String getDescription();
+
+ public abstract String getID();
+
+ private static final MatchFilter POTENTIAL_FILTER= new PotentialFilter();
+ private static final MatchFilter IMPORT_FILTER= new ImportFilter();
+ private static final MatchFilter JAVADOC_FILTER= new RubydocFilter();
+ private static final MatchFilter READ_FILTER= new ReadFilter();
+ private static final MatchFilter WRITE_FILTER= new WriteFilter();
+
+ private static final MatchFilter[] ALL_FILTERS= new MatchFilter[] {
+ POTENTIAL_FILTER,
+ IMPORT_FILTER,
+ JAVADOC_FILTER,
+ READ_FILTER,
+ WRITE_FILTER
+ };
+
+ public static MatchFilter[] allFilters() {
+ return ALL_FILTERS;
+ }
+
+ private static MatchFilter findMatchFilter(String id) {
+ for (int i= 0; i < ALL_FILTERS.length; i++) {
+ if (ALL_FILTERS[i].getID().equals(id))
+ return ALL_FILTERS[i];
+ }
+ return IMPORT_FILTER; // just return something, should not happen
+ }
+
+
+}
+
+class PotentialFilter extends MatchFilter {
+ public boolean filters(RubyElementMatch match) {
+ return match.getAccuracy() == SearchMatch.A_INACCURATE;
+ }
+
+ public String getName() {
+ return SearchMessages.MatchFilter_PotentialFilter_name;
+ }
+
+ public String getActionLabel() {
+ return SearchMessages.MatchFilter_PotentialFilter_actionLabel;
+ }
+
+ public String getDescription() {
+ return SearchMessages.MatchFilter_PotentialFilter_description;
+ }
+
+ public boolean isApplicable(RubySearchQuery query) {
+ return true;
+ }
+
+ public String getID() {
+ return "filter_potential"; //$NON-NLS-1$
+ }
+}
+
+class ImportFilter extends MatchFilter {
+ public boolean filters(RubyElementMatch match) {
+ return match.getElement() instanceof IImportDeclaration;
+ }
+
+ public String getName() {
+ return SearchMessages.MatchFilter_ImportFilter_name;
+ }
+
+ public String getActionLabel() {
+ return SearchMessages.MatchFilter_ImportFilter_actionLabel;
+ }
+
+ public String getDescription() {
+ return SearchMessages.MatchFilter_ImportFilter_description;
+ }
+
+ public boolean isApplicable(RubySearchQuery query) {
+ QuerySpecification spec= query.getSpecification();
+ if (spec instanceof ElementQuerySpecification) {
+ ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
+ return elementSpec.getElement() instanceof IType;
+ } else if (spec instanceof PatternQuerySpecification) {
+ PatternQuerySpecification patternSpec= (PatternQuerySpecification) spec;
+ return patternSpec.getSearchFor() == IRubySearchConstants.TYPE;
+ }
+ return false;
+ }
+
+ public String getID() {
+ return "filter_imports"; //$NON-NLS-1$
+ }
+}
+
+abstract class FieldFilter extends MatchFilter {
+ public boolean isApplicable(RubySearchQuery query) {
+ QuerySpecification spec= query.getSpecification();
+ if (spec instanceof ElementQuerySpecification) {
+ ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
+ return elementSpec.getElement() instanceof IField;
+ } else if (spec instanceof PatternQuerySpecification) {
+ PatternQuerySpecification patternSpec= (PatternQuerySpecification) spec;
+ return patternSpec.getSearchFor() == IRubySearchConstants.FIELD;
+ }
+ return false;
+ }
+
+}
+
+class WriteFilter extends FieldFilter {
+ public boolean filters(RubyElementMatch match) {
+ return match.isWriteAccess() && !match.isReadAccess();
+ }
+ public String getName() {
+ return SearchMessages.MatchFilter_WriteFilter_name;
+ }
+ public String getActionLabel() {
+ return SearchMessages.MatchFilter_WriteFilter_actionLabel;
+ }
+ public String getDescription() {
+ return SearchMessages.MatchFilter_WriteFilter_description;
+ }
+ public String getID() {
+ return "filter_writes"; //$NON-NLS-1$
+ }
+}
+
+class ReadFilter extends FieldFilter {
+ public boolean filters(RubyElementMatch match) {
+ return match.isReadAccess() && !match.isWriteAccess();
+ }
+ public String getName() {
+ return SearchMessages.MatchFilter_ReadFilter_name;
+ }
+ public String getActionLabel() {
+ return SearchMessages.MatchFilter_ReadFilter_actionLabel;
+ }
+ public String getDescription() {
+ return SearchMessages.MatchFilter_ReadFilter_description;
+ }
+ public String getID() {
+ return "filter_reads"; //$NON-NLS-1$
+ }
+}
+
+class RubydocFilter extends MatchFilter {
+ public boolean filters(RubyElementMatch match) {
+ return match.isRubydoc();
+ }
+ public String getName() {
+ return SearchMessages.MatchFilter_RubydocFilter_name;
+ }
+ public String getActionLabel() {
+ return SearchMessages.MatchFilter_RubydocFilter_actionLabel;
+ }
+ public String getDescription() {
+ return SearchMessages.MatchFilter_RubydocFilter_description;
+ }
+ public boolean isApplicable(RubySearchQuery query) {
+ return true;
+ }
+ public String getID() {
+ return "filter_javadoc"; //$NON-NLS-1$
+ }
+}
+
+
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/NewSearchResultCollector.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/NewSearchResultCollector.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/NewSearchResultCollector.java 2007-05-15 17:36:12 UTC (rev 2479)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - ini...
[truncated message content] |