Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2002-09-12 14:44:25 +0000
committerDani Megert2002-09-12 14:44:25 +0000
commit823946b2f9f69b1e5af849e2ebd510c4f329a7bf (patch)
treeb68222a1b6d347d80984cd811f3dfb61d1101d94
parent08ce9a9148ac49be06f37fe2bec345674a7b6fe6 (diff)
downloadeclipse.platform.text-823946b2f9f69b1e5af849e2ebd510c4f329a7bf.tar.gz
eclipse.platform.text-823946b2f9f69b1e5af849e2ebd510c4f329a7bf.tar.xz
eclipse.platform.text-823946b2f9f69b1e5af849e2ebd510c4f329a7bf.zip
Added SearchViewEntryAdapter to get resource
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java27
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntry.java3
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntryAdapterFactory.java45
3 files changed, 72 insertions, 3 deletions
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java
index 4c98d85aa..cfb8681ec 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java
@@ -13,6 +13,7 @@ import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.IPluginRegistry;
@@ -23,10 +24,10 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.Assert;
import org.eclipse.ui.IViewPart;
@@ -37,6 +38,7 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.search.ui.IContextMenuConstants;
import org.eclipse.search.ui.ISearchResultView;
+import org.eclipse.search.ui.ISearchResultViewEntry;
import org.eclipse.search.ui.SearchUI;
import org.eclipse.search.internal.ui.util.ExceptionHandler;
@@ -53,6 +55,8 @@ public class SearchPlugin extends AbstractUIPlugin {
private List fPageDescriptors;
private List fSorterDescriptors;
+
+ private SearchResultViewEntryAdapterFactory fSearchResultViewEntryAdapterFactory;
public SearchPlugin(IPluginDescriptor descriptor) {
super(descriptor);
@@ -191,12 +195,19 @@ public class SearchPlugin extends AbstractUIPlugin {
}
}
+
+ public void startup() throws CoreException {
+ super.startup();
+ registerAdapters();
+ }
+
/**
* Shuts down this plug-in.
*/
public void shutdown() throws CoreException {
- super.shutdown();
+ unregisterAdapters();
getWorkspace().removeResourceChangeListener(SearchManager.getDefault());
+ super.shutdown();
fgSearchPlugin = null;
}
@@ -286,10 +297,22 @@ public class SearchPlugin extends AbstractUIPlugin {
menu.add(new Separator(IContextMenuConstants.GROUP_SHOW));
menu.add(new Separator(IContextMenuConstants.GROUP_BUILD));
menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE));
+ menu.add(new Separator(IContextMenuConstants.GROUP_REMOVE_MATCHES));
menu.add(new GroupMarker(IContextMenuConstants.GROUP_GENERATE));
menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH));
menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
menu.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP));
menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES));
}
+
+ private void registerAdapters() {
+ IAdapterManager manager= Platform.getAdapterManager();
+ fSearchResultViewEntryAdapterFactory= new SearchResultViewEntryAdapterFactory();
+ manager.registerAdapters(fSearchResultViewEntryAdapterFactory, ISearchResultViewEntry.class);
+ }
+
+ private void unregisterAdapters() {
+ IAdapterManager manager= Platform.getAdapterManager();
+ manager.unregisterAdapters(fSearchResultViewEntryAdapterFactory);
+ }
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntry.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntry.java
index 7f8863bf6..ed648a49b 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntry.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntry.java
@@ -12,6 +12,7 @@ import java.util.Map;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.search.ui.ISearchResultViewEntry;
import org.eclipse.search.ui.SearchUI;
@@ -19,7 +20,7 @@ import org.eclipse.search.ui.SearchUI;
/**
* Represents an entry in the search result view
*/
-public class SearchResultViewEntry implements ISearchResultViewEntry {
+public class SearchResultViewEntry extends PlatformObject implements ISearchResultViewEntry {
private Object fGroupByKey= null;
private IResource fResource= null;
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntryAdapterFactory.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntryAdapterFactory.java
new file mode 100644
index 000000000..fab4cf06c
--- /dev/null
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewEntryAdapterFactory.java
@@ -0,0 +1,45 @@
+/*
+ * (c) Copyright IBM Corp. 2000, 2002.
+ * All Rights Reserved.
+ */
+
+package org.eclipse.search.internal.ui;
+
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdapterFactory;
+
+import org.eclipse.search.ui.ISearchResultViewEntry;
+
+/**
+ * Implements basic UI support for Java elements.
+ * Implements handle to persistent support for Java elements.
+ */
+public class SearchResultViewEntryAdapterFactory implements IAdapterFactory {
+
+ private static Class[] PROPERTIES= new Class[] {
+ IResource.class,
+ };
+
+
+ public Class[] getAdapterList() {
+ return PROPERTIES;
+ }
+
+ public Object getAdapter(Object element, Class key) {
+
+ ISearchResultViewEntry entry= (ISearchResultViewEntry)element;
+
+ if (IResource.class.equals(key)) {
+ IResource resource= entry.getResource();
+ /*
+ * This is a trick to filter out dummy markers that
+ * have been attached to a project because there is no
+ * corresponding resource in the workspace.
+ */
+ if (resource.getType() != IResource.PROJECT)
+ return resource;
+ }
+ return null;
+ }
+} \ No newline at end of file

Back to the top