Author: snjeza
Date: 2010-08-01 17:35:43 -0400 (Sun, 01 Aug 2010)
New Revision: 23855
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ExploreActionDelegate.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ExploreUtils.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerActionProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
Log:
https://jira.jboss.org/browse/JBIDE-6707 Add "Explore" option on the whole
server, not only on a specific resource
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ExploreActionDelegate.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ExploreActionDelegate.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ExploreActionDelegate.java 2010-08-01
21:35:43 UTC (rev 23855)
@@ -0,0 +1,62 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2009 JBoss by Red Hat 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.ide.eclipse.as.ui.actions;
+
+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.wst.server.core.IServer;
+
+/**
+ * @author Snjeza
+ *
+ */
+public class ExploreActionDelegate implements IObjectActionDelegate {
+
+ private ISelection fCurrentSelection;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ @Override
+ public void run(IAction action) {
+ if (fCurrentSelection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) fCurrentSelection;
+ Object object = structuredSelection.getFirstElement();
+ if (object instanceof IServer) {
+ IServer server = (IServer) object;
+ String deployDirectory = ExploreUtils.getDeployDirectory(server);
+ if (deployDirectory != null && deployDirectory.length() > 0) {
+ ExploreUtils.explore(deployDirectory);
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
org.eclipse.jface.viewers.ISelection)
+ */
+ @Override
+ public void selectionChanged(IAction action, ISelection selection) {
+ fCurrentSelection= selection;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction,
org.eclipse.ui.IWorkbenchPart)
+ */
+ @Override
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+
+ }
+
+}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ExploreUtils.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ExploreUtils.java 2010-07-31
05:05:37 UTC (rev 23854)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/actions/ExploreUtils.java 2010-08-01
21:35:43 UTC (rev 23855)
@@ -14,8 +14,10 @@
import java.io.IOException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.IServerWorkingCopy;
@@ -95,7 +97,7 @@
public static boolean canExplore(IServer server) {
String deployDirectory = ExploreUtils.getDeployDirectory(server);
- if (deployDirectory == null || deployDirectory.length() <= 0) {
+ if (deployDirectory == null || deployDirectory.length() <= 0 && new
File(deployDirectory).exists()) {
return false;
}
if (ExploreUtils.getExploreCommand() == null) {
@@ -122,8 +124,15 @@
int len = exploreFolderCommandArray.length;
exploreFolderCommandArray[len-1] = name;
Runtime.getRuntime().exec(exploreFolderCommandArray);
+ } else if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ command = command.replace(ExploreUtils.PATH, name);
+ Runtime.getRuntime().exec(command);
} else {
command = command.replace(ExploreUtils.PATH, name);
+ if (JBossServerUIPlugin.getDefault().isDebugging()) {
+ IStatus status = new Status(IStatus.WARNING, JBossServerUIPlugin.PLUGIN_ID,
"command=" + command, null); //$NON-NLS-1$
+ JBossServerUIPlugin.getDefault().getLog().log(status);
+ }
Runtime.getRuntime().exec(command);
}
} catch (IOException e) {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerActionProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerActionProvider.java 2010-07-31
05:05:37 UTC (rev 23854)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerActionProvider.java 2010-08-01
21:35:43 UTC (rev 23855)
@@ -137,7 +137,7 @@
clipboard = new Clipboard(tableViewer.getTree().getDisplay());
Shell shell = tableViewer.getTree().getShell();
- actions = new Action[6];
+ actions = new Action[5];
// create the start actions
actions[0] = new StartAction(shell, provider, ILaunchManager.DEBUG_MODE);
actions[1] = new StartAction(shell, provider, ILaunchManager.RUN_MODE);
@@ -148,7 +148,7 @@
// create the publish actions
actions[4] = new PublishAction(shell, provider);
- actions[5] = new ExploreAction(shell,provider);
+ //actions[5] = new ExploreAction(shell,provider);
// create the open action
openAction = new OpenAction(provider);
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2010-07-31 05:05:37 UTC (rev
23854)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2010-08-01 21:35:43 UTC (rev
23855)
@@ -578,5 +578,31 @@
typeIds="%AllJBossServerTypes">
</runtimeLocator>
</extension>
-
+
+ <extension point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ adaptable="true"
+ id="org.jboss.ide.eclipse.as.ui.actions.exploreAction"
+ objectClass="org.eclipse.wst.server.core.IServer">
+ enablesFor="1"
+ <enablement>
+ <adapt type="org.eclipse.wst.server.core.IServer">
+ <test forcePluginActivation="true"
+ property="org.eclipse.wst.server.ui.serverType"
+ value="org.jboss.ide.eclipse.as*" />
+ </adapt>
+ </enablement>
+
+ <action
+ label="Explore"
+ icon="icons/actions/xpl/explore.gif"
+
class="org.jboss.ide.eclipse.as.ui.actions.ExploreActionDelegate"
+ tooltip="Explore"
+
menubarPath="org.eclipse.wst.server.ui.internal.cnf.controlServerSectionEnd"
+ id="org.jboss.ide.eclipse.as.ui.actions.ExploreAction">
+ </action>
+ </objectContribution>
+
+ </extension>
+
</plugin>