01: /* Soot - a J*va Optimization Framework
02: * Copyright (C) 2003 Jennifer Lhotak
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the
16: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17: * Boston, MA 02111-1307, USA.
18: */
19:
20: package ca.mcgill.sable.soot.attributes;
21:
22: import java.util.*;
23:
24: import org.eclipse.core.resources.*;
25: import org.eclipse.jdt.core.*;
26: import org.eclipse.jface.text.source.IVerticalRulerInfo;
27: import org.eclipse.ui.PartInitException;
28: import org.eclipse.ui.texteditor.AbstractTextEditor;
29: import org.eclipse.ui.texteditor.ITextEditor;
30:
31: import ca.mcgill.sable.soot.SootPlugin;
32: import org.eclipse.ui.*;
33: import org.eclipse.ui.part.*;
34:
35: public class SootAttributeJimpleSelectAction extends
36: SootAttributeSelectAction {
37:
38: public SootAttributeJimpleSelectAction(ResourceBundle bundle,
39: String prefix, ITextEditor editor,
40: IVerticalRulerInfo rulerInfo) {
41: super (bundle, prefix, editor, rulerInfo);
42: }
43:
44: public ArrayList getMarkerLinks() {
45: SootAttributesHandler handler = SootPlugin.getDefault()
46: .getManager().getAttributesHandlerForFile(
47: (IFile) getResource(getEditor()));
48: ArrayList links = handler.getJimpleLinks(getLineNumber() + 1);
49: return links;
50: }
51:
52: protected int getLinkLine(LinkAttribute la) {
53: return la.getJimpleLink();
54: }
55:
56: public void findClass(String className) {
57: setLinkToEditor(getEditor());
58: String resource = removeExt(getResource(getEditor()).getName());
59: String ext = getResource(getEditor()).getFileExtension();
60:
61: IProject proj = getResource(getEditor()).getProject();
62: String slashedClassName = className.replaceAll("\\.", System
63: .getProperty("file.separator"));
64: String classNameToFind = slashedClassName + "." + ext;
65: if (!resource.equals(className)) {
66: IContainer parent = getResource(getEditor()).getParent();
67: IResource file = parent.findMember(className + "." + ext);
68: try {
69: setLinkToEditor((AbstractTextEditor) SootPlugin
70: .getDefault().getWorkbench()
71: .getActiveWorkbenchWindow().getActivePage()
72: .openEditor(new FileEditorInput((IFile) file),
73: file.getName()));
74: } catch (PartInitException e) {
75: }
76:
77: }
78:
79: }
80: }
|