Author: adietish
Date: 2011-10-05 07:03:07 -0400 (Wed, 05 Oct 2011)
New Revision: 35356
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/.classpath
trunk/as/plugins/org.jboss.tools.openshift.express.ui/.project
trunk/as/plugins/org.jboss.tools.openshift.express.ui/.settings/
trunk/as/plugins/org.jboss.tools.openshift.express.ui/.settings/org.eclipse.jdt.core.prefs
trunk/as/plugins/org.jboss.tools.openshift.express.ui/META-INF/
trunk/as/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.tools.openshift.express.ui/build.properties
trunk/as/plugins/org.jboss.tools.openshift.express.ui/icons/
trunk/as/plugins/org.jboss.tools.openshift.express.ui/icons/openshift-logo-dark-icon.png
trunk/as/plugins/org.jboss.tools.openshift.express.ui/icons/openshift-logo-dark.png
trunk/as/plugins/org.jboss.tools.openshift.express.ui/icons/openshift-logo-white-icon.png
trunk/as/plugins/org.jboss.tools.openshift.express.ui/icons/openshift-logo-white-medium.png
trunk/as/plugins/org.jboss.tools.openshift.express.ui/icons/openshift-logo-white.png
trunk/as/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
trunk/as/plugins/org.jboss.tools.openshift.express.ui/pom.xml
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenshiftImages.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenshiftUIActivator.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/common/
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/common/ImageRepository.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractOpenshiftWizardPage.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractSkippingWizard.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPageModel.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ISkipableWizardPage.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationDialog.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPage.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPageModel.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ServerAdapterWizard.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ServerAdapterWizardModel.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/TrimTrailingSlashConverter.java
Log:
[JBIDE-9841] renamed org.jboss.ide.eclipse.as.openshift.ui to
org.jboss.tools.openshift.express.ui
Added: trunk/as/plugins/org.jboss.tools.openshift.express.ui/.classpath
===================================================================
--- trunk/as/plugins/org.jboss.tools.openshift.express.ui/.classpath
(rev 0)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/.classpath 2011-10-05 11:03:07
UTC (rev 35356)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: trunk/as/plugins/org.jboss.tools.openshift.express.ui/.classpath
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/as/plugins/org.jboss.tools.openshift.express.ui/.project
===================================================================
--- trunk/as/plugins/org.jboss.tools.openshift.express.ui/.project
(rev 0)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/.project 2011-10-05 11:03:07 UTC
(rev 35356)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.openshift.express.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on: trunk/as/plugins/org.jboss.tools.openshift.express.ui/.project
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/.settings/org.eclipse.jdt.core.prefs 2011-10-05
11:03:07 UTC (rev 35356)
@@ -0,0 +1,8 @@
+#Wed Sep 14 11:53:06 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/as/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF 2011-10-05
11:03:07 UTC (rev 35356)
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Openshift UI
+Bundle-SymbolicName: org.jboss.tools.openshift.express.ui;singleton:=true
+Bundle-Version: 2.3.0.qualifier
+Bundle-Activator: org.jboss.tools.openshift.express.internal.ui.OpenshiftUIActivator
+Require-Bundle:
org.jboss.tools.openshift.express.client;bundle-version="2.3.0",
+ org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.databinding;bundle-version="1.4.0",
+ org.eclipse.core.databinding.beans;bundle-version="1.2.100",
+ org.eclipse.core.databinding.observable;bundle-version="1.4.0",
+ org.eclipse.core.databinding.property;bundle-version="1.4.0",
+ org.eclipse.jface.databinding;bundle-version="1.5.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.jboss.tools.common.databinding,
+ org.jboss.tools.common.ui,
+ org.jboss.tools.common.ui.databinding,
+ org.jboss.tools.common.ui.preferencevalue
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/as/plugins/org.jboss.tools.openshift.express.ui/build.properties
===================================================================
--- trunk/as/plugins/org.jboss.tools.openshift.express.ui/build.properties
(rev 0)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/build.properties 2011-10-05
11:03:07 UTC (rev 35356)
@@ -0,0 +1,11 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
+src.includes = .classpath,\
+ .project,\
+ META-INF/,\
+ build.properties,\
+ plugin.xml,\
+ pom.xml
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/build.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/icons/openshift-logo-dark-icon.png
===================================================================
(Binary files differ)
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/icons/openshift-logo-dark-icon.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/icons/openshift-logo-dark.png
===================================================================
(Binary files differ)
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/icons/openshift-logo-dark.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/icons/openshift-logo-white-icon.png
===================================================================
(Binary files differ)
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/icons/openshift-logo-white-icon.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/icons/openshift-logo-white-medium.png
===================================================================
(Binary files differ)
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/icons/openshift-logo-white-medium.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/icons/openshift-logo-white.png
===================================================================
(Binary files differ)
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/icons/openshift-logo-white.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/as/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
(rev 0)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2011-10-05 11:03:07
UTC (rev 35356)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <category
+ id="org.jboss.ide.eclipse.as.openshift.express.ui.wizard.category"
+ name="Openshift Express">
+ </category>
+ <wizard
+
category="org.jboss.ide.eclipse.as.openshift.express.ui.wizard.category"
+
class="org.jboss.tools.openshift.express.internal.ui.wizard.ServerAdapterWizard"
+ icon="icons/openshift-logo-white-icon.png"
+
id="org.jboss.ide.eclipse.as.openshift.express.ui.wizard.NewServerAdapter"
+ name="New Server Adapter">
+ </wizard>
+ </extension>
+</plugin>
Property changes on: trunk/as/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/as/plugins/org.jboss.tools.openshift.express.ui/pom.xml
===================================================================
--- trunk/as/plugins/org.jboss.tools.openshift.express.ui/pom.xml
(rev 0)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/pom.xml 2011-10-05 11:03:07 UTC
(rev 35356)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.jboss.tools.as</groupId>
+ <artifactId>plugins</artifactId>
+ <version>2.3.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.jboss.tools.as.plugins</groupId>
+ <artifactId>org.jboss.tools.openshift.express.ui</artifactId>
+ <packaging>eclipse-plugin</packaging>
+</project>
Property changes on: trunk/as/plugins/org.jboss.tools.openshift.express.ui/pom.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenshiftImages.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenshiftImages.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenshiftImages.java 2011-10-05
11:03:07 UTC (rev 35356)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.jboss.tools.openshift.express.internal.ui.common.ImageRepository;
+
+public class OpenshiftImages {
+
+ private static final String ICONS_FOLDER = "icons/";
+
+ private static final ImageRepository repo =
+ new ImageRepository(ICONS_FOLDER, OpenshiftUIActivator.getDefault(),
OpenshiftUIActivator.getDefault().getImageRegistry());
+
+ public static final ImageDescriptor OPENSHIFT_LOGO_DARK =
repo.create("openshift-logo-dark.png"); //$NON-NLS-1$
+ public static final ImageDescriptor OPENSHIFT_LOGO_WHITE =
repo.create("openshift-logo-white.png"); //$NON-NLS-1$
+ public static final ImageDescriptor OPENSHIFT_LOGO_WHITE_MEDIUM =
repo.create("openshift-logo-white-medium.png"); //$NON-NLS-1$
+}
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenshiftImages.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenshiftUIActivator.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenshiftUIActivator.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenshiftUIActivator.java 2011-10-05
11:03:07 UTC (rev 35356)
@@ -0,0 +1,60 @@
+package org.jboss.tools.openshift.express.internal.ui;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class OpenshiftUIActivator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID =
"org.jboss.ide.eclipse.as.openshift.ui"; //$NON-NLS-1$
+
+ // The shared instance
+ private static OpenshiftUIActivator plugin;
+
+ /**
+ * The constructor
+ */
+ public OpenshiftUIActivator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static OpenshiftUIActivator getDefault() {
+ return plugin;
+ }
+
+ public static void log(IStatus status) {
+ plugin.getLog().log(status);
+ }
+
+ public static void log(Throwable e) {
+ log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, e.getMessage(), e));
+ }
+
+}
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenshiftUIActivator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/common/ImageRepository.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/common/ImageRepository.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/common/ImageRepository.java 2011-10-05
11:03:07 UTC (rev 35356)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.common;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.osgi.util.NLS;
+import org.jboss.tools.openshift.express.internal.ui.OpenshiftUIActivator;
+
+public class ImageRepository {
+
+ private ImageRegistry imageRegistry;
+ private URL baseUrl;
+ private Plugin plugin;
+ private String imageFolder;
+
+ public ImageRepository(String imageFolder, Plugin plugin, ImageRegistry imageRegistry)
{
+ this.imageFolder = imageFolder;
+ this.plugin = plugin;
+ this.imageRegistry = imageRegistry;
+ }
+
+ protected URL getBaseUrl() {
+ try {
+ if (baseUrl == null) {
+ this.baseUrl = new URL(plugin.getBundle().getEntry("/"), imageFolder);
+ }
+ return baseUrl;
+ } catch (MalformedURLException e) {
+ OpenshiftUIActivator.log(e);
+ return null;
+ }
+ }
+
+ public ImageDescriptor create(String name) {
+ return create(imageRegistry, name);
+ }
+
+ private ImageDescriptor create(ImageRegistry registry,String name) {
+ return create(registry, name, getBaseUrl());
+ }
+
+ private ImageDescriptor create(ImageRegistry registry, String name, URL baseUrl) {
+ if (baseUrl == null) {
+ return null;
+ }
+
+ ImageDescriptor imageDescriptor =
+ ImageDescriptor.createFromURL(createFileURL(name, baseUrl));
+ registry.put(name, imageDescriptor);
+ return imageDescriptor;
+ }
+
+ private URL createFileURL(String name, URL baseUrl) {
+ try {
+ return new URL(baseUrl, name);
+ } catch (MalformedURLException e) {
+ plugin.getLog().log(
+ new Status(IStatus.ERROR, plugin.getBundle().getSymbolicName(), NLS.bind(
+ "Could not create URL for image {0}", name), e));
+ return null;
+ }
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/common/ImageRepository.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractOpenshiftWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractOpenshiftWizardPage.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractOpenshiftWizardPage.java 2011-10-05
11:03:07 UTC (rev 35356)
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.wizard;
+
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.IPageChangedListener;
+import org.eclipse.jface.dialogs.PageChangedEvent;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardContainer;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.common.ui.databinding.ParametrizableWizardPageSupport;
+import org.jboss.tools.openshift.express.internal.ui.OpenshiftImages;
+
+/**
+ * @author André Dietisheim
+ */
+public abstract class AbstractOpenshiftWizardPage extends WizardPage {
+
+ private DataBindingContext dbc;
+
+ protected AbstractOpenshiftWizardPage(String title, String description, String pageName,
IWizard wizard) {
+ super(pageName);
+ setWizard(wizard);
+ setTitle(title);
+ setDescription(description);
+ setImageDescriptor(OpenshiftImages.OPENSHIFT_LOGO_WHITE_MEDIUM);
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ this.dbc = new DataBindingContext();
+ ParametrizableWizardPageSupport.create(
+ IStatus.ERROR | IStatus.INFO | IStatus.WARNING | IStatus.CANCEL, this,
+ dbc);
+ Composite container = new Composite(parent, SWT.NONE);
+ setControl(container);
+ initPageChangedListener();
+
+ // container.addListener(SWT.Show, new Listener() {
+ // @Override
+ // public void handleEvent(Event event) {
+ // onPageVisible(dbc);
+ // }
+ // });
+ doCreateControls(container, dbc);
+ }
+
+ protected void initPageChangedListener() {
+ IWizardContainer wizardContainer = getContainer();
+ if (wizardContainer instanceof WizardDialog) {
+ ((WizardDialog) getContainer()).addPageChangedListener(new IPageChangedListener() {
+
+ @Override
+ public void pageChanged(PageChangedEvent event) {
+ if (event.getSelectedPage() == AbstractOpenshiftWizardPage.this) {
+ onPageActivated(dbc);
+ }
+ }
+ });
+ }
+ }
+
+ protected DataBindingContext getDatabindingContext() {
+ return dbc;
+ }
+
+ protected void onPageActivated(DataBindingContext dbc) {
+ }
+
+ protected abstract void doCreateControls(Composite parent, DataBindingContext dbc);
+}
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractOpenshiftWizardPage.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractSkippingWizard.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractSkippingWizard.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractSkippingWizard.java 2011-10-05
11:03:07 UTC (rev 35356)
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.wizard;
+
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+
+/**
+ * @author André Dietisheim
+ */
+public abstract class AbstractSkippingWizard extends Wizard implements INewWizard {
+
+ @Override
+ public IWizardPage getNextPage(IWizardPage page) {
+ IWizardPage nextPage = null;
+ while ((nextPage = super.getNextPage(page)) != null) {
+ if (ISkipableWizardPage.class.isAssignableFrom(nextPage.getClass())
+ && ((ISkipableWizardPage) nextPage).isSkip()) {
+ page = nextPage;
+ continue;
+ } else {
+ break;
+ }
+ }
+ return nextPage;
+ }
+
+ @Override
+ public IWizardPage getPreviousPage(IWizardPage page) {
+ IWizardPage previousPage = null;
+ while ((previousPage = super.getPreviousPage(page)) != null) {
+ if (ISkipableWizardPage.class.isAssignableFrom(previousPage.getClass())
+ && ((ISkipableWizardPage) previousPage).isSkip()) {
+ page = previousPage;
+ continue;
+ } else {
+ break;
+ }
+ }
+ return previousPage;
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractSkippingWizard.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java 2011-10-05
11:03:07 UTC (rev 35356)
@@ -0,0 +1,266 @@
+/*******************************************************************************
+ * 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.UpdateValueStrategy;
+import org.eclipse.core.databinding.beans.BeanProperties;
+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.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.tools.common.ui.BrowserUtil;
+import org.jboss.tools.common.ui.WizardUtils;
+import org.jboss.tools.common.ui.databinding.DataBindingUtils;
+import org.jboss.tools.openshift.express.client.IApplication;
+import org.jboss.tools.openshift.express.client.OpenshiftException;
+import org.jboss.tools.openshift.express.internal.ui.OpenshiftUIActivator;
+
+/**
+ * @author André Dietisheim
+ */
+public class ApplicationWizardPage extends AbstractOpenshiftWizardPage {
+
+ private TableViewer viewer;
+ private ApplicationWizardPageModel model;
+
+ protected ApplicationWizardPage(IWizard wizard, ServerAdapterWizardModel wizardModel) {
+ 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(3).margins(10, 10).spacing(4,
4).applyTo(container);
+
+ Group group = new Group(container, SWT.BORDER);
+ group.setText("Available applications");
+ GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).span(3,
1).applyTo(group);
+ FillLayout fillLayout = new FillLayout(SWT.VERTICAL);
+ fillLayout.marginHeight = 6;
+ fillLayout.marginWidth = 6;
+ group.setLayout(fillLayout);
+
+ 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("Ne&w");
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(80,
30).applyTo(newButton);
+ newButton.addSelectionListener(onNew(dbc));
+
+ Button deleteButton = new Button(container, SWT.PUSH);
+ deleteButton.setText("&Delete");
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(80,
30).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);
+ 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 {
+ WizardUtils.runInWizard(new LoadApplicationsJob(), getWizard().getContainer(), dbc);
+ } catch (Exception ex) {
+ // ignore
+ }
+ }
+
+ private class LoadApplicationsJob extends Job {
+ private LoadApplicationsJob() {
+ super("Loading applications");
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ 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,
+ "Could not load applications from Openshift Express");
+ }
+ }
+ }
+
+ 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()));
+ }
+ }
+
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPageModel.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPageModel.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPageModel.java 2011-10-05
11:03:07 UTC (rev 35356)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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 java.util.Collections;
+
+import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
+import org.jboss.tools.openshift.express.client.IApplication;
+import org.jboss.tools.openshift.express.client.IUser;
+import org.jboss.tools.openshift.express.client.OpenshiftException;
+
+/**
+ * @author André Dietisheim
+ *
+ */
+public class ApplicationWizardPageModel extends ObservableUIPojo {
+
+ public static final String PROPERTY_SELECTED_APPLICATION =
"selectedApplication";
+
+ private IApplication selectedApplication;
+ private ServerAdapterWizardModel wizardModel;
+
+ public ApplicationWizardPageModel(ServerAdapterWizardModel wizardModel) {
+ this.wizardModel = wizardModel;
+ }
+
+ 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();
+ }
+
+}
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPageModel.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java 2011-10-05
11:03:07 UTC (rev 35356)
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.wizard;
+
+import org.eclipse.core.databinding.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.value.WritableValue;
+import org.eclipse.core.databinding.validation.IValidator;
+import org.eclipse.core.databinding.validation.ValidationStatus;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.common.ui.BrowserUtil;
+import org.jboss.tools.common.ui.WizardUtils;
+import org.jboss.tools.common.ui.databinding.DataBindingUtils;
+import org.jboss.tools.openshift.express.internal.ui.OpenshiftUIActivator;
+
+/**
+ * @author André Dietisheim
+ */
+public class CredentialsWizardPage extends AbstractOpenshiftWizardPage {
+
+ protected static final String OPENSHIFT_EXPRESS_SIGNUP_URL =
"https://openshift.redhat.com/app/user/new/express"; //$NON-NLS-1$
+
+ private Button validateButton;
+
+ private CredentialsWizardPageModel model;
+
+ public CredentialsWizardPage(IWizard wizard, ServerAdapterWizardModel wizardModel) {
+ super("Server connetion", "Please provide the credentails of your user
account on Openshift Express",
+ "Server Connection", wizard);
+ this.model = new CredentialsWizardPageModel(wizardModel);
+ }
+
+ protected void doCreateControls(Composite container, DataBindingContext dbc) {
+ GridLayoutFactory.fillDefaults().numColumns(3).margins(10, 10).applyTo(container);
+
+ Link signupLink = new Link(container, SWT.WRAP);
+ signupLink.setText("If you have no user account on Openshit Express yet, please
sign up <a>here</a>.");
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(3, 1).hint(SWT.DEFAULT,
30).applyTo(signupLink);
+ signupLink.addSelectionListener(onSignupLinkClicked());
+
+ // Label serverUrlLabel = new Label(container, SWT.NONE);
+ // serverUrlLabel.setText("Server URL");
+ // GridDataFactory.fillDefaults().align(SWT.LEFT,
+ // SWT.CENTER).applyTo(serverUrlLabel);
+ // Text serverUrlText = new Text(container, SWT.BORDER);
+ // GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
+ // false).span(2, 1).applyTo(serverUrlText);
+ // dbc.bindValue(
+ // WidgetProperties.text(SWT.Modify).observe(serverUrlText),
+ // BeanProperties.value(
+ // ServerAdapterWizardModel.class,
+ // ServerAdapterWizardModel.PROPERTY_SERVER_URL).observe(model),
+ // new UpdateValueStrategy()
+ // .setAfterGetValidator(new
+ // MandatoryStringValidator("You have to provide a value for the server
url."))
+ // .setBeforeSetValidator(new SimpleUrlStringValidator())
+ // .setConverter(new TrimTrailingSlashConverter()),
+ // null);
+
+ Label rhLoginLabel = new Label(container, SWT.NONE);
+ rhLoginLabel.setText("&Username");
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(rhLoginLabel);
+ Text rhLoginText = new Text(container, SWT.BORDER);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2,
1).applyTo(rhLoginText);
+ Binding rhLoginBining = DataBindingUtils.bindMandatoryTextField(
+ rhLoginText, "Username", CredentialsWizardPageModel.PROPERTY_RHLOGIN,
model, dbc);
+
+ Label passwordLabel = new Label(container, SWT.NONE);
+ passwordLabel.setText("&Password");
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(passwordLabel);
+ Text passwordText = new Text(container, SWT.BORDER | SWT.PASSWORD);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2,
1).applyTo(passwordText);
+ Binding passwordBinding = DataBindingUtils.bindMandatoryTextField(
+ passwordText, "Password", CredentialsWizardPageModel.PROPERTY_PASSWORD,
model, dbc);
+
+ Label spacerLabel = new Label(container, SWT.None);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(2,
1).applyTo(spacerLabel);
+
+ // Label credentialsValidatyLabel = new Label(container, SWT.None);
+ // GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).hint(64,
+ // 64).applyTo(credentialsValidatyLabel);
+
+ this.validateButton = new Button(container, SWT.NONE);
+ validateButton.setText("&Validate");
+ GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).indent(0, 10).hint(100,
30).applyTo(validateButton);
+ DataBindingUtils.bindButtonEnablementToValidationStatus(
+ validateButton,
+ dbc,
+ rhLoginBining, passwordBinding);
+ validateButton.addSelectionListener(onValidate(dbc));
+ dbc.bindValue(
+ new WritableValue(null, IStatus.class),
+ BeanProperties.value(CredentialsWizardPageModel.PROPERTY_CREDENTIALS_VALIDITY).observe(model),
+ new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER),
+ new UpdateValueStrategy().setAfterGetValidator(
+ new CredentialsStatusValidator()));
+ }
+
+ protected SelectionAdapter onValidate(final DataBindingContext dbc) {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ WizardUtils.runInWizard(
+ new Job("Testing user credentials") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ model.validateCredentials();
+ return Status.OK_STATUS;
+ }
+ }, getWizard().getContainer(), dbc);
+ } catch (Exception ex) {
+ // ignore
+ }
+ };
+ };
+ }
+
+ protected SelectionAdapter onSignupLinkClicked() {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ BrowserUtil.checkedCreateInternalBrowser(OPENSHIFT_EXPRESS_SIGNUP_URL,
OPENSHIFT_EXPRESS_SIGNUP_URL,
+ OpenshiftUIActivator.PLUGIN_ID, OpenshiftUIActivator.getDefault().getLog());
+ getWizard().getContainer().getShell().close();
+ }
+ };
+ }
+
+ private static class CredentialsStatusValidator implements IValidator {
+ public IStatus validate(Object value) {
+ if (value instanceof IStatus) {
+ int currentSeverity = ((IStatus) value).getSeverity();
+ if (currentSeverity < IStatus.ERROR) {
+ return ValidationStatus.ok();
+ }
+ } else if (value == null) {
+ return ValidationStatus.info("You have to validate your credentials");
+ }
+ return ValidationStatus.error("The given credentials are not valid");
+ }
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java 2011-10-05
11:03:07 UTC (rev 35356)
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.wizard;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
+import org.jboss.tools.common.ui.preferencevalue.StringPreferenceValue;
+import org.jboss.tools.openshift.express.client.IOpenshiftService;
+import org.jboss.tools.openshift.express.client.IUser;
+import org.jboss.tools.openshift.express.client.NotFoundOpenshiftException;
+import org.jboss.tools.openshift.express.client.OpenshiftException;
+import org.jboss.tools.openshift.express.client.User;
+import org.jboss.tools.openshift.express.client.UserConfiguration;
+import org.jboss.tools.openshift.express.internal.ui.OpenshiftUIActivator;
+
+/**
+ * @author André Dietisheim
+ */
+public class CredentialsWizardPageModel extends ObservableUIPojo {
+
+ private static final String RHLOGIN_PREFS_KEY =
"org.jboss.tools.openshift.express.internal.ui.wizard.CredentialsWizardModel_RHLOGIN";
+
+ public static final String PROPERTY_SERVER_URL = "serverUrl";
+ public static final String PROPERTY_RHLOGIN = "rhLogin";
+ public static final String PROPERTY_PASSWORD = "password";
+ public static final String PROPERTY_CREDENTIALS_VALIDITY =
"credentialsValidity";
+
+ private String serverUrl;
+ private String rhLogin;
+ private String password;
+ private IStatus credentialsValidity;
+ private IUser user;
+ private StringPreferenceValue rhLoginPreferenceValue;
+
+ private ServerAdapterWizardModel wizardModel;
+
+ public CredentialsWizardPageModel(ServerAdapterWizardModel model) {
+ this.wizardModel = model;
+ this.serverUrl = IOpenshiftService.BASE_URL;
+ this.rhLoginPreferenceValue = new StringPreferenceValue(RHLOGIN_PREFS_KEY,
OpenshiftUIActivator.PLUGIN_ID);
+ this.rhLogin = initRhLogin();
+ resetCredentialsStatus();
+ }
+
+ protected String initRhLogin() {
+ String rhLogin = null;
+ rhLogin = rhLoginPreferenceValue.get();
+ if (rhLogin == null) {
+ rhLogin = getUserConfiguration();
+ }
+ return rhLogin;
+ }
+
+ protected String getUserConfiguration() {
+ String configuredUsername = null;
+ try {
+ configuredUsername = new UserConfiguration().getRhlogin();
+ } catch (Exception e) {
+ // do nothing
+ }
+ return configuredUsername;
+ }
+
+ public String getServerUrl() {
+ return serverUrl;
+ }
+
+ public void setServerUrl(String serverUrl) {
+ firePropertyChange(PROPERTY_SERVER_URL, this.serverUrl, this.serverUrl = serverUrl);
+ }
+
+ public String getRhLogin() {
+ return rhLogin;
+ }
+
+ public void setRhLogin(String rhLogin) {
+ if (rhLogin != null
+ && !rhLogin.equals(this.rhLogin)) {
+ rhLoginPreferenceValue.store(rhLogin);
+ firePropertyChange(PROPERTY_RHLOGIN, this.rhLogin, this.rhLogin = rhLogin);
+ resetCredentialsStatus();
+ }
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ if (password != null
+ && !password.equals(this.password)) {
+ firePropertyChange(PROPERTY_PASSWORD, this.password, this.password = password);
+ resetCredentialsStatus();
+ }
+ }
+
+ private void resetCredentialsStatus() {
+ setCredentialsStatus(null);
+ }
+
+ private void setCredentialsStatus(IStatus status) {
+ firePropertyChange(PROPERTY_CREDENTIALS_VALIDITY, this.credentialsValidity,
+ this.credentialsValidity = status);
+ }
+
+ public IStatus getCredentialsValidity() {
+ return credentialsValidity;
+ }
+
+ public void validateCredentials() {
+ IStatus status = new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID, "Your
credentails are not valid.");
+ try {
+ this.user = new User(getRhLogin(), getPassword());
+ if (user.isValid()) {
+ status = Status.OK_STATUS;
+ }
+ } catch (NotFoundOpenshiftException e) {
+ // valid user without domain
+ status = Status.OK_STATUS;
+ } catch (OpenshiftException e) {
+ this.user = null;
+ }
+ wizardModel.setUser(user);
+ setCredentialsStatus(status);
+ }
+
+ public IUser getUser() {
+ return user;
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ISkipableWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ISkipableWizardPage.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ISkipableWizardPage.java 2011-10-05
11:03:07 UTC (rev 35356)
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * @author André Dietisheim
+ */
+public interface ISkipableWizardPage {
+
+ public boolean isSkip();
+
+}
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ISkipableWizardPage.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationDialog.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationDialog.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationDialog.java 2011-10-05
11:03:07 UTC (rev 35356)
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * 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.concurrent.ArrayBlockingQueue;
+
+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.wizard.Wizard;
+import org.eclipse.osgi.util.NLS;
+import org.jboss.tools.common.ui.WizardUtils;
+import org.jboss.tools.openshift.express.client.IUser;
+import org.jboss.tools.openshift.express.client.OpenshiftException;
+import org.jboss.tools.openshift.express.internal.ui.OpenshiftUIActivator;
+
+/**
+ * @author André Dietisheim
+ */
+public class NewApplicationDialog extends Wizard {
+
+ private NewApplicationWizardPageModel newApplicationModel;
+
+ public NewApplicationDialog(IUser user) {
+ this.newApplicationModel = new NewApplicationWizardPageModel(user);
+ setNeedsProgressMonitor(true);
+ }
+
+ @Override
+ public boolean performFinish() {
+ final ArrayBlockingQueue<Boolean> queue = new
ArrayBlockingQueue<Boolean>(1);
+ try {
+ WizardUtils.runInWizard(new Job("Creating application") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ newApplicationModel.createApplication();
+ queue.offer(true);
+ } catch (OpenshiftException e) {
+ queue.offer(false);
+ return new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID,
+ NLS.bind("Could not create application \"{0}\"",
newApplicationModel.getName()), e);
+ }
+ return Status.OK_STATUS;
+ }
+ }, getContainer());
+ } catch (Exception e) {
+ // ignore
+ }
+ return queue.poll();
+ }
+
+ @Override
+ public void addPages() {
+ addPage(new NewApplicationWizardPage(newApplicationModel, this));
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationDialog.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPage.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPage.java 2011-10-05
11:03:07 UTC (rev 35356)
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.wizard;
+
+import org.eclipse.core.databinding.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.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.fieldassist.ControlDecorationSupport;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.osgi.util.NLS;
+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.tools.common.ui.WizardUtils;
+import org.jboss.tools.openshift.express.client.ICartridge;
+import org.jboss.tools.openshift.express.client.OpenshiftException;
+import org.jboss.tools.openshift.express.internal.ui.OpenshiftUIActivator;
+
+/**
+ * @author André Dietisheim
+ */
+public class NewApplicationWizardPage extends AbstractOpenshiftWizardPage {
+
+ 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("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().observe(nameText)
+ , BeanProperties.value(NewApplicationWizardPageModel.PROPERTY_NAME).observe(model)
+ , new UpdateValueStrategy().setAfterGetValidator(new ApplicationNameValidator())
+ , null);
+ ControlDecorationSupport.create(nameBinding, SWT.LEFT | SWT.TOP);
+
+ Label cartridgeLabel = new Label(parent, SWT.WRAP);
+ cartridgeLabel.setText("&Cartridge");
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(cartridgeLabel);
+ Combo cartridgesCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
+ dbc.bindList(
+ WidgetProperties.items().observe(cartridgesCombo)
+ ,
BeanProperties.list(NewApplicationWizardPageModel.PROPERTY_CARTRIDGES).observe(model)
+ , 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();
+ }
+ }));
+ dbc.bindValue(WidgetProperties.selection().observe(cartridgesCombo)
+ ,
BeanProperties.value(NewApplicationWizardPageModel.PROPERTY_SELECTED_CARTRIDGE).observe(model));
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(cartridgesCombo);
+ }
+
+ @Override
+ protected void onPageActivated(DataBindingContext dbc) {
+ try {
+ WizardUtils.runInWizard(new Job("Loading cartridges") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ model.loadCartridges();
+ } catch (OpenshiftException e) {
+ return new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID, "Could not
load cartridges", e);
+ }
+ return Status.OK_STATUS;
+ }
+ }, getContainer());
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ 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 (model.hasApplication(name)) {
+ return ValidationStatus.error(NLS.bind(
+ "Names must be unique. You already have an application named
\"{0}\"", name));
+ }
+ return ValidationStatus.ok();
+ }
+ }
+}
\ No newline at end of file
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPage.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPageModel.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPageModel.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPageModel.java 2011-10-05
11:03:07 UTC (rev 35356)
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * 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.jboss.tools.common.ui.databinding.ObservableUIPojo;
+import org.jboss.tools.common.ui.preferencevalue.StringPreferenceValue;
+import org.jboss.tools.openshift.express.client.ICartridge;
+import org.jboss.tools.openshift.express.client.IUser;
+import org.jboss.tools.openshift.express.client.OpenshiftException;
+import org.jboss.tools.openshift.express.internal.ui.OpenshiftUIActivator;
+
+/**
+ * @author André Dietisheim
+ */
+public class NewApplicationWizardPageModel extends ObservableUIPojo {
+
+ public static final String PROPERTY_NAME = "name";
+ public static final String PROPERTY_CARTRIDGES = "cartridges";
+ public static final String PROPERTY_SELECTED_CARTRIDGE = "selectedCartridge";
+
+ private IUser user;
+ private String name;
+
+ private Collection<ICartridge> cartridges;
+ private String selectedCartridge;
+ private StringPreferenceValue selectedCartridgePreference;
+
+ public NewApplicationWizardPageModel(IUser user) {
+ this.user = user;
+ this.selectedCartridgePreference = new StringPreferenceValue(
+ "org.jboss.tools.openshift.express.internal.ui.wizard.NewApplicationWizard.selectedCartridge",
OpenshiftUIActivator.PLUGIN_ID);
+ initSelectedCartridge();
+ }
+
+ private void initSelectedCartridge() {
+ String selectedCartridge = selectedCartridgePreference.get();
+ if (selectedCartridge == null
+ || selectedCartridge.length() == 0) {
+ selectedCartridge = ICartridge.JBOSSAS_7.getName();
+ }
+ this.selectedCartridge = selectedCartridge;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ firePropertyChange(PROPERTY_NAME, this.name, this.name = name);
+ }
+
+ public void loadCartridges() throws OpenshiftException {
+ setCartridges(user.getCartridges());
+ }
+
+ public void setCartridges(Collection<ICartridge> cartridges) {
+ firePropertyChange(PROPERTY_CARTRIDGES, this.cartridges, this.cartridges =
cartridges);
+ }
+
+ public Collection<ICartridge> getCartridges() {
+ return cartridges;
+ }
+
+ public String getSelectedCartridge() {
+ return selectedCartridge;
+ }
+
+ public void setSelectedCartridge(String name) {
+ selectedCartridgePreference.store(name);
+ firePropertyChange(PROPERTY_SELECTED_CARTRIDGE, selectedCartridge,
this.selectedCartridge = name);
+ }
+
+ public void createApplication() throws OpenshiftException {
+ user.createApplication(name, user.getCartridgeByName(selectedCartridge));
+ }
+
+ public boolean hasApplication(String name) {
+ try {
+ return user.getApplicationByName(name) != null;
+ } catch (OpenshiftException e) {
+ // TODO proper logging
+ return false;
+ }
+ }
+
+
+}
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPageModel.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java 2011-10-05
11:03:07 UTC (rev 35356)
@@ -0,0 +1,227 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.wizard;
+
+import java.io.File;
+import java.util.concurrent.ArrayBlockingQueue;
+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;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+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.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.common.ui.BrowserUtil;
+import org.jboss.tools.common.ui.WizardUtils;
+import org.jboss.tools.common.ui.databinding.DataBindingUtils;
+import org.jboss.tools.openshift.express.client.IDomain;
+import org.jboss.tools.openshift.express.internal.ui.OpenshiftUIActivator;
+
+/**
+ * @author André Dietisheim
+ */
+public class NewDomainWizardPage extends AbstractOpenshiftWizardPage implements
ISkipableWizardPage {
+
+ private static final String OPENSHIFT_EXPRESS_SIGNUP_URL =
"https://openshift.redhat.com/app/user/new/express"; //$NON-NLS-1$
+
+ private static final String DIRECTORY_SSH_KEYS = ".ssh";
+ private static final String FILTEREXPRESSION_PUBLIC_SSH_KEY = "*.pub";
+ private static final String FILTERNAME_PUBLIC_SSH_KEY = "Public ssh key file
(*.pub)";
+
+ private NewDomainWizardPageModel model;
+
+ public NewDomainWizardPage(IWizard wizard, ServerAdapterWizardModel wizardModel) {
+ super("New Domain", "Please create a new domain",
+ "new Domain", wizard);
+ this.model = new NewDomainWizardPageModel(wizardModel);
+ }
+
+ protected void doCreateControls(Composite container, DataBindingContext dbc) {
+ GridLayoutFactory.fillDefaults().numColumns(3).margins(10, 10).applyTo(container);
+
+ Label namespaceLabel = new Label(container, SWT.NONE);
+ namespaceLabel.setText("&Domain name");
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(namespaceLabel);
+ Text namespaceText = new Text(container, SWT.BORDER);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2,
1).applyTo(namespaceText);
+ DataBindingUtils.bindMandatoryTextField(namespaceText, "Domain name",
+ NewDomainWizardPageModel.PROPERTY_NAMESPACE, model, dbc);
+
+ Label sshKeyLabel = new Label(container, SWT.NONE);
+ sshKeyLabel.setText("SSH Key");
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(sshKeyLabel);
+ Text sshKeyText = new Text(container, SWT.READ_ONLY | SWT.BORDER);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(sshKeyText);
+ DataBindingUtils.bindMandatoryTextField(sshKeyText, "SSH Key",
NewDomainWizardPageModel.PROPERTY_SSHKEY, model,
+ dbc);
+ Button browseSShKeyButton = new Button(container, SWT.PUSH);
+ browseSShKeyButton.setText("Browse");
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100,
SWT.DEFAULT).applyTo(browseSShKeyButton);
+ browseSShKeyButton.addSelectionListener(onBrowseSshKey());
+
+ Label spacerLabel = new Label(container, SWT.None);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(spacerLabel);
+
+ Button createButton = new Button(container, SWT.NONE);
+ createButton.setText("&Create New Domain");
+ GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).span(2, 1).indent(0,
10).hint(160, 34)
+ .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() {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ FileDialog dialog = new FileDialog(shell);
+ dialog.setFilterPath(getSshKeysDirectory());
+ dialog.setFilterNames(new String[] { FILTERNAME_PUBLIC_SSH_KEY });
+ dialog.setFilterExtensions(new String[] { FILTEREXPRESSION_PUBLIC_SSH_KEY });
+ String sshKeyPath = dialog.open();
+ if (sshKeyPath != null) {
+ model.setSshKey(sshKeyPath);
+ }
+ }
+ };
+ }
+
+ private String getSshKeysDirectory() {
+ String userHome = System.getProperty("user.home");
+ File sshKeysDirectory = new File(userHome, DIRECTORY_SSH_KEYS);
+ return sshKeysDirectory.getAbsolutePath();
+ }
+
+ protected SelectionAdapter onCreate(final DataBindingContext dbc) {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ WizardUtils.runInWizard(
+ new Job("Creating new domain") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ model.createDomain();
+ } 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);
+ }
+ return Status.OK_STATUS;
+ }
+ }, getWizard().getContainer(), dbc);
+ } catch (Exception ex) {
+ // ignore
+ }
+ };
+ };
+ }
+
+ protected SelectionAdapter onSignupLinkClicked() {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ BrowserUtil.checkedCreateInternalBrowser(OPENSHIFT_EXPRESS_SIGNUP_URL,
OPENSHIFT_EXPRESS_SIGNUP_URL,
+ OpenshiftUIActivator.PLUGIN_ID, OpenshiftUIActivator.getDefault().getLog());
+ getWizard().getContainer().getShell().close();
+ }
+ };
+ }
+
+ protected IObservableCollection toObservableCollection(ValidationStatusProvider...
validationStatusProviders) {
+ WritableList validationProviders = new WritableList();
+ for (ValidationStatusProvider provider : validationStatusProviders) {
+ validationProviders.add(provider);
+ }
+ return validationProviders;
+ }
+
+ @Override
+ public boolean isSkip() {
+ if (!model.hasUser()) {
+ return false;
+ }
+
+ final ArrayBlockingQueue<Boolean> queue = new
ArrayBlockingQueue<Boolean>(1);
+ try {
+ WizardUtils.runInWizard(
+ new Job("Checking presence of domain") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ queue.offer(model.hasDomain());
+ } catch (Exception e) {
+ 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
+ }
+
+ 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...");
+ }
+ }
+ };
+
+}
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java 2011-10-05
11:03:07 UTC (rev 35356)
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.wizard;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
+import org.jboss.tools.openshift.express.client.IDomain;
+import org.jboss.tools.openshift.express.client.ISSHPublicKey;
+import org.jboss.tools.openshift.express.client.IUser;
+import org.jboss.tools.openshift.express.client.OpenshiftException;
+import org.jboss.tools.openshift.express.client.SSHPublicKey;
+
+/**
+ * @author André Dietisheim
+ */
+public class NewDomainWizardPageModel extends ObservableUIPojo {
+
+ public static final String PROPERTY_NAMESPACE = "namespace";
+ public static final String PROPERTY_SSHKEY = "sshKey";
+ public static final String PROPERTY_DOMAIN = "domain";
+
+ private String namespace;
+ private IDomain domain;
+ private String sshKey;
+ private ServerAdapterWizardModel wizardModel;
+
+ public NewDomainWizardPageModel(ServerAdapterWizardModel wizardModel) {
+ this.wizardModel = wizardModel;
+ }
+
+ public String getNamespace() {
+ return this.namespace;
+ }
+
+ public void createDomain() throws OpenshiftException, IOException {
+ IUser user = getUser();
+ IDomain domain = user.createDomain(namespace, loadSshKey());
+ setDomain(domain);
+ }
+
+ public String getSshKey() {
+ return sshKey;
+ }
+
+ public void setSshKey(String sshKey) {
+ firePropertyChange(PROPERTY_SSHKEY, this.sshKey, this.sshKey = sshKey);
+ }
+
+ private ISSHPublicKey loadSshKey() throws IOException, OpenshiftException {
+ return new SSHPublicKey(new File(sshKey));
+ }
+
+ public void setNamespace(String namespace) throws OpenshiftException {
+ firePropertyChange(PROPERTY_NAMESPACE, this.namespace, this.namespace = namespace);
+ }
+
+ public boolean hasDomain() throws OpenshiftException {
+ if (!hasUser()) {
+ return false;
+ }
+ return getUser().hasDomain();
+ }
+
+ 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();
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ServerAdapterWizard.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ServerAdapterWizard.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ServerAdapterWizard.java 2011-10-05
11:03:07 UTC (rev 35356)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.wizard;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * @author André Dietisheim
+ */
+public class ServerAdapterWizard extends AbstractSkippingWizard {
+
+ public ServerAdapterWizard() {
+ }
+
+ @Override
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ setWindowTitle("Create new Openshift Express Server Adapter");
+ setNeedsProgressMonitor(true);
+ }
+
+ @Override
+ public boolean performFinish() {
+ return true;
+ }
+
+ @Override
+ public void addPages() {
+ ServerAdapterWizardModel model = new ServerAdapterWizardModel();
+ addPage(new CredentialsWizardPage(this, model));
+ addPage(new NewDomainWizardPage(this, model));
+ addPage(new ApplicationWizardPage(this, model));
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ServerAdapterWizard.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ServerAdapterWizardModel.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ServerAdapterWizardModel.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ServerAdapterWizardModel.java 2011-10-05
11:03:07 UTC (rev 35356)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.wizard;
+
+import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
+import org.jboss.tools.openshift.express.client.IUser;
+
+/**
+ * @author André Dietisheim
+ */
+public class ServerAdapterWizardModel extends ObservableUIPojo {
+
+ private IUser user;
+
+ public void setUser(IUser user) {
+ this.user = user;
+ }
+
+ public IUser getUser() {
+ return user;
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ServerAdapterWizardModel.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/TrimTrailingSlashConverter.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/TrimTrailingSlashConverter.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/TrimTrailingSlashConverter.java 2011-10-05
11:03:07 UTC (rev 35356)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.wizard;
+
+import org.eclipse.core.databinding.conversion.Converter;
+import org.eclipse.core.runtime.Assert;
+
+/**
+ * @author André Dietisheim
+ */
+public class TrimTrailingSlashConverter extends Converter {
+
+ public TrimTrailingSlashConverter() {
+ super(String.class, String.class);
+ }
+
+ @Override
+ public Object convert(Object fromObject) {
+ Assert.isLegal(fromObject instanceof String);
+ String url = (String) fromObject;
+ if (url.charAt(url.length() - 1) == '/') {
+ return url.substring(0, url.length() - 1);
+ }
+ return url;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/TrimTrailingSlashConverter.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain