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(); } }
public IStatus buildLang(IFile langFile, IProgressMonitor monitor) throws CoreException { final IProgressMonitor sub = new SubProgressMonitor(monitor, 100); sub.beginTask(Msgs.buildingLanguages, 100); final IMavenProjectFacade facade = MavenUtil.getProjectFacade(getProject(), sub); sub.worked(10); final ICallable<IStatus> callable = new ICallable<IStatus>() { public IStatus call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException { return MavenUtil.executeMojoGoal( facade, context, ILiferayMavenConstants.PLUGIN_GOAL_BUILD_LANG, monitor); } }; final IStatus retval = executeMaven(facade, callable, sub); sub.worked(80); getProject().refreshLocal(IResource.DEPTH_INFINITE, sub); sub.worked(10); sub.done(); return retval; }
public IStatus buildSB( final IFile serviceXmlFile, final String goal, final IProgressMonitor monitor) throws CoreException { final IMavenProjectFacade facade = MavenUtil.getProjectFacade(getProject(), monitor); monitor.worked(10); final ICallable<IStatus> callable = new ICallable<IStatus>() { public IStatus call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException { return MavenUtil.executeMojoGoal(facade, context, goal, monitor); } }; final IStatus retval = executeMaven(facade, callable, monitor); monitor.worked(70); refreshSiblingProject(facade, monitor); monitor.worked(10); getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor); monitor.worked(10); monitor.done(); return retval; }
/** * Reports progress by creating a balanced binary tree of progress monitors. Simulates mixed usage * of IProgressMonitor in a typical usage. Calls isCanceled once each time work is reported. Half * of the work is reported using internalWorked and half is reported using worked, to simulate * mixed usage of the progress monitor. * * @deprecated to suppress deprecation warnings * @param monitor progress monitor (callers are responsible for calling done() if necessary) * @param loopSize total size of the recursion tree */ public static void reportWorkInBalancedTree(IProgressMonitor monitor, int loopSize) { monitor.beginTask("", 100); int leftBranch = loopSize / 2; int rightBranch = loopSize - leftBranch; if (leftBranch > 1) { SubProgressMonitor leftProgress = new SubProgressMonitor(monitor, 50); reportWorkInBalancedTree(leftProgress, leftBranch); leftProgress.done(); } else { monitor.worked(25); monitor.internalWorked(25.0); monitor.isCanceled(); } if (rightBranch > 1) { SubProgressMonitor rightProgress = new SubProgressMonitor(monitor, 50); reportWorkInBalancedTree(rightProgress, rightBranch); rightProgress.done(); } else { monitor.worked(25); monitor.internalWorked(25.0); monitor.isCanceled(); } }
@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 RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException { try { pm.beginTask("", 7); // $NON-NLS-1$ RefactoringStatus result = Checks.validateEdit(fCu, getValidationContext()); if (result.hasFatalError()) return result; pm.worked(1); if (fCuRewrite == null) { JavaScriptUnit cuNode = RefactoringASTParser.parseWithASTProvider(fCu, true, new SubProgressMonitor(pm, 3)); fCuRewrite = new CompilationUnitRewrite(fCu, cuNode); } else { pm.worked(3); } result.merge(checkSelection(new SubProgressMonitor(pm, 3))); if (result.hasFatalError()) return result; if (isLiteralNodeSelected()) fReplaceAllOccurrences = false; return result; } finally { pm.done(); } }
public boolean visit(IResourceDelta delta) throws CoreException { IResource resource = delta.getResource(); if (!(resource instanceof IFile) || !resource.getName().endsWith(".java") || !resource.exists()) { return true; } monitor.subTask(resource.getName()); switch (delta.getKind()) { case IResourceDelta.ADDED: check(resource, architecture, true); monitor.worked(1); break; case IResourceDelta.REMOVED: delete(resource); monitor.worked(1); break; case IResourceDelta.CHANGED: check(resource, architecture, true); monitor.worked(1); break; } /* return true to continue visiting children */ return true; }
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 void doShakeKons(IProgressMonitor monitor, int workUnits) { try { monitor.subTask("Anonymisiere Konsultationen"); Query<Konsultation> qbe = new Query<Konsultation>(Konsultation.class); List<Konsultation> list = qbe.execute(); int workPerKons = (Math.round(workUnits * .8f) / list.size()); Lipsum lipsum = new Lipsum(); monitor.worked(Math.round(workUnits * .2f)); for (Konsultation k : list) { VersionedResource vr = k.getEintrag(); StringBuilder par = new StringBuilder(); int numPars = (int) Math.round(3 * Math.random() + 1); while (numPars-- > 0) { par.append(lipsum.getParagraph()); } vr.update(par.toString(), "random contents"); k.setEintrag(vr, true); k.purgeEintrag(); if (monitor.isCanceled()) { break; } monitor.worked(workPerKons); } } catch (Throwable e) { SWTHelper.showError("Fehler", e.getMessage()); } }
/** * 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; }
/** * Deletes a set of files from the file system, and also their parent folders if those become * empty during this process. * * @param nameSet set of file paths * @param monitor progress monitor * @throws CoreException if an error occurs */ private void deleteFiles(final Set<IPath> nameSet, IProgressMonitor monitor) throws CoreException { if (nameSet == null || nameSet.isEmpty()) { return; } Set<IContainer> subFolders = new HashSet<IContainer>(); for (IPath filePath : nameSet) { // Generate new path IFile currentFile = project.getFile(filePath); if (currentFile.exists()) { // Retrieve parent folder and store for deletion IContainer folder = currentFile.getParent(); subFolders.add(folder); currentFile.delete(true, monitor); } monitor.worked(1); } // Delete parent folders, if they are empty for (IContainer folder : subFolders) { if (folder.exists() && folder.members().length == 0) { folder.delete(true, monitor); } monitor.worked(1); } }
/** * @param process process from where the output should be gotten * @param executionString string to execute (only for errors) * @param monitor monitor for giving progress * @return a tuple with the output of stdout and stderr */ public static Tuple<String, String> getProcessOutput( Process process, String executionString, IProgressMonitor monitor, String encoding) { if (monitor == null) { monitor = new NullProgressMonitor(); } if (process != null) { try { process.getOutputStream().close(); // we won't write to it... } catch (IOException e2) { } monitor.setTaskName("Reading output..."); monitor.worked(5); // No need to synchronize as we'll waitFor() the process before getting the contents. ThreadStreamReader std = new ThreadStreamReader(process.getInputStream(), false, encoding); ThreadStreamReader err = new ThreadStreamReader(process.getErrorStream(), false, encoding); std.start(); err.start(); boolean interrupted = true; while (interrupted) { interrupted = false; try { monitor.setTaskName("Waiting for process to finish."); monitor.worked(5); process.waitFor(); // wait until the process completion. } catch (InterruptedException e1) { interrupted = true; } } try { // just to see if we get something after the process finishes (and let the other threads // run). Object sync = new Object(); synchronized (sync) { sync.wait(50); } } catch (Exception e) { // ignore } return new Tuple<String, String>(std.getContents(), err.getContents()); } else { try { throw new CoreException( PydevPlugin.makeStatus( IStatus.ERROR, "Error creating process - got null process(" + executionString + ")", new Exception("Error creating process - got null process."))); } catch (CoreException e) { Log.log(IStatus.ERROR, e.getMessage(), e); } } return new Tuple<String, String>( "", "Error creating process - got null process(" + executionString + ")"); // no output }
/* (non-Javadoc) * @see org.eclipse.sequoyah.tfm.sign.core.extension.security.ISecurityManagement#openKeyStore(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor) */ public String[] openKeyStore(IPath keyStore, String storePass, IProgressMonitor monitor) throws SignException { monitor.beginTask(Messages.SunSecurityManagement_Opening_key_store, 100); monitor.worked(10); initializeKeytool(); String[] cmdArgs = keytool.generateOpenKeyStoreCmd(ksType, keyStore, storePass, getConsoleEncoding()); Process p = keytool.execute(cmdArgs); BufferedReader cmdOutputStream = new BufferedReader(new InputStreamReader(p.getInputStream())); String cmdOutput; List<String> aliases = new ArrayList<String>(); try { while ((cmdOutput = cmdOutputStream.readLine()) != null) { monitor.subTask(cmdOutput); monitor.worked(25); if (cmdOutput.toLowerCase().indexOf("error") >= 0) { // $NON-NLS-1$ monitor.done(); if (cmdOutput.toLowerCase().indexOf("invalid keystore format") >= 0) { // $NON-NLS-1$ throw new SignException( NLS.bind( Messages.SunSecurityManagement_defaultErrorMessage, new String[] { SignErrors.getErrorMessage(SignErrors.SECURITY_BAD_KEY_TYPE), cmdOutput })); } else if (cmdOutput.toLowerCase().indexOf("password was incorrect") >= 0) { //$NON-NLS-1$ throw new SignException( NLS.bind( Messages.SunSecurityManagement_defaultErrorMessage, new String[] { SignErrors.getErrorMessage(SignErrors.SECURITY_BAD_KEYSTORE_OR_PASSWORD), cmdOutput })); } else { throw new SignException( NLS.bind( Messages.SunSecurityManagement_defaultErrorMessage, new String[] { SignErrors.getErrorMessage(SignErrors.GENERIC_SECURITY_ERROR), cmdOutput })); } } else if (cmdOutput.indexOf(",") >= 0) { // $NON-NLS-1$ StringTokenizer strtok = new StringTokenizer(cmdOutput, ".,"); // $NON-NLS-1$ aliases.add(strtok.nextToken()); } } } catch (IOException ee) { throw new SignException(SignErrors.getErrorMessage(SignErrors.GENERIC_SECURITY_ERROR), ee); } return aliases.toArray(new String[aliases.size()]); }
/* (non-Javadoc) * @see org.eclipse.egit.core.op.IEGitOperation#execute(org.eclipse.core.runtime.IProgressMonitor) */ public void execute(IProgressMonitor m) throws CoreException { if (m == null) { m = new NullProgressMonitor(); } m.beginTask(CoreText.ConnectProviderOperation_connecting, 100 * projects.size()); try { for (Iterator iterator = projects.keySet().iterator(); iterator.hasNext(); ) { IProject project = (IProject) iterator.next(); m.setTaskName( NLS.bind(CoreText.ConnectProviderOperation_ConnectingProject, project.getName())); // TODO is this the right location? if (GitTraceLocation.CORE.isActive()) GitTraceLocation.getTrace() .trace( GitTraceLocation.CORE.getLocation(), "Locating repository for " + project); // $NON-NLS-1$ Collection<RepositoryMapping> repos = new RepositoryFinder(project).find(new SubProgressMonitor(m, 40)); File suggestedRepo = projects.get(project); RepositoryMapping actualMapping = findActualRepository(repos, suggestedRepo); if (actualMapping != null) { GitProjectData projectData = new GitProjectData(project); try { projectData.setRepositoryMappings(Arrays.asList(actualMapping)); projectData.store(); } catch (CoreException ce) { GitProjectData.delete(project); throw ce; } catch (RuntimeException ce) { GitProjectData.delete(project); throw ce; } RepositoryProvider.map(project, GitProvider.class.getName()); projectData = GitProjectData.get(project); project.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(m, 50)); m.worked(10); } else { // TODO is this the right location? if (GitTraceLocation.CORE.isActive()) GitTraceLocation.getTrace() .trace( GitTraceLocation.CORE.getLocation(), "Attempted to share project without repository ignored :" //$NON-NLS-1$ + project); m.worked(60); } } } finally { m.done(); } }
/** * 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; } }
private void recursiveDeleteTree(IPath path, IProgressMonitor monitor, MultiStatus status) throws IOException, ParseException { try { changeCurrentDir(path); FTPFile[] ftpFiles = listFiles(path, monitor); List<String> dirs = new ArrayList<String>(); for (FTPFile ftpFile : ftpFiles) { String name = ftpFile.getName(); if (".".equals(name) || "..".equals(name)) { // $NON-NLS-1$ //$NON-NLS-2$ continue; } if (ftpFile.isDir()) { dirs.add(name); continue; } Policy.checkCanceled(monitor); monitor.subTask(path.append(name).toPortableString()); try { ftpClient.delete(name); } catch (FTPException e) { status.add( new Status( IStatus.ERROR, FTPPlugin.PLUGIN_ID, StringUtils.format( Messages.FTPConnectionFileManager_deleting_failed, path.append(name).toPortableString()), e)); } monitor.worked(1); } for (String name : dirs) { monitor.subTask(path.append(name).toPortableString()); recursiveDeleteTree(path.append(name), monitor, status); Policy.checkCanceled(monitor); changeCurrentDir(path); Policy.checkCanceled(monitor); ftpClient.rmdir(name); monitor.worked(1); } } catch (IOException e) { throw e; } catch (Exception e) { status.add( new Status( IStatus.ERROR, FTPPlugin.PLUGIN_ID, StringUtils.format( Messages.FTPConnectionFileManager_deleting_failed, path.toPortableString()), e)); } }
public void installSymfony(IProgressMonitor monitor) { if (monitor == null) monitor = new NullProgressMonitor(); SymfonyProjectWizardFirstPage firstPage = (SymfonyProjectWizardFirstPage) fFirstPage; monitor.beginTask("Installing symfony...", 100); monitor.worked(10); IProject projectHandle = fFirstPage.getProjectHandle(); final IScriptProject scriptProject = DLTKCore.create(projectHandle); File file = null; final List<IBuildpathEntry> entries = new ArrayList<IBuildpathEntry>(); level = 0; try { file = new File(firstPage.getLibraryPath()); symfonyPath = new Path(firstPage.getLibraryPath()).toString(); if (file.isDirectory()) { final File[] files = file.listFiles(); if (!scriptProject.isOpen()) { scriptProject.open(monitor); } if (files != null && scriptProject != null && scriptProject.isOpen()) { for (File f : files) { importFile(f, scriptProject.getProject(), entries); } BuildPathUtils.addEntriesToBuildPath(scriptProject, entries); monitor.worked(90); } } } catch (ModelException e) { e.printStackTrace(); Logger.logException(e); } catch (Exception e) { e.printStackTrace(); Logger.logException(e); } finally { monitor.worked(100); monitor.done(); } }
private void doShakeNames(IProgressMonitor monitor, int workUnits) { monitor.subTask("Anonymisiere Patienten und Kontakte"); Query<Kontakt> qbe = new Query<Kontakt>(Kontakt.class); List<Kontakt> list = qbe.execute(); int workPerName = (Math.round(workUnits * .8f) / list.size()); Namen n = null; if (zufallsnamen) { n = new Namen(); } monitor.worked(Math.round(workUnits * .2f)); for (Kontakt k : list) { String vorname = ""; // Mandanten behalten // if(k.get(Kontakt.FLD_IS_MANDATOR).equalsIgnoreCase(StringConstants.ONE)) // continue; if (zufallsnamen) { k.set("Bezeichnung1", n.getRandomNachname()); } else { k.set("Bezeichnung1", getWord()); } if (zufallsnamen) { vorname = n.getRandomVorname(); } else { vorname = getWord(); } k.set("Bezeichnung2", vorname); if (k.istPerson()) { Person p = Person.load(k.getId()); p.set(Person.SEX, StringTool.isFemale(vorname) ? Person.FEMALE : Person.MALE); } k.set(Kontakt.FLD_ANSCHRIFT, ""); k.set(Kontakt.FLD_PHONE1, getPhone()); k.set(Kontakt.FLD_PHONE2, Math.random() > 0.6 ? getPhone() : ""); k.set(Kontakt.FLD_MOBILEPHONE, Math.random() > 0.5 ? getPhone() : ""); k.set(Kontakt.FLD_E_MAIL, ""); k.set(Kontakt.FLD_PLACE, ""); k.set(Kontakt.FLD_STREET, ""); k.set(Kontakt.FLD_ZIP, ""); k.set(Kontakt.FLD_FAX, Math.random() > 0.8 ? getPhone() : ""); if (monitor.isCanceled()) { break; } monitor.worked(workPerName); } }
/** * Handles the conversion for a node. * * @param node the test case * @throws StopConversionException */ private void handleNode(INodePO node) throws StopConversionException { if (progressMonitor.isCanceled()) { throw new StopConversionException(true); } progressMonitor.worked(1); NodeInfo info = uuidToNodeInfoMap.get(node.getGuid()); File file = new File(info.getFqFileName()); if (node instanceof ICategoryPO) { file.mkdirs(); for (INodePO child : node.getUnmodifiableNodeList()) { handleNode(child); } } else { try { file.getParentFile().mkdirs(); file.createNewFile(); NodeGenerator gen = new NodeGenerator(); try { String content = gen.generate(info); writeContentToFile(file, content); } catch (MinorConversionException e) { Plugin.getDefault() .writeLineToConsole( NLS.bind(Messages.InvalidNode, new String[] {node.getName(), e.getMessage()}), true); file.delete(); } } catch (IOException e) { ErrorHandlingUtil.createMessageDialog( new JBException(e.getMessage(), e, MessageIDs.E_FILE_NO_PERMISSION)); throw new StopConversionException(); } } }
private void doUpdateHistoricalQuotes(IProgressMonitor monitor, List<IStatus> errors) { for (Security security : securities) { monitor.subTask(MessageFormat.format(Messages.JobMsgUpdatingQuotesFor, security.getName())); try { QuoteFeed feed = Factory.getQuoteFeedProvider(security.getFeed()); if (feed != null) { ArrayList<Exception> exceptions = new ArrayList<Exception>(); feed.updateHistoricalQuotes(security, exceptions); if (!exceptions.isEmpty()) addToErrors(security.getName(), exceptions, errors); } } catch (IOException e) { errors.add( new Status( IStatus.ERROR, PortfolioPlugin.PLUGIN_ID, security.getName() + ": " //$NON-NLS-1$ + e.getMessage(), e)); } monitor.worked(1); } }
protected IStatus run(IProgressMonitor monitor) { ArrayList<IFile> files = new ArrayList<IFile>(10); for (IResource resource : resources) { getFilesFromResouce(resource, files); } int count = files.size(); monitor.beginTask("Validating ...", count); int completed = 0; for (IFile file : files.toArray(new IFile[0])) { monitor.setTaskName( "Validating " + file.getProjectRelativePath().toString() + " (" + (completed + 1) + "/" + count + ")"); validateFile(file, monitor); monitor.worked(++completed); if (monitor.isCanceled()) return Status.CANCEL_STATUS; } return Status.OK_STATUS; }
@Override protected IStatus run(final IProgressMonitor monitor) { int work = messageFiles.length; double workRate = initWorkRate(work); initHeader(messageFiles); try { initBody(messageFiles); monitor.worked(getWorked(workRate, work - 1)); doWriting(); monitor.worked(getWorked(workRate, work)); return new Status(Status.OK, "OK", "OK"); } catch (Exception ex) { return new Status( Status.ERROR, "FAIL", "FAIL TO SAVE EXCEL, MAKE SURE THE EXCEL IS NOT OPEN"); } }
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(); }
/** * Launches the generation. * * @param monitor This will be used to display progress information to the user. * @throws IOException Thrown when the output cannot be saved. * @generated */ public void doGenerate(IProgressMonitor monitor) throws IOException { if (!targetFolder.getLocation().toFile().exists()) { targetFolder.getLocation().toFile().mkdirs(); } // final URI template0 = // getTemplateURI("org.eclipse.papyrus.robotml.generators.intempora.rtmaps", new // Path("/org/eclipse/robotml/generators/acceleo/rtmaps/main/generate_rtmaps.emtl")); // org.eclipse.papyrus.robotml.generators.intempora.rtmaps.main.Generate_rtmaps gen0 = new // org.eclipse.papyrus.robotml.generators.intempora.rtmaps.main.Generate_rtmaps(modelURI, // targetFolder.getLocation().toFile(), arguments) { // protected URI createTemplateURI(String entry) { // return template0; // } // }; // gen0.doGenerate(BasicMonitor.toMonitor(monitor)); monitor.subTask("Loading..."); Generate_rtmaps gen0 = new Generate_rtmaps(modelURI, targetFolder.getLocation().toFile(), arguments); monitor.worked(1); String generationID = org.eclipse.acceleo.engine.utils.AcceleoLaunchingUtil.computeUIProjectID( "org.eclipse.papyrus.robotml.generators.intempora.rtmaps", "org.eclipse.papyrus.robotml.generators.intempora.rtmaps.main.Generate_rtmaps", modelURI.toString(), targetFolder.getFullPath().toString(), new ArrayList<String>()); gen0.setGenerationID(generationID); gen0.doGenerate(BasicMonitor.toMonitor(monitor)); }
public void taskDone() { synchronized (monitor) { if (remainingOnCurrentTask > 0) monitor.worked(remainingOnCurrentTask); remainingOnCurrentTask = ticksPerTask; } if (subNamesIter.hasNext()) monitor.subTask(subNamesIter.next()); }
@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(); } }
/** @return a tuple with the process created and a string representation of the cmdarray. */ public Tuple<Process, String> run( String[] cmdarray, File workingDir, IPythonNature nature, IProgressMonitor monitor) { if (monitor == null) { monitor = new NullProgressMonitor(); } String executionString = getArgumentsAsStr(cmdarray); monitor.setTaskName("Executing: " + executionString); monitor.worked(5); Process process = null; try { monitor.setTaskName("Making pythonpath environment..." + executionString); String[] envp = null; if (nature != null) { envp = getEnvironment( nature, nature.getProjectInterpreter(), nature.getRelatedInterpreterManager()); // Don't remove as it *should* be updated // based on the nature) } // Otherwise, use default (used when configuring the interpreter for instance). monitor.setTaskName("Making exec..." + executionString); if (workingDir != null) { if (!workingDir.isDirectory()) { throw new RuntimeException( org.python.pydev.shared_core.string.StringUtils.format( "Working dir must be an existing directory (received: %s)", workingDir)); } } process = createProcess(cmdarray, envp, workingDir); } catch (Exception e) { throw new RuntimeException(e); } return new Tuple<Process, String>(process, executionString); }
public static IStatus assignPort( IShellProvider shellProvider, IProgressMonitor monitor, BTTargetPhone phone) { try { monitor.beginTask("Scanning BT device for OBEX service", 1); monitor.setTaskName("Scanning BT device for OBEX service"); int port = ServiceSearch.search(phone.getAddress()); if (port != -1) { phone.assignPort(port); } else { return new Status( IStatus.ERROR, TargetPhonePlugin.PLUGIN_ID, "The device connected to has no OBEX service"); } return Status.OK_STATUS; } catch (Exception e) { return new Status( IStatus.ERROR, TargetPhonePlugin.PLUGIN_ID, "The device connected to has no OBEX service", e); } finally { monitor.worked(1); } }
@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(); } }
/** * Launches the python process. * * <p>Modelled after Ant & Java runners see WorkbenchLaunchConfigurationDelegate::launch */ public void launch( ILaunchConfiguration conf, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { if (monitor == null) { monitor = new NullProgressMonitor(); } monitor.beginTask("Preparing configuration", 3); try { PythonRunnerConfig runConfig = new PythonRunnerConfig(conf, mode, getRunnerConfigRun(conf, mode, launch)); monitor.worked(1); try { PythonRunner.run(runConfig, launch, monitor); } catch (IOException e) { Log.log(e); finishLaunchWithError(launch); throw new CoreException( PydevDebugPlugin.makeStatus( IStatus.ERROR, "Unexpected IO Exception in Pydev debugger", null)); } } catch (final InvalidRunException e) { handleError(launch, e); } catch (final MisconfigurationException e) { handleError(launch, e); } }