summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Kriese2011-04-20 02:48:28 (EDT)
committerSteffen Kriese2011-04-20 02:48:28 (EDT)
commita48ceb42ccc7b251dd655845d9d8e83bc59c7be3 (patch)
tree465076166386dfecbbb9984f339e21248852dccd
parent699b3f28de6c7cee3fa16f6b4afa379d55ef629d (diff)
downloadorg.eclipse.riena-a48ceb42ccc7b251dd655845d9d8e83bc59c7be3.zip
org.eclipse.riena-a48ceb42ccc7b251dd655845d9d8e83bc59c7be3.tar.gz
org.eclipse.riena-a48ceb42ccc7b251dd655845d9d8e83bc59c7be3.tar.bz2
removed dependencie to org.eclipse.riena.example.client from tests-bundle
-rw-r--r--org.eclipse.riena.tests/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.riena.tests/Riena - AllTests.launch4
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/AllTests.java29
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ChoiceSubModuleController.java300
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ChoiceSubModuleControllerTest.java5
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ComboSubModuleController.java147
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ComboSubModuleControllerTest.java1
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ControllerTestsPlaygroundSubModuleController.java573
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ControllerTestsPlaygroundSubModuleControllerTest.java1
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/HelloDialogController.java234
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/HelloDialogControllerTest.java5
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/MarkerSubModuleController.java420
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/MarkerSubModuleControllerTest.java1
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/NavigateSubModuleController.java256
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/NavigateSubModuleControllerTest.java5
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/NavigationSubModuleController.java190
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/NavigationSubModuleControllerTest.java1
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/PersonModificationBean.java90
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/TableSubModuleController.java233
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/TableSubModuleControllerTest.java1
20 files changed, 2479 insertions, 18 deletions
diff --git a/org.eclipse.riena.tests/META-INF/MANIFEST.MF b/org.eclipse.riena.tests/META-INF/MANIFEST.MF
index d896cb7..47529b9 100644
--- a/org.eclipse.riena.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.riena.tests/META-INF/MANIFEST.MF
@@ -7,7 +7,6 @@ Bundle-Activator: org.eclipse.riena.internal.tests.Activator
Require-Bundle: org.apache.log4j;resolution:=optional,
org.easymock,
org.eclipse.riena.client,
- org.eclipse.riena.example.client,
org.eclipse.riena.monitor.common,
org.eclipse.riena.monitor.client,
org.eclipse.riena.objecttransaction,
diff --git a/org.eclipse.riena.tests/Riena - AllTests.launch b/org.eclipse.riena.tests/Riena - AllTests.launch
index 19b392c..b93e8c2 100644
--- a/org.eclipse.riena.tests/Riena - AllTests.launch
+++ b/org.eclipse.riena.tests/Riena - AllTests.launch
@@ -36,8 +36,8 @@
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.riena.sample.app.client.mail.product"/>
<booleanAttribute key="run_in_ui_thread" value="true"/>
-<stringAttribute key="selected_target_plugins" value="org.eclipse.core.databinding.observable@default:default,org.apache.commons.logging@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.equinox.security.win32.x86@default:false,org.eclipse.core.expressions@default:default,org.eclipse.equinox.log@default:default,org.eclipse.help@default:default,org.eclipse.core.runtime@default:true,org.eclipse.equinox.registry@default:default,org.eclipse.core.jobs@default:default,org.eclipse.jface@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.swt.win32.win32.x86@default:false,org.eclipse.ui.workbench@default:default,javax.servlet@default:default,com.ibm.icu@default:default,org.eclipse.equinox.common@2:true,org.eclipse.core.databinding@default:default,org.eclipse.core.commands@default:default,org.eclipse.osgi@-1:true,org.eclipse.equinox.servletbridge.extensionbundle@default:false,org.eclipse.core.databinding.beans@default:default,org.eclipse.equinox.weaving.hook@default:false,org.eclipse.jface.databinding@default:default,org.eclipse.equinox.app@default:default,org.eclipse.ui@default:default,org.eclipse.swt@default:default,org.eclipse.equinox.transforms.hook@default:false,org.eclipse.equinox.security@default:default,org.eclipse.osgi.services@default:default"/>
-<stringAttribute key="selected_workspace_plugins" value="org.apache.log4j@default:default,org.eclipse.riena.core@default:default,org.pushingpixels.trident@default:default,org.eclipse.riena.communication.factory.hessian@default:default,org.eclipse.riena.communication.console@default:default,org.junit@default:default,org.eclipse.riena.beans.common@default:default,org.eclipse.riena.monitor.common@default:default,org.eclipse.riena.ui.core@default:default,com.caucho.hessian@default:default,org.eclipse.riena.security.common@default:default,org.eclipse.nebula.widgets.compositetable@default:default,org.eclipse.riena.navigation.ui@default:default,org.eclipse.riena.security.simpleservices@default:default,org.easymock@default:default,org.eclipse.riena.navigation@default:default,org.eclipse.riena.security.server@default:default,org.eclipse.riena.ui.ridgets.swt.optional@default:default,org.eclipse.riena.communication.publisher@default:default,org.eclipse.core.variables@default:default,org.eclipse.riena.ui.common@default:default,org.eclipse.riena.ui.swt@default:default,org.eclipse.riena.ui.swt.rcp@default:default,org.eclipse.riena.ui.ridgets@default:default,org.apache.commons.beanutils@default:default,org.eclipse.riena.ui.filter@default:default,org.eclipse.riena.ui.ridgets.swt@default:default,org.eclipse.riena.example.client@default:default,org.eclipse.riena.tests@default:default,org.apache.oro@default:default,org.eclipse.riena.sample.app.common@default:default,org.eclipse.riena.ui.workarea@default:default,org.eclipse.riena.monitor.client@default:default,org.eclipse.riena.communication.core@default:default,org.eclipse.riena.navigation.ui.swt@default:default,org.eclipse.riena.client@default:default,org.eclipse.riena.security.services@default:default,org.eclipse.riena.objecttransaction@default:default"/>
+<stringAttribute key="selected_target_plugins" value="org.eclipse.swt@default:default,com.ibm.icu@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.equinox.common@2:true,org.eclipse.jface.databinding@default:default,org.eclipse.core.runtime@default:true,org.eclipse.equinox.servletbridge.extensionbundle@default:false,org.eclipse.core.databinding.observable@default:default,org.eclipse.osgi.services@default:default,org.eclipse.equinox.log@default:default,org.eclipse.equinox.transforms.hook@default:false,org.eclipse.ui@default:default,org.eclipse.help@default:default,org.apache.commons.logging@default:default,org.eclipse.core.databinding@default:default,org.eclipse.jface@default:default,org.eclipse.equinox.security@default:default,org.eclipse.core.databinding.beans@default:default,org.eclipse.equinox.weaving.hook@default:false,org.eclipse.core.databinding.property@default:default,org.eclipse.core.jobs@default:default,org.eclipse.equinox.security.win32.x86@default:false,org.eclipse.core.commands@default:default,org.eclipse.equinox.app@default:default,org.eclipse.osgi@-1:true,javax.servlet@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.swt.win32.win32.x86@default:false,org.eclipse.core.expressions@default:default,org.eclipse.equinox.registry@default:default"/>
+<stringAttribute key="selected_workspace_plugins" value="org.eclipse.riena.ui.swt@default:default,org.eclipse.riena.ui.ridgets.swt.optional@default:default,org.pushingpixels.trident@default:default,org.eclipse.riena.communication.console@default:default,org.eclipse.riena.monitor.common@default:default,org.eclipse.riena.client@default:default,org.eclipse.riena.ui.filter@default:default,org.eclipse.riena.navigation.ui@default:default,org.eclipse.riena.objecttransaction@default:default,com.caucho.hessian@default:default,org.eclipse.riena.ui.core@default:default,org.apache.oro@default:default,org.eclipse.riena.security.services@default:default,org.easymock@default:default,org.eclipse.riena.monitor.client@default:default,org.eclipse.riena.ui.ridgets@default:default,org.apache.commons.beanutils@default:default,org.eclipse.riena.navigation@default:default,org.eclipse.riena.communication.core@default:default,org.eclipse.riena.navigation.ui.swt@default:default,org.eclipse.riena.ui.swt.rcp@default:default,org.eclipse.core.variables@default:default,org.eclipse.riena.communication.publisher@default:default,org.eclipse.riena.tests@default:default,org.eclipse.riena.ui.ridgets.swt@default:default,org.eclipse.riena.security.simpleservices@default:default,org.eclipse.riena.sample.app.common@default:default,org.eclipse.riena.beans.common@default:default,org.eclipse.riena.core@default:default,org.eclipse.riena.security.server@default:default,org.eclipse.riena.security.common@default:default,org.eclipse.riena.ui.common@default:default,org.apache.log4j@default:default,org.eclipse.riena.communication.factory.hessian@default:default,org.eclipse.riena.ui.workarea@default:default,org.junit@default:default,org.eclipse.nebula.widgets.compositetable@default:default"/>
<booleanAttribute key="show_selected_only" value="false"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useCustomFeatures" value="false"/>
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/AllTests.java b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/AllTests.java
new file mode 100644
index 0000000..7eced3d
--- /dev/null
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/AllTests.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 compeople AG 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:
+ * compeople AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.riena.client.controller.test;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+
+import org.eclipse.riena.internal.core.test.collect.NonGatherableTestCase;
+import org.eclipse.riena.internal.core.test.collect.TestCollector;
+import org.eclipse.riena.internal.tests.Activator;
+
+/**
+ * Tests all test cases within this package.
+ */
+@NonGatherableTestCase("This is not a ´TestCase´!")
+public class AllTests extends TestCase {
+
+ public static Test suite() {
+ return TestCollector.createTestSuiteWith(Activator.getDefault().getBundle(), AllTests.class.getPackage());
+ }
+}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ChoiceSubModuleController.java b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ChoiceSubModuleController.java
new file mode 100644
index 0000000..6d65519
--- /dev/null
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ChoiceSubModuleController.java
@@ -0,0 +1,300 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 compeople AG 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:
+ * compeople AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.riena.client.controller.test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.beans.BeansObservables;
+import org.eclipse.core.databinding.beans.PojoObservables;
+import org.eclipse.core.databinding.observable.list.WritableList;
+import org.eclipse.core.runtime.Assert;
+
+import org.eclipse.riena.beans.common.AbstractBean;
+import org.eclipse.riena.internal.ui.ridgets.swt.SingleChoiceRidget;
+import org.eclipse.riena.navigation.ISubModuleNode;
+import org.eclipse.riena.navigation.listener.SubModuleNodeListener;
+import org.eclipse.riena.navigation.ui.controllers.SubModuleController;
+import org.eclipse.riena.ui.core.marker.MandatoryMarker;
+import org.eclipse.riena.ui.ridgets.IActionListener;
+import org.eclipse.riena.ui.ridgets.IActionRidget;
+import org.eclipse.riena.ui.ridgets.IMultipleChoiceRidget;
+import org.eclipse.riena.ui.ridgets.ISingleChoiceRidget;
+import org.eclipse.riena.ui.ridgets.ITextRidget;
+
+/**
+ * Controller for the example.
+ */
+@SuppressWarnings("restriction")
+public class ChoiceSubModuleController extends SubModuleController {
+
+ private final CarConfig carConfig = new CarConfig();
+ private final String[] additionalColors = new String[] { "white", "silver", "gray", "yellow" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ public ChoiceSubModuleController(final ISubModuleNode navigationNode) {
+ super(navigationNode);
+ }
+
+ public CarConfig getCarConfig() {
+ return carConfig;
+ }
+
+ /**
+ * Binds and updates the ridgets.
+ *
+ * @see org.eclipse.riena.ui.ridgets.IRidgetContainer#configureRidgets()
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public void configureRidgets() {
+
+ final SingleChoiceRidget compositeCarModel = getRidget(SingleChoiceRidget.class, "compositeCarModel"); //$NON-NLS-1$
+ compositeCarModel.bindToModel(toList(CarModels.values()),
+ BeansObservables.observeValue(carConfig, CarConfig.PROP_MODEL));
+ compositeCarModel.addMarker(new MandatoryMarker());
+ compositeCarModel.updateFromModel();
+
+ final IMultipleChoiceRidget compositeCarExtras = getRidget(IMultipleChoiceRidget.class, "compositeCarExtras"); //$NON-NLS-1$
+ final String[] labels = { "Front Machine Guns", "Self Destruct Button", "Underwater Package", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "Park Distance Control System", }; //$NON-NLS-1$
+ compositeCarExtras.bindToModel(toList(CarOptions.values()), Arrays.asList(labels), carConfig,
+ CarConfig.PROP_OPTIONS);
+ compositeCarExtras.updateFromModel();
+
+ final ISingleChoiceRidget compositeCarWarranty = getRidget(ISingleChoiceRidget.class, "compositeCarWarranty"); //$NON-NLS-1$
+ compositeCarWarranty.bindToModel(toList(CarWarranties.values()),
+ BeansObservables.observeValue(carConfig, CarConfig.PROP_WARRANTY));
+ compositeCarWarranty.addMarker(new MandatoryMarker());
+ compositeCarWarranty.updateFromModel();
+
+ final IMultipleChoiceRidget compositeCarPlates = getRidget(IMultipleChoiceRidget.class, "compositeCarPlates"); //$NON-NLS-1$
+ compositeCarPlates
+ .bindToModel(toList(carPlates), PojoObservables.observeList(carConfig, CarConfig.PROP_PLATES));
+ compositeCarPlates.addMarker(new MandatoryMarker());
+ compositeCarPlates.updateFromModel();
+
+ final ISingleChoiceRidget compositeColor = getRidget(ISingleChoiceRidget.class, "compositeColor"); //$NON-NLS-1$
+ compositeColor.bindToModel(carConfig, "colors", carConfig, CarConfig.PROP_COLOR); //$NON-NLS-1$
+ compositeColor.updateFromModel();
+
+ final ISingleChoiceRidget compositeSunroof = getRidget(ISingleChoiceRidget.class, "compositeSunroof"); //$NON-NLS-1$
+ final String[] roofLabels = { "yes", "no" }; //$NON-NLS-1$ //$NON-NLS-2$
+ compositeSunroof.bindToModel(toList(new Boolean[] { true, false }), toList(roofLabels), carConfig,
+ CarConfig.PROP_SUNROOF);
+ compositeSunroof.updateFromModel();
+
+ final ITextRidget txtPrice = getRidget(ITextRidget.class, "txtPrice"); //$NON-NLS-1$
+ txtPrice.setOutputOnly(true);
+ final DataBindingContext dbc = new DataBindingContext();
+ dbc.bindValue(BeansObservables.observeValue(txtPrice, ITextRidget.PROPERTY_TEXT),
+ BeansObservables.observeValue(carConfig, CarConfig.PROP_PRICE), null, null);
+
+ final IActionRidget buttonPreset = getRidget(IActionRidget.class, "buttonPreset"); //$NON-NLS-1$
+ buttonPreset.setText("&Quick Config"); //$NON-NLS-1$
+ buttonPreset.addListener(new IActionListener() {
+ public void callback() {
+ compositeCarModel.setSelection(CarModels.BMW);
+ compositeCarExtras.setSelection(Arrays.asList(new CarOptions[] { CarOptions.PDCS }));
+ compositeCarWarranty.setSelection(CarWarranties.EXTENDED);
+ compositeCarPlates.setSelection(Arrays.asList(new String[] { carPlates[0] }));
+ }
+ });
+ final IActionRidget buttonReset = getRidget(IActionRidget.class, "buttonReset"); //$NON-NLS-1$
+
+ buttonReset.setText("&Reset"); //$NON-NLS-1$
+ buttonReset.addListener(new IActionListener() {
+ public void callback() {
+ carConfig.reset();
+ compositeCarModel.updateFromModel();
+ compositeCarExtras.updateFromModel();
+ compositeCarWarranty.updateFromModel();
+ compositeCarPlates.updateFromModel();
+ compositeSunroof.updateFromModel();
+ compositeColor.updateFromModel();
+ }
+ });
+
+ getNavigationNode().addListener(new SubModuleNodeListener() {
+ @Override
+ public void beforeActivated(final ISubModuleNode source) {
+
+ for (final String color : additionalColors) {
+ if (!carConfig.getColors().contains(color)) {
+ carConfig.addColor(color);
+ compositeColor.updateFromModel();
+ break;
+ }
+ }
+ }
+ });
+
+ }
+
+ private WritableList toList(final Object[] values) {
+ return new WritableList(Arrays.asList(values), Object.class);
+ }
+
+ // helping classes
+ // ////////////////
+
+ /**
+ * Bean that holds a single car configuration composed of: model, option(s),
+ * warranty, plate(s).
+ */
+ public static final class CarConfig extends AbstractBean {
+ public static final String PROP_MODEL = "model"; //$NON-NLS-1$
+ public static final String PROP_OPTIONS = "options"; //$NON-NLS-1$
+ public static final String PROP_WARRANTY = "warranty"; //$NON-NLS-1$
+ public static final String PROP_PLATES = "plates"; //$NON-NLS-1$
+ public static final String PROP_PRICE = "price"; //$NON-NLS-1$
+ public static final String PROP_COLOR = "color"; //$NON-NLS-1$
+ public static final String PROP_SUNROOF = "sunroof"; //$NON-NLS-1$
+
+ private CarModels model;
+ private List<CarOptions> options = new ArrayList<CarOptions>();
+ private CarWarranties warranty;
+ private List<String> plates = new ArrayList<String>();
+ private final List<String> colors = new ArrayList<String>();
+ private String color;
+ private boolean sunroof;
+
+ public CarConfig() {
+ addColor("red"); //$NON-NLS-1$
+ addColor("black"); //$NON-NLS-1$
+ addColor("blue"); //$NON-NLS-1$
+ setColor(getColors().get(0));
+ setSunroof(false);
+ }
+
+ public void addColor(final String color) {
+ getColors().add(color);
+ }
+
+ public CarModels getModel() {
+ return model;
+ }
+
+ public void setModel(final CarModels model) {
+ firePropertyChanged(PROP_MODEL, this.model, this.model = model);
+ firePropertyChanged(PROP_PRICE, null, getPrice());
+ }
+
+ public List<CarOptions> getOptions() {
+ return Collections.unmodifiableList(options);
+ }
+
+ public void setOptions(final List<CarOptions> options) {
+ firePropertyChanged(PROP_OPTIONS, this.options, this.options = new ArrayList<CarOptions>(options));
+ firePropertyChanged(PROP_PRICE, null, getPrice());
+ }
+
+ public CarWarranties getWarranty() {
+ return warranty;
+ }
+
+ public void setWarranty(final CarWarranties warranty) {
+ firePropertyChanged(PROP_WARRANTY, this.warranty, this.warranty = warranty);
+ firePropertyChanged(PROP_PRICE, null, getPrice());
+ }
+
+ public List<String> getPlates() {
+ return Collections.unmodifiableList(plates);
+ }
+
+ public void setPlates(final List<String> plates) {
+ firePropertyChanged(PROP_PLATES, this.plates, this.plates = new ArrayList<String>(plates));
+ firePropertyChanged(PROP_PRICE, null, getPrice());
+ }
+
+ public void reset() {
+ setModel(null);
+ setOptions(new ArrayList<CarOptions>());
+ setWarranty(null);
+ setPlates(new ArrayList<String>());
+ setColor(getColors().get(0));
+ setSunroof(false);
+ }
+
+ public long getPrice() {
+ long price = 0;
+ if (model != null) {
+ price += 100000;
+ }
+ price += options.size() * 25000L;
+ if (warranty == CarWarranties.EXTENDED) {
+ price += 10000;
+ }
+ if (isSunroof()) {
+ price += 899;
+ }
+ price += plates.size() * 200L;
+ return price;
+ }
+
+ public void setColor(final String color) {
+ this.color = color;
+ }
+
+ public String getColor() {
+ return color;
+ }
+
+ public List<String> getColors() {
+ return colors;
+ }
+
+ public void setSunroof(final boolean sunroof) {
+ firePropertyChanged(PROP_SUNROOF, this.sunroof, this.sunroof = sunroof);
+ firePropertyChanged(PROP_PRICE, null, getPrice());
+ }
+
+ public boolean isSunroof() {
+ return sunroof;
+ }
+
+ }
+
+ public enum CarModels {
+ ASTON_MARTIN("Aston Martin V-12 Vanquish"), LOTUS("Lotus Esprit Turbo"), BMW("BMW Z8"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ private String label;
+
+ private CarModels(final String label) {
+ Assert.isNotNull(label);
+ this.label = label;
+ }
+
+ @Override
+ public String toString() {
+ return label;
+ }
+ }
+
+ public enum CarOptions {
+ FRONT_GUNS, SELF_DESTRUCT, UNDERWATER, PDCS
+ }
+
+ private enum CarWarranties {
+ STANDARD, EXTENDED;
+
+ @Override
+ public String toString() {
+ final char[] result = super.toString().toLowerCase().toCharArray();
+ result[0] = Character.toUpperCase(result[0]);
+ return String.valueOf(result);
+ }
+ }
+
+ private final String[] carPlates = { "JM5B0ND", "1 SPY", "MNY PNY", "BN D07", "Q RULE2", "MI64EVR" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ChoiceSubModuleControllerTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ChoiceSubModuleControllerTest.java
index 35f2b79..b9b81c3 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ChoiceSubModuleControllerTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ChoiceSubModuleControllerTest.java
@@ -12,9 +12,8 @@ package org.eclipse.riena.client.controller.test;
import java.util.Arrays;
-import org.eclipse.riena.example.client.controllers.ChoiceSubModuleController;
-import org.eclipse.riena.example.client.controllers.ChoiceSubModuleController.CarModels;
-import org.eclipse.riena.example.client.controllers.ChoiceSubModuleController.CarOptions;
+import org.eclipse.riena.client.controller.test.ChoiceSubModuleController.CarModels;
+import org.eclipse.riena.client.controller.test.ChoiceSubModuleController.CarOptions;
import org.eclipse.riena.internal.core.test.collect.NonUITestCase;
import org.eclipse.riena.navigation.ISubModuleNode;
import org.eclipse.riena.navigation.ui.swt.controllers.AbstractSubModuleControllerTest;
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ComboSubModuleController.java b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ComboSubModuleController.java
new file mode 100644
index 0000000..5ed9ce7
--- /dev/null
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ComboSubModuleController.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 compeople AG 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:
+ * compeople AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.riena.client.controller.test;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Iterator;
+
+import org.eclipse.riena.beans.common.Person;
+import org.eclipse.riena.beans.common.PersonFactory;
+import org.eclipse.riena.beans.common.PersonManager;
+import org.eclipse.riena.navigation.ISubModuleNode;
+import org.eclipse.riena.navigation.NavigationArgument;
+import org.eclipse.riena.navigation.listener.SubModuleNodeListener;
+import org.eclipse.riena.navigation.ui.controllers.SubModuleController;
+import org.eclipse.riena.ui.ridgets.IActionListener;
+import org.eclipse.riena.ui.ridgets.IActionRidget;
+import org.eclipse.riena.ui.ridgets.IComboRidget;
+import org.eclipse.riena.ui.ridgets.ITextRidget;
+import org.eclipse.riena.ui.ridgets.IToggleButtonRidget;
+
+/**
+ * Controller for the {@link ComboSubModuleView} example.
+ */
+public class ComboSubModuleController extends SubModuleController {
+
+ /** Manages a collection of persons. */
+ private final PersonManager manager;
+ /** Holds editable data for a person. */
+ private PersonModificationBean value;
+ private IComboRidget comboOne;
+ private ITextRidget textFirst;
+ private ITextRidget textLast;
+
+ public ComboSubModuleController() {
+ this(null);
+ }
+
+ public ComboSubModuleController(final ISubModuleNode navigationNode) {
+ super(navigationNode);
+ manager = new PersonManager(PersonFactory.createPersonList());
+ manager.setSelectedPerson(manager.getPersons().iterator().next());
+ value = new PersonModificationBean();
+ }
+
+ @Override
+ public void afterBind() {
+ super.afterBind();
+ bindModels();
+ }
+
+ private void bindModels() {
+ comboOne.bindToModel(manager, "persons", String.class, null, manager, "selectedPerson"); //$NON-NLS-1$ //$NON-NLS-2$
+ comboOne.updateFromModel();
+
+ textFirst.bindToModel(value, "firstName"); //$NON-NLS-1$
+ textFirst.updateFromModel();
+
+ textLast.bindToModel(value, "lastName"); //$NON-NLS-1$
+ textLast.updateFromModel();
+ }
+
+ @Override
+ public void configureRidgets() {
+
+ comboOne = getRidget(IComboRidget.class, "comboOne"); //$NON-NLS-1$
+
+ value.setPerson(manager.getSelectedPerson());
+
+ textFirst = getRidget(ITextRidget.class, "textFirst"); //$NON-NLS-1$
+ textLast = getRidget(ITextRidget.class, "textLast"); //$NON-NLS-1$
+
+ if (getNavigationNode().getNavigationArgument() != null
+ && getNavigationNode().getNavigationArgument().getParameter() instanceof PersonModificationBean) { // we came here from a navigation
+ setValuesFromNavigation();
+ }
+
+ comboOne.addPropertyChangeListener(IComboRidget.PROPERTY_SELECTION, new PropertyChangeListener() {
+ public void propertyChange(final PropertyChangeEvent evt) {
+ final Person selectedPerson = (Person) evt.getNewValue();
+ value.setPerson(selectedPerson);
+ textFirst.updateFromModel();
+ textLast.updateFromModel();
+ }
+ });
+
+ final IActionRidget buttonSave = getRidget(IActionRidget.class, "buttonSave"); //$NON-NLS-1$
+ buttonSave.setText("&Save"); //$NON-NLS-1$
+ buttonSave.addListener(new IActionListener() {
+ public void callback() {
+ value.update();
+ comboOne.updateFromModel();
+ }
+ });
+
+ final IToggleButtonRidget buttonSecondValue = getRidget("buttonSecondValue"); //$NON-NLS-1$
+ if (buttonSecondValue != null) {
+ buttonSecondValue.setText("Always use second person!"); //$NON-NLS-1$
+ buttonSecondValue.addListener(new IActionListener() {
+ public void callback() {
+ if (buttonSecondValue.isSelected()) {
+ if (manager.getPersons().size() > 1) {
+ final Iterator<Person> iterator = manager.getPersons().iterator();
+ iterator.next();
+ final Person second = iterator.next();
+ manager.setSelectedPerson(second);
+ }
+ comboOne.setOutputOnly(true);
+ } else {
+ comboOne.setOutputOnly(false);
+ }
+ System.out.println("Selected Person: " + manager.getSelectedPerson()); //$NON-NLS-1$
+ comboOne.updateFromModel();
+ }
+ });
+ }
+ getNavigationNode().addListener(new NavigateSubModuleNavigationNodeListener());
+ }
+
+ private void setValuesFromNavigation() {
+ final NavigationArgument navigationArgument = getNavigationNode().getNavigationArgument();
+ if (navigationArgument != null) {
+ value = (PersonModificationBean) navigationArgument.getParameter();
+ manager.setSelectedPerson(value.getPerson());
+ bindModels();
+ }
+ }
+
+ private class NavigateSubModuleNavigationNodeListener extends SubModuleNodeListener {
+ @Override
+ public void afterActivated(final ISubModuleNode source) {
+ super.afterActivated(source);
+ if (getNavigationNode().getNavigationArgument() != null
+ && getNavigationNode().getNavigationArgument().getParameter() instanceof PersonModificationBean) { // we came here from a navigation
+ setValuesFromNavigation();
+ }
+ }
+ }
+}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ComboSubModuleControllerTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ComboSubModuleControllerTest.java
index d4572df..827a5dd 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ComboSubModuleControllerTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ComboSubModuleControllerTest.java
@@ -14,7 +14,6 @@ import java.util.List;
import org.eclipse.riena.beans.common.Person;
import org.eclipse.riena.beans.common.PersonFactory;
-import org.eclipse.riena.example.client.controllers.ComboSubModuleController;
import org.eclipse.riena.internal.core.test.collect.NonUITestCase;
import org.eclipse.riena.navigation.ISubModuleNode;
import org.eclipse.riena.navigation.ui.swt.controllers.AbstractSubModuleControllerTest;
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ControllerTestsPlaygroundSubModuleController.java b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ControllerTestsPlaygroundSubModuleController.java
new file mode 100644
index 0000000..edf8f11
--- /dev/null
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ControllerTestsPlaygroundSubModuleController.java
@@ -0,0 +1,573 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 compeople AG 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:
+ * compeople AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.riena.client.controller.test;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.beans.BeansObservables;
+import org.eclipse.core.databinding.observable.list.WritableList;
+import org.eclipse.core.databinding.observable.value.WritableValue;
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnPixelData;
+
+import org.eclipse.riena.beans.common.AbstractBean;
+import org.eclipse.riena.beans.common.Person;
+import org.eclipse.riena.beans.common.PersonFactory;
+import org.eclipse.riena.beans.common.TypedBean;
+import org.eclipse.riena.core.RienaStatus;
+import org.eclipse.riena.internal.ui.ridgets.swt.CComboRidget;
+import org.eclipse.riena.navigation.ui.controllers.SubModuleController;
+import org.eclipse.riena.ui.core.marker.ValidationTime;
+import org.eclipse.riena.ui.ridgets.AbstractMasterDetailsDelegate;
+import org.eclipse.riena.ui.ridgets.IActionListener;
+import org.eclipse.riena.ui.ridgets.IActionRidget;
+import org.eclipse.riena.ui.ridgets.IBrowserRidget;
+import org.eclipse.riena.ui.ridgets.IComboRidget;
+import org.eclipse.riena.ui.ridgets.IDateTextRidget;
+import org.eclipse.riena.ui.ridgets.IDateTimeRidget;
+import org.eclipse.riena.ui.ridgets.ILabelRidget;
+import org.eclipse.riena.ui.ridgets.ILinkRidget;
+import org.eclipse.riena.ui.ridgets.IListRidget;
+import org.eclipse.riena.ui.ridgets.IMasterDetailsRidget;
+import org.eclipse.riena.ui.ridgets.IMultipleChoiceRidget;
+import org.eclipse.riena.ui.ridgets.IRidgetContainer;
+import org.eclipse.riena.ui.ridgets.ISelectableRidget;
+import org.eclipse.riena.ui.ridgets.ISingleChoiceRidget;
+import org.eclipse.riena.ui.ridgets.ISliderRidget;
+import org.eclipse.riena.ui.ridgets.ISpinnerRidget;
+import org.eclipse.riena.ui.ridgets.ITableRidget;
+import org.eclipse.riena.ui.ridgets.ITextRidget;
+import org.eclipse.riena.ui.ridgets.IToggleButtonRidget;
+import org.eclipse.riena.ui.ridgets.ITraverseRidget;
+import org.eclipse.riena.ui.ridgets.listener.ISelectionListener;
+import org.eclipse.riena.ui.ridgets.listener.SelectionEvent;
+import org.eclipse.riena.ui.ridgets.swt.ImageButtonRidget;
+import org.eclipse.riena.ui.ridgets.validation.NotEmpty;
+import org.eclipse.riena.ui.swt.MasterDetailsComposite;
+
+/**
+ * Example Controller with as many ridgets as possible. Used for controller
+ * testing.
+ */
+public class ControllerTestsPlaygroundSubModuleController extends SubModuleController {
+ private ITableRidget multiTable;
+ private IListRidget tableList;
+ private final Temperature temperature;
+ private final List<Person> input = PersonFactory.createPersonList();
+ private long now;
+ private IToggleButtonRidget selectAllToggleButton;
+ private IActionListener toggleListener;
+ private ISelectionListener multiTableSelectionListener;
+
+ /**
+ *
+ */
+ public ControllerTestsPlaygroundSubModuleController() {
+ temperature = new Temperature();
+ temperature.setKelvin(273.15f, true);
+ }
+
+ @Override
+ public void configureRidgets() {
+ configureTableGroup();
+ configureComboGroup();
+ configureBrowserGroup();
+ configureTraverseGroup();
+ configureMasterDetailsGroup();
+ configureDateTimeGroup();
+ configureImageButtonGroup();
+ //TODO work in progress
+ }
+
+ /**
+ *
+ */
+ private void configureImageButtonGroup() {
+ final IActionRidget imageButton = getRidget(ImageButtonRidget.class, "imageButton"); //$NON-NLS-1$
+ imageButton.setIcon("imageBtn"); //$NON-NLS-1$
+ imageButton.addListener(new IActionListener() {
+ public void callback() {
+ System.out.println("Button klicked..."); //$NON-NLS-1$
+ }
+ });
+
+ final IActionRidget arrowButton = getRidget(ImageButtonRidget.class, "arrowButton"); //$NON-NLS-1$
+ arrowButton.setIcon("arrowRight"); //$NON-NLS-1$
+ arrowButton.addListener(new IActionListener() {
+ public void callback() {
+ System.out.println("Button klicked..."); //$NON-NLS-1$
+ }
+ });
+
+ final IActionRidget arrowHotButton = getRidget(ImageButtonRidget.class, "arrowHotButton"); //$NON-NLS-1$
+ arrowHotButton.setIcon("arrowRight"); //$NON-NLS-1$
+ arrowHotButton.addListener(new IActionListener() {
+ public void callback() {
+ System.out.println("Button klicked..."); //$NON-NLS-1$
+ }
+ });
+ }
+
+ /**
+ *
+ */
+ private void configureDateTimeGroup() {
+ final IDateTimeRidget dtDate = getRidget(IDateTimeRidget.class, "dtDate"); //$NON-NLS-1$
+ final IDateTimeRidget dtTime = getRidget(IDateTimeRidget.class, "dtTime"); //$NON-NLS-1$
+ final IDateTimeRidget dtDateOnly = getRidget(IDateTimeRidget.class, "dtDateOnly"); //$NON-NLS-1$
+ final IDateTimeRidget dtTimeOnly = getRidget(IDateTimeRidget.class, "dtTimeOnly"); //$NON-NLS-1$
+ final IDateTimeRidget dtCal = getRidget(IDateTimeRidget.class, "dtCal"); //$NON-NLS-1$
+ final ITextRidget txt1 = getRidget(ITextRidget.class, "txt1"); //$NON-NLS-1$
+ final ITextRidget txt2 = getRidget(ITextRidget.class, "txt2"); //$NON-NLS-1$
+ final ITextRidget txt3 = getRidget(ITextRidget.class, "txt3"); //$NON-NLS-1$
+ final ITextRidget txt4 = getRidget(ITextRidget.class, "txt4"); //$NON-NLS-1$
+
+ now = System.currentTimeMillis();
+ final TypedBean<Date> date1 = new TypedBean<Date>(new Date(now));
+ final TypedBean<Date> date2 = new TypedBean<Date>(new Date(now));
+ final TypedBean<Date> date3 = new TypedBean<Date>(new Date(now));
+ final TypedBean<Date> date4 = new TypedBean<Date>(new Date(now));
+
+ dtDate.bindToModel(date1, TypedBean.PROP_VALUE);
+ dtDate.updateFromModel();
+ dtTime.bindToModel(date1, TypedBean.PROP_VALUE);
+ dtTime.updateFromModel();
+
+ dtDateOnly.bindToModel(date2, TypedBean.PROP_VALUE);
+ dtDateOnly.updateFromModel();
+
+ dtTimeOnly.bindToModel(date3, TypedBean.PROP_VALUE);
+ dtTimeOnly.updateFromModel();
+
+ dtCal.bindToModel(date4, TypedBean.PROP_VALUE);
+ dtCal.updateFromModel();
+
+ final DataBindingContext dbc = new DataBindingContext();
+ dbc.bindValue(BeansObservables.observeValue(txt1, ITextRidget.PROPERTY_TEXT),
+ BeansObservables.observeValue(date1, TypedBean.PROP_VALUE));
+ dbc.bindValue(BeansObservables.observeValue(txt2, ITextRidget.PROPERTY_TEXT),
+ BeansObservables.observeValue(date2, TypedBean.PROP_VALUE));
+ dbc.bindValue(BeansObservables.observeValue(txt3, ITextRidget.PROPERTY_TEXT),
+ BeansObservables.observeValue(date3, TypedBean.PROP_VALUE));
+ dbc.bindValue(BeansObservables.observeValue(txt4, ITextRidget.PROPERTY_TEXT),
+ BeansObservables.observeValue(date4, TypedBean.PROP_VALUE));
+
+ makeOutputOnly(txt1, txt2, txt3, txt4);
+
+ final IDateTextRidget dateTextRidget = getRidget(IDateTextRidget.class, "dateText"); //$NON-NLS-1$
+ dateTextRidget.setText("03.03.2011"); //$NON-NLS-1$
+ final IActionRidget dateTimeButton = getRidget(IActionRidget.class, "dateTimeButton"); //$NON-NLS-1$
+ dateTimeButton.setText("apply date"); //$NON-NLS-1$
+ dateTimeButton.addListener(new IActionListener() {
+ public void callback() {
+ final DateFormat df = new SimpleDateFormat("dd.MM.yyyy"); //$NON-NLS-1$
+ try {
+ final Date newDate = df.parse(dateTextRidget.getText());
+ dtDate.setDate(newDate);
+ dtDateOnly.setDate(newDate);
+ dtCal.setDate(newDate);
+ } catch (final ParseException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+
+ private void configureMasterDetailsGroup() {
+ final String[] properties = new String[] { "firstname", "lastname" }; //$NON-NLS-1$ //$NON-NLS-2$
+ final String[] headers = new String[] { "First Name", "Last Name" }; //$NON-NLS-1$ //$NON-NLS-2$
+
+ final IMasterDetailsRidget master = getRidget(IMasterDetailsRidget.class, "master"); //$NON-NLS-1$
+ if (master != null) {
+ if (RienaStatus.isTest()) {
+ master.configureRidgets();
+ }
+ master.setDelegate(new PersonDelegate());
+ master.bindToModel(new WritableList(input, Person.class), Person.class, properties, headers);
+ master.updateFromModel();
+
+ final IActionRidget actionApply = master.getRidget(IActionRidget.class,
+ MasterDetailsComposite.BIND_ID_APPLY);
+ addDefaultAction(master, actionApply);
+ }
+
+ final IActionRidget enableDisableButton = getRidget(IActionRidget.class, "enableDisable"); //$NON-NLS-1$
+ if (enableDisableButton != null) {
+ enableDisableButton.addListener(new IActionListener() {
+ public void callback() {
+ if (master != null) {
+ master.setEnabled(!master.isEnabled());
+ }
+ }
+ });
+ }
+ }
+
+ private void configureBrowserGroup() {
+ final ILinkRidget link1 = getRidget(ILinkRidget.class, "link1"); //$NON-NLS-1$
+ link1.setText("<a>http://www.eclipse.org/</a>"); //$NON-NLS-1$
+
+ final ILinkRidget link2 = getRidget(ILinkRidget.class, "link2"); //$NON-NLS-1$
+ link2.setText("Visit <a href=\"http://www.eclipse.org/riena/\">Riena</a>"); //$NON-NLS-1$
+
+ final ILinkRidget link3 = getRidget(ILinkRidget.class, "link3"); //$NON-NLS-1$
+ link3.setText("Eclipse <a href=\"http://planeteclipse.org\">Blogs</a>, <a href=\"http://www.eclipse.org/community/news/\">News</a> and <a href=\"http://live.eclipse.org\">Events</a>"); //$NON-NLS-1$
+
+ final ITextRidget textLinkUrl = getRidget(ITextRidget.class, "textLinkUrl"); //$NON-NLS-1$
+ textLinkUrl.setOutputOnly(true);
+
+ final IBrowserRidget browser = getRidget(IBrowserRidget.class, "browser"); //$NON-NLS-1$
+ browser.bindToModel(textLinkUrl, ITextRidget.PROPERTY_TEXT);
+
+ final ISelectionListener listener = new ISelectionListener() {
+ public void ridgetSelected(final SelectionEvent event) {
+ final String linkUrl = (String) event.getNewSelection().get(0);
+ browser.setUrl(linkUrl);
+ }
+ };
+ link1.addSelectionListener(listener);
+ link2.addSelectionListener(listener);
+ link3.addSelectionListener(listener);
+
+ }
+
+ private void configureComboGroup() {
+ final ITextRidget comboText = getRidget(ITextRidget.class, "comboTextField"); //$NON-NLS-1$
+
+ final List<String> ages = new ArrayList<String>(Arrays.asList(new String[] {
+ "<none>", "young", "moderate", "aged", "old" })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+
+ final ILabelRidget comboLabel = getRidget(ILabelRidget.class, "comboLabel"); //$NON-NLS-1$
+ comboLabel.setText(ages.get(0));
+
+ final IComboRidget comboAge = getRidget(IComboRidget.class, "ageCombo"); //$NON-NLS-1$
+ comboAge.bindToModel(new WritableList(ages, String.class), String.class, null, new WritableValue());
+ comboAge.updateFromModel();
+ comboAge.setEmptySelectionItem("<none>"); //$NON-NLS-1$
+ comboAge.setSelection(0);
+
+ final IComboRidget cComboAge = getRidget(CComboRidget.class, "ageCCombo"); //$NON-NLS-1$
+ cComboAge.bindToModel(new WritableList(ages, String.class), String.class, null, new WritableValue());
+ cComboAge.updateFromModel();
+ cComboAge.setEmptySelectionItem("<none>"); //$NON-NLS-1$
+ cComboAge.setSelection(0);
+
+ final ISelectionListener selectionListener = new ISelectionListener() {
+ public void ridgetSelected(final SelectionEvent event) {
+ comboLabel.setText(event.getNewSelection().get(0).toString());
+ }
+ };
+
+ comboAge.addSelectionListener(selectionListener);
+ cComboAge.addSelectionListener(selectionListener);
+
+ final IActionRidget addToComboButton = getRidget(IActionRidget.class, "addToComboButton"); //$NON-NLS-1$
+ addToComboButton.addListener(new IActionListener() {
+ public void callback() {
+ final String comboString = comboText.getText();
+ if (comboString.length() >= 0) {
+ ages.add(comboString);
+ }
+ comboAge.bindToModel(new WritableList(ages, String.class), String.class, null, new WritableValue());
+ comboAge.updateFromModel();
+ comboAge.setSelection(comboAge.getObservableList().size() - 1);
+ cComboAge.bindToModel(new WritableList(ages, String.class), String.class, null, new WritableValue());
+ cComboAge.updateFromModel();
+ cComboAge.setSelection(comboAge.getObservableList().size() - 1);
+ comboText.setText(""); //$NON-NLS-1$
+ }
+ });
+ }
+
+ private void configureTableGroup() {
+ multiTable = getRidget(ITableRidget.class, "multiTable"); //$NON-NLS-1$
+ final ColumnLayoutData[] widths = { new ColumnPixelData(80, true), new ColumnPixelData(80, true) };
+ multiTable.setColumnWidths(widths);
+ multiTable.setSelectionType(ISelectableRidget.SelectionType.MULTI);
+ final String[] colValues = new String[] { "lastname", "firstname" }; //$NON-NLS-1$ //$NON-NLS-2$
+ final String[] colHeaders = new String[] { "Last Name", "First Name" }; //$NON-NLS-1$ //$NON-NLS-2$
+ multiTable.addDoubleClickListener(new IActionListener() {
+
+ public void callback() {
+ multiTable.getSelection();
+ }
+ });
+ multiTable.bindToModel(createPersonList(), Person.class, colValues, colHeaders);
+ multiTable.updateFromModel();
+
+ tableList = getRidget(IListRidget.class, "tableList"); //$NON-NLS-1$
+
+ tableList.setSelectionType(ISelectableRidget.SelectionType.MULTI);
+
+ selectAllToggleButton = getRidget(IToggleButtonRidget.class, "toggleButton"); //$NON-NLS-1$
+ selectAllToggleButton.setText("select all"); //$NON-NLS-1$
+
+ multiTableSelectionListener = new MultiTableSelectionListener();
+ multiTable.addSelectionListener(multiTableSelectionListener);
+
+ toggleListener = new IActionListener() {
+ public void callback() {
+ multiTable.removeSelectionListener(multiTableSelectionListener);
+ if (selectAllToggleButton.isSelected()) {
+ selectAllToggleButton.setText("deselect"); //$NON-NLS-1$
+ final int[] allIndices = new int[multiTable.getOptionCount()];
+ for (int i = 0; i < multiTable.getOptionCount(); i++) {
+ allIndices[i] = i;
+ }
+ multiTable.setSelection(allIndices);
+ } else {
+ multiTable.clearSelection();
+ selectAllToggleButton.setText("select all"); //$NON-NLS-1$
+ }
+ multiTable.addSelectionListener(multiTableSelectionListener);
+ }
+ };
+ selectAllToggleButton.addListener(toggleListener);
+
+ final IActionRidget copySelectionButton = getRidget(IActionRidget.class, "copySelectionButton"); //$NON-NLS-1$
+ copySelectionButton.addListener(new IActionListener() {
+ public void callback() {
+ final List<Object> selection = multiTable.getSelection();
+ tableList.bindToModel(new WritableList(selection, Person.class), Person.class, "listEntry"); //$NON-NLS-1$
+ tableList.updateFromModel();
+ }
+ });
+
+ }
+
+ private void configureTraverseGroup() {
+ final ISpinnerRidget fahrenheitSpinner = getRidget(ISpinnerRidget.class, "fahrenheitSpinner"); //$NON-NLS-1$
+ final ITraverseRidget celsiusScale = getRidget(ITraverseRidget.class, "celsiusScale"); //$NON-NLS-1$
+ final ISliderRidget kelvinSlider = getRidget(ISliderRidget.class, "kelvinSlider"); //$NON-NLS-1$
+
+ final IActionListener listener = new IActionListener() {
+
+ public void callback() {
+ celsiusScale.updateFromModel();
+ fahrenheitSpinner.updateFromModel();
+ kelvinSlider.updateFromModel();
+ }
+ };
+
+ kelvinSlider.setIncrement(1);
+ kelvinSlider.setMaximum(324);
+ kelvinSlider.setMinimum(273);
+ kelvinSlider.setToolTipText("The current value is: [VALUE] (rounded)."); //$NON-NLS-1$
+ kelvinSlider.bindToModel(BeansObservables.observeValue(temperature, Temperature.PROPERTY_KELVIN));
+ kelvinSlider.updateFromModel();
+ kelvinSlider.addListener(listener);
+
+ fahrenheitSpinner.setIncrement(1);
+ fahrenheitSpinner.setMaximum(122);
+ fahrenheitSpinner.setMinimum(32);
+ fahrenheitSpinner.bindToModel(BeansObservables
+ .observeValue(temperature, Temperature.PROPERTY_DEGREE_FAHRENHEIT));
+ fahrenheitSpinner.updateFromModel();
+ fahrenheitSpinner.addListener(listener);
+
+ celsiusScale.setIncrement(1);
+ celsiusScale.setMaximum(50);
+ celsiusScale.setMinimum(0);
+ celsiusScale.bindToModel(BeansObservables.observeValue(temperature, Temperature.PROPERTY_DEGREE_CELSIUS));
+ celsiusScale.updateFromModel();
+ celsiusScale.addListener(listener);
+ }
+
+ // helpers
+ //////////
+
+ private class Temperature extends AbstractBean {
+
+ static final String PROPERTY_DEGREE_CELSIUS = "degreeCelsius"; //$NON-NLS-1$
+ static final String PROPERTY_DEGREE_FAHRENHEIT = "degreeFahrenheit"; //$NON-NLS-1$
+ static final String PROPERTY_KELVIN = "kelvin"; //$NON-NLS-1$
+
+ private float kelvin;
+ private int degreeCelsius;
+ private int degreeFahrenheit;
+
+ public Temperature() {
+ setDegreeCelsius(0);
+ }
+
+ public void setDegreeCelsius(final int degreeCelsius) {
+ setDegreeCelsius(degreeCelsius, true);
+ }
+
+ private void setDegreeCelsius(final int degreeCelsius, final boolean updateKelvin) {
+ final int oldValue = this.degreeCelsius;
+ this.degreeCelsius = degreeCelsius;
+ if (updateKelvin) {
+ final float k = degreeCelsius + 273.15f;
+ setKelvin(k, false);
+ updateFahrenheit();
+ }
+ firePropertyChanged(PROPERTY_DEGREE_CELSIUS, oldValue, degreeCelsius);
+ }
+
+ @SuppressWarnings("unused")
+ public int getDegreeCelsius() {
+ return degreeCelsius;
+ }
+
+ @SuppressWarnings("unused")
+ public void setDegreeFahrenheit(final int degreeFahrenheit) {
+ setDegreeFahrenheit(degreeFahrenheit, true);
+ }
+
+ private void setDegreeFahrenheit(final int degreeFahrenheit, final boolean updateKelvin) {
+ final int oldValue = this.degreeFahrenheit;
+ this.degreeFahrenheit = degreeFahrenheit;
+ if (updateKelvin) {
+ final float c = (degreeFahrenheit - 32) / 1.8f;
+ final float k = c + 273.15f;
+ setKelvin(k, false);
+ updateCelsius();
+ }
+ firePropertyChanged(PROPERTY_DEGREE_FAHRENHEIT, oldValue, degreeFahrenheit);
+ }
+
+ @SuppressWarnings("unused")
+ public int getDegreeFahrenheit() {
+ return degreeFahrenheit;
+ }
+
+ private void setKelvin(final float kelvin, final boolean updateOthers) {
+ final float oldValue = this.kelvin;
+ this.kelvin = kelvin;
+ if (updateOthers) {
+ updateCelsius();
+ updateFahrenheit();
+ }
+ firePropertyChanged(PROPERTY_KELVIN, oldValue, Math.round(kelvin));
+ }
+
+ @SuppressWarnings("unused")
+ public void setKelvin(final int kelvin) {
+ setKelvin(kelvin, true);
+ }
+
+ public int getKelvin() {
+ return Math.round(kelvin);
+ }
+
+ private void updateCelsius() {
+ final int c = Math.round(getKelvin() - 273.15f);
+ setDegreeCelsius(c, false);
+ }
+
+ private void updateFahrenheit() {
+ final int c = Math.round(getKelvin() - 273.15f);
+ final int f = Math.round(c * 1.8f + 32);
+ setDegreeFahrenheit(f, false);
+ }
+ }
+
+ private class MultiTableSelectionListener implements ISelectionListener {
+ public void ridgetSelected(final SelectionEvent event) {
+ selectAllToggleButton.removeListener(toggleListener);
+ selectAllToggleButton.setSelected(true);
+ selectAllToggleButton.setText("deselect"); //$NON-NLS-1$
+ selectAllToggleButton.addListener(toggleListener);
+ }
+ }
+
+ private WritableList createPersonList() {
+ return new WritableList(PersonFactory.createPersonList(), Person.class);
+ }
+
+ /**
+ * Setup the ridgets for editing a person (text ridgets for name, single
+ * choice ridget for gender, multiple choice ridgets for pets).
+ */
+ private static final class PersonDelegate extends AbstractMasterDetailsDelegate {
+
+ private static final String[] GENDER = { Person.FEMALE, Person.MALE };
+
+ private final Person workingCopy = createWorkingCopy();
+
+ public void configureRidgets(final IRidgetContainer container) {
+ final ITextRidget txtFirst = container.getRidget(ITextRidget.class, "first"); //$NON-NLS-1$
+ txtFirst.setMandatory(true);
+ txtFirst.bindToModel(workingCopy, Person.PROPERTY_FIRSTNAME);
+ txtFirst.updateFromModel();
+
+ final ITextRidget txtLast = container.getRidget(ITextRidget.class, "last"); //$NON-NLS-1$
+ txtLast.setMandatory(true);
+ txtLast.addValidationRule(new NotEmpty(), ValidationTime.ON_UI_CONTROL_EDIT);
+ txtLast.bindToModel(workingCopy, Person.PROPERTY_LASTNAME);
+ txtLast.updateFromModel();
+
+ final ISingleChoiceRidget gender = container.getRidget(ISingleChoiceRidget.class, "gender"); //$NON-NLS-1$
+ if (gender != null) {
+ gender.bindToModel(Arrays.asList(GENDER), (List<String>) null, workingCopy, Person.PROPERTY_GENDER);
+ gender.updateFromModel();
+ }
+
+ final IMultipleChoiceRidget pets = container.getRidget(IMultipleChoiceRidget.class, "pets"); //$NON-NLS-1$
+ if (pets != null) {
+ pets.bindToModel(Arrays.asList(Person.Pets.values()), (List<String>) null, workingCopy,
+ Person.PROPERTY_PETS);
+ pets.updateFromModel();
+ }
+ }
+
+ public Person createWorkingCopy() {
+ return new Person("", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public Person copyBean(final Object source, final Object target) {
+ final Person from = source != null ? (Person) source : createWorkingCopy();
+ final Person to = target != null ? (Person) target : createWorkingCopy();
+ to.setFirstname(from.getFirstname());
+ to.setLastname(from.getLastname());
+ to.setGender(from.getGender());
+ to.setPets(from.getPets());
+ return to;
+ }
+
+ public Object getWorkingCopy() {
+ return workingCopy;
+ }
+
+ @Override
+ public boolean isChanged(final Object source, final Object target) {
+ final Person p1 = (Person) source;
+ final Person p2 = (Person) target;
+ final boolean equals = p1.getFirstname().equals(p2.getFirstname())
+ && p1.getLastname().equals(p2.getLastname()) && p1.getGender().equals(p2.getGender())
+ && p1.getPets().equals(p2.getPets());
+ return !equals;
+ }
+
+ @Override
+ public String isValid(final IRidgetContainer container) {
+ final ITextRidget txtLast = container.getRidget(ITextRidget.class, "last"); //$NON-NLS-1$
+ if (txtLast.isErrorMarked()) {
+ return "'Last Name' is not valid."; //$NON-NLS-1$
+ }
+ return null;
+ }
+ }
+
+ private void makeOutputOnly(final ITextRidget... ridgets) {
+ for (final ITextRidget ridget : ridgets) {
+ ridget.setOutputOnly(true);
+ }
+ }
+}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ControllerTestsPlaygroundSubModuleControllerTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ControllerTestsPlaygroundSubModuleControllerTest.java
index 6c23f5a..cd1ff96 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ControllerTestsPlaygroundSubModuleControllerTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/ControllerTestsPlaygroundSubModuleControllerTest.java
@@ -23,7 +23,6 @@ import org.eclipse.riena.beans.common.Person;
import org.eclipse.riena.beans.common.PersonFactory;
import org.eclipse.riena.beans.common.TypedBean;
import org.eclipse.riena.core.util.ReflectionUtils;
-import org.eclipse.riena.example.client.controllers.ControllerTestsPlaygroundSubModuleController;
import org.eclipse.riena.internal.core.test.collect.NonUITestCase;
import org.eclipse.riena.internal.ui.ridgets.swt.CComboRidget;
import org.eclipse.riena.navigation.ISubModuleNode;
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/HelloDialogController.java b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/HelloDialogController.java
new file mode 100644
index 0000000..998b64a
--- /dev/null
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/HelloDialogController.java
@@ -0,0 +1,234 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 compeople AG 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:
+ * compeople AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.riena.client.controller.test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.beans.BeansObservables;
+import org.eclipse.core.databinding.beans.PojoObservables;
+import org.eclipse.core.databinding.observable.list.WritableList;
+import org.eclipse.core.runtime.Assert;
+
+import org.eclipse.riena.beans.common.AbstractBean;
+import org.eclipse.riena.ui.core.marker.MandatoryMarker;
+import org.eclipse.riena.ui.ridgets.IActionRidget;
+import org.eclipse.riena.ui.ridgets.IMultipleChoiceRidget;
+import org.eclipse.riena.ui.ridgets.ISingleChoiceRidget;
+import org.eclipse.riena.ui.ridgets.ITextRidget;
+import org.eclipse.riena.ui.ridgets.annotation.OnActionCallback;
+import org.eclipse.riena.ui.ridgets.annotation.OnActionCallbacks;
+import org.eclipse.riena.ui.ridgets.controller.AbstractWindowController;
+
+/**
+ * The controller for the hello dialog of the dialog example.
+ */
+public class HelloDialogController extends AbstractWindowController {
+
+ private final String[] carPlates = { "JM5B0ND", "1 SPY", "MNY PNY", "BN D07", "Q RULE2", "MI64EVR" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ private ISingleChoiceRidget compositeCarModel;
+ private ISingleChoiceRidget compositeCarWarranty;
+ private IMultipleChoiceRidget compositeCarPlates;
+ private IMultipleChoiceRidget compositeCarExtras;
+ private CarConfig carConfig;
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void configureRidgets() {
+ super.configureRidgets();
+
+ getWindowRidget().setTitle("James' Car Configurator"); //$NON-NLS-1$
+
+ carConfig = new CarConfig();
+
+ compositeCarModel = getRidget(ISingleChoiceRidget.class, "compositeCarModel"); //$NON-NLS-1$
+ compositeCarModel.bindToModel(toList(CarModels.values()),
+ BeansObservables.observeValue(carConfig, CarConfig.PROP_MODEL));
+ compositeCarModel.addMarker(new MandatoryMarker());
+ compositeCarModel.updateFromModel();
+
+ compositeCarExtras = getRidget(IMultipleChoiceRidget.class, "compositeCarExtras"); //$NON-NLS-1$
+ final String[] labels = { "Front Machine Guns", "Self Destruct Button", "Underwater Package", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "Park Distance Control System", }; //$NON-NLS-1$
+ compositeCarExtras.bindToModel(toList(CarOptions.values()), Arrays.asList(labels), carConfig,
+ CarConfig.PROP_OPTIONS);
+ compositeCarExtras.updateFromModel();
+
+ compositeCarWarranty = getRidget(ISingleChoiceRidget.class, "compositeCarWarranty"); //$NON-NLS-1$
+ compositeCarWarranty.bindToModel(toList(CarWarranties.values()),
+ BeansObservables.observeValue(carConfig, CarConfig.PROP_WARRANTY));
+ compositeCarWarranty.addMarker(new MandatoryMarker());
+ compositeCarWarranty.updateFromModel();
+
+ compositeCarPlates = getRidget(IMultipleChoiceRidget.class, "compositeCarPlates"); //$NON-NLS-1$
+ compositeCarPlates
+ .bindToModel(toList(carPlates), PojoObservables.observeList(carConfig, CarConfig.PROP_PLATES));
+ compositeCarPlates.addMarker(new MandatoryMarker());
+ compositeCarPlates.updateFromModel();
+
+ final ITextRidget txtPrice = getRidget(ITextRidget.class, "txtPrice"); //$NON-NLS-1$
+ txtPrice.setOutputOnly(true);
+ final DataBindingContext dbc = new DataBindingContext();
+ dbc.bindValue(BeansObservables.observeValue(txtPrice, ITextRidget.PROPERTY_TEXT),
+ BeansObservables.observeValue(carConfig, CarConfig.PROP_PRICE), null, null);
+
+ final IActionRidget buttonPreset = getRidget(IActionRidget.class, "buttonPreset"); //$NON-NLS-1$
+ buttonPreset.setText("&Quick Config"); //$NON-NLS-1$
+
+ final IActionRidget buttonReset = getRidget(IActionRidget.class, "buttonReset"); //$NON-NLS-1$
+ buttonReset.setText("&Reset"); //$NON-NLS-1$
+ }
+
+ public CarConfig getCarConfig() {
+ return carConfig;
+ }
+
+ @OnActionCallback(ridgetId = "buttonPreset")
+ public void onPreset() {
+ compositeCarModel.setSelection(CarModels.BMW);
+ compositeCarExtras.setSelection(Arrays.asList(new CarOptions[] { CarOptions.PDCS }));
+ compositeCarWarranty.setSelection(CarWarranties.EXTENDED);
+ compositeCarPlates.setSelection(Arrays.asList(new String[] { carPlates[0] }));
+ }
+
+ @OnActionCallback(ridgetId = "buttonReset")
+ public void onReset() {
+ carConfig.reset();
+ compositeCarModel.updateFromModel();
+ compositeCarExtras.updateFromModel();
+ compositeCarWarranty.updateFromModel();
+ compositeCarPlates.updateFromModel();
+ }
+
+ @SuppressWarnings("unused")
+ @OnActionCallbacks({ @OnActionCallback(ridgetId = "buttonPreset"), @OnActionCallback(ridgetId = "buttonReset") })
+ private void demonstrateMutlipleOnActionCallbacksAnnotation() {
+ System.out.println("Demonstrate multiple @OnActionCallback annotations!"); //$NON-NLS-1$
+ }
+
+ // helping methods
+ // ////////////////
+
+ private WritableList toList(final Object[] values) {
+ return new WritableList(Arrays.asList(values), Object.class);
+ }
+
+ // helping classes
+ // ////////////////
+
+ /**
+ * Bean that holds a single car configuration composed of: model, option(s),
+ * warranty, plate(s).
+ */
+ public static final class CarConfig extends AbstractBean {
+ public static final String PROP_MODEL = "model"; //$NON-NLS-1$
+ public static final String PROP_OPTIONS = "options"; //$NON-NLS-1$
+ public static final String PROP_WARRANTY = "warranty"; //$NON-NLS-1$
+ public static final String PROP_PLATES = "plates"; //$NON-NLS-1$
+ public static final String PROP_PRICE = "price"; //$NON-NLS-1$
+
+ private CarModels model;
+ private List<CarOptions> options = new ArrayList<CarOptions>();
+ private CarWarranties warranty;
+ private List<String> plates = new ArrayList<String>();
+
+ public CarModels getModel() {
+ return model;
+ }
+
+ public void setModel(final CarModels model) {
+ firePropertyChanged(PROP_MODEL, this.model, this.model = model);
+ firePropertyChanged(PROP_PRICE, null, getPrice());
+ }
+
+ public List<CarOptions> getOptions() {
+ return Collections.unmodifiableList(options);
+ }
+
+ public void setOptions(final List<CarOptions> options) {
+ firePropertyChanged(PROP_OPTIONS, this.options, this.options = new ArrayList<CarOptions>(options));
+ firePropertyChanged(PROP_PRICE, null, getPrice());
+ }
+
+ public CarWarranties getWarranty() {
+ return warranty;
+ }
+
+ public void setWarranty(final CarWarranties warranty) {
+ firePropertyChanged(PROP_WARRANTY, this.warranty, this.warranty = warranty);
+ firePropertyChanged(PROP_PRICE, null, getPrice());
+ }
+
+ public List<String> getPlates() {
+ return Collections.unmodifiableList(plates);
+ }
+
+ public void setPlates(final List<String> plates) {
+ firePropertyChanged(PROP_PLATES, this.plates, this.plates = new ArrayList<String>(plates));
+ firePropertyChanged(PROP_PRICE, null, getPrice());
+ }
+
+ public void reset() {
+ setModel(null);
+ setOptions(new ArrayList<CarOptions>());
+ setWarranty(null);
+ setPlates(new ArrayList<String>());
+ }
+
+ public long getPrice() {
+ long price = 0;
+ if (model != null) {
+ price += 100000;
+ }
+ price += options.size() * 25000L;
+ if (warranty == CarWarranties.EXTENDED) {
+ price += 10000;
+ }
+ price += plates.size() * 200L;
+ return price;
+ }
+ }
+
+ public enum CarModels {
+ ASTON_MARTIN("Aston Martin V-12 Vanquish"), LOTUS("Lotus Esprit Turbo"), BMW("BMW Z8"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ private final String label;
+
+ private CarModels(final String label) {
+ Assert.isNotNull(label);
+ this.label = label;
+ }
+
+ @Override
+ public String toString() {
+ return label;
+ }
+ }
+
+ public enum CarOptions {
+ FRONT_GUNS, SELF_DESTRUCT, UNDERWATER, PDCS
+ }
+
+ private enum CarWarranties {
+ STANDARD, EXTENDED;
+
+ @Override
+ public String toString() {
+ final char[] result = super.toString().toLowerCase().toCharArray();
+ result[0] = Character.toUpperCase(result[0]);
+ return String.valueOf(result);
+ }
+ }
+
+}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/HelloDialogControllerTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/HelloDialogControllerTest.java
index 3c09aa3..bc03cbd 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/HelloDialogControllerTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/HelloDialogControllerTest.java
@@ -12,9 +12,8 @@ package org.eclipse.riena.client.controller.test;
import java.util.Arrays;
-import org.eclipse.riena.example.client.controllers.HelloDialogController;
-import org.eclipse.riena.example.client.controllers.HelloDialogController.CarModels;
-import org.eclipse.riena.example.client.controllers.HelloDialogController.CarOptions;
+import org.eclipse.riena.client.controller.test.HelloDialogController.CarModels;
+import org.eclipse.riena.client.controller.test.HelloDialogController.CarOptions;
import org.eclipse.riena.navigation.ISubModuleNode;
import org.eclipse.riena.navigation.ui.swt.controllers.AbstractSubModuleControllerTest;
import org.eclipse.riena.ui.ridgets.IActionRidget;
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/MarkerSubModuleController.java b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/MarkerSubModuleController.java
new file mode 100644
index 0000000..c86dce4
--- /dev/null
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/MarkerSubModuleController.java
@@ -0,0 +1,420 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 compeople AG 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:
+ * compeople AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.riena.client.controller.test;
+
+import java.text.DateFormat;
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+
+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.runtime.IStatus;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+import org.eclipse.riena.beans.common.Person;
+import org.eclipse.riena.beans.common.PersonFactory;
+import org.eclipse.riena.beans.common.TestBean;
+import org.eclipse.riena.beans.common.WordNode;
+import org.eclipse.riena.navigation.INavigationNode;
+import org.eclipse.riena.navigation.model.SimpleNavigationNodeAdapter;
+import org.eclipse.riena.navigation.ui.controllers.SubModuleController;
+import org.eclipse.riena.ui.core.marker.AttentionMarker;
+import org.eclipse.riena.ui.core.marker.ValidationTime;
+import org.eclipse.riena.ui.ridgets.AbstractCompositeRidget;
+import org.eclipse.riena.ui.ridgets.IActionListener;
+import org.eclipse.riena.ui.ridgets.IActionRidget;
+import org.eclipse.riena.ui.ridgets.IComboRidget;
+import org.eclipse.riena.ui.ridgets.ICompositeTableRidget;
+import org.eclipse.riena.ui.ridgets.IDateTextRidget;
+import org.eclipse.riena.ui.ridgets.IDateTimeRidget;
+import org.eclipse.riena.ui.ridgets.IDecimalTextRidget;
+import org.eclipse.riena.ui.ridgets.IGroupedTreeTableRidget;
+import org.eclipse.riena.ui.ridgets.IListRidget;
+import org.eclipse.riena.ui.ridgets.IMarkableRidget;
+import org.eclipse.riena.ui.ridgets.IMultipleChoiceRidget;
+import org.eclipse.riena.ui.ridgets.INumericTextRidget;
+import org.eclipse.riena.ui.ridgets.IRidget;
+import org.eclipse.riena.ui.ridgets.IRowRidget;
+import org.eclipse.riena.ui.ridgets.ISelectableRidget;
+import org.eclipse.riena.ui.ridgets.ISingleChoiceRidget;
+import org.eclipse.riena.ui.ridgets.ITableRidget;
+import org.eclipse.riena.ui.ridgets.ITextRidget;
+import org.eclipse.riena.ui.ridgets.IToggleButtonRidget;
+import org.eclipse.riena.ui.ridgets.ITreeRidget;
+import org.eclipse.riena.ui.ridgets.tree2.ITreeNode;
+import org.eclipse.riena.ui.ridgets.tree2.TreeNode;
+import org.eclipse.riena.ui.ridgets.validation.MinLength;
+import org.eclipse.riena.ui.ridgets.validation.ValidationRuleStatus;
+
+/**
+ * Controller for the {@link MarkerSubModuleView} example.
+ */
+public class MarkerSubModuleController extends SubModuleController {
+
+ /**
+ * @see org.eclipse.riena.ui.ridgets.IRidgetContainer#configureRidgets()
+ */
+ @Override
+ public void configureRidgets() {
+ final ITextRidget textName = getRidget(ITextRidget.class, "textName"); //$NON-NLS-1$
+ textName.setText("Chateau Schaedelbrummer"); //$NON-NLS-1$
+
+ final IDecimalTextRidget textPrice = getRidget(IDecimalTextRidget.class, "textPrice"); //$NON-NLS-1$
+ textPrice.setGrouping(true);
+ textPrice.setText(NumberFormat.getInstance().format(-29.99));
+
+ final INumericTextRidget textAmount = getRidget(INumericTextRidget.class, "textAmount"); //$NON-NLS-1$
+ textAmount.setSigned(false);
+ textAmount.setGrouping(true);
+ textAmount.setText("1001"); //$NON-NLS-1$
+
+ final IDateTextRidget textDate = getRidget(IDateTextRidget.class, "textDate"); //$NON-NLS-1$
+ textDate.setFormat(IDateTextRidget.FORMAT_DDMMYYYY);
+ textDate.setText("04.12.2008"); //$NON-NLS-1$
+
+ final IDateTimeRidget dtDate = getRidget(IDateTimeRidget.class, "dtDate"); //$NON-NLS-1$
+ final DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy"); //$NON-NLS-1$
+ try {
+ final Date date = dateFormat.parse("04.12.2008"); //$NON-NLS-1$
+ dtDate.setDate(date);
+ } catch (final ParseException e) {
+ dtDate.setDate(new Date());
+ }
+
+ final IDateTextRidget dtPicker = getRidget(IDateTextRidget.class, "dtPicker"); //$NON-NLS-1$
+ dtPicker.setFormat(IDateTextRidget.FORMAT_DDMMYYYY);
+ dtPicker.setText("04.12.2008"); //$NON-NLS-1$
+
+ final IComboRidget comboAge = getRidget(IComboRidget.class, "comboAge"); //$NON-NLS-1$
+ final List<String> ages = Arrays.asList(new String[] { "<none>", "young", "moderate", "aged", "old" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ comboAge.bindToModel(new WritableList(ages, String.class), String.class, null, new WritableValue());
+ comboAge.updateFromModel();
+ comboAge.setEmptySelectionItem("<none>"); //$NON-NLS-1$
+ comboAge.setSelection(1);
+
+ final IComboRidget comboStyle = getRidget(IComboRidget.class, "comboStyle"); //$NON-NLS-1$
+ final List<String> styles = Arrays.asList(new String[] {
+ "<none>", "Bordeaux", "Beaujolaix", "Merlot", "Pinot Noire", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ "Syrah" }); //$NON-NLS-1$
+ comboStyle.bindToModel(new WritableList(styles, String.class), String.class, null, new WritableValue());
+ comboStyle.updateFromModel();
+ comboStyle.setEmptySelectionItem("<none>"); //$NON-NLS-1$
+ comboStyle.setSelection(1);
+
+ final IComboRidget comboSize = getRidget(IComboRidget.class, "ccomboSize"); //$NON-NLS-1$
+ final List<String> sizes = Arrays.asList(new String[] { "<none>", "xs", "s", "m", "l", "xl" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ comboSize.bindToModel(new WritableList(sizes, String.class), String.class, null, new WritableValue());
+ comboSize.updateFromModel();
+ comboSize.setEmptySelectionItem("<none>"); //$NON-NLS-1$
+ comboSize.setSelection(1);
+
+ final ISingleChoiceRidget choiceType = getRidget(ISingleChoiceRidget.class, "choiceType"); //$NON-NLS-1$
+ choiceType.bindToModel(Arrays.asList("red", "white", "rose"), (List<String>) null, new TestBean(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ TestBean.PROPERTY);
+ choiceType.updateFromModel();
+ choiceType.setSelection("red"); //$NON-NLS-1$
+
+ final IMultipleChoiceRidget choiceFlavor = getRidget(IMultipleChoiceRidget.class, "choiceFlavor"); //$NON-NLS-1$
+ choiceFlavor.bindToModel(Arrays.asList("dry", "sweet", "sour", "spicy"), (List<String>) null, new TestBean(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ TestBean.PROPERTY);
+ choiceFlavor.updateFromModel();
+ choiceFlavor.setSelection(Arrays.asList("dry", "spicy")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ final IListRidget listPersons = getRidget(IListRidget.class, "listPersons"); //$NON-NLS-1$
+ listPersons.setSelectionType(ISelectableRidget.SelectionType.SINGLE);
+ listPersons.bindToModel(createPersonList(), Person.class, "listEntry"); //$NON-NLS-1$
+ listPersons.updateFromModel();
+
+ final ITableRidget tablePersons = getRidget(ITableRidget.class, "tablePersons"); //$NON-NLS-1$
+ tablePersons.setSelectionType(ISelectableRidget.SelectionType.SINGLE);
+ String[] colValues = new String[] { "lastname", "firstname" }; //$NON-NLS-1$ //$NON-NLS-2$
+ final String[] colHeaders = new String[] { "Last Name", "First Name" }; //$NON-NLS-1$ //$NON-NLS-2$
+ tablePersons.bindToModel(createPersonList(), Person.class, colValues, colHeaders);
+ tablePersons.updateFromModel();
+
+ final ITreeRidget treePersons = getRidget(ITreeRidget.class, "treePersons"); //$NON-NLS-1$
+ treePersons.setSelectionType(ISelectableRidget.SelectionType.SINGLE);
+ treePersons.bindToModel(createTreeRoots(), ITreeNode.class, ITreeNode.PROPERTY_CHILDREN,
+ ITreeNode.PROPERTY_PARENT, ITreeNode.PROPERTY_VALUE);
+ treePersons.updateFromModel();
+
+ final IGroupedTreeTableRidget treeWCols = getRidget(IGroupedTreeTableRidget.class, "treeWCols"); //$NON-NLS-1$
+ treeWCols.setSelectionType(ISelectableRidget.SelectionType.MULTI);
+ treeWCols.setGroupingEnabled(true);
+ colValues = new String[] { "word", "ACount" }; //$NON-NLS-1$ //$NON-NLS-2$
+ final String[] colHeaders2 = new String[] { "Word", "#A" }; //$NON-NLS-1$ //$NON-NLS-2$
+ treeWCols.bindToModel(createTreeTableRoots(), WordNode.class, ITreeNode.PROPERTY_CHILDREN,
+ ITreeNode.PROPERTY_PARENT, colValues, colHeaders2);
+ treeWCols.updateFromModel();
+
+ final IActionRidget buttonPush = getRidget(IActionRidget.class, "buttonPush"); //$NON-NLS-1$
+
+ final IToggleButtonRidget buttonToggleA = getRidget(IToggleButtonRidget.class, "buttonToggleA"); //$NON-NLS-1$
+ final IToggleButtonRidget buttonToggleB = getRidget(IToggleButtonRidget.class, "buttonToggleB"); //$NON-NLS-1$
+ buttonToggleA.setSelected(true);
+
+ final IToggleButtonRidget buttonRadioA = getRidget(IToggleButtonRidget.class, "buttonRadioA"); //$NON-NLS-1$
+ final IToggleButtonRidget buttonRadioB = getRidget(IToggleButtonRidget.class, "buttonRadioB"); //$NON-NLS-1$
+ buttonRadioA.setSelected(true);
+
+ final IToggleButtonRidget buttonCheckA = getRidget(IToggleButtonRidget.class, "buttonCheckA"); //$NON-NLS-1$
+ final IToggleButtonRidget buttonCheckB = getRidget(IToggleButtonRidget.class, "buttonCheckB"); //$NON-NLS-1$
+ buttonCheckA.setSelected(true);
+
+ final IRidget[] markables = new IRidget[] { textName, textPrice, textAmount, textDate, dtDate, dtPicker,
+ comboAge, comboStyle, comboSize, choiceType, choiceFlavor, listPersons, tablePersons, treePersons,
+ treeWCols, buttonToggleA, buttonToggleB, buttonPush, buttonRadioA, buttonRadioB, buttonCheckA,
+ buttonCheckB };
+
+ final IToggleButtonRidget checkMandatory = getRidget(IToggleButtonRidget.class, "checkMandatory"); //$NON-NLS-1$
+ final IToggleButtonRidget checkError = getRidget(IToggleButtonRidget.class, "checkError"); //$NON-NLS-1$
+ final IToggleButtonRidget checkDisabled = getRidget(IToggleButtonRidget.class, "checkDisabled"); //$NON-NLS-1$
+ final IToggleButtonRidget checkOutput = getRidget(IToggleButtonRidget.class, "checkOutput"); //$NON-NLS-1$
+ final IToggleButtonRidget checkHidden = getRidget(IToggleButtonRidget.class, "checkHidden"); //$NON-NLS-1$
+ final IToggleButtonRidget checkHiddenParent = getRidget(IToggleButtonRidget.class, "checkHiddenParent"); //$NON-NLS-1$
+
+ checkMandatory.addListener(new IActionListener() {
+ public void callback() {
+ final boolean isMandatory = checkMandatory.isSelected();
+ for (final IRidget ridget : markables) {
+ if (ridget instanceof IMarkableRidget) {
+ ((IMarkableRidget) ridget).setMandatory(isMandatory);
+ } else {
+ final String name = ridget.getClass().getSimpleName();
+ System.out.println("No mandatory marker support on " + name); //$NON-NLS-1$
+ }
+ }
+ if (isMandatory) {
+ textName.setText(""); //$NON-NLS-1$
+ textPrice.setText(""); //$NON-NLS-1$
+ textAmount.setText(null);
+ textDate.setText(null);
+ dtPicker.setText(null);
+ comboAge.setSelection("<none>"); //$NON-NLS-1$
+ comboStyle.setSelection("<none>"); //$NON-NLS-1$
+ comboSize.setSelection("<none>"); //$NON-NLS-1$
+ choiceType.setSelection(null);
+ choiceFlavor.setSelection(null);
+ listPersons.setSelection((Object) null);
+ tablePersons.setSelection((Object) null);
+ treePersons.setSelection((Object) null);
+ treeWCols.setSelection((Object) null);
+ buttonToggleA.setSelected(false);
+ buttonToggleB.setSelected(false);
+ buttonRadioA.setSelected(false);
+ buttonRadioB.setSelected(false);
+ buttonCheckA.setSelected(false);
+ buttonCheckB.setSelected(false);
+ }
+ }
+ });
+
+ checkError.addListener(new IActionListener() {
+ private final IValidator alwaysWrong = new AlwaysWrongValidator();
+
+ public void callback() {
+ final boolean isError = checkError.isSelected();
+ for (final IRidget ridget : markables) {
+ if (ridget instanceof IMarkableRidget) {
+ ((IMarkableRidget) ridget).setErrorMarked(isError);
+ }
+ }
+ // using this "always wrong" validator for purposes of this
+ // demo. It prevents the error marker being removed from the
+ // text field on the next revalidation (i.e. when the user
+ // types).
+ if (isError) {
+ textName.addValidationRule(alwaysWrong, ValidationTime.ON_UI_CONTROL_EDIT);
+ textPrice.addValidationRule(alwaysWrong, ValidationTime.ON_UI_CONTROL_EDIT);
+ textAmount.addValidationRule(alwaysWrong, ValidationTime.ON_UI_CONTROL_EDIT);
+ textDate.addValidationRule(alwaysWrong, ValidationTime.ON_UI_CONTROL_EDIT);
+ } else {
+ textName.removeValidationRule(alwaysWrong);
+ textPrice.removeValidationRule(alwaysWrong);
+ textAmount.removeValidationRule(alwaysWrong);
+ textDate.removeValidationRule(alwaysWrong);
+ }
+ }
+ });
+
+ checkDisabled.addListener(new DisabledActionListener(markables, checkDisabled));
+ checkOutput.addListener(new OutputActionListener(markables, checkOutput));
+ checkHidden.addListener(new HiddenActionListener(checkHidden, markables));
+ checkHiddenParent.addListener(new HiddenParentActionListener(checkHiddenParent, markables));
+
+ getNavigationNode().addSimpleListener(new SimpleNavigationNodeAdapter() {
+ @Override
+ public void afterActivated(final INavigationNode<?> node) {
+ super.afterDeactivated(node);
+ final Collection<AttentionMarker> markers = node.getMarkersOfType(AttentionMarker.class);
+ for (final AttentionMarker marker : markers) {
+ node.removeMarker(marker);
+ }
+ }
+ });
+
+ final ITextRidget ridget = getRidget(ITextRidget.class, "seite2Text"); //$NON-NLS-1$
+ ridget.addValidationRule(new MinLength(3), ValidationTime.ON_UI_CONTROL_EDIT);
+ }
+
+ // helping methods
+ // ////////////////
+
+ private WritableList createPersonList() {
+ return new WritableList(PersonFactory.createPersonList(), Person.class);
+ }
+
+ private ITreeNode[] createTreeRoots() {
+ final ITreeNode rootA = new TreeNode("A"); //$NON-NLS-1$
+ new TreeNode(rootA, new Person("Albinus", "Albert")); //$NON-NLS-1$ //$NON-NLS-2$
+ new TreeNode(rootA, new Person("Aurelius", "Mark")); //$NON-NLS-1$ //$NON-NLS-2$
+ final ITreeNode rootB = new TreeNode("B"); //$NON-NLS-1$
+ new TreeNode(rootB, new Person("Barker", "Clyve")); //$NON-NLS-1$ //$NON-NLS-2$
+ new TreeNode(rootB, new Person("Barclay", "Bob")); //$NON-NLS-1$ //$NON-NLS-2$
+ return new ITreeNode[] { rootA, rootB };
+ }
+
+ private WordNode[] createTreeTableRoots() {
+ final WordNode rootA = new WordNode("A"); //$NON-NLS-1$
+ final WordNode rootB = new WordNode("B"); //$NON-NLS-1$
+ new WordNode(rootA, "Astoria"); //$NON-NLS-1$
+ new WordNode(rootA, "Ashland"); //$NON-NLS-1$
+ new WordNode(rootA, "Aurora"); //$NON-NLS-1$
+ new WordNode(rootA, "Alpine"); //$NON-NLS-1$
+ new WordNode(rootB, "Boring"); //$NON-NLS-1$
+ new WordNode(rootB, "Bend"); //$NON-NLS-1$
+ new WordNode(rootB, "Beaverton"); //$NON-NLS-1$
+ new WordNode(rootB, "Bridgeport"); //$NON-NLS-1$
+ return new WordNode[] { rootA, rootB };
+ }
+
+ // helping classes
+ // ////////////////
+
+ private static final class DisabledActionListener implements IActionListener {
+
+ private final IRidget[] markables;
+ private final IToggleButtonRidget checkDisabled;
+
+ private DisabledActionListener(final IRidget[] markables, final IToggleButtonRidget checkDisabled) {
+ this.markables = markables;
+ this.checkDisabled = checkDisabled;
+ }
+
+ public void callback() {
+ final boolean isEnabled = !checkDisabled.isSelected();
+ for (final IRidget ridget : markables) {
+ ridget.setEnabled(isEnabled);
+ }
+ }
+
+ }
+
+ private static final class OutputActionListener implements IActionListener {
+
+ private final IRidget[] markables;
+ private final IToggleButtonRidget checkOutput;
+
+ private OutputActionListener(final IRidget[] markables, final IToggleButtonRidget checkOutput) {
+ this.markables = markables;
+ this.checkOutput = checkOutput;
+ }
+
+ public void callback() {
+ final boolean isOutput = checkOutput.isSelected();
+ for (final IRidget ridget : markables) {
+ if (ridget instanceof IMarkableRidget) {
+ ((IMarkableRidget) ridget).setOutputOnly(isOutput);
+ } else {
+ final String name = ridget.getClass().getSimpleName();
+ System.out.println("No output marker support on " + name); //$NON-NLS-1$
+ }
+ }
+ }
+
+ }
+
+ private static final class HiddenActionListener implements IActionListener {
+
+ private final IToggleButtonRidget checkHidden;
+ private final IRidget[] markables;
+
+ private HiddenActionListener(final IToggleButtonRidget checkHidden, final IRidget[] markables) {
+ this.checkHidden = checkHidden;
+ this.markables = markables;
+ }
+
+ public void callback() {
+ final boolean isVisible = !checkHidden.isSelected();
+ for (final IRidget ridget : markables) {
+ ridget.setVisible(isVisible);
+ }
+ }
+
+ }
+
+ private static final class HiddenParentActionListener implements IActionListener {
+
+ private final IToggleButtonRidget checkHiddenParent;
+ private final IRidget[] markables;
+
+ private HiddenParentActionListener(final IToggleButtonRidget checkHiddenParent, final IRidget[] markables) {
+ this.checkHiddenParent = checkHiddenParent;
+ this.markables = markables;
+ }
+
+ public void callback() {
+ final Composite parent = ((Control) markables[0].getUIControl()).getParent();
+ final boolean isVisible = !checkHiddenParent.isSelected();
+ parent.setVisible(isVisible);
+ }
+
+ }
+
+ /**
+ * Validator that always returns an error status.
+ */
+ private static final class AlwaysWrongValidator implements IValidator {
+ public IStatus validate(final Object value) {
+ return ValidationRuleStatus.error(false, ""); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * A row ridget with two text ridgets for use with
+ * {@link ICompositeTableRidget}.
+ */
+ public static final class RowRidget extends AbstractCompositeRidget implements IRowRidget {
+ private Person rowData;
+
+ public void setData(final Object rowData) {
+ this.rowData = (Person) rowData;
+ }
+
+ @Override
+ public void configureRidgets() {
+ final ITextRidget txtLast = getRidget("txtLast"); //$NON-NLS-1$
+ txtLast.bindToModel(rowData, Person.PROPERTY_FIRSTNAME);
+ txtLast.updateFromModel();
+ final ITextRidget txtFirst = getRidget("txtFirst"); //$NON-NLS-1$
+ txtFirst.bindToModel(rowData, Person.PROPERTY_FIRSTNAME);
+ txtFirst.updateFromModel();
+ }
+ }
+
+}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/MarkerSubModuleControllerTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/MarkerSubModuleControllerTest.java
index 3e06780..77b6054 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/MarkerSubModuleControllerTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/MarkerSubModuleControllerTest.java
@@ -17,7 +17,6 @@ import java.util.Locale;
import org.eclipse.riena.beans.common.Person;
import org.eclipse.riena.beans.common.PersonFactory;
-import org.eclipse.riena.example.client.controllers.MarkerSubModuleController;
import org.eclipse.riena.internal.core.test.collect.NonUITestCase;
import org.eclipse.riena.internal.ui.swt.test.TestUtils;
import org.eclipse.riena.navigation.ISubModuleNode;
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/NavigateSubModuleController.java b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/NavigateSubModuleController.java
new file mode 100644
index 0000000..411667d
--- /dev/null
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/NavigateSubModuleController.java
@@ -0,0 +1,256 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 compeople AG 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:
+ * compeople AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.riena.client.controller.test;
+
+import org.eclipse.riena.beans.common.Person;
+import org.eclipse.riena.navigation.ISubModuleNode;
+import org.eclipse.riena.navigation.NavigationArgument;
+import org.eclipse.riena.navigation.NavigationNodeId;
+import org.eclipse.riena.navigation.NodePositioner;
+import org.eclipse.riena.navigation.model.ModuleGroupNode;
+import org.eclipse.riena.navigation.model.ModuleNode;
+import org.eclipse.riena.navigation.model.SubApplicationNode;
+import org.eclipse.riena.navigation.ui.controllers.SubModuleController;
+import org.eclipse.riena.ui.ridgets.IActionListener;
+import org.eclipse.riena.ui.ridgets.IActionRidget;
+
+/**
+ * Controller of a sub module to demonstrate the navigate method of
+ * {@code INavigationNode}.
+ */
+public class NavigateSubModuleController extends SubModuleController {
+
+ public NavigateSubModuleController() {
+ this(null);
+ }
+
+ public NavigateSubModuleController(final ISubModuleNode navigationNode) {
+ super(navigationNode);
+ }
+
+ @Override
+ public void configureRidgets() {
+
+ final IActionRidget comboAndList = getRidget(IActionRidget.class, "comboAndList"); //$NON-NLS-1$
+ comboAndList.setText("Combo and List (async) (SubApplication 1)"); //$NON-NLS-1$
+ comboAndList.addListener(new ComboAndListListener());
+
+ final IActionRidget tableTextAndTree = getRidget(IActionRidget.class, "tableTextAndTree"); //$NON-NLS-1$
+ tableTextAndTree.setText("Table, Text and Tree (async) (SubApplication 2) [First Position]"); //$NON-NLS-1$
+ tableTextAndTree.addListener(new TableTextAndTreeListener());
+
+ final IActionRidget textAssembly = getRidget(IActionRidget.class, "textAssembly"); //$NON-NLS-1$
+ textAssembly.setText("Text Assembly (SubApplication 1)"); //$NON-NLS-1$
+ textAssembly.addListener(new TextAssemblyListener());
+
+ final IActionRidget openAsFirstModule = getRidget(IActionRidget.class, "openAsFirstModule"); //$NON-NLS-1$
+ openAsFirstModule.setText("Open Module As First"); //$NON-NLS-1$
+ openAsFirstModule.addListener(new OpenModuleAsFirstListener());
+
+ final IActionRidget openAsFirstSubModule = getRidget(IActionRidget.class, "openAsFirstSubModule"); //$NON-NLS-1$
+ openAsFirstSubModule.setText("Open SubModule As FIRST in 'Combo And List'"); //$NON-NLS-1$
+ openAsFirstSubModule.addListener(new OpenSubModuleAsFirstListener());
+
+ final IActionRidget openAsThirdSubModule = getRidget(IActionRidget.class, "openAsThirdSubModule"); //$NON-NLS-1$
+ openAsThirdSubModule.setText("Open SubModule As THIRD in 'Combo And List'"); //$NON-NLS-1$
+ openAsThirdSubModule.addListener(new OpenSubModuleAsThirdListener());
+
+ final IActionRidget openAsOrdinal10 = getRidget(IActionRidget.class, "openAsOrdinal10"); //$NON-NLS-1$
+ openAsOrdinal10.setText("Open SubModule with ORDINAL index 10"); //$NON-NLS-1$
+ openAsOrdinal10.addListener(new OpenSubModuleOrdinal10Listener());
+
+ final IActionRidget openAsOrdinal5 = getRidget(IActionRidget.class, "openAsOrdinal5"); //$NON-NLS-1$
+ openAsOrdinal5.setText("Open SubModule with ORDINAL index 5"); //$NON-NLS-1$
+ openAsOrdinal5.addListener(new OpenSubModuleOrdinal5Listener());
+
+ final IActionRidget addToModule = getRidget(IActionRidget.class, "addToModule"); //$NON-NLS-1$
+ addToModule.setText("Add SubModule to current Module at index 2"); //$NON-NLS-1$
+ addToModule.addListener(new AddSubModuleToCurrentModule());
+
+ final IActionRidget moveModule = getRidget(IActionRidget.class, "moveModule"); //$NON-NLS-1$
+ moveModule.setText("Move Active Module"); //$NON-NLS-1$
+ moveModule.addListener(new MoveActiveModule());
+
+ final IActionRidget moveInActiveModule = getRidget(IActionRidget.class, "moveInActiveModule"); //$NON-NLS-1$
+ moveInActiveModule.setText("Move Inactive Module"); //$NON-NLS-1$
+ moveInActiveModule.addListener(new MoveInActiveModule());
+
+ final IActionRidget moduleJump = getRidget(IActionRidget.class, "jumpToTargetModule"); //$NON-NLS-1$
+ moduleJump.setText("Jump To Module"); //$NON-NLS-1$
+ moduleJump.addListener(new JumpToTargetModule());
+
+ final IActionRidget subModuleJump = getRidget(IActionRidget.class, "jumpToTargetSubModule"); //$NON-NLS-1$
+ subModuleJump.setText("Jump To SubModule"); //$NON-NLS-1$
+ subModuleJump.addListener(new JumpToTargetSubModule());
+
+ final IActionRidget validation = getRidget(IActionRidget.class, "validation"); //$NON-NLS-1$
+ validation.setText("Validation"); //$NON-NLS-1$
+ validation.addListener(new ValidationListener());
+
+ final PersonModificationBean bean = new PersonModificationBean();
+ bean.setPerson(new Person("Doe", "Jane")); //$NON-NLS-1$ //$NON-NLS-2$
+ final IActionRidget navigateRidget = getRidget(IActionRidget.class, "btnNavigateToRidget"); //$NON-NLS-1$
+ navigateRidget.addListener(new IActionListener() {
+ public void callback() {
+ getNavigationNode().navigate(new NavigationNodeId("org.eclipse.riena.example.combo"), //$NON-NLS-1$
+ new NavigationArgument(bean, "textFirst")); //$NON-NLS-1$
+
+ }
+ });
+ }
+
+ private class ComboAndListListener implements IActionListener {
+
+ public void callback() {
+ final NavigationArgument naviAgr = new NavigationArgument(new Integer(2));
+ getNavigationNode().navigate(
+ new NavigationNodeId("org.eclipse.riena.example.navigate.comboAndList"), naviAgr); //$NON-NLS-1$
+ }
+
+ }
+
+ private class TableTextAndTreeListener implements IActionListener {
+
+ public void callback() {
+ final NavigationArgument naviAgr = new NavigationArgument();
+ naviAgr.setNodePositioner(NodePositioner.ADD_BEGINNING);
+ getNavigationNode().createAsync(
+ new NavigationNodeId("org.eclipse.riena.example.navigate.tableTextAndTree"), naviAgr); //$NON-NLS-1$
+ }
+
+ }
+
+ private class OpenModuleAsFirstListener implements IActionListener {
+
+ public void callback() {
+ final NavigationArgument naviAgr = new NavigationArgument();
+ naviAgr.setNodePositioner(NodePositioner.ADD_BEGINNING);
+ getNavigationNode().navigate(
+ new NavigationNodeId("org.eclipse.riena.example.navigate.firstmodule"), naviAgr); //$NON-NLS-1$
+
+ }
+
+ }
+
+ private class OpenSubModuleAsFirstListener implements IActionListener {
+
+ public void callback() {
+ final NavigationArgument naviAgr = new NavigationArgument();
+ naviAgr.setNodePositioner(NodePositioner.ADD_BEGINNING);
+ getNavigationNode().navigate(
+ new NavigationNodeId("org.eclipse.riena.example.navigate.firstSubModule"), naviAgr); //$NON-NLS-1$
+
+ }
+
+ }
+
+ private class OpenSubModuleAsThirdListener implements IActionListener {
+
+ public void callback() {
+ final NavigationArgument naviAgr = new NavigationArgument();
+ naviAgr.setNodePositioner(NodePositioner.indexed(2));
+ getNavigationNode().navigate(
+ new NavigationNodeId("org.eclipse.riena.example.navigate.thirdSubModule"), naviAgr); //$NON-NLS-1$
+
+ }
+
+ }
+
+ private class OpenSubModuleOrdinal10Listener implements IActionListener {
+
+ public void callback() {
+ final NavigationArgument naviAgr = new NavigationArgument();
+ naviAgr.setNodePositioner(NodePositioner.ordinal(10));
+ getNavigationNode().navigate(
+ new NavigationNodeId("org.eclipse.riena.example.navigate.ordinal10SubModule"), naviAgr); //$NON-NLS-1$
+
+ }
+
+ }
+
+ private class OpenSubModuleOrdinal5Listener implements IActionListener {
+
+ public void callback() {
+ final NavigationArgument naviAgr = new NavigationArgument();
+ naviAgr.setNodePositioner(NodePositioner.ordinal(5));
+ getNavigationNode().navigate(
+ new NavigationNodeId("org.eclipse.riena.example.navigate.ordinal5SubModule"), naviAgr); //$NON-NLS-1$
+
+ }
+
+ }
+
+ private class AddSubModuleToCurrentModule implements IActionListener {
+
+ private int instanceId = 1;
+
+ public void callback() {
+ final NavigationArgument naviAgr = new NavigationArgument();
+ naviAgr.setNodePositioner(NodePositioner.indexed(2));
+ getNavigationNode()
+ .create(new NavigationNodeId(
+ "org.eclipse.riena.example.navigate.submoduleToModuleAtIndex2", String.valueOf(instanceId++)), naviAgr); //$NON-NLS-1$
+
+ }
+
+ }
+
+ private class MoveActiveModule implements IActionListener {
+
+ public void callback() {
+ getNavigationNode().getParentOfType(ModuleNode.class).moveTo(
+ new NavigationNodeId("org.eclipse.riena.example.moduleGroup1.1.1")); //$NON-NLS-1$
+
+ }
+ }
+
+ private class MoveInActiveModule implements IActionListener {
+
+ public void callback() {
+ final ModuleNode moduleNode = (ModuleNode) getNavigationNode().getParentOfType(SubApplicationNode.class)
+ .findNode(new NavigationNodeId("org.eclipse.riena.example.module.1.1.1")); //$NON-NLS-1$
+ moduleNode.moveTo(getNavigationNode().getParentOfType(ModuleGroupNode.class).getNodeId());
+ }
+ }
+
+ private class JumpToTargetSubModule implements IActionListener {
+
+ public void callback() {
+ getNavigationNode().jump(new NavigationNodeId("4"));
+
+ }
+ }
+
+ private class JumpToTargetModule implements IActionListener {
+
+ public void callback() {
+ getNavigationNode().jump(new NavigationNodeId("test"));
+
+ }
+ }
+
+ private class TextAssemblyListener implements IActionListener {
+
+ public void callback() {
+ getNavigationNode().navigate(new NavigationNodeId("org.eclipse.riena.example.client.textExamplesGroup")); //$NON-NLS-1$
+ }
+
+ }
+
+ private class ValidationListener implements IActionListener {
+
+ public void callback() {
+ getNavigationNode().navigate(new NavigationNodeId("org.eclipse.riena.example.validation")); //$NON-NLS-1$
+ }
+
+ }
+
+}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/NavigateSubModuleControllerTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/NavigateSubModuleControllerTest.java
index 41a6bd6..1c5e445 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/NavigateSubModuleControllerTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/NavigateSubModuleControllerTest.java
@@ -17,9 +17,7 @@ import java.util.Comparator;
import org.easymock.LogicalOperator;
import org.eclipse.riena.beans.common.Person;
-import org.eclipse.riena.example.client.controllers.NavigateSubModuleController;
import org.eclipse.riena.internal.core.test.collect.NonUITestCase;
-import org.eclipse.riena.internal.example.client.beans.PersonModificationBean;
import org.eclipse.riena.navigation.INavigationNode;
import org.eclipse.riena.navigation.ISubModuleNode;
import org.eclipse.riena.navigation.NavigationArgument;
@@ -154,8 +152,7 @@ public class NavigateSubModuleControllerTest extends AbstractSubModuleController
.andReturn(createNavigationNode("org.eclipse.riena.example.navigate.firstmodule"));
replay(getMockNavigationProcessor());
- final IActionRidget navigateFirstModule = getController().getRidget(IActionRidget.class,
- "openAsFirstModule");
+ final IActionRidget navigateFirstModule = getController().getRidget(IActionRidget.class, "openAsFirstModule");
navigateFirstModule.fireAction();
verify(getMockNavigationProcessor());
}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/NavigationSubModuleController.java b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/NavigationSubModuleController.java
new file mode 100644
index 0000000..3073935
--- /dev/null
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/NavigationSubModuleController.java
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 compeople AG 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:
+ * compeople AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.riena.client.controller.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.riena.core.RienaStatus;
+import org.eclipse.riena.navigation.IApplicationNode;
+import org.eclipse.riena.navigation.IModuleGroupNode;
+import org.eclipse.riena.navigation.IModuleNode;
+import org.eclipse.riena.navigation.INavigationNode;
+import org.eclipse.riena.navigation.ISubApplicationNode;
+import org.eclipse.riena.navigation.ISubModuleNode;
+import org.eclipse.riena.navigation.NavigationNodeId;
+import org.eclipse.riena.navigation.model.ModuleGroupNode;
+import org.eclipse.riena.navigation.model.ModuleNode;
+import org.eclipse.riena.navigation.model.SubModuleNode;
+import org.eclipse.riena.navigation.ui.controllers.ApplicationController;
+import org.eclipse.riena.navigation.ui.controllers.SubModuleController;
+import org.eclipse.riena.ui.ridgets.IActionListener;
+import org.eclipse.riena.ui.ridgets.IActionRidget;
+
+/**
+ * This controller adds dynamically nodes to the navigation.
+ */
+public class NavigationSubModuleController extends SubModuleController {
+
+ private IActionRidget addSubModuleToModuleBtn;
+ private IActionRidget addSubModuleToSelfBtn;
+ private IActionRidget removeSubModuleBtn;
+ private IActionRidget addModuleBtn;
+ private IActionRidget addModuleGroupBtn;
+
+ private static int nodeCount = 0;
+
+ public NavigationSubModuleController() {
+ this(null);
+ }
+
+ /**
+ * @param navigationNode
+ */
+ public NavigationSubModuleController(final ISubModuleNode navigationNode) {
+ super(navigationNode);
+ }
+
+ /**
+ * Binds and updates the ridgets.<br>
+ * Sets texts and adds action listeners.
+ *
+ * @see org.eclipse.riena.ui.ridgets.IRidgetContainer#configureRidgets()
+ */
+ @Override
+ public void configureRidgets() {
+ addSubModuleToModuleBtn = getRidget(IActionRidget.class, "addSubModuleToModuleBtn"); //$NON-NLS-1$
+ addSubModuleToModuleBtn.setText("Add Sub-Module to &Root"); //$NON-NLS-1$
+ addSubModuleToModuleBtn.addListener(new IActionListener() {
+ public void callback() {
+ final ISubModuleNode newNode = createSubModuleNode("Node " + String.valueOf(nodeCount++)); //$NON-NLS-1$
+ final IModuleNode parent = getParentNodeOfType(getNavigationNode(), IModuleNode.class);
+ parent.setNodeId(new NavigationNodeId("org.eclipse.riena.example.navigate.root")); //$NON-NLS-1$
+ parent.addChild(newNode);
+ showStatusLineMessage("Sub-Module was added!"); //$NON-NLS-1$
+ }
+
+ });
+
+ addSubModuleToSelfBtn = getRidget(IActionRidget.class, "addSubModuleToSelfBtn"); //$NON-NLS-1$
+ addSubModuleToSelfBtn.setText("Add S&ub-Module this Node"); //$NON-NLS-1$
+ addSubModuleToSelfBtn.addListener(new IActionListener() {
+ public void callback() {
+ final ISubModuleNode navigationNode = getNavigationNode();
+ final ISubModuleNode subModule = createSubModuleNode("Node " + String.valueOf(nodeCount++)); //$NON-NLS-1$
+ navigationNode.addChild(subModule);
+ subModule.activate();
+ showStatusLineMessage("Sub-Module was added!"); //$NON-NLS-1$
+ }
+ });
+
+ removeSubModuleBtn = getRidget(IActionRidget.class, "removeSubModuleBtn"); //$NON-NLS-1$
+ removeSubModuleBtn.setText("Remove all children"); //$NON-NLS-1$
+ removeSubModuleBtn.addListener(new IActionListener() {
+ public void callback() {
+ final ISubModuleNode navigationNode = getNavigationNode();
+ final List<ISubModuleNode> children = new ArrayList<ISubModuleNode>(navigationNode.getChildren());
+ for (final ISubModuleNode child : children) {
+ child.dispose();
+ }
+ if (children.size() > 0) {
+ showStatusLineMessage("All children removed!"); //$NON-NLS-1$
+ }
+ }
+ });
+
+ addModuleBtn = getRidget(IActionRidget.class, "addModuleBtn"); //$NON-NLS-1$
+ addModuleBtn.setText("Add &Module"); //$NON-NLS-1$
+ addModuleBtn.addListener(new IActionListener() {
+ public void callback() {
+ final IModuleGroupNode parent = getParentNodeOfType(getNavigationNode(), IModuleGroupNode.class);
+ parent.addChild(createModuleNode());
+ showStatusLineMessage("Module was added!"); //$NON-NLS-1$
+ }
+ });
+
+ addModuleGroupBtn = getRidget(IActionRidget.class, "addModuleGroupBtn"); //$NON-NLS-1$
+ addModuleGroupBtn.setText("Add Module-&Group"); //$NON-NLS-1$
+ addModuleGroupBtn.addListener(new IActionListener() {
+ public void callback() {
+ final ISubApplicationNode parent = getParentNodeOfType(getNavigationNode(), ISubApplicationNode.class);
+ parent.addChild(createModuleGroupNode());
+ showStatusLineMessage("Module-Group was added!"); //$NON-NLS-1$
+ }
+ });
+ }
+
+ private void showStatusLineMessage(final String text) {
+ if (!RienaStatus.isTest()) {
+ getApplicationController().getStatusline().setMessage(text);
+ }
+ }
+
+ private <N extends INavigationNode<?>> N getParentNodeOfType(final INavigationNode<?> node, final Class<N> clazz) {
+ return node.getParentOfType(clazz);
+ }
+
+ /**
+ * Creates a new module group and adds a new module to the group.
+ *
+ * @return module group
+ */
+ private IModuleGroupNode createModuleGroupNode() {
+
+ final NavigationNodeId nodeId = new NavigationNodeId("moduleGroup", Integer.toString(++nodeCount)); //$NON-NLS-1$
+ final IModuleGroupNode newModuleGroupNode = new ModuleGroupNode(nodeId);
+ newModuleGroupNode.setLabel("ModuleGroup"); //$NON-NLS-1$
+ final IModuleNode newModuleNode = createModuleNode();
+ newModuleGroupNode.addChild(newModuleNode);
+
+ return newModuleGroupNode;
+ }
+
+ /**
+ * Creates a new module and adds a new sub-module to the module.
+ *
+ * @return module
+ */
+ private IModuleNode createModuleNode() {
+
+ final NavigationNodeId nodeId = new NavigationNodeId("module", Integer.toString(++nodeCount)); //$NON-NLS-1$
+ final IModuleNode newModuleNode = new ModuleNode(nodeId, "Module"); //$NON-NLS-1$
+ final ISubModuleNode newSubModuleNode = createSubModuleNode("SubModule"); //$NON-NLS-1$
+ newModuleNode.addChild(newSubModuleNode);
+ return newModuleNode;
+ }
+
+ /**
+ * Creates a new sub-module with the given label.
+ *
+ * @param label
+ * label of the sub-module
+ * @return sub-module
+ */
+ private ISubModuleNode createSubModuleNode(final String label) {
+
+ final ISubModuleNode newSubModuleNode = new SubModuleNode(new NavigationNodeId(
+ "org.eclipse.riena.example.navigation", Integer.toString(nodeCount)), label); //$NON-NLS-1$
+ return newSubModuleNode;
+
+ }
+
+ /**
+ * Returns the controller of the parent sub-application.
+ *
+ * @return sub-application controller
+ */
+ private ApplicationController getApplicationController() {
+ return (ApplicationController) getNavigationNode().getParentOfType(IApplicationNode.class)
+ .getNavigationNodeController();
+ }
+
+}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/NavigationSubModuleControllerTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/NavigationSubModuleControllerTest.java
index 9cc3437..8d14797 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/NavigationSubModuleControllerTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/NavigationSubModuleControllerTest.java
@@ -12,7 +12,6 @@ package org.eclipse.riena.client.controller.test;
import org.easymock.EasyMock;
-import org.eclipse.riena.example.client.controllers.NavigationSubModuleController;
import org.eclipse.riena.internal.core.test.collect.NonUITestCase;
import org.eclipse.riena.navigation.ISubModuleNode;
import org.eclipse.riena.navigation.NavigationNodeId;
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/PersonModificationBean.java b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/PersonModificationBean.java
new file mode 100644
index 0000000..621ba03
--- /dev/null
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/PersonModificationBean.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 compeople AG 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:
+ * compeople AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.riena.client.controller.test;
+
+import org.eclipse.riena.beans.common.Person;
+
+/**
+ * This beans allows editing of a {@link Person} without immediately changing
+ * it. Modifications to the first and last name are stored in the bean and are
+ * only applied to the Person after invoking {@link #update()}.
+ */
+public final class PersonModificationBean {
+
+ private Person person;
+
+ private String first;
+ private String last;
+
+ public String getFirstName() {
+ return person == null ? "" : person.getFirstname(); //$NON-NLS-1$
+ }
+
+ public void setFirstName(final String first) {
+ this.first = first;
+ }
+
+ public String getLastName() {
+ return person == null ? "" : person.getLastname(); //$NON-NLS-1$
+ }
+
+ public void setLastName(final String last) {
+ this.last = last;
+ }
+
+ public Person getPerson() {
+ return person;
+ }
+
+ public void setPerson(final Person person) {
+ this.person = person;
+ first = getFirstName();
+ last = getLastName();
+ }
+
+ public void update() {
+ if (person != null) {
+ person.setFirstname(first);
+ person.setLastname(last);
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((person == null) ? 0 : person.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final PersonModificationBean other = (PersonModificationBean) obj;
+ if (person == null) {
+ if (other.person != null) {
+ return false;
+ }
+ } else if (!person.equals(other.person)) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/TableSubModuleController.java b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/TableSubModuleController.java
new file mode 100644
index 0000000..09ed81b
--- /dev/null
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/TableSubModuleController.java
@@ -0,0 +1,233 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 compeople AG 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:
+ * compeople AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.riena.client.controller.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.beans.BeansObservables;
+import org.eclipse.core.databinding.observable.list.WritableList;
+import org.eclipse.core.databinding.observable.value.ComputedValue;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.riena.beans.common.TypedComparator;
+import org.eclipse.riena.beans.common.WordNode;
+import org.eclipse.riena.navigation.ISubModuleNode;
+import org.eclipse.riena.navigation.ui.controllers.SubModuleController;
+import org.eclipse.riena.ui.ridgets.IActionListener;
+import org.eclipse.riena.ui.ridgets.IActionRidget;
+import org.eclipse.riena.ui.ridgets.IRidget;
+import org.eclipse.riena.ui.ridgets.ISelectableRidget;
+import org.eclipse.riena.ui.ridgets.ITableRidget;
+import org.eclipse.riena.ui.ridgets.IToggleButtonRidget;
+import org.eclipse.riena.ui.ridgets.listener.ISelectionListener;
+import org.eclipse.riena.ui.ridgets.listener.SelectionEvent;
+import org.eclipse.riena.ui.ridgets.swt.ColumnFormatter;
+import org.eclipse.riena.ui.ridgets.swt.NumberColumnFormatter;
+import org.eclipse.riena.ui.swt.StatusMeter;
+
+/**
+ * Controller for the {@link TableSubModuleView} example.
+ */
+public class TableSubModuleController extends SubModuleController {
+
+ private IActionRidget buttonRename;
+ private ITableRidget table;
+ private List<WordNode> input;
+
+ private Color green;
+ private Color darkGreen;
+
+ public TableSubModuleController() {
+ this(null);
+
+ final Display display = Display.getCurrent();
+ green = display.getSystemColor(SWT.COLOR_GREEN);
+ darkGreen = display.getSystemColor(SWT.COLOR_DARK_GREEN);
+ }
+
+ public TableSubModuleController(final ISubModuleNode navigationNode) {
+ super(navigationNode);
+ }
+
+ /**
+ * @see org.eclipse.riena.navigation.ui.controllers.SubModuleController#afterBind()
+ */
+ @Override
+ public void afterBind() {
+ super.afterBind();
+ // bindModel();
+ }
+
+ private void bindModel() {
+ input = createInput();
+ final String[] columnPropertyNames = { "AQuota", "word", "upperCase", "ACount", "AQuota" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ final String[] columnHeaders = { "S", "Word", "Uppercase", "A Count", "A Quota [%]" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ table.bindToModel(new WritableList(input, WordNode.class), WordNode.class, columnPropertyNames, columnHeaders);
+ table.updateFromModel();
+ table.setComparator(1, new TypedComparator<String>());
+ table.setComparator(2, new TypedComparator<Boolean>());
+ table.setColumnFormatter(4, new NumberColumnFormatter(Float.class, 2) {
+ @Override
+ protected Number getValue(final Object element) {
+ return ((WordNode) element).getAQuota();
+ }
+ });
+ table.setColumnSortable(3, false);
+ table.setSelectionType(ISelectableRidget.SelectionType.SINGLE);
+ table.setSelection(0);
+
+ table.setColumnFormatter(0, new ColumnFormatter() {
+ @Override
+ public String getText(final Object element) {
+ return ""; //$NON-NLS-1$
+ }
+
+ @Override
+ public Image getImage(final Object element) {
+ if (((WordNode) element).isUpperCase()) {
+ return StatusMeter.imageFinished().width(16).gradientStartColor(green).gradientEndColor(darkGreen)
+ .getImage();
+ } else {
+ final int value = (int) ((WordNode) element).getAQuota();
+ return StatusMeter.imageDefault().width(16).value(value).getImage();
+ }
+ }
+ });
+ }
+
+ /**
+ * @see org.eclipse.riena.ui.ridgets.IRidgetContainer#configureRidgets()
+ */
+ @Override
+ public void configureRidgets() {
+ table = getRidget(ITableRidget.class, "table"); //$NON-NLS-1$
+ final IToggleButtonRidget buttonPrintSelection = getRidget(IToggleButtonRidget.class, "buttonPrintSelection"); //$NON-NLS-1$
+ final IActionRidget buttonAddSibling = getRidget(IActionRidget.class, "buttonAddSibling"); //$NON-NLS-1$
+ buttonRename = getRidget(IActionRidget.class, "buttonRename"); //$NON-NLS-1$
+ final IActionRidget buttonDelete = getRidget(IActionRidget.class, "buttonDelete"); //$NON-NLS-1$
+
+ table.addDoubleClickListener(new IActionListener() {
+ public void callback() {
+ final WordNode node = (WordNode) table.getSingleSelectionObservable().getValue();
+ if (node != null) {
+ final boolean isUpperCase = !node.isUpperCase();
+ node.setUpperCase(isUpperCase);
+ }
+ }
+ });
+
+ table.addSelectionListener(new ISelectionListener() {
+ public void ridgetSelected(final SelectionEvent event) {
+ if (buttonPrintSelection.isSelected()) {
+ System.out.println(event);
+ }
+ }
+ });
+
+ buttonPrintSelection.setText("&Echo Selection"); //$NON-NLS-1$
+ buttonPrintSelection.setSelected(true);
+
+ buttonAddSibling.setText("&Add"); //$NON-NLS-1$
+ buttonAddSibling.addListener(new IActionListener() {
+ public void callback() {
+ final WordNode newNode = new WordNode("A_NEW_SIBLING"); //$NON-NLS-1$
+ input.add(newNode);
+ table.updateFromModel();
+ table.setSelection(newNode);
+ }
+ });
+
+ buttonRename.setText("&Modify"); //$NON-NLS-1$
+ buttonRename.addListener(new IActionListener() {
+ public void callback() {
+ final WordNode node = (WordNode) table.getSingleSelectionObservable().getValue();
+ if (node != null) {
+ final String newValue = getNewValue(node.getWordIgnoreUppercase());
+ if (newValue != null) {
+ node.setWord(newValue);
+ }
+ }
+ }
+ });
+
+ buttonDelete.setText("&Delete"); //$NON-NLS-1$
+ buttonDelete.addListener(new IActionListener() {
+ public void callback() {
+ final WordNode node = (WordNode) table.getSingleSelectionObservable().getValue();
+ input.remove(node);
+ table.updateFromModel();
+ }
+ });
+
+ final IObservableValue viewerSelection = table.getSingleSelectionObservable();
+ final IObservableValue hasSelection = new ComputedValue(Boolean.TYPE) {
+ @Override
+ protected Object calculate() {
+ return Boolean.valueOf(viewerSelection.getValue() != null);
+ }
+ };
+ final DataBindingContext dbc = new DataBindingContext();
+ bindEnablementToValue(dbc, buttonDelete, hasSelection);
+ bindEnablementToValue(dbc, buttonRename, hasSelection);
+
+ bindModel();
+ }
+
+ private void bindEnablementToValue(final DataBindingContext dbc, final IRidget ridget, final IObservableValue value) {
+ dbc.bindValue(BeansObservables.observeValue(ridget, IRidget.PROPERTY_ENABLED), value, null, null);
+ }
+
+ private String getNewValue(final Object oldValue) {
+ String newValue = null;
+ if (oldValue != null) {
+ final Shell shell = ((Button) buttonRename.getUIControl()).getShell();
+ final IInputValidator validator = new IInputValidator() {
+ public String isValid(final String newText) {
+ final boolean isValid = newText.trim().length() > 0;
+ return isValid ? null : "Word cannot be empty!"; //$NON-NLS-1$
+ }
+ };
+ final InputDialog dialog = new InputDialog(shell, "Modify", "Enter a new word:", String.valueOf(oldValue), //$NON-NLS-1$ //$NON-NLS-2$
+ validator);
+ final int result = dialog.open();
+ if (result == Window.OK) {
+ newValue = dialog.getValue();
+ }
+ }
+ return newValue;
+ }
+
+ private List<WordNode> createInput() {
+ final String[] words = { "Adventure", "Acclimatisation", "Aardwark", "Binoculars", "Beverage", "Boredom", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ "Ballistics", "Calculation", "Coexistence", "Cinnamon", "Celebration", "Disney", "Dictionary", "Delta", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
+ "Desperate", "Elf", "Electronics", "Elwood", "Enemy" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ final ArrayList<WordNode> result = new ArrayList<WordNode>(words.length);
+ for (final String word : words) {
+ final WordNode node = new WordNode(word);
+ result.add(node);
+ }
+ result.get(0).setUpperCase(true);
+ result.get(1).setUpperCase(true);
+ return result;
+ }
+
+}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/TableSubModuleControllerTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/TableSubModuleControllerTest.java
index 66f00cb..d7f1bcd 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/TableSubModuleControllerTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/client/controller/test/TableSubModuleControllerTest.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.riena.client.controller.test;
-import org.eclipse.riena.example.client.controllers.TableSubModuleController;
import org.eclipse.riena.internal.core.test.collect.NonUITestCase;
import org.eclipse.riena.navigation.ISubModuleNode;
import org.eclipse.riena.navigation.ui.swt.controllers.AbstractSubModuleControllerTest;