[jbosstools-commits] JBoss Tools SVN: r39401 - in trunk: as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal and 5 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Fri Mar 9 05:06:59 EST 2012


Author: rob.stryker at jboss.com
Date: 2012-03-09 05:06:57 -0500 (Fri, 09 Mar 2012)
New Revision: 39401

Added:
   trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/IExtendedPropertiesProvider.java
   trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/ServerExtendedProperties.java
   trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerExtendedProperties.java
Removed:
   trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ShowInWelcomePageActionProvider.java
Modified:
   trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/ExtendedServerPropertiesAdapterFactory.java
   trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/JBossExtendedProperties.java
   trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
   trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ShowInWelcomePageActionProvider.java
   trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
   trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServer.java
Log:
JBIDE-11231   unifying the welcome page url actions (to trunk only)

Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/ExtendedServerPropertiesAdapterFactory.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/ExtendedServerPropertiesAdapterFactory.java	2012-03-09 08:54:01 UTC (rev 39400)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/ExtendedServerPropertiesAdapterFactory.java	2012-03-09 10:06:57 UTC (rev 39401)
@@ -10,12 +10,15 @@
  ******************************************************************************/ 
 package org.jboss.ide.eclipse.as.core.server.internal;
 
+import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.wst.server.core.IRuntime;
 import org.eclipse.wst.server.core.IServer;
 import org.jboss.ide.eclipse.as.core.server.internal.extendedproperties.JBossAS710ExtendedProperties;
 import org.jboss.ide.eclipse.as.core.server.internal.extendedproperties.JBossAS7ExtendedProperties;
 import org.jboss.ide.eclipse.as.core.server.internal.extendedproperties.JBossExtendedProperties;
+import org.jboss.ide.eclipse.as.core.server.internal.extendedproperties.ServerExtendedProperties;
 import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
 
 public class ExtendedServerPropertiesAdapterFactory implements IAdapterFactory, IJBossToolingConstants {
@@ -26,7 +29,7 @@
 	
 	@Override
 	public Object getAdapter(Object adaptableObject, Class adapterType) {
-		if( adapterType != JBossExtendedProperties.class )
+		if( adapterType != ServerExtendedProperties.class )
 			return null;
 		String typeId = null;
 		IServer s = null;
@@ -38,39 +41,49 @@
 			typeId = ((IRuntime)adaptableObject).getRuntimeType().getId();
 			r = (IRuntime)adaptableObject;
 		}
+		IAdaptable adaptable = s == null ? r : s;
 		if( typeId != null ) {
 			if( SERVER_AS_32.equals(typeId) || AS_32.equals(typeId)) 
-				return new JBossExtendedProperties(s == null ? r : s);
+				return new JBossExtendedProperties(adaptable);
 			if( SERVER_AS_40.equals(typeId) || AS_40.equals(typeId)) 
-				return new JBossExtendedProperties(s == null ? r : s);
+				return new JBossExtendedProperties(adaptable);
 			if( SERVER_AS_42.equals(typeId) || AS_42.equals(typeId))
-				return new JBossExtendedProperties(s == null ? r : s);
+				return new JBossExtendedProperties(adaptable);
 			if( SERVER_AS_50.equals(typeId) || AS_50.equals(typeId))
-				return new JBossExtendedProperties(s == null ? r : s);
+				return new JBossExtendedProperties(adaptable);
 			if( SERVER_AS_51.equals(typeId) || AS_51.equals(typeId))
-				return new JBossExtendedProperties(s == null ? r : s);
+				return new JBossExtendedProperties(adaptable);
 			if( SERVER_AS_60.equals(typeId) || AS_60.equals(typeId))
-				return new JBossExtendedProperties(s == null ? r : s);
+				return new JBossExtendedProperties(adaptable);
 			if( SERVER_EAP_43.equals(typeId) || EAP_43.equals(typeId))
-				return new JBossExtendedProperties(s == null ? r : s);
+				return new JBossExtendedProperties(adaptable);
 			if( SERVER_EAP_50.equals(typeId) || EAP_50.equals(typeId))
-				return new JBossExtendedProperties(s == null ? r : s);
+				return new JBossExtendedProperties(adaptable);
 			
 			if( SERVER_AS_70.equals(typeId) || AS_70.equals(typeId))
-				return new JBossAS7ExtendedProperties(s == null ? r : s);
+				return new JBossAS7ExtendedProperties(adaptable);
 			if( SERVER_AS_71.equals(typeId) || AS_71.equals(typeId))
-				return new JBossAS710ExtendedProperties(s == null ? r : s);
+				return new JBossAS710ExtendedProperties(adaptable);
 			if( SERVER_EAP_60.equals(typeId) || EAP_60.equals(typeId))
-				return new JBossAS710ExtendedProperties(s == null ? r : s);
+				return new JBossAS710ExtendedProperties(adaptable);
 			
 			// NEW_SERVER_ADAPTER
 		}
+		
+		// Last ditch
+		if( s != null ) {
+			IExtendedPropertiesProvider propProvider = (IExtendedPropertiesProvider)
+					s.loadAdapter(IExtendedPropertiesProvider.class, new NullProgressMonitor());
+			if( propProvider != null ) {
+				return propProvider.getExtendedProperties();
+			}
+		}
 		return null;
 	}
 
 	@Override
 	public Class[] getAdapterList() {
-		return new Class[]{ JBossExtendedProperties.class};
+		return new Class[]{ ServerExtendedProperties.class};
 	}
 
 }

Added: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/IExtendedPropertiesProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/IExtendedPropertiesProvider.java	                        (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/IExtendedPropertiesProvider.java	2012-03-09 10:06:57 UTC (rev 39401)
@@ -0,0 +1,7 @@
+package org.jboss.ide.eclipse.as.core.server.internal;
+
+import org.jboss.ide.eclipse.as.core.server.internal.extendedproperties.ServerExtendedProperties;
+
+public interface IExtendedPropertiesProvider {
+	public ServerExtendedProperties getExtendedProperties();
+}

Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/JBossExtendedProperties.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/JBossExtendedProperties.java	2012-03-09 08:54:01 UTC (rev 39400)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/JBossExtendedProperties.java	2012-03-09 10:06:57 UTC (rev 39401)
@@ -1,11 +1,24 @@
+/******************************************************************************* 
+ * Copyright (c) 2012 Red Hat, Inc. 
+ * Distributed under license by Red Hat, Inc. All rights reserved. 
+ * This program is 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: 
+ * Red Hat, Inc. - initial API and implementation 
+ ******************************************************************************/ 
 package org.jboss.ide.eclipse.as.core.server.internal.extendedproperties;
 
+import java.text.MessageFormat;
+
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.IServer;
 import org.jboss.ide.eclipse.as.core.resolvers.ConfigNameResolver;
 import org.jboss.ide.eclipse.as.core.server.bean.ServerBeanLoader;
+import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
 import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
+import org.jboss.ide.eclipse.as.core.util.ServerUtil;
 
 /**
  * The superclass containing most functionality, to be overridden as necessary.
@@ -13,22 +26,19 @@
  * else, but need to be customized on a per-server or per-server-type basis
  *
  */
-public class JBossExtendedProperties {
-	private IServer server;
-	private IRuntime runtime;
+public class JBossExtendedProperties extends ServerExtendedProperties {
 	public JBossExtendedProperties(IAdaptable adaptable) {
-		if( adaptable instanceof IServer) {
-			this.server = (IServer)adaptable;
-			this.runtime = server.getRuntime();
-		} else if( adaptable instanceof IRuntime){
-			this.runtime = (IRuntime)adaptable;
-		}
+		super(adaptable);
 	}
 
-	public String getNewFilesetDefaultRootFolder() {
-		return "servers/${jboss_config}"; //$NON-NLS-1$
+	public boolean runtimeSupportsBindingToAllInterfaces() {
+		return true;
 	}
 	
+	protected ServerBeanLoader getServerBeanLoader() {
+		return new ServerBeanLoader(runtime.getLocation().toFile());
+	}
+	
 	/**
 	 * Returns the full path of a local server's server/{config}/deploy folder
 	 */
@@ -38,21 +48,26 @@
 		return new ConfigNameResolver().performSubstitutions(
 				original, server.getName());
 	}
-	
-	
-	public static final int JMX_DEFAULT_PROVIDER = 0;
-	public static final int JMX_AS_3_TO_6_PROVIDER = 1;
-	public static final int JMX_AS_710_PROVIDER = 2;
+
 	public int getJMXProviderType() {
 		return JMX_AS_3_TO_6_PROVIDER;
 	}
 	
-	
-	public boolean runtimeSupportsBindingToAllInterfaces() {
+	public boolean hasWelcomePage() {
 		return true;
 	}
 	
-	protected ServerBeanLoader getServerBeanLoader() {
-		return new ServerBeanLoader(runtime.getLocation().toFile());
+	protected static final String WELCOME_PAGE_URL_PATTERN = "http://{0}:{1}/"; //$NON-NLS-1$
+	public String getWelcomePageUrl() {
+		try {
+			JBossServer jbossServer = ServerUtil.checkedGetServerAdapter(server, JBossServer.class);
+			String host = jbossServer.getHost();
+			int webPort = jbossServer.getJBossWebPort();
+			String consoleUrl = MessageFormat.format(WELCOME_PAGE_URL_PATTERN, host, String.valueOf(webPort));
+			return consoleUrl;
+		} catch(CoreException ce) {
+			return null;
+		}
 	}
+
 }

Added: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/ServerExtendedProperties.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/ServerExtendedProperties.java	                        (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/extendedproperties/ServerExtendedProperties.java	2012-03-09 10:06:57 UTC (rev 39401)
@@ -0,0 +1,38 @@
+package org.jboss.ide.eclipse.as.core.server.internal.extendedproperties;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IServer;
+
+public class ServerExtendedProperties {
+	protected IServer server;
+	protected IRuntime runtime;
+	public ServerExtendedProperties(IAdaptable adaptable) {
+		if( adaptable instanceof IServer) {
+			this.server = (IServer)adaptable;
+			this.runtime = server.getRuntime();
+		} else if( adaptable instanceof IRuntime){
+			this.runtime = (IRuntime)adaptable;
+		}
+	}
+
+	public String getNewFilesetDefaultRootFolder() {
+		return "servers/${jboss_config}"; //$NON-NLS-1$
+	}
+	
+	public static final int JMX_NULL_PROVIDER = -1;
+	public static final int JMX_DEFAULT_PROVIDER = 0;
+	public static final int JMX_AS_3_TO_6_PROVIDER = 1;
+	public static final int JMX_AS_710_PROVIDER = 2;
+	public int getJMXProviderType() {
+		return JMX_NULL_PROVIDER;
+	}
+	
+	public boolean hasWelcomePage() {
+		return false;
+	}
+	
+	public String getWelcomePageUrl() {
+		return null;
+	}
+}

Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml	2012-03-09 08:54:01 UTC (rev 39400)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml	2012-03-09 10:06:57 UTC (rev 39401)
@@ -1196,7 +1196,7 @@
             adaptableType="org.eclipse.wst.server.core.IServer"
             class="org.jboss.ide.eclipse.as.core.server.internal.ExtendedServerPropertiesAdapterFactory">
          <adapter
-               type="org.jboss.ide.eclipse.as.core.server.internal.extendedproperties.JBossExtendedProperties">
+               type="org.jboss.ide.eclipse.as.core.server.internal.extendedproperties.ServerExtendedProperties">
          </adapter>
       </factory>
    </extension>

Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ShowInWelcomePageActionProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ShowInWelcomePageActionProvider.java	2012-03-09 08:54:01 UTC (rev 39400)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ShowInWelcomePageActionProvider.java	2012-03-09 10:06:57 UTC (rev 39401)
@@ -11,9 +11,11 @@
 package org.jboss.ide.eclipse.as.ui.views.server.extensions;
 
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.wst.server.core.IServer;
 import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
+import org.jboss.ide.eclipse.as.core.server.internal.extendedproperties.ServerExtendedProperties;
 import org.jboss.ide.eclipse.as.core.util.ServerUtil;
 import org.jboss.ide.eclipse.as.ui.Messages;
 
@@ -28,8 +30,12 @@
 	
 	protected boolean shouldAddForSelection(IStructuredSelection sel) {
 		IServer server = getSingleServer(sel);
-		if( server != null )
-			return ServerUtil.isJBossServerType(server.getServerType()) && accepts(server);
+		if( server != null ) {
+			ServerExtendedProperties props = (ServerExtendedProperties)
+					server.loadAdapter(ServerExtendedProperties.class, new NullProgressMonitor());
+			if( props != null && props.hasWelcomePage())
+				return true;
+		}
 		return false;
 	}
 
@@ -38,11 +44,8 @@
 	}
 	
 	protected String getURL(IServer server) throws CoreException {
-		JBossServer jbossServer = ServerUtil.checkedGetServerAdapter(server, JBossServer.class);
-		String host = jbossServer.getHost();
-		int webPort = jbossServer.getJBossWebPort();
-		String consoleUrl = MessageFormat.format(WELCOME_PAGE_URL_PATTERN, host, String.valueOf(webPort));
-		return consoleUrl;
+		ServerExtendedProperties props = (ServerExtendedProperties)
+				server.loadAdapter(ServerExtendedProperties.class, new NullProgressMonitor());
+		return props.getWelcomePageUrl();
 	}
-
 }

Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml	2012-03-09 08:54:01 UTC (rev 39400)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml	2012-03-09 10:06:57 UTC (rev 39401)
@@ -177,31 +177,7 @@
 	    </viewerActionBinding>
 	</extension>
 
-    <extension
-      point="org.eclipse.ui.navigator.navigatorContent">
- 		<actionProvider
-          class="org.jboss.tools.openshift.express.internal.ui.behaviour.ShowInWelcomePageActionProvider"
-          id="org.jboss.tools.openshift.express.internal.ui.behaviour.ShowInWelcomePageActionProvider">
-       		<enablement>
-          		<instanceof
-                	value="org.eclipse.wst.server.core.IServer">
-          		</instanceof>
-       		</enablement>
-    	</actionProvider>
-    </extension>  
-	<extension point="org.eclipse.ui.navigator.viewer">
-		<viewerContentBinding viewerId="org.eclipse.wst.server.ui.ServersView">
-		</viewerContentBinding>
-    	<viewerActionBinding viewerId="org.eclipse.wst.server.ui.ServersView">
-	       <includes>
-	          <actionExtension
-	                pattern="org.jboss.tools.openshift.express.internal.ui.behaviour.ShowInWelcomePageActionProvider"/>
-	       </includes>
-	    </viewerActionBinding>
-	</extension>
-
     <!-- Extensions to Server View to provide 'tail' of the remote server.log file -->
-    
 	<extension point="org.eclipse.ui.navigator.navigatorContent">
 		<actionProvider
 				class="org.jboss.tools.openshift.express.internal.ui.console.TailServerLogActionProvider"

Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServer.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServer.java	2012-03-09 08:54:01 UTC (rev 39400)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServer.java	2012-03-09 10:06:57 UTC (rev 39401)
@@ -22,11 +22,13 @@
 import org.eclipse.wst.server.core.model.IURLProvider;
 import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
 import org.jboss.ide.eclipse.as.core.server.internal.DeployableServer;
+import org.jboss.ide.eclipse.as.core.server.internal.IExtendedPropertiesProvider;
 import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
+import org.jboss.ide.eclipse.as.core.server.internal.extendedproperties.ServerExtendedProperties;
 import org.jboss.ide.eclipse.as.core.util.ServerUtil;
 import org.jboss.ide.eclipse.as.wtp.core.util.ServerModelUtilities;
 
-public class ExpressServer extends DeployableServer implements IURLProvider {
+public class ExpressServer extends DeployableServer implements IURLProvider, IExtendedPropertiesProvider {
 	public void setDefaults(IProgressMonitor monitor) {
 		getServerWorkingCopy().setName(ServerUtil.getDefaultServerName(getServer().getServerType().getName()));
 		setAttribute(IDeployableServer.SERVER_MODE, ExpressBehaviourDelegate.OPENSHIFT_ID);
@@ -54,7 +56,6 @@
 			IProgressMonitor monitor) throws CoreException {
 	}
 
-	@Override
 	public URL getModuleRootURL(IModule module) {
 		String appProjString = ExpressServerUtils.getExpressDeployProject(getServer());
 		IProject appProj = appProjString == null ? null : ResourcesPlugin.getWorkspace().getRoot().getProject(appProjString);
@@ -62,4 +63,8 @@
 		boolean shouldIgnore = ExpressServerUtils.getIgnoresContextRoot(getServer()) && p.equals(appProj);		
 		return JBossServer.getModuleRootURL(module, getServer().getHost(), 80, shouldIgnore);
 	}
+	
+	public ServerExtendedProperties getExtendedProperties() {
+		return new ExpressServerExtendedProperties(getServer());
+	}
 }

Added: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerExtendedProperties.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerExtendedProperties.java	                        (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerExtendedProperties.java	2012-03-09 10:06:57 UTC (rev 39401)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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:
+ *     Red Hat Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.openshift.express.internal.core.behaviour;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.osgi.util.NLS;
+import org.jboss.ide.eclipse.as.core.server.internal.extendedproperties.ServerExtendedProperties;
+import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
+
+import com.openshift.express.client.IApplication;
+import com.openshift.express.client.OpenShiftException;
+
+public class ExpressServerExtendedProperties extends ServerExtendedProperties {
+
+	public ExpressServerExtendedProperties(IAdaptable adaptable) {
+		super(adaptable);
+	}
+	public boolean hasWelcomePage() {
+		return true;
+	}
+	
+	public String getWelcomePageUrl() {
+		if (!ExpressServerUtils.isOpenShiftRuntime(server)) {
+			return null;
+		}
+		IApplication application = ExpressServerUtils.findApplicationForServer(server);
+		if (application != null) {
+			try {
+				return application.getApplicationUrl();
+			} catch (OpenShiftException e) {
+				IStatus status = OpenShiftUIActivator.createErrorStatus(
+						NLS.bind("Could not get application url for server {0}", server.getName()), e);
+				OpenShiftUIActivator.log(status);
+			}
+		}
+		return null;
+	}
+}

Deleted: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ShowInWelcomePageActionProvider.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ShowInWelcomePageActionProvider.java	2012-03-09 08:54:01 UTC (rev 39400)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ShowInWelcomePageActionProvider.java	2012-03-09 10:06:57 UTC (rev 39401)
@@ -1,78 +0,0 @@
-/******************************************************************************* 
- * Copyright (c) 2011 Red Hat, Inc. 
- * Distributed under license by Red Hat, Inc. All rights reserved. 
- * This program is 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: 
- * Red Hat, Inc. - initial API and implementation 
- ******************************************************************************/
-package org.jboss.tools.openshift.express.internal.ui.behaviour;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.server.core.IServer;
-import org.jboss.ide.eclipse.as.ui.Messages;
-import org.jboss.ide.eclipse.as.ui.views.server.extensions.AbstractOpenBrowserServerAction;
-import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
-import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
-
-import com.openshift.express.client.IApplication;
-import com.openshift.express.client.OpenShiftException;
-
-/**
- * Action that shows the welcome page for a given openshift application. This is
- * actually a copy of org.jboss.ide.eclipse.as.ui.views.server.extensions.
- * ShowInWelcomePageActionProvider, should be consolidated at some point.
- * 
- * @author Andre Dietisheim
- */
-public class ShowInWelcomePageActionProvider extends AbstractOpenBrowserServerAction {
-
-	protected String getActionText() {
-		return Messages.ShowInWelcomePage_Action_Text;
-	}
-
-	protected boolean shouldAddForSelection(IStructuredSelection sel) {
-		IServer server = getSingleServer(sel);
-		boolean shouldAddForSelection = false;
-		/**
-		 * TODO: move this logic to the server, allow this action to ask the
-		 * server if it supports welcome page: ex. #hasWelcomePage
-		 */
-		if (server != null) {
-			shouldAddForSelection = 
-					ExpressServerUtils.isOpenShiftRuntime(server)
-					&& accepts(server);
-		}
-		return shouldAddForSelection;
-	}
-
-	protected boolean accepts(IServer server) {
-		return server.getServerState() == IServer.STATE_STARTED;
-	}
-
-	/**
-	 * TODO: move this logic to the server, allow this action to ask the
-	 * server for welcome page: ex. #getWelcomePage
-	 */
-	protected String getURL(IServer server) throws CoreException {
-		if (!ExpressServerUtils.isOpenShiftRuntime(server)) {
-			return null;
-		}
-		IApplication application = ExpressServerUtils.findApplicationForServer(server);
-		if (application == null) {
-			return null;
-		}
-		try {
-			return application.getApplicationUrl();
-		} catch (OpenShiftException e) {
-			IStatus status = OpenShiftUIActivator.createErrorStatus(
-					NLS.bind("Could not get application url for server {0}", server.getName()), e);
-			throw new CoreException(status);
-		}
-	}
-}



More information about the jbosstools-commits mailing list