use of org.eclipse.egit.ui.internal.commit.CommitEditor in project egit by eclipse.
the class StashDropHandler 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 Shell parent = getPart(event).getSite().getShell();
final int stashIndex = getStashIndex(repo, commit.getId());
if (!confirmStashDrop(parent, stashIndex))
return null;
final StashDropOperation op = new StashDropOperation(repo, stashIndex);
Job job = new WorkspaceJob(MessageFormat.format(UIText.StashDropCommand_jobTitle, commit.name())) {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) {
try {
op.execute(monitor);
} catch (CoreException e) {
Activator.logError(MessageFormat.format(UIText.StashDropCommand_dropFailed, // $NON-NLS-1$
"stash@{" + stashIndex + "}"), // $NON-NLS-1$
e);
}
return Status.OK_STATUS;
}
@Override
public boolean belongsTo(Object family) {
if (JobFamilies.STASH.equals(family))
return true;
return super.belongsTo(family);
}
};
final IWorkbenchPart part = getPart(event);
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
if (event.getResult().isOK()) {
if (part instanceof CommitEditor) {
((CommitEditor) part).close(false);
}
}
}
});
job.setUser(true);
job.setRule(op.getSchedulingRule());
job.schedule();
return null;
}
use of org.eclipse.egit.ui.internal.commit.CommitEditor in project egit by eclipse.
the class CommitEditorTest method openAllEditorPagesOnValidCommit.
@Test
public void openAllEditorPagesOnValidCommit() throws Exception {
final AtomicReference<IEditorPart> editorRef = new AtomicReference<>();
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
RepositoryCommit repoCommit = new RepositoryCommit(repository, commit);
editorRef.set(CommitEditor.openQuiet(repoCommit));
}
});
assertNotNull(editorRef.get());
IEditorPart editor = editorRef.get();
assertTrue(editor instanceof CommitEditor);
RepositoryCommit adaptedCommit = Utils.getAdapter(editor, RepositoryCommit.class);
assertNotNull(adaptedCommit);
assertEquals(commit, adaptedCommit.getRevCommit());
assertEquals(repository.getDirectory(), adaptedCommit.getRepository().getDirectory());
IEditorInput input = editor.getEditorInput();
assertNotNull(input);
SWTBotMultiPageEditor botEditor = bot.multipageEditorByTitle(input.getName());
assertNotNull(botEditor);
assertTrue(botEditor.getPageCount() > 1);
for (String name : botEditor.getPagesTitles()) botEditor.activatePage(name);
botEditor.close();
}
Aggregations