use of org.eclipse.egit.core.op.StashApplyOperation in project egit by eclipse.
the class StashApplyHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final RevCommit commit = getSelectedItem(RevCommit.class, event);
if (commit == null)
return null;
Repository repo = getSelectedItem(Repository.class, event);
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;
}
use of org.eclipse.egit.core.op.StashApplyOperation in project egit by eclipse.
the class StashApplyCommand method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
List<StashedCommitNode> nodes = getSelectedNodes(event);
if (nodes.isEmpty())
return null;
Repository repo = nodes.get(0).getRepository();
if (repo == null)
return null;
final RevCommit commit = nodes.get(0).getObject();
if (commit == 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;
}
Aggregations