Author: adietish
Date: 2012-10-11 16:13:37 -0400 (Thu, 11 Oct 2012)
New Revision: 44441
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/connection/ConnectionUtils.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/connection/ConnectionsModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/CreateServerAdapterAction.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/EditCartridgesAction.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsComposite.java
Log:
[JBIDE-12798] changed server adapter wizard to support available connections now.
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2012-10-11
19:26:19 UTC (rev 44440)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2012-10-11
20:13:37 UTC (rev 44441)
@@ -11,6 +11,7 @@
package org.jboss.tools.openshift.express.internal.core.behaviour;
import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -40,6 +41,7 @@
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
import org.jboss.tools.openshift.egit.core.EGitUtils;
import org.jboss.tools.openshift.express.internal.core.connection.Connection;
+import org.jboss.tools.openshift.express.internal.core.connection.ConnectionUtils;
import org.jboss.tools.openshift.express.internal.core.connection.ConnectionsModel;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
@@ -91,7 +93,7 @@
public static final String OPENSHIFT_SERVER_TYPE =
"org.jboss.tools.openshift.express.openshift.server.type";
/* For use inside express wizard fragment */
- public static final String TASK_WIZARD_ATTR_USER = "user";
+ public static final String TASK_WIZARD_ATTR_CONNECTION = "connection";
public static final String TASK_WIZARD_ATTR_DOMAIN = "domain";
public static final String TASK_WIZARD_ATTR_APP_LIST = "appList";
public static final String TASK_WIZARD_ATTR_SELECTED_APP = "application";
@@ -128,7 +130,7 @@
final String appName = getExpressApplicationName(server);
final String userName = getExpressUsername(server);
try {
- final Connection ud = ConnectionsModel.getDefault().getConnection(userName);
+ final Connection ud = ConnectionsModel.getDefault().getConnectionByUrl(userName);
if (ud != null) {
return ud.getApplicationByName(appName); // May be long running
}
@@ -165,12 +167,12 @@
getExpressDeployProject2(attributes), SETTING_CONNECTIONURL, null);
if (connectionValue == null) {
String username = getExpressUsername(attributes);
-// connectionValue =
ConnectionUtils.getUrlForUsername(getExpressUsername(attributes));
try {
- connectionValue = new Connection(username, null).toURLString();
+ connectionValue = ConnectionUtils.getUrlForUsername(username);
} catch (UnsupportedEncodingException e) {
OpenShiftUIActivator.log(NLS.bind("Could not get connection url for user
{0}", username), e);
- return null;
+ } catch (MalformedURLException e) {
+ OpenShiftUIActivator.log(NLS.bind("Could not get connection url for user
{0}", username), e);
}
}
@@ -443,7 +445,7 @@
public static IApplication findApplicationForServer(IServerAttributes server) {
try {
String user = ExpressServerUtils.getExpressUsername(server);
- Connection connection = ConnectionsModel.getDefault().getConnection(user);
+ Connection connection = ConnectionsModel.getDefault().getConnectionByUrl(user);
String appName = ExpressServerUtils.getExpressApplicationName(server);
IApplication app = connection == null ? null :
connection.getApplicationByName(appName);
return app;
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/connection/ConnectionUtils.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/connection/ConnectionUtils.java 2012-10-11
19:26:19 UTC (rev 44440)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/connection/ConnectionUtils.java 2012-10-11
20:13:37 UTC (rev 44441)
@@ -33,17 +33,9 @@
// inhibit instantiation
}
- public static String getUrlForUsername(String username) {
- UrlPortions portions;
- try {
- portions = UrlUtils.toPortions(getDefaultHostUrl());
- return UrlUtils.getUrlFor(username, portions.getHost(), portions.getProtocol());
- } catch (UnsupportedEncodingException e) {
- OpenShiftUIActivator.log(NLS.bind("Could not get default host for user {0}",
username), e);
- } catch (MalformedURLException e) {
- OpenShiftUIActivator.log(NLS.bind("Could not get default host for user {0}",
username), e);
- }
- return null;
+ public static String getUrlForUsername(String username) throws
UnsupportedEncodingException, MalformedURLException {
+ UrlPortions portions = UrlUtils.toPortions(getDefaultHostUrl());
+ return UrlUtils.getUrlFor(username, portions.getHost(), portions.getProtocol());
}
/**
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/connection/ConnectionsModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/connection/ConnectionsModel.java 2012-10-11
19:26:19 UTC (rev 44440)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/connection/ConnectionsModel.java 2012-10-11
20:13:37 UTC (rev 44441)
@@ -85,7 +85,9 @@
this.recentConnection = null;
fireModelChange(connection, REMOVED);
} catch (UnsupportedEncodingException e) {
- OpenShiftUIActivator.log(NLS.bind("Could not remove connection {0} - {1}",
connection.getUsername(), connection.getHost()), e);
+ OpenShiftUIActivator.log(
+ NLS.bind("Could not remove connection {0} - {1}",
connection.getUsername(), connection.getHost()),
+ e);
}
}
@@ -114,17 +116,27 @@
return recentConnection;
}
- public void setRecentUser(Connection user) {
- this.recentConnection = user;
+ public void setRecentUser(Connection connection) {
+ this.recentConnection = connection;
}
- public Connection getConnection(String name) {
- if (name == null) {
+ public Connection getConnectionByUrl(String url) {
+ if (url == null) {
return null;
}
- return allConnections.get(name);
+ return allConnections.get(url);
}
+ public Connection getConnectionByUsername(String username) {
+ try {
+ String url = new Connection(username, null).toURLString();
+ return getConnectionByUrl(url);
+ } catch (UnsupportedEncodingException e) {
+ OpenShiftUIActivator.log(NLS.bind("Could not get url for connection {0}",
username), e);
+ return null;
+ }
+ }
+
public Connection[] getConnections() {
Collection<Connection> c = allConnections.values();
Connection[] rets = (Connection[]) c.toArray(new Connection[c.size()]);
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/CreateServerAdapterAction.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/CreateServerAdapterAction.java 2012-10-11
19:26:19 UTC (rev 44440)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/CreateServerAdapterAction.java 2012-10-11
20:13:37 UTC (rev 44441)
@@ -61,9 +61,9 @@
final IDomain domain = application.getDomain();
final IUser user = domain.getUser();
Assert.isNotNull(user, NLS.bind("application {0} does not reference any
user", application.getName()));
- Connection connection =
ConnectionsModel.getDefault().getConnection(user.getRhlogin());
NewServerWizard w = new NewServerWizard(ExpressServerUtils.OPENSHIFT_SERVER_TYPE);
- w.getTaskModel().putObject(ExpressServerUtils.TASK_WIZARD_ATTR_USER, connection);
+ Connection connection =
ConnectionsModel.getDefault().getConnectionByUsername(user.getRhlogin());
+ w.getTaskModel().putObject(ExpressServerUtils.TASK_WIZARD_ATTR_CONNECTION,
connection);
w.getTaskModel().putObject(ExpressServerUtils.TASK_WIZARD_ATTR_DOMAIN, domain);
w.getTaskModel().putObject(ExpressServerUtils.TASK_WIZARD_ATTR_SELECTED_APP,
application);
WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), w);
@@ -73,6 +73,7 @@
OpenShiftUIActivator.log("Could not create OpenShift server", e);
}
}
+
public class NewServerWizard extends TaskWizard implements INewWizard {
public NewServerWizard(final String serverType) {
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/EditCartridgesAction.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/EditCartridgesAction.java 2012-10-11
19:26:19 UTC (rev 44440)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/EditCartridgesAction.java 2012-10-11
20:13:37 UTC (rev 44441)
@@ -40,7 +40,7 @@
if (selection != null && selection instanceof ITreeSelection &&
treeSelection.getFirstElement() instanceof IApplication) {
try {
final IApplication application = (IApplication) treeSelection.getFirstElement();
- final Connection user =
ConnectionsModel.getDefault().getConnection(application.getDomain().getUser().getRhlogin());
+ final Connection user =
ConnectionsModel.getDefault().getConnectionByUrl(application.getDomain().getUser().getRhlogin());
EmbedCartridgeWizard wizard = new EmbedCartridgeWizard(application, user);
int result = WizardUtils.openWizardDialog(wizard,
Display.getCurrent().getActiveShell());
if(result == Dialog.OK) {
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsComposite.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsComposite.java 2012-10-11
19:26:19 UTC (rev 44440)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsComposite.java 2012-10-11
20:13:37 UTC (rev 44441)
@@ -67,6 +67,7 @@
import org.jboss.tools.common.ui.WizardUtils;
import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
import org.jboss.tools.openshift.express.internal.core.connection.Connection;
+import org.jboss.tools.openshift.express.internal.core.connection.ConnectionUtils;
import org.jboss.tools.openshift.express.internal.core.connection.ConnectionsModel;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
import org.jboss.tools.openshift.express.internal.ui.explorer.ConnectToOpenShiftWizard;
@@ -134,23 +135,23 @@
}
private void initModel() {
-// String connectionUrl = ExpressServerUtils.getExpressConnectionUrl(server);
-// if (connectionUrl == null) {
+ String connectionUrl = ExpressServerUtils.getExpressConnectionUrl(server);
+ if (ConnectionUtils.getDefaultHostUrl().equals(connectionUrl)) {
initModelNewServerWizard();
-// return;
-// }
-//
-// this.connectionUrl = connectionUrl;
-// this.connection = ConnectionsModel.getDefault().getConnection(this.connectionUrl);
-// this.app = ExpressServerUtils.getExpressApplicationName(server);
-// this.deployProject = ExpressServerUtils.getExpressDeployProject(server);
-// this.deployFolder = ExpressServerUtils.getExpressDeployFolder(server);
-// this.remote = ExpressServerUtils.getExpressRemoteName(server);
+ return;
+ }
+
+ this.connectionUrl = connectionUrl;
+ this.connection = ConnectionsModel.getDefault().getConnectionByUrl(connectionUrl);
+ this.app = ExpressServerUtils.getExpressApplicationName(server);
+ this.deployProject = ExpressServerUtils.getExpressDeployProject(server);
+ this.deployFolder = ExpressServerUtils.getExpressDeployFolder(server);
+ this.remote = ExpressServerUtils.getExpressRemoteName(server);
}
private void initModelNewServerWizard() {
// We're in a new server wizard.
- Connection tmpConnection = (Connection)
callback.getAttribute(ExpressServerUtils.TASK_WIZARD_ATTR_USER);
+ Connection tmpConnection = (Connection)
callback.getAttribute(ExpressServerUtils.TASK_WIZARD_ATTR_CONNECTION);
IApplication app = (IApplication)
callback.getAttribute(ExpressServerUtils.TASK_WIZARD_ATTR_SELECTED_APP);
if (tmpConnection != null && app != null) {
@@ -346,12 +347,11 @@
private void addListeners() {
connectionComboViewer.addSelectionChangedListener(onConnectionSelected());
- if (showVerify)
- remoteModifyListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- remote = remoteText.getText();
- }
- };
+ remoteModifyListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ remote = remoteText.getText();
+ }
+ };
remoteText.addModifyListener(remoteModifyListener);
if (appNameCombo != null) {