Author: adietish
Date: 2012-02-28 02:49:23 -0500 (Tue, 28 Feb 2012)
New Revision: 39162
Added:
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ShowInWelcomePageActionProvider.java
Modified:
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
Log:
[JBIDE-11052] added separate action to show welcome page on OpenShift server adapters
Modified:
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
===================================================================
---
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-02-28
07:22:15 UTC (rev 39161)
+++
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-02-28
07:49:23 UTC (rev 39162)
@@ -171,6 +171,40 @@
sourcePathComputerId="org.eclipse.jst.server.generic.core.sourcePathComputer"/>
</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.ui.internal.ui.console.tailServerLogActionProvider"/>
+ </includes>
+ </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">
Modified:
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
===================================================================
---
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2012-02-28
07:22:15 UTC (rev 39161)
+++
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2012-02-28
07:49:23 UTC (rev 39162)
@@ -19,6 +19,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jgit.transport.URIish;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.IServerAttributes;
@@ -35,6 +36,7 @@
import org.jboss.ide.eclipse.as.core.util.ServerCreationUtils;
import org.jboss.tools.openshift.egit.core.EGitUtils;
import org.jboss.tools.openshift.express.internal.core.console.UserModel;
+import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
import
org.jboss.tools.openshift.express.internal.ui.wizard.IOpenShiftExpressWizardModel;
import com.openshift.express.client.IApplication;
@@ -328,17 +330,25 @@
}
public static IProject findProjectForServersApplication(IServer server) {
+ IApplication app = findApplicationForServer(server);
+ if (app == null) {
+ return null;
+ }
+ return ExpressServerUtils.findProjectForApplication(app);
+ }
+
+ public static IApplication findApplicationForServer(IServer server) {
try {
String user = ExpressServerUtils.getExpressUsername(server);
IUser user2 = UserModel.getDefault().findUser(user);
String appName = ExpressServerUtils.getExpressApplicationName(server);
IApplication app = user2.getApplicationByName(appName);
- IProject destProj = ExpressServerUtils.findProjectForApplication(app);
- return destProj;
+ return app;
} catch(OpenShiftException ose) {
- //TODO log and throw core e
+ Logger.error(NLS.bind("Could not find application for server {0}",
server.getName()));
+ return null;
}
- return null;
}
+
}
Added:
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ShowInWelcomePageActionProvider.java
===================================================================
---
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ShowInWelcomePageActionProvider.java
(rev 0)
+++
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ShowInWelcomePageActionProvider.java 2012-02-28
07:49:23 UTC (rev 39162)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * 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);
+ }
+ }
+}
Property changes on:
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ShowInWelcomePageActionProvider.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain