Author: adietish
Date: 2011-11-29 15:39:52 -0500 (Tue, 29 Nov 2011)
New Revision: 36745
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/OpenManagementConsoleActionProvider.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/JBossServerUISharedImages.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
Log:
[JBIDE-6828] implementing "Open Management Console" action in context menu of
the server/serverView
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/META-INF/MANIFEST.MF 2011-11-29 19:49:41
UTC (rev 36744)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/META-INF/MANIFEST.MF 2011-11-29 20:39:52
UTC (rev 36745)
@@ -55,7 +55,8 @@
org.eclipse.wst.common.project.facet.ui;bundle-version="1.4.200",
org.jboss.ide.eclipse.as.wtp.core;bundle-version="2.3.0",
org.eclipse.jst.common.project.facet.core;bundle-version="1.4.200",
- org.eclipse.wst.common.emfworkbench.integration;bundle-version="1.2.100"
+ org.eclipse.wst.common.emfworkbench.integration;bundle-version="1.2.100",
+ org.jboss.tools.common.ui;bundle-version="3.3.0"
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.ide.eclipse.as.ui,
org.jboss.ide.eclipse.as.ui.console,
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/JBossServerUISharedImages.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/JBossServerUISharedImages.java 2011-11-29
19:49:41 UTC (rev 36744)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/JBossServerUISharedImages.java 2011-11-29
20:39:52 UTC (rev 36745)
@@ -50,9 +50,8 @@
public static final String XPATH_LEVEL_1 = "xpath_level_1"; //$NON-NLS-1$
public static final String XPATH_LEVEL_2 = "xpath_level_2"; //$NON-NLS-1$
public static final String XPATH_LEVEL_3 = "xpath_level_3"; //$NON-NLS-1$
+ public static final String CONSOLE = "console"; //$NON-NLS-1$
-
-
private static JBossServerUISharedImages instance;
private Hashtable<String, Object> images, descriptors;
@@ -77,6 +76,7 @@
descriptors.put(XPATH_LEVEL_2, createImageDescriptor(pluginBundle,
"icons/xpath_level_2.gif")); //$NON-NLS-1$
descriptors.put(XPATH_LEVEL_3, createImageDescriptor(pluginBundle,
"icons/xpath_level_3.gif")); //$NON-NLS-1$
+ descriptors.put(CONSOLE, createImageDescriptor(pluginBundle,
"/icons/console.gif")); //$NON-NLS-1$
Iterator<String> iter = descriptors.keySet().iterator();
while (iter.hasNext()) {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java 2011-11-29
19:49:41 UTC (rev 36744)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java 2011-11-29
20:39:52 UTC (rev 36745)
@@ -223,6 +223,8 @@
public static String ExploreUtils_Action_Text;
public static String ExploreUtils_Description;
+ public static String OpenManagementConsole_Action_Text;
+ public static String OpenConsole_Action_Description;
public static String Configure;
public static String ConfigureRuntimeMarkerResolution_Description;
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties 2011-11-29
19:49:41 UTC (rev 36744)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties 2011-11-29
20:39:52 UTC (rev 36745)
@@ -196,6 +196,7 @@
ExploreUtils_Action_Text=Explore
ExploreUtils_Description=Explore deploy directory
+OpenManagementConsole_Action_Text=Open Management Console
Configure=Configure...
ConfigureRuntimeMarkerResolution_Description=Configure Targeted Runtimes
ConvertNodeToXPathDialog_DisplayString=Add to XPaths
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/OpenManagementConsoleActionProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/OpenManagementConsoleActionProvider.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/OpenManagementConsoleActionProvider.java 2011-11-29
20:39:52 UTC (rev 36745)
@@ -0,0 +1,96 @@
+package org.jboss.ide.eclipse.as.ui.views.server.extensions;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonViewerSite;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.ui.internal.view.servers.AbstractServerAction;
+import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
+import org.jboss.ide.eclipse.as.core.util.ServerUtil;
+import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
+import org.jboss.ide.eclipse.as.ui.JBossServerUISharedImages;
+import org.jboss.ide.eclipse.as.ui.Messages;
+import org.jboss.tools.common.ui.BrowserUtil;
+
+import com.ibm.icu.text.MessageFormat;
+
+public class OpenManagementConsoleActionProvider extends CommonActionProvider {
+
+ private static final String CONSOLE_URL_PATTERN = "http://{0}:{1}/console";
+
+ private ICommonActionExtensionSite actionSite;
+ private OpenManagementConsoleAction openManagementConsoleAction;
+ public OpenManagementConsoleActionProvider() {
+ super();
+ }
+
+ public void init(ICommonActionExtensionSite site) {
+ super.init(site);
+ this.actionSite = site;
+ createActions(site);
+ }
+
+ protected void createActions(ICommonActionExtensionSite aSite) {
+ ICommonViewerSite viewSite = aSite.getViewSite();
+ if( viewSite instanceof ICommonViewerWorkbenchSite ) {
+ StructuredViewer v = aSite.getStructuredViewer();
+ if( v instanceof CommonViewer ) {
+ ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite)viewSite;
+ openManagementConsoleAction = new
OpenManagementConsoleAction(wsSite.getSelectionProvider());
+ }
+ }
+ }
+
+ public void fillContextMenu(IMenuManager menu) {
+ ICommonViewerSite site = actionSite.getViewSite();
+ IStructuredSelection selection = null;
+ if (site instanceof ICommonViewerWorkbenchSite) {
+ ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite) site;
+ selection = (IStructuredSelection) wsSite.getSelectionProvider()
+ .getSelection();
+ }
+ IContributionItem menuItem =
menu.find("org.eclipse.ui.navigate.showInQuickMenu"); //$NON-NLS-1$
+ if( menuItem != null && selection != null && selection.toArray().length
== 1 ) {
+ if( selection.getFirstElement() instanceof IServer ) {
+ if( menu instanceof MenuManager ) {
+ ((MenuManager)menuItem).add(openManagementConsoleAction);
+ }
+ }
+ }
+ }
+
+ private static class OpenManagementConsoleAction extends AbstractServerAction {
+ public OpenManagementConsoleAction(ISelectionProvider sp) {
+ super(sp, Messages.OpenManagementConsole_Action_Text);
+ setImageDescriptor(JBossServerUISharedImages.getImageDescriptor(JBossServerUISharedImages.CONSOLE));
+ }
+
+ public boolean accept(IServer server) {
+ return (ServerUtil.isJBoss7(server));
+ }
+
+ public void perform(IServer server) {
+ JBossServer jbossServer;
+ try {
+ jbossServer = ServerUtil.checkedGetServerAdapter(server, JBossServer.class);
+ String host = jbossServer.getHost();
+ int webPort = jbossServer.getJBossWebPort();
+ String consoleUrl = MessageFormat.format(CONSOLE_URL_PATTERN, host,
String.valueOf(webPort));
+ BrowserUtil.checkedCreateInternalBrowser(
+ consoleUrl, server.getName(), JBossServerUIPlugin.PLUGIN_ID,
JBossServerUIPlugin.getDefault().getLog());
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/OpenManagementConsoleActionProvider.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2011-11-29 19:49:41 UTC (rev
36744)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2011-11-29 20:39:52 UTC (rev
36745)
@@ -374,6 +374,18 @@
</instanceof>
</enablement>
</actionProvider>
+ <actionProvider
+
class="org.jboss.ide.eclipse.as.ui.views.server.extensions.OpenManagementConsoleActionProvider"
+ id="org.jboss.ide.eclipse.as.ui.extensions.managementConsole">
+ <enablement>
+<!-- <instanceof
+
value="org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7Server">
+ </instanceof> -->
+ <instanceof
+ value="org.eclipse.wst.server.core.IServer">
+ </instanceof>
+ </enablement>
+ </actionProvider>
</extension>
@@ -396,6 +408,8 @@
<actionExtension
pattern="org.jboss.ide.eclipse.as.ui.extensions.serverLog"/>
<actionExtension
+
pattern="org.jboss.ide.eclipse.as.ui.extensions.managementConsole"/>
+ <actionExtension
pattern="org.jboss.tools.as.wst.server.ui.ServersView.ExploreActionProvider"/>
</includes>
</viewerActionBinding>
Show replies by date