Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2004-04-04 22:38:37 -0400
committerDarin Wright2004-04-04 22:38:37 -0400
commitcf79a08d18b1450795a9b2c6534ff4c168d0b502 (patch)
treeba6f059a2d5d9f766795981dd6c2d6ee48240563
parent6aa08cc3d4eebde7989f2f27e0782c4361347ddf (diff)
downloadeclipse.platform.debug-cf79a08d18b1450795a9b2c6534ff4c168d0b502.tar.gz
eclipse.platform.debug-cf79a08d18b1450795a9b2c6534ff4c168d0b502.tar.xz
eclipse.platform.debug-cf79a08d18b1450795a9b2c6534ff4c168d0b502.zip
Bug 29890 - Debug Platform Source Lookup Facilites
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/AbstractSourceLookupDirector.java4
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/AbstractSourceLookupParticipant.java44
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/ISourceLookupDirector.java15
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/ISourceLookupParticipant.java9
-rw-r--r--org.eclipse.debug.ui/plugin.xml4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveFilter.java102
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveSourceContainerBrowser.java103
8 files changed, 269 insertions, 14 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/AbstractSourceLookupDirector.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/AbstractSourceLookupDirector.java
index 023a81001..d1b343ede 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/AbstractSourceLookupDirector.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/AbstractSourceLookupDirector.java
@@ -254,7 +254,9 @@ public abstract class AbstractSourceLookupDirector implements ISourceLookupDirec
* @param participant the participant to remove
*/
private void removeSourceLookupParticipant(ISourceLookupParticipant participant) {
- fParticipants.remove(participant);
+ if (fParticipants.remove(participant)) {
+ participant.dispose();
+ }
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/AbstractSourceLookupParticipant.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/AbstractSourceLookupParticipant.java
index 30fb53705..108ff127f 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/AbstractSourceLookupParticipant.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/AbstractSourceLookupParticipant.java
@@ -55,18 +55,20 @@ public abstract class AbstractSourceLookupParticipant implements ISourceLookupPa
if (name != null) {
ISourceContainer[] containers = getSourceContainers();
for (int i = 0; i < containers.length; i++) {
- ISourceContainer container = containers[i];
- Object[] objects = container.findSourceElements(name);
- if (objects.length > 0) {
- if (isFindDuplicates()) {
- for (int j = 0; j < objects.length; j++) {
- results.add(objects[j]);
- }
- } else {
- if (objects.length == 1) {
- return objects;
+ ISourceContainer container = getDelegateContainer(containers[i]);
+ if (container != null) {
+ Object[] objects = container.findSourceElements(name);
+ if (objects.length > 0) {
+ if (isFindDuplicates()) {
+ for (int j = 0; j < objects.length; j++) {
+ results.add(objects[j]);
+ }
} else {
- return new Object[]{objects[0]};
+ if (objects.length == 1) {
+ return objects;
+ } else {
+ return new Object[]{objects[0]};
+ }
}
}
}
@@ -79,6 +81,20 @@ public abstract class AbstractSourceLookupParticipant implements ISourceLookupPa
}
/**
+ * Returns the source container to search in place of the given source
+ * container, or <code>null</code> if the given source container is not
+ * to be searched. The default implementation does not translate source
+ * containers. Subclasses should override if required.
+ *
+ * @param container the source container about to be searched (proxy)
+ * @return the source container to be searched (delegate), or <code>null</code>
+ * if the source container should not be searched
+ */
+ protected ISourceContainer getDelegateContainer(ISourceContainer container) {
+ return container;
+ }
+
+ /**
* Returns the source lookup director this participant is registered with
* or <code>null</code> if none.
*
@@ -110,4 +126,10 @@ public abstract class AbstractSourceLookupParticipant implements ISourceLookupPa
protected ISourceContainer[] getSourceContainers() {
return getDirector().getSourceContainers();
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.core.sourcelookup.ISourceLookupParticipant#sourceContainersChanged(org.eclipse.debug.internal.core.sourcelookup.ISourceLookupDirector)
+ */
+ public void sourceContainersChanged(ISourceLookupDirector director) {
+ }
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/ISourceLookupDirector.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/ISourceLookupDirector.java
index 203d2a8f3..3d4cb513a 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/ISourceLookupDirector.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/ISourceLookupDirector.java
@@ -103,4 +103,19 @@ public interface ISourceLookupDirector extends IPersistableSourceLocator2 {
* @param frame stack frame to clear source lookup results for
*/
public void clearSourceElements(IStackFrame frame);
+
+ /**
+ * Adds the given source lookup participants to this director.
+ *
+ * @param participants participants to add
+ */
+ public void addParticipants(ISourceLookupParticipant[] participants);
+
+ /**
+ * Removes the given source lookup participants from this director.
+ *
+ * @param participants participants to remove
+ */
+ public void removeParticipants(ISourceLookupParticipant[] participants);
+
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/ISourceLookupParticipant.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/ISourceLookupParticipant.java
index 64e1325e1..71e47e4fc 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/ISourceLookupParticipant.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/ISourceLookupParticipant.java
@@ -76,4 +76,13 @@ public interface ISourceLookupParticipant {
* disposed.
*/
public void dispose();
+
+ /**
+ * Notification that the source lookup containers in the given source
+ * lookup director have changed.
+ *
+ * @param director source lookup director that is directing this
+ * participant
+ */
+ public void sourceContainersChanged(ISourceLookupDirector director);
}
diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml
index c852b07f0..26974c6b4 100644
--- a/org.eclipse.debug.ui/plugin.xml
+++ b/org.eclipse.debug.ui/plugin.xml
@@ -1710,12 +1710,12 @@
icon="icons/full/obj16/prj_obj.gif"
id="org.eclipse.debug.ui.containerPresentation.workspace">
</sourceContainerPresentation>
-<!-- <sourceContainerPresentation
+ <sourceContainerPresentation
browserClass="org.eclipse.debug.internal.ui.sourcelookup.browsers.ArchiveSourceContainerBrowser"
containerTypeID="org.eclipse.debug.core.containerType.archive"
icon="icons/full/obj16/jar_obj.gif"
id="org.eclipse.debug.ui.containerPresentation.archive">
- </sourceContainerPresentation> -->
+ </sourceContainerPresentation>
<sourceContainerPresentation
browserClass="org.eclipse.debug.internal.ui.sourcelookup.browsers.ExternalArchiveSourceContainerBrowser"
containerTypeID="org.eclipse.debug.core.containerType.externalArchive"
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties
index c4c56377f..c7fe35b93 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties
@@ -92,3 +92,5 @@ ResolveDuplicatesHandler.1=Choose a source file (? = any character, * = any stri
EditSourceLookupPathAction.0=Edit Source Loo&kup...
LookupSourceAction.0=Lookup &Source
ExternalArchiveSourceContainerBrowser.2=Select Source Archive
+ArchiveSourceContainerBrowser.3=Archive Selection
+ArchiveSourceContainerBrowser.4=Choose archives to add:
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveFilter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveFilter.java
new file mode 100644
index 000000000..cbd29a599
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveFilter.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.sourcelookup.browsers;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.custom.BusyIndicator;
+
+/**
+ * ArchiveFilter
+ */
+public class ArchiveFilter extends ViewerFilter {
+
+ /**
+ * Collection of archives and containers to display
+ */
+ private Set fArchives;
+
+ /**
+ * Collection of already existing archives
+ */
+ private List fExisting;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ return fArchives.contains(element) && !fExisting.contains(element);
+ }
+
+ /**
+ * Constructs a new filter to display archives and their containers,
+ * excluding the resources in the given list.
+ *
+ * @param objects resources to exclude
+ */
+ public ArchiveFilter(List objects) {
+ fExisting = objects;
+ init();
+ }
+
+ /**
+ * Search for all archives in the workspace.
+ */
+ private void init() {
+ BusyIndicator.showWhile(DebugUIPlugin.getStandardDisplay(), new Runnable() {
+ public void run() {
+ fArchives = new HashSet();
+ traverse(ResourcesPlugin.getWorkspace().getRoot(), fArchives);
+ }
+ });
+ }
+
+ /**
+ * Traverse the given container, adding archives to the given set.
+ * Returns whether any files were added
+ *
+ * @param root
+ */
+ private boolean traverse(IContainer container, Set set) {
+ boolean added = false;
+ try {
+ IResource[] resources = container.members();
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ if (resource instanceof IFile) {
+ IFile file = (IFile)resource;
+ String ext = file.getFileExtension();
+ if (ext != null && (ext.equalsIgnoreCase("jar") || ext.equalsIgnoreCase("zip"))) { //$NON-NLS-1$ //$NON-NLS-2$
+ set.add(file);
+ added = true;
+ }
+ } else if (resource instanceof IContainer) {
+ if (traverse((IContainer)resource, set)) {
+ set.add(resource);
+ added = true;
+ }
+ }
+ }
+ } catch (CoreException e) {
+ }
+ return added;
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveSourceContainerBrowser.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveSourceContainerBrowser.java
new file mode 100644
index 000000000..208e564ae
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveSourceContainerBrowser.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.sourcelookup.browsers;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.internal.core.sourcelookup.ISourceContainer;
+import org.eclipse.debug.internal.core.sourcelookup.ISourceLookupDirector;
+import org.eclipse.debug.internal.core.sourcelookup.containers.ArchiveSourceContainer;
+import org.eclipse.debug.internal.core.sourcelookup.containers.ArchiveSourceContainerType;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.sourcelookup.ISourceContainerBrowser;
+import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIMessages;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.views.navigator.ResourceSorter;
+
+/**
+ * Adds an internal jar to the runtime class path.
+ */
+public class ArchiveSourceContainerBrowser implements ISourceContainerBrowser {
+
+ private ISelectionStatusValidator validator= new ISelectionStatusValidator() {
+ public IStatus validate(Object[] selection) {
+ if (selection.length == 0) {
+ return new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), 0, "", null); //$NON-NLS-1$
+ }
+ for (int i= 0; i < selection.length; i++) {
+ if (!(selection[i] instanceof IFile)) {
+ return new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), 0, "", null); //$NON-NLS-1$
+ }
+ }
+ return new Status(IStatus.OK, DebugUIPlugin.getUniqueIdentifier(), 0, "", null); //$NON-NLS-1$
+ }
+ };
+
+ /**
+ * Returns internal jars (source containers) currently used by the
+ * given source lookup director.
+ *
+ * @param director source lookup director jars are being added to
+ */
+ protected List getSelectedJars(ISourceLookupDirector director) {
+ ISourceContainer[] containers = director.getSourceContainers();
+ List jars = new ArrayList();
+ for (int i = 0; i < containers.length; i++) {
+ ISourceContainer container = containers[i];
+ if (container.getType().getId().equals(ArchiveSourceContainerType.TYPE_ID)) {
+ jars.add(container);
+ }
+ }
+ return jars;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.sourcelookup.ISourceContainerBrowser#createSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.internal.core.sourcelookup.ISourceLookupDirector)
+ */
+ public ISourceContainer[] createSourceContainers(Shell shell, ISourceLookupDirector director) {
+ ViewerFilter filter= new ArchiveFilter(getSelectedJars(director));
+
+ ILabelProvider lp= new WorkbenchLabelProvider();
+ ITreeContentProvider cp= new WorkbenchContentProvider();
+
+ ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(shell, lp, cp);
+ dialog.setValidator(validator);
+ dialog.setTitle(SourceLookupUIMessages.getString("ArchiveSourceContainerBrowser.3")); //$NON-NLS-1$
+ dialog.setMessage(SourceLookupUIMessages.getString("ArchiveSourceContainerBrowser.4")); //$NON-NLS-1$
+ dialog.addFilter(filter);
+ dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
+ dialog.setSorter(new ResourceSorter(ResourceSorter.NAME));
+
+ if (dialog.open() == Window.OK) {
+ Object[] result = dialog.getResult();
+ ISourceContainer[] containers = new ISourceContainer[result.length];
+ for (int i = 0; i < containers.length; i++) {
+ containers[i] = new ArchiveSourceContainer((IFile)result[i], true);
+ }
+ return containers;
+ }
+ return new ISourceContainer[0];
+ }
+}

Back to the top