use of org.eclipse.jdt.internal.ui.fix.ImportsCleanUp in project liferay-ide by liferay.
the class NewPortletWizard method openJavaClass.
@Override
protected void openJavaClass() {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProject project = workspace.getRoot().getProject(getDataModel().getStringProperty(PROJECT_NAME));
if (getDataModel().getBooleanProperty(USE_DEFAULT_PORTLET_CLASS)) {
try {
String jspsFolder = getDataModel().getStringProperty(CREATE_JSPS_FOLDER);
// IDE-110 IDE-648
IWebProject webproject = LiferayCore.create(IWebProject.class, project);
if ((webproject != null) && (webproject.getDefaultDocrootFolder() != null)) {
IFolder defaultDocroot = webproject.getDefaultDocrootFolder();
IFile viewFile = defaultDocroot.getFile(new Path(jspsFolder + "/view.jsp"));
if (viewFile.exists()) {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
IDE.openEditor(page, viewFile, true);
return;
}
}
} catch (Exception e) {
// eat this exception this is just best effort
}
} else {
Map<String, String> settings = new Hashtable<>();
settings.put(CleanUpConstants.ORGANIZE_IMPORTS, CleanUpOptions.TRUE);
ImportsCleanUp importsCleanUp = new ImportsCleanUp(settings);
ICleanUp[] cleanUps = { importsCleanUp };
IJavaProject javaProject = JavaCore.create(project);
try {
IType type = javaProject.findType(getDataModel().getStringProperty(INewJavaClassDataModelProperties.QUALIFIED_CLASS_NAME));
ICompilationUnit cu = (ICompilationUnit) type.getParent();
ICompilationUnit[] units = { cu };
RefactoringExecutionStarter.startCleanupRefactoring(units, cleanUps, false, getShell(), false, "organize imports");
} catch (Exception e) {
}
super.openJavaClass();
}
}
Aggregations