summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Drossel2009-03-27 11:15:24 (EDT)
committerCarsten Drossel2009-03-27 11:15:24 (EDT)
commitfc3635de14d28d1a7d8aa5f9c9033a41e21a90fe (patch)
treeea959f7382647a141c50024c2bbb10c08e2d0540
parent8eb7389900b7dd6a6d3331e7ffaf185907b59428 (diff)
downloadorg.eclipse.riena-fc3635de14d28d1a7d8aa5f9c9033a41e21a90fe.zip
org.eclipse.riena-fc3635de14d28d1a7d8aa5f9c9033a41e21a90fe.tar.gz
org.eclipse.riena-fc3635de14d28d1a7d8aa5f9c9033a41e21a90fe.tar.bz2
added an example how a List widget can be replaced by a Table widget (one column, no header, no lines) to improve look&feel (e.g. change background color)
-rw-r--r--org.eclipse.riena.example.client/plugin.xml5
-rw-r--r--org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/ListSubModuleController.java3
-rw-r--r--org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/navigation/model/PlaygroundNodeAssembler.java7
-rw-r--r--org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/views/ListSubModuleView.java14
-rw-r--r--org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/views/ListUsingTableSubModuleView.java70
5 files changed, 92 insertions, 7 deletions
diff --git a/org.eclipse.riena.example.client/plugin.xml b/org.eclipse.riena.example.client/plugin.xml
index d2d489b..796c367 100644
--- a/org.eclipse.riena.example.client/plugin.xml
+++ b/org.eclipse.riena.example.client/plugin.xml
@@ -78,6 +78,11 @@
name="org.eclipse.riena.example.client.views.ListSubModuleView">
</view>
<view allowMultiple="true"
+ class="org.eclipse.riena.example.client.views.ListUsingTableSubModuleView"
+ id="org.eclipse.riena.example.client.views.ListUsingTableSubModuleView"
+ name="org.eclipse.riena.example.client.views.ListUsingTableSubModuleView">
+ </view>
+ <view allowMultiple="true"
class="org.eclipse.riena.example.client.views.TextSubModuleView"
id="org.eclipse.riena.example.client.views.TextSubModuleView"
name="org.eclipse.riena.example.client.views.TextSubModuleView">
diff --git a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/ListSubModuleController.java b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/ListSubModuleController.java
index c7a0530..34112f5 100644
--- a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/ListSubModuleController.java
+++ b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/controllers/ListSubModuleController.java
@@ -17,6 +17,7 @@ import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.core.databinding.observable.value.ComputedValue;
import org.eclipse.core.databinding.observable.value.IObservableValue;
+
import org.eclipse.riena.beans.common.Person;
import org.eclipse.riena.beans.common.PersonFactory;
import org.eclipse.riena.beans.common.PersonManager;
@@ -66,7 +67,7 @@ public class ListSubModuleController extends SubModuleController {
listPersons.setSelectionType(ISelectableRidget.SelectionType.SINGLE);
listPersons.setComparator(0, new TypedComparator<String>());
listPersons.setSortedColumn(0);
- listPersons.bindToModel(manager, "persons", Person.class, new String[] { "listEntry" }, new String[] { "" }); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ listPersons.bindToModel(manager, "persons", Person.class, new String[] { "listEntry" }, null); //$NON-NLS-1$//$NON-NLS-2$
listPersons.updateFromModel();
listPersons.bindSingleSelectionToModel(manager, PersonManager.PROPERTY_SELECTED_PERSON);
diff --git a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/navigation/model/PlaygroundNodeAssembler.java b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/navigation/model/PlaygroundNodeAssembler.java
index e4530ea..feace10 100644
--- a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/navigation/model/PlaygroundNodeAssembler.java
+++ b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/navigation/model/PlaygroundNodeAssembler.java
@@ -43,6 +43,7 @@ import org.eclipse.riena.example.client.views.CompositeTableSubModuleView;
import org.eclipse.riena.example.client.views.DialogSubModuleView;
import org.eclipse.riena.example.client.views.FocusableSubModuleView;
import org.eclipse.riena.example.client.views.ListSubModuleView;
+import org.eclipse.riena.example.client.views.ListUsingTableSubModuleView;
import org.eclipse.riena.example.client.views.MarkerSubModuleView;
import org.eclipse.riena.example.client.views.MasterDetailsSubModuleView;
import org.eclipse.riena.example.client.views.MasterDetailsSubModuleView2;
@@ -133,6 +134,12 @@ public class PlaygroundNodeAssembler extends AbstractNavigationAssembler {
workarea.registerDefinition(listSubModule, ListSubModuleController.class, ListSubModuleView.ID, false);
playgroundModule.addChild(listSubModule);
+ ISubModuleNode listUsingTableSubModule = new SubModuleNode(new NavigationNodeId(
+ "org.eclipse.riena.example.listUsingTable"), "List (using Table)"); //$NON-NLS-1$ //$NON-NLS-2$
+ workarea.registerDefinition(listUsingTableSubModule, ListSubModuleController.class,
+ ListUsingTableSubModuleView.ID, false);
+ playgroundModule.addChild(listUsingTableSubModule);
+
ISubModuleNode markerSubModule = new SubModuleNode(
new NavigationNodeId("org.eclipse.riena.example.marker"), "Marker"); //$NON-NLS-1$ //$NON-NLS-2$
workarea.registerDefinition(markerSubModule, MarkerSubModuleController.class, MarkerSubModuleView.ID, false);
diff --git a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/views/ListSubModuleView.java b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/views/ListSubModuleView.java
index e63c622..66416f7 100644
--- a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/views/ListSubModuleView.java
+++ b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/views/ListSubModuleView.java
@@ -11,11 +11,6 @@
package org.eclipse.riena.example.client.views;
import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.riena.example.client.controllers.ListSubModuleController;
-import org.eclipse.riena.navigation.ui.swt.views.SubModuleView;
-import org.eclipse.riena.ui.swt.lnf.LnfKeyConstants;
-import org.eclipse.riena.ui.swt.lnf.LnfManager;
-import org.eclipse.riena.ui.swt.utils.UIControlsFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -24,6 +19,12 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.riena.example.client.controllers.ListSubModuleController;
+import org.eclipse.riena.navigation.ui.swt.views.SubModuleView;
+import org.eclipse.riena.ui.swt.lnf.LnfKeyConstants;
+import org.eclipse.riena.ui.swt.lnf.LnfManager;
+import org.eclipse.riena.ui.swt.utils.UIControlsFactory;
+
/**
* SWT {@link IListRidget} sample.
*/
@@ -46,7 +47,7 @@ public class ListSubModuleView extends SubModuleView<ListSubModuleController> {
// helping methods
// ////////////////
- private Group createListGroup(Composite parent) {
+ protected Group createListGroup(Composite parent) {
Group group = UIControlsFactory.createGroup(parent, "&Persons:"); //$NON-NLS-1$
group.setLayout(new GridLayout(2, true));
@@ -79,6 +80,7 @@ public class ListSubModuleView extends SubModuleView<ListSubModuleController> {
UIControlsFactory.createLabel(group, "&First Name:"); //$NON-NLS-1$
Text textFirst = UIControlsFactory.createText(group);
+
fillFactory.applyTo(textFirst);
addUIControl(textFirst, "textFirst"); //$NON-NLS-1$
diff --git a/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/views/ListUsingTableSubModuleView.java b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/views/ListUsingTableSubModuleView.java
new file mode 100644
index 0000000..45f31b2
--- /dev/null
+++ b/org.eclipse.riena.example.client/src/org/eclipse/riena/example/client/views/ListUsingTableSubModuleView.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 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.example.client.views;
+
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.TableColumnLayout;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+import org.eclipse.riena.ui.swt.utils.UIControlsFactory;
+
+/**
+ * Experimental view using a single column Table instead of a List. This
+ * improves look&feel by using the default background color for the list rather
+ * than white. But if the list is sorted the background color is different under
+ * some MS Windows versions to highlight the sorted column...
+ */
+public class ListUsingTableSubModuleView extends ListSubModuleView {
+
+ public static final String ID = ListUsingTableSubModuleView.class.getName();
+
+ @Override
+ protected Group createListGroup(Composite parent) {
+ Group group = UIControlsFactory.createGroup(parent, "&Persons:"); //$NON-NLS-1$
+ group.setLayout(new GridLayout(2, true));
+
+ Composite tableComposite = new Composite(group, SWT.NONE);
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(tableComposite);
+ int style = SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.NO_BACKGROUND;
+ final Table listPersons = new Table(tableComposite, style);
+ listPersons.setLinesVisible(false);
+ TableColumn listColumn = new TableColumn(listPersons, SWT.LEFT);
+ TableColumnLayout layout = new TableColumnLayout();
+ layout.setColumnData(listColumn, new ColumnWeightData(1, false));
+ tableComposite.setLayout(layout);
+
+ GridDataFactory.fillDefaults().grab(false, true).span(2, 1).applyTo(tableComposite);
+ addUIControl(listPersons, "listPersons"); //$NON-NLS-1$
+
+ Button buttonSort = UIControlsFactory.createButtonCheck(group);
+ GridDataFactory.fillDefaults().grab(false, true).span(2, 1).applyTo(buttonSort);
+ addUIControl(buttonSort, "buttonSort"); //$NON-NLS-1$
+
+ Button buttonAdd = UIControlsFactory.createButton(group);
+ addUIControl(buttonAdd, "buttonAdd"); //$NON-NLS-1$
+ int xHint = UIControlsFactory.getWidthHint(buttonAdd);
+ GridDataFactory.fillDefaults().hint(xHint, SWT.DEFAULT).applyTo(buttonAdd);
+
+ Button buttonRemove = UIControlsFactory.createButton(group);
+ addUIControl(buttonRemove, "buttonRemove"); //$NON-NLS-1$
+ xHint = UIControlsFactory.getWidthHint(buttonRemove);
+ GridDataFactory.fillDefaults().hint(xHint, SWT.DEFAULT).applyTo(buttonRemove);
+
+ return group;
+ }
+}