1
19 package com.qasystems.qstudio.java.integration.eclipse.actions;
20
21 import com.qasystems.debug.DebugWriter;
22 import com.qasystems.qstudio.java.gui.Project;
23 import com.qasystems.qstudio.java.integration.eclipse.EclipseAnalyzer;
24 import com.qasystems.qstudio.java.integration.eclipse.EclipseEnvironment;
25
26 import java.util.Vector;
27
28 import org.eclipse.jdt.core.IJavaElement;
29 import org.eclipse.jdt.core.JavaModelException;
30 import org.eclipse.jface.action.IAction;
31 import org.eclipse.ui.IEditorActionDelegate;
32 import org.eclipse.ui.IEditorInput;
33 import org.eclipse.ui.IEditorPart;
34 import org.eclipse.ui.actions.ActionDelegate;
35
36
39 public class InspectFileAction extends ActionDelegate
40 implements IEditorActionDelegate {
41
42 private IEditorPart editor;
43
44
47 public InspectFileAction() {
48 super();
49 }
50
51
54 public void setActiveEditor(IAction action, IEditorPart targetEditor) {
55 editor = targetEditor;
56 }
57
58
61 public void run(IAction action) {
62 if (editor.isDirty() && editor.isSaveAsAllowed()) {
63 editor.doSave(null);
64 }
65
66 final IJavaElement javaElement = getJavaElement();
67 final Vector files = new Vector();
68 final Project qstudioProject =
69 EclipseEnvironment.toQSJavaProject(javaElement.getJavaProject());
70
71 try {
72 EclipseEnvironment.getJavaFileFromJavaElement(javaElement, files);
73 } catch (JavaModelException e) {
74 new DebugWriter().writeException(e, this);
75 }
76
77 new EclipseAnalyzer(qstudioProject, files);
83
84 }
86
87 private IJavaElement getJavaElement() {
88 final IEditorInput input = editor.getEditorInput();
89 final IJavaElement je = (IJavaElement) input.getAdapter(IJavaElement.class);
90
91 return (je);
92 }
93 }
94