Package org.eclipse.egit.core.op

Examples of org.eclipse.egit.core.op.DiscardChangesOperation


    boolean performAction = MessageDialog.openConfirm(getShell(event),
        UIText.DiscardChangesAction_confirmActionTitle,
        UIText.DiscardChangesAction_confirmActionMessage);
    if (!performAction)
      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


      // ignore, we will not discard the files in case the user
      // cancels the scope operation
      return null;
    }

    return new DiscardChangesOperation(resourcesInScope, revision);

  }
View Full Code Here

    IFile file2 = project.getFile(new Path("folder1/file2.txt"));
    contents = testUtils.slurpAndClose(file2.getContents());
    assertEquals("Hello world 2", contents);
    setNewFileContent(file2, "changed 2");

    DiscardChangesOperation dcop = new DiscardChangesOperation(
        new IResource[] { file1, file2 });
    dcop.execute(new NullProgressMonitor());

    contents = testUtils.slurpAndClose(file1.getContents());
    assertEquals("Hello world 1", contents);

    contents = testUtils.slurpAndClose(file2.getContents());
View Full Code Here

    IFile file = project2.getFile(new Path("file.txt"));
    String contents = testUtils.slurpAndClose(file.getContents());
    assertEquals("initial", contents);
    setNewFileContent(file, "changed");

    DiscardChangesOperation dcop = new DiscardChangesOperation(new IResource[] { project2 });
    dcop.execute(new NullProgressMonitor());

    String replacedContents = testUtils.slurpAndClose(file.getContents());
    assertEquals("initial", replacedContents);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.egit.core.op.DiscardChangesOperation

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.