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.ui.IEditorInput; 20 import org.eclipse.ui.texteditor.AddMarkerAction; 21 import org.eclipse.ui.texteditor.ITextEditor; 22 23 import org.eclipse.jdt.core.IClassFile; 24 import org.eclipse.jdt.core.JavaCore; 25 import org.eclipse.jdt.core.JavaModelException; 26 27 import org.eclipse.jdt.internal.ui.IResourceLocator; 28 29 30 31 class AddClassFileMarkerAction extends AddMarkerAction { 32 33 34 37 public AddClassFileMarkerAction(String prefix, ITextEditor textEditor, String markerType, boolean askForLabel) { 38 super(JavaEditorMessages.getBundleForConstructedKeys(), prefix, textEditor, markerType, askForLabel); 39 } 40 41 44 protected IResource getResource() { 45 46 IResource resource= null; 47 48 IEditorInput input= getTextEditor().getEditorInput(); 49 if (input instanceof IClassFileEditorInput) { 50 IClassFile c= ((IClassFileEditorInput) input).getClassFile(); 51 IResourceLocator locator= (IResourceLocator) c.getAdapter(IResourceLocator.class); 52 if (locator != null) { 53 try { 54 resource= locator.getContainingResource(c); 55 } catch (JavaModelException x) { 56 } 58 } 59 } 60 61 return resource; 62 } 63 64 67 protected Map getInitialAttributes() { 68 69 Map attributes= super.getInitialAttributes(); 70 71 IEditorInput input= getTextEditor().getEditorInput(); 72 if (input instanceof IClassFileEditorInput) { 73 74 IClassFile classFile= ((IClassFileEditorInput) input).getClassFile(); 75 JavaCore.addJavaElementMarkerAttributes(attributes, classFile); 76 } 77 78 return attributes; 79 } 80 } 81 | Popular Tags |