Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDariusz Luksza2011-05-20 19:53:22 +0000
committerDariusz Luksza2011-05-20 19:54:14 +0000
commit32e5479b2e16dc3da212503f56a8efce08ba5d25 (patch)
treed6384b2b73ce2c6b1c8fa1f28256bf497ff90df6 /org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal
parent2a690282841dc51b54e09f37aac2ac9688af945c (diff)
downloadegit-32e5479b2e16dc3da212503f56a8efce08ba5d25.tar.gz
egit-32e5479b2e16dc3da212503f56a8efce08ba5d25.tar.xz
egit-32e5479b2e16dc3da212503f56a8efce08ba5d25.zip
Add rebase button into git toolbar
Also improves formatting of toolbar section in plugin.xml Change-Id: I2cb10a5933f4fca730f617816b597b4889707a30 Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ActionCommands.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RebaseAction.java27
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RebaseActionHandler.java31
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/AbstractSharedCommandHandler.java14
4 files changed, 75 insertions, 1 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ActionCommands.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ActionCommands.java
index 4987f6dc8c..60385ec901 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ActionCommands.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ActionCommands.java
@@ -95,6 +95,9 @@ public class ActionCommands {
/** "Reset" action command id */
public static final String RESET_ACTION = "org.eclipse.egit.ui.team.Reset"; //$NON-NLS-1$
+ /** "Rebase" action command id */
+ public static final String REBASE_ACTION = "org.eclipse.egit.ui.team.Rebase"; //$NON-NLS-1$
+
/** "Show History" action command id */
public static final String SHOW_HISTORY = "org.eclipse.egit.ui.team.ShowHistory"; //$NON-NLS-1$
@@ -121,4 +124,5 @@ public class ActionCommands {
/** "Merge Tool" action command id */
public static final String MERGE_TOOL_ACTION = "org.eclipse.egit.ui.team.MergeTool"; //$NON-NLS-1$
+
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RebaseAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RebaseAction.java
new file mode 100644
index 0000000000..c34be48bdf
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RebaseAction.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (C) 2011, Dariusz Luksza <dariusz@luksza.org>
+ *
+ * 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
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.actions;
+
+import org.eclipse.egit.core.op.RebaseOperation;
+
+/**
+ * An action to rebase the current branch on top of selected one.
+ *
+ * @see RebaseOperation
+ */
+public class RebaseAction extends RepositoryAction {
+
+ /**
+ *
+ */
+ public RebaseAction() {
+ super(ActionCommands.REBASE_ACTION, new RebaseActionHandler());
+ }
+
+}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RebaseActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RebaseActionHandler.java
new file mode 100644
index 0000000000..eaa1f83e21
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RebaseActionHandler.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (C) 2011, Dariusz Luksza <dariusz@luksza.org>
+ *
+ * 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
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.actions;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.egit.core.op.RebaseOperation;
+import org.eclipse.egit.ui.internal.commands.shared.RebaseCurrentRefCommand;
+
+/**
+ * An action to rebase the current branch on top of given branch.
+ *
+ * @see RebaseOperation
+ */
+public class RebaseActionHandler extends RepositoryActionHandler {
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ return new RebaseCurrentRefCommand().execute(event);
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return getRepository() != null && containsHead();
+ }
+}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/AbstractSharedCommandHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/AbstractSharedCommandHandler.java
index fbbdc6a3d6..8894db7ddf 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/AbstractSharedCommandHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commands/shared/AbstractSharedCommandHandler.java
@@ -25,12 +25,18 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
/**
* Abstract super class for commands shared between different components in EGit
*/
public abstract class AbstractSharedCommandHandler extends AbstractHandler {
+
+ private static final IWorkbench WORKBENCH = PlatformUI.getWorkbench();
+
/**
* @param event
* the {@link ExecutionEvent}
@@ -75,7 +81,13 @@ public abstract class AbstractSharedCommandHandler extends AbstractHandler {
return result;
}
if (selection instanceof TextSelection) {
- // TODO find editor input and adapt to IResource
+ IEditorInput activeEditor = WORKBENCH.getActiveWorkbenchWindow()
+ .getActivePage().getActiveEditor().getEditorInput();
+ IResource resource = (IResource) activeEditor
+ .getAdapter(IResource.class);
+
+ if (resource != null)
+ return RepositoryMapping.getMapping(resource).getRepository();
}
return null;
}

Back to the top