use of org.eclipse.egit.ui.internal.staging.StagingView in project egit by eclipse.
the class CommitActionStagingViewTest method testOpenStagingViewNoLinkWithSelection.
@Test
public void testOpenStagingViewNoLinkWithSelection() throws Exception {
setTestFileContent("I have changed this");
SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
util.getProjectItems(projectExplorerTree, PROJ1)[0].select();
String menuString = util.getPluginLocalizedValue("CommitAction_label");
ContextMenuHelper.clickContextMenu(projectExplorerTree, "Team", menuString);
TestUtil.joinJobs(ADD_TO_INDEX);
TestUtil.waitUntilViewWithGivenIdShows(StagingView.VIEW_ID);
final Repository[] repo = { null };
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
StagingView view;
try {
view = (StagingView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(StagingView.VIEW_ID);
repo[0] = view.getCurrentRepository();
} catch (PartInitException e) {
// Ignore, repo[0] remains null
}
}
});
Repository repository = lookupRepository(repositoryFile);
assertNotNull("No repository found", repository);
assertEquals("Repository mismatch", repository, repo[0]);
}
use of org.eclipse.egit.ui.internal.staging.StagingView in project egit by eclipse.
the class CommitViewerComparator method openStagingViewLinkClicked.
private void openStagingViewLinkClicked() {
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
try {
StagingView view = (StagingView) workbenchPage.showView(StagingView.VIEW_ID);
view.reload(repository);
String message = commitMessageComponent.getCommitMessage();
if (message != null && message.length() > 0)
view.setCommitMessage(message);
setReturnCode(CANCEL);
close();
} catch (PartInitException e) {
Activator.handleError(UIText.CommitDialog_OpenStagingViewError, e, true);
}
}
use of org.eclipse.egit.ui.internal.staging.StagingView in project egit by eclipse.
the class AbstractRebaseCommandHandler method startRebaseJob.
private void startRebaseJob(final RebaseOperation rebase, final Repository repository, final RebaseCommand.Operation operation) {
JobUtil.scheduleUserWorkspaceJob(rebase, jobname, JobFamilies.REBASE, new JobChangeAdapter() {
@Override
public void aboutToRun(IJobChangeEvent event) {
// that repository state is safe
if (operation == Operation.BEGIN && !repository.getRepositoryState().equals(RepositoryState.SAFE)) {
throw new IllegalStateException(// $NON-NLS-1$
"Can't start rebase if repository state isn't SAFE");
}
super.aboutToRun(event);
}
@Override
public void done(IJobChangeEvent cevent) {
finishRebaseInteractive();
IStatus result = cevent.getJob().getResult();
if (result == null) {
return;
}
// abort and show exception
if (operation == Operation.BEGIN && result.getSeverity() == IStatus.ERROR) {
handleBeginError(repository, result);
} else if (result.getSeverity() == IStatus.CANCEL)
Display.getDefault().asyncExec(new Runnable() {
@Override
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.AbstractRebaseCommand_DialogTitle, dialogMessage);
}
});
else if (result.isOK()) {
if (rebase.getResult().getStatus() == Status.UNCOMMITTED_CHANGES) {
handleUncommittedChanges(repository, rebase.getResult().getUncommittedChanges());
} else {
RebaseResultDialog.show(rebase.getResult(), repository);
if (operation == Operation.ABORT)
setAmending(false, false);
if (rebase.getResult().getStatus() == Status.EDIT)
setAmending(true, true);
}
}
}
private void setAmending(final boolean amending, final boolean openStagingView) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
try {
IViewPart view;
if (openStagingView)
view = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(StagingView.VIEW_ID);
else
view = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(StagingView.VIEW_ID);
if (view instanceof StagingView) {
final StagingView sv = (StagingView) view;
sv.reload(repository);
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
sv.setAmending(amending);
}
});
}
} catch (PartInitException e) {
Activator.logError(e.getMessage(), e);
}
}
});
}
private void finishRebaseInteractive() {
RebaseInteractivePlan plan = RebaseInteractivePlan.getPlan(repository);
if (plan != null && !plan.isRebasingInteractive())
plan.dispose();
}
});
}
use of org.eclipse.egit.ui.internal.staging.StagingView in project egit by eclipse.
the class EditHandler method openStagingAndRebaseInteractiveViews.
private void openStagingAndRebaseInteractiveViews(final Repository repository) {
Job job = new UIJob(UIText.EditHandler_OpenStagingAndRebaseInteractiveViews) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
try {
IWorkbenchPage workbenchPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
final StagingView stagingView = (StagingView) workbenchPage.showView(StagingView.VIEW_ID);
stagingView.reload(repository);
stagingView.setAmending(true);
RebaseInteractiveView rebaseView = (RebaseInteractiveView) workbenchPage.showView(RebaseInteractiveView.VIEW_ID);
rebaseView.setInput(repository);
} catch (PartInitException e) {
Activator.logError(e.getMessage(), e);
}
return Status.OK_STATUS;
}
};
job.setRule(RuleUtil.getRule(repository));
job.setUser(true);
job.schedule();
}
use of org.eclipse.egit.ui.internal.staging.StagingView in project egit by eclipse.
the class CommitActionHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final Repository repository = getRepository(true, event);
if (repository == null) {
return null;
}
IPreferenceStore uiPreferences = Activator.getDefault().getPreferenceStore();
boolean useStagingView = uiPreferences.getBoolean(UIPreferences.ALWAYS_USE_STAGING_VIEW);
if (useStagingView) {
if (uiPreferences.getBoolean(UIPreferences.AUTO_STAGE_ON_COMMIT)) {
boolean includeUntracked = uiPreferences.getBoolean(UIPreferences.COMMIT_DIALOG_INCLUDE_UNTRACKED);
autoStage(repository, includeUntracked, getResourcesInScope(event));
}
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
try {
StagingView view = (StagingView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(StagingView.VIEW_ID);
if (view.getCurrentRepository() != repository) {
view.reload(repository);
}
view.setFocus();
} catch (PartInitException e) {
Activator.logError(e.getMessage(), e);
}
}
});
} else {
final Shell shell = getShell(event);
IResource[] resourcesInScope = getResourcesInScope(event);
if (resourcesInScope != null) {
CommitUI commitUi = new CommitUI(shell, repository, resourcesInScope, false);
commitUi.commit();
}
}
return null;
}
Aggregations