Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2011-12-15 08:09:55 +0000
committerEike Stepper2011-12-15 08:10:59 +0000
commitf7a23ca189c774df5c85cb3c9cc3458785f53da0 (patch)
tree0198a9475578ee196856a2bb41f6fd832966f473 /plugins/org.eclipse.emf.cdo.releng.winexplorer
parentee0ad8ac4359db5c8cc0a456e1bcae2a0a82ded8 (diff)
downloadcdo-f7a23ca189c774df5c85cb3c9cc3458785f53da0.tar.gz
cdo-f7a23ca189c774df5c85cb3c9cc3458785f53da0.tar.xz
cdo-f7a23ca189c774df5c85cb3c9cc3458785f53da0.zip
Add actions to open Dos command prompt or Git bash
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.releng.winexplorer')
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.winexplorer/build.properties3
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.winexplorer/plugin.xml13
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.winexplorer/prompt.gifbin0 -> 591 bytes
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.winexplorer/src/org/eclipse/emf/cdo/releng/winexplorer/AbstractContainerAction.java67
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.winexplorer/src/org/eclipse/emf/cdo/releng/winexplorer/ExplorerAction.java49
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.winexplorer/src/org/eclipse/emf/cdo/releng/winexplorer/PromptAction.java32
6 files changed, 118 insertions, 46 deletions
diff --git a/plugins/org.eclipse.emf.cdo.releng.winexplorer/build.properties b/plugins/org.eclipse.emf.cdo.releng.winexplorer/build.properties
index 4b1478f730..b47e81a10f 100644
--- a/plugins/org.eclipse.emf.cdo.releng.winexplorer/build.properties
+++ b/plugins/org.eclipse.emf.cdo.releng.winexplorer/build.properties
@@ -10,6 +10,7 @@ bin.includes = plugin.xml,\
about.properties,\
copyright.txt,\
modeling32.png,\
- plugin.properties
+ plugin.properties,\
+ prompt.gif
src.includes = about.html,\
copyright.txt
diff --git a/plugins/org.eclipse.emf.cdo.releng.winexplorer/plugin.xml b/plugins/org.eclipse.emf.cdo.releng.winexplorer/plugin.xml
index 25d6526621..4dab216042 100644
--- a/plugins/org.eclipse.emf.cdo.releng.winexplorer/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.releng.winexplorer/plugin.xml
@@ -9,6 +9,16 @@
id="org.eclipse.emf.cdo.releng.winexplorer.contribution"
objectClass="org.eclipse.core.resources.IResource">
<action
+ class="org.eclipse.emf.cdo.releng.winexplorer.PromptAction"
+ enablesFor="1"
+ icon="prompt.gif"
+ id="org.eclipse.emf.cdo.releng.PromptAction"
+ label="Command Prompt"
+ menubarPath="additions"
+ state="true"
+ style="push"
+ tooltip="Open Command Prompt"/>
+ <action
class="org.eclipse.emf.cdo.releng.winexplorer.ExplorerAction"
enablesFor="1"
icon="explorer.gif"
@@ -17,8 +27,7 @@
menubarPath="additions"
state="true"
style="push"
- tooltip="Open Windows Explorer">
- </action>
+ tooltip="Open Windows Explorer"/>
</objectContribution>
</extension>
diff --git a/plugins/org.eclipse.emf.cdo.releng.winexplorer/prompt.gif b/plugins/org.eclipse.emf.cdo.releng.winexplorer/prompt.gif
new file mode 100644
index 0000000000..a02c521ef3
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.winexplorer/prompt.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.cdo.releng.winexplorer/src/org/eclipse/emf/cdo/releng/winexplorer/AbstractContainerAction.java b/plugins/org.eclipse.emf.cdo.releng.winexplorer/src/org/eclipse/emf/cdo/releng/winexplorer/AbstractContainerAction.java
new file mode 100644
index 0000000000..fa88153ce4
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.winexplorer/src/org/eclipse/emf/cdo/releng/winexplorer/AbstractContainerAction.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.releng.winexplorer;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AbstractContainerAction implements IObjectActionDelegate
+{
+ private IContainer container;
+
+ public AbstractContainerAction()
+ {
+ }
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart)
+ {
+ }
+
+ public void selectionChanged(IAction action, ISelection selection)
+ {
+ container = null;
+ if (selection instanceof IStructuredSelection)
+ {
+ IStructuredSelection ssel = (IStructuredSelection)selection;
+ Object element = ssel.getFirstElement();
+ if (element instanceof IFile)
+ {
+ container = ((IFile)element).getParent();
+ }
+ else if (element instanceof IContainer)
+ {
+ container = (IContainer)element;
+ }
+ }
+ }
+
+ public void run(IAction action)
+ {
+ try
+ {
+ run(container);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ protected abstract void run(IContainer container) throws Exception;
+}
diff --git a/plugins/org.eclipse.emf.cdo.releng.winexplorer/src/org/eclipse/emf/cdo/releng/winexplorer/ExplorerAction.java b/plugins/org.eclipse.emf.cdo.releng.winexplorer/src/org/eclipse/emf/cdo/releng/winexplorer/ExplorerAction.java
index 00a3eab1ca..99b3978b3a 100644
--- a/plugins/org.eclipse.emf.cdo.releng.winexplorer/src/org/eclipse/emf/cdo/releng/winexplorer/ExplorerAction.java
+++ b/plugins/org.eclipse.emf.cdo.releng.winexplorer/src/org/eclipse/emf/cdo/releng/winexplorer/ExplorerAction.java
@@ -10,60 +10,23 @@
*/
package org.eclipse.emf.cdo.releng.winexplorer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.core.resources.IContainer;
import java.io.File;
-import java.io.IOException;
/**
* @author Eike Stepper
*/
-public class ExplorerAction implements IObjectActionDelegate
+public class ExplorerAction extends AbstractContainerAction
{
- private IResource resource;
-
public ExplorerAction()
{
}
- public void setActivePart(IAction action, IWorkbenchPart targetPart)
- {
- }
-
- public void selectionChanged(IAction action, ISelection selection)
- {
- resource = null;
- if (selection instanceof IStructuredSelection)
- {
- IStructuredSelection ssel = (IStructuredSelection)selection;
- Object element = ssel.getFirstElement();
- if (element instanceof IResource)
- {
- resource = (IResource)element;
- if (resource instanceof IFile)
- {
- resource = resource.getParent();
- }
- }
- }
- }
-
- public void run(IAction action)
+ @Override
+ protected void run(IContainer container) throws Exception
{
- try
- {
- String location = resource.getLocation().toString().replace('/', File.separatorChar);
- Runtime.getRuntime().exec("explorer.exe \"" + location + "\"");
- }
- catch (IOException ex)
- {
- ex.printStackTrace();
- }
+ String location = container.getLocation().toString().replace('/', File.separatorChar);
+ Runtime.getRuntime().exec("explorer.exe \"" + location + "\"");
}
}
diff --git a/plugins/org.eclipse.emf.cdo.releng.winexplorer/src/org/eclipse/emf/cdo/releng/winexplorer/PromptAction.java b/plugins/org.eclipse.emf.cdo.releng.winexplorer/src/org/eclipse/emf/cdo/releng/winexplorer/PromptAction.java
new file mode 100644
index 0000000000..71d8cef40d
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.winexplorer/src/org/eclipse/emf/cdo/releng/winexplorer/PromptAction.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.releng.winexplorer;
+
+import org.eclipse.core.resources.IContainer;
+
+import java.io.File;
+
+/**
+ * @author Eike Stepper
+ */
+public class PromptAction extends AbstractContainerAction
+{
+ public PromptAction()
+ {
+ }
+
+ @Override
+ protected void run(IContainer container) throws Exception
+ {
+ String location = container.getLocation().toString().replace('/', File.separatorChar);
+ Runtime.getRuntime().exec("cmd /c cd \"" + location + "\" && start cmd.exe");
+ }
+}

Back to the top