Search in sources :

Example 1 with CommitUI

use of org.eclipse.egit.ui.internal.commit.CommitUI in project egit by eclipse.

the class CleanupUncomittedChangesDialog method buttonPressed.

@Override
protected void buttonPressed(int buttonId) {
    switch(buttonId) {
        case IDialogConstants.PROCEED_ID:
            CommitUI commitUI = new CommitUI(getShell(), repository, new IResource[0], true);
            shouldContinue = commitUI.commit();
            break;
        case IDialogConstants.ABORT_ID:
            final ResetOperation operation = new ResetOperation(repository, Constants.HEAD, ResetType.HARD);
            String jobname = NLS.bind(UIText.ResetAction_reset, Constants.HEAD);
            JobUtil.scheduleUserWorkspaceJob(operation, jobname, JobFamilies.RESET);
            shouldContinue = true;
            break;
        case IDialogConstants.SKIP_ID:
            StashCreateUI stashCreateUI = new StashCreateUI(repository);
            shouldContinue = stashCreateUI.createStash(getShell());
            break;
        case IDialogConstants.CANCEL_ID:
        default:
            break;
    }
    super.buttonPressed(buttonId);
}
Also used : ResetOperation(org.eclipse.egit.core.op.ResetOperation) StashCreateUI(org.eclipse.egit.ui.internal.stash.StashCreateUI) CommitUI(org.eclipse.egit.ui.internal.commit.CommitUI)

Example 2 with CommitUI

use of org.eclipse.egit.ui.internal.commit.CommitUI 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;
}
Also used : Repository(org.eclipse.jgit.lib.Repository) Shell(org.eclipse.swt.widgets.Shell) StagingView(org.eclipse.egit.ui.internal.staging.StagingView) PartInitException(org.eclipse.ui.PartInitException) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) IResource(org.eclipse.core.resources.IResource) CommitUI(org.eclipse.egit.ui.internal.commit.CommitUI)

Aggregations

CommitUI (org.eclipse.egit.ui.internal.commit.CommitUI)2 IResource (org.eclipse.core.resources.IResource)1 ResetOperation (org.eclipse.egit.core.op.ResetOperation)1 StagingView (org.eclipse.egit.ui.internal.staging.StagingView)1 StashCreateUI (org.eclipse.egit.ui.internal.stash.StashCreateUI)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 Repository (org.eclipse.jgit.lib.Repository)1 Shell (org.eclipse.swt.widgets.Shell)1 PartInitException (org.eclipse.ui.PartInitException)1