diff options
author | yyang | 2015-11-19 20:16:01 +0000 |
---|---|---|
committer | yyang | 2015-11-19 20:16:01 +0000 |
commit | 9b69495cee02097152b27962575e0c18b1ea91c1 (patch) | |
tree | 8141c0f949b53fa3a5689e67943170b903b952ba | |
parent | 313edc9d43b3906102709fe5a4f8325aedb10b53 (diff) | |
download | org.eclipse.xwt-9b69495cee02097152b27962575e0c18b1ea91c1.tar.gz org.eclipse.xwt-9b69495cee02097152b27962575e0c18b1ea91c1.tar.xz org.eclipse.xwt-9b69495cee02097152b27962575e0c18b1ea91c1.zip |
Bug 482622 - Attribute names in UPCASE aren't found (edit)
7 files changed, 147 insertions, 1 deletions
diff --git a/org.eclipse.xwt.tests/src/org/eclipse/xwt/tests/databinding/BindingTestSuite.java b/org.eclipse.xwt.tests/src/org/eclipse/xwt/tests/databinding/BindingTestSuite.java index 4376dc9..da1cf1d 100644 --- a/org.eclipse.xwt.tests/src/org/eclipse/xwt/tests/databinding/BindingTestSuite.java +++ b/org.eclipse.xwt.tests/src/org/eclipse/xwt/tests/databinding/BindingTestSuite.java @@ -16,6 +16,7 @@ import junit.framework.TestSuite; import org.eclipse.xwt.tests.databinding.bindcontrol.ControlBindingTests;
import org.eclipse.xwt.tests.databinding.multibinding.MultiBindingTests;
import org.eclipse.xwt.tests.databinding.pojo.PojoDataBindingTests;
+import org.eclipse.xwt.tests.databinding.pojo.attribute.PojoAttrDataBindingTests;
import org.eclipse.xwt.tests.databinding.self.DataBindingSelfTests;
import org.eclipse.xwt.tests.databinding.status.ValidationStatusTests;
import org.eclipse.xwt.tests.databinding.validation.ValidationsTests;
@@ -28,6 +29,7 @@ public class BindingTestSuite extends TestSuite { public BindingTestSuite() {
addTest(new TestSuite(DataBindingTests.class));
addTest(new TestSuite(PojoDataBindingTests.class));
+ addTest(new TestSuite(PojoAttrDataBindingTests.class));
addTest(new TestSuite(ControlBindingTests.class));
addTest(new TestSuite(MultiBindingTests.class));
addTest(new TestSuite(DataBindingSelfTests.class));
diff --git a/org.eclipse.xwt.tests/src/org/eclipse/xwt/tests/databinding/pojo/PojoDataBindingTests.java b/org.eclipse.xwt.tests/src/org/eclipse/xwt/tests/databinding/pojo/PojoDataBindingTests.java index 8702835..c05ce9f 100644 --- a/org.eclipse.xwt.tests/src/org/eclipse/xwt/tests/databinding/pojo/PojoDataBindingTests.java +++ b/org.eclipse.xwt.tests/src/org/eclipse/xwt/tests/databinding/pojo/PojoDataBindingTests.java @@ -17,11 +17,12 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.xwt.IConstants;
import org.eclipse.xwt.XWT;
import org.eclipse.xwt.tests.XWTTestCase;
+import org.eclipse.xwt.tests.databinding.pojo.attribute.PojoAttrDataBindingTests;
public class PojoDataBindingTests extends XWTTestCase {
public void testDataBinding() throws Exception {
- URL url = PojoDataBindingTests.class.getResource(DataBinding.class
+ URL url = PojoAttrDataBindingTests.class.getResource(DataBinding.class
.getSimpleName()
+ IConstants.XWT_EXTENSION_SUFFIX);
runTest(url, new Runnable() {
diff --git a/org.eclipse.xwt.tests/src/org/eclipse/xwt/tests/databinding/pojo/attribute/Company.java b/org.eclipse.xwt.tests/src/org/eclipse/xwt/tests/databinding/pojo/attribute/Company.java new file mode 100644 index 0000000..5fc3341 --- /dev/null +++ b/org.eclipse.xwt.tests/src/org/eclipse/xwt/tests/databinding/pojo/attribute/Company.java @@ -0,0 +1,23 @@ +/*******************************************************************************
+ * Copyright (c) 2006, 2010 Soyatec (http://www.soyatec.com) and others.
+ * 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:
+ * Soyatec - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.xwt.tests.databinding.pojo.attribute;
+
+public class Company {
+ private String NAME = "Soyatec";
+
+ public void setNAME(String value) {
+ this.NAME = value;
+ }
+
+ public String getNAME() {
+ return NAME;
+ }
+}
diff --git a/org.eclipse.xwt.tests/src/org/eclipse/xwt/tests/databinding/pojo/attribute/DataBinding.java b/org.eclipse.xwt.tests/src/org/eclipse/xwt/tests/databinding/pojo/attribute/DataBinding.java new file mode 100644 index 0000000..30c5c95 --- /dev/null +++ b/org.eclipse.xwt.tests/src/org/eclipse/xwt/tests/databinding/pojo/attribute/DataBinding.java @@ -0,0 +1,42 @@ +/*******************************************************************************
+ * Copyright (c) 2006, 2010 Soyatec (http://www.soyatec.com) and others.
+ * 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:
+ * Soyatec - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.xwt.tests.databinding.pojo.attribute;
+
+import java.net.URL;
+
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.xwt.IConstants;
+import org.eclipse.xwt.XWT;
+
+public class DataBinding {
+ public static void main(String[] args) {
+
+ URL url = DataBinding.class.getResource(DataBinding.class
+ .getSimpleName()
+ + IConstants.XWT_EXTENSION_SUFFIX);
+ try {
+ XWT.open(url);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ protected void onNew(Event event) {
+ Shell shell = (Shell) XWT.findElementByName(event.widget, "Root");
+ Company company = (Company) XWT.getDataContext(shell);
+ company.setNAME("Eclipse");
+ IObservableValue managerValue = XWT.observableValue(shell, company,
+ "name");
+ managerValue.setValue("Eclipse");
+ }
+}
diff --git a/org.eclipse.xwt.tests/src/org/eclipse/xwt/tests/databinding/pojo/attribute/DataBinding.xwt b/org.eclipse.xwt.tests/src/org/eclipse/xwt/tests/databinding/pojo/attribute/DataBinding.xwt new file mode 100644 index 0000000..4a5888b --- /dev/null +++ b/org.eclipse.xwt.tests/src/org/eclipse/xwt/tests/databinding/pojo/attribute/DataBinding.xwt @@ -0,0 +1,24 @@ +<Shell xmlns="http://www.eclipse.org/xwt/presentation"
+ xmlns:x="http://www.eclipse.org/xwt"
+ xmlns:y="clr-namespace:org.eclipse.xwt.tests.databinding.pojo.attribute"
+ x:Class="org.eclipse.xwt.tests.databinding.pojo.attribute.DataBinding"
+ Size="400, 300"
+ x:Name="Root"
+ DataContext="{StaticResource myData}">
+ <Shell.layout>
+ <GridLayout numColumns="3"/>
+ </Shell.layout>
+
+ <Shell.Resources>
+ <y:Company x:Key="myData"/>
+ </Shell.Resources>
+
+ <Label text="Name"/>
+ <Text Name="Name" x:style="BORDER" text="{Binding Path=NAME}">
+ <Text.layoutData>
+ <GridData horizontalAlignment="FILL"
+ grabExcessHorizontalSpace="true"/>
+ </Text.layoutData>
+ </Text>
+ <Button Name="Button" Text="Change" SelectionEvent="onNew"/>
+</Shell>
\ No newline at end of file diff --git a/org.eclipse.xwt.tests/src/org/eclipse/xwt/tests/databinding/pojo/attribute/PojoAttrDataBindingTests.java b/org.eclipse.xwt.tests/src/org/eclipse/xwt/tests/databinding/pojo/attribute/PojoAttrDataBindingTests.java new file mode 100644 index 0000000..8f8bbf0 --- /dev/null +++ b/org.eclipse.xwt.tests/src/org/eclipse/xwt/tests/databinding/pojo/attribute/PojoAttrDataBindingTests.java @@ -0,0 +1,49 @@ +/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.xwt.tests.databinding.pojo.attribute;
+
+import java.net.URL;
+
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.xwt.IConstants;
+import org.eclipse.xwt.XWT;
+import org.eclipse.xwt.tests.XWTTestCase;
+
+public class PojoAttrDataBindingTests extends XWTTestCase {
+
+ public void testDataBinding() throws Exception {
+ URL url = PojoAttrDataBindingTests.class.getResource(DataBinding.class
+ .getSimpleName()
+ + IConstants.XWT_EXTENSION_SUFFIX);
+ runTest(url, new Runnable() {
+ public void run() {
+ checkButton();
+ }
+
+ public void checkButton() {
+ Object element = XWT.findElementByName(root, "Button");
+ assertTrue(element instanceof Button);
+ }
+ }, new Runnable() {
+ public void run() {
+ checkButton();
+ }
+
+ public void checkButton() {
+ Object element = XWT.findElementByName(root, "Name");
+ assertTrue(element instanceof Text);
+ Text text = (Text) element;
+ assertEquals(text.getText(), "Soyatec");
+ }
+ });
+ }
+}
diff --git a/org.eclipse.xwt/src/org/eclipse/xwt/metadata/ModelUtils.java b/org.eclipse.xwt/src/org/eclipse/xwt/metadata/ModelUtils.java index 3466912..ed4976d 100644 --- a/org.eclipse.xwt/src/org/eclipse/xwt/metadata/ModelUtils.java +++ b/org.eclipse.xwt/src/org/eclipse/xwt/metadata/ModelUtils.java @@ -28,6 +28,11 @@ public class ModelUtils { if (Character.isLowerCase(c)) {
return name;
}
+ if (name.length() > 1) {
+ if (Character.isUpperCase(name.charAt(1))) {
+ return name;
+ }
+ }
return Character.toLowerCase(name.charAt(0)) + name.substring(1);
}
}
|