Author: scabanovich
Date: 2012-03-14 14:25:37 -0400 (Wed, 14 Mar 2012)
New Revision: 39515
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/browser/wtp/RunOnServerContext.java
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/server/ServerManager.java
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/server/ServerManagerListener.java
Log:
JBIDE-11306
https://issues.jboss.org/browse/JBIDE-11306
'Run on Server' on struts/jsf objects.
Modified: trunk/jst/plugins/org.jboss.tools.jst.web/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/META-INF/MANIFEST.MF 2012-03-14 18:23:33 UTC
(rev 39514)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/META-INF/MANIFEST.MF 2012-03-14 18:25:37 UTC
(rev 39515)
@@ -11,6 +11,7 @@
Require-Bundle: org.jboss.tools.common.model;visibility:=reexport,
org.jboss.tools.common.projecttemplates;visibility:=reexport,
org.jboss.tools.common.validation,
+ org.jboss.ide.eclipse.as.ui;visibility:=reexport,
org.eclipse.ui;bundle-version="3.7.0",
org.eclipse.jdt.launching;bundle-version="3.6.0",
org.eclipse.debug.ui;bundle-version="3.7.0",
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/browser/wtp/RunOnServerContext.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/browser/wtp/RunOnServerContext.java 2012-03-14
18:23:33 UTC (rev 39514)
+++
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/browser/wtp/RunOnServerContext.java 2012-03-14
18:25:37 UTC (rev 39515)
@@ -16,14 +16,17 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.browser.IWebBrowser;
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
import org.eclipse.wst.server.core.*;
+import org.eclipse.wst.server.core.IServer.IOperationListener;
import org.eclipse.wst.server.core.internal.*;
import org.eclipse.wst.server.core.util.*;
@@ -114,7 +117,7 @@
protected void doExecute(String lastRunUrl) throws XModelException {
ServiceDialog d = PreferenceModelUtilities.getPreferenceModel().getService();
- IServer server = ServerManager.getInstance().getSelectedServer();
+ final IServer server = ServerManager.getInstance().getSelectedServer();
if(server == null) {
if(lastRunUrl != null && lastRunUrl.startsWith("%server%")) {
//$NON-NLS-1$
String message = WebUIMessages.PLEASE_CREATE_A_SERVER_AND_SELECT_IT_ON_TOOLBAR;
@@ -128,11 +131,23 @@
server.getModules();
- String launchMode = ILaunchManager.DEBUG_MODE.equals(server.getMode()) ?
ILaunchManager.DEBUG_MODE : ILaunchManager.RUN_MODE;
+ final String launchMode = ILaunchManager.DEBUG_MODE.equals(server.getMode()) ?
ILaunchManager.DEBUG_MODE : ILaunchManager.RUN_MODE;
try {
- Object launchable = new HttpLaunchable(new URL(lastRunUrl));
- IClient[] clients = getClients(server, launchable, launchMode);
- IClient client = clients[0];
+ final Object launchable = new HttpLaunchable(new URL(lastRunUrl));
+ final IClient[] clients = getClients(server, launchable, launchMode);
+ final IClient client = clients[0];
+ if(server.getLaunch() == null) {
+ server.start(launchMode, new IOperationListener() {
+ public void done(IStatus result) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ client.launch(server, launchable, launchMode, server.getLaunch());
+ }
+ });
+ }
+ });
+ return;
+ }
client.launch(server, launchable, launchMode, server.getLaunch());
} catch (MalformedURLException e) {
WebModelPlugin.getPluginLog().logError(e);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/server/ServerManager.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/server/ServerManager.java 2012-03-14
18:23:33 UTC (rev 39514)
+++
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/server/ServerManager.java 2012-03-14
18:25:37 UTC (rev 39515)
@@ -10,173 +10,5 @@
******************************************************************************/
package org.jboss.tools.jst.web.server;
-import java.util.*;
-
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.wst.server.core.*;
-import org.jboss.tools.jst.web.WebModelPlugin;
-
-public class ServerManager {
- private static ServerManager instance;
-
- public static synchronized ServerManager getInstance() {
- if(instance == null) {
- instance = new ServerManager();
- }
- return instance;
- }
-
- private List<ServerManagerListener> listeners = new
ArrayList<ServerManagerListener>();
- private IServerListener serverListener;
- protected IServer[] servers = new IServer[0];
-
- IServer selected = null;
-
- public ServerManager() {
- serverListener = new ServerListenerImpl();
- load();
- }
-
- void load() {
- servers = (IServer[])ServerCore.getServers().clone();
- loadSelectedServer();
- ServerResourceListenerImpl listener = new ServerResourceListenerImpl();
- ServerCore.addRuntimeLifecycleListener(listener);
- ServerCore.addServerLifecycleListener(listener);
- }
-
- private void loadSelectedServer() {
- if(servers == null || servers.length == 0) return;
- String ds = getDefaultWebServer();
- IServer s = getServer(ds);
- if(s == null && servers.length > 0) {
- s = servers[0];
- setDefaultWebServer(servers[0].getId());
- }
- setSelectedServerInternal(s);
- }
-
- public IServer[] getServers() {
- return servers;
- }
-
- public IServer getServer(String serverId) {
- for (int i = 0; i < servers.length; i++) {
- if(servers[i].getId().equals(serverId)) {
- return servers[i];
- }
- }
- return null;
- }
-
- public void addListener(ServerManagerListener listener) {
- if(!listeners.contains(listener)) listeners.add(listener);
- }
-
- public void removeListener(ServerManagerListener listener) {
- listeners.remove(listener);
- }
-
- void fire() {
- ServerManagerListener[] ls = (ServerManagerListener[])listeners.toArray(new
ServerManagerListener[0]);
- for (int i = 0; i < ls.length; i++) {
- ls[i].serverManagerChanged();
- }
- }
-
- public void setSelectedServer(String id) {
- IServer server = getServer(id);
- if(server == selected) return;
- setSelectedServerInternal(server);
- setDefaultWebServer(id);
- fire();
- }
-
- private void setSelectedServerInternal(IServer server) {
- if(selected == server) return;
- if(selected != null) selected.removeServerListener(serverListener);
- selected = server;
- if(selected != null) selected.addServerListener(serverListener);
- }
-
- public String getSelectedServerId() {
- String result = getDefaultWebServer();
- return result == null ? "" : result; //$NON-NLS-1$
- }
-
- public IServer getSelectedServer() {
- return selected;
- }
-
- class ServerResourceListenerImpl implements IRuntimeLifecycleListener,
IServerLifecycleListener {
- public void serverAdded(IServer server) {
- IServer[] ss = new IServer[servers.length + 1];
- System.arraycopy(servers, 0, ss, 0, servers.length);
- ss[servers.length] = server;
- servers = ss;
- loadSelectedServer();
- fire();
- }
- public void serverChanged(IServer server) {
- fire();
- }
- public void serverRemoved(IServer server) {
- List<IServer> l = new ArrayList<IServer>();
- for (int i = 0; i < servers.length; i++) {
- if(servers[i] != server) l.add(servers[i]);
- }
- if(l.size() == servers.length) return;
- servers = l.toArray(new IServer[0]);
- loadSelectedServer();
- fire();
- }
- public void runtimeAdded(IRuntime runtime) {
- fire();
- }
- public void runtimeChanged(IRuntime runtime) {
- fire();
- }
- public void runtimeRemoved(IRuntime runtime) {
- fire();
- }
- }
-
- class ServerListenerImpl implements IServerListener {
- public void serverChanged(ServerEvent arg0) {
- fire();
- }
- }
-
- static String DEFAULT_WEB_SERVER = WebModelPlugin.PLUGIN_ID +
".defaultWebServer"; //$NON-NLS-1$
-
- static String getDefaultWebServer() {
- String result = getInstancePreference(DEFAULT_WEB_SERVER);
- return result;
- }
-
- static void setDefaultWebServer(String value) {
- getInstancePreferences().put(DEFAULT_WEB_SERVER, value);
- }
-
- static IEclipsePreferences getInstancePreferences() {
- return new InstanceScope().getNode(WebModelPlugin.PLUGIN_ID);
- }
-
- static IEclipsePreferences getDefaultPreferences() {
- return new DefaultScope().getNode(WebModelPlugin.PLUGIN_ID);
- }
-
- static String getInstancePreference(String key) {
- IEclipsePreferences p = getInstancePreferences();
- String value = p == null ? null : p.get(key, null);
- return value != null ? value : getDefaultPreference(key);
- }
-
- static String getDefaultPreference(String key) {
- IEclipsePreferences p = getDefaultPreferences();
- return p == null ? null : p.get(key, null);
- }
-
+public class ServerManager extends org.jboss.ide.eclipse.as.ui.actions.ServerManager {
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/server/ServerManagerListener.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/server/ServerManagerListener.java 2012-03-14
18:23:33 UTC (rev 39514)
+++
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/server/ServerManagerListener.java 2012-03-14
18:25:37 UTC (rev 39515)
@@ -10,7 +10,5 @@
******************************************************************************/
package org.jboss.tools.jst.web.server;
-public interface ServerManagerListener {
- public void serverManagerChanged();
-
+public interface ServerManagerListener extends
org.jboss.ide.eclipse.as.ui.actions.ServerManagerListener {
}