@Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { monitor.setTaskName("Retrieving LOG file for procedure " + m_proc.getProcName()); IFileManager fileMgr = (IFileManager) ServiceManager.get(IFileManager.class); String path = fileMgr.getServerFilePath(m_proc.getProcId(), ServerFileType.EXECUTOR_LOG, monitor); Logger.debug("LOG file path: '" + path + "'", Level.PROC, this); logFile = (LogFile) fileMgr.getServerFile(path, ServerFileType.EXECUTOR_LOG, null, monitor); List<IServerFileLine> lines = logFile.getLines(); monitor.beginTask("Exporting log data", lines.size()); PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(m_destinationFileName))); for (IServerFileLine line : lines) { writer.println(line.toString()); monitor.worked(1); if (monitor.isCanceled()) break; } writer.close(); monitor.done(); result = CommandResult.SUCCESS; } catch (Exception e) { Logger.error("Could retrieve LOG:" + e.getLocalizedMessage(), Level.PROC, this); } monitor.done(); }
/* * @see org.eclipse.core.internal.filebuffers.textmanipulation.IFileBufferOperation#run(org.eclipse.core.filebuffers.IFileBuffer, org.eclipse.core.runtime.IProgressMonitor) */ public void run(IFileBuffer fileBuffer, IProgressMonitor progressMonitor) throws CoreException, OperationCanceledException { if (fileBuffer instanceof ITextFileBuffer) { ITextFileBuffer textFileBuffer = (ITextFileBuffer) fileBuffer; IPath path = textFileBuffer.getLocation(); String taskName = path == null ? getOperationName() : path.lastSegment(); progressMonitor = Progress.getMonitor(progressMonitor); progressMonitor.beginTask(taskName, 100); try { IProgressMonitor subMonitor = Progress.getSubMonitor(progressMonitor, 10); MultiTextEditWithProgress edit = computeTextEdit(textFileBuffer, subMonitor); subMonitor.done(); if (edit != null) { Object stateData = startRewriteSession(textFileBuffer); try { subMonitor = Progress.getSubMonitor(progressMonitor, 90); applyTextEdit(textFileBuffer, edit, subMonitor); subMonitor.done(); } finally { stopRewriteSession(textFileBuffer, stateData); } } } finally { progressMonitor.done(); } } }
private void searchForRuntimes( List<RuntimeDefinition> runtimeCollector, IPath path, IProgressMonitor monitor) { File[] files = null; if (path != null) { File root = path.toFile(); if (root.isDirectory()) files = new File[] {root}; else return; } else files = File.listRoots(); if (files != null) { int size = files.length; monitor.beginTask("Searching " + path.toOSString(), size * 100); int work = 100 / size; for (int i = 0; i < size; i++) { if (monitor.isCanceled()) return; if (files[i] != null && files[i].isDirectory()) searchDirectory(files[i], runtimeCollector, DEPTH, new SubProgressMonitor(monitor, 80)); monitor.worked(20); } monitor.done(); } else { monitor.beginTask("Searching " + path.toOSString(), 1); monitor.worked(1); monitor.done(); } }
@Override protected IStatus run(IProgressMonitor monitor) { // The core plugin might have been stopped before we could cancel // this job. RepositoryCache repositoryCache = org.eclipse.egit.core.Activator.getDefault().getRepositoryCache(); if (repositoryCache == null) return Status.OK_STATUS; Repository[] repos = repositoryCache.getAllRepositories(); if (repos.length == 0) return Status.OK_STATUS; // When people use Git from the command line a lot of changes // may happen. Don't scan when inactive depending on the user's // choice. if (Activator.getDefault() .getPreferenceStore() .getBoolean(UIPreferences.REFESH_ONLY_WHEN_ACTIVE)) { if (!isActive()) { monitor.done(); if (doReschedule) schedule(REPO_SCAN_INTERVAL); return Status.OK_STATUS; } } monitor.beginTask(UIText.Activator_scanningRepositories, repos.length); try { for (Repository repo : repos) { if (monitor.isCanceled()) break; if (GitTraceLocation.REPOSITORYCHANGESCANNER.isActive()) GitTraceLocation.getTrace() .trace( GitTraceLocation.REPOSITORYCHANGESCANNER.getLocation(), "Scanning " + repo + " for changes"); // $NON-NLS-1$ //$NON-NLS-2$ repo.scanForRepoChanges(); monitor.worked(1); } } catch (IOException e) { if (GitTraceLocation.REPOSITORYCHANGESCANNER.isActive()) GitTraceLocation.getTrace() .trace( GitTraceLocation.REPOSITORYCHANGESCANNER.getLocation(), "Stopped rescheduling " + getName() + "job"); // $NON-NLS-1$ //$NON-NLS-2$ return createErrorStatus(UIText.Activator_scanError, e); } finally { monitor.done(); } if (GitTraceLocation.REPOSITORYCHANGESCANNER.isActive()) GitTraceLocation.getTrace() .trace( GitTraceLocation.REPOSITORYCHANGESCANNER.getLocation(), "Rescheduling " + getName() + " job"); // $NON-NLS-1$ //$NON-NLS-2$ if (doReschedule) schedule(REPO_SCAN_INTERVAL); return Status.OK_STATUS; }
@Override protected IStatus run(IProgressMonitor monitor) { final AbstractShellCommand command = getCommand(progress, hgRoot, port, prefix, name, webdirConf, stdio, ipv6); try { command.executeToBytes(Integer.MAX_VALUE, false); } catch (HgException e) { MercurialEclipsePlugin.logError(e); } finally { command.terminate(); progress.done(); monitor.done(); } return Status.OK_STATUS; }
/** {@inheritDoc} */ @Override protected IStatus run(final IProgressMonitor monitor) { try { final IConnection connection = ConnectionFactory.openConnection(m_serverConnection); connection.sychronizeNow(monitor); m_status = SynchronizationStatus.OK; RepositoryFactory.getRepository() .getServerConnectionRepository() .markSynchronized(m_serverConnection.getId()); } catch (final Throwable e) { e.printStackTrace(); ConnectionUIPlugin.getDefault().log(e); m_status = SynchronizationStatus.FAILURE; m_lastError = e.getMessage(); } finally { monitor.done(); } m_lastRun = new Date(); reschedule(); return Status.OK_STATUS; }
// protected final RefactoringStatus isValid(IProgressMonitor pm, boolean checkReadOnly, boolean // checkDirty) throws CoreException { protected final RefactoringStatus isValid(IProgressMonitor pm, int flags) throws CoreException { pm.beginTask("", 2); // $NON-NLS-1$ try { RefactoringStatus result = new RefactoringStatus(); Object modifiedElement = getModifiedElement(); checkExistence(result, modifiedElement); if (result.hasFatalError()) return result; if (flags == NONE) return result; IResource resource = getResource(modifiedElement); if (resource != null) { ValidationState state = new ValidationState(resource); state.checkModificationStamp(result, fModificationStamp); if (result.hasFatalError()) return result; state.checkSameReadOnly(result, fReadOnly); if (result.hasFatalError()) return result; if ((flags & READ_ONLY) != 0) { state.checkReadOnly(result); if (result.hasFatalError()) return result; } if ((flags & DIRTY) != 0) { if ((flags & SAVE) != 0) { state.checkDirty(result, fModificationStamp, new SubProgressMonitor(pm, 1)); } else { state.checkDirty(result); } } } return result; } finally { pm.done(); } }
@Override protected void publishServer(int kind, IProgressMonitor monitor) throws CoreException { if (getServer().getRuntime() == null) return; IPath confDir = getBaseDirectory(); getJonasVersionHandler() .createJonasBase( getServer().getRuntime().getLocation(), this.getJonasRuntimeInstance().getInstanceDirectory()); IStatus status = getJonasVersionHandler().prepareDeployDirectory(confDir); if (status != null && !status.isOK()) throw new CoreException(status); IProgressMonitor monitor2 = ProgressUtil.getMonitorFor(monitor); monitor2.beginTask(Messages.publishServerTask, 600); // TODO OSAMI 1) Cleanup 2) Backup and Publish, // if (status != null && !status.isOK()) // throw new CoreException(status); monitor2.done(); setServerPublishState(IServer.PUBLISH_STATE_NONE); }
public void done() { tickTask.cancel(); tickTimer.cancel(); synchronized (monitor) { monitor.done(); } }
@Override public void postWikiPage( TaskRepository repository, TracWikiPage newPage, IProgressMonitor monitor) throws CoreException { monitor.beginTask(Messages.TracWikiHandler_Upload_Wiki_Page, IProgressMonitor.UNKNOWN); try { String pageName = newPage.getPageInfo().getPageName(); String content = newPage.getContent(); Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put("comment", newPage.getPageInfo().getComment()); // $NON-NLS-1$ attributes.put("author", newPage.getPageInfo().getAuthor()); // $NON-NLS-1$ boolean success = getTracWikiClient(repository).putWikipage(pageName, content, attributes, monitor); if (success) { return; } else { throw new CoreException( TracCorePlugin.toStatus( new TracException("Failed to upload wiki page. No further information available."), repository)); //$NON-NLS-1$ } } catch (TracException e) { throw new CoreException(TracCorePlugin.toStatus(e, repository)); } finally { monitor.done(); } }
/** {@inheritDoc} */ @Override protected IStatus run(IProgressMonitor pMonitor) { progressMonitor = pMonitor; progressMonitor.setTaskName("Waiting..."); try { final Display display = Activator.getDefault().getWorkbench().getDisplay(); display.syncExec( new Runnable() { public void run() { MessageBox turnOn = new MessageBox(new Shell(display), SWT.ICON_INFORMATION); if (serviceMode) { turnOn.setMessage("Turn On connected device in service mode and press OK."); } else { turnOn.setMessage("Turn On connected device in normal mode and press OK."); } if (turnOn.open() == SWT.OK) { result = "OK"; } else { result = "CANCEL"; } } }); return new Status(IStatus.OK, Activator.PLUGIN_ID, result); } catch (Exception e) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Command failed", e); } finally { progressMonitor.done(); } // return null; }
@Override public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException { RefactoringStatus status = new RefactoringStatus(); try { pm.beginTask("Checking preconditions...", 6); if (mSelectionStart == -1 || mSelectionEnd == -1) { status.addFatalError("No selection to convert"); return status; } // Make sure the selection is contiguous if (mTreeSelection != null) { List<CanvasViewInfo> infos = getSelectedViewInfos(); if (!validateNotEmpty(infos, status)) { return status; } } // Ensures that we have a valid DOM model: if (mElements.size() == 0) { status.addFatalError("Nothing to convert"); return status; } pm.worked(1); return status; } finally { pm.done(); } }
protected List unExclude(List elements, IScriptProject project, IProgressMonitor monitor) throws ModelException { if (monitor == null) monitor = new NullProgressMonitor(); try { monitor.beginTask(NewWizardMessages.BuildpathModifier_Monitor_Including, 2 * elements.size()); List entries = BuildpathModifier.getExistingEntries(project); for (int i = 0; i < elements.size(); i++) { IResource resource = (IResource) elements.get(i); IProjectFragment root = BuildpathModifier.getFragmentRoot( resource, project, new SubProgressMonitor(monitor, 1)); if (root != null) { BPListElement entry = BuildpathModifier.getBuildpathEntry(entries, root); BuildpathModifier.unExclude(resource, entry, project, new SubProgressMonitor(monitor, 1)); } } BuildpathModifier.commitBuildPath(entries, project, new SubProgressMonitor(monitor, 4)); List resultElements = BuildpathModifier.getCorrespondingElements(elements, project); return resultElements; } finally { monitor.done(); } }
/** * {@inheritDoc} * * @see * org.eclipse.core.resources.IWorkspaceRunnable#run(org.eclipse.core.runtime.IProgressMonitor) */ public void run(IProgressMonitor monitor) throws CoreException { monitor.beginTask( AcceleoUIMessages.getString("AcceleoCompileOperation.Task.Compile"), files.length); // $NON-NLS-1$ for (int i = 0; i < files.length; i++) { checkCanceled(monitor); monitor.subTask( AcceleoUIMessages.getString( "AcceleoCompileOperation.Task.Clean", files[0].getFullPath().toString())); // $NON-NLS-1$ if (files[i].isAccessible()) { files[i].deleteMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE); files[i].deleteMarkers(IMarker.TASK, true, IResource.DEPTH_INFINITE); files[i].deleteMarkers( AcceleoMarkerUtils.OVERRIDE_MARKER_ID, true, IResource.DEPTH_INFINITE); } } if (!isClean) { doCompileResources(monitor); } else { for (IFile file : this.files) { AcceleoProject acceleoProject = new AcceleoProject(project); IPath outputPath = acceleoProject.getOutputFilePath(file); if (outputPath != null) { URI platformURI = URI.createPlatformResourceURI(outputPath.toString(), false); try { AcceleoUIResourceSet.removeResource(platformURI); } catch (IOException e) { AcceleoUIActivator.log(e, true); } } } } monitor.done(); }
@Override public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException { pm.beginTask(RefactoringCoreMessages.ExtractConstantRefactoring_checking_preconditions, 2); /* Note: some checks are performed on change of input widget * values. (e.g. see ExtractConstantRefactoring.checkConstantNameOnChange()) */ // TODO: possibly add more checking for name conflicts that might // lead to a change in behavior try { RefactoringStatus result = new RefactoringStatus(); createConstantDeclaration(); replaceExpressionsWithConstant(); fChange = fCuRewrite.createChange( RefactoringCoreMessages.ExtractConstantRefactoring_change_name, true, new SubProgressMonitor(pm, 1)); if (fCheckResultForCompileProblems) { checkSource(new SubProgressMonitor(pm, 1), result); } return result; } finally { fConstantTypeCache = null; fCuRewrite.clearASTAndImportRewrites(); pm.done(); } }
@Override protected IStatus run(IProgressMonitor monitor) { checkDir(); monitor.beginTask("Saveing full Profile to... " + workingDir, IProgressMonitor.UNKNOWN); createDirAndFile(); saveFullProfile(downloadFullProfile()); saveXLogData(); monitor.done(); ExUtil.exec( PlatformUI.getWorkbench().getDisplay(), new Runnable() { public void run() { Action act = new OpenWorkspaceExplorerAction( window, "Workspace Explorer", Images.explorer, true, serverId); act.run(); } }); return Status.OK_STATUS; }
private Set<String> getResourcesToBuild( final int kind, @SuppressWarnings("rawtypes") final Map args, final IProject project) throws CoreException { Set<BuildResource> result = Sets.newHashSet(); final IProgressMonitor submon = new NullProgressMonitor(); // new SubProgressMonitor(monitor, 10); submon.beginTask("retrieving resources to build", IProgressMonitor.UNKNOWN); if (kind == FULL_BUILD) { result = helper.getAffectedResources(args, project, submon); } else { final IResourceDelta delta = getDelta(project); final Path path = new Path(".settings/org.erlide.core.prefs"); if (delta.findMember(path) != null) { ErlLogger.info("project configuration changed: doing full rebuild"); result = helper.getAffectedResources(args, project, submon); } else { result = helper.getAffectedResources(args, delta, submon); } } if (BuilderHelper.isDebugging()) { ErlLogger.debug( "Will compile %d resource(s): %s", Integer.valueOf(result.size()), result.toString()); } submon.done(); final Set<String> paths = new HashSet<String>(); for (final BuildResource res : result) { paths.add(res.getResource().getLocation().toPortableString()); } return paths; }
@Override public Change createChange(final IProgressMonitor pm) throws CoreException, OperationCanceledException { pm.beginTask("Creating changes", changedFiles.size() + 1); final CompositeChange change = new CompositeChange(getName()); pm.internalWorked(1); try { Change c; for (final ChangedFile e : changedFiles) { c = e.createChanges(); if (c != null) { change.add(c); pm.internalWorked(1); } } } catch (final IOException e) { final Status s = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage()); throw new CoreException(s); } finally { pm.done(); } return change; }
protected void execute(GeneralProjectMigration page, String libraryId, IProgressMonitor monitor2) throws Exception { IProject target = ToolingUtils.importLibrary(libraryId); IProject project2Update = this.project; // copy projects before as requested Boolean projectCopy = page.getFieldValueBoolean(GeneralProjectMigration.Fields.copybefore.toString()); if (projectCopy) { project2Update = null; String newNameParam = page.getFieldValueString(GeneralProjectMigration.Fields.newName.toString()); if (StringUtils.trimToNull(newNameParam) == null) { newNameParam = GeneralProjectMigration.DEFAULT_VALUE_NEWNAME; } IProjectDescription description = project.getDescription(); String newName = newNameParam; description.setName(newName); description.setLocationURI(null); System.out.println( "ModelMigrationWizard.execute() rename project " + project.getName() + " -> " + newName); project.copy(description, true, monitor2); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(description.getName()); project2Update = project; } // execute models conversion ModelMigrationHelper modelMigrationHelper = new ModelMigrationHelper(); modelMigrationHelper.updateProject(project2Update, target, libraryId, projectCopy, monitor2); monitor2.subTask("Refresh project"); IFileHelper.refreshFolder(project2Update); monitor2.done(); }
@Override protected void clearProblems(IProgressMonitor monitor, IDocument document, IRegion region) throws CoreException { monitor.beginTask(Messages.AnnotationMarkupValidator_clearingProblems, 100); // nothing to do: we do this all in the createProblems method. monitor.done(); }
public ASTReader(IJavaProject iJavaProject, IProgressMonitor monitor) { if (monitor != null) monitor.beginTask("Parsing selected Java Project", getNumberOfCompilationUnits(iJavaProject)); systemObject = new SystemObject(); examinedProject = iJavaProject; try { IPackageFragmentRoot[] iPackageFragmentRoots = iJavaProject.getPackageFragmentRoots(); for (IPackageFragmentRoot iPackageFragmentRoot : iPackageFragmentRoots) { IJavaElement[] children = iPackageFragmentRoot.getChildren(); for (IJavaElement child : children) { if (child.getElementType() == IJavaElement.PACKAGE_FRAGMENT) { IPackageFragment iPackageFragment = (IPackageFragment) child; ICompilationUnit[] iCompilationUnits = iPackageFragment.getCompilationUnits(); for (ICompilationUnit iCompilationUnit : iCompilationUnits) { if (monitor != null && monitor.isCanceled()) throw new OperationCanceledException(); systemObject.addClasses(parseAST(iCompilationUnit)); if (monitor != null) monitor.worked(1); } } } } } catch (JavaModelException e) { e.printStackTrace(); } if (monitor != null) monitor.done(); }
public static void addUserLibToClassPath(IProject project, IProgressMonitor monitor) { monitor = Util.getNonNullMonitor(monitor); try { IJavaProject javaProject = JavaCore.create(project); IClasspathEntry[] oldClasspath = javaProject.getRawClasspath(); IClasspathEntry[] newClasspath = new IClasspathEntry[oldClasspath.length + 1]; System.arraycopy(oldClasspath, 0, newClasspath, 0, oldClasspath.length); IClasspathEntry gwtuserJarEntry = JavaCore.newVariableEntry(Util.getGwtUserLibPath(), null, null); gwtuserJarEntry = JavaCore.newVariableEntry( gwtuserJarEntry.getPath(), null, null, new IAccessRule[0], new IClasspathAttribute[0], false); newClasspath[oldClasspath.length] = gwtuserJarEntry; javaProject.setRawClasspath(newClasspath, monitor); } catch (CoreException e) { // the jar is already in the classpath. Activator.logException(e); } finally { monitor.done(); } }
/** * @param monitor * @throws Exception */ private void addServletToGwtXml(IProgressMonitor monitor) throws Exception { monitor = Util.getNonNullMonitor(monitor); try { monitor.beginTask("", 1); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); File moduleFile = getModuleFile(); Document document = builder.parse(moduleFile); Node module = document.getDocumentElement(); Element newServlet = document.createElement("servlet"); newServlet.setAttribute("path", "/" + serviceUri); // $NON-NLS-2$ newServlet.setAttribute( "class", getPackageFragment().getElementName() + '.' + getTypeName() + "Impl"); // $NON-NLS-2$ module.appendChild(newServlet); Transformer writer = TransformerFactory.newInstance().newTransformer(); writer.transform(new DOMSource(document), new StreamResult(moduleFile)); } finally { monitor.done(); } }
/** {@inheritDoc} */ public void doSave(IProgressMonitor monitor) { monitor.beginTask(Messages.EditorsSaveEditors, IProgressMonitor.UNKNOWN); try { EditSupport editSupport = getEditorHelper().getEditSupport(); final IPersistentObject perObj = editSupport.getWorkVersion(); TimestampBP.refreshTimestamp((ITimestampPO) perObj); editSupport.saveWorkVersion(); getEditorHelper().resetEditableState(); getEditorHelper().setDirty(false); } catch (IncompatibleTypeException pmce) { handlePMCompNameException(pmce); } catch (PMException e) { PMExceptionHandler.handlePMExceptionForMasterSession(e); try { reOpenEditor(((NodeEditorInput) getEditorInput()).getNode()); } catch (PMException e1) { PMExceptionHandler.handlePMExceptionForEditor(e, this); } } catch (ProjectDeletedException e) { PMExceptionHandler.handleProjectDeletedException(); } finally { monitor.done(); } }
protected ILaunch buildAndLaunch( ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException { monitor.beginTask("", 1); // $NON-NLS-1$ try { MavenLaunchDelegate mvld = new TalendMavenLaunchDelegate(); ILaunch launch = new Launch(configuration, mode, null); ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); launch.setAttribute( DebugPlugin.ATTR_LAUNCH_TIMESTAMP, Long.toString(System.currentTimeMillis())); launch.setAttribute( DebugPlugin.ATTR_CONSOLE_ENCODING, launchManager.getEncoding(configuration)); if (isCaptureOutputInConsoleView()) { launchManager.addLaunch(launch); } String type = "org.eclipse.m2e.launching.MavenSourceLocator"; // $NON-NLS-1$ IPersistableSourceLocator locator = launchManager.newSourceLocator(type); locator.initializeDefaults(configuration); launch.setSourceLocator(locator); mvld.launch(configuration, mode, launch, monitor); return launch; } finally { monitor.done(); } }
public void configureProject(String wizardCmdArgs) throws CoreException { pm.beginTask(SConsI18N.SConsProjectConfigureHandler_ConvertingInProgress, 10); try { configureCDTProject(); pm.worked(1); saveProjectSettings(wizardCmdArgs); pm.worked(1); extractProjectInformation(); pm.worked(7); removeMakeBuilder(); addSConsNature(); } catch (Exception e) { SConsPlugin.log(e); IStatus status = new Status( IStatus.ERROR, SConsPlugin.PLUGIN_ID, 0, SConsI18N.SConsProjectConfigureHandler_ConfiguringFailedErrorMessage, e); throw new CoreException(status); } finally { pm.done(); } }
private GradleImportOperation createImportOperation(IProgressMonitor m) throws FastOperationFailedException, OperationCanceledException, CoreException { m.beginTask("Create re-import operation", 1); try { GradleRefreshPreferences prefs = gradleProjects.iterator().next().getRootProject().getRefreshPreferences(); List<HierarchicalEclipseProject> projects = new ArrayList<HierarchicalEclipseProject>(gradleProjects.size()); Set<HierarchicalEclipseProject> relatedProjectsSet = new HashSet<HierarchicalEclipseProject>(); for (GradleProject gradleProject : gradleProjects) { projects.add(gradleProject.getGradleModel(m)); relatedProjectsSet.addAll(gradleProject.getAllProjectsInBuild()); } GradleImportOperation op = new GradleImportOperation( projects, false, GradleImportOperation.createProjectMapping( prefs.getUseHierarchicalNames(), Arrays.asList( relatedProjectsSet.toArray( new HierarchicalEclipseProject[relatedProjectsSet.size()])))); op.setQuickWorkingSet(null); // this option only meaningfull on initial import. op.setReimport(true); op.verify(); return op; } finally { m.done(); } }
@Override public void buildNow(IProgressMonitor monitor) throws CoreException { if (monitor.isCanceled()) { return; } try { monitor.beginTask(Messages.MSBuild_BuildProjectTask, 10); // TODO: use extension point to create the generator. WPProjectGenerator creator = new WPProjectGenerator(getProject(), null, WPProjectUtils.WP8); SubProgressMonitor generateMonitor = new SubProgressMonitor(monitor, 1); File vstudioProjectDir = creator.generateNow(generateMonitor); monitor.worked(4); if (monitor.isCanceled()) { return; } doBuildProject(vstudioProjectDir, generateMonitor); HybridProject hybridProject = HybridProject.getHybridProject(this.getProject()); if (hybridProject == null) { throw new CoreException( new Status(IStatus.ERROR, WPCore.PLUGIN_ID, Messages.MSBuild_NoHybridError)); } if (isRelease()) { setBuildArtifact(new File(getBuildDir(vstudioProjectDir), RELEASE_XAP_NAME)); } else { setBuildArtifact(new File(getBuildDir(vstudioProjectDir), DEBUG_XAP_NAME)); } } finally { monitor.done(); } }
public static void addServletLibToWebInf(IProject project, IProgressMonitor monitor) { monitor = Util.getNonNullMonitor(monitor); try { monitor.beginTask("", 1); IJavaProject javaProject = JavaCore.create(project); IClasspathEntry[] oldClasspath = javaProject.getRawClasspath(); IClasspathEntry[] newClasspath = new IClasspathEntry[oldClasspath.length + 1]; System.arraycopy(oldClasspath, 0, newClasspath, 0, oldClasspath.length); IClasspathEntry gwtServletJarEntry = JavaCore.newVariableEntry(Util.getGwtServletLibPath(), null, null); IClasspathAttribute attr = JavaCore.newClasspathAttribute("org.eclipse.jst.component.dependency", "/WEB-INF/lib"); gwtServletJarEntry = JavaCore.newVariableEntry( gwtServletJarEntry.getPath(), null, null, new IAccessRule[0], new IClasspathAttribute[] {attr}, false); newClasspath[oldClasspath.length] = gwtServletJarEntry; javaProject.setRawClasspath(newClasspath, monitor); } catch (JavaModelException e) { // the jar is already in the classpath. Activator.logException(e); } finally { monitor.done(); } }
/** * Set the progress monitor done. * * @param progress The progress monitor or <code>null</code>. */ public static final void done(IProgressMonitor progress) { if (progress != null) { progress.setTaskName(""); // $NON-NLS-1$ progress.subTask(""); // $NON-NLS-1$ progress.done(); } }