KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > launcher > PDESourceLookupDirector


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.launcher;
12
13 import java.util.HashSet JavaDoc;
14 import java.util.Set JavaDoc;
15
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.core.runtime.SafeRunner;
18 import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
19 import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
20 import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant;
21 import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer;
22 import org.eclipse.debug.core.sourcelookup.containers.WorkspaceSourceContainer;
23 import org.eclipse.debug.ui.sourcelookup.WorkingSetSourceContainer;
24 import org.eclipse.jdt.debug.core.IJavaObject;
25 import org.eclipse.jdt.debug.core.IJavaReferenceType;
26 import org.eclipse.jdt.debug.core.IJavaStackFrame;
27 import org.eclipse.jdt.launching.sourcelookup.containers.JavaSourceLookupParticipant;
28
29 public class PDESourceLookupDirector extends AbstractSourceLookupDirector {
30
31     private static Set JavaDoc fFilteredTypes;
32     
33     static {
34         fFilteredTypes = new HashSet JavaDoc(3);
35         fFilteredTypes.add(ProjectSourceContainer.TYPE_ID);
36         fFilteredTypes.add(WorkspaceSourceContainer.TYPE_ID);
37         fFilteredTypes.add(WorkingSetSourceContainer.TYPE_ID); //$NON-NLS-1$
38
}
39     
40     /* (non-Javadoc)
41      * @see org.eclipse.debug.internal.core.sourcelookup.ISourceLookupDirector#initializeParticipants()
42      */

43     public void initializeParticipants() {
44         addParticipants(new ISourceLookupParticipant[] {new JavaSourceLookupParticipant()});
45     }
46     
47     /* (non-Javadoc)
48      * @see org.eclipse.debug.internal.core.sourcelookup.ISourceLookupDirector#supportsSourceContainerType(org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType)
49      */

50     public boolean supportsSourceContainerType(ISourceContainerType type) {
51         return !fFilteredTypes.contains(type.getId());
52     }
53     
54     /* (non-Javadoc)
55      * @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector#getSourceElement(java.lang.Object)
56      */

57     public Object JavaDoc getSourceElement(Object JavaDoc element) {
58         PDESourceLookupQuery query = new PDESourceLookupQuery(element);
59         SafeRunner.run(query);
60         Object JavaDoc result = query.getResult();
61         return result != null ? result : super.getSourceElement(element);
62     }
63     
64     /* (non-Javadoc)
65      * @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector#findSourceElements(java.lang.Object)
66      */

67     public Object JavaDoc[] findSourceElements(Object JavaDoc object) throws CoreException {
68         Object JavaDoc[] sourceElements = null;
69         if (object instanceof IJavaStackFrame || object instanceof IJavaObject || object instanceof IJavaReferenceType){
70             sourceElements = new Object JavaDoc[] {getSourceElement(object)};
71         }
72         if (sourceElements == null) {
73             sourceElements = super.findSourceElements(object);
74         }
75         return sourceElements;
76     }
77     
78 }
79
Popular Tags