git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Robin Rosenberg <robin.rosenberg@dewire.com>
To: "Shawn O. Pearce" <spearce@spearce.org>
Cc: git@vger.kernel.org, Marek Zawirski <marek.zawirski@gmail.com>,
	Robin Rosenberg <robin.rosenberg@dewire.com>
Subject: [EGIT PATCH 5/6] Create baseclasses for actions and operations on RevObjects
Date: Fri, 11 Jul 2008 00:39:32 +0200	[thread overview]
Message-ID: <1215729573-26536-6-git-send-email-robin.rosenberg@dewire.com> (raw)
In-Reply-To: <1215729573-26536-5-git-send-email-robin.rosenberg@dewire.com>

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 .../internal/actions/AbstractOperationAction.java  |   15 +++++++----
 .../internal/actions/AbstractRevObjectAction.java  |   26 ++++++++++++++++++++
 .../actions/AbstractRevObjectOperation.java        |   21 ++++++++++++++++
 3 files changed, 57 insertions(+), 5 deletions(-)
 create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractRevObjectAction.java
 create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractRevObjectOperation.java

diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractOperationAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractOperationAction.java
index be6d0d5..52f60f5 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractOperationAction.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractOperationAction.java
@@ -32,11 +32,20 @@ import org.spearce.egit.ui.UIText;
  * Common functionality for EGit operations.
  */
 public abstract class AbstractOperationAction implements IObjectActionDelegate {
-	private IWorkbenchPart wp;
+	/**
+	 * The active workbench part
+	 */
+	protected IWorkbenchPart wp;
 
 	private IWorkspaceRunnable op;
 
 	public void selectionChanged(final IAction act, final ISelection sel) {
+		// work performed in setActivePart
+	}
+
+	public void setActivePart(final IAction act, final IWorkbenchPart part) {
+		wp = part;
+		ISelection sel = part.getSite().getPage().getSelection();
 		final List selection;
 		if (sel instanceof IStructuredSelection && !sel.isEmpty()) {
 			selection = ((IStructuredSelection) sel).toList();
@@ -47,10 +56,6 @@ public abstract class AbstractOperationAction implements IObjectActionDelegate {
 		act.setEnabled(op != null && wp != null);
 	}
 
-	public void setActivePart(final IAction act, final IWorkbenchPart part) {
-		wp = part;
-	}
-
 	/**
 	 * Instantiate an operation on an action on provided objects.
 	 *
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractRevObjectAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractRevObjectAction.java
new file mode 100644
index 0000000..b7f4285
--- /dev/null
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractRevObjectAction.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * See LICENSE for the full license text, also available.
+ *******************************************************************************/
+package org.spearce.egit.ui.internal.actions;
+
+import org.spearce.egit.ui.internal.history.RevObjectSelectionProvider;
+import org.spearce.jgit.lib.Repository;
+
+abstract class AbstractRevObjectAction extends AbstractOperationAction {
+
+	/**
+	 * Find out which repository is involved here
+	 *
+	 * @return the Git repository associated with the selected RevObject
+	 */
+	protected Repository getActiveRepository() {
+		RevObjectSelectionProvider selectionProvider = (RevObjectSelectionProvider) wp
+				.getSite().getSelectionProvider();
+		return selectionProvider.getActiveRepository();
+	}
+
+}
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractRevObjectOperation.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractRevObjectOperation.java
new file mode 100644
index 0000000..0c5d570
--- /dev/null
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractRevObjectOperation.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * See LICENSE for the full license text, also available.
+ *******************************************************************************/
+package org.spearce.egit.ui.internal.actions;
+
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.spearce.jgit.lib.Repository;
+
+abstract class AbstractRevObjectOperation implements IWorkspaceRunnable {
+
+	Repository repository;
+
+	AbstractRevObjectOperation(final Repository repository) {
+		this.repository = repository;
+	}
+
+}
-- 
1.5.6.2.220.g44701

  reply	other threads:[~2008-07-10 22:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-10 22:39 [EGIT PATCH 0/6] RevObject selection handler Robin Rosenberg
2008-07-10 22:39 ` [EGIT PATCH 1/6] Create a selection handler for the revision graph Robin Rosenberg
2008-07-10 22:39   ` [EGIT PATCH 2/6] Using the page site selection turned out to be cumbersome Robin Rosenberg
2008-07-10 22:39     ` [EGIT PATCH 3/6] Adapt Git team operations to non-resouce objects Robin Rosenberg
2008-07-10 22:39       ` [EGIT PATCH 4/6] Teach the revision selection handler about the active repository Robin Rosenberg
2008-07-10 22:39         ` Robin Rosenberg [this message]
2008-07-10 22:39           ` [EGIT PATCH 6/6] Add actions in history view to perform reset actions Robin Rosenberg
2008-07-11  3:47     ` [EGIT PATCH 2/6] Using the page site selection turned out to be cumbersome Shawn O. Pearce
2008-07-11  3:52       ` Shawn O. Pearce
2008-07-11 11:14         ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1215729573-26536-6-git-send-email-robin.rosenberg@dewire.com \
    --to=robin.rosenberg@dewire.com \
    --cc=git@vger.kernel.org \
    --cc=marek.zawirski@gmail.com \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).