Search in sources :

Example 1 with CleanupUncomittedChangesDialog

use of org.eclipse.egit.ui.internal.branch.CleanupUncomittedChangesDialog in project egit by eclipse.

the class PullOperationUI method handleUncommittedChanges.

/**
 * @param repository
 * @param files
 *            uncommitted files that were in the way for the rebase
 * @param shell
 */
private void handleUncommittedChanges(final Repository repository, final List<String> files, Shell shell) {
    String repoName = Activator.getDefault().getRepositoryUtil().getRepositoryName(repository);
    CleanupUncomittedChangesDialog cleanupUncomittedChangesDialog = new CleanupUncomittedChangesDialog(shell, MessageFormat.format(UIText.AbstractRebaseCommandHandler_cleanupDialog_title, repoName), UIText.AbstractRebaseCommandHandler_cleanupDialog_text, repository, files);
    cleanupUncomittedChangesDialog.open();
    if (cleanupUncomittedChangesDialog.shouldContinue()) {
        final PullOperationUI parentOperation = this;
        final PullOperationUI pullOperationUI = new PullOperationUI(Collections.singleton(repository));
        pullOperationUI.checkForLaunches = false;
        tasksToWaitFor.incrementAndGet();
        pullOperationUI.start(new JobChangeAdapter() {

            @Override
            public void done(IJobChangeEvent event) {
                // put the result from this subtask into the result map of
                // the outer PullOperationUI and display the results if all
                // subtasks have reported back
                parentOperation.results.putAll(pullOperationUI.results);
                int missing = parentOperation.tasksToWaitFor.decrementAndGet();
                if (missing == 0)
                    parentOperation.showResults();
            }
        });
    }
}
Also used : CleanupUncomittedChangesDialog(org.eclipse.egit.ui.internal.branch.CleanupUncomittedChangesDialog) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent)

Example 2 with CleanupUncomittedChangesDialog

use of org.eclipse.egit.ui.internal.branch.CleanupUncomittedChangesDialog in project egit by eclipse.

the class UIRepositoryUtils method handleUncommittedFiles.

/**
 * Checks the repository to see if there are uncommitted changes, and
 * prompts the user to clean them up.
 *
 * @param repo
 *            the repository
 * @param shell
 *            the parent shell for opening the dialog
 * @param dialogTitle
 *            the dialog title
 * @return true if the git status was clean or it was dirty and the user
 *         cleaned up the uncommitted changes and the previous action may
 *         continue
 * @throws GitAPIException
 *             if there was an error checking the repository
 */
public static boolean handleUncommittedFiles(Repository repo, Shell shell, String dialogTitle) throws GitAPIException {
    Status status = null;
    try (Git git = new Git(repo)) {
        status = git.status().call();
    }
    if (status != null && status.hasUncommittedChanges()) {
        List<String> files = new ArrayList<>(status.getModified());
        Collections.sort(files);
        CleanupUncomittedChangesDialog cleanupUncomittedChangesDialog = new CleanupUncomittedChangesDialog(shell, dialogTitle, UIText.AbstractRebaseCommandHandler_cleanupDialog_text, repo, files);
        cleanupUncomittedChangesDialog.open();
        return cleanupUncomittedChangesDialog.shouldContinue();
    } else
        return true;
}
Also used : Status(org.eclipse.jgit.api.Status) CleanupUncomittedChangesDialog(org.eclipse.egit.ui.internal.branch.CleanupUncomittedChangesDialog) Git(org.eclipse.jgit.api.Git) ArrayList(java.util.ArrayList)

Example 3 with CleanupUncomittedChangesDialog

use of org.eclipse.egit.ui.internal.branch.CleanupUncomittedChangesDialog in project egit by eclipse.

the class FeatureCheckoutHandler method handleUncommittedFiles.

private boolean handleUncommittedFiles(Repository repo, Shell shell, String repoName) throws GitAPIException {
    try (Git git = new Git(repo)) {
        org.eclipse.jgit.api.Status status = git.status().call();
        if (status.hasUncommittedChanges()) {
            List<String> files = new ArrayList<String>(status.getUncommittedChanges());
            Collections.sort(files);
            CleanupUncomittedChangesDialog cleanupUncomittedChangesDialog = new CleanupUncomittedChangesDialog(shell, MessageFormat.format(UIText.FeatureCheckoutHandler_cleanupDialog_title, repoName), UIText.FeatureCheckoutHandler_cleanupDialog_text, repo, files);
            cleanupUncomittedChangesDialog.open();
            return cleanupUncomittedChangesDialog.shouldContinue();
        } else {
            return true;
        }
    }
}
Also used : CleanupUncomittedChangesDialog(org.eclipse.egit.ui.internal.branch.CleanupUncomittedChangesDialog) Git(org.eclipse.jgit.api.Git) ArrayList(java.util.ArrayList)

Aggregations

CleanupUncomittedChangesDialog (org.eclipse.egit.ui.internal.branch.CleanupUncomittedChangesDialog)3 ArrayList (java.util.ArrayList)2 Git (org.eclipse.jgit.api.Git)2 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)1 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)1 Status (org.eclipse.jgit.api.Status)1