Author: adietish
Date: 2011-10-05 19:51:50 -0400 (Wed, 05 Oct 2011)
New Revision: 35406
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractOpenshiftWizardPage.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationDetailsDialog.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationDialog.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPage.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPageModel.java
Log:
[JBIDE-9793] added link to application url (public url), tried to fix combo selection in
"NewApplicationWizardPage" (is still not working: no initial selection, no
validation)
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractOpenshiftWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractOpenshiftWizardPage.java 2011-10-05
23:40:51 UTC (rev 35405)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractOpenshiftWizardPage.java 2011-10-05
23:51:50 UTC (rev 35406)
@@ -22,7 +22,6 @@
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
import org.jboss.tools.common.ui.databinding.ParametrizableWizardPageSupport;
import org.jboss.tools.openshift.express.internal.ui.OpenshiftImages;
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationDetailsDialog.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationDetailsDialog.java 2011-10-05
23:40:51 UTC (rev 35405)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationDetailsDialog.java 2011-10-05
23:51:50 UTC (rev 35406)
@@ -12,19 +12,25 @@
import java.util.concurrent.Callable;
+import org.eclipse.core.runtime.ILog;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.common.ui.BrowserUtil;
import org.jboss.tools.openshift.express.client.IApplication;
import org.jboss.tools.openshift.express.client.utils.RFC822DateUtils;
import org.jboss.tools.openshift.express.internal.ui.OpenshiftImages;
+import org.jboss.tools.openshift.express.internal.ui.OpenshiftUIActivator;
/**
* @author André Dietisheim
@@ -74,28 +80,47 @@
return application.getGitUri();
}
}.get(), container);
- createDetails("Public URL", new
ErrorMessageCallable<String>("Public URL") {
+ Label publicUrlLabel = new Label(container, SWT.NONE);
+ publicUrlLabel.setText("Public URL");
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(publicUrlLabel);
+ Link publicUrlLink = new Link(container, SWT.WRAP);
+ String applicationUrl = new ErrorMessageCallable<String>("Public URL")
{
+
@Override
public String call() throws Exception {
return application.getApplicationUrl();
}
- }.get(), container);
+ }.get();
+ publicUrlLink.setText("<a>" + applicationUrl +
"</a>");
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(publicUrlLink);
+ publicUrlLink.addSelectionListener(onPublicUrl(applicationUrl));
return container;
}
+ private SelectionAdapter onPublicUrl(final String applicationUrl) {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ ILog log = OpenshiftUIActivator.getDefault().getLog();
+ BrowserUtil.checkedCreateExternalBrowser(applicationUrl,
OpenshiftUIActivator.PLUGIN_ID, log);
+ }
+ };
+ }
+
private void createDetails(String name, String value, Composite container) {
Label label = new Label(container, SWT.None);
label.setText(name);
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(label);
Text text = new Text(container, SWT.BORDER);
text.setEditable(false);
+ text.setBackground(container.getBackground());
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(text);
text.setText(value);
}
-
private abstract class ErrorMessageCallable<T> implements Callable<T> {
private String fieldName;
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java 2011-10-05
23:40:51 UTC (rev 35405)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java 2011-10-05
23:51:50 UTC (rev 35406)
@@ -32,9 +32,6 @@
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.ViewerCell;
@@ -51,7 +48,6 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.PlatformUI;
-import org.jboss.tools.common.ui.BrowserUtil;
import org.jboss.tools.common.ui.WizardUtils;
import org.jboss.tools.common.ui.databinding.DataBindingUtils;
import org.jboss.tools.openshift.express.client.IApplication;
@@ -129,21 +125,22 @@
@Override
public void doubleClick(DoubleClickEvent event) {
- try {
- ISelection selection = event.getSelection();
- if (selection instanceof StructuredSelection) {
- Object firstElement = ((IStructuredSelection) selection).getFirstElement();
- if (firstElement instanceof IApplication) {
- String url = ((IApplication) firstElement).getApplicationUrl();
- BrowserUtil.checkedCreateExternalBrowser(url, OpenshiftUIActivator.PLUGIN_ID,
- OpenshiftUIActivator.getDefault().getLog());
- }
- }
- } catch (OpenshiftException e) {
- IStatus status = new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID,
- "Could not open Openshift Express application in browser", e);
- OpenshiftUIActivator.getDefault().getLog().log(status);
- }
+// try {
+// ISelection selection = event.getSelection();
+// if (selection instanceof StructuredSelection) {
+// Object firstElement = ((IStructuredSelection) selection).getFirstElement();
+// if (firstElement instanceof IApplication) {
+// String url = ((IApplication) firstElement).getApplicationUrl();
+// BrowserUtil.checkedCreateExternalBrowser(url, OpenshiftUIActivator.PLUGIN_ID,
+// OpenshiftUIActivator.getDefault().getLog());
+// }
+// }
+// } catch (OpenshiftException e) {
+// IStatus status = new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID,
+// "Could not open Openshift Express application in browser", e);
+// OpenshiftUIActivator.getDefault().getLog().log(status);
+// }
+ openDetailsDialog();
}
};
}
@@ -231,12 +228,16 @@
@Override
public void widgetSelected(SelectionEvent e) {
- Shell shell = getContainer().getShell();
- new ApplicationDetailsDialog(model.getSelectedApplication(), shell).open();
+ openDetailsDialog();
}
};
}
+ private void openDetailsDialog() {
+ Shell shell = getContainer().getShell();
+ new ApplicationDetailsDialog(model.getSelectedApplication(), shell).open();
+ }
+
@Override
protected void onPageActivated(DataBindingContext dbc) {
try {
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationDialog.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationDialog.java 2011-10-05
23:40:51 UTC (rev 35405)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationDialog.java 2011-10-05
23:51:50 UTC (rev 35406)
@@ -39,7 +39,7 @@
public boolean performFinish() {
final ArrayBlockingQueue<Boolean> queue = new
ArrayBlockingQueue<Boolean>(1);
try {
- WizardUtils.runInWizard(new Job("Creating application") {
+ WizardUtils.runInWizard(new Job("Creating application...") {
@Override
protected IStatus run(IProgressMonitor monitor) {
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPage.java 2011-10-05
23:40:51 UTC (rev 35405)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPage.java 2011-10-05
23:51:50 UTC (rev 35406)
@@ -34,6 +34,7 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.jboss.tools.common.ui.WizardUtils;
+import org.jboss.tools.openshift.express.client.Cartridge;
import org.jboss.tools.openshift.express.client.ICartridge;
import org.jboss.tools.openshift.express.client.OpenshiftException;
import org.jboss.tools.openshift.express.internal.ui.OpenshiftUIActivator;
@@ -62,16 +63,17 @@
nameText.setTextLimit(13);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(nameText);
Binding nameBinding = dbc.bindValue(
- WidgetProperties.text(SWT.Modify).observe(nameText)
+ WidgetProperties.text(SWT.Modify).observe(nameText)
, BeanProperties.value(NewApplicationWizardPageModel.PROPERTY_NAME).observe(model)
, new UpdateValueStrategy().setAfterGetValidator(new ApplicationNameValidator())
, null);
ControlDecorationSupport.create(nameBinding, SWT.LEFT | SWT.TOP);
-
+
Label cartridgeLabel = new Label(parent, SWT.WRAP);
cartridgeLabel.setText("&Cartridge");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(cartridgeLabel);
- Combo cartridgesCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
+ Combo cartridgesCombo = new Combo(parent, SWT.BORDER |
+ SWT.READ_ONLY);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(cartridgesCombo);
dbc.bindList(
WidgetProperties.items().observe(cartridgesCombo)
@@ -87,20 +89,52 @@
return ((ICartridge) fromObject).getName();
}
}));
- dbc.bindValue(
+ Binding comboSelectionBinding = dbc.bindValue(
WidgetProperties.selection().observe(cartridgesCombo)
- ,
BeanProperties.value(NewApplicationWizardPageModel.PROPERTY_SELECTED_CARTRIDGE).observe(model));
+ ,
BeanProperties.value(NewApplicationWizardPageModel.PROPERTY_SELECTED_CARTRIDGE).observe(model)
+ , new UpdateValueStrategy().setConverter(new Converter(String.class,
ICartridge.class) {
+
+ @Override
+ public Object convert(Object fromObject) {
+ if (fromObject instanceof String) {
+ return new Cartridge(((String) fromObject));
+ }
+ return null;
+ }
+ })
+ , new UpdateValueStrategy().setAfterGetValidator(
+ new IValidator() {
+
+ @Override
+ public IStatus validate(Object value) {
+ if (!(value instanceof ICartridge)) {
+ return ValidationStatus.error("You have to select a type");
+ } else {
+ return ValidationStatus.ok();
+ }
+ }
+ }).setConverter(new Converter(ICartridge.class, String.class) {
+
+ @Override
+ public Object convert(Object fromObject) {
+ if (fromObject instanceof ICartridge) {
+ return ((ICartridge) fromObject).getName();
+ }
+ return null;
+ }
+ }));
+ ControlDecorationSupport.create(comboSelectionBinding, SWT.LEFT | SWT.TOP);
}
@Override
protected void onPageActivated(DataBindingContext dbc) {
try {
- WizardUtils.runInWizard(new Job("Loading cartridges") {
+ WizardUtils.runInWizard(new Job("Loading cartridges...") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
-
+
model.loadCartridges();
} catch (OpenshiftException e) {
return new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID, "Could not
load cartridges", e);
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPageModel.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPageModel.java 2011-10-05
23:40:51 UTC (rev 35405)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPageModel.java 2011-10-05
23:51:50 UTC (rev 35406)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.wizard;
+import java.util.ArrayList;
import java.util.Collection;
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
@@ -30,25 +31,26 @@
private IUser user;
private String name;
-
- private Collection<ICartridge> cartridges;
- private String selectedCartridge;
+
+ private Collection<ICartridge> cartridges = new ArrayList<ICartridge>();
+ private ICartridge selectedCartridge;
private StringPreferenceValue selectedCartridgePreference;
public NewApplicationWizardPageModel(IUser user) {
this.user = user;
this.selectedCartridgePreference = new StringPreferenceValue(
- "org.jboss.tools.openshift.express.internal.ui.wizard.NewApplicationWizard.selectedCartridge",
OpenshiftUIActivator.PLUGIN_ID);
+ "org.jboss.tools.openshift.express.internal.ui.wizard.NewApplicationWizard.selectedCartridge",
+ OpenshiftUIActivator.PLUGIN_ID);
initSelectedCartridge();
}
private void initSelectedCartridge() {
- String selectedCartridge = selectedCartridgePreference.get();
- if (selectedCartridge == null
- || selectedCartridge.length() == 0) {
- selectedCartridge = ICartridge.JBOSSAS_7.getName();
+ String selectedCartridgeName = selectedCartridgePreference.get();
+ if (selectedCartridgeName == null
+ || selectedCartridgeName.length() == 0) {
+ selectedCartridge = ICartridge.JBOSSAS_7;
}
- this.selectedCartridge = selectedCartridge;
+ this.selectedCartridge = getCartridgeByName(selectedCartridgeName);
}
public String getName() {
@@ -71,17 +73,28 @@
return cartridges;
}
- public String getSelectedCartridge() {
+ public ICartridge getSelectedCartridge() {
return selectedCartridge;
}
- public void setSelectedCartridge(String name) {
- selectedCartridgePreference.store(name);
- firePropertyChange(PROPERTY_SELECTED_CARTRIDGE, selectedCartridge,
this.selectedCartridge = name);
+ public void setSelectedCartridge(ICartridge cartridge) {
+ selectedCartridgePreference.store(cartridge.getName());
+ firePropertyChange(PROPERTY_SELECTED_CARTRIDGE, selectedCartridge,
this.selectedCartridge = cartridge);
}
+ private ICartridge getCartridgeByName(String name) {
+ ICartridge matchingCartridge = null;
+ for (ICartridge cartridge : getCartridges()) {
+ if (name.equals(cartridge.getName())) {
+ matchingCartridge = cartridge;
+ break;
+ }
+ }
+ return matchingCartridge;
+ }
+
public void createApplication() throws OpenshiftException {
- user.createApplication(name, user.getCartridgeByName(selectedCartridge));
+ user.createApplication(name, selectedCartridge);
}
public boolean hasApplication(String name) {