KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ca > mcgill > sable > soot > attributes > SootAttributeJimpleSelectAction


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2003 Jennifer Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * 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
21 package ca.mcgill.sable.soot.attributes;
22
23 import java.util.*;
24
25
26 import org.eclipse.core.resources.*;
27 import org.eclipse.jdt.core.*;
28 import org.eclipse.jface.text.source.IVerticalRulerInfo;
29 import org.eclipse.ui.PartInitException;
30 import org.eclipse.ui.texteditor.AbstractTextEditor;
31 import org.eclipse.ui.texteditor.ITextEditor;
32
33 import ca.mcgill.sable.soot.SootPlugin;
34 import org.eclipse.ui.*;
35 import org.eclipse.ui.part.*;
36
37 public class SootAttributeJimpleSelectAction
38     extends SootAttributeSelectAction {
39         
40     public SootAttributeJimpleSelectAction(ResourceBundle bundle, String JavaDoc prefix, ITextEditor editor, IVerticalRulerInfo rulerInfo) {
41         super(bundle, prefix, editor, rulerInfo);
42     }
43     
44     public ArrayList getMarkerLinks(){
45         SootAttributesHandler handler = SootPlugin.getDefault().getManager().getAttributesHandlerForFile((IFile)getResource(getEditor()));
46         ArrayList links = handler.getJimpleLinks(getLineNumber()+1);
47         return links;
48     }
49     protected int getLinkLine(LinkAttribute la){
50         return la.getJimpleLink();
51     }
52     
53     public void findClass(String JavaDoc className){
54         setLinkToEditor(getEditor());
55         String JavaDoc resource = removeExt(getResource(getEditor()).getName());
56         String JavaDoc ext = getResource(getEditor()).getFileExtension();
57     
58         IProject proj = getResource(getEditor()).getProject();
59         String JavaDoc slashedClassName = className.replaceAll("\\.", System.getProperty("file.separator"));
60         String JavaDoc classNameToFind = slashedClassName+"."+ext;
61         if (!resource.equals(className)){
62             IContainer parent = getResource(getEditor()).getParent();
63             IResource file = parent.findMember(className+"."+ext);
64             try {
65                 setLinkToEditor((AbstractTextEditor)SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(new FileEditorInput((IFile)file), file.getName()));
66             }
67             catch (PartInitException e){
68             }
69             
70         }
71         
72     }
73 }
74
Popular Tags