Java Code Examples for org.eclipse.core.runtime.IProgressMonitor#subTask()
The following examples show how to use
org.eclipse.core.runtime.IProgressMonitor#subTask() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GitMergeUtil.java From MergeProcessor with Apache License 2.0 | 6 votes |
/** * Run the processor. * * @param pmd the monitor dialog * @param monitor the process monitor * @throws MergeUnitException * @throws SftpUtilException * @throws MergeCancelException */ private void run(final ProgressMonitorDialog pmd, final IProgressMonitor monitor) throws MergeUnitException, SftpUtilException, MergeCancelException { this.monitor = monitor; run(Messages.GitMergeUtil_createRepositoryDirectory, this::createLocalRepositoryIfNotExisting); run(Messages.GitMergeUtil_clone, this::cloneRepositoryIfNotExisting); run(Messages.GitMergeUtil_pull, this::pull); run(Messages.GitMergeUtil_evaluteCommitMessage, this::evaluteCommitMessage); run(Messages.GitMergeUtil_checkoutBranch, this::checkout); run(Messages.GitMergeUtil_checkStatus, this::checkStatus); run(Messages.GitMergeUtil_cherryPick, this::cherryPick); run(Messages.GitMergeUtil_commit, this::commit); // When pushed, no way of return pmd.setCancelable(false); run(Messages.GitMergeUtil_push, this::push); monitor.subTask(Messages.GitMergeUtil_moveMergeUnit); SftpUtil.getInstance().moveMergeUnitFromRemoteToDone(mergeUnit); monitor.worked(1); }
Example 2
Source File: Rechnungslauf.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
/** * only keeps the ones that match the selected account system * * @param monitor */ private void applyAccountSystemFilter(IProgressMonitor monitor){ if (accountSys != null) { log.debug("apply filter for accounting system: " + accountSys); monitor.subTask("Filtern nach Abrechnungssystem ..."); for (Konsultation k : kons) { if (accepted(k)) { Fall fall = k.getFall(); if (fall != null && fall.getAbrechnungsSystem().equals(accountSys)) { subResults.add(k); } } } updateKonsList(); } }
Example 3
Source File: SummaryDifferencer.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
protected void updateProgress(IProgressMonitor progressMonitor, Object node) { if (node instanceof ITypedElement) { ITypedElement element = (ITypedElement)node; progressMonitor.subTask(Policy.bind("CompareEditorInput.fileProgress", new String[] {element.getName()})); //$NON-NLS-1$ progressMonitor.worked(1); } }
Example 4
Source File: OutputFileManager.java From texlipse with Eclipse Public License 1.0 | 5 votes |
/** * Deletes the output file. * * @param monitor progress monitor * @throws CoreException if an error occurs */ public void cleanOutputFile(IProgressMonitor monitor) throws CoreException { monitor.subTask(TexlipsePlugin.getResourceString("builderSubTaskCleanOutput")); IFile outputFile = getSelectedOutputFile(); if (outputFile != null && outputFile.exists()) { outputFile.delete(true, monitor); } monitor.worked(1); }
Example 5
Source File: XMLInputFieldsImportProgressDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void setAttributeField( Attribute attribute, IProgressMonitor monitor ) { // Get Attribute Name String attributname = attribute.getName(); String attributnametxt = cleanString( attribute.getPath() ); if ( !Utils.isEmpty( attributnametxt ) && !list.contains( attribute.getPath() ) ) { nr++; monitor.subTask( BaseMessages.getString( PKG, "GetXMLDataXMLInputFieldsImportProgressDialog.Task.FetchFields", String.valueOf( nr ) ) ); monitor.subTask( BaseMessages.getString( PKG, "GetXMLDataXMLInputFieldsImportProgressDialog.Task.AddingField", attributname ) ); RowMetaAndData row = new RowMetaAndData(); row.addValue( VALUE_NAME, Value.VALUE_TYPE_STRING, attributname ); row.addValue( VALUE_PATH, Value.VALUE_TYPE_STRING, attributnametxt ); row.addValue( VALUE_ELEMENT, Value.VALUE_TYPE_STRING, GetXMLDataField.ElementTypeDesc[1] ); row.addValue( VALUE_RESULT, Value.VALUE_TYPE_STRING, GetXMLDataField.ResultTypeDesc[0] ); // Get attribute value String valueAttr = attribute.getText(); // Try to get the Type if ( IsDate( valueAttr ) ) { row.addValue( VALUE_TYPE, Value.VALUE_TYPE_STRING, "Date" ); row.addValue( VALUE_FORMAT, Value.VALUE_TYPE_STRING, "yyyy/MM/dd" ); } else if ( IsInteger( valueAttr ) ) { row.addValue( VALUE_TYPE, Value.VALUE_TYPE_STRING, "Integer" ); row.addValue( VALUE_FORMAT, Value.VALUE_TYPE_STRING, null ); } else if ( IsNumber( valueAttr ) ) { row.addValue( VALUE_TYPE, Value.VALUE_TYPE_STRING, "Number" ); row.addValue( VALUE_FORMAT, Value.VALUE_TYPE_STRING, null ); } else { row.addValue( VALUE_TYPE, Value.VALUE_TYPE_STRING, "String" ); row.addValue( VALUE_FORMAT, Value.VALUE_TYPE_STRING, null ); } list.add( attribute.getPath() ); } // end if }
Example 6
Source File: CodeTemplates.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@VisibleForTesting static void copyChildFile(String name, IContainer parent, IProgressMonitor monitor) throws CoreException { monitor.subTask("Copying file " + name); ResourceUtils.createFolders(parent, monitor); IFile child = parent.getFile(new Path(name)); if (!child.exists()) { Templates.copyFileContent(child.getLocation().toString(), name); child.refreshLocal(IResource.DEPTH_ZERO, monitor); } }
Example 7
Source File: UndeployProcessOperation.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void deleteProcessDefinition(final String processLabel, final ProcessAPI processApi, final long processDefinitionId, final IProgressMonitor monitor) throws DeletionException, URISyntaxException, IOException { monitor.subTask(Messages.bind(Messages.deletingProcessDefinition, processLabel)); CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); String apiToken = logToSession(monitor); try { deleteProcessDefinition(processApi, processDefinitionId,apiToken); } finally { logoutFromSession(apiToken); } }
Example 8
Source File: Xliff2Properties.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * Load segments. * @throws SAXException * the SAX exception * @throws IOException * Signals that an I/O exception has occurred. */ private void loadSegments(IProgressMonitor monitor) throws SAXException, IOException { try { monitor.beginTask(Messages.getString("javaproperties.Xliff2Properties.msg3"), IProgressMonitor.UNKNOWN); monitor.subTask(""); SAXBuilder builder = new SAXBuilder(); if (catalogue != null) { builder.setEntityResolver(catalogue); } Document doc = builder.build(xliffFile); Element root = doc.getRootElement(); Element body = root.getChild("file").getChild("body"); //$NON-NLS-1$ //$NON-NLS-2$ List<Element> units = body.getChildren("trans-unit"); //$NON-NLS-1$ Iterator<Element> i = units.iterator(); segments = new Hashtable<String, Element>(); while (i.hasNext()) { // 是否取消操作 if (monitor.isCanceled()) { throw new OperationCanceledException(Messages.getString("javaproperties.cancel")); } Element unit = i.next(); segments.put(unit.getAttributeValue("id"), unit); //$NON-NLS-1$ } } finally { monitor.done(); } }
Example 9
Source File: MSF4JProjectImporter.java From msf4j with Apache License 2.0 | 5 votes |
public void importMSF4JProject(MSF4JProjectModel msf4jProjectModel, String projectName, File pomFile, IProgressMonitor monitor) throws CoreException { String operationText; Set<MavenProjectInfo> projectSet = null; if (pomFile.exists()) { IProjectConfigurationManager configurationManager = MavenPlugin.getProjectConfigurationManager(); MavenModelManager mavenModelManager = MavenPlugin.getMavenModelManager(); LocalProjectScanner scanner = new LocalProjectScanner( ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile(), // projectName, false, mavenModelManager); operationText = "Scanning maven project."; monitor.subTask(operationText); try { scanner.run(new SubProgressMonitor(monitor, 15)); projectSet = configurationManager.collectProjects(scanner.getProjects()); for (MavenProjectInfo projectInfo : projectSet) { if (projectInfo != null) { saveMavenParentInfo(projectInfo); } } ProjectImportConfiguration configuration = new ProjectImportConfiguration(); operationText = "importing maven project."; monitor.subTask(operationText); if (projectSet != null && !projectSet.isEmpty()) { List<IMavenProjectImportResult> importResults = configurationManager.importProjects(projectSet, configuration, new SubProgressMonitor(monitor, 60)); } } catch (InterruptedException | IOException | XmlPullParserException e) { Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell(); MessageDialog errorDialog = new MessageDialog(shell, ERROR_TAG, null, "Unable to import the project, Error occurred while importing the generated project.", MessageDialog.ERROR, new String[] { OK_BUTTON }, 0); errorDialog.open(); } } else { } }
Example 10
Source File: AbstractSARLLaunchConfigurationDelegate.java From sarl with Apache License 2.0 | 5 votes |
/** Configure the "stop in main" feature. * * @param monitor the progress monitor. * @throws CoreException if a parameter cannot be extracted. */ @SuppressWarnings("synthetic-access") protected void configureStopInMain(IProgressMonitor monitor) throws CoreException { monitor.subTask( Messages.SARLLaunchConfigurationDelegate_5); prepareStopInMain(this.configuration); }
Example 11
Source File: Html2Xliff.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * Builds the tables. * @param iniFile * the ini file * @throws SAXException * the SAX exception * @throws IOException * Signals that an I/O exception has occurred. * @throws ParserConfigurationException * the parser configuration exception */ private void buildTables(String iniFile, IProgressMonitor monitor) throws SAXException, IOException, ParserConfigurationException { SAXBuilder builder = new SAXBuilder(); Catalogue cat = new Catalogue(catalogue); builder.setEntityResolver(cat); Document doc = builder.build(iniFile); Element root = doc.getRootElement(); List<Element> tags = root.getChildren("tag"); //$NON-NLS-1$ startsSegment = new Hashtable<String, String>(); translatableAttributes = new Hashtable<String, Vector<String>>(); entities = new Hashtable<String, String>(); ctypes = new Hashtable<String, String>(); keepFormating = new Hashtable<String, String>(); int size = tags.size(); monitor.beginTask(Messages.getString("html.Html2Xliff.task3"), size); monitor.subTask(""); Iterator<Element> i = tags.iterator(); while (i.hasNext()) { if (monitor.isCanceled()) { // 用户取消操作 throw new OperationCanceledException(Messages.getString("html.cancel")); } monitor.worked(1); Element t = i.next(); if (t.getAttributeValue("hard-break", "inline").equals("segment")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ startsSegment.put(t.getText(), "yes"); //$NON-NLS-1$ } if (t.getAttributeValue("keep-format", "no").equals("yes")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ keepFormating.put(t.getText(), "yes"); //$NON-NLS-1$ } String attributes = t.getAttributeValue("attributes", ""); //$NON-NLS-1$ //$NON-NLS-2$ if (!attributes.equals("")) { //$NON-NLS-1$ StringTokenizer tokenizer = new StringTokenizer(attributes, ";"); //$NON-NLS-1$ int count = tokenizer.countTokens(); Vector<String> v = new Vector<String>(count); for (int j = 0; j < count; j++) { v.add(tokenizer.nextToken()); } translatableAttributes.put(t.getText(), v); } String ctype = t.getAttributeValue("ctype", ""); //$NON-NLS-1$ //$NON-NLS-2$ if (!ctype.equals("")) { //$NON-NLS-1$ ctypes.put(t.getText(), ctype); } t = null; } tags = null; List<Element> ents = root.getChildren("entity"); //$NON-NLS-1$ Iterator<Element> it = ents.iterator(); while (it.hasNext()) { Element e = it.next(); entities.put("&" + e.getAttributeValue("name") + ";", e.getText()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } root = null; doc = null; builder = null; monitor.done(); }
Example 12
Source File: CheckKonsultationValidity.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
@Override public String executeMaintenance(IProgressMonitor pm, String DBVersion){ StringBuilder output = new StringBuilder(); pm.beginTask("Check validity of konsultationen", 2); pm.subTask("Checking case references ..."); Query<Konsultation> qbe = new Query<Konsultation>(Konsultation.class); List<Konsultation> kons = qbe.execute(); output.append("Konsultationen mit leerem oder ungültigem Fall:\n"); int counter = 0; for (Konsultation k : kons) { if (k.getFall() == null || !k.getFall().exists()) { output.append("Kons.ID: " + k.getLabel() + " (" + k.getId() + ") , Datum: " + k.getDatum() + "\n"); counter++; } } output = feedbackIfOK(output, counter); pm.worked(1); pm.subTask("Checking leistungs references ..."); Query<Verrechnet> qbe1 = new Query<Verrechnet>(Verrechnet.class); List<Verrechnet> verrechnet = qbe1.execute(); output.append("\nKonsultationen mit ungültigen Leistungen:\n"); counter = 0; for (Verrechnet v : verrechnet) { IVerrechenbar verrechenbar = v.getVerrechenbar(); try { // skip konsultationen with no leistungen if (verrechenbar != null) { verrechenbar.getMinutes(); } } catch (NullPointerException npe) { if (v.getKons() != null) { output.append("Kons.ID: " + v.getKons().getLabel() + " (" + v.getKons().getId() + "), Patient: " + v.getKons().getFall().getPatient().getLabel() + ", LeistungsCode: " + v.get(Verrechnet.LEISTG_CODE) + ", Klasse: " + v.get(Verrechnet.CLASS) + "\n"); counter++; } } } output = feedbackIfOK(output, counter); pm.worked(1); output.append("\nPrüfung abgeschlossen."); pm.done(); return output.toString(); }
Example 13
Source File: Rtf2Xliff.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * Parses the. * @param group * the group */ private void parse(String group, IProgressMonitor monitor) { System.out.println("Initializing rules"); //$NON-NLS-1$ initBreaks(); segments = new Vector<String>(); StringTokenizer tk = new StringTokenizer(group, "\\{}", true); //$NON-NLS-1$ System.out.println("Processing " + tk.countTokens() + " tokens"); //$NON-NLS-1$ //$NON-NLS-2$ String segment = ""; //$NON-NLS-1$ String token = ""; //$NON-NLS-1$ int tokenSize = tk.countTokens(); monitor.beginTask(Messages.getString("rtf.Rtf2Xliff.task10"), tokenSize); monitor.subTask(""); while (tk.hasMoreTokens()) { // 是否取消操作 if (monitor.isCanceled()) { throw new OperationCanceledException(Messages.getString("rtf.cancel")); } token = tk.nextToken(); if (token.equals("\\")) { //$NON-NLS-1$ token = token + tk.nextToken(); } if (token.equals("{")) { //$NON-NLS-1$ token = token + tk.nextToken(); } if (token.equals("}")) { //$NON-NLS-1$ skip = 0; } if (token.equals("{\\")) { //$NON-NLS-1$ token = token + tk.nextToken(); } if (token.equals("\\*") || token.equals("{\\*")) { //$NON-NLS-1$ //$NON-NLS-2$ token = token + tk.nextToken() + tk.nextToken(); } String ctrl = getControl(token); if (ctrl.equals("footnote")) { //$NON-NLS-1$ // skip until the end of the footnote // ignore any breaking token segment = segment + token.substring(0, token.indexOf("\\footnote")); //$NON-NLS-1$ token = token.substring(token.indexOf("\\footnote")); //$NON-NLS-1$ int level = 1; boolean canBreak = false; do { if (token.equals("{")) { //$NON-NLS-1$ level++; } if (token.equals("}")) { //$NON-NLS-1$ level--; } if (level == 0) { canBreak = true; } segment = segment + token; token = tk.nextToken(); } while (!canBreak); // == false); ctrl = getControl(token); } if (breaks.containsKey(ctrl)) { if (token.startsWith("{")) { //$NON-NLS-1$ segment = segment + token.substring(0, token.indexOf("\\")); //$NON-NLS-1$ token = token.substring(token.indexOf("\\")); //$NON-NLS-1$ } segments.add(segment); segment = ""; //$NON-NLS-1$ } segment = segment + token; monitor.worked(1); } monitor.done(); segments.add(segment); }
Example 14
Source File: PPTX2XLIFF.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** * 解析 ppt/slideMasters 目录下的 slideMasterN.xml 文件,查找 ph 中 type 不是 dt 和 sldNum 的节点,<br/> * 取出其 type, idx 属性值和坐标值,因为有的幻灯片中节点的坐标是存放在此文件中的 * @throws Exception */ private void parseSlideMaster(IProgressMonitor monitor) throws Exception { File slideMasterDic = new File(strTmpFolderPath + File.separator + "ppt" + File.separator + "slideMasters"); if (slideMasterDic.isDirectory()) { VTDGen vg = new VTDGen(); VTDUtils vu = new VTDUtils(); AutoPilot ap = new AutoPilot(); ap.declareXPathNameSpace(PREFIX_A, NAMESPACE_A); ap.declareXPathNameSpace(PREFIX_P, NAMESPACE_P); File[] arrSlideMasterFile = slideMasterDic.listFiles(); monitor.beginTask("", arrSlideMasterFile.length); for (File slideMasterFile : arrSlideMasterFile) { if (monitor.isCanceled()) { throw new OperationCanceledException(Messages.getString("preference.cancel")); } monitor.subTask(MessageFormat.format(Messages.getString("pptx.PPTX2XLIFF.task4"), slideMasterFile.getName())); if (slideMasterFile.isFile() && slideMasterFile.getName().toLowerCase().endsWith(".xml")) { if (vg.parseFile(slideMasterFile.getAbsolutePath(), true)) { String name = slideMasterFile.getName(); VTDNav vn = vg.getNav(); vu.bind(vn); ap.bind(vn); ap.selectXPath("/p:sldMaster/p:cSld/p:spTree//p:sp[descendant::p:ph[not(@type='dt') and not(@type='sldNum')]]"); ArrayList<String[]> lstFld = new ArrayList<String[]>(); while (ap.evalXPath() != -1) { String strType = getElementAttribute(".//p:ph", "type", vn); String idx = getElementAttribute(".//p:ph", "idx", vn); if (strType == null && idx == null) { continue; } String strX = getElementAttribute(".//a:xfrm/a:off", "x", vn); String strY = getElementAttribute(".//a:xfrm/a:off", "y", vn); if (strX != null && strY != null) { lstFld.add(new String[] { strType, idx, strX, strY }); } } if (lstFld.size() > 0) { mapSldMasterPH.put(name, lstFld); } } } monitor.worked(1); } } monitor.done(); }
Example 15
Source File: Html2Xliff.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** * Builds the tables. * @param iniFile * the ini file * @throws SAXException * the SAX exception * @throws IOException * Signals that an I/O exception has occurred. * @throws ParserConfigurationException * the parser configuration exception */ private void buildTables(String iniFile, IProgressMonitor monitor) throws SAXException, IOException, ParserConfigurationException { SAXBuilder builder = new SAXBuilder(); Catalogue cat = new Catalogue(catalogue); builder.setEntityResolver(cat); Document doc = builder.build(iniFile); Element root = doc.getRootElement(); List<Element> tags = root.getChildren("tag"); //$NON-NLS-1$ startsSegment = new Hashtable<String, String>(); translatableAttributes = new Hashtable<String, Vector<String>>(); entities = new Hashtable<String, String>(); ctypes = new Hashtable<String, String>(); keepFormating = new Hashtable<String, String>(); int size = tags.size(); monitor.beginTask(Messages.getString("html.Html2Xliff.task3"), size); monitor.subTask(""); Iterator<Element> i = tags.iterator(); while (i.hasNext()) { if (monitor.isCanceled()) { // 用户取消操作 throw new OperationCanceledException(Messages.getString("html.cancel")); } monitor.worked(1); Element t = i.next(); if (t.getAttributeValue("hard-break", "inline").equals("segment")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ startsSegment.put(t.getText(), "yes"); //$NON-NLS-1$ } if (t.getAttributeValue("keep-format", "no").equals("yes")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ keepFormating.put(t.getText(), "yes"); //$NON-NLS-1$ } String attributes = t.getAttributeValue("attributes", ""); //$NON-NLS-1$ //$NON-NLS-2$ if (!attributes.equals("")) { //$NON-NLS-1$ StringTokenizer tokenizer = new StringTokenizer(attributes, ";"); //$NON-NLS-1$ int count = tokenizer.countTokens(); Vector<String> v = new Vector<String>(count); for (int j = 0; j < count; j++) { v.add(tokenizer.nextToken()); } translatableAttributes.put(t.getText(), v); } String ctype = t.getAttributeValue("ctype", ""); //$NON-NLS-1$ //$NON-NLS-2$ if (!ctype.equals("")) { //$NON-NLS-1$ ctypes.put(t.getText(), ctype); } t = null; } tags = null; List<Element> ents = root.getChildren("entity"); //$NON-NLS-1$ Iterator<Element> it = ents.iterator(); while (it.hasNext()) { Element e = it.next(); entities.put("&" + e.getAttributeValue("name") + ";", e.getText()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } root = null; doc = null; builder = null; monitor.done(); }
Example 16
Source File: InlineMethodRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException { pm.beginTask("", 20); //$NON-NLS-1$ fChangeManager= new TextChangeManager(); RefactoringStatus result= new RefactoringStatus(); fSourceProvider.initialize(); fTargetProvider.initialize(); pm.setTaskName(RefactoringCoreMessages.InlineMethodRefactoring_searching); RefactoringStatus searchStatus= new RefactoringStatus(); String binaryRefsDescription= Messages.format(RefactoringCoreMessages.ReferencesInBinaryContext_ref_in_binaries_description , BasicElementLabels.getJavaElementName(fSourceProvider.getMethodName())); ReferencesInBinaryContext binaryRefs= new ReferencesInBinaryContext(binaryRefsDescription); ICompilationUnit[] units= fTargetProvider.getAffectedCompilationUnits(searchStatus, binaryRefs, new SubProgressMonitor(pm, 1)); binaryRefs.addErrorIfNecessary(searchStatus); if (searchStatus.hasFatalError()) { result.merge(searchStatus); return result; } IFile[] filesToBeModified= getFilesToBeModified(units); result.merge(Checks.validateModifiesFiles(filesToBeModified, getValidationContext())); if (result.hasFatalError()) return result; result.merge(ResourceChangeChecker.checkFilesToBeChanged(filesToBeModified, new SubProgressMonitor(pm, 1))); checkOverridden(result, new SubProgressMonitor(pm, 4)); IProgressMonitor sub= new SubProgressMonitor(pm, 15); sub.beginTask("", units.length * 3); //$NON-NLS-1$ for (int c= 0; c < units.length; c++) { ICompilationUnit unit= units[c]; sub.subTask(Messages.format(RefactoringCoreMessages.InlineMethodRefactoring_processing, BasicElementLabels.getFileName(unit))); CallInliner inliner= null; try { boolean added= false; MultiTextEdit root= new MultiTextEdit(); CompilationUnitChange change= (CompilationUnitChange)fChangeManager.get(unit); change.setEdit(root); BodyDeclaration[] bodies= fTargetProvider.getAffectedBodyDeclarations(unit, new SubProgressMonitor(pm, 1)); if (bodies.length == 0) continue; inliner= new CallInliner(unit, (CompilationUnit) bodies[0].getRoot(), fSourceProvider); for (int b= 0; b < bodies.length; b++) { BodyDeclaration body= bodies[b]; inliner.initialize(body); RefactoringStatus nestedInvocations= new RefactoringStatus(); ASTNode[] invocations= removeNestedCalls(nestedInvocations, unit, fTargetProvider.getInvocations(body, new SubProgressMonitor(sub, 2))); for (int i= 0; i < invocations.length; i++) { ASTNode invocation= invocations[i]; result.merge(inliner.initialize(invocation, fTargetProvider.getStatusSeverity())); if (result.hasFatalError()) break; if (result.getSeverity() < fTargetProvider.getStatusSeverity()) { added= true; TextEditGroup group= new TextEditGroup(RefactoringCoreMessages.InlineMethodRefactoring_edit_inline); change.addTextEditGroup(group); result.merge(inliner.perform(group)); } else { fDeleteSource= false; } } // do this after we have inlined the method calls. We still want // to generate the modifications. if (!nestedInvocations.isOK()) { result.merge(nestedInvocations); fDeleteSource= false; } } if (!added) { fChangeManager.remove(unit); } else { root.addChild(inliner.getModifications()); ImportRewrite rewrite= inliner.getImportEdit(); if (rewrite.hasRecordedChanges()) { TextEdit edit= rewrite.rewriteImports(null); if (edit instanceof MultiTextEdit ? ((MultiTextEdit)edit).getChildrenSize() > 0 : true) { root.addChild(edit); change.addTextEditGroup( new TextEditGroup(RefactoringCoreMessages.InlineMethodRefactoring_edit_import, new TextEdit[] {edit})); } } } } finally { if (inliner != null) inliner.dispose(); } sub.worked(1); if (sub.isCanceled()) throw new OperationCanceledException(); } result.merge(searchStatus); sub.done(); pm.done(); return result; }
Example 17
Source File: CheckMarkerUpdateJob.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
/** {@inheritDoc} */ @Override protected IStatus run(final IProgressMonitor monitor) { // Let's start (number of task = number of resource * 2 (loading + validating)) monitor.beginTask("", 2 * this.uris.size()); //$NON-NLS-1$ for (final URI uri : this.uris) { // Last chance to cancel before next validation if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } final IResourceServiceProvider serviceProvider = serviceProviderRegistry.getResourceServiceProvider(uri); if (serviceProvider == null) { // This may happen for non-Xtext resources in ice entities if (LOGGER.isDebugEnabled()) { LOGGER.debug(MessageFormat.format("Could not validate {0}: no resource service provider found", uri.toString())); //$NON-NLS-1$ } continue; // Skip to next URI } final IResourceValidator resourceValidator = serviceProvider.getResourceValidator(); final IStorage2UriMapper uriMapper = serviceProvider.get(IStorage2UriMapper.class); final MarkerCreator markerCreator = serviceProvider.get(MarkerCreator.class); // Get the file; only local files will be re-validated, derived files are ignored final IFile iFile = getFileFromStorageMapper(uriMapper, uri); if (iFile == null) { continue; // no storage mapping found for this URI } if (resourceValidator == null) { LOGGER.error(MessageFormat.format("Could not validate {0}: no resource validator found", iFile.getName())); //$NON-NLS-1$ } else if (iFile != null) { monitor.subTask("loading " + iFile.getName()); //$NON-NLS-1$ // Don't try to evaluate resource set before it has been checked that the storage provider contains a mapping // for current uri final ResourceSet resourceSet = getResourceSet(uriMapper, uri); // Load the corresponding resource boolean loaded = false; Resource eResource = null; try { eResource = resourceSet.getResource(uri, false); if ((eResource == null) || (eResource != null && !eResource.isLoaded())) { // if the resource does not exist in the resource set, or is not loaded yet // load it. eResource = resourceSet.getResource(uri, true); loaded = true; } monitor.worked(1); // CHECKSTYLE:OFF } catch (final RuntimeException e) { // CHECKSTYLE:ON LOGGER.error(MessageFormat.format("{0} could not be validated.", iFile.getName()), e); //$NON-NLS-1$ } finally { if (eResource != null) { validateAndCreateMarkers(resourceValidator, markerCreator, iFile, eResource, monitor); LOGGER.debug("Validated " + uri); //$NON-NLS-1$ if (loaded) { // NOPMD // unload any resource that was previously loaded as part of this loop. eResource.unload(); } } } } } monitor.done(); return Status.OK_STATUS; }
Example 18
Source File: XMLInputFieldsImportProgressDialog.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@SuppressWarnings( "unchecked" ) private RowMetaAndData[] doScan( IProgressMonitor monitor ) throws Exception { monitor.beginTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.ScanningFile", filename ), 1 ); SAXReader reader = XMLParserFactoryProducer.getSAXReader( null ); monitor.worked( 1 ); if ( monitor.isCanceled() ) { return null; } // Validate XML against specified schema? if ( meta.isValidating() ) { reader.setValidation( true ); reader.setFeature( "http://apache.org/xml/features/validation/schema", true ); } else { // Ignore DTD reader.setEntityResolver( new IgnoreDTDEntityResolver() ); } monitor.worked( 1 ); monitor .beginTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.ReadingDocument" ), 1 ); if ( monitor.isCanceled() ) { return null; } InputStream is = null; try { Document document = null; if ( !Utils.isEmpty( filename ) ) { is = KettleVFS.getInputStream( filename ); document = reader.read( is, encoding ); } else { if ( !Utils.isEmpty( xml ) ) { document = reader.read( new StringReader( xml ) ); } else { document = reader.read( new URL( url ) ); } } monitor.worked( 1 ); monitor.beginTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.DocumentOpened" ), 1 ); monitor.worked( 1 ); monitor.beginTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.ReadingNode" ), 1 ); if ( monitor.isCanceled() ) { return null; } List<Node> nodes = document.selectNodes( this.loopXPath ); monitor.worked( 1 ); monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.FetchNodes" ) ); if ( monitor.isCanceled() ) { return null; } for ( Node node : nodes ) { if ( monitor.isCanceled() ) { return null; } nr++; monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.FetchNodes", String .valueOf( nr ) ) ); monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.FetchNodes", node .getPath() ) ); setNodeField( node, monitor ); childNode( node, monitor ); } monitor.worked( 1 ); } finally { try { if ( is != null ) { is.close(); } } catch ( Exception e ) { /* Ignore */ } } RowMetaAndData[] listFields = fieldsList.toArray( new RowMetaAndData[fieldsList.size()] ); monitor.setTaskName( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.NodesReturned" ) ); monitor.done(); return listFields; }
Example 19
Source File: GenerateJava.java From eip-designer with Apache License 2.0 | 4 votes |
/** * 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("com.github.lbroudoux.dsl.eip.gen.camel", new Path("/com/github/lbroudoux/dsl/eip/gen/camel/main/generateJavaRoutes.emtl")); // com.github.lbroudoux.dsl.eip.gen.camel.main.GenerateJavaRoutes gen0 = new com.github.lbroudoux.dsl.eip.gen.camel.main.GenerateJavaRoutes(modelURI, targetFolder.getLocation().toFile(), arguments) { // protected URI createTemplateURI(String entry) { // return template0; // } //}; //gen0.doGenerate(BasicMonitor.toMonitor(monitor)); monitor.subTask("Loading..."); com.github.lbroudoux.dsl.eip.gen.camel.main.GenerateJavaRoutes gen0 = new com.github.lbroudoux.dsl.eip.gen.camel.main.GenerateJavaRoutes(modelURI, targetFolder.getLocation().toFile(), arguments); monitor.worked(1); String generationID = org.eclipse.acceleo.engine.utils.AcceleoLaunchingUtil.computeUIProjectID("com.github.lbroudoux.dsl.eip.gen.camel", "com.github.lbroudoux.dsl.eip.gen.camel.main.GenerateJavaRoutes", modelURI.toString(), targetFolder.getFullPath().toString(), new ArrayList<String>()); gen0.setGenerationID(generationID); gen0.doGenerate(BasicMonitor.toMonitor(monitor)); // EObject model = gen0.getModel(); // if (model != null) { //final URI template1 = getTemplateURI("com.github.lbroudoux.dsl.eip.gen.camel", new Path("/com/github/lbroudoux/dsl/eip/gen/camel/main/generateXmlRoutes.emtl")); //com.github.lbroudoux.dsl.eip.gen.camel.main.GenerateXmlRoutes gen1 = new com.github.lbroudoux.dsl.eip.gen.camel.main.GenerateXmlRoutes(model, targetFolder.getLocation().toFile(), arguments) { // protected URI createTemplateURI(String entry) { // return template1; // } //}; //gen1.doGenerate(BasicMonitor.toMonitor(monitor)); // monitor.subTask("Loading..."); // com.github.lbroudoux.dsl.eip.gen.camel.main.GenerateXmlRoutes gen1 = new com.github.lbroudoux.dsl.eip.gen.camel.main.GenerateXmlRoutes(model, targetFolder.getLocation().toFile(), arguments); // monitor.worked(1); // generationID = org.eclipse.acceleo.engine.utils.AcceleoLaunchingUtil.computeUIProjectID("com.github.lbroudoux.dsl.eip.gen.camel", "com.github.lbroudoux.dsl.eip.gen.camel.main.GenerateXmlRoutes", modelURI.toString(), targetFolder.getFullPath().toString(), new ArrayList<String>()); // gen1.setGenerationID(generationID); // gen1.doGenerate(BasicMonitor.toMonitor(monitor)); // } }
Example 20
Source File: Rtf2Xliff.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * Parses the group. * @param group * the group * @return the string */ private String parseGroup(String group, IProgressMonitor monitor) { int size = group.length(); // 如果 size 大于 10000,则把总任务数按比例缩小 100 倍;如果 size 大于 100000,则把总任务数按比例缩小 1000 倍。 int scale = 1; if (size > 100000) { scale = 1000; } else if (size > 10000) { scale = 100; } int totalTask = size / scale; monitor.beginTask("", totalTask); monitor.subTask(Messages.getString("rtf.Rtf2Xliff.task7")); Stack<String> localStack = new Stack<String>(); String buff = ""; //$NON-NLS-1$ int count = 0; for (int i = 0; i < group.length(); i++) { // 是否取消操作 if (monitor.isCanceled()) { throw new OperationCanceledException(Messages.getString("rtf.cancel")); } char c = group.charAt(i); if (c == '{') { localStack.push(buff); buff = ""; //$NON-NLS-1$ } buff = buff + c; if (c == '}') { String clean = cleanGroup(buff); buff = localStack.pop(); if (buff.matches(".*\\\\[a-zA-Z]+") && clean.matches("[a-zA-z0-9].*")) { //$NON-NLS-1$ //$NON-NLS-2$ buff = buff + " "; //$NON-NLS-1$ } if (buff.matches(".*\\\\[a-zA-Z]+[0-9]+") && clean.matches("[0-9].*")) { //$NON-NLS-1$ //$NON-NLS-2$ buff = buff + " "; //$NON-NLS-1$ } buff = buff + clean; } count++; int temp = count / scale; count %= scale; if (temp > 0) { monitor.worked(temp); } } monitor.done(); return buff; }