Author: adietish
Date: 2011-08-16 04:05:18 -0400 (Tue, 16 Aug 2011)
New Revision: 33960
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/plugin.xml
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/ui/
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/ui/EGitUIActivator.java
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/ui/commands/
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/ui/commands/CommitAndPushHandler.java
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/ui/util/
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/ui/util/CommandUtils.java
Removed:
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/ui/Activator.java
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/ui/
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/.project
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/build.properties
Log:
[JBIDE-9511] implemented commit and push handler
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/.project
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/.project 2011-08-16 06:12:13 UTC
(rev 33959)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/.project 2011-08-16 08:05:18 UTC
(rev 33960)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>org.jboss.ide.eclipse.as.egit.ui</name>
+ <name>org.jboss.ide.eclipse.as.egit.internal.ui</name>
<comment></comment>
<projects>
</projects>
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/META-INF/MANIFEST.MF 2011-08-16
06:12:13 UTC (rev 33959)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/META-INF/MANIFEST.MF 2011-08-16
08:05:18 UTC (rev 33960)
@@ -3,8 +3,9 @@
Bundle-Name: EGit integration UI
Bundle-SymbolicName: org.jboss.ide.eclipse.as.egit.ui;singleton:=true
Bundle-Version: 0.0.1.qualifier
-Bundle-Activator: org.jboss.ide.eclipse.as.egit.ui.Activator
+Bundle-Activator: org.jboss.ide.eclipse.as.egit.internal.ui.EGitUIActivator
Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime
+ org.eclipse.core.runtime,
+ org.eclipse.core.expressions;bundle-version="3.4.300"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/build.properties
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/build.properties 2011-08-16 06:12:13
UTC (rev 33959)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/build.properties 2011-08-16 08:05:18
UTC (rev 33960)
@@ -1,4 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
- .
+ .,\
+ plugin.xml
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/plugin.xml
(rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/plugin.xml 2011-08-16 08:05:18 UTC
(rev 33960)
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ description="psuhes and commits"
+ id="org.jboss.ide.eclipse.as.egit.ui.commands.PushAndCommit"
+ name="pushAndCommit">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+
class="org.jboss.ide.eclipse.as.egit.internal.ui.commands.CommitAndPushHandler"
+
commandId="org.jboss.ide.eclipse.as.egit.ui.commands.PushAndCommit">
+<!-- <activeWhen>
+ <and>
+ <count
+ value="+">
+ </count>
+ <iterate>
+ <or>
+ <adapt
+ type="org.eclipse.core.resources.IResource">
+ </adapt>
+ <adapt
+
type="org.eclipse.core.resources.mapping.ResourceMapping">
+ </adapt>
+ <adapt
+ type="org.eclipse.ui.IContributorResourceAdapter">
+ </adapt>
+ </or>
+ </iterate>
+ </and>
+ </activeWhen> -->
+ </handler>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="true"
+ locationURI="popup:team.main?after=group1">
+ <command
+
commandId="org.jboss.ide.eclipse.as.egit.ui.commands.PushAndCommit"
+ label="Commit and Push"
+ style="push"
+ tooltip="Commit And Push">
+ </command>
+ </menuContribution>
+ </extension>
+
+</plugin>
Property changes on: trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/plugin.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/ui/Activator.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/ui/Activator.java 2011-08-15
11:48:40 UTC (rev 33921)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/ui/Activator.java 2011-08-16
08:05:18 UTC (rev 33960)
@@ -1,50 +0,0 @@
-package org.jboss.ide.eclipse.as.egit.ui;
-
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.jboss.ide.eclipse.as.egit.ui";
//$NON-NLS-1$
-
- // The shared instance
- private static Activator plugin;
-
- /**
- * The constructor
- */
- public Activator() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
-}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/ui/EGitUIActivator.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/ui/EGitUIActivator.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/ui/EGitUIActivator.java 2011-08-16
08:05:18 UTC (rev 33960)
@@ -0,0 +1,50 @@
+package org.jboss.ide.eclipse.as.egit.internal.ui;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class EGitUIActivator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID =
"org.jboss.ide.eclipse.as.egit.internal.ui"; //$NON-NLS-1$
+
+ // The shared instance
+ private static EGitUIActivator plugin;
+
+ /**
+ * The constructor
+ */
+ public EGitUIActivator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static EGitUIActivator getDefault() {
+ return plugin;
+ }
+
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/ui/EGitUIActivator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/ui/commands/CommitAndPushHandler.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/ui/commands/CommitAndPushHandler.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/ui/commands/CommitAndPushHandler.java 2011-08-16
08:05:18 UTC (rev 33960)
@@ -0,0 +1,47 @@
+package org.jboss.ide.eclipse.as.egit.internal.ui.commands;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.NotEnabledException;
+import org.eclipse.core.commands.NotHandledException;
+import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.jboss.ide.eclipse.as.egit.internal.ui.util.CommandUtils;
+
+public class CommitAndPushHandler extends AbstractHandler {
+
+ private static final String EGIT_COMMIT_COMMAND_ID =
"org.eclipse.egit.ui.team.Commit";
+ private static final String EGIT_PUSH_COMMAND_ID =
"org.eclipse.egit.ui.team.Push";
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ executeCommand(EGIT_COMMIT_COMMAND_ID, selection );
+ executeCommand(EGIT_PUSH_COMMAND_ID, selection);
+ return null;
+ }
+
+ private static void executeCommand(String commandId, ISelection selection) throws
ExecutionException {
+ if (!(selection instanceof IStructuredSelection)) {
+ throw new ExecutionException(NLS.bind("Could not execute command
\"{0}\" since there's no valid selection",
+ commandId));
+ }
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ try {
+ CommandUtils.executeCommand(commandId, structuredSelection);
+ } catch (NotDefinedException e) {
+ throw new ExecutionException(NLS.bind("Could not execute command
\"{0}\" since it is not defined",
+ commandId), e);
+ } catch (NotEnabledException e) {
+ throw new ExecutionException(NLS.bind("Could not execute command
\"{0}\" since it was not enabled",
+ commandId), e);
+ } catch (NotHandledException e) {
+ throw new ExecutionException(NLS.bind(
+ "Could not execute command \"{0}\" since there's no actve handler
for it", commandId), e);
+ }
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/ui/commands/CommitAndPushHandler.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/ui/util/CommandUtils.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/ui/util/CommandUtils.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/ui/util/CommandUtils.java 2011-08-16
08:05:18 UTC (rev 33960)
@@ -0,0 +1,59 @@
+package org.jboss.ide.eclipse.as.egit.internal.ui.util;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.NotEnabledException;
+import org.eclipse.core.commands.NotHandledException;
+import org.eclipse.core.commands.ParameterizedCommand;
+import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.core.expressions.EvaluationContext;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.ISources;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.handlers.IHandlerService;
+
+public class CommandUtils {
+
+ public static boolean executeCommand(String commandId, IStructuredSelection selection)
throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException
{
+ Command command = getCommand(commandId);
+ if (!command.isDefined()) {
+ return false;
+ }
+
+ IHandlerService handlerService = (IHandlerService)
+ PlatformUI.getWorkbench().getService(IHandlerService.class);
+ EvaluationContext context = createEvaluationContext(selection, handlerService);
+ return doExecuteCommand(commandId, command, handlerService, context);
+ }
+
+ private static EvaluationContext createEvaluationContext(IStructuredSelection
selection,
+ IHandlerService handlerService) {
+ EvaluationContext context = null;
+ if (selection != null) {
+ context = new EvaluationContext(
+ handlerService.createContextSnapshot(false),
+ selection.toList());
+ context.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection);
+ context.removeVariable(ISources.ACTIVE_MENU_SELECTION_NAME);
+ }
+ return context;
+ }
+
+ private static boolean doExecuteCommand(String commandId, Command command,
IHandlerService handlerService,
+ EvaluationContext context) throws ExecutionException, NotDefinedException,
NotEnabledException, NotHandledException {
+ if (context != null) {
+ handlerService.executeCommandInContext(
+ new ParameterizedCommand(command, null), null, context);
+ } else {
+ handlerService.executeCommand(commandId, null);
+ }
+ return true;
+ }
+
+ public static Command getCommand(String commandId) {
+ ICommandService commandService =
+ (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
+ return commandService.getCommand(commandId);
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.egit.ui/src/org/jboss/ide/eclipse/as/egit/internal/ui/util/CommandUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain