Author: adietish
Date: 2011-10-11 16:31:55 -0400 (Tue, 11 Oct 2011)
New Revision: 35557
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardModel.java
Removed:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/DomainWizardPage.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/DomainWizardPageModel.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java
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/ApplicationWizardPageModel.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainDialog.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ServerAdapterWizard.java
Log:
[JBIDE-9793] removed DomainPage, added domain to application page
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-11
20:22:21 UTC (rev 35556)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java 2011-10-11
20:31:55 UTC (rev 35557)
@@ -16,14 +16,19 @@
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.beans.BeanProperties;
+import org.eclipse.core.databinding.conversion.Converter;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.jface.databinding.viewers.ViewerProperties;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
@@ -41,17 +46,20 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
import org.jboss.tools.common.ui.WizardUtils;
import org.jboss.tools.common.ui.databinding.DataBindingUtils;
import org.jboss.tools.openshift.express.client.IApplication;
+import org.jboss.tools.openshift.express.client.IDomain;
import org.jboss.tools.openshift.express.client.OpenshiftException;
import org.jboss.tools.openshift.express.internal.ui.OpenshiftUIActivator;
@@ -62,10 +70,12 @@
private TableViewer viewer;
private ApplicationWizardPageModel model;
+ private ServerAdapterWizardModel wizardModel;
protected ApplicationWizardPage(IWizard wizard, ServerAdapterWizardModel wizardModel) {
super("Application selection", "Please select an Openshift Express
application",
"Application selection", wizard);
+ this.wizardModel = wizardModel;
this.model = new ApplicationWizardPageModel(wizardModel);
}
@@ -73,17 +83,53 @@
protected void doCreateControls(Composite container, DataBindingContext dbc) {
GridLayoutFactory.fillDefaults().numColumns(3).applyTo(container);
- Group group = new Group(container, SWT.BORDER);
- group.setText("Available Applications");
- GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).hint(400,
160).span(3, 1)
- .applyTo(group);
- FillLayout fillLayout = new FillLayout(SWT.VERTICAL);
- fillLayout.marginHeight = 6;
- fillLayout.marginWidth = 6;
- group.setLayout(fillLayout);
+ createDomainGroup(container, dbc);
+ createApplicationsGroup(container, dbc);
+ }
- Composite tableContainer = new Composite(group, SWT.NONE);
+ private void createDomainGroup(Composite container, DataBindingContext dbc) {
+ Group domainGroup = new Group(container, SWT.BORDER);
+ domainGroup.setText("Domain");
+ GridDataFactory.fillDefaults()
+ .grab(true, false).align(SWT.FILL, SWT.TOP).span(3, 1).applyTo(domainGroup);
+ GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(3).applyTo(domainGroup);
+ Label namespaceLabel = new Label(domainGroup, SWT.NONE);
+ namespaceLabel.setText("&Domain name");
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(namespaceLabel);
+ Text namespaceText = new Text(domainGroup, SWT.BORDER);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(namespaceText);
+ Binding namespaceBinding = DataBindingUtils.bindMandatoryTextField(
+ namespaceText, "Domain", ApplicationWizardPageModel.PROPERTY_NAMESPACE,
model, dbc);
+ Button createRenameButton = new Button(domainGroup, SWT.PUSH);
+ DataBindingUtils.bindEnablementToValidationStatus(createRenameButton, IStatus.OK, dbc,
namespaceBinding);
+ dbc.bindValue(WidgetProperties.text().observe(createRenameButton)
+ , BeanProperties.value(ApplicationWizardPageModel.PROPERTY_DOMAIN).observe(model)
+ , new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER)
+ , new UpdateValueStrategy().setConverter(new Converter(IDomain.class, String.class)
{
+
+ @Override
+ public Object convert(Object fromObject) {
+ if (fromObject instanceof IDomain) {
+ return "&Rename";
+ } else {
+ return "&Create";
+ }
+ }
+ }));
+ GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).hint(80,
SWT.DEFAULT).applyTo(createRenameButton);
+ createRenameButton.addSelectionListener(onCreateRenameDomain(dbc));
+ }
+
+ private void createApplicationsGroup(Composite container, DataBindingContext dbc) {
+ Group applicationGroup = new Group(container, SWT.BORDER);
+ applicationGroup.setText("Available Applications");
+ GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).hint(400,
260).span(3, 1)
+ .applyTo(applicationGroup);
+ GridLayoutFactory.fillDefaults().numColumns(3).margins(6,
6).applyTo(applicationGroup);
+
+ Composite tableContainer = new Composite(applicationGroup, SWT.NONE);
this.viewer = createTable(tableContainer);
+ GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.FILL).grab(true,
true).applyTo(tableContainer);
viewer.addDoubleClickListener(onApplicationDoubleClick());
Binding selectedApplicationBinding = dbc.bindValue(
@@ -103,49 +149,78 @@
}),
null);
- Button newButton = new Button(container, SWT.PUSH);
+ Button newButton = new Button(applicationGroup, SWT.PUSH);
newButton.setText("Ne&w");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(80,
30).applyTo(newButton);
newButton.addSelectionListener(onNew(dbc));
- Button deleteButton = new Button(container, SWT.PUSH);
+ Button deleteButton = new Button(applicationGroup, SWT.PUSH);
deleteButton.setText("&Delete");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(80,
SWT.DEFAULT).applyTo(deleteButton);
- DataBindingUtils.bindEnablementToValidationStatus(deleteButton, IStatus.INFO, dbc,
selectedApplicationBinding);
+ DataBindingUtils.bindEnablementToValidationStatus(deleteButton, IStatus.OK, dbc,
selectedApplicationBinding);
deleteButton.addSelectionListener(onDelete(dbc));
- Button detailsButton = new Button(container, SWT.PUSH);
+ Button detailsButton = new Button(applicationGroup, SWT.PUSH);
detailsButton.setText("De&tails");
- GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).hint(80,
SWT.DEFAULT).applyTo(detailsButton);
- DataBindingUtils.bindEnablementToValidationStatus(detailsButton, IStatus.INFO, dbc,
selectedApplicationBinding);
+ GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).grab(true, false).hint(80,
SWT.DEFAULT)
+ .applyTo(detailsButton);
+ DataBindingUtils.bindEnablementToValidationStatus(detailsButton, IStatus.OK, dbc,
selectedApplicationBinding);
detailsButton.addSelectionListener(onDetails(dbc));
}
+ private SelectionListener onCreateRenameDomain(DataBindingContext dbc) {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (model.hasDomain()) {
+ renameDomain();
+ } else {
+ try {
+ createDomain();
+ } catch (OpenshiftException ex) {
+ IStatus status = new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID,
ex.getMessage(), ex);
+ OpenshiftUIActivator.getDefault().getLog().log(status);
+ ErrorDialog.openError(getShell(), "Error creating domain", "An error
occurred while creating the domain.", status);
+ }
+ }
+ }
+ };
+ }
+
+ private void createDomain() throws OpenshiftException {
+ if (WizardUtils.openWizardDialog(
+ new NewDomainDialog(model.getNamespace(), wizardModel), getContainer().getShell()) ==
Dialog.OK) {
+ model.updateDomain();
+ }
+ }
+
+ private void renameDomain() {
+ try {
+ WizardUtils.runInWizard(
+ new Job("Renaming domain...") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ model.renameDomain();
+ return Status.OK_STATUS;
+ } catch (Exception e) {
+ return new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID,
+ "Could not rename domain", e);
+ }
+ }
+ }, getContainer(), getDatabindingContext());
+ } catch (Exception ex) {
+ // ignore
+ }
+ }
+
private IDoubleClickListener onApplicationDoubleClick() {
return new IDoubleClickListener() {
@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);
- // }
openDetailsDialog();
}
};
@@ -207,13 +282,15 @@
@Override
public void widgetSelected(SelectionEvent e) {
try {
- if (MessageDialog.openQuestion(getShell(),
+ if (MessageDialog
+ .openQuestion(
+ getShell(),
"Delete Application",
NLS.bind(
"You're up to delete all data within an application. The data may not
be recovered. "
- + "Are you sure that you want to delete application {0}?",
+ + "Are you sure that you want to delete application {0}?",
model.getSelectedApplication().getName()))) {
- WizardUtils.runInWizard(new DeleteApplicationJob(), getWizard().getContainer(),
dbc);
+ WizardUtils.runInWizard(new DeleteApplicationJob(), getContainer(), dbc);
}
} catch (Exception ex) {
// ignore
@@ -228,8 +305,8 @@
@Override
public void widgetSelected(SelectionEvent e) {
Shell shell = getContainer().getShell();
- if (WizardUtils.openWizardDialog(new NewApplicationDialog(model.getUser()), shell)
- == Dialog.OK) {
+ if (WizardUtils.openWizardDialog(
+ new NewApplicationDialog(model.getUser()), shell) == Dialog.OK) {
viewer.refresh();
}
}
@@ -247,22 +324,43 @@
}
private void openDetailsDialog() {
- Shell shell = getContainer().getShell();
- new ApplicationDetailsDialog(model.getSelectedApplication(), shell).open();
+ new ApplicationDetailsDialog(model.getSelectedApplication(), getShell()).open();
}
@Override
- protected void onPageActivated(DataBindingContext dbc) {
+ protected void onPageActivated(final DataBindingContext dbc) {
try {
- WizardUtils.runInWizard(new LoadApplicationsJob(), getWizard().getContainer(), dbc);
+ Job loadDomainJob = new LoadDomainJob();
+ loadDomainJob.addJobChangeListener(onLoadDomainFinished(dbc));
+ WizardUtils.runInWizard(loadDomainJob, getContainer(), getDatabindingContext());
+
} catch (Exception ex) {
// ignore
}
}
+ private JobChangeAdapter onLoadDomainFinished(final DataBindingContext dbc) {
+ return new JobChangeAdapter() {
+
+ @Override
+ public void done(IJobChangeEvent event) {
+ try {
+ if (!event.getResult().isOK()) {
+ return;
+ }
+ if (model.hasDomain()) {
+ WizardUtils.runInWizard(new LoadApplicationsJob(), getContainer(), dbc);
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ };
+ }
+
private class LoadApplicationsJob extends Job {
private LoadApplicationsJob() {
- super("Loading applications");
+ super("Loading applications...");
}
@Override
@@ -309,6 +407,22 @@
model.getSelectedApplication().getName()));
}
}
+ }
+ private class LoadDomainJob extends Job {
+ private LoadDomainJob() {
+ super("Checking presence of domain...");
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ model.updateDomain();
+ return Status.OK_STATUS;
+ } catch (Exception e) {
+ return new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID,
+ "Could not get domain", e);
+ }
+ }
}
}
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPageModel.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPageModel.java 2011-10-11
20:22:21 UTC (rev 35556)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPageModel.java 2011-10-11
20:31:55 UTC (rev 35557)
@@ -15,6 +15,7 @@
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
import org.jboss.tools.openshift.express.client.IApplication;
+import org.jboss.tools.openshift.express.client.IDomain;
import org.jboss.tools.openshift.express.client.IUser;
import org.jboss.tools.openshift.express.client.OpenshiftException;
@@ -24,8 +25,12 @@
*/
public class ApplicationWizardPageModel extends ObservableUIPojo {
+ public static final String PROPERTY_NAMESPACE = "namespace";
+ public static final String PROPERTY_DOMAIN = "domain";
public static final String PROPERTY_SELECTED_APPLICATION =
"selectedApplication";
+ private String namespace;
+ private IDomain domain;
private IApplication selectedApplication;
private ServerAdapterWizardModel wizardModel;
@@ -33,6 +38,43 @@
this.wizardModel = wizardModel;
}
+ public String getNamespace() {
+ return this.namespace;
+ }
+
+ private void setNamespace(IDomain domain) {
+ if (domain != null) {
+ setNamespace(domain.getNamespace());
+ } else {
+ setNamespace((String) null);
+ }
+ }
+
+ public void setNamespace(String namespace) {
+ firePropertyChange(PROPERTY_NAMESPACE, this.namespace, this.namespace = namespace);
+ }
+
+ public boolean hasDomain() {
+ return domain != null;
+ }
+
+ public IDomain getDomain() {
+ return domain;
+ }
+
+ public void setDomain(IDomain domain) {
+ firePropertyChange(PROPERTY_DOMAIN, this.domain, this.domain = domain);
+ setNamespace(domain);
+ }
+
+ public void renameDomain() throws OpenshiftException {
+ getDomain().setNamespace(namespace);
+ }
+
+ public void updateDomain() throws OpenshiftException {
+ setDomain(getUser().getDomain());
+ }
+
public Collection<IApplication> getApplications() throws OpenshiftException {
IUser user = wizardModel.getUser();
if (user == null) {
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java 2011-10-11
20:22:21 UTC (rev 35556)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java 2011-10-11
20:31:55 UTC (rev 35557)
@@ -135,7 +135,7 @@
model.validateCredentials();
return Status.OK_STATUS;
}
- }, getWizard().getContainer(), dbc);
+ }, getContainer(), dbc);
} catch (Exception ex) {
// ignore
}
@@ -150,7 +150,7 @@
public void widgetSelected(SelectionEvent e) {
BrowserUtil.checkedCreateInternalBrowser(OPENSHIFT_EXPRESS_SIGNUP_URL,
OPENSHIFT_EXPRESS_SIGNUP_URL,
OpenshiftUIActivator.PLUGIN_ID, OpenshiftUIActivator.getDefault().getLog());
- getWizard().getContainer().getShell().close();
+ getContainer().getShell().close();
}
};
}
Deleted:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/DomainWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/DomainWizardPage.java 2011-10-11
20:22:21 UTC (rev 35556)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/DomainWizardPage.java 2011-10-11
20:31:55 UTC (rev 35557)
@@ -1,158 +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.wizard;
-
-import org.eclipse.core.databinding.DataBindingContext;
-import org.eclipse.core.databinding.UpdateValueStrategy;
-import org.eclipse.core.databinding.beans.BeanProperties;
-import org.eclipse.core.databinding.observable.value.WritableValue;
-import org.eclipse.core.databinding.validation.IValidator;
-import org.eclipse.core.databinding.validation.ValidationStatus;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.wizard.IWizard;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.jboss.tools.common.ui.WizardUtils;
-import org.jboss.tools.common.ui.databinding.DataBindingUtils;
-import org.jboss.tools.openshift.express.client.IDomain;
-import org.jboss.tools.openshift.express.internal.ui.OpenshiftUIActivator;
-
-/**
- * @author André Dietisheim
- */
-public class DomainWizardPage extends AbstractOpenshiftWizardPage {
-
- private DomainWizardPageModel model;
- private ServerAdapterWizardModel wizardModel;
-
- public DomainWizardPage(IWizard wizard, ServerAdapterWizardModel wizardModel) {
- super("Domain", "Create a new domain (if you have none yet), use your
existing domain or rename it...",
- "new Domain", wizard);
- this.wizardModel = wizardModel;
- this.model = new DomainWizardPageModel(wizardModel);
- }
-
- protected void doCreateControls(Composite container, DataBindingContext dbc) {
- GridLayoutFactory.fillDefaults().numColumns(3).applyTo(container);
-
- Label namespaceLabel = new Label(container, SWT.NONE);
- namespaceLabel.setText("&Domain name");
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(namespaceLabel);
- Text namespaceText = new Text(container, SWT.BORDER);
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2,
1).applyTo(namespaceText);
- DataBindingUtils.bindMandatoryTextField(
- namespaceText, "Domain name", DomainWizardPageModel.PROPERTY_NAMESPACE,
model, dbc);
-
- // bind the existence of a domain to the page validity
- dbc.bindValue(
- new WritableValue(null, IDomain.class)
- , BeanProperties.value(DomainWizardPageModel.PROPERTY_DOMAIN).observe(model)
- , new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER)
- , new UpdateValueStrategy().setAfterGetValidator(new IValidator() {
-
- @Override
- public IStatus validate(Object value) {
- if (!(value instanceof IDomain)) {
- return ValidationStatus.info("You have no domain yet, you need to create
one.");
- }
- return ValidationStatus.ok();
- }
- }));
-
- Label spacerLabel = new Label(container, SWT.NONE);
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(80,
30).applyTo(spacerLabel);
-
- Button createButton = new Button(container, SWT.PUSH);
- createButton.setText("&Create");
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(80,
SWT.DEFAULT).applyTo(createButton);
- DataBindingUtils.bindEnablementToValidationStatus(createButton, IStatus.ERROR |
IStatus.WARNING | IStatus.INFO , dbc);
- createButton.addSelectionListener(onCreate(dbc));
-
- Button renameButton = new Button(container, SWT.PUSH);
- renameButton.setText("&Rename");
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(80,
SWT.DEFAULT).applyTo(renameButton);
- DataBindingUtils.bindEnablementToValidationStatus(renameButton, IStatus.OK, dbc);
- renameButton.addSelectionListener(onRename(dbc));
- }
-
- private SelectionListener onCreate(DataBindingContext dbc) {
- return new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- Shell shell = getContainer().getShell();
- if (WizardUtils.openWizardDialog(new NewDomainDialog(model.getNamespace(),
wizardModel), shell)
- == Dialog.OK) {
- }
- }
- };
- }
-
- private SelectionListener onRename(DataBindingContext dbc) {
- return new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- try {
- WizardUtils.runInWizard(new Job("Renaming domain...") {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- model.renameDomain();
- return Status.OK_STATUS;
- } catch (Exception e) {
- return new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID,
- "Could not get domain", e);
- }
- }
- }, getWizard().getContainer(), getDatabindingContext());
- } catch (Exception ex) {
- // ignore
- }
- }
- };
- }
-
- @Override
- protected void onPageActivated(DataBindingContext dbc) {
- try {
- WizardUtils.runInWizard(new Job("Checking presence of domain...") {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- model.updateDomain();
- return Status.OK_STATUS;
- } catch (Exception e) {
- return new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID,
- "Could not get domain", e);
- }
- }
- }, getWizard().getContainer(), getDatabindingContext());
- } catch (Exception ex) {
- // ignore
- }
- }
-}
Deleted:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/DomainWizardPageModel.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/DomainWizardPageModel.java 2011-10-11
20:22:21 UTC (rev 35556)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/DomainWizardPageModel.java 2011-10-11
20:31:55 UTC (rev 35557)
@@ -1,75 +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.wizard;
-
-import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
-import org.jboss.tools.openshift.express.client.IDomain;
-import org.jboss.tools.openshift.express.client.IUser;
-import org.jboss.tools.openshift.express.client.OpenshiftException;
-
-/**
- * @author André Dietisheim
- */
-public class DomainWizardPageModel extends ObservableUIPojo {
-
- public static final String PROPERTY_NAMESPACE = "namespace";
- public static final String PROPERTY_DOMAIN = "domain";
-
- private String namespace;
- private IDomain domain;
- private ServerAdapterWizardModel wizardModel;
-
- public DomainWizardPageModel(ServerAdapterWizardModel wizardModel) {
- this.wizardModel = wizardModel;
- }
-
- public String getNamespace() {
- return this.namespace;
- }
-
- public void setNamespace(String namespace) {
- firePropertyChange(PROPERTY_NAMESPACE, this.namespace, this.namespace = namespace);
- }
-
- public boolean hasDomain() {
- return domain != null;
- }
-
- public IDomain getDomain() {
- return domain;
- }
-
- public void setDomain(IDomain domain) {
- firePropertyChange(PROPERTY_DOMAIN, this.domain, this.domain = domain);
- setNamespace(domain);
- }
-
- private void setNamespace(IDomain domain) {
- if (domain != null) {
- setNamespace(domain.getNamespace());
- } else {
- setNamespace((String) null);
- }
- }
-
- public void renameDomain() throws OpenshiftException {
- getDomain().setNamespace(namespace);
- }
-
- public void updateDomain() throws OpenshiftException {
- setDomain(getUser().getDomain());
- }
-
- public IUser getUser() {
- return wizardModel.getUser();
- }
-
-}
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainDialog.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainDialog.java 2011-10-11
20:22:21 UTC (rev 35556)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainDialog.java 2011-10-11
20:31:55 UTC (rev 35557)
@@ -26,13 +26,12 @@
*/
public class NewDomainDialog extends Wizard {
- private NewDomainWizardPageModel newDomainWizardModel;
- private ServerAdapterWizardModel wizardModel;
private String namespace;
+ private NewDomainWizardModel model;
public NewDomainDialog(String namespace, ServerAdapterWizardModel wizardModel) {
this.namespace = namespace;
- this.wizardModel = wizardModel;
+ this.model = new NewDomainWizardModel(namespace, wizardModel.getUser());
setNeedsProgressMonitor(true);
}
@@ -40,17 +39,17 @@
public boolean performFinish() {
final ArrayBlockingQueue<Boolean> queue = new
ArrayBlockingQueue<Boolean>(1);
try {
- WizardUtils.runInWizard(new Job("Creating application...") {
+ WizardUtils.runInWizard(new Job("Creating domain...") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
- newDomainWizardModel.createDomain();
+ model.createDomain();
queue.offer(true);
} catch (Exception e) {
queue.offer(false);
return new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID,
- NLS.bind("Could not create domain \"{0}\"",
newDomainWizardModel.getNamespace()), e);
+ NLS.bind("Could not create domain \"{0}\"",
model.getNamespace()), e);
}
return Status.OK_STATUS;
}
@@ -63,6 +62,6 @@
@Override
public void addPages() {
- addPage(new NewDomainWizardPage(namespace, wizardModel, this));
+ addPage(new NewDomainWizardPage(namespace, model, this));
}
}
Copied:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardModel.java
(from rev 35512,
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java)
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardModel.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardModel.java 2011-10-11
20:31:55 UTC (rev 35557)
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * 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.wizard;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
+import org.jboss.tools.openshift.express.client.IDomain;
+import org.jboss.tools.openshift.express.client.ISSHPublicKey;
+import org.jboss.tools.openshift.express.client.IUser;
+import org.jboss.tools.openshift.express.client.OpenshiftException;
+import org.jboss.tools.openshift.express.client.SSHPublicKey;
+
+/**
+ * @author André Dietisheim
+ */
+public class NewDomainWizardModel extends ObservableUIPojo {
+
+ public static final String PROPERTY_NAMESPACE = "namespace";
+ public static final String PROPERTY_SSHKEY = "sshKey";
+ public static final String PROPERTY_DOMAIN = "domain";
+
+ private String namespace;
+ private IDomain domain;
+ private String sshKey;
+ private IUser user;
+
+ public NewDomainWizardModel(String namespace, IUser user) {
+ this.namespace = namespace;
+ this.user = user;
+ }
+
+ public String getNamespace() {
+ return this.namespace;
+ }
+
+ public void createDomain() throws OpenshiftException, IOException {
+ IDomain domain = user.createDomain(namespace, loadSshKey());
+ setDomain(domain);
+ }
+
+ public String getSshKey() {
+ return sshKey;
+ }
+
+ public void setSshKey(String sshKey) {
+ firePropertyChange(PROPERTY_SSHKEY, this.sshKey, this.sshKey = sshKey);
+ }
+
+ private ISSHPublicKey loadSshKey() throws IOException, OpenshiftException {
+ return new SSHPublicKey(new File(sshKey));
+ }
+
+ public void setNamespace(String namespace) {
+ firePropertyChange(PROPERTY_NAMESPACE, this.namespace, this.namespace = namespace);
+ }
+
+ public boolean hasDomain() {
+ return domain != null;
+ }
+
+ public IDomain getDomain() {
+ return domain;
+ }
+
+ public void setDomain(IDomain domain) {
+ firePropertyChange(PROPERTY_DOMAIN, this.domain, this.domain = domain);
+ if (domain != null) {
+ setNamespace(domain.getNamespace());
+ }
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardModel.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java 2011-10-11
20:22:21 UTC (rev 35556)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java 2011-10-11
20:31:55 UTC (rev 35557)
@@ -43,11 +43,11 @@
private static final String FILTEREXPRESSION_PUBLIC_SSH_KEY = "*.pub";
private static final String FILTERNAME_PUBLIC_SSH_KEY = "Public ssh key file
(*.pub)";
- private NewDomainWizardPageModel model;
+ private NewDomainWizardModel model;
- public NewDomainWizardPage(String namespace, ServerAdapterWizardModel wizardModel,
IWizard wizard) {
+ public NewDomainWizardPage(String namespace, NewDomainWizardModel model, IWizard wizard)
{
super("Domain", "Create a new domain", "New Domain",
wizard);
- this.model = new NewDomainWizardPageModel(namespace, wizardModel);
+ this.model = model;
}
protected void doCreateControls(Composite container, DataBindingContext dbc) {
@@ -59,17 +59,17 @@
Text namespaceText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2,
1).applyTo(namespaceText);
DataBindingUtils.bindMandatoryTextField(
- namespaceText, "Domain name", NewDomainWizardPageModel.PROPERTY_NAMESPACE,
model, dbc);
+ namespaceText, "Domain name", NewDomainWizardModel.PROPERTY_NAMESPACE,
model, dbc);
Label sshKeyLabel = new Label(container, SWT.NONE);
- sshKeyLabel.setText("SSH Key");
+ sshKeyLabel.setText("SSH Public Key");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(sshKeyLabel);
Text sshKeyText = new Text(container, SWT.READ_ONLY | SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(sshKeyText);
Binding sshKeyBinding = dbc.bindValue(
WidgetProperties.text(SWT.Modify).observe(sshKeyText)
- , BeanProperties.value(NewDomainWizardPageModel.PROPERTY_SSHKEY).observe(model)
+ , BeanProperties.value(NewDomainWizardModel.PROPERTY_SSHKEY).observe(model)
, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER)
, null
);
Deleted:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java 2011-10-11
20:22:21 UTC (rev 35556)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java 2011-10-11
20:31:55 UTC (rev 35557)
@@ -1,84 +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.wizard;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
-import org.jboss.tools.openshift.express.client.IDomain;
-import org.jboss.tools.openshift.express.client.ISSHPublicKey;
-import org.jboss.tools.openshift.express.client.OpenshiftException;
-import org.jboss.tools.openshift.express.client.SSHPublicKey;
-
-/**
- * @author André Dietisheim
- */
-public class NewDomainWizardPageModel extends ObservableUIPojo {
-
- public static final String PROPERTY_NAMESPACE = "namespace";
- public static final String PROPERTY_SSHKEY = "sshKey";
- public static final String PROPERTY_DOMAIN = "domain";
-
- private String namespace;
- private IDomain domain;
- private String sshKey;
- private ServerAdapterWizardModel wizardModel;
-
- public NewDomainWizardPageModel(String namespace, ServerAdapterWizardModel wizardModel)
{
- setNamespace(namespace);
- this.wizardModel = wizardModel;
- }
-
- public String getNamespace() {
- return this.namespace;
- }
-
- public void createDomain() throws OpenshiftException, IOException {
- IDomain domain = wizardModel.getUser().createDomain(namespace, loadSshKey());
- setDomain(domain);
- }
-
- public String getSshKey() {
- return sshKey;
- }
-
- public void setSshKey(String sshKey) {
- firePropertyChange(PROPERTY_SSHKEY, this.sshKey, this.sshKey = sshKey);
- }
-
- private ISSHPublicKey loadSshKey() throws IOException, OpenshiftException {
- return new SSHPublicKey(new File(sshKey));
- }
-
- public void setNamespace(String namespace) {
- firePropertyChange(PROPERTY_NAMESPACE, this.namespace, this.namespace = namespace);
- }
-
- public boolean hasDomain() {
- return domain != null;
- }
-
- public IDomain getDomain() {
- return domain;
- }
-
- public void setDomain(IDomain domain) {
- firePropertyChange(PROPERTY_DOMAIN, this.domain, this.domain = domain);
- if (domain != null) {
- setNamespace(domain.getNamespace());
- }
- }
-
- public void updateDomain() throws OpenshiftException {
- setDomain(wizardModel.getUser().getDomain());
- }
-}
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ServerAdapterWizard.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ServerAdapterWizard.java 2011-10-11
20:22:21 UTC (rev 35556)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ServerAdapterWizard.java 2011-10-11
20:31:55 UTC (rev 35557)
@@ -79,7 +79,6 @@
public void addPages() {
this.model = new ServerAdapterWizardModel();
addPage(new CredentialsWizardPage(this, model));
- addPage(new DomainWizardPage(this, model));
addPage(new ApplicationWizardPage(this, model));
addPage(new AdapterWizardPage(this, model));
}