1 11 12 package org.eclipse.jdt.internal.ui.javaeditor; 13 14 15 import java.util.Map ; 16 17 import org.eclipse.core.resources.IResource; 18 19 import org.eclipse.jface.text.source.IVerticalRuler; 20 21 import org.eclipse.ui.IEditorInput; 22 import org.eclipse.ui.texteditor.ITextEditor; 23 import org.eclipse.ui.texteditor.MarkerRulerAction; 24 25 import org.eclipse.jdt.core.IClassFile; 26 import org.eclipse.jdt.core.JavaCore; 27 import org.eclipse.jdt.core.JavaModelException; 28 29 import org.eclipse.jdt.internal.ui.IResourceLocator; 30 31 32 33 class ClassFileMarkerRulerAction extends MarkerRulerAction { 34 35 36 public ClassFileMarkerRulerAction(String prefix, IVerticalRuler ruler, ITextEditor editor, String markerType, boolean askForLabel) { 37 super(JavaEditorMessages.getBundleForConstructedKeys(), prefix, editor, ruler, markerType, askForLabel); 38 } 39 40 43 protected IResource getResource() { 44 45 IResource resource= null; 46 47 IEditorInput input= getTextEditor().getEditorInput(); 48 if (input instanceof IClassFileEditorInput) { 49 IClassFile c= ((IClassFileEditorInput) input).getClassFile(); 50 IResourceLocator locator= (IResourceLocator) c.getAdapter(IResourceLocator.class); 51 if (locator != null) { 52 try { 53 resource= locator.getContainingResource(c); 54 } catch (JavaModelException x) { 55 } 57 } 58 } 59 60 return resource; 61 } 62 63 66 protected Map getInitialAttributes() { 67 68 Map attributes= super.getInitialAttributes(); 69 70 IEditorInput input= getTextEditor().getEditorInput(); 71 if (input instanceof IClassFileEditorInput) { 72 IClassFile classFile= ((IClassFileEditorInput) input).getClassFile(); 73 JavaCore.addJavaElementMarkerAttributes(attributes, classFile); 74 } 75 76 return attributes; 77 } 78 } 79 | Popular Tags |