Author: adietish
Date: 2011-10-04 15:18:39 -0400 (Tue, 04 Oct 2011)
New Revision: 35333
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewApplicationDialog.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewApplicationWizardPage.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewApplicationWizardPageModel.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/ApplicationWizardPage.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/ApplicationWizardPageModel.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewDomainWizardPage.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewDomainWizardPageModel.java
Log:
[JBIDE-9793] implementing Application page (selection, create new, delete selected, etc.)
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/ApplicationWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/ApplicationWizardPage.java 2011-10-04
18:20:34 UTC (rev 35332)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/ApplicationWizardPage.java 2011-10-04
19:18:39 UTC (rev 35333)
@@ -12,30 +12,51 @@
import java.util.Collection;
+import org.eclipse.core.databinding.Binding;
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.list.IObservableList;
-import org.eclipse.core.databinding.observable.list.WritableList;
+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.databinding.viewers.ViewerSupport;
+import org.eclipse.jface.databinding.viewers.ViewerProperties;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.layout.TableColumnLayout;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CellLabelProvider;
+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;
import org.eclipse.jface.wizard.IWizard;
+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.layout.FillLayout;
+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.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.PlatformUI;
import org.jboss.ide.eclipse.as.openshift.core.IApplication;
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
import org.jboss.ide.eclipse.as.openshift.ui.internal.OpenshiftUIActivator;
+import org.jboss.tools.common.ui.BrowserUtil;
import org.jboss.tools.common.ui.WizardUtils;
+import org.jboss.tools.common.ui.databinding.DataBindingUtils;
/**
* @author André Dietisheim
@@ -46,29 +67,149 @@
private ApplicationWizardPageModel model;
protected ApplicationWizardPage(IWizard wizard, ServerAdapterWizardModel wizardModel) {
- super("Application selection", "Please select an Openshift Express
application to use",
+ super("Application selection", "Please select an Openshift Express
application",
"Application selection", wizard);
this.model = new ApplicationWizardPageModel(wizardModel);
}
@Override
protected void doCreateControls(Composite container, DataBindingContext dbc) {
- GridLayoutFactory.fillDefaults().numColumns(1).margins(10, 10).applyTo(container);
+ GridLayoutFactory.fillDefaults().numColumns(3).margins(10, 10).spacing(4,
4).applyTo(container);
Group group = new Group(container, SWT.BORDER);
group.setText("Available applications");
- GridDataFactory.fillDefaults().hint(600, 300).applyTo(group);
+ GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).span(3,
1).applyTo(group);
FillLayout fillLayout = new FillLayout(SWT.VERTICAL);
- fillLayout.marginHeight = 10;
- fillLayout.marginWidth = 10;
+ fillLayout.marginHeight = 6;
+ fillLayout.marginWidth = 6;
group.setLayout(fillLayout);
-
- Table table = new Table(group, SWT.BORDER | SWT.V_SCROLL);
+
+ this.viewer = createApplicationTable(group);
+ viewer.addDoubleClickListener(onApplicationDoubleClick());
+
+ Binding selectedApplicationBinding = dbc.bindValue(
+ ViewerProperties.singleSelection().observe(viewer),
+ BeanProperties.value(ApplicationWizardPageModel.PROPERTY_SELECTED_APPLICATION).observe(model),
+ new UpdateValueStrategy().setAfterGetValidator(new IValidator() {
+
+ @Override
+ public IStatus validate(Object value) {
+ if (value != null) {
+ return ValidationStatus.ok();
+ }
+ else {
+ return ValidationStatus.info("You have to select an application...");
+ }
+ }
+ }),
+ null);
+
+ Button newButton = new Button(container, SWT.PUSH);
+ newButton.setText("New");
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(newButton);
+ newButton.addSelectionListener(onNew(dbc));
+
+ Button deleteButton = new Button(container, SWT.PUSH);
+ deleteButton.setText("Delete");
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(deleteButton);
+ DataBindingUtils.bindButtonEnablementToValidationStatus(deleteButton, dbc,
selectedApplicationBinding);
+ deleteButton.addSelectionListener(onDelete(dbc));
+ }
+
+ protected 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);
+ }
+ }
+ };
+ }
+
+ protected SelectionAdapter onNew(DataBindingContext dbc) {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Shell shell = getContainer().getShell();
+ if (WizardUtils.openWizardDialog(new NewApplicationDialog(model.getUser()), shell)
+ == Dialog.OK) {
+ viewer.refresh();
+ }
+ }
+ };
+ }
+
+ protected TableViewer createApplicationTable(Group group) {
+ Composite tableContainer = new Composite(group, SWT.NONE);
+ Table table = new Table(tableContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL
| SWT.H_SCROLL);
table.setLinesVisible(true);
table.setHeaderVisible(true);
- this.viewer = new TableViewer(table);
+ TableColumnLayout tableLayout = new TableColumnLayout();
+ tableContainer.setLayout(tableLayout);
+ TableViewer viewer = new TableViewer(table);
+ viewer.setContentProvider(new ArrayContentProvider());
+
+ createTableColumn("Name", 1, new CellLabelProvider() {
+
+ @Override
+ public void update(ViewerCell cell) {
+ IApplication application = (IApplication) cell.getElement();
+ cell.setText(application.getName());
+ }
+ }, viewer, tableLayout);
+ createTableColumn("URL", 3, new CellLabelProvider() {
+
+ @Override
+ public void update(ViewerCell cell) {
+ try {
+ IApplication application = (IApplication) cell.getElement();
+ cell.setText(application.getApplicationUrl());
+ } catch (OpenshiftException e) {
+ // ignore
+ }
+ }
+ }, viewer, tableLayout);
+ return viewer;
}
+ private void createTableColumn(String name, int weight, CellLabelProvider
cellLabelProvider, TableViewer viewer,
+ TableColumnLayout layout) {
+ TableViewerColumn column = new TableViewerColumn(viewer, SWT.LEFT);
+ column.getColumn().setText(name);
+ column.setLabelProvider(cellLabelProvider);
+
+ layout.setColumnData(column.getColumn(), new ColumnWeightData(weight, true));
+ }
+
+ private SelectionAdapter onDelete(final DataBindingContext dbc) {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ WizardUtils.runInWizard(new DeleteApplicationJob(), getWizard().getContainer(),
dbc);
+ } catch (Exception ex) {
+ // ignore
+ }
+ }
+ };
+ }
+
@Override
protected void onPageActivated(DataBindingContext dbc) {
try {
@@ -78,18 +219,6 @@
}
}
- protected void bindApplications(final Collection<IApplication> applications, final
TableViewer viewer) {
- Display display = PlatformUI.getWorkbench().getDisplay();
- display.syncExec(new Runnable() {
-
- @Override
- public void run() {
- IObservableList input = new WritableList(applications, IApplication.class);
- ViewerSupport.bind(viewer, input, BeanProperties.values(new String[] {
"name", "applicationUrl" }));
- }
- });
- }
-
private class LoadApplicationsJob extends Job {
private LoadApplicationsJob() {
super("Loading applications");
@@ -98,7 +227,15 @@
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
- bindApplications(model.getApplications(), viewer);
+ final Collection<IApplication> applications = model.getApplications();
+ Display display = PlatformUI.getWorkbench().getDisplay();
+ display.syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ viewer.setInput(applications);
+ }
+ });
return Status.OK_STATUS;
} catch (OpenshiftException e) {
return new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID,
@@ -106,4 +243,24 @@
}
}
}
+
+ private class DeleteApplicationJob extends Job {
+
+ public DeleteApplicationJob() {
+ super("Deleteing application");
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ model.destroyCurrentApplication();
+ return Status.OK_STATUS;
+ } catch (OpenshiftException e) {
+ return new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID, NLS.bind(
+ "Could not delete application \"{0}\"",
+ model.getSelectedApplication().getName()));
+ }
+ }
+
+ }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/ApplicationWizardPageModel.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/ApplicationWizardPageModel.java 2011-10-04
18:20:34 UTC (rev 35332)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/ApplicationWizardPageModel.java 2011-10-04
19:18:39 UTC (rev 35333)
@@ -11,17 +11,22 @@
package org.jboss.ide.eclipse.as.openshift.ui.internal.wizard;
import java.util.Collection;
+import java.util.Collections;
import org.jboss.ide.eclipse.as.openshift.core.IApplication;
import org.jboss.ide.eclipse.as.openshift.core.IUser;
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
+import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
/**
* @author André Dietisheim
- *
+ *
*/
-public class ApplicationWizardPageModel {
+public class ApplicationWizardPageModel extends ObservableUIPojo {
+ public static final String PROPERTY_SELECTED_APPLICATION =
"selectedApplication";
+
+ private IApplication selectedApplication;
private ServerAdapterWizardModel wizardModel;
public ApplicationWizardPageModel(ServerAdapterWizardModel wizardModel) {
@@ -30,7 +35,30 @@
public Collection<IApplication> getApplications() throws OpenshiftException {
IUser user = wizardModel.getUser();
+ if (user == null) {
+ return Collections.emptyList();
+ }
return user.getApplications();
}
+ public IApplication getSelectedApplication() {
+ return selectedApplication;
+ }
+
+ public void setSelectedApplication(IApplication application) {
+ firePropertyChange(PROPERTY_SELECTED_APPLICATION, this.selectedApplication,
this.selectedApplication = application);
+ }
+
+ public void destroyCurrentApplication() throws OpenshiftException {
+ if (selectedApplication == null) {
+ return;
+ }
+
+ selectedApplication.destroy();
+ }
+
+ public IUser getUser() {
+ return wizardModel.getUser();
+ }
+
}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewApplicationDialog.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewApplicationDialog.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewApplicationDialog.java 2011-10-04
19:18:39 UTC (rev 35333)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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.ide.eclipse.as.openshift.ui.internal.wizard;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.jboss.ide.eclipse.as.openshift.core.IUser;
+
+/**
+ * @author André Dietisheim
+ */
+public class NewApplicationDialog extends Wizard {
+
+ private IUser user;
+
+ public NewApplicationDialog(IUser user) {
+ this.user = user;
+ setNeedsProgressMonitor(true);
+ }
+
+ @Override
+ public boolean performFinish() {
+ return true;
+ }
+
+ @Override
+ public void addPages() {
+ addPage(new NewApplicationWizardPage(new NewApplicationWizardPageModel(user), this));
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewApplicationDialog.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewApplicationWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewApplicationWizardPage.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewApplicationWizardPage.java 2011-10-04
19:18:39 UTC (rev 35333)
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * 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.ide.eclipse.as.openshift.ui.internal.wizard;
+
+import org.eclipse.core.databinding.DataBindingContext;
+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.IInputValidator;
+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.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
+import org.jboss.ide.eclipse.as.openshift.ui.internal.OpenshiftUIActivator;
+import org.jboss.tools.common.ui.WizardUtils;
+
+/**
+ * @author André Dietisheim
+ */
+public class NewApplicationWizardPage extends AbstractOpenshiftWizardPage {
+
+ private static final int NAME_MAXLENGTH = 13;
+
+ private NewApplicationWizardPageModel model;
+
+ public NewApplicationWizardPage(NewApplicationWizardPageModel model, IWizard wizard) {
+ super("Create new Openshift Express application", "Create new Openshift
Express application",
+ "Create new Openshift Express application", wizard);
+ this.model = model;
+ }
+
+ @Override
+ protected void doCreateControls(Composite parent, DataBindingContext dbc) {
+ GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).applyTo(parent);
+
+ Label nameLabel = new Label(parent, SWT.NONE);
+ nameLabel.setText("Name");
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(nameLabel);
+ Text nameText = new Text(parent, SWT.BORDER);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(nameText);
+
+ 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);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(cartridgesCombo);
+ }
+
+ @Override
+ protected void onPageActivated(DataBindingContext dbc) {
+ try {
+ WizardUtils.runInWizard(new Job("Load 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);
+ }
+ return Status.OK_STATUS;
+ }
+ }, getContainer());
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ private final class ApplicationNameValidator implements IInputValidator {
+
+ @Override
+ public String isValid(String newText) {
+ if (newText.length() > 0
+ && newText.length() <= NAME_MAXLENGTH) {
+ return null;
+ } else {
+ return "you have to provide a valid application name with less than 13
characters";
+ }
+ }
+ };
+
+}
\ No newline at end of file
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewApplicationWizardPage.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewApplicationWizardPageModel.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewApplicationWizardPageModel.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewApplicationWizardPageModel.java 2011-10-04
19:18:39 UTC (rev 35333)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.ide.eclipse.as.openshift.ui.internal.wizard;
+
+import java.util.Collection;
+
+import org.jboss.ide.eclipse.as.openshift.core.ICartridge;
+import org.jboss.ide.eclipse.as.openshift.core.IUser;
+import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
+import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
+
+/**
+ * @author André Dietisheim
+ */
+public class NewApplicationWizardPageModel extends ObservableUIPojo {
+
+ private static final String PROPERTY_CARTRIDGES = "cartridges";
+
+ private IUser user;
+ private Collection<ICartridge> cartridges;
+
+ public NewApplicationWizardPageModel(IUser user) {
+ this.user = user;
+ }
+
+ public void loadCartridges() throws OpenshiftException {
+ setCartridges(user.getCartridges());
+ }
+
+ public void setCartridges(Collection<ICartridge> cartridges) {
+ firePropertyChange(PROPERTY_CARTRIDGES, this.cartridges, this.cartridges =
cartridges);
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewApplicationWizardPageModel.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewDomainWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewDomainWizardPage.java 2011-10-04
18:20:34 UTC (rev 35332)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewDomainWizardPage.java 2011-10-04
19:18:39 UTC (rev 35333)
@@ -12,12 +12,17 @@
import java.io.File;
import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.TimeUnit;
import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.ValidationStatusProvider;
+import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.observable.IObservableCollection;
import org.eclipse.core.databinding.observable.list.WritableList;
+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;
@@ -37,7 +42,7 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
-import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
+import org.jboss.ide.eclipse.as.openshift.core.IDomain;
import org.jboss.ide.eclipse.as.openshift.ui.internal.OpenshiftUIActivator;
import org.jboss.tools.common.ui.BrowserUtil;
import org.jboss.tools.common.ui.WizardUtils;
@@ -94,6 +99,12 @@
.applyTo(createButton);
createButton.addSelectionListener(onCreate(dbc));
DataBindingUtils.bindButtonEnablementToValidationStatus(createButton, dbc);
+
+ dbc.bindValue(
+ new WritableValue(null, IDomain.class)
+ , BeanProperties.value(NewDomainWizardPageModel.PROPERTY_DOMAIN).observe(model)
+ , new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER)
+ , new UpdateValueStrategy().setAfterGetValidator(new DomainCreatedValidator()));
}
private SelectionListener onBrowseSshKey() {
@@ -110,7 +121,6 @@
if (sshKeyPath != null) {
model.setSshKey(sshKeyPath);
}
- ;
}
};
}
@@ -134,7 +144,7 @@
protected IStatus run(IProgressMonitor monitor) {
try {
model.createDomain();
- } catch (OpenshiftException e) {
+ } catch (Exception e) {
return new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID, NLS.bind(
"Could not create a new domain with the name \"{0}\"",
model.getNamespace()), e);
@@ -174,8 +184,8 @@
if (!model.hasUser()) {
return false;
}
-
- final BlockingQueue<Boolean> queue = new ArrayBlockingQueue<Boolean>(1);
+
+ final ArrayBlockingQueue<Boolean> queue = new
ArrayBlockingQueue<Boolean>(1);
try {
WizardUtils.runInWizard(
new Job("Checking presence of domain") {
@@ -188,13 +198,30 @@
queue.offer(false);
return new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID,
"Could not get domain", e);
- }
+ }
return Status.OK_STATUS;
}
}, getWizard().getContainer(), getDatabindingContext());
} catch (Exception ex) {
// ignore
}
- return queue.poll();
+
+ try {
+ return queue.poll(6, TimeUnit.SECONDS);
+ } catch (InterruptedException e) {
+ return false;
+ }
}
+
+ private static class DomainCreatedValidator implements IValidator {
+ @Override
+ public IStatus validate(Object value) {
+ if (value != null) {
+ return ValidationStatus.ok();
+ } else {
+ return ValidationStatus.info("You have to create a domain...");
+ }
+ }
+ };
+
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewDomainWizardPageModel.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewDomainWizardPageModel.java 2011-10-04
18:20:34 UTC (rev 35332)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.ui/src/org/jboss/ide/eclipse/as/openshift/ui/internal/wizard/NewDomainWizardPageModel.java 2011-10-04
19:18:39 UTC (rev 35333)
@@ -10,10 +10,14 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.openshift.ui.internal.wizard;
+import java.io.File;
+import java.io.IOException;
+
import org.jboss.ide.eclipse.as.openshift.core.IDomain;
import org.jboss.ide.eclipse.as.openshift.core.ISSHPublicKey;
import org.jboss.ide.eclipse.as.openshift.core.IUser;
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
+import org.jboss.ide.eclipse.as.openshift.core.SSHPublicKey;
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
/**
@@ -23,6 +27,7 @@
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;
@@ -37,9 +42,10 @@
return this.namespace;
}
- public void createDomain() throws OpenshiftException {
- IUser user = wizardModel.getUser();
- this.domain = user.createDomain(namespace, loadSshKey());
+ public void createDomain() throws OpenshiftException, IOException {
+ IUser user = getUser();
+ IDomain domain = user.createDomain(namespace, loadSshKey());
+ setDomain(domain);
}
public String getSshKey() {
@@ -50,9 +56,8 @@
firePropertyChange(PROPERTY_SSHKEY, this.sshKey, this.sshKey = sshKey);
}
- private ISSHPublicKey loadSshKey() {
- // TODO Auto-generated method stub
- return null;
+ private ISSHPublicKey loadSshKey() throws IOException, OpenshiftException {
+ return new SSHPublicKey(new File(sshKey));
}
public void setNamespace(String namespace) throws OpenshiftException {
@@ -66,21 +71,18 @@
return getUser().hasDomain();
}
- public void loadDomain() throws OpenshiftException {
- if (!hasUser()) {
- return;
- }
- IDomain domain = getUser().getDomain();
- if (domain != null) {
- this.domain = domain;
- setNamespace(domain.getNamespace());
- }
+ public IDomain getDomain() {
+ return domain;
}
+ public void setDomain(IDomain domain) {
+ firePropertyChange(PROPERTY_DOMAIN, this.domain, this.domain = domain);
+ }
+
public boolean hasUser() {
return wizardModel.getUser() != null;
}
-
+
public IUser getUser() {
return wizardModel.getUser();
}