Package org.eclipse.core.resources

Examples of org.eclipse.core.resources.WorkspaceJob


  private static void fireSynchronizeAction(final IWorkbenchWindow window,
      final GitSynchronizeDataSet gsdSet, final ResourceMapping[] mappings) {
    final GitResourceVariantTreeSubscriber subscriber = new GitResourceVariantTreeSubscriber(
        gsdSet);

    Job syncJob = new WorkspaceJob(
        UIText.GitModelSynchronize_fetchGitDataJobName) {

      @Override
      public IStatus runInWorkspace(IProgressMonitor monitor) {
        subscriber.init(monitor);

        return Status.OK_STATUS;
      }
      @Override
      public boolean belongsTo(Object family) {
        if (JobFamilies.SYNCHRONIZE_READ_DATA.equals(family))
          return true;

        return super.belongsTo(family);
      }
    };

    syncJob.addJobChangeListener(new JobChangeAdapter() {
      @Override
      public void done(IJobChangeEvent event) {
        RemoteResourceMappingContext remoteContext = new GitSubscriberResourceMappingContext(subscriber,
            gsdSet);
        SubscriberScopeManager manager = new SubscriberScopeManager(
            subscriber.getName(), mappings, subscriber,
            remoteContext, true);
        GitSubscriberMergeContext context = new GitSubscriberMergeContext(
            subscriber, manager, gsdSet);
        final GitModelSynchronizeParticipant participant = new GitModelSynchronizeParticipant(
            context);

        TeamUI.getSynchronizeManager().addSynchronizeParticipants(
            new ISynchronizeParticipant[] { participant });

        IWorkbenchPart activePart = null;
        if (window != null)
          activePart = window.getActivePage().getActivePart();

        participant.run(activePart);
      }
    });

    syncJob.setUser(true);
    syncJob.schedule();
  }
View Full Code Here


  /**
   * Starts the operation asynchronously showing a confirmation dialog after
   * completion
   */
  public void start() {
    Job job = new WorkspaceJob(NLS.bind(
        UIText.FetchOperationUI_FetchJobName,
        sourceString)) {

      @Override
      public IStatus runInWorkspace(IProgressMonitor monitor) {
        try {
          execute(monitor);
        } catch (CoreException e) {
          return Activator.createErrorStatus(e.getStatus()
              .getMessage(), e);
        }
        return Status.OK_STATUS;
      }

      @Override
      public boolean belongsTo(Object family) {
        if (JobFamilies.FETCH.equals(family))
          return true;
        return super.belongsTo(family);
      }
    };
    job.setUser(true);
    job.schedule();
    job.addJobChangeListener(new JobChangeAdapter() {
      @Override
      public void done(IJobChangeEvent event) {
        if (event.getResult().isOK())
          FetchResultDialog.show(repository, op.getOperationResult(),
              sourceString);
View Full Code Here

    final String textForBranch = branchText.getText();

    storeRunInBackgroundSelection();

    if (runInBackgroud.getSelection()) {
      Job job = new WorkspaceJob(
          UIText.FetchGerritChangePage_GetChangeTaskName) {

        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) {
          internalDoFetch(spec, uri, doCheckout, doCreateTag,
              doCreateBranch, doCheckoutNewBranch,
              doActivateAdditionalRefs,
              textForTag, textForBranch, monitor);
          return org.eclipse.core.runtime.Status.OK_STATUS;
        }

        @Override
        public boolean belongsTo(Object family) {
          if (JobFamilies.FETCH.equals(family))
            return true;
          return super.belongsTo(family);
        }
      };
      job.setUser(true);
      job.schedule();
      return true;
    } else {
      try {
      getWizard().getContainer().run(true, true,
          new IRunnableWithProgress() {
View Full Code Here

    for (RepositoryCommit repoCommit : repoCommits)
      commits.add(repoCommit.getRevCommit());
    final RevertCommitOperation op = new RevertCommitOperation(repo,
        commits);

    Job job = new WorkspaceJob(MessageFormat.format(
        UIText.RevertHandler_JobName, Integer.valueOf(commits.size()))) {

      @Override
      public IStatus runInWorkspace(IProgressMonitor monitor) {
        try {
          op.execute(monitor);
          RevCommit newHead = op.getNewHead();
          List<Ref> revertedRefs = op.getRevertedRefs();
          if (newHead != null && revertedRefs.isEmpty())
            showRevertedDialog(shell);
          if (newHead == null) {
            RevCommit newestUnmergedCommit = null;
            for (RevCommit commit : commits) {
              if (!contains(revertedRefs, commit)) {
                newestUnmergedCommit = commit;
                break;
              }
            }
            showFailureDialog(shell, newestUnmergedCommit,
                op.getFailingResult());
          }
        } catch (CoreException e) {
          Activator.handleError(UIText.RevertOperation_InternalError,
              e, true);
        }
        return Status.OK_STATUS;
      }

      @Override
      public boolean belongsTo(Object family) {
        if (JobFamilies.REVERT_COMMIT.equals(family))
          return true;
        return super.belongsTo(family);
      }
    };
    job.setUser(true);
    job.setRule(op.getSchedulingRule());
    job.schedule();
    return null;
  }
View Full Code Here

    if (!confirmStashDrop(parent, stashIndex))
      return null;

    final StashDropOperation op = new StashDropOperation(repo, stashIndex);

    Job job = new WorkspaceJob(MessageFormat.format(
        UIText.StashApplyCommand_jobTitle, commit.name())) {

      @Override
      public IStatus runInWorkspace(IProgressMonitor monitor) {
        try {
          op.execute(monitor);
        } catch (CoreException e) {
          Activator.logError(MessageFormat.format(
              UIText.StashDropCommand_dropFailed, "stash@{" //$NON-NLS-1$
                  + stashIndex + "}"), e); //$NON-NLS-1$
        }

        return Status.OK_STATUS;
      }

      @Override
      public boolean belongsTo(Object family) {
        if (JobFamilies.STASH.equals(family))
          return true;
        return super.belongsTo(family);
      }
    };
    job.setUser(true);
    job.setRule(op.getSchedulingRule());
    job.schedule();
    return null;
  }
View Full Code Here

      return null;

    final RewordCommitOperation op = new RewordCommitOperation(repo,
        commit, newMessage);

    Job job = new WorkspaceJob(MessageFormat.format(
        UIText.RewordHandler_JobName,
        commit.name())) {

      @Override
      public IStatus runInWorkspace(IProgressMonitor monitor) {
        try {
          op.execute(monitor);
        } catch (CoreException e) {
          Activator.logError(UIText.RewordHandler_InternalError, e);
        }
        return Status.OK_STATUS;
      }

      @Override
      public boolean belongsTo(Object family) {
        if (JobFamilies.REWORD.equals(family))
          return true;
        return super.belongsTo(family);
      }
    };
    job.setUser(true);
    job.setRule(op.getSchedulingRule());
    job.schedule();
    return null;
  }
View Full Code Here

    if (repo == null)
      return null;

    final StashApplyOperation op = new StashApplyOperation(repo, commit);

    Job job = new WorkspaceJob(MessageFormat.format(
        UIText.StashApplyCommand_jobTitle, commit.name())) {

      @Override
      public IStatus runInWorkspace(IProgressMonitor monitor) {
        try {
          op.execute(monitor);
        } catch (CoreException e) {
          return new Status(IStatus.ERROR, Activator.getPluginId(),
              MessageFormat.format(
                  UIText.StashApplyCommand_applyFailed,
                  commit.abbreviate(7).name(),
                  e.getLocalizedMessage()), e);
        }
        return Status.OK_STATUS;
      }

      @Override
      public boolean belongsTo(Object family) {
        if (JobFamilies.STASH.equals(family))
          return true;
        return super.belongsTo(family);
      }
    };
    job.setUser(true);
    job.setRule(op.getSchedulingRule());
    job.schedule();
    return null;
  }
View Full Code Here

    boolean includeUntracked = commitMessageDialog.getIncludeUntracked();

    final StashCreateOperation op = new StashCreateOperation(repo, message,
        includeUntracked);
    Job job = new WorkspaceJob(UIText.StashCreateCommand_jobTitle) {

      @Override
      public IStatus runInWorkspace(IProgressMonitor monitor) {
        monitor.beginTask("", 1); //$NON-NLS-1$
        try {
          op.execute(monitor);
          RevCommit commit = op.getCommit();
          if (commit == null)
            showNoChangesToStash();

        } catch (CoreException e) {
          Activator
              .logError(UIText.StashCreateCommand_stashFailed, e);
        }
        return Status.OK_STATUS;
      }

      @Override
      public boolean belongsTo(Object family) {
        if (JobFamilies.STASH.equals(family))
          return true;
        return super.belongsTo(family);
      }
    };
    job.setUser(true);
    job.setRule(op.getSchedulingRule());
    job.schedule();
    return true;

  }
View Full Code Here

  private void importProjects(final Repository repository,
      final IWorkingSet[] sets) {
    String repoName = Activator.getDefault().getRepositoryUtil()
        .getRepositoryName(repository);
    Job importJob = new WorkspaceJob(MessageFormat.format(
        UIText.GitCloneWizard_jobImportProjects, repoName)) {

      public IStatus runInWorkspace(IProgressMonitor monitor) {
        List<File> files = new ArrayList<File>();
        ProjectUtil.findProjectFiles(files, repository.getWorkTree(),
            true, monitor);
        if (files.isEmpty())
          return Status.OK_STATUS;

        Set<ProjectRecord> records = new LinkedHashSet<ProjectRecord>();
        for (File file : files)
          records.add(new ProjectRecord(file));
        try {
          ProjectUtils.createProjects(records, sets, monitor);
        } catch (InvocationTargetException e) {
          Activator.logError(e.getLocalizedMessage(), e);
        } catch (InterruptedException e) {
          Activator.logError(e.getLocalizedMessage(), e);
        }
        return Status.OK_STATUS;
      }
    };
    importJob.schedule();
  }
View Full Code Here

      return null;
    final DiscardChangesOperation operation = createOperation(part, event);
    if (operation == null)
      return null;
    String jobname = UIText.DiscardChangesAction_discardChanges;
    Job job = new WorkspaceJob(jobname) {
      @Override
      public IStatus runInWorkspace(IProgressMonitor monitor) {
        try {
          operation.execute(monitor);
        } catch (CoreException e) {
          return Activator.createErrorStatus(e.getStatus()
              .getMessage(), e);
        }
        return Status.OK_STATUS;
      }

      @Override
      public boolean belongsTo(Object family) {
        if (JobFamilies.DISCARD_CHANGES.equals(family))
          return true;
        return super.belongsTo(family);
      }
    };
    job.setUser(true);
    job.setRule(operation.getSchedulingRule());
    job.schedule();
    return null;
  }
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.