Package org.eclipse.core.resources

Examples of org.eclipse.core.resources.WorkspaceJob


      else
        return null;
    }
    String jobname = NLS.bind(UIText.MergeAction_JobNameMerge, refName);
    final MergeOperation op = new MergeOperation(repository, refName);
    Job job = new WorkspaceJob(jobname) {

      @Override
      public IStatus runInWorkspace(IProgressMonitor monitor) {
        try {
          op.execute(monitor);
        } catch (final CoreException e) {
          return e.getStatus();
        }
        return Status.OK_STATUS;
      }
    };
    job.setUser(true);
    job.setRule(op.getSchedulingRule());
    job.addJobChangeListener(new JobChangeAdapter() {
      @Override
      public void done(IJobChangeEvent cevent) {
        IStatus result = cevent.getJob().getResult();
        if (result.getSeverity() == IStatus.CANCEL)
          Display.getDefault().asyncExec(new Runnable() {
            public void run() {
              // don't use getShell(event) here since
              // the active shell has changed since the
              // execution has been triggered.
              Shell shell = PlatformUI.getWorkbench()
                  .getActiveWorkbenchWindow().getShell();
              MessageDialog
                  .openInformation(
                      shell,
                      UIText.MergeAction_MergeCanceledTitle,
                      UIText.MergeAction_MergeCanceledMessage);
            }
          });
        else if (!result.isOK())
          Activator.handleError(result.getMessage(), result
              .getException(), true);
        else
          Display.getDefault().asyncExec(new Runnable() {
            public void run() {
              Shell shell = PlatformUI.getWorkbench()
                  .getActiveWorkbenchWindow().getShell();
              MergeResultDialog.getDialog(shell, repository, op
                  .getResult()).open();
            }
          });
      }
    });
    job.schedule();
    return null;
  }
View Full Code Here


   * @param jobChangeListener
   */
  public static void scheduleUserWorkspaceJob(final IEGitOperation op,
      String jobName, final Object jobFamily,
      IJobChangeListener jobChangeListener) {
    Job job = new WorkspaceJob(jobName) {
      @Override
      public IStatus runInWorkspace(IProgressMonitor monitor) {
        try {
          op.execute(monitor);
        } catch (CoreException e) {
          return e.getStatus();
        }
        return Status.OK_STATUS;
      }

      @Override
      public boolean belongsTo(Object family) {
        if (jobFamily != null && family.equals(jobFamily))
          return true;
        return super.belongsTo(family);
      }
    };
    job.setRule(op.getSchedulingRule());
    job.setUser(true);
    if (jobChangeListener != null)
      job.addJobChangeListener(jobChangeListener);
    job.schedule();
  }
View Full Code Here

        try {
            rootDelta.accept(visitor);

            if (Utils.isNotEmpty(projects)) {
                WorkspaceJob job = new WorkspaceJob("Setting projects for upgrade") {
                    @Override
                    public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
                        for (IProject project : projects) {
                            try {
                                inspectProject(project, monitor);
                            } catch (CoreException e) {
                                String logMessage = Utils.generateCoreExceptionLog(e);
                                logger.warn("Unable to evaluate project '" + project.getName()
                                        + "' for upgrade-ability: " + logMessage);
                            }
                        }
                        return Status.OK_STATUS;
                    }
                };
                job.schedule();
            }
        } catch (CoreException e) {
            String logMessage = Utils.generateCoreExceptionLog(e);
            logger.warn("Unable to evaluate projects for upgrade-ability: " + logMessage);
        }
View Full Code Here

          JavaProject javaProject = (JavaProject)delta.getElement();
          projectsToTouch[i] = javaProject.getProject();
        }
        if (projectsToTouch.length > 0) {
          if (asynchronous){
            WorkspaceJob touchJob = new WorkspaceJob(Messages.updating_external_archives_jobName) {
             
              public IStatus runInWorkspace(IProgressMonitor progressMonitor) throws CoreException {
                try {
                  if (progressMonitor != null)
                    progressMonitor.beginTask("", projectsToTouch.length); //$NON-NLS-1$
                  touchProjects(projectsToTouch, progressMonitor);
                }
                finally {
                  if (progressMonitor != null)
                    progressMonitor.done();
                }
                return Status.OK_STATUS;
              }
             
              public boolean belongsTo(Object family) {
                return ResourcesPlugin.FAMILY_MANUAL_REFRESH == family;
              }
            };
            touchJob.schedule();
          }
          else {
            // touch the projects to force them to be recompiled while taking the workspace lock
            //   so that there is no concurrency with the Java builder
            // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=96575
View Full Code Here

    @Override
    public boolean performFinish() {
        if (!page.isPageComplete()) {
            return false;
        }
        Job job = new WorkspaceJob("Importing SBT project") {
            @Override
            public IStatus runInWorkspace(IProgressMonitor monitor)
                    throws CoreException {
                IWorkspace workspace = ResourcesPlugin.getWorkspace();
                String name = page.getLoadedProperties().getProperty(
                        "project.name");
                IProjectDescription description = workspace
                        .newProjectDescription(name);
                description.setLocation(new Path(page.getRoot()
                        .getAbsolutePath()));
                description.setNatureIds(new String[] { JavaCore.NATURE_ID });
                IWorkspaceRoot root = workspace.getRoot();
                IProject project = root.getProject(name);
                project.create(description, monitor);
                project.open(monitor);

                new ClasspathRemoverConfigurer(project).run(monitor);
                new DefaultOutputPathConfigurer(project).run(monitor);
                new SourceFoldersConfigurer(project).run(monitor);
                new UnmanagedLibsConfigurer(project).run(monitor);
                new ClasspathContainerConfigurer(
                        SbtClasspathContainer.CLASSPATH_CONTAINER_ID, project)
                        .run(monitor);

                return Status.OK_STATUS;
            }
        };
        job.schedule();
        return true;
    }
View Full Code Here

        txtResult.setText("Executing code...");
        txtResult.update();

        final String code = txtSourceInput.getText();
        // Execute the code in a different thread to allow debugging (since DBGP takes up the main thread)
        WorkspaceJob job = new WorkspaceJob("Execute-Anonymous") {
            @Override
            public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
                ExecuteAnonymousResultExt result = executeAnonymousController.executeExecuteAnonymous(code);
                handleExecuteResults(result);
                return Status.OK_STATUS;
            }
        };
        job.schedule();
    }
View Full Code Here

        projectPackageList.setProject(getProjectModel().getProject());
        projectPackageList.generateComponents(retrieveResultHandler.getZipFile(),
            retrieveResultHandler.getFileMetadataHandler());

        monitorCheckSubTask(monitor, Messages.getString("Components.Saving"));
        WorkspaceJob job =
                new ForceProjectRefreshJob.ForceProjectRefreshProject(projectPackageList,
                        projectPackageList.getProject());
        job.setRule(projectPackageList.getProject());
        job.schedule();

        monitorCheck(monitor);
    }
View Full Code Here

        try {
            event.getDelta().accept(visitor);

            if (Utils.isNotEmpty(projects)) {
                WorkspaceJob job = new WorkspaceJob("Applying updates to newly added Force.com projects") {
                    @Override
                    public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
                        for (IProject project : projects) {
                            if (!serviceLocator.getProjectService().hasCredentials(project)) {
                                OnlineNature.removeNature(project, new NullProgressMonitor());
                                logger.warn("No credentials found for project '" + project.getName()
                                        + "' - removing online nature");
                            }

                        }
                        return Status.OK_STATUS;
                    }
                };
                job.schedule();
            }

        } catch (CoreException e) {
            String logMessage = Utils.generateCoreExceptionLog(e);
            logger.warn("Unable to evaluated added project(s) for builder skip: " + logMessage);
View Full Code Here

      if (i < includePathEntries.length - 1) {
        buf.append(PREF_SEP);
      }
    }
    modifyingIncludePath = true;
    WorkspaceJob job = new WorkspaceJob("Modifying Include Path") { //$NON-NLS-1$
      public IStatus runInWorkspace(IProgressMonitor monitor)
          throws CoreException {
        CorePreferencesSupport.getInstance()
            .setProjectSpecificPreferencesValue(PREF_KEY,
                buf.toString(), project);
        modifyingIncludePath = false;

        // TODO - should not be part of the current job
        refresh(project);
        return Status.OK_STATUS;
      }
    };
    job.setRule(project.getWorkspace().getRoot());
    job.setPriority(WorkspaceJob.INTERACTIVE);
    job.schedule();
  }
View Full Code Here

    try {
      // load all the syntax dictionaries
      DictionaryManager.initDictionaries();

      // startup the image hovers lazily so plugin starts fast
      Job job = new WorkspaceJob("Initializing Image Hovers") {
        public IStatus runInWorkspace(IProgressMonitor monitor) {
          StartupHandler startupHandler = new StartupHandler();
          startupHandler.earlyStartup();
          if (monitor.isCanceled()) return Status.CANCEL_STATUS;
          return Status.OK_STATUS;
        }
      };
      job.schedule(3000);
      // startup the image registry in job so doesn't slow down init
      CFPluginImages.initCFPluginImages();

      setupCAM();
      setupLastEncMgr();
View Full Code Here

TOP

Related Classes of org.eclipse.core.resources.WorkspaceJob

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.