Пример #1
0
  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;
      }
    }
  }
  @Override
  public void execute(
      IProject project, IProjectFacetVersion version, Object object, IProgressMonitor progress)
      throws CoreException {
    if (!project.hasNature(PHPNature.ID)) {
      return;
    }

    progress.subTask("Installing composer nature");

    // add the composer nature
    ResourceUtil.addNature(project, progress, ComposerNature.NATURE_ID);

    progress.subTask("Installing composer buildpath");

    // maybe comment out this one:
    // create composer buildpath entry

    //		if (ComposerPlugin.getDefault().isBuildpathContainerEnabled()) {
    //			IScriptProject scriptProject = DLTKCore.create(project);
    //			IBuildpathContainer composerContainer = new ComposerBuildpathContainer(
    //					new Path(ComposerBuildpathContainerInitializer.CONTAINER),
    //					scriptProject);
    //			List<IBuildpathEntry> entries = new ArrayList<IBuildpathEntry>();
    //			entries.add(DLTKCore.newContainerEntry(composerContainer.getPath()));
    //
    //			// add the composer buildpathentry to the project
    //			BuildPathUtils.addEntriesToBuildPath(scriptProject, entries);
    //
    //			BuildpathUtil.setupVendorBuildpath(scriptProject, progress);
    //
    //		}
  }
  /*
   * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, int)
   */
  public final ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
    long start = DEBUG ? System.currentTimeMillis() : 0;

    clearState();

    IProgressMonitor monitor = createProgressMonitor();
    monitor.beginTask(
        JavaTextMessages.ContentAssistProcessor_computing_proposals, fCategories.size() + 1);

    ContentAssistInvocationContext context = createContext(viewer, offset);
    long setup = DEBUG ? System.currentTimeMillis() : 0;

    monitor.subTask(JavaTextMessages.ContentAssistProcessor_collecting_proposals);
    List<ICompletionProposal> proposals = collectProposals(viewer, offset, monitor, context);
    long collect = DEBUG ? System.currentTimeMillis() : 0;

    monitor.subTask(JavaTextMessages.ContentAssistProcessor_sorting_proposals);
    List<ICompletionProposal> filtered = filterAndSortProposals(proposals, monitor, context);
    fNumberOfComputedResults = filtered.size();
    long filter = DEBUG ? System.currentTimeMillis() : 0;

    ICompletionProposal[] result = filtered.toArray(new ICompletionProposal[filtered.size()]);
    monitor.done();

    if (DEBUG) {
      System.err.println(
          "Code Assist Stats (" + result.length + " proposals)"); // $NON-NLS-1$ //$NON-NLS-2$
      System.err.println("Code Assist (setup):\t" + (setup - start)); // $NON-NLS-1$
      System.err.println("Code Assist (collect):\t" + (collect - setup)); // $NON-NLS-1$
      System.err.println("Code Assist (sort):\t" + (filter - collect)); // $NON-NLS-1$
    }

    return result;
  }
Пример #4
0
  public IStatus execute(
      IProgressMonitor monitor,
      ICommand command,
      IReturnValueConsumer returnValueConsumer,
      Options options) {
    monitor.beginTask(null, 100);

    monitor.subTask(Messages.DNSSDRemoteCommandService_ResolveRemoteCommandService);

    boolean doResolve = false;
    synchronized (info) {
      if (!resolving) {
        resolving = true;
        doResolve = true;
      }
    }

    DNSSDService resolver = null;
    if (doResolve) {
      try {
        resolver = DNSSD.resolve(flags, ifIndex, serviceName, regType, domain, this);
      } catch (DNSSDException e) {
        return new Status(
            IStatus.ERROR,
            LANRemoteCommandPlugin.ID,
            Messages.DNSSDRemoteCommandService_FailedResolveRemoteCommand,
            e);
      }
    }
    try {
      while (resolving) {
        if (monitor.isCanceled()) return Status.CANCEL_STATUS;
        Thread.sleep(0);
      }
    } catch (InterruptedException e) {
      return Status.CANCEL_STATUS;
    } finally {
      if (resolver != null) {
        resolver.stop();
      }
    }

    if (monitor.isCanceled()) return Status.CANCEL_STATUS;
    monitor.worked(10);

    monitor.subTask(Messages.DNSSDRemoteCommandService_SendCommand);
    IProgressMonitor handleMonitor = new SubProgressMonitor(monitor, 90);
    OutgoingSocketCommandHandler handler = new OutgoingSocketCommandHandler(info.getAddress());
    handler.setPluginId(LANRemoteCommandPlugin.ID);
    handler.setSocketPool(socketPool);
    IStatus handled =
        handler.handleOutgoingCommand(
            handleMonitor, command, returnValueConsumer, options.timeout());
    if (!handleMonitor.isCanceled()) handleMonitor.done();
    return handled;
  }
Пример #5
0
  /**
   * 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);
  }
 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 boolean visit(IResource resource) throws CoreException {
      if (resource.isDerived()) {
        return false;
      }

      handler.handleResourceStart(resource);

      if (resource.getType() == IResource.FILE
          && ContentTypeUtils.isGroovyLikeFileName(resource.getName())) {
        if (Util.isExcluded(resource, includes, excludes)) {
          return false;
        }

        GroovyCompilationUnit unit = (GroovyCompilationUnit) JavaCore.create((IFile) resource);
        if (unit != null && unit.isOnBuildPath()) {
          if (monitor.isCanceled()) {
            throw new OperationCanceledException();
          }
          monitor.subTask(resource.getName());
          handler.setResource((IFile) resource);
          Map<Integer, String> commentsMap = findComments(unit);
          StaticTypeCheckerRequestor requestor =
              new StaticTypeCheckerRequestor(handler, commentsMap, onlyAssertions);
          TypeInferencingVisitorWithRequestor visitor =
              new TypeInferencingVisitorFactory().createVisitor(unit);
          try {
            unit.becomeWorkingCopy(monitor);
            visitor.visitCompilationUnit(requestor);
          } finally {
            unit.discardWorkingCopy();
          }
        }
      }
      return true;
    }
Пример #8
0
 /**
  * Set the progress monitor done.
  *
  * @param progress The progress monitor or <code>null</code>.
  */
 public static final void done(IProgressMonitor progress) {
   if (progress != null) {
     progress.setTaskName(""); // $NON-NLS-1$
     progress.subTask(""); // $NON-NLS-1$
     progress.done();
   }
 }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.core.resources.IWorkspaceRunnable#run(org.eclipse.core.runtime.IProgressMonitor)
  */
 public void run(IProgressMonitor monitor) throws CoreException {
   monitor.beginTask(
       AcceleoUIMessages.getString("AcceleoCompileOperation.Task.Compile"),
       files.length); // $NON-NLS-1$
   for (int i = 0; i < files.length; i++) {
     checkCanceled(monitor);
     monitor.subTask(
         AcceleoUIMessages.getString(
             "AcceleoCompileOperation.Task.Clean",
             files[0].getFullPath().toString())); // $NON-NLS-1$
     if (files[i].isAccessible()) {
       files[i].deleteMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
       files[i].deleteMarkers(IMarker.TASK, true, IResource.DEPTH_INFINITE);
       files[i].deleteMarkers(
           AcceleoMarkerUtils.OVERRIDE_MARKER_ID, true, IResource.DEPTH_INFINITE);
     }
   }
   if (!isClean) {
     doCompileResources(monitor);
   } else {
     for (IFile file : this.files) {
       AcceleoProject acceleoProject = new AcceleoProject(project);
       IPath outputPath = acceleoProject.getOutputFilePath(file);
       if (outputPath != null) {
         URI platformURI = URI.createPlatformResourceURI(outputPath.toString(), false);
         try {
           AcceleoUIResourceSet.removeResource(platformURI);
         } catch (IOException e) {
           AcceleoUIActivator.log(e, true);
         }
       }
     }
   }
   monitor.done();
 }
Пример #10
0
  /**
   * @param sourceStore the file to be copied
   * @param destinationStore the destination location
   * @param monitor the progress monitor
   * @return true if the file is successfully copied, false if the operation did not go through for
   *     any reason
   */
  protected boolean copyFile(
      IFileStore sourceStore, IFileStore destinationStore, IProgressMonitor monitor) {
    if (sourceStore == null) {
      return false;
    }

    boolean success = true;
    monitor.subTask(
        MessageFormat.format(
            "Copying {0} to {1}", sourceStore.getName(), destinationStore.getName()));
    try {
      if (fAlwaysOverwrite) {
        sourceStore.copy(destinationStore, EFS.OVERWRITE, monitor);
      } else if (destinationStore.fetchInfo(0, monitor).exists()) {
        String overwrite = fOverwriteQuery.queryOverwrite(destinationStore.toString());
        if (overwrite.equals(IOverwriteQuery.ALL) || overwrite.equals(IOverwriteQuery.YES)) {
          sourceStore.copy(destinationStore, EFS.OVERWRITE, monitor);
        } else {
          success = false;
        }
      } else {
        sourceStore.copy(destinationStore, EFS.NONE, monitor);
      }
    } catch (CoreException e) {
      // TODO: report the error
      success = false;
    }
    return success;
  }
    /**
     * Check whether the new definition will either conflict with or shadow an existing definition
     */
    private List<PhotranTokenRef> findReferencesToShadowedDefinitions() {
      List<PhotranTokenRef> referencesToShadowedDefinitions = new LinkedList<PhotranTokenRef>();

      for (String newName : newNames) {
        Token token =
            definitionToCheck == null
                ? new FakeToken(scopeOfDefinitionToCheck, newName)
                : new FakeToken(definitionToCheck.getTokenRef().findToken(), newName);

        List<PhotranTokenRef> shadowedDefinitions = scopeOfDefinitionToCheck.manuallyResolve(token);
        // TODO: Does not consider rename or only lists (need to tell if this SPECIFIC definition
        // will be imported)
        for (ScopingNode importingScope : scopeOfDefinitionToCheck.findImportingScopes()) {
          pm.subTask(
              Messages.bind(
                  Messages.FortranResourceRefactoring_CheckingForReferencesTo,
                  newName,
                  importingScope.describe()));
          shadowedDefinitions.addAll(importingScope.manuallyResolve(token));
        }

        for (PhotranTokenRef def : shadowedDefinitions) {
          Definition definition = PhotranVPG.getInstance().getDefinitionFor(def);
          if (definition != null)
            referencesToShadowedDefinitions.addAll(definition.findAllReferences(false));
        }
      }

      return referencesToShadowedDefinitions;
    }
Пример #12
0
 private void beginRTask(final IToolService r, final IProgressMonitor monitor)
     throws CoreException {
   synchronized (this) {
     while (fRProcess != null) {
       if (fRTask == 1) {
         monitor.subTask("Waiting for package check...");
         try {
           wait();
         } catch (final InterruptedException e) {
           if (monitor.isCanceled()) {
             throw new CoreException(Status.CANCEL_STATUS);
           }
         }
       } else {
         final Status status =
             new Status(
                 IStatus.ERROR,
                 RCore.PLUGIN_ID,
                 NLS.bind(
                     "Another package manager task for ''{0}'' is already running in ''{0}''",
                     fREnv.getName(), fRProcess.getLabel(ITool.DEFAULT_LABEL)));
         //				r.handleStatus(status, monitor);
         throw new CoreException(status);
       }
     }
     fRProcess = r.getTool();
     fRTask = 2;
   }
 }
 @Override
 public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
   try {
     result = CommandResult.SUCCESS;
     if (m_scope == null && m_variables == null) {
       monitor.setTaskName("Clearing all variables and scopes");
       ISharedDataService svc = (ISharedDataService) ServiceManager.get(ISharedDataService.class);
       for (String scope : svc.getSharedScopes()) {
         svc.removeSharedScope(scope);
       }
       svc.getSharedScope(ISharedDataService.GLOBAL_SCOPE).clear();
     } else if (m_variables != null) {
       monitor.beginTask(
           "Clearing variables in scope " + m_scope.getScopeName(), m_variables.size());
       for (SharedVariable var : m_variables) {
         monitor.subTask("Removing variable " + var.name);
         m_scope.clear(var.name);
         monitor.worked(1);
         if (monitor.isCanceled()) return;
       }
     } else {
       monitor.setTaskName("Clearing variables in scope " + m_scope.getScopeName());
       m_scope.clear();
     }
     monitor.done();
   } catch (Exception ex) {
     ex.printStackTrace();
     message = ex.getLocalizedMessage();
     result = CommandResult.FAILED;
   }
 }
Пример #14
0
  /**
   * 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));
  }
  @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);
  }
  private void addProjectNature(final IProject proj, final IProgressMonitor monitor)
      throws CoreException {

    monitor.subTask(Messages.getString("GridProjectCreationOperation.nature_task")); // $NON-NLS-1$

    IProjectDescription desc = proj.getDescription();
    String[] natureIDs = desc.getNatureIds();
    String gridNatureID = GridProjectNature.getID();

    boolean found = false;
    for (int i = 0; (i < natureIDs.length) && (!found); i++) {
      if (natureIDs[i].equals(gridNatureID)) {
        found = true;
      }
    }

    if (!found) {
      String[] newNatureIDs = new String[natureIDs.length + 1];
      System.arraycopy(natureIDs, 0, newNatureIDs, 1, natureIDs.length);
      newNatureIDs[0] = gridNatureID;
      desc.setNatureIds(newNatureIDs);
      proj.setDescription(desc, new SubProgressMonitor(monitor, 100));
    }

    if (monitor.isCanceled()) {
      throw new OperationCanceledException();
    }
  }
Пример #17
0
 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());
   }
 }
Пример #18
0
 private void doPurgeDB(IProgressMonitor monitor, int workUnits) {
   monitor.subTask("Bereinige Datenbank");
   JdbcLink j = PersistentObject.getConnection();
   j.exec("DELETE FROM kontakt where deleted='1'");
   j.exec("DELETE FROM briefe where deleted='1'");
   j.exec("DELETE FROM faelle where deleted='1'");
   j.exec("DELETE FROM behandlungen where deleted='1'");
   j.exec("DELETE FROM artikel where deleted='1'");
   j.exec("DELETE FROM leistungen where deleted='1'");
   j.exec("DELETE FROM output_log");
   j.exec("DELETE FROM rechnungen where deleted='1'");
   j.exec("DELETE FROM reminders where deleted='1'");
   j.exec("DELETE FROM traces");
   j.exec("DELETE FROM laboritems where deleted='1'");
   j.exec("DELETE FROM laborwerte where deleted='1'");
   j.exec("DELETE FROM rezepte where deleted='1'");
   j.exec("DELETE FROM heap where deleted='1'");
   j.exec("DELETE FROM auf where deleted='1'");
   j.exec("DELETE FROM heap2 where deleted='1'");
   j.exec("DELETE FROM logs where deleted='1'");
   j.exec("DELETE FROM xid where deleted='1'");
   j.exec("DELETE FROM etiketten where deleted='1'");
   j.exec("DELETE FROM CH_ELEXIS_OMNIVORE_DATA where deleted='1'");
   monitor.worked(workUnits);
 }
Пример #19
0
 /**
  * @param packageNames
  * @return
  */
 private List getPackageFragments(List packageNames) {
   monitor.subTask("Finding Packages in tangle");
   SearchEngine searchEngine = new SearchEngine();
   IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
   SearchPattern pattern =
       SearchPattern.createPattern(
           "*",
           IJavaSearchConstants.PACKAGE,
           IJavaSearchConstants.DECLARATIONS,
           SearchPattern.R_PATTERN_MATCH);
   PackageCollector c = new PackageCollector(packageNames);
   try {
     searchEngine.search(
         pattern,
         new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
         scope,
         c,
         monitor);
     monitor.worked(100);
     return c.getResult();
   } catch (CoreException e) {
     e.printStackTrace();
     return new ArrayList();
   }
 }
 public void taskDone() {
   synchronized (monitor) {
     if (remainingOnCurrentTask > 0) monitor.worked(remainingOnCurrentTask);
     remainingOnCurrentTask = ticksPerTask;
   }
   if (subNamesIter.hasNext()) monitor.subTask(subNamesIter.next());
 }
Пример #21
0
    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 run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {

    try {
      String[] ddls = ddl.split(";[\r\n]+");

      monitor.beginTask(ResourceString.getResourceString("dialog.message.drop.table"), ddls.length);

      for (int i = 0; i < ddls.length; i++) {
        String message = ddls[i];
        int index = message.indexOf("\r\n");
        if (index != -1) {
          message = message.substring(0, index);
        }

        monitor.subTask("(" + (i + 1) + "/" + ddls.length + ") " + message);

        this.executeDDL(ddls[i]);
        monitor.worked(1);

        if (monitor.isCanceled()) {
          throw new InterruptedException("Cancel has been requested.");
        }
      }

      this.con.commit();

    } catch (InterruptedException e) {
      throw e;

    } catch (Exception e) {
      this.exception = e;
    }

    monitor.done();
  }
Пример #23
0
 public IStatus doImport(final InputStream inputStream, final IProgressMonitor monitor)
     throws ElexisException {
   ExcelWrapper ew = new ExcelWrapper();
   if (ew.load(inputStream, 0)) {
     int f = ew.getFirstRow() + 1;
     int l = ew.getLastRow();
     monitor.beginTask("Import BAG-Medikamente", l - f);
     int counter = 0;
     ew.setFieldTypes(
         new Class[] {
           String.class, Character.class, Integer.class, Integer.class, Integer.class,
           Character.class, String.class, String.class, Double.class, Double.class,
           String.class, Integer.class, Integer.class, String.class, Integer.class
         });
     for (int i = f; i < l; i++) {
       List<String> row = ew.getRow(i);
       monitor.subTask(row.get(7));
       importUpdate(row.toArray(new String[0]));
       if (counter++ > 200) {
         PersistentObject.clearCache();
         counter = 0;
       }
       if (monitor.isCanceled()) {
         return Status.CANCEL_STATUS;
       }
       monitor.worked(1);
       row = null;
     }
     monitor.done();
     return Status.OK_STATUS;
   }
   return Status.CANCEL_STATUS;
 }
Пример #24
0
  protected void execute(GeneralProjectMigration page, String libraryId, IProgressMonitor monitor2)
      throws Exception {

    IProject target = ToolingUtils.importLibrary(libraryId);
    IProject project2Update = this.project;
    // copy projects before as requested
    Boolean projectCopy =
        page.getFieldValueBoolean(GeneralProjectMigration.Fields.copybefore.toString());
    if (projectCopy) {
      project2Update = null;
      String newNameParam =
          page.getFieldValueString(GeneralProjectMigration.Fields.newName.toString());

      if (StringUtils.trimToNull(newNameParam) == null) {
        newNameParam = GeneralProjectMigration.DEFAULT_VALUE_NEWNAME;
      }

      IProjectDescription description = project.getDescription();
      String newName = newNameParam;
      description.setName(newName);
      description.setLocationURI(null);
      System.out.println(
          "ModelMigrationWizard.execute() rename project " + project.getName() + " -> " + newName);
      project.copy(description, true, monitor2);
      IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(description.getName());
      project2Update = project;
    }

    // execute models conversion
    ModelMigrationHelper modelMigrationHelper = new ModelMigrationHelper();
    modelMigrationHelper.updateProject(project2Update, target, libraryId, projectCopy, monitor2);
    monitor2.subTask("Refresh project");
    IFileHelper.refreshFolder(project2Update);
    monitor2.done();
  }
Пример #25
0
  /** Job's main routine which starts and monitors WorkerThread */
  @Override
  protected IStatus run(final IProgressMonitor monitor) {
    if (item == null) return Status.OK_STATUS;

    monitor.beginTask(Messages.ArchiveFetchStart, IProgressMonitor.UNKNOWN);
    final WorkerThread worker = new WorkerThread();
    Future<?> done = Activator.getThreadPool().submit(worker);
    // Poll worker and progress monitor
    long seconds = 0;
    while (!done.isDone()) {
      try {
        Thread.sleep(POLL_PERIOD_MS);
      } catch (InterruptedException ex) {
        // Ignore
      }
      final String info =
          NLS.bind(Messages.ArchiveFetchProgressFmt, worker.getMessage(), ++seconds);
      monitor.subTask(info);
      // Try to cancel the worker in response to user's cancel request.
      // Continues to cancel the worker until isDone()
      if (monitor.isCanceled()) worker.cancel();
    }
    monitor.done();

    return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
  }
  private IProject createProject(final GridProjectProperties props, final IProgressMonitor monitor)
      throws CoreException {

    monitor.subTask(Messages.getString("GridProjectCreationOperation.init_task")); // $NON-NLS-1$

    String projectName = props.getProjectName();
    IPath projectPath = props.getProjectLocation();
    IProject[] referencesProjects = props.getReferencesProjects();

    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IProject project = workspaceRoot.getProject(projectName);

    IStatus status = ResourcesPlugin.getWorkspace().validateProjectLocation(project, projectPath);
    if (status.getSeverity() != IStatus.OK) {
      throw new CoreException(status);
    }

    IProjectDescription desc = project.getWorkspace().newProjectDescription(projectName);
    desc.setLocation(projectPath);
    if (referencesProjects != null) {
      desc.setReferencedProjects(referencesProjects);
    }
    project.create(desc, new SubProgressMonitor(monitor, 50));
    project.open(new SubProgressMonitor(monitor, 50));

    createProjectStructure(project, props);
    setProjectProperties(project, props);

    if (monitor.isCanceled()) {
      throw new OperationCanceledException();
    }

    return project;
  }
Пример #27
0
  /**
   * 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.earthsystemcurator.cupid.esmf2fortran", new
    // Path("/esmf2fortran/main/generate.emtl"));
    // esmf2fortran.main.Generate gen0 = new esmf2fortran.main.Generate(modelURI,
    // targetFolder.getLocation().toFile(), arguments) {
    //	protected URI createTemplateURI(String entry) {
    //		return template0;
    //	}
    // };
    // gen0.doGenerate(BasicMonitor.toMonitor(monitor));
    monitor.subTask("Loading...");
    esmf2fortran.main.Generate gen0 =
        new esmf2fortran.main.Generate(modelURI, targetFolder.getLocation().toFile(), arguments);
    monitor.worked(1);
    String generationID =
        org.eclipse.acceleo.engine.utils.AcceleoLaunchingUtil.computeUIProjectID(
            "org.earthsystemcurator.cupid.esmf2fortran",
            "esmf2fortran.main.Generate",
            modelURI.toString(),
            targetFolder.getFullPath().toString(),
            new ArrayList<String>());
    gen0.setGenerationID(generationID);
    gen0.doGenerate(BasicMonitor.toMonitor(monitor));
  }
Пример #28
0
  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);
    }
  }
Пример #29
0
  private void addTextMatches(IResource resource, IProgressMonitor pm) throws JavaModelException {
    try {
      String task = RefactoringCoreMessages.TextMatchUpdater_searching + resource.getFullPath();
      if (resource instanceof IFile) {
        IJavaElement element = JavaCore.create(resource);
        // don't start pm task (flickering label updates; finally {pm.done()} is enough)
        if (!(element instanceof ICompilationUnit)) return;
        if (!element.exists()) return;
        if (!fScope.encloses(element)) return;
        addCuTextMatches((ICompilationUnit) element);

      } else if (resource instanceof IContainer) {
        IResource[] members = ((IContainer) resource).members();
        pm.beginTask(task, members.length);
        pm.subTask(task);
        for (int i = 0; i < members.length; i++) {
          if (pm.isCanceled()) throw new OperationCanceledException();

          addTextMatches(members[i], new SubProgressMonitor(pm, 1));
        }
      }
    } catch (JavaModelException e) {
      throw e;
    } catch (CoreException e) {
      throw new JavaModelException(e);
    } finally {
      pm.done();
    }
  }
Пример #30
0
 /**
  * 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);
 }