@Override public void setContents(InputStream content, int updateFlags, IProgressMonitor monitor) throws CoreException { monitor = Policy.monitorFor(monitor); try { String message = NLS.bind(Messages.resources_settingContents, getFullPath()); monitor.beginTask(message, Policy.totalWork); if (workspace.shouldValidate) workspace.validateSave(this); final ISchedulingRule rule = workspace.getRuleFactory().modifyRule(this); try { workspace.prepareOperation(rule, monitor); ResourceInfo info = getResourceInfo(false, false); checkAccessible(getFlags(info)); workspace.beginOperation(true); IFileInfo fileInfo = getStore().fetchInfo(); internalSetContents( content, fileInfo, updateFlags, false, Policy.subMonitorFor(monitor, Policy.opWork)); } catch (OperationCanceledException e) { workspace.getWorkManager().operationCanceled(); throw e; } finally { workspace.endOperation(rule, true, Policy.subMonitorFor(monitor, Policy.endOpWork)); } } finally { monitor.done(); FileUtil.safeClose(content); } }
public void setSubTask(int template, String subtask[]) { if (m_monitor != null) { switch (template) { case STASK_SCANNING: if (subtask.length == 1) m_monitor.subTask(subtask[0]); break; case STASK_PREPARE: m_monitor.subTask("Preparing to transfer"); break; case STASK_TRANSFER: if (subtask.length == 5) { // need percentage // need time remaining // need data transfer rate String text = ""; text += subtask[0] + "\t" + subtask[1] + "\n"; text += subtask[2] + "\t" + subtask[3] + "\t" + subtask[4]; m_monitor.subTask(text); } else { m_monitor.subTask("Starting transfer...."); } break; } } }
/** * Adds the text and move changes to the root change This change is the a more global change, it * includes both the file(s) move, the update of it's includes and update all the references, all * the files that have includes to the moved file. * * @param pm - progress monitor * @param rootChange - the root change that the new changes are added to * @return the root change after the additions */ private Change createReferenceUpdatingMoveChange(IProgressMonitor pm, CompositeChange rootChange) throws CoreException, OperationCanceledException { try { pm.beginTask(PhpRefactoringCoreMessages.getString("MoveDelegate.0"), 100); // $NON-NLS-1$ IResource[] sourceResources = fProcessor.getSourceSelection(); createTextChanges(new SubProgressMonitor(pm, 80), rootChange, phpFiles, sourceResources); pm.worked(80); // update configuration file. createRunConfigurationChange(sourceResources, rootChange); // There is a tricky thing here. // The resource move must be happened after text change, and run // configuration changes(this is because the share file under the // project) // but before the other changes, e.g. break point and etc. createMoveChange(sourceResources, rootChange); // update associated break point. createBreakPointChange(sourceResources, rootChange); createBuildPathChange(sourceResources, rootChange); createRenameLibraryFolderChange(sourceResources, rootChange); pm.worked(20); } finally { pm.done(); } return rootChange; }
protected IResource[] checkOverwriteOfDirtyResources( IResource[] resources, IProgressMonitor monitor) throws CVSException, InterruptedException { List dirtyResources = new ArrayList(); IResource[] selectedResources = getSelectedResources(); try { monitor = Policy.monitorFor(monitor); monitor.beginTask(null, selectedResources.length * 100); monitor.setTaskName(CVSUIMessages.ReplaceWithAction_calculatingDirtyResources); for (int i = 0; i < selectedResources.length; i++) { IResource resource = selectedResources[i]; ICVSResource cvsResource = getCVSResourceFor(resource); if (cvsResource.isModified(Policy.subMonitorFor(monitor, 100))) { dirtyResources.add(resource); } } } finally { monitor.done(); } PromptingDialog dialog = new PromptingDialog( getShell(), selectedResources, getPromptCondition( (IResource[]) dirtyResources.toArray(new IResource[dirtyResources.size()])), CVSUIMessages.ReplaceWithAction_confirmOverwrite); return dialog.promptForMultiple(); }
public void setTask(int template, String task[]) { if (m_monitor != null) { switch (template) { case TASK_CONNECT: m_monitor.setTaskName("Connecting to SFTP Site"); break; case TASK_SCANNING: m_monitor.setTaskName("Scanning directories"); break; case TASK_TRANSFER: if (task.length == 2) { m_monitor.setTaskName(task[0] + ":\t" + task[1]); } break; case TASK_COMPLETE: m_monitor.setTaskName("Transfer completed"); break; case TASK_ERROR: if (task.length >= 1) { m_monitor.setTaskName("ERROR: " + task[0]); for (int a = 0; a < task.length; a++) { m_output.append(task[a] + "\n"); System.out.println(task[a]); } } break; } } }
public void search( ISearchRequestor requestor, QuerySpecification querySpecification, IProgressMonitor monitor) throws CoreException { if (querySpecification.getLimitTo() != S_LIMIT_REF && querySpecification.getLimitTo() != S_LIMIT_ALL) return; String search; if (querySpecification instanceof ElementQuerySpecification) { IJavaElement element = ((ElementQuerySpecification) querySpecification).getElement(); if (element instanceof IType) search = ((IType) element).getFullyQualifiedName('.'); else search = element.getElementName(); int type = element.getElementType(); if (type == IJavaElement.TYPE) fSearchFor = S_FOR_TYPES; else if (type == IJavaElement.PACKAGE_FRAGMENT || type == IJavaElement.PACKAGE_FRAGMENT_ROOT) fSearchFor = S_FOR_PACKAGES; } else { fSearchFor = ((PatternQuerySpecification) querySpecification).getSearchFor(); search = ((PatternQuerySpecification) querySpecification).getPattern(); } if (fSearchFor != S_FOR_TYPES && fSearchFor != S_FOR_PACKAGES) return; fSearchPattern = PatternConstructor.createPattern(search, true); fSearchRequestor = requestor; IPath[] enclosingPaths = querySpecification.getScope().enclosingProjectsAndJars(); IPluginModelBase[] pluginModels = PluginRegistry.getWorkspaceModels(); monitor.beginTask(PDEUIMessages.ClassSearchParticipant_taskMessage, pluginModels.length); for (int i = 0; i < pluginModels.length; i++) { IProject project = pluginModels[i].getUnderlyingResource().getProject(); if (!monitor.isCanceled() && encloses(enclosingPaths, project.getFullPath())) searchProject(project, monitor); } }
@Override public void setCharset(String newCharset, IProgressMonitor monitor) throws CoreException { monitor = Policy.monitorFor(monitor); try { String message = NLS.bind(Messages.resources_settingCharset, getFullPath()); monitor.beginTask(message, Policy.totalWork); // need to get the project as a scheduling rule because we might be creating a new folder/file // to // hold the project settings final ISchedulingRule rule = workspace.getRuleFactory().charsetRule(this); try { workspace.prepareOperation(rule, monitor); ResourceInfo info = getResourceInfo(false, false); checkAccessible(getFlags(info)); workspace.beginOperation(true); workspace.getCharsetManager().setCharsetFor(getFullPath(), newCharset); info = getResourceInfo(false, true); info.incrementCharsetGenerationCount(); monitor.worked(Policy.opWork); } catch (OperationCanceledException e) { workspace.getWorkManager().operationCanceled(); throw e; } finally { workspace.endOperation(rule, true, Policy.subMonitorFor(monitor, Policy.endOpWork)); } } finally { monitor.done(); } }
/* * @see IWorkspaceRunnable#run(IProgressMonitor) */ public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException { if (monitor == null) { monitor = new NullProgressMonitor(); } monitor.beginTask(MDEUIMessages.FeatureImportWizard_operation_creating, fModels.length); try { MultiStatus multiStatus = new MultiStatus( MDEPlugin.getPluginId(), IStatus.OK, MDEUIMessages.FeatureImportWizard_operation_multiProblem, null); for (int i = 0; i < fModels.length; i++) { try { createProject(fModels[i], new SubProgressMonitor(monitor, 1)); } catch (CoreException e) { multiStatus.merge(e.getStatus()); } if (monitor.isCanceled()) { throw new OperationCanceledException(); } } if (!multiStatus.isOK()) { throw new CoreException(multiStatus); } } finally { monitor.done(); } }
/** * Set task name. * * @see IProgressMonitor#setTaskName(String) * @since 2.0 */ public void setTaskName(String name) { this.taskString = name; this.subTaskString = ""; // $NON-NLS-1$ this.showDetails = false; this.totalCopyCount = 0; monitor.subTask(""); // $NON-NLS-1$ monitor.setTaskName(name); }
private void initialize(final IRefreshSubscriberListener listener) { final GotoActionWrapper actionWrapper = new GotoActionWrapper(); IProgressMonitor group = Job.getJobManager().createProgressGroup(); group.beginTask(taskName, 100); setProgressGroup(group, 80); handleProgressGroupSet(group, 20); setProperty(IProgressConstants.ICON_PROPERTY, participant.getImageDescriptor()); setProperty(IProgressConstants.ACTION_PROPERTY, actionWrapper); setProperty(IProgressConstants.KEEPONE_PROPERTY, Boolean.valueOf(!isJobModal())); // Listener delegate IRefreshSubscriberListener autoListener = new IRefreshSubscriberListener() { @Override public void refreshStarted(IRefreshEvent event) { if (listener != null) { listener.refreshStarted(event); } } @Override public ActionFactory.IWorkbenchAction refreshDone(IRefreshEvent event) { if (listener != null) { boolean isModal = isJobModal(); event.setIsLink(!isModal); final ActionFactory.IWorkbenchAction runnable = listener.refreshDone(event); if (runnable != null) { // If the job is being run modally then simply prompt the user immediately if (isModal) { if (runnable != null) { Job update = new UIJob("") { // $NON-NLS-1$ @Override public IStatus runInUIThread(IProgressMonitor monitor) { runnable.run(); return Status.OK_STATUS; } }; update.setSystem(true); update.schedule(); } } else { // If the job is being run in the background, don't interrupt the user and simply // update the goto action // to perform the results. actionWrapper.setGotoAction(runnable); } } RefreshParticipantJob.removeRefreshListener(this); } return null; } }; if (listener != null) { RefreshParticipantJob.addRefreshListener(autoListener); } }
@Override protected IStatus run(IProgressMonitor monitor) { MultiStatus result = new MultiStatus( ResourcesPlugin.PI_RESOURCES, IResourceStatus.FAILED_SETTING_CHARSET, Messages.resources_updatingEncoding, null); monitor = Policy.monitorFor(monitor); try { monitor.beginTask(Messages.resources_charsetUpdating, Policy.totalWork); final ISchedulingRule rule = workspace.getRuleFactory().modifyRule(workspace.getRoot()); try { workspace.prepareOperation(rule, monitor); workspace.beginOperation(true); Map.Entry<IProject, Boolean> next; while ((next = getNextChange()) != null) { // just exit if the system is shutting down or has been shut down // it is too late to change the workspace at this point anyway if (systemBundle.getState() != Bundle.ACTIVE) return Status.OK_STATUS; IProject project = next.getKey(); try { if (project.isAccessible()) { boolean shouldDisableCharsetDeltaJob = next.getValue().booleanValue(); // flush preferences for non-derived resources flushPreferences( getPreferences(project, false, false, true), shouldDisableCharsetDeltaJob); // flush preferences for derived resources flushPreferences( getPreferences(project, false, true, true), shouldDisableCharsetDeltaJob); } } catch (BackingStoreException e) { // we got an error saving String detailMessage = Messages.resources_savingEncoding; result.add( new ResourceStatus( IResourceStatus.FAILED_SETTING_CHARSET, project.getFullPath(), detailMessage, e)); } } monitor.worked(Policy.opWork); } catch (OperationCanceledException e) { workspace.getWorkManager().operationCanceled(); throw e; } finally { workspace.endOperation(rule, true, Policy.subMonitorFor(monitor, Policy.endOpWork)); } } catch (CoreException ce) { return ce.getStatus(); } finally { monitor.done(); } return result; }
public void execute(IProgressMonitor monitor) { IPluginModelBase[] plugins = PluginJavaSearchUtil.getPluginImports(fImportID); monitor.beginTask( PDEUIMessages.DependencyExtentOperation_searching + " " + fImportID + "...", 10); //$NON-NLS-1$//$NON-NLS-2$ checkForJavaDependencies(plugins, new SubProgressMonitor(monitor, 9)); for (int i = 0; i < plugins.length; i++) { checkForExtensionPointsUsed(plugins[i]); } monitor.done(); }
/** * Adds the move changes to the root change This change is the proper move change, nothing else * * @param pm - progress monitor * @param rootChange - the root change that the new changes are added to * @return the root change after the additions */ private Change createSimpleMoveChange(final IProgressMonitor pm, final CompositeChange rootChange) throws CoreException, OperationCanceledException { try { pm.beginTask(PhpRefactoringCoreMessages.getString("MoveDelegate.0"), 100); // $NON-NLS-1$ IResource[] sourceResources = fProcessor.getSourceSelection(); createMoveChange(sourceResources, rootChange); pm.worked(100); } finally { pm.done(); } return rootChange; }
public ICVSRemoteResource[] getFoldersForTag( ICVSRepositoryLocation location, CVSTag tag, IProgressMonitor monitor) throws CVSException { monitor = Policy.monitorFor(monitor); try { monitor.beginTask( NLS.bind( CVSUIMessages.RepositoryManager_fetchingRemoteFolders, new String[] {tag.getName()}), 100); if (tag.getType() == CVSTag.HEAD) { ICVSRemoteResource[] resources = location.members(tag, false, Policy.subMonitorFor(monitor, 60)); RepositoryRoot root = getRepositoryRootFor(location); ICVSRemoteResource[] modules = root.getDefinedModules(tag, Policy.subMonitorFor(monitor, 40)); ICVSRemoteResource[] result = new ICVSRemoteResource[resources.length + modules.length]; System.arraycopy(resources, 0, result, 0, resources.length); System.arraycopy(modules, 0, result, resources.length, modules.length); return result; } if (tag.getType() == CVSTag.DATE) { ICVSRemoteResource[] resources = location.members(tag, false, Policy.subMonitorFor(monitor, 60)); RepositoryRoot root = getRepositoryRootFor(location); ICVSRemoteResource[] modules = root.getDefinedModules(tag, Policy.subMonitorFor(monitor, 40)); ICVSRemoteResource[] result = new ICVSRemoteResource[resources.length + modules.length]; System.arraycopy(resources, 0, result, 0, resources.length); System.arraycopy(modules, 0, result, resources.length, modules.length); return result; } Set result = new HashSet(); // Get the tags for the location RepositoryRoot root = getRepositoryRootFor(location); String[] paths = root.getKnownRemotePaths(); for (int i = 0; i < paths.length; i++) { String path = paths[i]; List tags = Arrays.asList(root.getAllKnownTags(path)); if (tags.contains(tag)) { ICVSRemoteFolder remote = root.getRemoteFolder(path, tag, Policy.subMonitorFor(monitor, 100)); result.add(remote); } } return (ICVSRemoteResource[]) result.toArray(new ICVSRemoteResource[result.size()]); } finally { monitor.done(); } }
/* (non-Javadoc) * @see org.eclipse.core.internal.jobs.InternalJob#run(org.eclipse.core.runtime.IProgressMonitor) */ protected IStatus run(IProgressMonitor monitor) { TreeNode root = new TreeNode(""); File it = new File(proj.getLocation().addTrailingSeparator() + "goblin.xml"); if (!it.canRead()) return new Status(IStatus.ERROR, "ee.ut.goblin", 97, "Can't read analysis file.", null); DefaultHandler handler = new XMLHandler(root); SAXParserFactory factory = SAXParserFactory.newInstance(); try { // Parse the input SAXParser saxParser = factory.newSAXParser(); saxParser.parse(it, handler); } catch (Throwable t) { return new Status(IStatus.ERROR, "ee.ut.goblin", 96, t.getMessage(), t); } TreeAnalysisMap tam = new TreeAnalysisMap((TreeAnalysis) root.getChildren()[0]); try { proj.setSessionProperty(GoblinPlugin.RESULT_NAME, tam); } catch (CoreException e) { return new Status(IStatus.ERROR, "ee.ut.goblin", 95, e.getMessage(), e); } monitor.done(); return Status.OK_STATUS; }
/** * Initializes DLTKCore internal structures to allow subsequent operations (such as the ones that * need a resolved classpath) to run full speed. A client may choose to call this method in a * background thread early after the workspace has started so that the initialization is * transparent to the user. * * <p>However calling this method is optional. Services will lazily perform initialization when * invoked. This is only a way to reduce initialization overhead on user actions, if it can be * performed before at some appropriate moment. * * <p>This initialization runs accross all Java projects in the workspace. Thus the workspace root * scheduling rule is used during this operation. * * <p>This method may return before the initialization is complete. The initialization will then * continue in a background thread. * * <p>This method can be called concurrently. * * @param monitor a progress monitor, or <code>null</code> if progress reporting and cancellation * are not desired * @exception CoreException if the initialization fails, the status of the exception indicates the * reason of the failure * @since 3.1 */ public static void initializeAfterLoad(IProgressMonitor monitor) throws CoreException { try { if (monitor != null) { monitor.beginTask(CoreMessages.PHPCorePlugin_initializingPHPToolkit, 125); } // dummy query for waiting until the indexes are ready IDLTKSearchScope scope = SearchEngine.createWorkspaceScope(PHPLanguageToolkit.getDefault()); try { LanguageModelInitializer.cleanup(monitor); if (monitor != null) { monitor.subTask(CoreMessages.PHPCorePlugin_initializingSearchEngine); monitor.worked(25); } PhpModelAccess.getDefault() .findMethods(ID, MatchRule.PREFIX, Modifiers.AccGlobal, 0, scope, monitor); if (monitor != null) { monitor.worked(25); } PhpModelAccess.getDefault() .findTypes(ID, MatchRule.PREFIX, Modifiers.AccGlobal, 0, scope, monitor); if (monitor != null) { monitor.worked(25); } PhpModelAccess.getDefault() .findFields(ID, MatchRule.PREFIX, Modifiers.AccGlobal, 0, scope, monitor); if (monitor != null) { monitor.worked(25); } PhpModelAccess.getDefault().findIncludes(ID, MatchRule.PREFIX, scope, monitor); if (monitor != null) { monitor.worked(25); } } catch (OperationCanceledException e) { if (monitor != null && monitor.isCanceled()) { throw e; } // else indexes were not ready: catch the exception so that jars // are still refreshed } } finally { if (monitor != null) { monitor.done(); } toolkitInitialized = true; } }
/** * Implements the interface method by looping through template sections and executing them * sequentially. * * @param project the project * @param model the plug-in model * @param monitor the progress monitor to track the execution progress as part of the overall new * project creation operation * @return <code>true</code> if the wizard completed the operation with success, <code>false * </code> otherwise. */ public boolean performFinish(IProject project, IPluginModelBase model, IProgressMonitor monitor) { try { ITemplateSection[] sections = getTemplateSections(); monitor.beginTask("", sections.length); // $NON-NLS-1$ for (int i = 0; i < sections.length; i++) { sections[i].execute(project, model, new SubProgressMonitor(monitor, 1)); } // No reason to do this any more with the new editors // saveTemplateFile(project, null); } catch (CoreException e) { PDEPlugin.logException(e); return false; } finally { monitor.done(); } return true; }
protected void infoCompleted() throws IOException { if (monitor != null) { monitor.progressCompleted(); } infoPrintTraceStatus(); infoPreCompleted(); }
protected void infoProcessingTrace(String className, String traceName, Integer testCount) throws IOException { if (monitor != null) { monitor.progressStartTrace(className + "`" + traceName); currentPct = 0; } preProcessingTrace(className, traceName, testCount); }
public String getPercentComplete() { double p = ((double) m_bytes / m_bytesTotal) * 100.0f; m_monitor.worked((int) ((p - m_percent) * 100)); m_percent = p; DecimalFormat df = new DecimalFormat("0.##"); return PaddedString.rpad((df.format(m_percent) + " % Complete"), 25); }
/** * Fuehrt einen Restart am Server durch. * * @param monitor * @param selection * @param more * @return true wenn abbruch * @throws ConnectionException */ private boolean restart( final IProgressMonitor monitor, final IRestartSelection selection, final boolean more) throws ConnectionException { monitor.subTask("Invoking restart"); fConnection .getProtocolWriter() .writeInvokeRestart(selection.getRestart(), selection.getParameter()); readAllOutput(monitor); monitor.subTask("Reading restart result"); IResult result = fConnection.getEvaluation().evalResult(); IRestartSelection restartSelection = callFormEvaluated(result, more); if (restartSelection == null) { return false; } else if (restartSelection.isAborted()) { return true; } else { // rekursiver restart return restart(monitor, restartSelection, more); } }
@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); }
public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor) { SubMonitor subMonitor = SubMonitor.convert(monitor, requests.length); try { MultiStatus overallStatus = new MultiStatus(TestActivator.PI_PROV_TESTS, IStatus.OK, null, null); for (int i = 0; i < requests.length; i++) { overallStatus.add(getArtifact((ArtifactRequest) requests[i], subMonitor.newChild(1))); } return (monitor.isCanceled() ? Status.CANCEL_STATUS : overallStatus); } finally { subMonitor.done(); } }
/** * 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); }
protected void infoProcessingTest( String className, String traceName, Integer testNumber, Integer total) throws IOException { if (monitor != null) { Integer pct = new Double((double) testNumber / (double) total * 100).intValue(); if (currentPct + 10 <= pct) { monitor.progress(pct); currentPct = pct; } } if (DEBUG) { System.out.println(testNumber); } }
/** * Performs the reconcile and returns the AST if it was computed. * * @param unit the compilation unit * @param initialReconcile <code>true</code> if this is the initial reconcile * @return the AST or <code>null</code> if none * @throws JavaModelException if the original Java element does not exist * @since 3.4 */ private Program reconcile(ISourceModule unit, boolean initialReconcile) throws ModelException { /* fix for missing cancel flag communication */ IProblemRequestorExtension extension = getProblemRequestorExtension(); if (extension != null) { extension.setProgressMonitor(fProgressMonitor); extension.setIsActive(true); } try { final ASTProvider astProvider = PHPUiPlugin.getDefault().getASTProvider(); synchronized (unit) { unit.reconcile(true, null, fProgressMonitor); } // read DOM AST from provider if avaiable Program createdAST = astProvider.getAST(unit, SharedASTProvider.WAIT_NO, fProgressMonitor); if (astProvider.isActive(unit) && createdAST != null) { return createdAST; } if (initialReconcile || astProvider.isActive(unit)) { PHPVersion phpVersion = ProjectOptions.getPhpVersion(unit.getScriptProject().getProject()); ASTParser newParser = ASTParser.newParser(phpVersion, unit); createdAST = newParser.createAST(null); if (createdAST != null && document != null) { createdAST.setSourceModule(unit); createdAST.setSourceRange(0, document.getLength()); createdAST.setLineEndTable(Util.lineEndTable(document)); } return createdAST; } } catch (OperationCanceledException ex) { Assert.isTrue(fProgressMonitor == null || fProgressMonitor.isCanceled()); } catch (Exception e) { throw new ModelException(e, IStatus.ERROR); } finally { /* fix for missing cancel flag communication */ if (extension != null) { extension.setProgressMonitor(null); extension.setIsActive(false); } } return null; }
/** * Sets the number of bytes already copied. * * @see #showCopyDetails(boolean) * @see #setTotalCount(long) * @param count number of bytes already copied. * @since 2.0 */ public void setCopyCount(long count) { if (showDetails && count > 0) { currentCount = count; long countK = count / 1024; long totalK = totalCopyCount / 1024; String msg = (totalK <= 0) ? NLS.bind( Messages.InstallMonitor_DownloadSize, (new String[] {Long.toString(countK)})) : NLS.bind( Messages.InstallMonitor_DownloadSizeLong, (new String[] {Long.toString(countK), Long.toString(totalK)})); monitor.subTask(subTaskString + msg); } }
public void validateContent(IProgressMonitor monitor) { Element element = getDocumentRoot(); if (element == null) return; String elementName = element.getNodeName(); if (!"plugin".equals(elementName) && !"fragment".equals(elementName)) { // $NON-NLS-1$ //$NON-NLS-2$ reportIllegalElement(element, CompilerFlags.ERROR); } else { int severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_DEPRECATED); if (severity != CompilerFlags.IGNORE) { NamedNodeMap attrs = element.getAttributes(); for (int i = 0; i < attrs.getLength(); i++) { reportUnusedAttribute(element, attrs.item(i).getNodeName(), severity); } } NodeList children = element.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { if (monitor.isCanceled()) break; Element child = (Element) children.item(i); String name = child.getNodeName(); if (name.equals("extension")) { // $NON-NLS-1$ validateExtension(child); } else if (name.equals("extension-point")) { // $NON-NLS-1$ validateExtensionPoint(child); } else { if (!name.equals("runtime") && !name.equals("requires")) { // $NON-NLS-1$ //$NON-NLS-2$ severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_ELEMENT); if (severity != CompilerFlags.IGNORE) reportIllegalElement(child, severity); } else { severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_DEPRECATED); if (severity != CompilerFlags.IGNORE) reportUnusedElement(child, severity); } } } IExtensions extensions = fModel.getExtensions(); if (extensions != null && extensions.getExtensions().length == 0 && extensions.getExtensionPoints().length == 0) report( MDECoreMessages.Builders_Manifest_useless_file, -1, IMarker.SEVERITY_WARNING, MDEMarkerFactory.P_USELESS_FILE, MDEMarkerFactory.CAT_OTHER); } }
/** * Ausfuehrung der Evaluierung. Jeder Ausdruck wird ueber die Verbindung ausgewertet und das * Ergebnis der Evaluierung wird dem {@link IBackgroundEvaluationListener} mitgeteilt. * * @param monitor - der ProgressMonitor * @see IBackgroundEvaluationListener * @sse {@link AbstractJob#run0(IProgressMonitor)} */ @Override @SuppressWarnings("NP") // Rueckgabe von non-null Wert wird über Methoden-Contract geregelt protected IStatus run0(final IProgressMonitor monitor) throws Exception { monitor.subTask("Waiting for connection"); acquireLock(); ensureConnected(fConnection); callPrepare(fForms.size() > 1); monitor.beginTask(fJobName, (fForms.size() + 1) * 1000); if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } for (int i = 0, n = fForms.size(); i < n; i++) { PackageBoundForm form = fForms.get(i); monitor.subTask("Starting evaluation " + i + "/" + fForms.size()); IEvaluation eval = fConnection.getEvaluation(); eval.evalStart(form.getPackage(), form.getForm()); // Output Lesen readAllOutput(monitor); monitor.subTask("Reading result"); IResult evalResult = eval.evalResult(); boolean more = i != n - 1; IRestartSelection selection = callFormEvaluated(evalResult, more); monitor.worked(1000); if (evalResult.getTyp() == TResult.SUCCESS) { // Ergebnis ok continue; // alles ok mit ergebnis, mit naechstem weitermachen wenn vorhanden } else if (evalResult.getTyp() == TResult.READ_ERROR) { // Read error, es darf kein abort gesendet werden break; } else if (selection != null && selection.isAborted()) { abort(); // Ein Fehler, kann nur EVAL_ERROR sein, wurde abgebrochen break; } else { // EVAL_ERROR und es wurde ein Restart gewaehlt, bzw. war verfuegbar boolean abort = restart(monitor, selection, more); // eintritt rekursiver restart if (abort) { // restart abgebrochen abort(); // abort senden break; // und (bulk-)eval komplette beenden } continue; // restart war erfolgreich -> weiter mit naechstem im bulk } } return new Status(IStatus.OK, LispPluginActivator.ID, IStatus.OK, "Evaluation succeeded", null); }
public void update(long bytes, long bytesTotal) { if (m_monitor.isCanceled()) { cancelTransfer(); } else { setTransferSpeed(bytes, bytesTotal); setSubTask( TASK_TRANSFER, new String[] { getNumberFiles(), getTransferSize(), getPercentComplete(), getTransferSpeed(), getTimeLeft() }); } }