use of com.liferay.ide.portlet.core.model.Portlet in project liferay-ide by liferay.
the class OpenPortletResourceAction method openPortletJavaClass.
/**
* @param file
*/
protected void openPortletJavaClass(IFile file) {
Element modelElement = ((PortletNode) selectedNode).getModel();
if (modelElement instanceof Portlet) {
Portlet portlet = (Portlet) modelElement;
JavaTypeName portletClassFile = portlet.getPortletClass().content();
Runnable run = new Runnable() {
public void run() {
IJavaProject project = JavaCore.create(file.getProject());
String fullyQualifiedName = portletClassFile.qualified();
try {
IType type = project.findType(fullyQualifiedName);
if ((type != null) && type.exists()) {
IResource resource = type.getResource();
if (resource instanceof IFile) {
IFile javaFile = (IFile) resource;
IEditorDescriptor editorDescriptor = findEditor(javaFile);
IEditorPart editorPart = null;
if (editorDescriptor != null) {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
try {
editorPart = page.findEditor(new FileEditorInput(javaFile));
if (editorPart == null) {
editorPart = page.openEditor(new FileEditorInput(javaFile), editorDescriptor.getId());
}
} catch (Exception e) {
MessageDialog.openError(page.getWorkbenchWindow().getShell(), Msgs.errorOpeningFile, e.getMessage());
}
}
}
}
} catch (JavaModelException jme) {
PortletUIPlugin.logError(jme);
}
}
};
Display.getDefault().asyncExec(run);
}
}
Aggregations