Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2016-07-09 17:06:13 +0000
committerMatthias Sohn2016-09-05 21:33:48 +0000
commit5369c472551e573c7756abe5f7c72748ba4f8541 (patch)
treea70ad4ad8de70a4b360349e2795a4afe828c34ab /org.eclipse.egit.ui/src/org/eclipse/egit/ui
parentc01903674b8d1a2f25bc133a2fe5ce4e228632a7 (diff)
downloadegit-5369c472551e573c7756abe5f7c72748ba4f8541.tar.gz
egit-5369c472551e573c7756abe5f7c72748ba4f8541.tar.xz
egit-5369c472551e573c7756abe5f7c72748ba4f8541.zip
Check for running launches before modifying the workspace
Check before: * any checkout * any pull * any rebase, including when an interactive rebase is started * any merge * reset --hard * replace with ... * cherry-pick Bug: 495777 Change-Id: Ie7e325f363f4497f873694c419d5352fe269a89e Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse/egit/ui')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java11
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/DiscardChangesActionHandler.java22
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/MergeActionHandler.java13
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetMenu.java44
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/branch/BranchOperationUI.java89
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/branch/LaunchFinder.java153
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/AbstractRebaseCommandHandler.java7
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/ProcessStepsRebaseCommand.java8
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/RebaseCurrentRefCommand.java8
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/command/CherryPickHandler.java23
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangePage.java8
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/MergeHandler.java10
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/RebaseCurrentHandler.java10
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ResetHandler.java10
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/PullOperationUI.java33
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/command/ResetHandler.java10
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/MergeCommand.java13
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ResetCommand.java56
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java23
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties13
20 files changed, 359 insertions, 205 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
index 05c1c0d93c..637da7bedc 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
@@ -3094,16 +3094,19 @@ public class UIText extends NLS {
public static String BranchOperationUI_DetachedHeadMessage;
/** */
- public static String BranchOperationUI_RunningLaunchDontShowAgain;
+ public static String LaunchFinder_RunningLaunchDontShowAgain;
/** */
- public static String BranchOperationUI_RunningLaunchMessage;
+ public static String LaunchFinder_RunningLaunchMessage;
/** */
- public static String BranchOperationUI_RunningLaunchTitle;
+ public static String LaunchFinder_RunningLaunchTitle;
/** */
- public static String BranchOperationUI_SearchLaunchConfiguration;
+ public static String LaunchFinder_SearchLaunchConfiguration;
+
+ /** */
+ public static String LaunchFinder_ContinueQuestion;
/** */
public static String BranchRenameDialog_Message;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/DiscardChangesActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/DiscardChangesActionHandler.java
index 165a186cbf..eedde27e65 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/DiscardChangesActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/DiscardChangesActionHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (C) 2010, 2013 Roland Grunberg <rgrunber@redhat.com>
+ * Copyright (C) 2010, 2016 Roland Grunberg <rgrunber@redhat.com> and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,9 +9,13 @@
* Contributors:
* Benjamin Muskalla (Tasktop Technologies Inc.) - support for model scoping
* François Rey <eclipse.org_@_francois_._rey_._name> - handling of linked resources
+ * Thomas Wolf <thomas.wolf@paranor.ch> - Bug 495777
*******************************************************************************/
package org.eclipse.egit.ui.internal.actions;
+import java.text.MessageFormat;
+import java.util.Arrays;
+
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IResource;
@@ -22,10 +26,12 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.egit.core.op.DiscardChangesOperation;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.internal.UIText;
+import org.eclipse.egit.ui.internal.branch.LaunchFinder;
import org.eclipse.egit.ui.internal.operations.GitScopeUtil;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jgit.lib.Repository;
@@ -41,9 +47,21 @@ public class DiscardChangesActionHandler extends RepositoryActionHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart part = getPart(event);
+ String question = UIText.DiscardChangesAction_confirmActionMessage;
+ ILaunchConfiguration launch = LaunchFinder
+ .getRunningLaunchConfiguration(Arrays.asList(getRepositories()),
+ null);
+ if (launch != null) {
+ question = MessageFormat.format(question,
+ "\n\n" + MessageFormat.format( //$NON-NLS-1$
+ UIText.LaunchFinder_RunningLaunchMessage,
+ launch.getName()));
+ } else {
+ question = MessageFormat.format(question, ""); //$NON-NLS-1$
+ }
boolean performAction = MessageDialog.openConfirm(getShell(event),
UIText.DiscardChangesAction_confirmActionTitle,
- UIText.DiscardChangesAction_confirmActionMessage);
+ question);
if (!performAction)
return null;
final DiscardChangesOperation operation = createOperation(part, event);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/MergeActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/MergeActionHandler.java
index 96940b62c7..e004e48570 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/MergeActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/MergeActionHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 SAP AG.
+ * Copyright (c) 2010, 2016 SAP AG and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Stefan Lay (SAP AG) - initial implementation
+ * Thomas Wolf <thomas.wolf@paranor.ch> - Bug 495777
*******************************************************************************/
package org.eclipse.egit.ui.internal.actions;
@@ -26,6 +27,7 @@ import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.egit.core.op.MergeOperation;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.internal.UIText;
+import org.eclipse.egit.ui.internal.branch.LaunchFinder;
import org.eclipse.egit.ui.internal.dialogs.BasicConfigurationDialog;
import org.eclipse.egit.ui.internal.dialogs.MergeTargetSelectionDialog;
import org.eclipse.egit.ui.internal.merge.MergeResultDialog;
@@ -48,11 +50,12 @@ public class MergeActionHandler extends RepositoryActionHandler {
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final Repository repository = getRepository(true, event);
- if (repository == null)
- return null;
-
- if (!checkMergeIsPossible(repository, getShell(event)))
+ if (repository == null
+ || !checkMergeIsPossible(repository, getShell(event))
+ || LaunchFinder.shouldCancelBecauseOfRunningLaunches(repository,
+ null)) {
return null;
+ }
BasicConfigurationDialog.show(repository);
MergeTargetSelectionDialog mergeTargetSelectionDialog = new MergeTargetSelectionDialog(
getShell(event), repository);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetMenu.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetMenu.java
index f96cc270fe..27ce7593fe 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetMenu.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetMenu.java
@@ -1,30 +1,35 @@
/*******************************************************************************
- * Copyright (C) 2014, Konrad Kügler <swamblumat-eclipsebugs@yahoo.de> and others.
+ * Copyright (C) 2014, 2016 Konrad Kügler <swamblumat-eclipsebugs@yahoo.de> and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Thomas Wolf <thomas.wolf@paranor.ch> - Bug 495777
*******************************************************************************/
package org.eclipse.egit.ui.internal.actions;
+import java.text.MessageFormat;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.egit.core.internal.job.JobUtil;
import org.eclipse.egit.core.op.ResetOperation;
import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.internal.UIIcons;
import org.eclipse.egit.ui.internal.UIText;
+import org.eclipse.egit.ui.internal.branch.LaunchFinder;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jgit.api.ResetCommand.ResetType;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.menus.CommandContributionItem;
import org.eclipse.ui.menus.CommandContributionItemParameter;
@@ -76,26 +81,35 @@ public class ResetMenu {
}
/**
- * @param event
+ * @param shell
* @param repo
* @param commitId
- * @param resetMode
- * @throws ExecutionException
+ * @param resetType
*/
- public static void performReset(ExecutionEvent event,
- final Repository repo, final ObjectId commitId, String resetMode)
- throws ExecutionException {
- final ResetType resetType = ResetType.valueOf(resetMode);
+ public static void performReset(Shell shell,
+ final Repository repo, final ObjectId commitId,
+ ResetType resetType) {
final String jobName;
switch (resetType) {
case HARD:
- if (!MessageDialog.openQuestion(
- HandlerUtil.getActiveShellChecked(event),
+ String question = UIText.ResetTargetSelectionDialog_ResetConfirmQuestion;
+ ILaunchConfiguration launch = LaunchFinder
+ .getRunningLaunchConfiguration(Collections.singleton(repo),
+ null);
+ if (launch != null) {
+ question = MessageFormat.format(question,
+ "\n\n" + MessageFormat.format( //$NON-NLS-1$
+ UIText.LaunchFinder_RunningLaunchMessage,
+ launch.getName()));
+ } else {
+ question = MessageFormat.format(question, ""); //$NON-NLS-1$
+ }
+ if (!MessageDialog.openQuestion(shell,
UIText.ResetTargetSelectionDialog_ResetQuestion,
- UIText.ResetTargetSelectionDialog_ResetConfirmQuestion))
+ question)) {
return;
-
+ }
jobName = UIText.HardResetToRevisionAction_hardReset;
break;
case SOFT:
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/branch/BranchOperationUI.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/branch/BranchOperationUI.java
index 079bf31bc4..36b075a693 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/branch/BranchOperationUI.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/branch/BranchOperationUI.java
@@ -12,13 +12,8 @@
package org.eclipse.egit.ui.internal.branch;
import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Arrays;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
-import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -31,9 +26,7 @@ import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.egit.core.RepositoryUtil;
-import org.eclipse.egit.core.internal.util.ProjectUtil;
import org.eclipse.egit.core.op.BranchOperation;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
@@ -45,8 +38,6 @@ import org.eclipse.egit.ui.internal.repository.CreateBranchWizard;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.operation.ModalContext;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jgit.annotations.NonNull;
@@ -55,7 +46,6 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.PlatformUI;
@@ -130,7 +120,8 @@ public class BranchOperationUI {
return null;
}
- if (shouldCancelBecauseOfRunningLaunches(monitor)) {
+ if (LaunchFinder.shouldCancelBecauseOfRunningLaunches(repository,
+ monitor)) {
return null;
}
@@ -396,80 +387,4 @@ public class BranchOperationUI {
});
}
- private boolean shouldCancelBecauseOfRunningLaunches(
- IProgressMonitor monitor) {
- if (!showQuestionsBeforeCheckout) {
- return false;
- }
- final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
- if (!store.getBoolean(
- UIPreferences.SHOW_RUNNING_LAUNCH_ON_CHECKOUT_WARNING)) {
- return false;
- }
- final ILaunchConfiguration launchConfiguration = getRunningLaunchConfiguration(monitor);
- if (launchConfiguration != null) {
- final boolean[] dialogResult = new boolean[1];
- PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
- @Override
- public void run() {
- dialogResult[0] = showContinueDialogInUI(store,
- launchConfiguration);
- }
- });
- return dialogResult[0];
- }
- return false;
- }
-
- private boolean showContinueDialogInUI(final IPreferenceStore store,
- final ILaunchConfiguration launchConfiguration) {
- String[] buttons = new String[] { UIText.BranchOperationUI_Continue,
- IDialogConstants.CANCEL_LABEL };
- String message = NLS.bind(
- UIText.BranchOperationUI_RunningLaunchMessage,
- launchConfiguration.getName());
- MessageDialogWithToggle continueDialog = new MessageDialogWithToggle(
- getShell(), UIText.BranchOperationUI_RunningLaunchTitle, null,
- message, MessageDialog.NONE, buttons, 0,
- UIText.BranchOperationUI_RunningLaunchDontShowAgain, false);
- int result = continueDialog.open();
- // cancel
- if (result == IDialogConstants.CANCEL_ID || result == SWT.DEFAULT)
- return true;
- boolean dontWarnAgain = continueDialog.getToggleState();
- if (dontWarnAgain)
- store.setValue(
- UIPreferences.SHOW_RUNNING_LAUNCH_ON_CHECKOUT_WARNING,
- false);
- return false;
- }
-
- private ILaunchConfiguration getRunningLaunchConfiguration(
- IProgressMonitor monitor) {
- final ILaunchConfiguration[] result = { null };
- IRunnableWithProgress operation = new IRunnableWithProgress() {
-
- @Override
- public void run(IProgressMonitor m)
- throws InvocationTargetException, InterruptedException {
- Set<IProject> projects = new HashSet<>(
- Arrays.asList(ProjectUtil.getProjects(repository)));
- result[0] = LaunchFinder.findLaunch(projects, m);
- }
- };
- try {
- if (ModalContext.isModalContextThread(Thread.currentThread())) {
- operation.run(monitor);
- } else {
- ModalContext.run(operation, true, monitor,
- PlatformUI.getWorkbench().getDisplay());
- }
- } catch (InvocationTargetException e) {
- // ignore
- } catch (InterruptedException e) {
- // ignore
- }
- return result[0];
- }
-
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/branch/LaunchFinder.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/branch/LaunchFinder.java
index 77e3e62b90..89e716d66b 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/branch/LaunchFinder.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/branch/LaunchFinder.java
@@ -10,6 +10,11 @@
*******************************************************************************/
package org.eclipse.egit.ui.internal.branch;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.resources.IProject;
@@ -24,8 +29,21 @@ import org.eclipse.debug.core.model.ISourceLocator;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer;
+import org.eclipse.egit.core.internal.util.ProjectUtil;
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.internal.UIText;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.operation.ModalContext;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jgit.annotations.Nullable;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.ui.PlatformUI;
/**
* Utility class for finding launch configurations.
@@ -37,23 +55,57 @@ public final class LaunchFinder {
}
/**
- * If there is a running launch covering one of the given projects, return
- * the first such launch configuration.
+ * If there is a running launch covering at least one project from the given
+ * repositories, return the first such launch configuration.
*
- * @param projects
- * to check for
+ * @param repositories
+ * to determine projects to be checked whether they are used in
+ * running launches
* @param monitor
* for progress reporting and cancellation
- * @return the launch configuration, or {@code null} if none found.
+ * @return the {@link ILaunchConfiguration}, or {@code null} if none found.
*/
@Nullable
- public static ILaunchConfiguration findLaunch(Set<IProject> projects,
+ public static ILaunchConfiguration getRunningLaunchConfiguration(
+ final Collection<Repository> repositories,
+ IProgressMonitor monitor) {
+ SubMonitor progress = SubMonitor.convert(monitor, 1);
+ final ILaunchConfiguration[] result = { null };
+ IRunnableWithProgress operation = new IRunnableWithProgress() {
+
+ @Override
+ public void run(IProgressMonitor m)
+ throws InvocationTargetException, InterruptedException {
+ Set<IProject> projects = new HashSet<>();
+ for (Repository repository : repositories) {
+ projects.addAll(
+ Arrays.asList(ProjectUtil.getProjects(repository)));
+ }
+ result[0] = findLaunch(projects, m);
+ }
+ };
+ try {
+ if (ModalContext.isModalContextThread(Thread.currentThread())) {
+ operation.run(progress);
+ } else {
+ ModalContext.run(operation, true, progress,
+ PlatformUI.getWorkbench().getDisplay());
+ }
+ } catch (InvocationTargetException e) {
+ // ignore
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ return result[0];
+ }
+
+ private static ILaunchConfiguration findLaunch(Set<IProject> projects,
IProgressMonitor monitor) {
ILaunchManager launchManager = DebugPlugin.getDefault()
.getLaunchManager();
ILaunch[] launches = launchManager.getLaunches();
SubMonitor progress = SubMonitor.convert(monitor,
- UIText.BranchOperationUI_SearchLaunchConfiguration,
+ UIText.LaunchFinder_SearchLaunchConfiguration,
launches.length);
for (ILaunch launch : launches) {
if (progress.isCanceled()) {
@@ -107,4 +159,91 @@ public final class LaunchFinder {
return false;
}
+ /**
+ * Checks whether there are any running launches based on projects belonging
+ * to the given repository. If so, asks the user whether to cancel, and
+ * returns the user's choice. The user has the possibility to suppress the
+ * dialog, in which case this method returns {@code false} without checking
+ * for running launches.
+ *
+ * @param repository
+ * to determine projects to be checked whether they are used in
+ * running launches
+ * @param monitor
+ * for progress reporting and cancellation
+ * @return {@code true} if the operation should be canceled, {@code false}
+ * otherwise
+ */
+ public static boolean shouldCancelBecauseOfRunningLaunches(
+ Repository repository, IProgressMonitor monitor) {
+ return shouldCancelBecauseOfRunningLaunches(
+ Collections.singleton(repository), monitor);
+ }
+
+ /**
+ * Checks whether there are any running launches based on projects belonging
+ * to the given repositories. If so, asks the user whether to cancel, and
+ * returns the user's choice. The user has the possibility to suppress the
+ * dialog, in which case this method returns {@code false} without checking
+ * for running launches.
+ *
+ * @param repositories
+ * to determine projects to be checked whether they are used in
+ * running launches
+ * @param monitor
+ * for progress reporting and cancellation
+ * @return {@code true} if the operation should be canceled, {@code false}
+ * otherwise
+ */
+ public static boolean shouldCancelBecauseOfRunningLaunches(
+ Collection<Repository> repositories, IProgressMonitor monitor) {
+ final IPreferenceStore store = Activator.getDefault()
+ .getPreferenceStore();
+ if (!store.getBoolean(
+ UIPreferences.SHOW_RUNNING_LAUNCH_ON_CHECKOUT_WARNING)) {
+ return false;
+ }
+ SubMonitor progress = SubMonitor.convert(monitor);
+ final ILaunchConfiguration launchConfiguration = getRunningLaunchConfiguration(
+ repositories,
+ progress);
+ if (launchConfiguration != null) {
+ final boolean[] dialogResult = new boolean[1];
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ dialogResult[0] = showContinueDialogInUI(store,
+ launchConfiguration);
+ }
+ });
+ return dialogResult[0];
+ }
+ return false;
+ }
+
+ private static boolean showContinueDialogInUI(final IPreferenceStore store,
+ final ILaunchConfiguration launchConfiguration) {
+ String[] buttons = new String[] { UIText.BranchOperationUI_Continue,
+ IDialogConstants.CANCEL_LABEL };
+ String message = NLS.bind(UIText.LaunchFinder_RunningLaunchMessage,
+ launchConfiguration.getName()) + ' '
+ + UIText.LaunchFinder_ContinueQuestion;
+ MessageDialogWithToggle continueDialog = new MessageDialogWithToggle(
+ PlatformUI.getWorkbench().getModalDialogShellProvider()
+ .getShell(),
+ UIText.LaunchFinder_RunningLaunchTitle, null,
+ message, MessageDialog.NONE, buttons, 0,
+ UIText.LaunchFinder_RunningLaunchDontShowAgain, false);
+ int result = continueDialog.open();
+ // cancel
+ if (result == IDialogConstants.CANCEL_ID || result == SWT.DEFAULT)
+ return true;
+ boolean dontWarnAgain = continueDialog.getToggleState();
+ if (dontWarnAgain)
+ store.setValue(
+ UIPreferences.SHOW_RUNNING_LAUNCH_ON_CHECKOUT_WARNING,
+ false);
+ return false;
+ }
+
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/AbstractRebaseCommandHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/AbstractRebaseCommandHandler.java
index f33dd63ff3..49b4e414c8 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/AbstractRebaseCommandHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/AbstractRebaseCommandHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2014 SAP AG and others.
+ * Copyright (c) 2010, 2016 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Mathias Kinzler (SAP AG) - initial implementation
+ * Thomas Wolf <thomas.wolf@paranor.ch> - Bug 495777
*******************************************************************************/
package org.eclipse.egit.ui.internal.commands.shared;
@@ -233,7 +234,9 @@ public abstract class AbstractRebaseCommandHandler extends AbstractSharedCommand
*/
public void execute(Repository repository) throws ExecutionException {
final RebaseOperation rebase = createRebaseOperation(repository);
- execute(rebase);
+ if (rebase != null) {
+ execute(rebase);
+ }
}
private void handleBeginError(final Repository repository, IStatus result) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/ProcessStepsRebaseCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/ProcessStepsRebaseCommand.java
index 568fb7471c..c8d43ba5fc 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/ProcessStepsRebaseCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/ProcessStepsRebaseCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 SAP AG.
+ * Copyright (c) 2013, 2016 SAP AG and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,12 +7,14 @@
*
* Contributors:
* Tobias Pfeifer (SAP AG) - initial implementation
+ * Thomas Wolf <thomas.wolf@paranor.ch> - Bug 495777
*******************************************************************************/
package org.eclipse.egit.ui.internal.commands.shared;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.egit.core.op.RebaseOperation;
import org.eclipse.egit.ui.internal.UIText;
+import org.eclipse.egit.ui.internal.branch.LaunchFinder;
import org.eclipse.egit.ui.internal.rebase.RebaseInteractiveHandler;
import org.eclipse.jgit.api.RebaseCommand.Operation;
import org.eclipse.jgit.lib.Repository;
@@ -35,6 +37,10 @@ public class ProcessStepsRebaseCommand extends AbstractRebaseCommandHandler {
@Override
protected RebaseOperation createRebaseOperation(Repository repository)
throws ExecutionException {
+ if (LaunchFinder.shouldCancelBecauseOfRunningLaunches(repository,
+ null)) {
+ return null;
+ }
return new RebaseOperation(repository, Operation.PROCESS_STEPS,
RebaseInteractiveHandler.INSTANCE);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/RebaseCurrentRefCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/RebaseCurrentRefCommand.java
index b8248458e5..11a6d87989 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/RebaseCurrentRefCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/RebaseCurrentRefCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2014 SAP AG and others.
+ * Copyright (c) 2010, 2016 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -9,6 +9,7 @@
* Mathias Kinzler (SAP AG) - initial implementation
* Dariusz Luksza (dariusz@luksza.org) - disable command when HEAD cannot be
* resolved
+ * Thomas Wolf <thomas.wolf@paranor.ch> - Bug 495777
*******************************************************************************/
package org.eclipse.egit.ui.internal.commands.shared;
@@ -21,6 +22,7 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.egit.core.op.RebaseOperation;
import org.eclipse.egit.ui.internal.UIText;
+import org.eclipse.egit.ui.internal.branch.LaunchFinder;
import org.eclipse.egit.ui.internal.dialogs.BasicConfigurationDialog;
import org.eclipse.egit.ui.internal.dialogs.RebaseTargetSelectionDialog;
import org.eclipse.egit.ui.internal.rebase.RebaseInteractiveHandler;
@@ -156,6 +158,10 @@ public class RebaseCurrentRefCommand extends AbstractRebaseCommandHandler {
@Override
protected RebaseOperation createRebaseOperation(Repository repository)
throws ExecutionException {
+ if (LaunchFinder.shouldCancelBecauseOfRunningLaunches(repository,
+ null)) {
+ return null;
+ }
InteractiveHandler handler = interactive ? RebaseInteractiveHandler.INSTANCE
: null;
RebaseOperation operation = new RebaseOperation(repository, ref,
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/command/CherryPickHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/command/CherryPickHandler.java
index 0f7200ead0..e748bda975 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/command/CherryPickHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/command/CherryPickHandler.java
@@ -1,6 +1,5 @@
/******************************************************************************
- * Copyright (c) 2010 SAP AG.
- * Copyright (c) 2011, 2014 GitHub Inc.
+ * Copyright (c) 2010, 2016 SAP AG, GitHub Inc., and others
* and other copyright owners as documented in the project's IP log.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,6 +8,7 @@
*
* Contributors:
* Kevin Sawicki (GitHub Inc.) - initial API and implementation
+ * Thomas Wolf <thomas.wolf@paranor.ch> - Bug 495777
*****************************************************************************/
package org.eclipse.egit.ui.internal.commit.command;
@@ -16,6 +16,7 @@ import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -29,11 +30,13 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.egit.core.op.CherryPickOperation;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.internal.UIRepositoryUtils;
import org.eclipse.egit.ui.internal.UIText;
+import org.eclipse.egit.ui.internal.branch.LaunchFinder;
import org.eclipse.egit.ui.internal.commit.RepositoryCommit;
import org.eclipse.egit.ui.internal.handler.SelectionHandler;
import org.eclipse.jface.dialogs.IDialogConstants;
@@ -91,7 +94,7 @@ public class CherryPickHandler extends SelectionHandler {
final CherryPickOperation op = new CherryPickOperation(repo, commit);
Job job = new Job(MessageFormat.format(
- UIText.CherryPickHandler_JobName, 1)) {
+ UIText.CherryPickHandler_JobName, Integer.valueOf(1))) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
@@ -138,22 +141,30 @@ public class CherryPickHandler extends SelectionHandler {
final Repository repository, final RevCommit commit)
throws ExecutionException {
final AtomicBoolean confirmed = new AtomicBoolean(false);
- final String message;
+ String message;
try {
message = MessageFormat.format(
- UIText.CherryPickHandler_ConfirmMessage, 1,
+ UIText.CherryPickHandler_ConfirmMessage, Integer.valueOf(1),
repository.getBranch());
} catch (IOException e) {
throw new ExecutionException(
"Exception obtaining current repository branch", e); //$NON-NLS-1$
}
+ ILaunchConfiguration launch = LaunchFinder
+ .getRunningLaunchConfiguration(
+ Collections.singleton(repository), null);
+ if (launch != null) {
+ message += "\n\n" + MessageFormat.format( //$NON-NLS-1$
+ UIText.LaunchFinder_RunningLaunchMessage, launch.getName());
+ }
+ final String question = message;
shell.getDisplay().syncExec(new Runnable() {
@Override
public void run() {
ConfirmCherryPickDialog dialog = new ConfirmCherryPickDialog(
- shell, message, repository, Arrays.asList(commit));
+ shell, question, repository, Arrays.asList(commit));
int result = dialog.open();
confirmed.set(result == Window.OK);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangePage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangePage.java
index 34b131c14f..a9919d170c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangePage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangePage.java
@@ -8,7 +8,7 @@
* Contributors:
* Mathias Kinzler (SAP AG) - initial implementation
* Marc Khouzam (Ericsson) - Add an option not to checkout the new branch
- * Thomas Wolf <thomas.wolf@paranor.ch> - Bug 493935
+ * Thomas Wolf <thomas.wolf@paranor.ch> - Bug 493935, 495777
*******************************************************************************/
package org.eclipse.egit.ui.internal.fetch;
@@ -41,6 +41,7 @@ import org.eclipse.egit.ui.UIUtils;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.ValidationUtils;
import org.eclipse.egit.ui.internal.branch.BranchOperationUI;
+import org.eclipse.egit.ui.internal.branch.LaunchFinder;
import org.eclipse.egit.ui.internal.dialogs.AbstractBranchSelectionDialog;
import org.eclipse.egit.ui.internal.dialogs.BranchEditDialog;
import org.eclipse.egit.ui.internal.dialogs.CheckoutConflictDialog;
@@ -641,7 +642,6 @@ public class FetchGerritChangePage extends WizardPage {
}
boolean doFetch() {
-
final RefSpec spec = new RefSpec().setSource(refText.getText())
.setDestination(Constants.FETCH_HEAD);
final String uri = uriCombo.getText();
@@ -654,6 +654,10 @@ public class FetchGerritChangePage extends WizardPage {
final String textForTag = tagText.getText();
final String textForBranch = branchText.getText();
+ if (doCheckoutNewBranch && LaunchFinder
+ .shouldCancelBecauseOfRunningLaunches(repository, null)) {
+ return false;
+ }
storeRunInBackgroundSelection();
if (runInBackgroud.getSelection()) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/MergeHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/MergeHandler.java
index a4a66a2336..e852ac3635 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/MergeHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/MergeHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 SAP AG.
+ * Copyright (c) 2010, 2016 SAP AG and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -9,6 +9,7 @@
* Christian Halstrick (SAP AG) - initial implementation
* Mathias Kinzler (SAP AG) - initial implementation
* Robin Rosenberg - Adoption for the history menu
+ * Thomas Wolf <thomas.wolf@paranor.ch> - Bug 495777
*******************************************************************************/
package org.eclipse.egit.ui.internal.history.command;
@@ -30,6 +31,7 @@ import org.eclipse.egit.core.op.MergeOperation;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.actions.MergeActionHandler;
+import org.eclipse.egit.ui.internal.branch.LaunchFinder;
import org.eclipse.egit.ui.internal.dialogs.BranchSelectionDialog;
import org.eclipse.egit.ui.internal.merge.MergeResultDialog;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -65,8 +67,12 @@ public class MergeHandler extends AbstractHistoryCommandHandler {
if (repository == null)
return null;
- if (!MergeActionHandler.checkMergeIsPossible(repository, getShell(event)))
+ if (!MergeActionHandler.checkMergeIsPossible(repository,
+ getShell(event))
+ || LaunchFinder.shouldCancelBecauseOfRunningLaunches(repository,
+ null)) {
return null;
+ }
List<Ref> nodes;
try {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/RebaseCurrentHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/RebaseCurrentHandler.java
index b144f37f89..9a05de0d40 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/RebaseCurrentHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/RebaseCurrentHandler.java
@@ -1,14 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2013 SAP AG.
+ * Copyright (c) 2013, 2016 SAP AG and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Thomas Wolf <thomas.wolf@paranor.ch> - Bug 495777
*******************************************************************************/
package org.eclipse.egit.ui.internal.history.command;
import org.eclipse.egit.core.op.RebaseOperation;
+import org.eclipse.egit.ui.internal.branch.LaunchFinder;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
@@ -20,6 +24,10 @@ public class RebaseCurrentHandler extends AbstractRebaseHistoryCommandHandler {
@Override
protected RebaseOperation createRebaseOperation(Repository repository,
Ref ref) {
+ if (LaunchFinder.shouldCancelBecauseOfRunningLaunches(repository,
+ null)) {
+ return null;
+ }
return new RebaseOperation(repository, ref);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ResetHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ResetHandler.java
index 5dde6e4e9a..dc0e5657a9 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ResetHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ResetHandler.java
@@ -1,18 +1,23 @@
/*******************************************************************************
- * Copyright (C) 2010, 2014, Mathias Kinzler <mathias.kinzler@sap.com> and others.
+ * Copyright (C) 2010, 2016 Mathias Kinzler <mathias.kinzler@sap.com> and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Thomas Wolf <thomas.wolf@paranor.ch> - Bug 495777
*******************************************************************************/
package org.eclipse.egit.ui.internal.history.command;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.egit.ui.internal.actions.ResetMenu;
+import org.eclipse.jgit.api.ResetCommand.ResetType;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.ui.handlers.HandlerUtil;
/**
* "Reset" with parameter (hard, mixed, soft).
@@ -24,7 +29,8 @@ public class ResetHandler extends AbstractHistoryCommandHandler {
final ObjectId commitId = getSelectedCommitId(event);
String resetMode = event.getParameter(ResetMenu.RESET_MODE);
- ResetMenu.performReset(event, repo, commitId, resetMode);
+ ResetMenu.performReset(HandlerUtil.getActiveShellChecked(event), repo,
+ commitId, ResetType.valueOf(resetMode));
return null;
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/PullOperationUI.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/PullOperationUI.java
index 2681fd521d..09ced3d2c6 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/PullOperationUI.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/PullOperationUI.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG.
+ * Copyright (c) 2011, 2016 SAP AG and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Mathias Kinzler (SAP AG) - initial implementation
+ * Thomas Wolf <thomas.wolf@paranor.ch> - Bug 495777
*******************************************************************************/
package org.eclipse.egit.ui.internal.pull;
@@ -26,6 +27,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.IJobChangeListener;
import org.eclipse.core.runtime.jobs.Job;
@@ -38,6 +40,7 @@ import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.branch.CleanupUncomittedChangesDialog;
+import org.eclipse.egit.ui.internal.branch.LaunchFinder;
import org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -71,6 +74,8 @@ public class PullOperationUI extends JobChangeAdapter {
private final PullOperation pullOperation;
+ private boolean checkForLaunches = true;
+
/**
* @param repositories
*/
@@ -108,6 +113,11 @@ public class PullOperationUI extends JobChangeAdapter {
}
private void start(IJobChangeListener jobChangeListener) {
+ if (checkForLaunches
+ && LaunchFinder.shouldCancelBecauseOfRunningLaunches(
+ Arrays.asList(repositories), null)) {
+ return;
+ }
// figure out a job name
String jobName;
if (this.repositories.length == 1) {
@@ -128,7 +138,7 @@ public class PullOperationUI extends JobChangeAdapter {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) {
- execute(monitor);
+ execute(monitor, false);
// we always return OK and handle display of errors on our own
return Status.OK_STATUS;
}
@@ -152,15 +162,27 @@ public class PullOperationUI extends JobChangeAdapter {
* @param monitor
*/
public void execute(IProgressMonitor monitor) {
+ execute(monitor, true);
+ }
+
+ private void execute(IProgressMonitor monitor, boolean launchCheck) {
+ SubMonitor progress = SubMonitor.convert(monitor,
+ launchCheck ? 11 : 10);
+ if (launchCheck && LaunchFinder.shouldCancelBecauseOfRunningLaunches(
+ Arrays.asList(repositories), progress.newChild(1))) {
+ return;
+ }
try {
- pullOperation.execute(monitor);
+ pullOperation.execute(progress.newChild(10));
results.putAll(pullOperation.getResults());
} catch (CoreException e) {
- if (e.getStatus().getSeverity() == IStatus.CANCEL)
+ if (e.getStatus().getSeverity() == IStatus.CANCEL) {
results.putAll(pullOperation.getResults());
- else
+ } else {
Activator.handleError(e.getMessage(), e, true);
+ }
}
+
}
@Override
@@ -227,6 +249,7 @@ public class PullOperationUI extends JobChangeAdapter {
final PullOperationUI parentOperation = this;
final PullOperationUI pullOperationUI = new PullOperationUI(
Collections.singleton(repository));
+ pullOperationUI.checkForLaunches = false;
tasksToWaitFor.incrementAndGet();
pullOperationUI.start(new JobChangeAdapter() {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/command/ResetHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/command/ResetHandler.java
index 3d7060b43b..066547fdb4 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/command/ResetHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/command/ResetHandler.java
@@ -1,18 +1,23 @@
/*******************************************************************************
- * Copyright (c) 2014, Konrad Kügler <swamblumat-eclipsebugs@yahoo.de> and others.
+ * Copyright (c) 2014, 2016 Konrad Kügler <swamblumat-eclipsebugs@yahoo.de> and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Thomas Wolf <thomas.wolf@paranor.ch> - Bug 495777
*******************************************************************************/
package org.eclipse.egit.ui.internal.reflog.command;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.egit.ui.internal.actions.ResetMenu;
+import org.eclipse.jgit.api.ResetCommand.ResetType;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.ui.handlers.HandlerUtil;
/**
* Handler to reset (soft/mixed/hard) to a reflog entry's commit
@@ -25,7 +30,8 @@ public class ResetHandler extends AbstractReflogCommandHandler {
String resetMode = event.getParameter(ResetMenu.RESET_MODE);
RevCommit commit = getSelectedCommit(event, repository);
if (commit != null)
- ResetMenu.performReset(event, repository, commit, resetMode);
+ ResetMenu.performReset(HandlerUtil.getActiveShellChecked(event),
+ repository, commit, ResetType.valueOf(resetMode));
return null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/MergeCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/MergeCommand.java
index fd064585b2..c455ec0fed 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/MergeCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/MergeCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2013 SAP AG and others.
+ * Copyright (c) 2010, 2016 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,6 +10,7 @@
* Mathias Kinzler (SAP AG) - move to command framework
* Dariusz Luksza (dariusz@luksza.org - set action disabled when HEAD cannot
* be resolved
+ * Thomas Wolf <thomas.wolf@paranor.ch> - Bug 495777
*******************************************************************************/
package org.eclipse.egit.ui.internal.repository.tree.command;
@@ -29,6 +30,7 @@ import org.eclipse.egit.core.op.MergeOperation;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.actions.MergeActionHandler;
+import org.eclipse.egit.ui.internal.branch.LaunchFinder;
import org.eclipse.egit.ui.internal.dialogs.BasicConfigurationDialog;
import org.eclipse.egit.ui.internal.dialogs.MergeTargetSelectionDialog;
import org.eclipse.egit.ui.internal.merge.MergeResultDialog;
@@ -53,10 +55,13 @@ public class MergeCommand extends
RepositoryTreeNode node = getSelectedNodes(event).get(0);
final Repository repository = node.getRepository();
- BasicConfigurationDialog.show(repository);
-
- if (!MergeActionHandler.checkMergeIsPossible(repository, getShell(event)))
+ if (!MergeActionHandler.checkMergeIsPossible(repository,
+ getShell(event))
+ || LaunchFinder.shouldCancelBecauseOfRunningLaunches(repository,
+ null)) {
return null;
+ }
+ BasicConfigurationDialog.show(repository);
String targetRef;
if (node instanceof RefNode) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ResetCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ResetCommand.java
index 1253378fba..28882dca8e 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ResetCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ResetCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 SAP AG.
+ * Copyright (c) 2010, 2016 SAP AG and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,30 +7,24 @@
*
* Contributors:
* Mathias Kinzler (SAP AG) - initial implementation
+ * Thomas Wolf <thomas.wolf@paranor.ch> - Bug 495777
*******************************************************************************/
package org.eclipse.egit.ui.internal.repository.tree.command;
import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.egit.core.internal.job.JobUtil;
-import org.eclipse.egit.core.op.ResetOperation;
import org.eclipse.egit.ui.Activator;
-import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.actions.ResetActionHandler;
+import org.eclipse.egit.ui.internal.actions.ResetMenu;
import org.eclipse.egit.ui.internal.repository.SelectResetTypePage;
import org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jgit.api.ResetCommand.ResetType;
import org.eclipse.jgit.lib.Ref;
-import org.eclipse.osgi.util.NLS;
/**
* "Resets" a repository
@@ -53,15 +47,15 @@ public class ResetCommand extends
} catch (IOException e1) {
throw new ExecutionException(e1.getMessage(), e1);
}
- final String targetBranch;
- if (!(node.getObject() instanceof Ref))
+ if (!(node.getObject() instanceof Ref)) {
// Use same dialog as for project when a repository is selected
// allowing reset to any commit
return new ResetActionHandler().execute(event);
+ }
// If a ref is selected in the repository view, only reset to
// that ref will be possible.
- targetBranch = ((Ref) node.getObject()).getName();
+ final Ref targetBranch = (Ref) node.getObject();
final String repoName = Activator.getDefault().getRepositoryUtil()
.getRepositoryName(node.getRepository());
@@ -71,7 +65,7 @@ public class ResetCommand extends
@Override
public void addPages() {
addPage(new SelectResetTypePage(repoName, node.getRepository(),
- currentBranch, targetBranch));
+ currentBranch, targetBranch.getName()));
setWindowTitle(UIText.ResetCommand_WizardTitle);
}
@@ -79,40 +73,8 @@ public class ResetCommand extends
public boolean performFinish() {
final ResetType resetType = ((SelectResetTypePage) getPages()[0])
.getResetType();
- if (resetType == ResetType.HARD)
- if (!MessageDialog
- .openQuestion(
- getShell(),
- UIText.ResetTargetSelectionDialog_ResetQuestion,
- UIText.ResetTargetSelectionDialog_ResetConfirmQuestion))
- return true;
-
- try {
- getContainer().run(true, true,
- new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException,
- InterruptedException {
-
- String jobname = NLS.bind(
- UIText.ResetAction_reset,
- targetBranch);
- final ResetOperation operation = new ResetOperation(
- node.getRepository(), targetBranch,
- resetType);
- JobUtil.scheduleUserWorkspaceJob(operation,
- jobname, JobFamilies.RESET);
- }
- });
- } catch (InvocationTargetException ite) {
- Activator.handleError(
- UIText.ResetCommand_ResetFailureMessage, ite
- .getCause(), true);
- return false;
- } catch (InterruptedException ie) {
- // ignore here
- }
+ ResetMenu.performReset(getShell(), node.getRepository(),
+ targetBranch.getObjectId(), resetType);
return true;
}
};
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
index 6e758d85bd..a5224ebb2c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (C) 2011, 2015 Bernard Leach <leachbj@bouncycastle.org> and others.
+ * Copyright (C) 2011, 2016 Bernard Leach <leachbj@bouncycastle.org> and others.
* Copyright (C) 2015 SAP SE (Christian Georgi <christian.georgi@sap.com>)
* Copyright (C) 2015 Denis Zygann <d.zygann@web.de>
*
@@ -10,7 +10,7 @@
*
* Contributors:
* Tobias Baumann <tobbaumann@gmail.com> - Bug 373969, 473544
- * Thomas Wolf <thomas.wolf@paranor.ch> - Bug 481683
+ * Thomas Wolf <thomas.wolf@paranor.ch> - Bug 481683, 495777
*******************************************************************************/
package org.eclipse.egit.ui.internal.staging;
@@ -20,6 +20,7 @@ import java.io.File;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.HashSet;
@@ -46,6 +47,7 @@ import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.RepositoryUtil;
import org.eclipse.egit.core.internal.gerrit.GerritUtil;
@@ -67,6 +69,7 @@ import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.actions.ActionCommands;
import org.eclipse.egit.ui.internal.actions.BooleanPrefAction;
import org.eclipse.egit.ui.internal.actions.ReplaceWithOursTheirsMenu;
+import org.eclipse.egit.ui.internal.branch.LaunchFinder;
import org.eclipse.egit.ui.internal.commands.shared.AbortRebaseCommand;
import org.eclipse.egit.ui.internal.commands.shared.AbstractRebaseCommandHandler;
import org.eclipse.egit.ui.internal.commands.shared.ContinueRebaseCommand;
@@ -2260,9 +2263,21 @@ public class StagingView extends ViewPart implements IShowInSource {
@Override
public void run() {
+ String question = UIText.DiscardChangesAction_confirmActionMessage;
+ ILaunchConfiguration launch = LaunchFinder
+ .getRunningLaunchConfiguration(
+ Collections.singleton(getCurrentRepository()),
+ null);
+ if (launch != null) {
+ question = MessageFormat.format(question,
+ "\n\n" + MessageFormat.format( //$NON-NLS-1$
+ UIText.LaunchFinder_RunningLaunchMessage,
+ launch.getName()));
+ } else {
+ question = MessageFormat.format(question, ""); //$NON-NLS-1$
+ }
boolean performAction = MessageDialog.openConfirm(form.getShell(),
- UIText.DiscardChangesAction_confirmActionTitle,
- UIText.DiscardChangesAction_confirmActionMessage);
+ UIText.DiscardChangesAction_confirmActionTitle, question);
if (!performAction) {
return;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
index b4ba05a3d7..98c424580e 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
@@ -652,7 +652,7 @@ ResetTargetSelectionDialog_DetachedHeadState=You are in the 'detached HEAD' stat
ResetTargetSelectionDialog_ExpressionLabel=Reset to (expression):
ResetTargetSelectionDialog_ExpressionTooltip=Any Git expression resolving to a commit
ResetTargetSelectionDialog_ResetButton=&Reset
-ResetTargetSelectionDialog_ResetConfirmQuestion=Resetting will overwrite any changes in your working tree.\n\nDo you want to continue?
+ResetTargetSelectionDialog_ResetConfirmQuestion=Resetting will overwrite any changes in your working tree.{0}\n\nDo you want to continue?
ResetTargetSelectionDialog_ResetQuestion=Confirm Reset
ResetTargetSelectionDialog_ResetTitle=Reset: {0}
ResetTargetSelectionDialog_ResetTypeGroup=Reset type
@@ -1103,10 +1103,11 @@ BranchOperationUI_CheckoutRemoteTrackingTitle=Check out remote-tracking branch
BranchOperationUI_Continue=Continue
BranchOperationUI_DetachedHeadTitle=Detached HEAD
BranchOperationUI_DetachedHeadMessage=You are in the 'detached HEAD' state. This means that you don't have a local branch checked out.\n\nYou can look around, but it's not recommended to commit changes. The reason is that these commits would not be on any branch and would not be visible after checking out another branch.\n\nIf you want to make changes, create or checkout a local branch first.
-BranchOperationUI_RunningLaunchDontShowAgain=Don't show this warning again
-BranchOperationUI_RunningLaunchMessage=The launch configuration ''{0}'' is currently running and uses a project of this repository. Continue branch switch?
-BranchOperationUI_RunningLaunchTitle=Running Launch
-BranchOperationUI_SearchLaunchConfiguration=Search running launch configuration
+LaunchFinder_RunningLaunchDontShowAgain=Don't show this warning again
+LaunchFinder_RunningLaunchMessage=The launch configuration ''{0}'' is currently running and uses a project of this repository.
+LaunchFinder_RunningLaunchTitle=Running Launch
+LaunchFinder_SearchLaunchConfiguration=Search running launch configuration
+LaunchFinder_ContinueQuestion=Continue all the same?
BranchRenameDialog_Message=Please enter a new name for branch {0}
BranchRenameDialog_NewNameLabel=New Branch &name:
BranchRenameDialog_RenameExceptionMessage=Could not rename branch
@@ -1288,7 +1289,7 @@ DiffEditorPage_TaskGeneratingDiff=Generating diff
DiffEditorPage_TaskUpdatingViewer=Updating diff viewer
DiffEditorPage_Title=Diff
DiscardChangesAction_confirmActionTitle=Discard Local Changes
-DiscardChangesAction_confirmActionMessage=This will discard all local changes for the selected resources. Untracked files will be ignored. Are you sure you want to do this?
+DiscardChangesAction_confirmActionMessage=This will discard all local changes for the selected resources. Untracked files will be ignored.{0}\n\nAre you sure you want to do this?
DiscardChangesAction_discardChanges=Discard Changes
Disconnect_disconnect=Disconnect

Back to the top