Author: adietish
Date: 2012-02-17 10:09:43 -0500 (Fri, 17 Feb 2012)
New Revision: 38883
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/ExpressDetailsSection.java
Log:
[JBIDE-10922] corrected layout
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-02-17
15:04:21 UTC (rev 38882)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsComposite.java 2012-02-17
15:09:43 UTC (rev 38883)
@@ -55,16 +55,16 @@
import com.openshift.express.client.OpenShiftException;
public class ExpressDetailsComposite {
- public static ExpressDetailsComposite createComposite(Composite parent,
+ public static ExpressDetailsComposite createComposite(Composite parent,
IServerModeUICallback callback, String mode, boolean showVerify) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(2, false));
return new ExpressDetailsComposite(composite, callback, mode, showVerify);
}
-
+
protected IServerModeUICallback callback;
- private ModifyListener nameModifyListener, remoteModifyListener,
- appModifyListener, deployProjectModifyListener;
+ private ModifyListener nameModifyListener, remoteModifyListener,
+ appModifyListener, deployProjectModifyListener;
private ModifyListener passModifyListener;
private Link importLink;
protected Text userText, remoteText;
@@ -80,6 +80,7 @@
private String error;
private IServerWorkingCopy server;
private String mode;
+
public ExpressDetailsComposite(Composite fill, IServerModeUICallback callback, String
mode, boolean showVerify) {
this.callback = callback;
this.server = callback.getServer();
@@ -91,100 +92,119 @@
fillWidgets();
addListeners();
}
-
+
public Composite getComposite() {
return composite;
}
-
+
private void initModel() {
String nameFromExistingServer = ExpressServerUtils.getExpressUsername(server);
- if( nameFromExistingServer == null ) {
+ if (nameFromExistingServer == null) {
// We're in a new server wizard.
// First, check if the taskmodel has data
- IUser tmpUser =
(IUser)callback.getAttribute(ExpressServerUtils.TASK_WIZARD_ATTR_USER);
- if( tmpUser == null ) {
+ IUser tmpUser = (IUser)
callback.getAttribute(ExpressServerUtils.TASK_WIZARD_ATTR_USER);
+ if (tmpUser == null) {
// If not, use recent user
tmpUser = UserModel.getDefault().getRecentUser();
}
- if( tmpUser == null && UserModel.getDefault().getUsers().length > 0 ) {
+ if (tmpUser == null && UserModel.getDefault().getUsers().length > 0) {
tmpUser = UserModel.getDefault().getUsers()[0];
}
- if( tmpUser != null ) {
+ if (tmpUser != null) {
try {
this.fuser = tmpUser;
this.user = tmpUser.getRhlogin();
List<IApplication> allApps = tmpUser.getApplications();
this.appListNames = getAppNamesAsStrings(allApps);
- } catch(Exception e) { /* ignore */ }
- }
+ } catch (Exception e) { /* ignore */
+ }
+ }
} else {
this.user = nameFromExistingServer;
}
- IApplication app =
(IApplication)callback.getAttribute(ExpressServerUtils.TASK_WIZARD_ATTR_SELECTED_APP);
- if( app != null ) {
+ IApplication app = (IApplication)
callback.getAttribute(ExpressServerUtils.TASK_WIZARD_ATTR_SELECTED_APP);
+ if (app != null) {
this.fapplication = app;
this.app = app.getName();
}
-
+
this.pass = UserModel.getDefault().getPasswordFromSecureStorage(this.user);
this.remote = ExpressServerUtils.getExpressRemoteName(server);
this.remote = this.remote == null ?
IOpenShiftExpressWizardModel.NEW_PROJECT_REMOTE_NAME_DEFAULT : this.remote;
}
-
+
/* Set widgets initial values */
private void fillWidgets() {
- if( user != null ) userText.setText(user);
- if( pass != null ) passText.setText(pass);
- if( remote != null ) remoteText.setText(remote);
- if( appListNames != null ) appNameCombo.setItems(appListNames);
- if( app != null ) {
+ if (user != null)
+ userText.setText(user);
+ if (pass != null)
+ passText.setText(pass);
+ if (remote != null)
+ remoteText.setText(remote);
+ if (appListNames != null)
+ appNameCombo.setItems(appListNames);
+ if (app != null) {
int ind = appNameCombo.indexOf(app);
- if( ind != -1 ) {
+ if (ind != -1) {
appNameCombo.select(ind);
}
}
remoteText.setText(remote);
}
-
+
private void createWidgets(Composite composite) {
composite.setLayout(new GridLayout(2, false));
Label userLabel = new Label(composite, SWT.NONE);
+ GridDataFactory.fillDefaults()
+ .align(SWT.LEFT, SWT.CENTER).applyTo(userLabel);
userText = new Text(composite, SWT.SINGLE | SWT.BORDER);
- GridDataFactory.fillDefaults().hint(150, SWT.DEFAULT).applyTo(userText);
+ GridDataFactory.fillDefaults()
+ .align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(userText);
Label passLabel = new Label(composite, SWT.NONE);
+ GridDataFactory.fillDefaults()
+ .align(SWT.LEFT, SWT.CENTER).applyTo(passLabel);
passText = new Text(composite, SWT.PASSWORD | SWT.BORDER);
- GridDataFactory.fillDefaults().hint(150, SWT.DEFAULT).applyTo(passText);
-
- if( mode.equals(ExpressServerUtils.EXPRESS_SOURCE_MODE) ) {
+ GridDataFactory.fillDefaults()
+ .align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(passText);
+
+ if (mode.equals(ExpressServerUtils.EXPRESS_SOURCE_MODE)) {
Label appNameLabel = new Label(composite, SWT.NONE);
+ GridDataFactory.fillDefaults()
+ .align(SWT.LEFT, SWT.CENTER).applyTo(appNameLabel);
appNameCombo = new Combo(composite, SWT.NONE);
- appNameLabel.setText("Application Name: " );
+ GridDataFactory.fillDefaults()
+ .align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(appNameCombo);
+ appNameLabel.setText("Application Name: ");
String aName = ExpressServerUtils.getExpressApplicationName(server);
- if( aName != null ) appNameCombo.setText(aName);
- if( aName != null ) appNameCombo.setEnabled(false);
- }
-// else {
-// Label deployLocationLabel = new Label(composite, SWT.NONE);
-// deployProjectCombo = new Combo(composite, SWT.NONE);
-// deployLocationLabel.setText("Openshift Project: " );
-// String[] projectNames = discoverOpenshiftProjects();
-// deployProjectCombo.setItems(projectNames);
-// String depLoc = ExpressServerUtils.getExpressDeployProject(server);
-// if( depLoc != null ) deployProjectCombo.setText(depLoc);
-// if( depLoc != null ) deployProjectCombo.setEnabled(false);
-// }
-
+ if (aName != null)
+ appNameCombo.setText(aName);
+ if (aName != null)
+ appNameCombo.setEnabled(false);
+ }
+ // else {
+ // Label deployLocationLabel = new Label(composite, SWT.NONE);
+ // deployProjectCombo = new Combo(composite, SWT.NONE);
+ // deployLocationLabel.setText("Openshift Project: " );
+ // String[] projectNames = discoverOpenshiftProjects();
+ // deployProjectCombo.setItems(projectNames);
+ // String depLoc = ExpressServerUtils.getExpressDeployProject(server);
+ // if( depLoc != null ) deployProjectCombo.setText(depLoc);
+ // if( depLoc != null ) deployProjectCombo.setEnabled(false);
+ // }
+
Label remoteLabel = new Label(composite, SWT.NONE);
+ GridDataFactory.fillDefaults()
+ .align(SWT.LEFT, SWT.CENTER).applyTo(remoteLabel);
remoteText = new Text(composite, SWT.SINGLE | SWT.BORDER);
- GridDataFactory.fillDefaults().hint(150, SWT.DEFAULT).applyTo(remoteText);
-
-
+ GridDataFactory.fillDefaults()
+ .align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(remoteText);
+
// Text
userLabel.setText("Username: ");
passLabel.setText("Password: ");
remoteLabel.setText("Remote: ");
-
- if( showVerify ) {
+
+ if (showVerify) {
importLink = new Link(composite, SWT.DEFAULT);
importLink.setText("<a>Import this application</a>");
//$NON-NLS-1$
importLink.setEnabled(false);
@@ -194,22 +214,22 @@
verifyButton.setText("Verify...");
}
}
-
+
private void addListeners() {
nameModifyListener = new ModifyListener() {
public void modifyText(ModifyEvent e) {
user = userText.getText();
String storedPass = UserModel.getDefault().getPasswordFromSecureStorage(user);
- if( storedPass != null && !storedPass.equals(""))
+ if (storedPass != null && !storedPass.equals(""))
passText.setText(storedPass);
callback.execute(new SetUserCommand(server));
}
};
userText.addModifyListener(nameModifyListener);
-
+
passModifyListener = new ModifyListener() {
public void modifyText(ModifyEvent e) {
- //pass = passText.getText();
+ // pass = passText.getText();
callback.execute(new SetPassCommand(server));
}
};
@@ -223,7 +243,7 @@
};
remoteText.addModifyListener(remoteModifyListener);
- if( appNameCombo != null ) {
+ if (appNameCombo != null) {
appModifyListener = new ModifyListener() {
public void modifyText(ModifyEvent e) {
app = appNameCombo.getText();
@@ -231,9 +251,9 @@
}
};
appNameCombo.addModifyListener(appModifyListener);
- }
+ }
- if( deployProjectCombo != null ) {
+ if (deployProjectCombo != null) {
deployProjectModifyListener = new ModifyListener() {
public void modifyText(ModifyEvent e) {
deployProject = deployProjectCombo.getText();
@@ -241,9 +261,9 @@
}
};
deployProjectCombo.addModifyListener(deployProjectModifyListener);
- }
+ }
- if( verifyButton != null ) {
+ if (verifyButton != null) {
importLink.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
OpenShiftExpressApplicationWizard wizard = new
ImportOpenShiftExpressApplicationWizard();
@@ -253,6 +273,7 @@
dialog.create();
dialog.open();
}
+
public void widgetDefaultSelected(SelectionEvent e) {
}
});
@@ -261,12 +282,13 @@
public void widgetSelected(SelectionEvent e) {
verifyPressed();
}
+
public void widgetDefaultSelected(SelectionEvent e) {
}
});
}
}
-
+
private void verifyPressed() {
final CredentialsWizardPageModel model = new CredentialsWizardPageModel(new
ConnectToOpenShiftWizardModel());
this.fapplication = null;
@@ -285,22 +307,22 @@
callback.executeLongRunning(j);
postLongRunningValidate();
}
-
+
private void postLongRunningValidate() {
importLink.setEnabled(true);
- if( appListNames == null ) {
+ if (appListNames == null) {
appListNames = new String[0];
}
- if( appNameCombo != null ) {
+ if (appNameCombo != null) {
int index = Arrays.asList(appListNames).indexOf(app);
appNameCombo.setItems(appListNames);
- if( index != -1 )
+ if (index != -1)
appNameCombo.select(index);
}
- if( error == null ) {
+ if (error == null) {
IProject p = ExpressServerUtils.findProjectForApplication(fapplication);
- if( p == null ) {
- error = "Your workspace does not have a project corresponding to " + app
+". Please import one.";
+ if (p == null) {
+ error = "Your workspace does not have a project corresponding to " + app +
". Please import one.";
importLink.setEnabled(true);
}
}
@@ -308,46 +330,45 @@
verifyButton.setEnabled(true);
}
-
public class SetUserCommand extends ServerWorkingCopyPropertyCommand {
public SetUserCommand(IServerWorkingCopy server) {
- super(server, Messages.EditorChangeUsernameCommandName, userText, userText.getText(),
+ super(server, Messages.EditorChangeUsernameCommandName, userText, userText.getText(),
ExpressServerUtils.ATTRIBUTE_USERNAME, nameModifyListener);
}
}
public class SetRemoteCommand extends ServerWorkingCopyPropertyCommand {
public SetRemoteCommand(IServerWorkingCopy server) {
- super(server, "Change Remote Name", remoteText, remoteText.getText(),
+ super(server, "Change Remote Name", remoteText, remoteText.getText(),
ExpressServerUtils.ATTRIBUTE_REMOTE_NAME, remoteModifyListener);
}
}
public class SetApplicationCommand extends ServerWorkingCopyPropertyComboCommand {
public SetApplicationCommand(IServerWorkingCopy server) {
- super(server, "Change Application Name", appNameCombo,
appNameCombo.getText(),
+ super(server, "Change Application Name", appNameCombo,
appNameCombo.getText(),
ExpressServerUtils.ATTRIBUTE_APPLICATION_NAME, appModifyListener);
}
}
public class SetDeployProjectCommand extends ServerWorkingCopyPropertyComboCommand {
public SetDeployProjectCommand(IServerWorkingCopy server) {
- super(server, "Change Deployment Project", appNameCombo,
deployProjectCombo.getText(),
+ super(server, "Change Deployment Project", appNameCombo,
deployProjectCombo.getText(),
ExpressServerUtils.ATTRIBUTE_DEPLOY_PROJECT, deployProjectModifyListener);
}
}
public class SetPassCommand extends ServerWorkingCopyPropertyCommand {
public SetPassCommand(IServerWorkingCopy server) {
- super(server, Messages.EditorChangePasswordCommandName, passText, passText.getText(),
+ super(server, Messages.EditorChangePasswordCommandName, passText, passText.getText(),
null, passModifyListener);
oldVal = passText.getText();
}
-
+
public void execute() {
pass = newVal;
}
-
+
public void undo() {
pass = oldVal;
text.removeModifyListener(listener);
@@ -360,11 +381,11 @@
return new Runnable() {
public void run() {
final IStatus s = model.validateCredentials();
- if( !s.isOK() ) {
+ if (!s.isOK()) {
ExpressDetailsComposite.this.error = "Credentials Failed";
} else {
-
- if( mode.equals(ExpressServerUtils.EXPRESS_SOURCE_MODE) ) {
+
+ if (mode.equals(ExpressServerUtils.EXPRESS_SOURCE_MODE)) {
verifyApplicationSourceMode(model);
} else {
verifyApplicationBinaryMode(model);
@@ -373,37 +394,36 @@
}
};
}
-
-
private void verifyApplicationBinaryMode(CredentialsWizardPageModel model) {
IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(deployProject);
try {
fuser = UserModel.getDefault().getRecentUser();
final List<IApplication> allApps = fuser.getApplications();
fapplication = ExpressServerUtils.findApplicationForProject(p, allApps);
-
- if( fapplication == null ) {
+
+ if (fapplication == null) {
error = "Application for project \"" + p.getName() + "\" not
found";
}
- IServerWorkingCopy wc = callback.getServer();
+ IServerWorkingCopy wc = callback.getServer();
ExpressServerUtils.fillServerWithOpenShiftDetails(wc, fapplication, fuser,
mode, remote);
wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE,
IDeployableServer.DEPLOY_CUSTOM);
wc.setAttribute(IDeployableServer.ZIP_DEPLOYMENTS_PREF, true);
wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY,
p.getFolder("deployments").getLocation().toString());
- wc.setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY,
p.getFolder("deployments").getLocation().toString());
- } catch( OpenShiftException ce ) {
-
- } catch( CoreException ce) {
-
+ wc.setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY,
p.getFolder("deployments").getLocation()
+ .toString());
+ } catch (OpenShiftException ce) {
+
+ } catch (CoreException ce) {
+
}
}
-
+
private void verifyApplicationSourceMode(CredentialsWizardPageModel model) {
error = null;
// now check the app name and cartridge
- String[] appNames = new String[]{};
+ String[] appNames = new String[] {};
try {
IUser user = UserModel.getDefault().getRecentUser();
final List<IApplication> allApps = user.getApplications();
@@ -411,7 +431,7 @@
int index = Arrays.asList(appNames).indexOf(app);
IApplication application = index == -1 ? null : allApps.get(index);
ExpressDetailsComposite.this.appListNames = appNames;
- if( application == null ) {
+ if (application == null) {
error = "Application " + app + " not found";
} else {
// Fill with new data
@@ -419,31 +439,31 @@
ExpressDetailsComposite.this.fapplication = application;
ExpressDetailsComposite.this.fuser = user;
IProject p = ExpressServerUtils.findProjectForApplication(fapplication);
-
- // update the values
- IServerWorkingCopy wc = callback.getServer();
+
+ // update the values
+ IServerWorkingCopy wc = callback.getServer();
ExpressServerUtils.fillServerWithOpenShiftDetails(wc, application, fuser,
mode, remote);
wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE,
IDeployableServer.DEPLOY_CUSTOM);
wc.setAttribute(IDeployableServer.ZIP_DEPLOYMENTS_PREF, true);
- if( p != null ) {
- wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY,
p.getFolder("deployments").getLocation().toString());
- wc.setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY,
p.getFolder("deployments").getLocation().toString());
+ if (p != null) {
+ wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY,
p.getFolder("deployments").getLocation()
+ .toString());
+ wc.setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY,
p.getFolder("deployments")
+ .getLocation().toString());
}
- } catch(CoreException ce) {
+ } catch (CoreException ce) {
// TODO FIX HANDLE
}
}
- } catch(OpenShiftException ose) {
+ } catch (OpenShiftException ose) {
error = "Application \"" + app + "\" not found: " +
ose.getMessage();
}
}
-
-
private String[] getAppNamesAsStrings(List<IApplication> allApps) {
String[] appNames = new String[allApps.size()];
- for( int i = 0; i < allApps.size(); i++ ) {
+ for (int i = 0; i < allApps.size(); i++) {
appNames[i] = allApps.get(i).getName();
}
return appNames;
@@ -452,11 +472,11 @@
public String getUsername() {
return user;
}
-
+
public String getPassword() {
return pass;
}
-
+
public String getApplicationName() {
return app;
}
@@ -464,11 +484,11 @@
public IUser getUser() {
return fuser;
}
-
+
public IApplication getApplication() {
return fapplication;
}
-
+
public String getRemote() {
return remote;
}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsSection.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsSection.java 2012-02-17
15:04:21 UTC (rev 38882)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsSection.java 2012-02-17
15:09:43 UTC (rev 38883)
@@ -37,7 +37,7 @@
Section section = toolkit.createSection(parent,
ExpandableComposite.TWISTIE|ExpandableComposite.EXPANDED|ExpandableComposite.TITLE_BAR);
section.setText("Express Server in Source Mode (Details)");
- section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL |
GridData.VERTICAL_ALIGN_FILL));
+ section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL |
GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL| GridData.GRAB_VERTICAL));
details = ExpressDetailsComposite.createComposite(section, createCallback(),
ExpressServerUtils.EXPRESS_SOURCE_MODE, false);
toolkit.paintBordersFor(details.getComposite());