You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2012/04/24 17:59:58 UTC
svn commit: r1329813 - in
/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui:
./ src/main/java/org/apache/geronimo/st/v30/ui/actions/
src/main/java/org/apache/geronimo/st/v30/ui/internal/
src/main/java/org/apache/geronimo/st/...
Author: gawor
Date: Tue Apr 24 15:59:58 2012
New Revision: 1329813
URL: http://svn.apache.org/viewvc?rev=1329813&view=rev
Log:
Launch shell terminal window from popup menu instead of via server configuration
Added:
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/actions/LaunchGeronimoShellAction.java (with props)
Modified:
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/plugin.properties
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/plugin.xml
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/Messages.properties
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorKarafShellSection.java
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/view/KarafShellSSHTerminalView.java
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/plugin.properties
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/plugin.properties?rev=1329813&r1=1329812&r2=1329813&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/plugin.properties (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/plugin.properties Tue Apr 24 15:59:58 2012
@@ -26,4 +26,5 @@ deploymentPlanEditorName=Geronimo Deploy
BlueprintEditorName=Geronimo Blueprint Editor
changeBundleStartLevel=Change Start Level
geronimo.views.category.name=Geronimo terminal
-karafShellTerminal=Karaf Shell Terminal
+karafShellTerminal=Geronimo Shell Terminal
+PopupMenus.launchShell=Launch Geronimo Shell
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/plugin.xml
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/plugin.xml?rev=1329813&r1=1329812&r2=1329813&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/plugin.xml (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/plugin.xml Tue Apr 24 15:59:58 2012
@@ -271,7 +271,24 @@
</action>
</objectContribution>
</extension>
-
+
+ <extension point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ adaptable="true"
+ id="org.apache.geronimo.ui.serveractions.30"
+ objectClass="org.eclipse.wst.server.core.IServer">
+ <enablement>
+ <test forcePluginActivation="true"
+ property="org.eclipse.wst.server.ui.serverType"
+ value="org.apache.geronimo.server.3*" />
+ </enablement>
+ <action id="org.apache.geronimo.ui.launchconsole.30"
+ label="%PopupMenus.launchShell" icon="icons/obj16/littleG.gif"
+ class="org.apache.geronimo.st.v30.ui.actions.LaunchGeronimoShellAction"
+ enablesFor="1">
+ </action>
+ </objectContribution>
+ </extension>
<extension point="org.apache.geronimo.st.ui.loader">
<loader class="org.apache.geronimo.st.v30.ui.editors.GeronimoFormContentLoader" version="3.0"/>
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/actions/LaunchGeronimoShellAction.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/actions/LaunchGeronimoShellAction.java?rev=1329813&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/actions/LaunchGeronimoShellAction.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/actions/LaunchGeronimoShellAction.java Tue Apr 24 15:59:58 2012
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v30.ui.actions;
+
+import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
+import org.apache.geronimo.st.v30.ui.Activator;
+import org.apache.geronimo.st.v30.ui.internal.Trace;
+import org.apache.geronimo.st.v30.ui.view.KarafShellSSHTerminalView;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.server.core.IServer;
+
+/**
+ * @version $Rev$ $Date: 2011-05-25 04:16:27 -0400 (Wed, 25 May 2011)
+ */
+public class LaunchGeronimoShellAction implements IActionDelegate {
+
+ private IServer server;
+
+ private String serverPrefix;
+
+ public LaunchGeronimoShellAction() {
+ IExtensionRegistry reg = Platform.getExtensionRegistry();
+ IConfigurationElement[] extensions = reg
+ .getConfigurationElementsFor("org.apache.geronimo.st.v30.ui.actionURLs");
+ for (IConfigurationElement element : extensions) {
+ Trace.trace(Trace.INFO, element.getName() + " = " + element.getValue() + ".", Activator.traceActions);
+ if (element.getName().equals("server_prefix")) {
+ serverPrefix = element.getValue();
+ Trace.trace(Trace.INFO, "server_prefix = " + serverPrefix + ".", Activator.traceActions);
+ }
+ }
+ }
+
+ public void run(IAction action) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ IWorkbenchWindow activeWKBench = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage activePage = getActivePage(activeWKBench);
+ try {
+ KarafShellSSHTerminalView terminalView = (KarafShellSSHTerminalView) activePage.showView(KarafShellSSHTerminalView.VIEW_ID);
+ GeronimoServerDelegate serverDelegate = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
+ terminalView.doConnect(serverDelegate);
+ } catch (Exception e) {
+ Trace.trace(Trace.ERROR, "Error starting Geronimo shell terminal", e, Activator.logCommands);
+ }
+ }
+ });
+ }
+
+ private IWorkbenchPage getActivePage(IWorkbenchWindow activeWKBench) {
+ IWorkbenchPage activePage = activeWKBench.getActivePage();
+ try {
+ while (activePage == null) {
+ Thread.sleep(100);
+ activePage = activeWKBench.getActivePage();
+ }
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ return activePage;
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ server = (IServer) ((StructuredSelection) selection).getFirstElement();
+ boolean enable = server != null
+ && server.getServerType().getId().startsWith(serverPrefix)
+ && (server.getServerState() == IServer.STATE_STARTED || server.getServerState() == IServer.STATE_STARTING)
+ && isShellEnabled(server);
+ action.setEnabled(enable);
+ }
+
+ private boolean isShellEnabled(IServer server) {
+ ILaunch launch = server.getLaunch();
+ if (launch != null) {
+ IProcess[] processes = launch.getProcesses();
+ if (processes != null && processes.length > 0) {
+ GeronimoServerDelegate delegate = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
+ return delegate.isKarafShell();
+ }
+ }
+ return true;
+ }
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/actions/LaunchGeronimoShellAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/actions/LaunchGeronimoShellAction.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/actions/LaunchGeronimoShellAction.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/Messages.properties
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/Messages.properties?rev=1329813&r1=1329812&r2=1329813&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/Messages.properties (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/Messages.properties Tue Apr 24 15:59:58 2012
@@ -108,19 +108,19 @@ changeOSGIBundleStartLevel=Change the Bu
changeOSGIBundleStartLevelDesc=Input new start level of the bundle.
changeOSGIBundleStartLevelDescOnError=The start level must be a integer, please try again.
-editorSectionKarafShellTitle=Karaf Shell in Eclipse Console
-editorSectionKarafShellDescription=Select whether to enable the Karaf shell in Eclipse console window.
+editorSectionKarafShellTitle=Geronimo Shell
+editorSectionKarafShellDescription=Specify whether to enable the Geronimo shell.
enableKarafShell=Enable
-karafShellTimeout=Timeout(sec):
-karafShellkeepAlive=Keep alive(sec):
+karafShellTimeout=Timeout (sec):
+karafShellkeepAlive=Keep alive (sec):
karafShellPort=Port:
-karafShellLaunch=Launch Karaf Shell
-karafShellNoConnection=Karaf Shell No Connection
-karafShellErrorConnect=Karaf Shell Connection Error
-karafShellNoConfigExisted=The Karaf shell configuration does not exist, please launch Karaf shell from the Server Page first time.
-karafShellTerminalTitle=Karaf Shell Terminal
-karafShellChangeEnableProblem=Change Karaf Shell Enablement
-karafShellMustChangeBeforeServerStart =The change of Karaf shell enablement will only be effective after server restart.
+karafShellLaunch=Launch Geronimo Shell
+karafShellNoConnection=Geronimo Shell - No Connection
+karafShellErrorConnect=Geronimo Shell - Connection Error
+karafShellNoConfigExisted=The Geronimo shell configuration does not exist. Please open Geronimo server configuration page.
+karafShellTerminalTitle=Geronimo Shell Terminal
+karafShellChangeEnableProblem=Geronimo Shell Configuration
+karafShellMustChangeBeforeServerStart=The Geronimo shell will be enabled after server restart.
editorSectionVMArgsTitle=Server VM Arguments
editorSectionVMArgsDescription=Specify the Java VM arguments to be provided on server startup.
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorKarafShellSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorKarafShellSection.java?rev=1329813&r1=1329812&r2=1329813&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorKarafShellSection.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/ServerEditorKarafShellSection.java Tue Apr 24 15:59:58 2012
@@ -16,22 +16,16 @@
*/
package org.apache.geronimo.st.v30.ui.sections;
-import org.apache.geronimo.st.core.ServerIdentifier;
import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
-import org.apache.geronimo.st.v30.ui.Activator;
-import org.apache.geronimo.st.v30.ui.CommonMessages;
import org.apache.geronimo.st.v30.ui.commands.SetKarafShellCommand;
import org.apache.geronimo.st.v30.ui.commands.SetKarafShellKeepAliveCommand;
import org.apache.geronimo.st.v30.ui.commands.SetKarafShellPortCommand;
import org.apache.geronimo.st.v30.ui.commands.SetKarafShellTimeoutCommand;
import org.apache.geronimo.st.v30.ui.internal.Messages;
-import org.apache.geronimo.st.v30.ui.internal.Trace;
-import org.apache.geronimo.st.v30.ui.view.KarafShellSSHTerminalView;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
@@ -40,17 +34,10 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerListener;
-import org.eclipse.wst.server.core.ServerEvent;
-import org.eclipse.wst.server.core.util.SocketUtil;
/**
* @version $Rev$ $Date$
@@ -61,11 +48,7 @@ public class ServerEditorKarafShellSecti
Text timeout;
Text keepAlive;
Text port;
- Button launchBtn;
-
- protected static final String terminalViewId = "org.apache.geronimo.st.v30.ui.view.KarafShellSSHTerminalView";
- protected static KarafShellSSHTerminalView terminalView;
-
+
public ServerEditorKarafShellSection() {
super();
}
@@ -146,7 +129,6 @@ public class ServerEditorKarafShellSecti
timeout.setEnabled(enable.getSelection());
keepAlive.setEnabled(enable.getSelection());
port.setEnabled(enable.getSelection());
- launchBtn.setEnabled(enable.getSelection() && server.getOriginal().getServerState() == IServer.STATE_STARTED);
}
});
@@ -183,90 +165,5 @@ public class ServerEditorKarafShellSecti
execute(new SetKarafShellPortCommand(server, port, value));
}
});
- // create launch ssh terminal button
- launchBtn = toolkit.createButton(subComp1, Messages.karafShellLaunch, SWT.PUSH);
- GridData buttonData = new GridData(SWT.LEFT, SWT.CENTER, false, false);
- launchBtn.setLayoutData(buttonData);
- launchBtn.setEnabled(enable.getSelection() && server.getOriginal().getServerState() == IServer.STATE_STARTED);
-
- launchBtn.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- if(! isLocalHost()) {
- MessageDialog.openError(Display.getCurrent().getActiveShell(), CommonMessages.errorOpenWizard, CommonMessages.isNotLocalHost);
- } else {
- connectToTerminal();
- }
- }
-
- });
- Activator.addServerListener(new ServerIdentifier(server.getOriginal()), new IServerListener() {
- @Override
- public void serverChanged(ServerEvent event) {
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- int state = server.getOriginal().getServerState();
- if(state > 4 || launchBtn.isDisposed()) return;
- launchBtn.setEnabled(enable.getSelection() && server.getOriginal().getServerState() == IServer.STATE_STARTED);
- }
- });
-
- }
- });
-
- }
-
- private boolean isLocalHost() {
- return !(server.getServerType().supportsRemoteHosts()
- && !SocketUtil.isLocalhost(server.getHost()));
- }
-
- private void connectToTerminal() {
- final IWorkbenchWindow activeWKBench = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- IWorkbenchPage activePage = getActivePage(activeWKBench);
- try {
- terminalView = (KarafShellSSHTerminalView) activePage.showView(terminalViewId);
- connect();
- } catch (PartInitException e) {
- e.printStackTrace();
- }
- }
- });
- }
-
- private void connect() {
- GeronimoServerDelegate serverDelegate = (GeronimoServerDelegate) server.getOriginal().getAdapter(GeronimoServerDelegate.class);
- terminalView.doConnect(serverDelegate);
- }
-
- private IWorkbenchPage getActivePage(IWorkbenchWindow activeWKBench) {
- try {
- IWorkbenchPage activePage = activeWKBench.getActivePage();
- while(activePage == null) {
- Thread.sleep(100);
- activePage = activeWKBench.getActivePage();
- }
- return activePage;
- } catch (InterruptedException e) {
- Trace.trace(Trace.ERROR, "Can not getActivePage", e, Activator.logCommands);
- throw new RuntimeException(e);
- } catch (Exception e) {
- Trace.trace(Trace.ERROR, e.getMessage(), e, Activator.logCommands);
- throw new RuntimeException(e);
- }
}
}
-
-
-
-
-
-
-
-
-
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/view/KarafShellSSHTerminalView.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/view/KarafShellSSHTerminalView.java?rev=1329813&r1=1329812&r2=1329813&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/view/KarafShellSSHTerminalView.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/view/KarafShellSSHTerminalView.java Tue Apr 24 15:59:58 2012
@@ -51,6 +51,9 @@ import org.eclipse.ui.PartInitException;
*/
@SuppressWarnings("restriction")
public class KarafShellSSHTerminalView extends TerminalView {
+
+ public static final String VIEW_ID = KarafShellSSHTerminalView.class.getName();
+
private TerminalActionScrollLock fActionTerminalScrollLock;
protected GeronimoServerDelegate currentServerDelegate;