Package org.eclipse.core.runtime

Examples of org.eclipse.core.runtime.SubMonitor


        // Add JARs to project build path
        IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot();
        Collection<IPath> paths = classPathPage.getPaths();
        if (paths != null && !paths.isEmpty()) {
            int workRemaining = paths.size();
            SubMonitor progress = SubMonitor.convert(monitor, workRemaining);

            for (IPath path : paths) {
                File file = FileUtils.toFile(wsroot, path);
                if (file != null && file.isFile() && file.getName().toLowerCase().endsWith(".jar")) {
                    VersionedClause buildPathEntry = new VersionedClause("lib/" + file.getName(), new Attrs());
                    buildPathEntry.setVersionRange("file");
                    buildPath.add(buildPathEntry);
                }
                progress.setWorkRemaining(--workRemaining);
            }
        }

        // Add package exports
        List<IPath> selectedPackages = packageListPage.getSelectedPackages();
View Full Code Here


        return model;
    }

    @Override
    protected void processGeneratedProject(ProjectPaths projectPaths, BndEditModel bndModel, IJavaProject project, IProgressMonitor monitor) throws CoreException {
        SubMonitor progress = SubMonitor.convert(monitor, 2);
        super.processGeneratedProject(projectPaths, bndModel, project, progress.newChild(1));

        Collection<IPath> paths = classPathPage.getPaths();
        if (paths != null && !paths.isEmpty()) {
            int workRemaining = 1 + paths.size();
            progress.setWorkRemaining(workRemaining);

            IFolder libFolder = project.getProject().getFolder("lib");
            libFolder.create(false, true, progress.newChild(1));

            // Copy JARs into project lib folder.
            IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot();
            for (IPath path : paths) {
                File file = FileUtils.toFile(wsroot, path);
                if (file != null && file.isFile()) {
                    IFile copy = libFolder.getFile(file.getName());
                    try {
                        FileInputStream input = new FileInputStream(file);
                        try {
                            copy.create(input, false, progress.newChild(1));
                        } finally {
                            input.close();
                        }
                    } catch (IOException e) {
                        throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error copying JAR into project.", e));
                    }
                }
                progress.setWorkRemaining(--workRemaining);
            }
        }
    }
View Full Code Here

     * make workspace resource modifications.
     *
     * @throws CoreException
     */
    protected void processGeneratedProject(ProjectPaths projectPaths, BndEditModel bndModel, IJavaProject project, IProgressMonitor monitor) throws CoreException {
        SubMonitor progress = SubMonitor.convert(monitor, 3);

        Document document = new Document("");
        bndModel.saveChangesTo(document);
        progress.worked(1);

        ByteArrayInputStream bndInput;
        try {
            bndInput = new ByteArrayInputStream(document.get().getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            return;
        }
        IFile bndBndFile = project.getProject().getFile(Project.BNDFILE);
        if (bndBndFile.exists()) {
            bndBndFile.setContents(bndInput, false, false, progress.newChild(1));
        }

        BndProject proj = generateBndProject(project.getProject(), progress.newChild(1));

        progress.setWorkRemaining(proj.getResources().size());
        for (Map.Entry<String,BndProjectResource> resource : proj.getResources().entrySet()) {
            importResource(project.getProject(), resource.getKey(), resource.getValue(), progress.newChild(1));
        }

        if (!bndBndFile.exists()) {
            bndBndFile.create(bndInput, false, progress.newChild(1));
        }

        /* Version control ignores */
        VersionControlIgnoresManager versionControlIgnoresManager = Plugin.getDefault().getVersionControlIgnoresManager();
        Set<String> enabledIgnorePlugins = new BndPreferences().getVersionControlIgnoresPluginsEnabled(versionControlIgnoresManager, project, null);
View Full Code Here

                // Run using the progress bar from the wizard dialog
                getContainer().run(false, false, new IRunnableWithProgress() {
                    @Override
                    public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                        try {
                            SubMonitor progress = SubMonitor.convert(monitor, 3);

                            // Generate the Bnd model
                            final BndEditModel bndModel = generateBndModel(progress.newChild(1));

                            // Make changes to the project
                            final IWorkspaceRunnable op = new IWorkspaceRunnable() {
                                @Override
                                public void run(IProgressMonitor monitor) throws CoreException {
                                    processGeneratedProject(ProjectPaths.get(pageOne.getProjectLayout()), bndModel, javaProj, monitor);
                                }
                            };
                            javaProj.getProject().getWorkspace().run(op, progress.newChild(2));
                        } catch (CoreException e) {
                            throw new InvocationTargetException(e);
                        }
                    }
                });
View Full Code Here

   * @throws CoreException if failure occurred while attempting to execute the
   * client operation.
   */
  public T run(IProgressMonitor monitor) throws CoreException {

    SubMonitor subProgress = SubMonitor.convert(monitor, label, 100);

    CloudFoundryOperations client = getClient(subProgress);
    if (client == null) {
      throw CloudErrorUtil.toCoreException(NLS.bind(Messages.ERROR_NO_CLIENT, label));
    }

    HttpTracer.getCurrent().trace(client);
    try {
      return runAndWait(client, subProgress);
    }
    catch (CoreException ce) {
      // See if it is a connection error. If so, parse it into readable
      // form.
      String connectionError = CloudErrorUtil.getConnectionError(ce);
      if (connectionError != null) {
        throw CloudErrorUtil.asCoreException(connectionError, ce, true);
      }
      else {
        throw ce;
      }
    }
    finally {
      subProgress.done();
    }

  }
View Full Code Here

   * working copy.
   * @throws CoreException if error occurred while loading an existing
   * manifest file.
   */
  public DeploymentInfoWorkingCopy load(IProgressMonitor monitor) throws CoreException {
    SubMonitor subMonitor = SubMonitor.convert(monitor);
    subMonitor.beginTask("Parsing and loading application manifest file", 6); //$NON-NLS-1$
    DeploymentInfoWorkingCopy workingCopy;
    try {
      workingCopy = appModule.resolveDeploymentInfoWorkingCopy(subMonitor);

      Map<?, ?> application = getApplication(null);

      subMonitor.worked(1);
      if (application == null) {
        return null;
      }

      // NOTE: When reading from manifest, the manifest may be INCOMPLETE,
      // therefore do not automatically
      // set all properties in the deployment info. Check if the value of
      // the
      // property is actually set before set value
      // in the info
      String appName = getStringValue(application, NAME_PROP);

      subMonitor.worked(1);
      if (appName != null) {
        workingCopy.setDeploymentName(appName);
      }

      readMemory(application, workingCopy);
      subMonitor.worked(1);

      readApplicationURL(application, workingCopy, appName, monitor);
      subMonitor.worked(1);

      String buildpackurl = getStringValue(application, BUILDPACK_PROP);
      if (buildpackurl != null) {
        Staging staging = new Staging(null, buildpackurl);
        workingCopy.setStaging(staging);
      }

      readEnvars(workingCopy, application);
      subMonitor.worked(1);

      readServices(workingCopy, application);
      subMonitor.worked(1);

      String archiveURL = getStringValue(application, PATH_PROP);
      if (archiveURL != null) {
        workingCopy.setArchive(archiveURL);
      }

    }
    finally {
      subMonitor.done();
    }

    return workingCopy;
  }
View Full Code Here

    }

    final String operationLabel = Messages.AbstractURLWizardPage_LABEL_FETCHING_DOMAIN;
    ICoreRunnable runnable = new ICoreRunnable() {
      public void run(IProgressMonitor coreRunnerMonitor) throws CoreException {
        SubMonitor subProgress = SubMonitor.convert(coreRunnerMonitor, operationLabel, 100);
        try {
          urlLookup.refreshDomains(subProgress);
          refreshedDomains = true;
          // Must launch this again in the UI thread AFTER
          // the refresh occurs.
          Display.getDefault().syncExec(new Runnable() {

            public void run() {
              // Clear any info in the dialogue
              setMessage(null);

              domainsRefreshed();
            }

          });
        }
        finally {
          subProgress.done();
        }
      }
    };
    runAsynchWithWizardProgress(runnable, operationLabel);
  }
View Full Code Here

  protected File packageApplication(final JarPackageData packageData,
      IProgressMonitor monitor) throws CoreException {

    int progressWork = 10;
    final SubMonitor subProgress = SubMonitor
        .convert(monitor, progressWork);

    final File[] createdFile = new File[1];

    final CoreException[] error = new CoreException[1];
    Display.getDefault().syncExec(new Runnable() {

      @Override
      public void run() {
        try {

          Shell shell = CloudUiUtil.getShell();

          IJarExportRunnable runnable = packageData
              .createJarExportRunnable(shell);
          try {
            runnable.run(subProgress);

            File file = new File(packageData.getJarLocation()
                .toString());
            if (!file.exists()) {
              handleApplicationDeploymentFailure();
            } else {
              createdFile[0] = file;
            }

          } catch (InvocationTargetException e) {
            throw CloudErrorUtil.toCoreException(e);
          } catch (InterruptedException ie) {
            throw CloudErrorUtil.toCoreException(ie);
          } finally {
            subProgress.done();
          }
        } catch (CoreException e) {
          error[0] = e;
        }
      }
View Full Code Here

      @Override
      protected Void doRun(CloudFoundryOperations client, SubMonitor progress) throws CoreException {
        // Update environment variables.
        Map<String, String> varsMap = new HashMap<String, String>();

        SubMonitor subProgress = SubMonitor.convert(progress);
        subProgress
            .setTaskName("Updating environment variables for: " + appModule.getDeployedApplicationName()); //$NON-NLS-1$

        try {
          List<EnvironmentVariable> vars = appModule.getDeploymentInfo().getEnvVariables();

          if (vars != null) {
            for (EnvironmentVariable var : vars) {
              varsMap.put(var.getVariable(), var.getValue());
            }
          }

          client.updateApplicationEnv(appModule.getDeployedApplicationName(), varsMap);

          // Update the cloud application which contains the updated
          // environment variables.
          CloudApplication cloudApplication = getApplication(appModule.getDeployedApplicationName(),
              subProgress);
          appModule.setCloudApplication(cloudApplication);

        }
        finally {
          subProgress.done();
        }

        return null;
      }
View Full Code Here

    createExternalClientLogin(location, userName, password, selfSigned, monitor);
  }

  public static CloudFoundryOperations createExternalClientLogin(final String location, String userName,
      String password, boolean selfSigned, IProgressMonitor monitor) throws CoreException {
    SubMonitor progress = SubMonitor.convert(monitor);
    progress.beginTask("Connecting", IProgressMonitor.UNKNOWN); //$NON-NLS-1$
    try {
      final CloudFoundryOperations client = createClient(location, userName, password, selfSigned);

      new ClientRequest<Void>(Messages.VALIDATING_CREDENTIALS) {

        @Override
        protected Void doRun(CloudFoundryOperations client, SubMonitor progress) throws CoreException {
          CloudFoundryLoginHandler operationsHandler = new CloudFoundryLoginHandler(client);
          int attempts = 5;
          operationsHandler.login(progress, attempts, CloudOperationsConstants.LOGIN_INTERVAL);
          return null;
        }

        @Override
        protected CloudFoundryOperations getClient(IProgressMonitor monitor) throws CoreException {
          return client;
        }

      }.run(monitor);
      return client;
    }
    catch (RuntimeException t) {
      throw CloudErrorUtil.checkServerCommunicationError(t);
    }
    finally {
      progress.done();
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.core.runtime.SubMonitor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.