KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > terracotta > dso > correction > BaseMarkerResolution


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package org.terracotta.dso.correction;
5
6 import org.eclipse.core.resources.IMarker;
7 import org.eclipse.core.resources.IWorkspace;
8 import org.eclipse.core.resources.IWorkspaceRunnable;
9 import org.eclipse.core.runtime.CoreException;
10 import org.eclipse.jdt.core.ICompilationUnit;
11 import org.eclipse.jdt.core.IJavaElement;
12 import org.eclipse.ui.IMarkerResolution;
13
14 import org.terracotta.dso.TcPlugin;
15
16 public abstract class BaseMarkerResolution
17   implements IMarkerResolution,
18              IWorkspaceRunnable
19 {
20   protected IJavaElement m_element;
21   protected IMarker m_marker;
22   
23   public BaseMarkerResolution(IJavaElement element) {
24     m_element = element;
25   }
26   
27   public void run(IMarker marker) {
28     try {
29       m_marker = marker;
30       m_marker.getResource().getWorkspace().run(this, null, IWorkspace.AVOID_UPDATE, null);
31     } catch(CoreException e) {
32       e.printStackTrace();
33     }
34   }
35
36   public ICompilationUnit getCompilationUnit() {
37     if(m_element != null) {
38       return (ICompilationUnit)m_element.getAncestor(IJavaElement.COMPILATION_UNIT);
39     }
40     
41     return null;
42   }
43
44   protected void inspectCompilationUnit() {
45     ICompilationUnit cu = getCompilationUnit();
46     
47     if(cu != null) {
48       TcPlugin.getDefault().inspect(cu);
49     }
50   }
51 }
52
Popular Tags