private static LiferayDescriptorHelper[] getDescriptorHelpers( IProject project, Class<? extends IDescriptorOperation> type) { List<LiferayDescriptorHelper> retval = new ArrayList<LiferayDescriptorHelper>(); project = CoreUtil.getLiferayProject(project); if (project == null || !project.exists()) { return null; } final LiferayDescriptorHelper[] allHelpers = LiferayDescriptorHelperReader.getInstance().getAllHelpers(); for (LiferayDescriptorHelper helper : allHelpers) { helper.setProject(project); final IFile descriptorFile = helper.getDescriptorFile(); if (descriptorFile != null && descriptorFile.exists()) { if (helper.getDescriptorOperation(type) != null) { retval.add(helper); } } } return retval.toArray(new LiferayDescriptorHelper[0]); }
private static IStatus removeSampleCodeAndFiles(NewLiferayPluginProjectOp op) { IStatus status = org.eclipse.core.runtime.Status.OK_STATUS; final boolean includeSampleCode = op.getIncludeSampleCode().content(); if (!includeSampleCode) { final IProject project = CoreUtil.getLiferayProject(op.getFinalProjectName().content()); if (project != null && project.exists()) { ProjectCore.operate(project, RemoveSampleElementsOperation.class); // delete sample files: view.jsp, main.css, main.js try { final IWebProject webproject = LiferayCore.create(IWebProject.class, project); if (webproject != null) { final IFolder docroot = webproject.getDefaultDocrootFolder(); final IFile[] sampleFiles = { docroot.getFile("view.jsp"), docroot.getFile("css/main.css"), docroot.getFile("js/main.js") }; for (IFile file : sampleFiles) { if (file != null && file.exists()) { file.delete(true, new NullProgressMonitor()); if (file.getParent().members().length == 0) { CoreUtil.deleteResource(file.getParent()); } } } } } catch (CoreException e) { ProjectCore.logError("Error deleting sample files.", e); } } } return status; }