import net.sourceforge.phpdt.core.ICompilationUnit;
import net.sourceforge.phpdt.core.IJavaElement;
+import net.sourceforge.phpdt.core.IJavaProject;
import net.sourceforge.phpdt.core.IMember;
import net.sourceforge.phpdt.core.IWorkingCopy;
+import net.sourceforge.phpdt.core.JavaCore;
import net.sourceforge.phpdt.core.JavaModelException;
import net.sourceforge.phpdt.internal.corext.util.JavaModelUtil;
import net.sourceforge.phpdt.ui.JavaUI;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.action.Action;
import org.eclipse.swt.SWT;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.ITextEditor;
IEditorInput input= null;
try {
- input= getEditorInput(inputElement);
+ input = getEditorInput(inputElement);
} catch (JavaModelException x) {
PHPeclipsePlugin.log(x.getStatus());
}
}
private static IEditorPart openInEditor(IFile file, boolean activate) throws PartInitException {
- if (file != null) {
- IWorkbenchPage p= PHPeclipsePlugin.getActivePage();
- if (p != null) {
- IEditorPart editorPart= p.openEditor(file, null, activate);
- initializeHighlightRange(editorPart);
- return editorPart;
- }
- }
- return null;
+ if (file != null) {
+ IWorkbenchPage p= PHPeclipsePlugin.getActivePage();
+ if (p != null) {
+ IEditorPart editorPart= IDE.openEditor(p, file, activate);
+ initializeHighlightRange(editorPart);
+ return editorPart;
+ }
+ }
+ return null;
}
private static IEditorPart openInEditor(IEditorInput input, String editorID, boolean activate) throws PartInitException {
return newModifierString;
return PHPEditorMessages.getFormattedString("EditorUtility.concatModifierStrings", new String[] {modifierString, newModifierString}); //$NON-NLS-1$
}
+
+ /**
+ * Returns the Java project for a given editor input or <code>null</code> if no corresponding
+ * Java project exists.
+ *
+ * @param input the editor input
+ * @return the corresponding Java project
+ *
+ * @since 3.0
+ */
+ public static IJavaProject getJavaProject(IEditorInput input) {
+ IJavaProject jProject= null;
+ if (input instanceof IFileEditorInput) {
+ IProject project= ((IFileEditorInput)input).getFile().getProject();
+ if (project != null) {
+ jProject= JavaCore.create(project);
+ if (!jProject.exists())
+ jProject= null;
+ }
+ }
+// else if (input instanceof IClassFileEditorInput) {
+// jProject= ((IClassFileEditorInput)input).getClassFile().getJavaProject();
+// }
+ return jProject;
+ }
}