Author: adietish
Date: 2012-10-11 13:33:10 -0400 (Thu, 11 Oct 2012)
New Revision: 44438
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/databinding/TrimmingStringConverter.java
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/connection/ConnectionWizardPage.java
Log:
[JBIDE-12572] trimming usernames to make it more robust (copy paste where you copy
trailing space)
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/databinding/TrimmingStringConverter.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/databinding/TrimmingStringConverter.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/databinding/TrimmingStringConverter.java 2012-10-11
17:33:10 UTC (rev 44438)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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.databinding;
+
+import org.eclipse.core.databinding.conversion.Converter;
+
+public class TrimmingStringConverter extends Converter {
+
+ public TrimmingStringConverter() {
+ super(String.class, String.class);
+ }
+
+ @Override
+ public Object convert(Object fromObject) {
+ if (!(fromObject instanceof String)) {
+ return fromObject;
+ }
+ return ((String) fromObject).trim();
+ }
+
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/databinding/TrimmingStringConverter.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/connection/ConnectionWizardPage.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/connection/ConnectionWizardPage.java 2012-10-11
17:31:33 UTC (rev 44437)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/connection/ConnectionWizardPage.java 2012-10-11
17:33:10 UTC (rev 44438)
@@ -54,6 +54,7 @@
import org.jboss.tools.openshift.express.internal.ui.databinding.HostNameValidator;
import
org.jboss.tools.openshift.express.internal.ui.databinding.RequiredControlDecorationUpdater;
import
org.jboss.tools.openshift.express.internal.ui.databinding.RequiredStringValidator;
+import
org.jboss.tools.openshift.express.internal.ui.databinding.TrimmingStringConverter;
import org.jboss.tools.openshift.express.internal.ui.explorer.AbstractLabelProvider;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
import org.jboss.tools.openshift.express.internal.ui.utils.StringUtils;
@@ -143,6 +144,7 @@
.align(SWT.FILL, SWT.CENTER).grab(true, false).span(1, 1).applyTo(rhLoginText);
Binding usernameBinding = ValueBindingBuilder
.bind(WidgetProperties.text(SWT.Modify).observe(rhLoginText))
+ .converting(new TrimmingStringConverter())
.validatingAfterGet(new RequiredStringValidator("username"))
.to(BeanProperties.value(ConnectionWizardPageModel.PROPERTY_USERNAME).observe(pageModel))
.in(dbc);