Author: xcoulon
Date: 2012-02-14 09:22:47 -0500 (Tue, 14 Feb 2012)
New Revision: 38699
Removed:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizard.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizardModel.java
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialogModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EditDomainWizardPage.java
Log:
Open - JBIDE-10899 There are many deprecated classes that we should clean up
https://issues.jboss.org/browse/JBIDE-10899
Deleted:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java 2012-02-14
14:03:44 UTC (rev 38698)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java 2012-02-14
14:22:47 UTC (rev 38699)
@@ -1,556 +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.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-
-import org.eclipse.core.databinding.DataBindingContext;
-import org.eclipse.core.databinding.beans.BeanProperties;
-import org.eclipse.core.databinding.observable.value.IObservableValue;
-import org.eclipse.core.databinding.observable.value.WritableValue;
-import org.eclipse.core.databinding.validation.IValidator;
-import org.eclipse.core.databinding.validation.MultiValidator;
-import org.eclipse.core.databinding.validation.ValidationStatus;
-import org.eclipse.core.resources.IProject;
-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.swt.WidgetProperties;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.wizard.IWizardPage;
-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.events.SelectionListener;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.server.core.IServerType;
-import org.eclipse.wst.server.core.ServerCore;
-import org.jboss.tools.common.ui.databinding.DataBindingUtils;
-import org.jboss.tools.common.ui.databinding.InvertingBooleanConverter;
-import org.jboss.tools.common.ui.databinding.ValueBindingBuilder;
-import org.jboss.tools.common.ui.ssh.SshPrivateKeysPreferences;
-import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
-import org.jboss.tools.openshift.express.internal.ui.ValidationStatusControlDecoration;
-import
org.jboss.tools.openshift.express.internal.ui.wizard.appimport.ImportProjectWizard;
-import
org.jboss.tools.openshift.express.internal.ui.wizard.appimport.ImportProjectWizardModel;
-
-import com.openshift.express.client.OpenShiftException;
-
-/**
- * @author André Dietisheim
- * @author Rob Stryker
- *
- */
-@Deprecated
-public class AdapterWizardPage extends AbstractOpenShiftWizardPage implements
IWizardPage, PropertyChangeListener {
-
- private AdapterWizardPageModel model;
- private Text cloneUriValueText;
- private Label domainValueLabel;
- private Label modeValueLabel;
- private Button serverAdapterCheckbox;
- private IServerType serverTypeToCreate;
-
- private IObservableValue serverAdapterCheckboxObservable;
- private IObservableValue newProjectCheckboxIsEnabled;
-
- public AdapterWizardPage(ImportProjectWizard wizard, ImportProjectWizardModel model) {
- super(
- "Import OpenShift application",
- "Choose to create a new/use existing project, " +
- "the GIT branch and clone destination, "
- + "and configure your server adapter ",
- "Server Adapter",
- wizard);
- this.model = new AdapterWizardPageModel(model);
- model.addPropertyChangeListener(this);
- }
-
- @Override
- protected void doCreateControls(Composite parent, DataBindingContext dbc) {
- GridLayoutFactory.fillDefaults().applyTo(parent);
-
- Group mergeGroup = createProjectGroup(parent, dbc);
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(mergeGroup);
-
- Group cloneGroup = createCloneGroup(parent, dbc);
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(cloneGroup);
-
- Group serverAdapterGroup = createAdapterGroup(parent, dbc);
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(serverAdapterGroup);
-
- Label fillerLabel = new Label(parent, SWT.NONE);
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(fillerLabel);
-
- }
-
- private Group createProjectGroup(Composite parent, DataBindingContext dbc) {
- Group projectGroup = new Group(parent, SWT.BORDER);
- projectGroup.setText("Project");
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(projectGroup);
- GridLayoutFactory.fillDefaults().numColumns(3).margins(6, 6).applyTo(projectGroup);
-
- Button newProjectCheckbox = new Button(projectGroup, SWT.CHECK);
- newProjectCheckbox.setText("Create new Project");
- GridDataFactory.fillDefaults()
- .span(3, 1).align(SWT.FILL, SWT.CENTER).grab(true,
true).applyTo(newProjectCheckbox);
- IObservableValue newProjectObservable =
- BeanProperties.value(AdapterWizardPageModel.PROPERTY_NEW_PROJECT).observe(model);
- ValueBindingBuilder
- .bind(WidgetProperties.selection().observe(newProjectCheckbox))
- .to(newProjectObservable)
- .in(dbc);
-
- this.newProjectCheckboxIsEnabled =
WidgetProperties.enabled().observe(newProjectCheckbox);
-
- Label existingProjectLabel = new Label(projectGroup, SWT.NONE);
- existingProjectLabel.setText("Existing Project");
- GridDataFactory
- .fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(existingProjectLabel);
- ValueBindingBuilder
- .bind(WidgetProperties.enabled().observe(existingProjectLabel))
- .notUpdating(newProjectObservable)
- .converting(new InvertingBooleanConverter())
- .in(dbc);
-
- Text newProjectText = new Text(projectGroup, SWT.BORDER);
- newProjectText.setEditable(false);
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.CENTER).grab(true, true).applyTo(newProjectText);
-
- IObservableValue newProjectNameObservable =
- BeanProperties.value(AdapterWizardPageModel.PROPERTY_PROJECT_NAME).observe(model);
- ValueBindingBuilder
- .bind(WidgetProperties.text().observe(newProjectText))
- .to(newProjectNameObservable)
- .in(dbc);
- ValueBindingBuilder
- .bind(WidgetProperties.enabled().observe(newProjectText))
- .notUpdating(newProjectObservable)
- .converting(new InvertingBooleanConverter())
- .in(dbc);
- MultiValidator newProjectValidator = new NewProjectValidator(newProjectObservable,
newProjectNameObservable);
- dbc.addValidationStatusProvider(newProjectValidator);
- new ValidationStatusControlDecoration(newProjectValidator).showFor(newProjectText,
SWT.TOP | SWT.LEFT);
-
- Button browseProjectsButton = new Button(projectGroup, SWT.NONE);
- browseProjectsButton.setText("Browse");
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(browseProjectsButton);
- browseProjectsButton.addSelectionListener(onBrowseProjects());
- ValueBindingBuilder
- .bind(WidgetProperties.enabled().observe(browseProjectsButton))
- .notUpdating(newProjectObservable)
- .converting(new InvertingBooleanConverter())
- .in(dbc);
-
- return projectGroup;
- }
-
- private Group createCloneGroup(Composite parent, DataBindingContext dbc) {
- Group cloneGroup = new Group(parent, SWT.BORDER);
- cloneGroup.setText("Git clone");
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(cloneGroup);
- GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(4).applyTo(cloneGroup);
-
- Label gitUriLabel = new Label(cloneGroup, SWT.NONE);
- gitUriLabel.setText("Cloning From");
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(gitUriLabel);
-
- cloneUriValueText = new Text(cloneGroup, SWT.BORDER);
- cloneUriValueText.setEditable(false);
- GridDataFactory
- .fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(cloneUriValueText);
- ValueBindingBuilder
- .bind(WidgetProperties.text(SWT.Modify).observe(cloneUriValueText))
- .notUpdating(BeanProperties.value(AdapterWizardPageModel.PROPERTY_CLONE_URI).observe(model))
- .in(dbc);
- ValueBindingBuilder
- .bind(WidgetProperties.enabled().observe(cloneUriValueText))
- .notUpdating(BeanProperties.value(AdapterWizardPageModel.PROPERTY_LOADING).observe(model))
- .converting(new InvertingBooleanConverter())
- .in(dbc);
-
- // bind loading state to page complete
- ValueBindingBuilder
- .bind(new WritableValue(false, Boolean.class))
- .notUpdating(BeanProperties.value(AdapterWizardPageModel.PROPERTY_LOADING).observe(model))
- .validatingAfterGet(new IValidator() {
-
- @Override
- public IStatus validate(Object value) {
- if (Boolean.FALSE.equals(value)) {
- return ValidationStatus.ok();
- } else {
- return ValidationStatus.cancel("Loading...");
- }
- }
- })
- .in(dbc);
-
- Label repoPathLabel = new Label(cloneGroup, SWT.NONE);
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(repoPathLabel);
- repoPathLabel.setText("Destination");
-
- Button defaultRepoPathButton = new Button(cloneGroup, SWT.CHECK);
- defaultRepoPathButton.setText("default");
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(defaultRepoPathButton);
- defaultRepoPathButton.addSelectionListener(onDefaultRepoPath());
- IObservableValue defaultRepoButtonSelection =
WidgetProperties.selection().observe(defaultRepoPathButton);
-
- Text repoPathText = new Text(cloneGroup, SWT.BORDER);
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(repoPathText);
- DataBindingUtils.bindMandatoryTextField(
- repoPathText, "Location", AdapterWizardPageModel.PROPERTY_REPO_PATH, model,
dbc);
- ValueBindingBuilder
- .bind(defaultRepoButtonSelection)
- .converting(new InvertingBooleanConverter())
- .to(WidgetProperties.enabled().observe(repoPathText))
- .notUpdatingParticipant()
- .in(dbc);
-
- Button browseRepoPathButton = new Button(cloneGroup, SWT.PUSH);
- browseRepoPathButton.setText("Browse");
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(browseRepoPathButton);
- browseRepoPathButton.addSelectionListener(onRepoPath());
- ValueBindingBuilder
- .bind(defaultRepoButtonSelection)
- .converting(new InvertingBooleanConverter())
- .to(WidgetProperties.enabled().observe(browseRepoPathButton))
- .notUpdatingParticipant()
- .in(dbc);
-
- defaultRepoButtonSelection.setValue(true);
-
- Label remoteNameLabel = new Label(cloneGroup, SWT.NONE);
- remoteNameLabel.setText("Remote name");
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(remoteNameLabel);
-
- Button defaultRemoteNameButton = new Button(cloneGroup, SWT.CHECK);
- defaultRemoteNameButton.setText("default");
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).hint(100,
SWT.DEFAULT).applyTo(defaultRemoteNameButton);
- defaultRemoteNameButton.addSelectionListener(onDefaultRemoteName());
-
- Text remoteNameText = new Text(cloneGroup, SWT.BORDER);
- GridDataFactory.fillDefaults()
- .span(2, 1).align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true,
false)
- .applyTo(remoteNameText);
- DataBindingUtils.bindMandatoryTextField(
- remoteNameText, "Remote name", AdapterWizardPageModel.PROPERTY_REMOTE_NAME,
model, dbc);
-
- IObservableValue defaultRemoteNameSelection =
WidgetProperties.selection().observe(defaultRemoteNameButton);
- ValueBindingBuilder
- .bind(defaultRemoteNameSelection)
- .converting(new InvertingBooleanConverter())
- .to(WidgetProperties.enabled().observe(remoteNameText))
- .notUpdatingParticipant()
- .in(dbc);
- defaultRemoteNameSelection.setValue(true);
-
- Link sshPrefsLink = new Link(cloneGroup, SWT.NONE);
- sshPrefsLink
- .setText("Make sure your SSH key used with the domain is listed in <a>SSH2
Preferences</a>");
- GridDataFactory.fillDefaults()
- .span(4, 1).align(SWT.FILL, SWT.CENTER).indent(0, 10).applyTo(sshPrefsLink);
- sshPrefsLink.addSelectionListener(onSshPrefs());
-
- return cloneGroup;
- }
-
- private SelectionListener onBrowseProjects() {
- return new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- SelectExistingProjectDialog dialog =
- new SelectExistingProjectDialog(model.getApplicationName(), getShell());
- if (dialog.open() == Dialog.OK) {
- Object selectedProject = dialog.getFirstResult();
- if (selectedProject instanceof IProject) {
- model.setProjectName(((IProject) selectedProject).getName());
- }
- }
- }
-
- };
- }
-
- private SelectionListener onDefaultRepoPath() {
- return new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- model.resetRepositoryPath();
- }
- };
- }
-
- private SelectionListener onRepoPath() {
- return new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- DirectoryDialog dialog = new DirectoryDialog(getShell());
- dialog.setMessage("Choose the location to store your repository clone
to...");
- String repositoryPath = dialog.open();
- if (repositoryPath != null) {
- model.setRepositoryPath(repositoryPath);
- }
- }
- };
- }
-
- private SelectionListener onDefaultRemoteName() {
- return new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- model.resetRemoteName();
- }
- };
- }
-
- private SelectionAdapter onSshPrefs() {
- return new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- SshPrivateKeysPreferences.openPreferencesPage(getShell());
- }
- };
- }
-
- private Group createAdapterGroup(Composite parent, DataBindingContext dbc) {
- Group serverAdapterGroup = new Group(parent, SWT.BORDER);
- serverAdapterGroup.setText("Server Adapter");
- GridLayoutFactory.fillDefaults().margins(6, 6).applyTo(serverAdapterGroup);
-
- Composite c = new Composite(serverAdapterGroup, SWT.NONE);
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(c);
- GridLayoutFactory.fillDefaults().numColumns(3).spacing(12, 8).applyTo(c);
-
- serverAdapterCheckbox = new Button(c, SWT.CHECK);
- serverAdapterCheckbox.setText("Create OpenShift Server Adapter");
- GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER)
- .grab(true, false).applyTo(serverAdapterCheckbox);
- serverAdapterCheckbox.addSelectionListener(onCreateAdapter());
-
- Label domainLabel = new Label(c, SWT.NONE);
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(domainLabel);
- domainLabel.setText("Host");
- domainValueLabel = new Label(c, SWT.NONE);
- GridDataFactory.fillDefaults()
- .span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(domainValueLabel);
- ValueBindingBuilder
- .bind(WidgetProperties.text().observe(domainValueLabel))
- .notUpdating(BeanProperties.value(AdapterWizardPageModel.PROPERTY_APPLICATION_URL).observe(model))
- .in(dbc);
-
- Label modeLabel = new Label(c, SWT.NONE);
- modeLabel.setText("Mode");
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).applyTo(modeLabel);
- modeValueLabel = new Label(c, SWT.NONE);
- GridDataFactory.fillDefaults()
- .span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(modeValueLabel);
-
- model.getWizardModel().setProperty(
- AdapterWizardPageModel.CREATE_SERVER, serverAdapterCheckbox.getSelection());
- this.serverAdapterCheckboxObservable =
- WidgetProperties.selection().observe(serverAdapterCheckbox);
-
- return serverAdapterGroup;
- }
-
- private SelectionListener onCreateAdapter() {
- return new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- model.getWizardModel().setProperty(
- AdapterWizardPageModel.CREATE_SERVER, serverAdapterCheckbox.getSelection());
- enableServerWidgets(serverAdapterCheckbox.getSelection());
- }
- };
- }
-
- protected void enableServerWidgets(boolean enabled) {
- domainValueLabel.setEnabled(enabled);
- modeValueLabel.setEnabled(enabled);
- }
-
- private IServerType getServerTypeToCreate() {
- return
ServerCore.findServerType("org.jboss.tools.openshift.express.openshift.server.type");
- }
-
- protected void onPageActivated(DataBindingContext dbc) {
- // allow to enable a proj only for as7 openshift applications
- setTitle(NLS.bind("Import OpenShift application {0}",
model.getApplicationName()));
-
- newProjectCheckboxIsEnabled.setValue(model.isJBossAS7Application());
-
- model.resetRepositoryPath();
- serverTypeToCreate = getServerTypeToCreate();
- model.getWizardModel().setProperty(AdapterWizardPageModel.SERVER_TYPE,
serverTypeToCreate);
- modeValueLabel.setText("Source");
- model.getWizardModel().setProperty(AdapterWizardPageModel.MODE,
AdapterWizardPageModel.MODE_SOURCE);
- onPageActivatedBackground(dbc);
- }
-
- protected void onPageActivatedBackground(final DataBindingContext dbc) {
- new Job("Loading remote OpenShift application") {
- public IStatus run(IProgressMonitor monitor) {
- try {
- model.loadGitUri();
- model.loadApplicationUrl();
- } catch (OpenShiftException e) {
- IStatus status = OpenShiftUIActivator.createErrorStatus(e.getMessage(), e);
- OpenShiftUIActivator.log(status);
- return status;
- }
- return Status.OK_STATUS;
- }
- }.schedule();
- }
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (ImportProjectWizardModel.APPLICATION.equals(evt.getPropertyName())) {
- handleApplicationChanged();
- }
- }
-
- private void handleApplicationChanged() {
- // we need to enable or disable all the server widgets depending on
- // if we can make a server out of this
- serverTypeToCreate = getServerTypeToCreate();
- boolean canCreateServer = serverTypeToCreate != null;
- serverAdapterCheckbox.setEnabled(canCreateServer);
- serverAdapterCheckboxObservable.setValue(canCreateServer);
- enableServerWidgets(canCreateServer);
- model.getWizardModel().setProperty(AdapterWizardPageModel.SERVER_TYPE,
serverTypeToCreate);
- model.getWizardModel().setProperty(AdapterWizardPageModel.CREATE_SERVER,
canCreateServer);
- }
-
- /**
- * A multi validator that validates the state of the project that shall be
- * (OpenShift) enabled
- */
- private class NewProjectValidator extends MultiValidator {
-
- private IObservableValue newProjectObservable;
- private IObservableValue newProjectNameObservable;
-
- public NewProjectValidator(IObservableValue newProjectObservable,
- IObservableValue newProjectNameObservable) {
- this.newProjectObservable = newProjectObservable;
- this.newProjectNameObservable = newProjectNameObservable;
- }
-
- @Override
- protected IStatus validate() {
- /**
- * WARNING: it is important to evaluate the validation state on
- * behalf of observable values (not widgets!). The multi validator
- * is tracking what observables are read to know when he has to
- * recalculate it's state.
- */
- if (Boolean.TRUE.equals(newProjectObservable.getValue())) {
- return ValidationStatus.ok();
- }
-
- if (newProjectNameObservable.getValue() != null
- && (!((String) newProjectNameObservable.getValue()).isEmpty())) {
- return ValidationStatus.ok();
- } else {
- return ValidationStatus.error(
- "Select an existing project to use with OpenShift");
- }
- }
- }
-
- // private static class GitUriLabelProvider implements ILabelProvider {
- //
- // @Override
- // public void addListener(ILabelProviderListener listener) {
- // }
- //
- // @Override
- // public void dispose() {
- // }
- //
- // @Override
- // public boolean isLabelProperty(Object element, String property) {
- // return true;
- // }
- //
- // @Override
- // public void removeListener(ILabelProviderListener listener) {
- // }
- //
- // @Override
- // public Image getImage(Object element) {
- // return null;
- // }
- //
- // @Override
- // public String getText(Object element) {
- // if (!(element instanceof GitUri)) {
- // return null;
- // }
- // return ((GitUri) element).getLabel();
- // }
- // }
-
- // private class MergeUriValidator implements IValidator {
- //
- // @Override
- // public IStatus validate(Object value) {
- // String mergeUri = (String) value;
- // if (mergeUri == null
- // || mergeUri.length() == 0) {
- // return ValidationStatus
- // .warning("You have to provide a git uri to merge with");
- // }
- // GitUri gitUri = model.getKnownMergeUri(mergeUri);
- // if (gitUri == null) {
- // return ValidationStatus
- // .warning("You are not merging with an official example. Things may go
wrong");
- // }
- // if (!model.isCompatibleToApplicationCartridge(gitUri.getCartridge())) {
- // return ValidationStatus
- // .warning("The example you've chosen is not compatible to your
application");
- // }
- // return ValidationStatus.ok();
- // }
- // }
-
-}
Deleted:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java 2012-02-14
14:03:44 UTC (rev 38698)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java 2012-02-14
14:22:47 UTC (rev 38699)
@@ -1,275 +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.egit.ui.util.EGitUIUtils;
-import
org.jboss.tools.openshift.express.internal.ui.wizard.appimport.ImportProjectWizardModel;
-
-import com.openshift.express.client.IApplication;
-import com.openshift.express.client.ICartridge;
-import com.openshift.express.client.OpenShiftException;
-
-/**
- * @author Andr� Dietisheim
- * @author Rob Stryker
- * @author Xavier Coulon
- */
-@Deprecated
-public class AdapterWizardPageModel extends ObservableUIPojo {
-
- private static final String REMOTE_NAME_DEFAULT = "origin";
-
- public static final String PROPERTY_NEW_PROJECT = "newProject";
- public static final String PROPERTY_CLONE_URI = "cloneUri";
-// public static final String PROPERTY_MERGE_URI = "mergeUri";
- public static final String PROPERTY_PROJECT_NAME = "projectName";
- public static final String PROPERTY_APPLICATION_URL = "applicationUrl";
- public static final String PROPERTY_REPO_PATH = "repositoryPath";
- public static final String PROPERTY_REMOTE_NAME = "remoteName";
- public static final String PROPERTY_LOADING = "loading";
-
- public static final String CREATE_SERVER = "createServer";
- public static final String MODE = "serverMode";
- public static final String MODE_SOURCE = "serverModeSource";
- public static final String MODE_BINARY = "serverModeBinary";
- public static final String SERVER_TYPE = "serverType";
-
- private ImportProjectWizardModel wizardModel;
- private boolean loading;
-
- public AdapterWizardPageModel(ImportProjectWizardModel wizardModel) {
- this.wizardModel = wizardModel;
- setRemoteName(REMOTE_NAME_DEFAULT);
- setNewProject(true);
- }
-
- public void setNewProject(boolean newProject) {
- firePropertyChange(PROPERTY_NEW_PROJECT, wizardModel.isNewProject(),
wizardModel.setNewProject(newProject));
- }
-
- public boolean isNewProject() {
- return wizardModel.isNewProject();
- }
-
- public void setProjectName(String projectName) {
- firePropertyChange(PROPERTY_PROJECT_NAME, wizardModel.getProjectName(),
wizardModel.setProjectName(projectName));
- }
-
- public String getProjectName() {
- return wizardModel.getProjectName();
- }
-
-// public void setMergeUri(String mergeUri) {
-// firePropertyChange(PROPERTY_MERGE_URI, wizardModel.getMergeUri(),
wizardModel.setMergeUri(mergeUri));
-// }
-//
-// public String getMergeUri() {
-// return wizardModel.getMergeUri();
-// }
-
-// public GitUri getKnownMergeUri(String uriOrLabel) {
-// GitUri gitUri = null;
-// if (isGitUri(uriOrLabel)) {
-// gitUri = getKnownMergeUriByUri(uriOrLabel);
-// } else {
-// gitUri = getKnownMergeUriByLabel(uriOrLabel);
-// }
-// return gitUri;
-// }
-
-// private boolean isGitUri(String gitUriString) {
-// try {
-// URIish uriish = new URIish(gitUriString);
-// return uriish.isRemote();
-// } catch (URISyntaxException e) {
-// return false;
-// }
-// }
-
-// private GitUri getKnownMergeUriByUri(String gitUriString) {
-// GitUri matchingGitUri = null;
-// for (GitUri gitUri : getMergeUris()) {
-// if (gitUri.getGitUri().equals(gitUriString)) {
-// matchingGitUri = gitUri;
-// break;
-// }
-// }
-// return matchingGitUri;
-// }
-
-// private GitUri getKnownMergeUriByLabel(String label) {
-// GitUri matchingGitUri = null;
-// for (GitUri gitUri : getMergeUris()) {
-// if (gitUri.getLabel().equals(label)) {
-// matchingGitUri = gitUri;
-// break;
-// }
-// }
-// return matchingGitUri;
-// }
-
-// public List<GitUri> getMergeUris() {
-// ArrayList<GitUri> mergeUris = new ArrayList<GitUri>();
-// mergeUris.add(new GitUri(
-// "seambooking-example",
"git://github.com/openshift/seambooking-example.git",
-// ICartridge.JBOSSAS_7));
-// mergeUris.add(new GitUri(
-// "tweetstream-example",
"git://github.com/openshift/tweetstream-example.git",
-// ICartridge.JBOSSAS_7));
-// mergeUris.add(new GitUri(
-// "sinatra-example",
"git://github.com/openshift/sinatra-example.git",
-// new Cartridge("rack-1.1")));
-// mergeUris.add(new GitUri(
-// "sugarcrm-example",
"git://github.com/openshift/sugarcrm-example.git",
-// new Cartridge("php-5.3")));
-// return mergeUris;
-// }
-
- public void loadGitUri() throws OpenShiftException {
- setLoading(true);
- setCloneUri("Loading...");
- setCloneUri(getCloneUri());
- setLoading(false);
- }
-
- private void setCloneUri(String gitUri) {
- firePropertyChange(PROPERTY_CLONE_URI, null, gitUri);
- }
-
- public String getCloneUri() throws OpenShiftException {
- IApplication application = wizardModel.getApplication();
- if (application == null) {
- return null;
- }
- return application.getGitUri();
- }
-
- public void loadApplicationUrl() throws OpenShiftException {
- setLoading(true);
- setApplicationUrl("Loading...");
- setApplicationUrl(getApplicationUrl());
- setLoading(false);
- }
-
- public String getApplicationUrl() throws OpenShiftException {
- IApplication application = wizardModel.getApplication();
- if (application == null) {
- return null;
- }
- return application.getApplicationUrl();
- }
-
- public String getApplicationName() {
- IApplication application = wizardModel.getApplication();
- if (application == null) {
- return null;
- }
- return application.getName();
- }
-
- public boolean isJBossAS7Application() {
- IApplication application = wizardModel.getApplication();
- if (application == null) {
- return false;
- }
- return ICartridge.JBOSSAS_7.equals(application.getCartridge());
- }
-
- public void setApplicationUrl(String applicationUrl) {
- firePropertyChange(PROPERTY_APPLICATION_URL, null, applicationUrl);
- }
-
- public String getRepositoryPath() {
- return wizardModel.getRepositoryPath();
- }
-
- public void setRepositoryPath(String repositoryPath) {
- firePropertyChange(PROPERTY_REPO_PATH
- , wizardModel.getRepositoryPath()
- , wizardModel.setRepositoryPath(repositoryPath));
- }
-
- public void resetRepositoryPath() {
- setRepositoryPath(getDefaultRepositoryPath());
- }
-
- private String getDefaultRepositoryPath() {
- return EGitUIUtils.getEGitDefaultRepositoryPath();
- }
-
- public String getRemoteName() {
- return wizardModel.getRemoteName();
- }
-
- public void setRemoteName(String remoteName) {
- firePropertyChange(PROPERTY_REMOTE_NAME
- , wizardModel.getRemoteName()
- , wizardModel.setRemoteName(remoteName));
- }
-
- public void resetRemoteName() {
- setRemoteName(REMOTE_NAME_DEFAULT);
- }
-
- // TODO should this stay?
- public ImportProjectWizardModel getWizardModel() {
- return wizardModel;
- }
-
- public boolean isLoading() {
- return loading;
- }
-
- public void setLoading(boolean loading) {
- firePropertyChange(PROPERTY_LOADING, this.loading, this.loading = loading);
- }
-
- public boolean isCompatibleToApplicationCartridge(ICartridge cartridge) {
- IApplication application = wizardModel.getApplication();
- return application != null
- && application.getCartridge() != null
- && application.getCartridge().equals(cartridge);
- }
-
- public static class GitUri {
-
- private String label;
- private String gitUri;
- private ICartridge cartridge;
-
- private GitUri(String label, String gitUri, ICartridge cartridge) {
- this.label = label;
- this.gitUri = gitUri;
- this.cartridge = cartridge;
- }
-
- public String getLabel() {
- return label;
- }
-
- public String getGitUri() {
- return gitUri;
- }
-
- public String toString() {
- return getLabel();
- }
-
- public ICartridge getCartridge() {
- return cartridge;
- }
-
- public boolean isCompatible(ICartridge cartridge) {
- return this.cartridge.equals(cartridge);
- }
- }
-}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialogModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialogModel.java 2012-02-14
14:03:44 UTC (rev 38698)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialogModel.java 2012-02-14
14:22:47 UTC (rev 38699)
@@ -13,9 +13,7 @@
import java.util.Collections;
import java.util.List;
-import org.eclipse.debug.internal.ui.importexport.launchconfigurations.WizardMessages;
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
-import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
import com.openshift.express.client.IApplication;
Deleted:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionWizardPage.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionWizardPage.java 2012-02-14
14:03:44 UTC (rev 38698)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionWizardPage.java 2012-02-14
14:22:47 UTC (rev 38699)
@@ -1,329 +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.util.Collection;
-
-import org.eclipse.core.databinding.Binding;
-import org.eclipse.core.databinding.DataBindingContext;
-import org.eclipse.core.databinding.UpdateListStrategy;
-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.observable.value.IObservableValue;
-import org.eclipse.core.databinding.validation.IValidator;
-import org.eclipse.core.databinding.validation.MultiValidator;
-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.fieldassist.ControlDecorationSupport;
-import org.eclipse.jface.databinding.swt.ISWTObservableValue;
-import org.eclipse.jface.databinding.swt.WidgetProperties;
-import org.eclipse.jface.fieldassist.AutoCompleteField;
-import org.eclipse.jface.fieldassist.ControlDecoration;
-import org.eclipse.jface.fieldassist.FieldDecoration;
-import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
-import org.eclipse.jface.fieldassist.TextContentAdapter;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.viewers.TableViewer;
-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.events.SelectionListener;
-import org.eclipse.swt.widgets.Button;
-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.tools.common.ui.WizardUtils;
-import org.jboss.tools.common.ui.databinding.InvertingBooleanConverter;
-import org.jboss.tools.common.ui.databinding.ValueBindingBuilder;
-import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
-
-import com.openshift.express.client.Cartridge;
-import com.openshift.express.client.IApplication;
-import com.openshift.express.client.ICartridge;
-import com.openshift.express.client.NotFoundOpenShiftException;
-
-/**
- * @author Andre Dietisheim
- * @author Xavier Coulon
- */
-@Deprecated
-public class ApplicationSelectionWizardPage extends AbstractOpenShiftWizardPage {
-
- private TableViewer tableViewer;
- private final ApplicationSelectionWizardPageModel pageModel;
-
- private Text existingAppNameText = null;
-
- public ApplicationSelectionWizardPage(IWizard wizard, IOpenShiftWizardModel wizardModel)
{
- super("Application selection", "Click 'next' or select another
application to import.",
- "Application selection", wizard);
- this.pageModel = new ApplicationSelectionWizardPageModel(wizardModel);
- }
-
- @Override
- protected void doCreateControls(Composite container, DataBindingContext dbc) {
- GridLayoutFactory.fillDefaults().numColumns(2).applyTo(container);
- createExistingAppSelectionGroup(container, dbc);
- //createApplicationCreationGroup(container, dbc);
- }
-
- private Composite createExistingAppSelectionGroup(Composite container,
DataBindingContext dbc) {
- Composite existingAppSelectionGroup = new Composite(container, SWT.NONE);
- // projectGroup.setText("Project");
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).align(SWT.FILL,
SWT.CENTER).grab(true, false)
- .applyTo(existingAppSelectionGroup);
- GridLayoutFactory.fillDefaults().numColumns(3).margins(6,
6).applyTo(existingAppSelectionGroup);
-
- // existing app checkbox
- Button useExistingAppBtn = new Button(existingAppSelectionGroup, SWT.CHECK);
- useExistingAppBtn.setText("Use the existing application");
- useExistingAppBtn.setToolTipText("Select an existing application or uncheck to
create a new one.");
- useExistingAppBtn.setFocus();
- GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER).grab(false,
false)
- .applyTo(useExistingAppBtn);
- final IObservableValue useExistingAppObservable = BeanProperties.value(
- ApplicationSelectionWizardPageModel.PROPERTY_USE_EXISTING_APPLICATION).observe(pageModel);
- final ISWTObservableValue useExistingAppBtnSelection =
WidgetProperties.selection().observe(useExistingAppBtn);
- dbc.bindValue(useExistingAppBtnSelection, useExistingAppObservable);
-
- // existing project
- Label existingProjectLabel = new Label(existingAppSelectionGroup, SWT.NONE);
- existingProjectLabel.setText("Use the existing project");
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(false,
false).indent(10, 0)
- .applyTo(existingProjectLabel);
-
- existingAppNameText = new Text(existingAppSelectionGroup, SWT.BORDER);
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true,
false)
- .applyTo(existingAppNameText);
- final IObservableValue appNameModelObservable = BeanProperties.value(
- ApplicationSelectionWizardPageModel.PROPERTY_SELECTED_APPLICATION).observe(pageModel);
- final ISWTObservableValue existingAppNameTextObservable =
WidgetProperties.text(SWT.Modify).observe(
- existingAppNameText);
- ValueBindingBuilder.bind(existingAppNameTextObservable).to(appNameModelObservable).in(dbc);
- // disable the project name text when the model state is set to 'new project'
- ValueBindingBuilder.bind(WidgetProperties.enabled().observe(existingAppNameText))
- .notUpdating(useExistingAppObservable).converting(new
InvertingBooleanConverter()).in(dbc);
- // move focus to the project name text control when choosing the 'Use an existing
project' option.
- useExistingAppBtn.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- existingAppNameText.setFocus();
- existingAppNameText.selectAll();
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
- // let's provide content assist on the existing project name
- ControlDecoration dec = new ControlDecoration(existingAppNameText, SWT.TOP |
SWT.LEFT);
- FieldDecoration contentProposalFieldIndicator =
FieldDecorationRegistry.getDefault().getFieldDecoration(
- FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
- dec.setImage(contentProposalFieldIndicator.getImage());
- dec.setDescriptionText("Auto-completion is enabled when you start typing a project
name.");
- dec.setShowOnlyOnFocus(true);
-
- AutoCompleteField adapter = new AutoCompleteField(existingAppNameText, new
TextContentAdapter(),
- new String[] {});
-
- //adapter.setProposals(getOpenProjectsInWorkspace());
-
- Button browseAppsButton = new Button(existingAppSelectionGroup, SWT.NONE);
- browseAppsButton.setText("Browse");
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100,
SWT.DEFAULT).span(1, 1).grab(false, false)
- .applyTo(browseAppsButton);
- browseAppsButton.addSelectionListener(onBrowseApps());
- ValueBindingBuilder.bind(WidgetProperties.enabled().observe(browseAppsButton))
- .notUpdating(useExistingAppObservable).converting(new
InvertingBooleanConverter()).in(dbc);
-
- final IObservableValue existingProjectValidityObservable = BeanProperties.value(
- ProjectAndServerAdapterSettingsWizardPageModel.PROPERTY_EXISTING_PROJECT_VALIDITY).observe(pageModel);
- final UseExistingApplicationValidator existingProjectValidator = new
UseExistingApplicationValidator(
- existingProjectValidityObservable);
- dbc.addValidationStatusProvider(existingProjectValidator);
- ControlDecorationSupport.create(existingProjectValidator, SWT.LEFT | SWT.TOP);
-
- return existingAppSelectionGroup;
- }
-
- private SelectionListener onBrowseApps() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /**
- * Creates the SWT Group in which a table which will display the existing applications
with their corresponding
- * type. Before each application, a radio button will let the user choose which
application to import in his
- * workspace.
- *
- * @param container
- * @param dbc
- */
- private void createApplicationCreationGroup(Composite parent, DataBindingContext dbc) {
- GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).applyTo(parent);
-
- Label nameLabel = new Label(parent, SWT.NONE);
- nameLabel.setText("Na&me");
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(nameLabel);
- Text nameText = new Text(parent, SWT.BORDER);
- 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),
- BeanProperties.value(NewApplicationWizardPageModel.PROPERTY_NAME).observe(pageModel),
- new UpdateValueStrategy().setAfterGetValidator(new ApplicationNameValidator()),
null);
- ControlDecorationSupport.create(nameBinding, SWT.LEFT | SWT.TOP);
-
- Label cartridgeLabel = new Label(parent, SWT.WRAP);
- cartridgeLabel.setText("&Application Type");
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(cartridgeLabel);
- 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),
- BeanProperties.list(NewApplicationWizardPageModel.PROPERTY_CARTRIDGES).observe(pageModel),
- new UpdateListStrategy(UpdateListStrategy.POLICY_NEVER),
- new UpdateListStrategy().setConverter(new Converter(Object.class, String.class) {
-
- @Override
- public Object convert(Object fromObject) {
- if (!(fromObject instanceof ICartridge)) {
- return null;
- }
- return ((ICartridge) fromObject).getName();
- }
- }));
- Binding comboSelectionBinding =
dbc.bindValue(WidgetProperties.selection().observe(cartridgesCombo),
- BeanProperties.value(NewApplicationWizardPageModel.PROPERTY_SELECTED_CARTRIDGE).observe(pageModel),
- new UpdateValueStrategy().setConverter(new Converter(String.class, ICartridge.class)
{
-
- @Override
- public Object convert(Object fromObject) {
- if (fromObject instanceof String && ((String) fromObject).length() > 0)
{
- return new Cartridge(((String) fromObject));
- }
- return null;
- }
- }).setAfterGetValidator(new IValidator() {
-
- @Override
- public IStatus validate(Object value) {
- if (!(value instanceof String) || ((String) value).length() == 0) {
- return ValidationStatus.error("You have to select a type");
- } else {
- return ValidationStatus.ok();
- }
- }
- }), new UpdateValueStrategy().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);
-
- }
-
- private SelectionAdapter onRefresh(final DataBindingContext dbc) {
- return new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent event) {
- try {
- WizardUtils.runInWizard(new Job("Loading applications...") {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- return Status.OK_STATUS;
- }
-
- }, getContainer(), getDataBindingContext());
-
- } catch (Exception e) {
- // ignore
- }
- }
- };
- }
-
- @Override
- protected void onPageActivated(final DataBindingContext dbc) {
- try {
- WizardUtils.runInWizard(new Job("Loading applications...") {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- final Collection<IApplication> applications = pageModel.getApplications();
- return Status.OK_STATUS;
- } catch (NotFoundOpenShiftException e) {
- // no domain and therefore no applications present
- return Status.OK_STATUS;
- } catch (Exception e) {
- return new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID, "Could not
load applications",
- e);
- }
- }
-
- }, getContainer(), getDataBindingContext());
-
- } catch (Exception ex) {
- // ignore
- }
- }
-
- class UseExistingApplicationValidator extends MultiValidator {
-
- private final IObservableValue existingProjectValidityObservable;
-
- public UseExistingApplicationValidator(IObservableValue
existingProjectValidityObservable) {
- this.existingProjectValidityObservable = existingProjectValidityObservable;
- }
-
- @Override
- protected IStatus validate() {
- final IStatus existingProjectValidityStatus = (IStatus)
existingProjectValidityObservable.getValue();
-
- if (existingProjectValidityStatus != null) {
- final IStatus existingProjectValidity = pageModel.getExistingApplicationValidity();
- return existingProjectValidity;
- }
- return ValidationStatus.ok();
- }
-
- }
-
- private class ApplicationNameValidator implements IValidator {
-
- @Override
- public IStatus validate(Object value) {
- String name = (String) value;
- if (name.length() == 0) {
- return ValidationStatus.error("You have to provide a name");
- } else if (pageModel.hasApplication(name)) {
- return ValidationStatus.error(NLS.bind(
- "Names must be unique. You already have an application named
\"{0}\"", name));
- }
- return ValidationStatus.ok();
- }
- }
-
-}
Deleted:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionWizardPageModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionWizardPageModel.java 2012-02-14
14:03:44 UTC (rev 38698)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionWizardPageModel.java 2012-02-14
14:22:47 UTC (rev 38699)
@@ -1,87 +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.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
-import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
-
-import com.openshift.express.client.IApplication;
-import com.openshift.express.client.IUser;
-import com.openshift.express.client.OpenShiftException;
-
-/**
- * @author Andre Dietisheim
- * @author Xavier Coulon
- *
- */
-@Deprecated
-public class ApplicationSelectionWizardPageModel extends ObservableUIPojo {
-
- public static final String PROPERTY_USE_EXISTING_APPLICATION =
"useExistingApplication";
- public static final String PROPERTY_SELECTED_APPLICATION =
"selectedApplication";
-
- private boolean useExistingApplication = false;
- private IApplication selectedApplication;
- private IOpenShiftWizardModel wizardModel;
-
- public ApplicationSelectionWizardPageModel(IOpenShiftWizardModel wizardModel) {
- this.wizardModel = wizardModel;
- this.selectedApplication = wizardModel.getApplication();
- this.useExistingApplication = wizardModel.isExistingApplication();
- }
-
- public List<IApplication> getApplications() throws OpenShiftException {
- IUser user = getUser();
- if (user == null) {
- return Collections.emptyList();
- }
- return user.getApplications();
- }
-
- public IApplication getSelectedApplication() {
- return selectedApplication;
- }
-
- public void setSelectedApplication(IApplication application) {
- wizardModel.setApplication(application);
- firePropertyChange(PROPERTY_SELECTED_APPLICATION, this.selectedApplication,
this.selectedApplication = application);
- }
-
- public IUser getUser() {
-// return OpenShiftUIActivator.getDefault().getUser();
- return wizardModel.getUser();
- }
-
- public boolean getUseExistingApplication() {
- return this.useExistingApplication;
- }
-
- public void setUseExistingApplication(boolean useExistingApplication) {
- wizardModel.setUseExistingApplication(useExistingApplication);
- firePropertyChange(PROPERTY_USE_EXISTING_APPLICATION, this.useExistingApplication,
this.useExistingApplication = useExistingApplication);
-
- }
- public IStatus getExistingApplicationValidity() {
- // TODO Auto-generated method stub
- return Status.OK_STATUS;
- }
-
- public boolean hasApplication(String name) {
- // TODO Auto-generated method stub
- return false;
- }
-
-}
Deleted:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java 2012-02-14
14:03:44 UTC (rev 38698)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java 2012-02-14
14:22:47 UTC (rev 38699)
@@ -1,413 +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.util.ArrayList;
-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.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.Job;
-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;
-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.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.events.SelectionListener;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-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.jboss.tools.common.ui.WizardUtils;
-import org.jboss.tools.common.ui.databinding.DataBindingUtils;
-import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
-import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
-import
org.jboss.tools.openshift.express.internal.ui.wizard.appimport.ImportProjectWizardModel;
-
-import com.openshift.express.client.IApplication;
-import com.openshift.express.client.IDomain;
-import com.openshift.express.client.NotFoundOpenShiftException;
-import com.openshift.express.client.OpenShiftException;
-
-/**
- * @author André Dietisheim
- */
-public class ApplicationWizardPage extends AbstractOpenShiftWizardPage {
-
- private TableViewer viewer;
- private ApplicationWizardPageModel model;
- private ImportProjectWizardModel wizardModel;
-
- public ApplicationWizardPage(IWizard wizard, ImportProjectWizardModel wizardModel) {
- super("Application selection", "Please select an application to start
with or create a new one.",
- "Application selection", wizard);
- this.wizardModel = wizardModel;
- this.model = new ApplicationWizardPageModel(wizardModel);
- }
-
- @Override
- protected void doCreateControls(Composite container, DataBindingContext dbc) {
- GridLayoutFactory.fillDefaults().numColumns(3).applyTo(container);
-
- createDomainGroup(container, dbc);
- createApplicationsGroup(container, dbc);
- }
-
- 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(4).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).span(3, 1)
- .applyTo(applicationGroup);
- GridLayoutFactory.fillDefaults().numColumns(4).margins(6,
6).applyTo(applicationGroup);
-
- Composite tableContainer = new Composite(applicationGroup, SWT.NONE);
- this.viewer = createTable(tableContainer);
- GridDataFactory.fillDefaults().span(4, 1).align(SWT.FILL, SWT.FILL).grab(true,
true).applyTo(tableContainer);
- 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("Please select an application to start with, or create a new
one");
- }
- }
- }),
- null);
-
- Button newButton = new Button(applicationGroup, SWT.PUSH);
- newButton.setText("Ne&w");
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(80,
SWT.DEFAULT).applyTo(newButton);
- newButton.addSelectionListener(onNew(dbc));
-
- 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.OK, dbc,
selectedApplicationBinding);
- deleteButton.addSelectionListener(onDelete(dbc));
-
- Button embedButton = new Button(applicationGroup, SWT.PUSH);
- embedButton.setText("E&dit");
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(80,
SWT.DEFAULT).applyTo(embedButton);
- DataBindingUtils.bindEnablementToValidationStatus(embedButton, IStatus.OK, dbc,
selectedApplicationBinding);
- embedButton.addSelectionListener(onEmbed(dbc));
-
- Button detailsButton = new Button(applicationGroup, SWT.PUSH);
- detailsButton.setText("De&tails");
- 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(wizardModel.getUser()), getContainer().getShell()) == Dialog.OK)
{
- model.loadDomain();
- }
- }
-
- 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) {
- openDetailsDialog();
- }
- };
- }
-
- protected TableViewer createTable(Composite tableContainer) {
- Table table = new Table(tableContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL
| SWT.H_SCROLL);
- GridDataFactory.fillDefaults().grab(true, true).applyTo(table);
- table.setLinesVisible(true);
- table.setHeaderVisible(true);
- 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("Type", 1, new CellLabelProvider() {
-
- @Override
- public void update(ViewerCell cell) {
- IApplication application = (IApplication) cell.getElement();
- cell.setText(application.getCartridge().getName());
- }
- }, 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 {
- if (MessageDialog
- .openQuestion(
- getShell(),
- "Delete Application",
- NLS.bind(
- "This action will permanently remove the application and all of its data.
The data cannot be recovered. "
- + "Are you sure that you want to delete application '{0}'
?",
- model.getSelectedApplication().getName()))) {
- WizardUtils.runInWizard(
- new Job(NLS.bind("Deleting application \"{0}\"...",
- model.getSelectedApplication().getName())) {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- model.destroyCurrentApplication();
- final Collection<IApplication> applications = model.getApplications();
- setViewerInput(applications);
- return Status.OK_STATUS;
- } catch (OpenShiftException e) {
- return OpenShiftUIActivator.createErrorStatus(
- NLS.bind("Could not delete application \"{0}\"",
- model.getSelectedApplication().getName())
- , e);
- }
- }
- }, getContainer(), dbc);
- }
- } catch (Exception ex) {
- // ignore
- }
- }
- };
- }
-
- private SelectionAdapter onNew(DataBindingContext dbc) {
- return new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- Shell shell = getContainer().getShell();
- NewApplicationWizard applicationDialog = new NewApplicationWizard(model.getUser());
- if (WizardUtils.openWizardDialog(applicationDialog, shell) == Dialog.OK) {
- try {
- final Collection<IApplication> applications = model.getApplications();
- setViewerInput(applications);
- model.setSelectedApplication(applicationDialog.getApplication());
- } catch (OpenShiftException ex) {
- Logger.error(NLS.bind("Could not delete application \"{0}\"",
- model.getSelectedApplication().getName()), ex);
- }
- }
- }
- };
- }
-
- private SelectionAdapter onEmbed(final DataBindingContext dbc) {
- return new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- WizardUtils.openWizardDialog(
- new EmbedCartridgeWizard(model.getSelectedApplication(), model.getUser()),
getShell());
- try {
- final Collection<IApplication> applications = model.getApplications();
- setViewerInput(applications);
- } catch (OpenShiftException ex) {
- Logger.error(NLS.bind("Could not load the availabel applications", ex));
- }
- }
- };
- }
-
- private SelectionAdapter onDetails(DataBindingContext dbc) {
- return new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- openDetailsDialog();
- }
- };
- }
-
- private void openDetailsDialog() {
- new ApplicationDetailsDialog(model.getSelectedApplication(), getShell()).open();
- }
-
- @Override
- protected void onPageActivated(final DataBindingContext dbc) {
- try {
- WizardUtils.runInWizard(new Job("Loading applications...") {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- model.loadDomain();
- final Collection<IApplication> applications = model.getApplications();
- setViewerInput(applications);
- return Status.OK_STATUS;
- } catch (NotFoundOpenShiftException e) {
- // no domain and therefore no applications present
- clearViewer();
- return Status.OK_STATUS;
- } catch (Exception e) {
- clearViewer();
- return new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID,
- "Could not load applications", e);
- }
- }
-
- }, getContainer(), getDataBindingContext());
-
- } catch (Exception ex) {
- // ignore
- }
- }
-
- private void clearViewer() {
- Logger.debug("Clearing applications list in viewer");
- setViewerInput(new ArrayList<IApplication>());
- }
-
- private void setViewerInput(final Collection<IApplication> applications) {
- getShell().getDisplay().syncExec(new Runnable() {
-
- @Override
- public void run() {
- Logger.debug("Setting {} application(s) in the viewer",
applications.size());
- viewer.setInput(applications);
- }
- });
- }
-}
Deleted:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPageModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPageModel.java 2012-02-14
14:03:44 UTC (rev 38698)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPageModel.java 2012-02-14
14:22:47 UTC (rev 38699)
@@ -1,109 +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.util.Collections;
-import java.util.List;
-
-import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
-import
org.jboss.tools.openshift.express.internal.ui.wizard.appimport.ImportProjectWizardModel;
-
-import com.openshift.express.client.IApplication;
-import com.openshift.express.client.IDomain;
-import com.openshift.express.client.IUser;
-import com.openshift.express.client.OpenShiftException;
-
-/**
- * @author André Dietisheim
- *
- */
-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 ImportProjectWizardModel wizardModel;
-
- public ApplicationWizardPageModel(ImportProjectWizardModel wizardModel) {
- 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 loadDomain() throws OpenShiftException {
- setDomain(getUser().getDomain());
- }
-
- public List<IApplication> getApplications() throws OpenShiftException {
- IUser user = getUser();
- if (user == null) {
- return Collections.emptyList();
- }
- return user.getApplications();
- }
-
- public IApplication getSelectedApplication() {
- return selectedApplication;
- }
-
- public void setSelectedApplication(IApplication application) {
- wizardModel.setApplication(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();
- }
-
-}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EditDomainWizardPage.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EditDomainWizardPage.java 2012-02-14
14:03:44 UTC (rev 38698)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EditDomainWizardPage.java 2012-02-14
14:22:47 UTC (rev 38699)
@@ -48,7 +48,7 @@
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);
- DataBindingUtils.bindMandatoryTextField(namespaceText, "Domain",
ApplicationWizardPageModel.PROPERTY_NAMESPACE,
+ DataBindingUtils.bindMandatoryTextField(namespaceText, "Domain",
EditDomainWizardPageModel.PROPERTY_NAMESPACE,
model, dbc);
}
Deleted:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizard.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizard.java 2012-02-14
14:03:44 UTC (rev 38698)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizard.java 2012-02-14
14:22:47 UTC (rev 38699)
@@ -1,203 +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.appimport;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URISyntaxException;
-
-import org.eclipse.core.resources.WorkspaceJob;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jgit.api.errors.JGitInternalException;
-import org.eclipse.jgit.errors.TransportException;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.jboss.tools.common.ui.DelegatingProgressMonitor;
-import org.jboss.tools.common.ui.JobUtils;
-import org.jboss.tools.common.ui.WizardUtils;
-import org.jboss.tools.openshift.express.internal.ui.ImportFailedException;
-import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
-import org.jboss.tools.openshift.express.internal.ui.WontOverwriteException;
-import org.jboss.tools.openshift.express.internal.ui.wizard.AdapterWizardPage;
-import org.jboss.tools.openshift.express.internal.ui.wizard.ApplicationWizardPage;
-import
org.jboss.tools.openshift.express.internal.ui.wizard.OpenShiftExpressApplicationWizard;
-
-import com.openshift.express.client.OpenShiftException;
-
-/**
- * @author André Dietisheim
- * @Deprecated: see {@link OpenShiftExpressApplicationWizard}
- */
-@Deprecated
-public class ImportProjectWizard extends Wizard implements INewWizard {
-
- private ImportProjectWizardModel model;
-
- public ImportProjectWizard() {
- }
-
- @Override
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- setWindowTitle("OpenShift application wizard");
- setNeedsProgressMonitor(true);
- }
-
- @Override
- public boolean performFinish() {
- try {
- final DelegatingProgressMonitor delegatingMonitor = new DelegatingProgressMonitor();
- IStatus jobResult = WizardUtils.runInWizard(
- new ImportJob(delegatingMonitor),
- delegatingMonitor, getContainer());
- return JobUtils.isOk(jobResult);
- } catch (Exception e) {
- ErrorDialog.openError(getShell(), "Error", "Could not create local git
repository.",
- new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID,
- "An exception occurred while creating local git repository.", e));
- return false;
- }
- }
-
- private boolean askForConfirmation(final String message, final String applicationName)
{
- final boolean[] confirmed = new boolean[1];
- getShell().getDisplay().syncExec(new Runnable() {
-
- @Override
- public void run() {
- confirmed[0] = MessageDialog.openConfirm(
- getShell(),
- NLS.bind("Import OpenShift Application ", applicationName),
- message);
- }
- });
- return confirmed[0];
- }
-
- @Override
- public void addPages() {
- this.model = new ImportProjectWizardModel();
- //addPage(new CredentialsWizardPage(this, model));
- addPage(new ApplicationWizardPage(this, model));
- addPage(new AdapterWizardPage(this, model));
- }
-
- private boolean isTransportException(InvocationTargetException e) {
- return e.getTargetException() instanceof JGitInternalException
- && e.getTargetException().getCause() instanceof TransportException;
- }
-
- private TransportException getTransportException(InvocationTargetException e) {
- if (isTransportException(e)) {
- return (TransportException) ((JGitInternalException)
e.getTargetException()).getCause();
- }
- return null;
- }
-
- /**
- * A workspace job that will create a new project or enable the selected
- * project to be used with OpenShift.
- */
- private class ImportJob extends WorkspaceJob {
-
- private DelegatingProgressMonitor delegatingMonitor;
-
- public ImportJob(DelegatingProgressMonitor delegatingMonitor) {
- super("Importing project to workspace...");
- this.delegatingMonitor = delegatingMonitor;
- }
-
- @Override
- public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
- try {
- delegatingMonitor.add(monitor);
-
- if (model.isNewProject()) {
- model.importProject(delegatingMonitor);
- } else if (!model.isGitSharedProject()) {
- if (!askForConfirmation(
- NLS.bind("OpenShift application {0} will be enabled on project {1} by "
+
- "copying OpenShift configuration and enabling Git for the project.\n "
+
- "This cannot be undone. Do you wish to continue ?",
- model.getApplicationName(), model.getProjectName()),
- model.getApplicationName())) {
- return Status.CANCEL_STATUS;
- }
- model.configureUnsharedProject(delegatingMonitor);
- } else {
- if (!askForConfirmation(
- NLS.bind("OpenShift application {0} will be enabled on project {1} by copying
OpenShift " +
- "configuration and adding the OpenShift git repo as remote.\n " +
- "This cannot be undone. Do you wish to continue ?",
- model.getApplicationName(), model.getProjectName()),
- model.getApplicationName())) {
- return Status.CANCEL_STATUS;
- }
- model.configureGitSharedProject(delegatingMonitor);
- }
-
- return Status.OK_STATUS;
- } catch (final WontOverwriteException e) {
- openError("Project already present", e.getMessage());
- return Status.CANCEL_STATUS;
- } catch (final ImportFailedException e) {
- return OpenShiftUIActivator.createErrorStatus(
- "Could not import maven project {0}.", e,
- model.getProjectName());
- } catch (IOException e) {
- return OpenShiftUIActivator.createErrorStatus(
- "Could not copy openshift configuration files to project {0}", e,
- model.getProjectName());
- } catch (OpenShiftException e) {
- return OpenShiftUIActivator.createErrorStatus(
- "Could not import project to the workspace.", e);
- } catch (URISyntaxException e) {
- return OpenShiftUIActivator.createErrorStatus(
- "The url of the remote git repository is not valid", e);
- } catch (InvocationTargetException e) {
- if (isTransportException(e)) {
- TransportException te = getTransportException(e);
- return OpenShiftUIActivator
- .createErrorStatus(
- "Could not clone the repository. Authentication failed.\n"
- + " Please make sure that you added your private key to the ssh
preferences.",
- te);
- } else {
- return OpenShiftUIActivator.createErrorStatus(
- "An exception occurred while creating local git repository.", e);
- }
- } catch (Exception e) {
- return OpenShiftUIActivator.createErrorStatus(
- "Could not import project to the workspace.", e);
- } finally {
- delegatingMonitor.done();
- }
- }
- }
-
- private void openError(final String title, final String message) {
- getShell().getDisplay().syncExec(new Runnable() {
-
- @Override
- public void run() {
- MessageDialog.openError(getShell(), title, message);
- }
- });
- }
-
-}
Deleted:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizardModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizardModel.java 2012-02-14
14:03:44 UTC (rev 38698)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizardModel.java 2012-02-14
14:22:47 UTC (rev 38699)
@@ -1,292 +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.appimport;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.IServerType;
-import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
-import org.jboss.tools.openshift.egit.core.EGitUtils;
-import org.jboss.tools.openshift.express.internal.ui.wizard.AdapterWizardPageModel;
-import
org.jboss.tools.openshift.express.internal.ui.wizard.OpenShiftExpressApplicationWizardModel;
-
-import com.openshift.express.client.IApplication;
-import com.openshift.express.client.ICartridge;
-import com.openshift.express.client.IUser;
-import com.openshift.express.client.OpenShiftException;
-
-/**
- * @author André Dietisheim <adietish(a)redhat.com>
- * @Deprecated: see {@link OpenShiftExpressApplicationWizardModel}
- */
-@Deprecated
-public class ImportProjectWizardModel extends ObservableUIPojo {
-
- private HashMap<String, Object> dataModel = new HashMap<String, Object>();
-
- public static final String NEW_PROJECT = "enableProject";
- public static final String USER = "user";
- public static final String APPLICATION = "application";
- public static final String REMOTE_NAME = "remoteName";
- public static final String REPOSITORY_PATH = "repositoryPath";
- public static final String PROJECT_NAME = "projectName";
- public static final String MERGE_URI = "mergeUri";
- public static final String RUNTIME_DELEGATE = "runtimeDelegate";
- public static final String CREATE_SERVER = "createServer";
-
- public ImportProjectWizardModel() {
- dataModel.put(NEW_PROJECT, false);
- }
-
- /**
- * Imports the project that the user has chosen into the workspace.
- *
- * @param monitor
- * the monitor to report progress to
- * @throws OpenShiftException
- * @throws CoreException
- * @throws InterruptedException
- * @throws URISyntaxException
- * @throws InvocationTargetException
- * @throws IOException
- */
- public void importProject(IProgressMonitor monitor) throws OpenShiftException,
CoreException, InterruptedException,
- URISyntaxException, InvocationTargetException, IOException {
- List<IProject> importedProjects = new ImportNewProject(getProjectName()
- , getApplication()
- , getRemoteName()
- , getRepositoryFile())
- .execute(monitor);
- createServerAdapter(monitor, importedProjects);
- }
-
- /**
- * Enables the user chosen, unshared project to be used on the chosen
- * OpenShift application. Clones the application git repository, copies the
- * configuration files to the user project (in the workspace), shares the
- * user project with git and creates the server adapter.
- *
- * @param monitor
- * the monitor to report progress to
- * @throws URISyntaxException
- * The OpenShift application repository could not be cloned,
- * because the uri it is located at is not a valid git uri
- * @throws OpenShiftException
- *
- * @throws InvocationTargetException
- * The OpenShift application repository could not be cloned, the
- * clone operation failed.
- * @throws InterruptedException
- * The OpenShift application repository could not be cloned, the
- * clone operation was interrupted.
- * @throws IOException
- * The configuration files could not be copied from the git
- * clone to the user project
- * @throws CoreException
- * The user project could not be shared with the git
- */
- public void configureUnsharedProject(IProgressMonitor monitor)
- throws OpenShiftException, InvocationTargetException, InterruptedException,
IOException, CoreException,
- URISyntaxException {
- List<IProject> importedProjects = new ConfigureUnsharedProject(
- getProjectName()
- , getApplication()
- , getRemoteName()
- , getUser())
- .execute(monitor);
- createServerAdapter(monitor, importedProjects);
- }
-
- /**
- * Enables the user chosen, unshared project to be used on the chosen
- * OpenShift application. Clones the application git repository, copies the
- * configuration files to the user project (in the workspace), adds the
- * appication git repo as remote and creates the server adapter.
- *
- * @param monitor
- * the monitor to report progress to
- * @throws URISyntaxException
- * The OpenShift application repository could not be cloned,
- * because the uri it is located at is not a valid git uri
- * @throws OpenShiftException
- *
- * @throws InvocationTargetException
- * The OpenShift application repository could not be cloned, the
- * clone operation failed.
- * @throws InterruptedException
- * The OpenShift application repository could not be cloned, the
- * clone operation was interrupted.
- * @throws IOException
- * The configuration files could not be copied from the git
- * clone to the user project
- * @throws CoreException
- * The user project could not be shared with the git
- */
- public void configureGitSharedProject(IProgressMonitor monitor)
- throws OpenShiftException, InvocationTargetException, InterruptedException,
IOException, CoreException,
- URISyntaxException {
- List<IProject> importedProjects = new ConfigureGitSharedProject(
- getProjectName()
- , getApplication()
- , getRemoteName()
- , getUser())
- .execute(monitor);
- createServerAdapter(monitor, importedProjects);
- }
-
- private void createServerAdapter(IProgressMonitor monitor, List<IProject>
importedProjects)
- throws OpenShiftException {
- Assert.isTrue(importedProjects.size() > 0);
- IProject project = importedProjects.get(0);
- //new ServerAdapterFactory().create(project, this, monitor);
- }
-
- public File getRepositoryFile() {
- String repositoryPath = getRepositoryPath();
- if (repositoryPath == null
- || repositoryPath.length() == 0) {
- return null;
- }
- return new File(repositoryPath, getApplicationName());
- }
-
- public Object setProperty(String key, Object value) {
- Object oldVal = dataModel.get(key);
- dataModel.put(key, value);
- firePropertyChange(key, oldVal, value);
- return value;
- }
-
- public Object getProperty(String key) {
- return dataModel.get(key);
- }
-
- public void setUser(IUser user) {
- setProperty(USER, user);
- }
-
- public IUser getUser() {
- return (IUser) getProperty(USER);
- }
-
- public IApplication getApplication() {
- return (IApplication) getProperty(APPLICATION);
- }
-
- public String getApplicationName() {
- String applicationName = null;
- IApplication application = getApplication();
- if (application != null) {
- applicationName = application.getName();
- }
- return applicationName;
- }
-
- public ICartridge getApplicationCartridge() {
- ICartridge cartridge = null;
- IApplication application = getApplication();
- if (application != null) {
- cartridge = application.getCartridge();
- }
- return cartridge;
- }
-
- public String getApplicationCartridgeName() {
- String cartridgeName = null;
- ICartridge cartridge = getApplicationCartridge();
- if (cartridge != null) {
- cartridgeName = cartridge.getName();
- }
- return cartridgeName;
- }
-
- public void setApplication(IApplication application) {
- setProperty(APPLICATION, application);
- }
-
- public String setRemoteName(String remoteName) {
- setProperty(REMOTE_NAME, remoteName);
- return remoteName;
- }
-
- public String getRemoteName() {
- return (String) getProperty(REMOTE_NAME);
- }
-
- public String setRepositoryPath(String repositoryPath) {
- return (String) setProperty(REPOSITORY_PATH, repositoryPath);
- }
-
- public String getRepositoryPath() {
- return (String) getProperty(REPOSITORY_PATH);
- }
-
- public boolean isNewProject() {
- return (Boolean) getProperty(NEW_PROJECT);
- }
-
- public boolean isGitSharedProject() {
- return EGitUtils.isSharedWithGit(getProject());
- }
-
- private IProject getProject() {
- return ResourcesPlugin.getWorkspace().getRoot().getProject(getProjectName());
- }
-
- public Boolean setNewProject(boolean newProject) {
- return (Boolean) setProperty(NEW_PROJECT, newProject);
- }
-
- public String setProjectName(String projectName) {
- return (String) setProperty(PROJECT_NAME, projectName);
- }
-
- public String getProjectName() {
- return (String) getProperty(PROJECT_NAME);
- }
-
- public String setMergeUri(String mergeUri) {
- return (String) setProperty(MERGE_URI, mergeUri);
- }
-
- public String getMergeUri() {
- return (String) getProperty(MERGE_URI);
- }
-
- public IServerType getServerType() {
- return (IServerType) getProperty(AdapterWizardPageModel.SERVER_TYPE);
- }
-
- public IRuntime getRuntime() {
- return (IRuntime) getProperty(RUNTIME_DELEGATE);
- }
-
- public String getMode() {
- return (String) getProperty(AdapterWizardPageModel.MODE);
- }
-
- public boolean isCreateServer() {
- Boolean isCreateServer = (Boolean) getProperty(CREATE_SERVER);
- return isCreateServer != null
- && isCreateServer.booleanValue();
- }
-}