@Override protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { int numUnits = fWebLocation == null ? 3 : 4; monitor.beginTask(PDEUIMessages.NewSiteWizard_creatingProject, numUnits); CoreUtility.createProject(fProject, fPath, monitor); fProject.open(monitor); CoreUtility.addNatureToProject(fProject, PDE.SITE_NATURE, monitor); monitor.worked(1); if (fWebLocation != null) { CoreUtility.createFolder(fProject.getFolder(fWebLocation)); createXSLFile(); createCSSFile(); createHTMLFile(); monitor.worked(1); } monitor.subTask(PDEUIMessages.NewSiteWizard_creatingManifest); IFile file = createSiteManifest(); monitor.worked(1); openFile(file); monitor.worked(1); }
/** * The worker method. It will find the container, create the file if missing or just replace its * contents, and open the editor on the newly created file. */ private void doFinish(String containerName, String fileName, IProgressMonitor monitor) throws CoreException { // create a sample file monitor.beginTask("Creating " + fileName, 2); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IResource resource = root.findMember(new Path(containerName)); if (!resource.exists() || !(resource instanceof IContainer)) { throwCoreException("Container \"" + containerName + "\" does not exist."); } IContainer container = (IContainer) resource; final IFile file = container.getFile(new Path(fileName)); try { InputStream stream = openContentStream(); if (file.exists()) { file.setContents(stream, true, true, monitor); } else { file.create(stream, true, monitor); } stream.close(); } catch (IOException e) { } monitor.worked(1); monitor.setTaskName("Opening file for editing..."); getShell() .getDisplay() .asyncExec( new Runnable() { public void run() { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); try { IDE.openEditor(page, file, true); } catch (PartInitException e) { } } }); monitor.worked(1); }
/** * The worker method. It will create a new project, then create the appropriate Soar heirarchy and * files. */ private void doFinish(String projectName, IProgressMonitor monitor) throws CoreException { monitor.beginTask("Creating " + projectName, 7); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IProject newProject = root.getProject(projectName); // creation of the project if (newProject.exists()) { throwCoreException("Project \"" + projectName + "\" already exists"); } else { newProject.create(monitor); newProject.open(monitor); try { IProjectDescription description = newProject.getDescription(); String[] natures = description.getNatureIds(); String[] newNatures = new String[natures.length + 1]; System.arraycopy(natures, 0, newNatures, 0, natures.length); newNatures[natures.length] = SoarProjectNature.NATURE_ID; description.setNatureIds(newNatures); newProject.setDescription(description, IResource.FORCE, monitor); newProject.setPersistentProperty(DataMap.VERTEX_ID, "0"); } catch (CoreException e) { e.printStackTrace(); } // catch } // else monitor.worked(2); // Create the contents of the project's root directory IFolder folderAll = newProject.getFolder("all"); if (!folderAll.exists()) { folderAll.create(true, true, monitor); } // if FileMarker.markResource(folderAll, "file"); IFolder folderElaborations = newProject.getFolder("elaborations"); if (!folderElaborations.exists()) { folderElaborations.create(true, true, monitor); } // if FileMarker.markResource(folderElaborations, "file"); IFile file_firstload = newProject.getFile("_firstload.soar"); if (!file_firstload.exists()) { file_firstload.create( Utility.getFileTemplate(file_firstload, "_firstload.soar"), true, monitor); } // if FileMarker.markResource(file_firstload, "file"); IFile filedatamap = newProject.getFile("datamap.xdm"); if (!filedatamap.exists()) { filedatamap.create(Utility.getFileTemplate(filedatamap, "datamap.xdm"), true, monitor); } // if monitor.worked(3); // Create the contents of the elaborations folder IFile file_all = folderElaborations.getFile("_all.soar"); if (!file_all.exists()) { file_all.create(Utility.getFileTemplate(file_all, "_all.soar"), true, monitor); } // if FileMarker.markResource(file_all, "file"); IFile filetopstate = folderElaborations.getFile("top-state.soar"); if (!filetopstate.exists()) { filetopstate.create(Utility.getFileTemplate(filetopstate, "top-state.soar"), true, monitor); } // if FileMarker.markResource(filetopstate, "file"); SourcingFile.createSourcingFile(newProject, monitor); newProject.close(monitor); newProject.open(monitor); monitor.worked(2); monitor.done(); } // void doFinish(...)