Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 42873 Details for
Bug 144260
[DataBinding] CellEditor support for TableViewer
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
CellEditor support
patch.txt (text/plain), 70.00 KB, created by
Brad Reynolds
on 2006-05-29 12:19:17 EDT
(
hide
)
Description:
CellEditor support
Filename:
MIME Type:
Creator:
Brad Reynolds
Created:
2006-05-29 12:19:17 EDT
Size:
70.00 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jface.databinding >Index: src/org/eclipse/jface/internal/databinding/internal/swt/TextObservableValue.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/swt/TextObservableValue.java,v >retrieving revision 1.2.4.4 >diff -u -r1.2.4.4 TextObservableValue.java >--- src/org/eclipse/jface/internal/databinding/internal/swt/TextObservableValue.java 14 May 2006 19:10:40 -0000 1.2.4.4 >+++ src/org/eclipse/jface/internal/databinding/internal/swt/TextObservableValue.java 29 May 2006 16:07:58 -0000 >@@ -11,10 +11,13 @@ > package org.eclipse.jface.internal.databinding.internal.swt; > > import org.eclipse.jface.internal.databinding.provisional.observable.Diffs; >+import org.eclipse.jface.internal.databinding.provisional.observable.IObservable; > import org.eclipse.jface.internal.databinding.provisional.observable.value.AbstractVetoableValue; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.KeyEvent; > import org.eclipse.swt.events.KeyListener; >+import org.eclipse.swt.events.TraverseEvent; >+import org.eclipse.swt.events.TraverseListener; > import org.eclipse.swt.events.VerifyEvent; > import org.eclipse.swt.events.VerifyListener; > import org.eclipse.swt.widgets.Event; >@@ -22,62 +25,191 @@ > import org.eclipse.swt.widgets.Text; > > /** >- * @since 1.0 >+ * {@link IObservable} implementation that manages the binding of a model >+ * property to a {@link Text} widget. The time at which communication of the >+ * value change event is specified by the consumer on construction. >+ * >+ * <dl> >+ * <dt>Events:</dt> >+ * <dd> If the update event type (specified on construction) is >+ * <code>SWT.Modify</code> a value change event will be fired on every key >+ * stroke. If the update event type is <code>SWT.FocusOut</code> a value >+ * change event will be fired on focus out. When in either mode if the user is >+ * entering text and presses [Escape] the value will be reverted back to the >+ * previous, unedited, model value. Regardless of the update event type a value >+ * changing event will fire on verify.</dd> >+ * </dl> >+ * >+ * <p> >+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as >+ * part of a work in progress. There is no guarantee that this API will remain >+ * unchanged during the 3.2 release cycle. Please do not use this API without >+ * consulting with the Platform/UI team. >+ * </p> > * >+ * @since 1.0 > */ > public class TextObservableValue extends AbstractVetoableValue { >- >+ /** >+ * {@link Text} widget that this is being observed. >+ */ > private final Text text; > >+ /** >+ * Flag to track when the model is updating the widget. When >+ * <code>true</code> the handlers for the SWT events should not process >+ * the event as this would cause an infinite loop. >+ */ > private boolean updating = false; > >- private int updatePolicy; >+ /** >+ * SWT event that on firing this observable will fire change events in an >+ * attempt to update the model. >+ */ >+ private final int updateEventType; >+ >+ /** >+ * Valid types for the {@link #updateEventType}. >+ */ >+ private static final int[] validUpdateEventTypes = new int[] { SWT.Modify, >+ SWT.FocusOut, SWT.NONE }; > >+ /** >+ * Previous value from the model. It is maintained so that when entering >+ * text if the consumer were to press [Escape] the value can be reverted >+ * back to the last known model value. >+ */ > private String bufferedValue; > >- private Listener updateListener = new Listener() { >- public void handleEvent(Event event) { >- if (!updating) { >- String oldValue = bufferedValue; >- String newValue = text.getText(); >- >- // If we are updating on focus lost then when we fire the change >- // event change the buffered value >- if (updatePolicy == SWT.FocusOut) { >- bufferedValue = text.getText(); >+ private Listener updateListener; >+ >+ private VerifyListener verifyListener; >+ >+ private KeyListener keyListener; >+ >+ private TraverseListener traverseListener; >+ >+ /** >+ * Private constructor for constructing a new instance. >+ * >+ * @param text >+ * @param updateEventType >+ * -1 if not specified >+ * @param traversalDetail >+ * -1 if not specified >+ * @throws IllegalArgumentException if both <code>updateEventType</code> and <code>traverseEventType</code> == -1. >+ * @throws IllegalArgumentException if <code>updateEventType</code> is unsupported >+ */ >+ private TextObservableValue(final Text text, final int updateEventType, >+ final int traversalDetail) { >+ if (text == null) { >+ throw new NullPointerException("Parameter " + text + " was null."); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ if (updateEventType == -1 && traversalDetail == -1) { >+ throw new IllegalArgumentException( >+ "Update event type or traversal event must be set."); //$NON-NLS-1$ >+ } >+ >+ if (updateEventType > -1) { >+ boolean eventValid = false; >+ for (int i = 0; !eventValid && i < validUpdateEventTypes.length; i++) { >+ eventValid = (updateEventType == validUpdateEventTypes[i]); >+ } >+ if (!eventValid) { >+ throw new IllegalArgumentException( >+ "UpdateEventType [" + updateEventType + "] is unsupported."); //$NON-NLS-1$//$NON-NLS-2$ >+ } >+ >+ setupLifecycleHandling(text, updateEventType); >+ } >+ >+ if (traversalDetail > -1) { >+ setupTraverseHandling(text, traversalDetail); >+ } >+ >+ this.text = text; >+ this.updateEventType = updateEventType; >+ >+ keyListener = new KeyListener() { >+ public void keyPressed(KeyEvent e) { >+ if (e.character == SWT.ESC && bufferedValue != null) { >+ // Revert the value in the text field to the model value >+ text.setText(bufferedValue); >+ } >+ } >+ >+ public void keyReleased(KeyEvent e) { >+ } >+ }; >+ text.addKeyListener(keyListener); >+ } >+ >+ /** >+ * Performs setup for firing value change events on traversal. >+ * >+ * @param text >+ * @param traverseEventTypes >+ */ >+ private void setupTraverseHandling(final Text text, >+ final int traverseEventTypes) { >+ traverseListener = new TraverseListener() { >+ public void keyTraversed(TraverseEvent e) { >+ if ((e.detail & traverseEventTypes) != 0) { >+ String oldValue = bufferedValue; >+ String newValue = text.getText(); >+ > if (!newValue.equals(oldValue)) { > fireValueChange(Diffs.createValueDiff(oldValue, > newValue)); > } >- } else { >- fireValueChange(Diffs.createValueDiff(oldValue, text >- .getText())); > } > } >- } >- }; >- >- private VerifyListener verifyListener; >- >- private KeyListener keyListener; >+ }; >+ text.addTraverseListener(traverseListener); >+ } > > /** >+ * Performs validation and setup for listeners of lifecycle events like >+ * modify and focus out. >+ * > * @param text >- * @param updatePolicy >+ * @param event >+ * @param updateListener > */ >- public TextObservableValue(final Text text, int updatePolicy) { >- this.text = text; >- this.updatePolicy = updatePolicy; >- if (updatePolicy != SWT.None) { >- text.addListener(updatePolicy, updateListener); >+ private void setupLifecycleHandling(final Text text, int event) { >+ if (event != SWT.None) { >+ updateListener = new Listener() { >+ public void handleEvent(Event event) { >+ if (!updating) { >+ String oldValue = bufferedValue; >+ String newValue = text.getText(); >+ >+ // If we are updating on focus lost then when we fire >+ // the change >+ // event change the buffered value >+ if (updateEventType == SWT.FocusOut) { >+ bufferedValue = text.getText(); >+ if (!newValue.equals(oldValue)) { >+ fireValueChange(Diffs.createValueDiff(oldValue, >+ newValue)); >+ } >+ } else { >+ fireValueChange(Diffs.createValueDiff(oldValue, >+ text.getText())); >+ } >+ } >+ } >+ }; >+ text.addListener(event, updateListener); > } >- // If the update policy is TIME_EARLY then the model is notified of >+ // If the update policy is SWT.Modify then the model is notified of > // changed on key stroke by key stroke > // When escape is pressed we need to rollback to the previous value > // which is done with a key listener, however > // the bufferedValue (the last remembered change value) must be changed > // on focus lost >- if (updatePolicy == SWT.Modify) { >+ if (event == SWT.Modify) { > text.addListener(SWT.FocusOut, new Listener() { > public void handleEvent(Event event) { > if (!updating) { >@@ -101,20 +233,33 @@ > } > }; > text.addVerifyListener(verifyListener); >- keyListener = new KeyListener() { >- public void keyPressed(KeyEvent e) { >- if (e.character == SWT.ESC && bufferedValue != null) { >- // Revert the value in the text field to the model value >- text.setText(bufferedValue); >- } >- } >+ } > >- public void keyReleased(KeyEvent e) { >- } >- }; >- text.addKeyListener(keyListener); >+ /** >+ * Constructs a new instance bound to <code>text</code> and configured to >+ * fire change events at the time of the <code>updateEventType</code>. >+ * >+ * @param text >+ * @param updateEventType >+ * SWT event constant as to what SWT event to update the model in >+ * response to. Appropriate values are: <code>SWT.Modify</code>, >+ * <code>SWT.FocusOut</code>, <code>SWT.NONE</code>. >+ * @throws IllegalArgumentException >+ * if <code>updateEventType</code> is an incorrect type. >+ */ >+ public TextObservableValue(final Text text, final int updateEventType) { >+ this(text, updateEventType, -1); > } > >+ /** >+ * Sets the bound {@link Text Text's} text to the passed <code>value</code>. >+ * >+ * @param value >+ * new value, String expected >+ * @see org.eclipse.jface.internal.databinding.provisional.observable.value.AbstractVetoableValue#doSetValue(java.lang.Object) >+ * @throws ClassCastException >+ * if the value is anything other than a String >+ */ > public void doSetValue(final Object value) { > try { > updating = true; >@@ -135,12 +280,35 @@ > > public void dispose() { > if (!text.isDisposed()) { >- text.removeKeyListener(keyListener); >- if (updatePolicy != SWT.None) { >- text.removeListener(updatePolicy, updateListener); >+ if (keyListener != null) { >+ text.removeKeyListener(keyListener); >+ } >+ if (updateListener != null) { >+ text.removeListener(updateEventType, updateListener); >+ } >+ >+ if (verifyListener != null) { >+ text.removeVerifyListener(verifyListener); >+ } >+ >+ if (traverseListener != null) { >+ text.removeTraverseListener(traverseListener); > } >- text.removeVerifyListener(verifyListener); > } > super.dispose(); > } >+ >+ /** >+ * Constructs a TextObservableValue whose update policy is defined for >+ * traversal events rather than lifecycle events like Modify and FocusOut. >+ * >+ * @param text >+ * @param details >+ * traversal detail values or'd "|" together >+ * @return TextObservableValue >+ */ >+ public static TextObservableValue asTraversalObservable(Text text, >+ int details) { >+ return new TextObservableValue(text, -1, details); >+ } > } >Index: src/org/eclipse/jface/internal/databinding/provisional/viewers/ViewersObservableFactory.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/viewers/ViewersObservableFactory.java,v >retrieving revision 1.4 >diff -u -r1.4 ViewersObservableFactory.java >--- src/org/eclipse/jface/internal/databinding/provisional/viewers/ViewersObservableFactory.java 17 Mar 2006 07:30:01 -0000 1.4 >+++ src/org/eclipse/jface/internal/databinding/provisional/viewers/ViewersObservableFactory.java 29 May 2006 16:07:58 -0000 >@@ -10,6 +10,7 @@ > *******************************************************************************/ > package org.eclipse.jface.internal.databinding.provisional.viewers; > >+import org.eclipse.jface.internal.databinding.internal.swt.TextObservableValue; > import org.eclipse.jface.internal.databinding.internal.viewers.AbstractListViewerObservableCollectionWithLabels; > import org.eclipse.jface.internal.databinding.internal.viewers.StructuredViewerObservableValue; > import org.eclipse.jface.internal.databinding.internal.viewers.TableViewerObservableCollectionWithLabels; >@@ -17,8 +18,12 @@ > import org.eclipse.jface.internal.databinding.provisional.factories.IObservableFactory; > import org.eclipse.jface.internal.databinding.provisional.observable.IObservable; > import org.eclipse.jface.viewers.AbstractListViewer; >+import org.eclipse.jface.viewers.CellEditor; > import org.eclipse.jface.viewers.StructuredViewer; > import org.eclipse.jface.viewers.TableViewer; >+import org.eclipse.jface.viewers.TextCellEditor; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.widgets.Text; > > /** > * A factory that supports binding to JFace viewers. This factory supports the >@@ -36,6 +41,7 @@ > * ViewersProperties.CONTENT</li> > * </ul> > * </li> >+ * <li>TextCellEditor</li> > * </ul> > * TODO complete the list > * >@@ -85,7 +91,22 @@ > } else if (description instanceof TableViewer) { > return new TableViewerObservableCollectionWithLabels( > (TableViewer) description); >+ >+ } else if (description instanceof CellEditor) { >+ CellEditor editor = (CellEditor) description; >+ >+ if (editor.getControl() == null) { >+ throw new IllegalArgumentException( >+ "The CellEditor's control has not been constructed. The editor must have a control to bind. Use the editor contructor that accepts a parent."); //$NON-NLS-1$ >+ } >+ >+ if (description instanceof TextCellEditor) { >+ return TextObservableValue.asTraversalObservable( >+ (Text) editor.getControl(), SWT.TRAVERSE_RETURN >+ | SWT.TRAVERSE_TAB_NEXT); >+ } > } >+ > return null; > } > } >Index: src/org/eclipse/jface/internal/databinding/provisional/viewers/TableViewerEditorManager.java >=================================================================== >RCS file: src/org/eclipse/jface/internal/databinding/provisional/viewers/TableViewerEditorManager.java >diff -N src/org/eclipse/jface/internal/databinding/provisional/viewers/TableViewerEditorManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/internal/databinding/provisional/viewers/TableViewerEditorManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,257 @@ >+package org.eclipse.jface.internal.databinding.provisional.viewers; >+ >+import org.eclipse.jface.internal.databinding.provisional.BindSpec; >+import org.eclipse.jface.internal.databinding.provisional.Binding; >+import org.eclipse.jface.internal.databinding.provisional.DataBindingContext; >+import org.eclipse.jface.internal.databinding.provisional.description.Property; >+import org.eclipse.jface.internal.databinding.provisional.description.TableModelDescription; >+import org.eclipse.jface.internal.databinding.provisional.observable.IObservable; >+import org.eclipse.jface.util.Assert; >+import org.eclipse.jface.viewers.CellEditor; >+import org.eclipse.jface.viewers.ICellModifier; >+import org.eclipse.jface.viewers.TableViewer; >+ >+/** >+ * Manages the process of binding editors to a <code>TableViewer</code>. When >+ * using the manager manipulation of the cell modifier, column properties, or >+ * editors on the viewer is forbidden. >+ * >+ * @since 3.3 >+ */ >+public class TableViewerEditorManager { >+ /** >+ * TableViewer whose editors are being managed. >+ */ >+ private final TableViewer tableViewer; >+ >+ /** >+ * Describes the model of the viewer, used to determine columns to edit. >+ */ >+ private final TableModelDescription tableModelDescription; >+ >+ /** >+ * Used to create observables for cell editors and to bind editors to the >+ * model. >+ */ >+ private final DataBindingContext dataBindingContext; >+ >+ /** >+ * IObservable that provides the ability to observe selection of the >+ * TableViewer. All editors observe the same instance. >+ */ >+ private IObservable selectionObservable; >+ >+ /** >+ * Constructs a new instance. >+ * >+ * @param tableViewer >+ * viewer to associate editors with >+ * @param tableModelDescription >+ * description of the model to apply to editing >+ * @param dataBindingContext >+ * context to use when binding >+ */ >+ public TableViewerEditorManager(TableViewer tableViewer, >+ TableModelDescription tableModelDescription, >+ DataBindingContext dataBindingContext) { >+ if (tableViewer == null) { >+ throw new NullPointerException( >+ "Parameter " + tableViewer + " was null."); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ if (tableModelDescription == null) { >+ throw new NullPointerException( >+ "Parameter " + tableModelDescription + " was null."); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ if (dataBindingContext == null) { >+ throw new NullPointerException( >+ "Parameter " + dataBindingContext + " was null."); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ this.tableViewer = tableViewer; >+ this.tableModelDescription = tableModelDescription; >+ this.dataBindingContext = dataBindingContext; >+ >+ tableViewer.setCellModifier(new CellModifier(tableViewer)); >+ >+ Object[] columnIDs = tableModelDescription.getColumnIDs(); >+ int columnCount = (columnIDs != null) ? columnIDs.length : 0; >+ >+ tableViewer.setCellEditors(new CellEditor[columnCount]); >+ >+ String[] properties = new String[columnCount]; >+ tableViewer.setColumnProperties(properties); >+ >+ for (int i = 0; i < columnCount; i++) { >+ properties[i] = columnIDs[i].toString(); >+ } >+ } >+ >+ /** >+ * @return Returns the dataBindingContext. >+ */ >+ public DataBindingContext getDataBindingContext() { >+ return dataBindingContext; >+ } >+ >+ /** >+ * @return Returns the tableModelDescription. >+ */ >+ public TableModelDescription getTableModelDescription() { >+ return tableModelDescription; >+ } >+ >+ /** >+ * @return Returns the tableViewer. >+ */ >+ public TableViewer getTableViewer() { >+ return tableViewer; >+ } >+ >+ /** >+ * ICellModifier implementation that mostly ignores it's duty of being the >+ * translator between an editor on the value being edited. The binding >+ * framework takes place of the ICellModifier but editing can't occur in >+ * viewers without an ICellModifier. >+ * >+ * @since 3.3 >+ */ >+ private static class CellModifier implements ICellModifier { >+ private final TableViewer viewer; >+ >+ private CellModifier(TableViewer viewer) { >+ this.viewer = viewer; >+ } >+ >+ /** >+ * Returns the editor for the property. >+ * >+ * @param property >+ * @return editor, <code>null</code> if not found >+ */ >+ private CellEditor getEditor(String property) { >+ Assert.isNotNull(property); >+ >+ if (property == null) >+ return null; >+ >+ CellEditor editor = null; >+ Object[] properties = viewer.getColumnProperties(); >+ for (int i = 0; i < properties.length; i++) { >+ if (property.equals(properties[i])) { >+ editor = viewer.getCellEditors()[i]; >+ break; >+ } >+ } >+ return editor; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, >+ * java.lang.String) >+ */ >+ public boolean canModify(Object element, String property) { >+ return getEditor(property) != null; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, >+ * java.lang.String) >+ */ >+ public Object getValue(Object element, String property) { >+ /* >+ * this is a workaround. if we return null the CellEditor will throw >+ * an exception. the binding framework will set the appropriate >+ * value after this method is invoked. >+ */ >+ CellEditor editor = getEditor(property); >+ >+ Assert.isTrue(editor != null); >+ >+ return editor.getValue(); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, >+ * java.lang.String, java.lang.Object) >+ */ >+ public void modify(Object element, String property, Object value) { >+ // modifies are handled by the binding framework >+ } >+ } >+ >+ /** >+ * Assigns an editor to the viewer. >+ * >+ * @param cellEditor >+ * @param columnID >+ * value that corresponds to the column specified in the >+ * TableModelDescription >+ * @param columnIDType >+ * type of the attribute to bind the editor to >+ * @param bindSpec >+ * spec that contains validators, converters, etc. to employ when >+ * updating the observables, can be <code>null</code>. >+ * @return binding >+ * @throws IllegalArgumentException >+ * if the columnID is not found in the TableModelDescription's >+ * columnIDs. >+ */ >+ public Binding bind(CellEditor cellEditor, Object columnID, >+ Class columnIDType, BindSpec bindSpec) { >+ if (cellEditor == null) { >+ throw new NullPointerException( >+ "Parameter " + cellEditor + " was null."); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ if (columnID == null) { >+ throw new NullPointerException( >+ "Parameter " + columnID + " was null."); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ if (columnIDType == null) { >+ throw new NullPointerException( >+ "Parameter " + columnIDType + " was null."); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ int columnIndex = -1; >+ Object[] columnIDs = tableModelDescription.getColumnIDs(); >+ for (int i = 0; columnIndex == -1 && i < columnIDs.length; i++) { >+ if (columnID.equals(columnIDs[i])) { >+ columnIndex = i; >+ } >+ } >+ >+ if (columnIndex == -1) { >+ throw new IllegalArgumentException( >+ "Column with ID [" + columnID + "] not found in TableModelDescription."); //$NON-NLS-1$//$NON-NLS-2$ >+ } >+ >+ tableViewer.getCellEditors()[columnIndex] = cellEditor; >+ >+ if (selectionObservable == null) { >+ selectionObservable = dataBindingContext >+ .createObservable(new Property(tableViewer, >+ ViewersProperties.SINGLE_SELECTION)); >+ Assert.isNotNull(selectionObservable); >+ } >+ >+ if (cellEditor.getControl() == null) { >+ cellEditor.create(tableViewer.getTable()); >+ } >+ >+ return dataBindingContext.bind(cellEditor, new Property( >+ selectionObservable, columnID, columnIDType, Boolean.FALSE), >+ bindSpec); >+ } >+ >+ /** >+ * @return Returns the viewerSelectionObservable. >+ */ >+ public IObservable getSelectionObservable() { >+ return selectionObservable; >+ } >+} >#P org.eclipse.jface.tests.databinding >Index: src/org/eclipse/jface/tests/databinding/scenarios/TableScenarios.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/TableScenarios.java,v >retrieving revision 1.29 >diff -u -r1.29 TableScenarios.java >--- src/org/eclipse/jface/tests/databinding/scenarios/TableScenarios.java 23 Mar 2006 17:09:06 -0000 1.29 >+++ src/org/eclipse/jface/tests/databinding/scenarios/TableScenarios.java 29 May 2006 16:08:04 -0000 >@@ -10,18 +10,27 @@ > *******************************************************************************/ > package org.eclipse.jface.tests.databinding.scenarios; > >+import java.util.ArrayList; >+import java.util.List; >+ > import org.eclipse.jface.examples.databinding.model.Account; > import org.eclipse.jface.examples.databinding.model.Catalog; > import org.eclipse.jface.examples.databinding.model.Category; > import org.eclipse.jface.examples.databinding.model.SampleData; > import org.eclipse.jface.internal.databinding.provisional.description.Property; > import org.eclipse.jface.internal.databinding.provisional.description.TableModelDescription; >+import org.eclipse.jface.internal.databinding.provisional.observable.list.AbstractObservableList; >+import org.eclipse.jface.internal.databinding.provisional.viewers.TableViewerEditorManager; > import org.eclipse.jface.viewers.ITableLabelProvider; >+import org.eclipse.jface.viewers.StructuredSelection; > import org.eclipse.jface.viewers.TableViewer; >+import org.eclipse.jface.viewers.TextCellEditor; > import org.eclipse.swt.SWT; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.layout.FillLayout; >+import org.eclipse.swt.widgets.Event; > import org.eclipse.swt.widgets.TableColumn; >+import org.eclipse.swt.widgets.Text; > > /** > * To run the tests in this class, right-click and select "Run As JUnit Plug-in >@@ -35,7 +44,7 @@ > private TableViewer tableViewer; > > private Catalog catalog; >- >+ > private Category category; > > private TableColumn firstNameColumn; >@@ -57,14 +66,14 @@ > firstNameColumn = new TableColumn(tableViewer.getTable(), SWT.NONE); > firstNameColumn.setWidth(50); > lastNameColumn = new TableColumn(tableViewer.getTable(), SWT.NONE); >- lastNameColumn.setWidth(50); >+ lastNameColumn.setWidth(50); > stateColumn = new TableColumn(tableViewer.getTable(), SWT.NONE); >- stateColumn.setWidth(50); >+ stateColumn.setWidth(50); > fancyColumn = new TableColumn(tableViewer.getTable(), SWT.NONE); >- fancyColumn.setWidth(250); >+ fancyColumn.setWidth(250); > > catalog = SampleData.CATALOG_2005; // Lodging source >- category = SampleData.WINTER_CATEGORY; >+ category = SampleData.WINTER_CATEGORY; > > images = new Image[] { > getShell().getDisplay().getSystemImage(SWT.ICON_ERROR), >@@ -83,24 +92,25 @@ > } > > private String getValue(String text) { >- if (text==null) >+ if (text == null) > return ""; > return text; > } >- >+ > public void testScenario01() { > // Show that a TableViewer with three columns renders the accounts > Account[] accounts = catalog.getAccounts(); > >- TableModelDescription tableModelDescription = new TableModelDescription(new Property(catalog, "accounts"),new String[]{"firstName","lastName","state"}); >- getDbc().bind(tableViewer, >- tableModelDescription, null); >+ TableModelDescription tableModelDescription = new TableModelDescription( >+ new Property(catalog, "accounts"), new String[] { "firstName", >+ "lastName", "state" }); >+ getDbc().bind(tableViewer, tableModelDescription, null); > > // Verify the data in the table columns matches the accounts > for (int i = 0; i < accounts.length; i++) { > Account account = catalog.getAccounts()[i]; > String col_0 = ((ITableLabelProvider) tableViewer >- .getLabelProvider()).getColumnText(account, 0); >+ .getLabelProvider()).getColumnText(account, 0); > assertEquals(getValue(account.getFirstName()), col_0); > String col_1 = ((ITableLabelProvider) tableViewer > .getLabelProvider()).getColumnText(account, 1); >@@ -112,301 +122,464 @@ > } > } > >- public void testScenario02() throws SecurityException, IllegalArgumentException { >+ public void testEditColumnWithTextCellEditor() throws Exception { >+ TableModelDescription description = new TableModelDescription( >+ new Property(catalog, "accounts", Account.class, Boolean.TRUE), >+ new String[] { "firstName", "lastName" }); >+ >+ getDbc().bind(tableViewer, description, null); >+ >+ TableViewerEditorManager manager = new TableViewerEditorManager( >+ tableViewer, description, getDbc()); >+ TextCellEditor editor = new TextCellEditor(); >+ manager.bind(editor, "firstName", String.class, null); >+ >+ Account account = catalog.getAccounts()[0]; >+ String originalValue = account.getFirstName(); >+ >+ tableViewer.editElement(account, 0); >+ assertEquals(account, >+ ((StructuredSelection) tableViewer.getSelection()) >+ .getFirstElement()); >+ >+ String newValue = editor.getValue().toString() + "," >+ + editor.getValue().toString(); >+ editor.setValue(newValue); >+ >+ // Value shouldn't yet change >+ assertEquals(originalValue, account.getFirstName()); >+ >+ getShell().open(); >+ >+ // Apply value >+ Text text = (Text) editor.getControl(); >+ Event event = new Event(); >+ event.detail = SWT.TRAVERSE_RETURN; >+ text.notifyListeners(SWT.Traverse, event); >+ tableViewer.getTable().setFocus(); >+ >+ assertEquals(newValue, account.getFirstName()); >+ } >+ >+ public void testCancelEditOfTextCellEditor() throws Exception { >+ TableModelDescription description = new TableModelDescription( >+ new Property(catalog, "accounts", Account.class, Boolean.TRUE), >+ new String[] { "firstName", "lastName" }); >+ >+ getDbc().bind(tableViewer, description, null); >+ >+ TableViewerEditorManager manager = new TableViewerEditorManager( >+ tableViewer, description, getDbc()); >+ TextCellEditor editor = new TextCellEditor(); >+ manager.bind(editor, "firstName", String.class, null); >+ >+ Account account = catalog.getAccounts()[0]; >+ String originalValue = account.getFirstName(); >+ >+ tableViewer.editElement(account, 0); >+ assertEquals(account, >+ ((StructuredSelection) tableViewer.getSelection()) >+ .getFirstElement()); >+ >+ String newValue = editor.getValue().toString() + "," >+ + editor.getValue().toString(); >+ editor.setValue(newValue); >+ >+ // Value shouldn't yet change >+ assertEquals(originalValue, account.getFirstName()); >+ >+ // Aborts the edit >+ tableViewer.getTable().setFocus(); >+ >+ assertEquals(originalValue, account.getFirstName()); >+ } >+ >+ private class ObservableList extends AbstractObservableList { >+ private List list; >+ >+ private Object elementType; >+ >+ private ObservableList(Object elementType) { >+ list = new ArrayList(); >+ this.elementType = elementType; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.internal.databinding.provisional.observable.list.AbstractObservableList#add(java.lang.Object) >+ */ >+ public boolean add(Object o) { >+ return list.add(o); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.internal.databinding.provisional.observable.list.AbstractObservableList#doGetSize() >+ */ >+ protected int doGetSize() { >+ return list.size(); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see java.util.AbstractList#get(int) >+ */ >+ public Object get(int index) { >+ return list.get(index); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.internal.databinding.provisional.observable.list.IObservableList#getElementType() >+ */ >+ public Object getElementType() { >+ return elementType; >+ } >+ } >+ >+ public void testScenario02() throws SecurityException, >+ IllegalArgumentException { > // Show that a TableViewer with three columns can be used to update > // columns >-// Account[] accounts = catalog.getAccounts(); >-// >-// TableModelDescription tableModelDescription = new TableModelDescription(new Property(catalog, "accounts"), new String[]{"firstName","lastName","state"}); >-//// tableViewerDescription.addEditableColumn("firstName"); >-//// tableViewerDescription.addEditableColumn("lastName", null, null, new PhoneConverter()); >-//// tableViewerDescription.addEditableColumn("state", null, null, new StateConverter()); >-// getDbc().bind(tableViewer, >-// tableModelDescription, null); >-// >-// Account account = accounts[0]; >-// // Select the first item in the table >-// tableViewer.editElement(account, 0); >-// // Set the text property of the cell editor which is now active over the "firstName" column >-// CellEditor[] cellEditors = tableViewer.getCellEditors(); >-// TextCellEditor firstNameEditor = (TextCellEditor) cellEditors[0]; >-// // Change the firstName and test it goes to the model >-// enterText((Text) firstNameEditor.getControl(), "Bill"); >-// // Check whether the model has changed >-// assertEquals("Bill",account.getFirstName()); >+ // Account[] accounts = catalog.getAccounts(); >+ // >+ // TableModelDescription tableModelDescription = new >+ // TableModelDescription(new >+ // Property(catalog, "accounts"), new >+ // String[]{"firstName","lastName","state"}); >+ // // tableViewerDescription.addEditableColumn("firstName"); >+ // // tableViewerDescription.addEditableColumn("lastName", null, null, >+ // new >+ // PhoneConverter()); >+ // // tableViewerDescription.addEditableColumn("state", null, null, new >+ // StateConverter()); >+ // getDbc().bind(tableViewer, >+ // tableModelDescription, null); >+ // >+ // Account account = accounts[0]; >+ // // Select the first item in the table >+ // tableViewer.editElement(account, 0); >+ // // Set the text property of the cell editor which is now active over >+ // the >+ // "firstName" column >+ // CellEditor[] cellEditors = tableViewer.getCellEditors(); >+ // TextCellEditor firstNameEditor = (TextCellEditor) cellEditors[0]; >+ // // Change the firstName and test it goes to the model >+ // enterText((Text) firstNameEditor.getControl(), "Bill"); >+ // // Check whether the model has changed >+ // assertEquals("Bill",account.getFirstName()); > } >- >+ > public void testScenario04() { >-// // Show that when an item is added to a collection the table gets an extra item >-// Account[] accounts = catalog.getAccounts(); >-// >-// TableViewerDescription tableViewerDescription = new TableViewerDescription( >-// tableViewer); >-// tableViewerDescription.addColumn("firstName"); >-// tableViewerDescription.addColumn("lastName"); >-// tableViewerDescription.addColumn("state"); >-// tableViewerDescription.addColumn(null,new IConverter(){ >-// >-// public Class getModelType() { >-// return Account.class; >-// } >-// >-// public Class getTargetType() { >-// return ViewerLabel.class; >-// } >-// >-// public Object convertTargetToModel(Object targetObject) { >-// return null; >-// } >-// >-// public Object convertModelToTarget(Object modelObject) { >-// Account account = (Account) modelObject; >-// return new ViewerLabel(account.toString(), images[new Random().nextInt(images.length)]); >-// }}); >-// getDbc().bind(tableViewerDescription, >-// new Property(catalog, "accounts"), null); >-// >-// //interact(); >-// >-// // Verify the number of accounts matches the number of items in the table >-// assertEquals(tableViewer.getTable().getItemCount(),accounts.length); >-// // Add a new account and verify that the number of items in the table increases >-// Account newAccount = new Account(); >-// newAccount.setFirstName("Finbar"); >-// newAccount.setLastName("McGoo"); >-// newAccount.setLastName("NC"); >-// catalog.addAccount(newAccount); >-// // The number of items should have gone up by one >-// assertEquals(tableViewer.getTable().getItemCount(),accounts.length + 1); >-// // The number of items should still match the number of accounts (i.e. test the model) >-// assertEquals(tableViewer.getTable().getItemCount(),catalog.getAccounts().length); >-// // Remove the account that was just added >-// catalog.removeAccount(newAccount); >-// // The number of items should match the original >-// assertEquals(tableViewer.getTable().getItemCount(),accounts.length); >-// // The number of items should still match the number of accounts (i.e. test the model is reset) >-// assertEquals(tableViewer.getTable().getItemCount(),catalog.getAccounts().length); >-// >-// // Test adding and removing to the model on a non UI thread >-// int numberOfAccounts = catalog.getAccounts().length; >-// final Account barney = new Account(); >-// barney.setFirstName("Barney"); >-// barney.setLastName("Smith"); >-// barney.setLastName("CA"); >-// invokeNonUI(new Runnable(){ >-// public void run(){ >-// catalog.addAccount(barney); >-// } >-// }); >-// spinEventLoop(0); >-// // The number of items should have gone up by one >-// assertEquals(tableViewer.getTable().getItemCount(),numberOfAccounts + 1); >-// >-// invokeNonUI(new Runnable(){ >-// public void run(){ >-// catalog.removeAccount(barney); >-// } >-// }); >-// spinEventLoop(0); >-// // The number of items should have reverted to the original number before barney was added and removed >-// assertEquals(tableViewer.getTable().getItemCount(),numberOfAccounts); >-// >+ // // Show that when an item is added to a collection the table gets an >+ // extra >+ // item >+ // Account[] accounts = catalog.getAccounts(); >+ // >+ // TableViewerDescription tableViewerDescription = new >+ // TableViewerDescription( >+ // tableViewer); >+ // tableViewerDescription.addColumn("firstName"); >+ // tableViewerDescription.addColumn("lastName"); >+ // tableViewerDescription.addColumn("state"); >+ // tableViewerDescription.addColumn(null,new IConverter(){ >+ // >+ // public Class getModelType() { >+ // return Account.class; >+ // } >+ // >+ // public Class getTargetType() { >+ // return ViewerLabel.class; >+ // } >+ // >+ // public Object convertTargetToModel(Object targetObject) { >+ // return null; >+ // } >+ // >+ // public Object convertModelToTarget(Object modelObject) { >+ // Account account = (Account) modelObject; >+ // return new ViewerLabel(account.toString(), images[new >+ // Random().nextInt(images.length)]); >+ // }}); >+ // getDbc().bind(tableViewerDescription, >+ // new Property(catalog, "accounts"), null); >+ // >+ // //interact(); >+ // >+ // // Verify the number of accounts matches the number of items in the >+ // table >+ // assertEquals(tableViewer.getTable().getItemCount(),accounts.length); >+ // // Add a new account and verify that the number of items in the table >+ // increases >+ // Account newAccount = new Account(); >+ // newAccount.setFirstName("Finbar"); >+ // newAccount.setLastName("McGoo"); >+ // newAccount.setLastName("NC"); >+ // catalog.addAccount(newAccount); >+ // // The number of items should have gone up by one >+ // assertEquals(tableViewer.getTable().getItemCount(),accounts.length + >+ // 1); >+ // // The number of items should still match the number of accounts >+ // (i.e. test >+ // the model) >+ // assertEquals(tableViewer.getTable().getItemCount(),catalog.getAccounts().length); >+ // // Remove the account that was just added >+ // catalog.removeAccount(newAccount); >+ // // The number of items should match the original >+ // assertEquals(tableViewer.getTable().getItemCount(),accounts.length); >+ // // The number of items should still match the number of accounts >+ // (i.e. test >+ // the model is reset) >+ // assertEquals(tableViewer.getTable().getItemCount(),catalog.getAccounts().length); >+ // >+ // // Test adding and removing to the model on a non UI thread >+ // int numberOfAccounts = catalog.getAccounts().length; >+ // final Account barney = new Account(); >+ // barney.setFirstName("Barney"); >+ // barney.setLastName("Smith"); >+ // barney.setLastName("CA"); >+ // invokeNonUI(new Runnable(){ >+ // public void run(){ >+ // catalog.addAccount(barney); >+ // } >+ // }); >+ // spinEventLoop(0); >+ // // The number of items should have gone up by one >+ // assertEquals(tableViewer.getTable().getItemCount(),numberOfAccounts + >+ // 1); >+ // >+ // invokeNonUI(new Runnable(){ >+ // public void run(){ >+ // catalog.removeAccount(barney); >+ // } >+ // }); >+ // spinEventLoop(0); >+ // // The number of items should have reverted to the original number >+ // before >+ // barney was added and removed >+ // assertEquals(tableViewer.getTable().getItemCount(),numberOfAccounts); >+ // > } >- >+ > public void testScenario03() { >-// // Show that converters work for table columns >-// Account[] accounts = catalog.getAccounts(); >-// >-// TableViewerDescription tableViewerDescription = new TableViewerDescription( >-// tableViewer); >-// tableViewerDescription.addEditableColumn("lastName"); >-// tableViewerDescription.addEditableColumn("phone", null, null , >-// new PhoneConverter()); >-// tableViewerDescription.addEditableColumn("state", null, null , >-// new StateConverter()); >-// getDbc().bind(tableViewerDescription, >-// new Property(catalog, "accounts"), null); >-// >-// // Verify that the data in the the table columns matches the expected >-// // What we are looking for is that the phone numbers are converterted to >-// // nnn-nnn-nnnn and that >-// // the state letters are converted to state names >-// // Verify the data in the table columns matches the accounts >-// PhoneConverter phoneConverter = new PhoneConverter(); >-// StateConverter stateConverter = new StateConverter(); >-// for (int i = 0; i < accounts.length; i++) { >-// Account account = catalog.getAccounts()[i]; >-// // Check the phone number >-// String col_phone = ((ITableLabelProvider) tableViewer >-// .getLabelProvider()).getColumnText(account, 1); >-// assertEquals(getValue((String)phoneConverter >-// .convertModelToTarget(account.getPhone())), col_phone); >-// String col_state = ((ITableLabelProvider) tableViewer >-// .getLabelProvider()).getColumnText(account, 2); >-// assertEquals(getValue((String)stateConverter >-// .convertModelToTarget(account.getState())), col_state); >-// } >+ // // Show that converters work for table columns >+ // Account[] accounts = catalog.getAccounts(); >+ // >+ // TableViewerDescription tableViewerDescription = new >+ // TableViewerDescription( >+ // tableViewer); >+ // tableViewerDescription.addEditableColumn("lastName"); >+ // tableViewerDescription.addEditableColumn("phone", null, null , >+ // new PhoneConverter()); >+ // tableViewerDescription.addEditableColumn("state", null, null , >+ // new StateConverter()); >+ // getDbc().bind(tableViewerDescription, >+ // new Property(catalog, "accounts"), null); >+ // >+ // // Verify that the data in the the table columns matches the expected >+ // // What we are looking for is that the phone numbers are converterted >+ // to >+ // // nnn-nnn-nnnn and that >+ // // the state letters are converted to state names >+ // // Verify the data in the table columns matches the accounts >+ // PhoneConverter phoneConverter = new PhoneConverter(); >+ // StateConverter stateConverter = new StateConverter(); >+ // for (int i = 0; i < accounts.length; i++) { >+ // Account account = catalog.getAccounts()[i]; >+ // // Check the phone number >+ // String col_phone = ((ITableLabelProvider) tableViewer >+ // .getLabelProvider()).getColumnText(account, 1); >+ // assertEquals(getValue((String)phoneConverter >+ // .convertModelToTarget(account.getPhone())), col_phone); >+ // String col_state = ((ITableLabelProvider) tableViewer >+ // .getLabelProvider()).getColumnText(account, 2); >+ // assertEquals(getValue((String)stateConverter >+ // .convertModelToTarget(account.getState())), col_state); >+ // } > } >- >+ > public void testScenario05() { >-// // Show that when the model changes then the UI refreshes to reflect this >-// >-// TableViewerDescription tableViewerDescription = new TableViewerDescription( >-// tableViewer); >-// tableViewerDescription.addColumn("lastName"); >-// tableViewerDescription.addColumn("phone", >-// new PhoneConverter()); >-// tableViewerDescription.addColumn("state", >-// new StateConverter()); >-// getDbc().bind(tableViewerDescription, >-// new Property(catalog, "accounts"), null); >-// >-// final Account account = catalog.getAccounts()[0]; >-// String lastName = tableViewer.getTable().getItem(0).getText(0); >-// // Check the firstName in the TableItem is the same as the model >-// assertEquals(lastName,account.getLastName()); >-// // Now change the model and check again >-// account.setLastName("Gershwin"); >-// lastName = tableViewer.getTable().getItem(0).getText(0); >-// assertEquals(lastName,account.getLastName()); >-// >-// // Test the model update on a non UI thread >-// invokeNonUI(new Runnable(){ >-// public void run(){ >-// account.setLastName("Mozart"); >-// } >-// }); >-// spinEventLoop(0); >-// lastName = tableViewer.getTable().getItem(0).getText(0); >-// assertEquals(lastName,account.getLastName()); >-// >- } >- >- public void testScenario06(){ >-// // Check that explicit type means that defaulting of converters works >-// TableViewerDescription tableViewerDescription = new TableViewerDescription( >-// tableViewer); >-// tableViewerDescription.addEditableColumn("price"); >-// tableViewerDescription.getColumn(0).setPropertyType(Double.TYPE); >-// getDbc().bind(tableViewerDescription, >-// new Property(catalog, "transporations"), null); >-// Transportation transporation = catalog.getTransporations()[0]; >-// tableViewer.editElement(transporation, 0); >-// // Set the text property of the cell editor which is now active over the "firstName" column >-// CellEditor[] cellEditors = tableViewer.getCellEditors(); >-// TextCellEditor priceEditor = (TextCellEditor) cellEditors[0]; >-// // Change the firstName and test it goes to the model >-// enterText((Text) priceEditor.getControl(), "123.45"); >-// // Verify the model is updated >-// assertEquals(transporation.getPrice(),123.45,0); >- >- } >- >- public void testScenario07(){ >-// // Verify that even when a column's property type is not set, that it is worked out lazily from the target type >-// TableViewerDescription tableViewerDescription = new TableViewerDescription( >-// tableViewer); >-// tableViewerDescription.addEditableColumn("price"); >-// // The column's type is not set to be Double.TYPE. This will be inferred once the first Transportation object is set >-// // into the ObservableCollection >-// getDbc().bind(tableViewerDescription, >-// new Property(catalog, "transporations"), null); >-// Transportation transporation = catalog.getTransporations()[0]; >-// tableViewer.editElement(transporation, 0); >-// // Set the text property of the cell editor which is now active over the "firstName" column >-// CellEditor[] cellEditors = tableViewer.getCellEditors(); >-// TextCellEditor priceEditor = (TextCellEditor) cellEditors[0]; >-// // Change the firstName and test it goes to the model >-// enterText((Text) priceEditor.getControl(), "123.45"); >-// // Verify the model is updated >-// assertEquals(transporation.getPrice(),123.45,0); >-// >- } >- >- public void testScenario08_00(){ >-// // Verify that binding to a Collection property (rather than an array) works when specifying data type >-// TableViewerDescription tableViewerDescription = new TableViewerDescription( >-// tableViewer); >-// tableViewerDescription.addEditableColumn("userId"); >-// tableViewerDescription.addEditableColumn("password"); >-// getDbc().bind(tableViewerDescription, >-// new Property(catalog, "signons", Signon.class, null), null); >-// Signon firstSignon = (Signon) catalog.getSignons().get(0); >-// // Verify the UI matches the model >-// TableItem firstTableItem = tableViewer.getTable().getItem(0); >-// assertEquals(firstTableItem.getText(1),firstSignon.getPassword()); >-// // Change the model and ensure the UI refreshes >-// firstSignon.setPassword("Eclipse123Rocks"); >-// assertEquals("Eclipse123Rocks",firstSignon.getPassword()); >-// assertEquals(firstTableItem.getText(1),firstSignon.getPassword()); >-// // Change the GUI and ensure the model refreshes >-// tableViewer.editElement(firstSignon, 1); >-// CellEditor[] cellEditors = tableViewer.getCellEditors(); >-// TextCellEditor passwordEditor = (TextCellEditor) cellEditors[1]; >-// enterText((Text) passwordEditor.getControl(), "Cricket11Players"); >-// assertEquals("Cricket11Players",firstSignon.getPassword()); >-// >- } >- >- public void testScenario08_01(){ >-// // Verify that binding to a Collection property (rather than an array) works without specifying data type >-// TableViewerDescription tableViewerDescription = new TableViewerDescription( >-// tableViewer); >-// tableViewerDescription.addEditableColumn("userId"); >-// tableViewerDescription.addEditableColumn("password"); >-// getDbc().bind(tableViewerDescription, >-// new Property(catalog, "signons"), null); >-// Signon firstSignon = (Signon) catalog.getSignons().get(0); >-// // Verify the UI matches the model >-// TableItem firstTableItem = tableViewer.getTable().getItem(0); >-// assertEquals(firstTableItem.getText(1),firstSignon.getPassword()); >-// // Change the model and ensure the UI refreshes >-// firstSignon.setPassword("Eclipse123Rocks"); >-// assertEquals("Eclipse123Rocks",firstSignon.getPassword()); >-// assertEquals(firstTableItem.getText(1),firstSignon.getPassword()); >-// // Change the GUI and ensure the model refreshes >-// tableViewer.editElement(firstSignon, 1); >-// CellEditor[] cellEditors = tableViewer.getCellEditors(); >-// TextCellEditor passwordEditor = (TextCellEditor) cellEditors[1]; >-// enterText((Text) passwordEditor.getControl(), "Cricket11Players"); >-// assertEquals("Cricket11Players",firstSignon.getPassword()); >-// >- } >- >- public void testScenario09(){ >-// // Verify that nested properties work. Catalog has adventures. Adventure has defaultLodging. Loding has name. >-// TableViewerDescription tableViewerDescription = new TableViewerDescription(tableViewer); >-// tableViewerDescription.addColumn("name"); >-// tableViewerDescription.addColumn("defaultLodging.name"); >-// getDbc().bind(tableViewerDescription,new Property(category, "adventures"),null); >-// >- } >-/** >- public void testScenario10(){ >- // Verify that for TIME_EARLY updating occurs on a per key basic for a TextCellEditor >- // Show that converters work for table columns >- Account[] accounts = catalog.getAccounts(); >- Account firstAccount = accounts[0]; >- SampleData.getSWTObservableFactory().setUpdateTime(DataBindingContext.TIME_EARLY); >- TableViewerDescription tableViewerDescription = new TableViewerDescription(tableViewer); >- tableViewerDescription.addEditableColumn("lastName"); >- tableViewerDescription.addColumn("lastName"); >- getDbc().bind(tableViewerDescription,new Property(catalog, "accounts"), null); >- >- // Verify that the first account is shown in the first row with the last name correctly >- assertEquals(tableViewer.getTable().getItem(0).getData(),firstAccount); >- assertEquals(tableViewer.getTable().getItem(0).getText(0),firstAccount.getLastName()); >- assertEquals(tableViewer.getTable().getItem(0).getText(1),firstAccount.getLastName()); >- // Create a cell editor over the first column >- tableViewer.editElement(firstAccount, 0); >- // Set the text property of the cell editor which is now active over the "firstName" column >- CellEditor[] cellEditors = tableViewer.getCellEditors(); >- TextCellEditor lastNameCellEditor = (TextCellEditor) cellEditors[0]; >- ((Text)lastNameCellEditor.getControl()).setText("E"); >- // Verify that the key press goes to the model >- assertEquals(firstAccount.getLastName(),"E"); >- >- } >- **/ >+ // // Show that when the model changes then the UI refreshes to reflect >+ // this >+ // >+ // TableViewerDescription tableViewerDescription = new >+ // TableViewerDescription( >+ // tableViewer); >+ // tableViewerDescription.addColumn("lastName"); >+ // tableViewerDescription.addColumn("phone", >+ // new PhoneConverter()); >+ // tableViewerDescription.addColumn("state", >+ // new StateConverter()); >+ // getDbc().bind(tableViewerDescription, >+ // new Property(catalog, "accounts"), null); >+ // >+ // final Account account = catalog.getAccounts()[0]; >+ // String lastName = tableViewer.getTable().getItem(0).getText(0); >+ // // Check the firstName in the TableItem is the same as the model >+ // assertEquals(lastName,account.getLastName()); >+ // // Now change the model and check again >+ // account.setLastName("Gershwin"); >+ // lastName = tableViewer.getTable().getItem(0).getText(0); >+ // assertEquals(lastName,account.getLastName()); >+ // >+ // // Test the model update on a non UI thread >+ // invokeNonUI(new Runnable(){ >+ // public void run(){ >+ // account.setLastName("Mozart"); >+ // } >+ // }); >+ // spinEventLoop(0); >+ // lastName = tableViewer.getTable().getItem(0).getText(0); >+ // assertEquals(lastName,account.getLastName()); >+ // >+ } >+ >+ public void testScenario06() { >+ // // Check that explicit type means that defaulting of converters works >+ // TableViewerDescription tableViewerDescription = new >+ // TableViewerDescription( >+ // tableViewer); >+ // tableViewerDescription.addEditableColumn("price"); >+ // tableViewerDescription.getColumn(0).setPropertyType(Double.TYPE); >+ // getDbc().bind(tableViewerDescription, >+ // new Property(catalog, "transporations"), null); >+ // Transportation transporation = catalog.getTransporations()[0]; >+ // tableViewer.editElement(transporation, 0); >+ // // Set the text property of the cell editor which is now active over >+ // the >+ // "firstName" column >+ // CellEditor[] cellEditors = tableViewer.getCellEditors(); >+ // TextCellEditor priceEditor = (TextCellEditor) cellEditors[0]; >+ // // Change the firstName and test it goes to the model >+ // enterText((Text) priceEditor.getControl(), "123.45"); >+ // // Verify the model is updated >+ // assertEquals(transporation.getPrice(),123.45,0); >+ >+ } >+ >+ public void testScenario07() { >+ // // Verify that even when a column's property type is not set, that it >+ // is >+ // worked out lazily from the target type >+ // TableViewerDescription tableViewerDescription = new >+ // TableViewerDescription( >+ // tableViewer); >+ // tableViewerDescription.addEditableColumn("price"); >+ // // The column's type is not set to be Double.TYPE. This will be >+ // inferred once >+ // the first Transportation object is set >+ // // into the ObservableCollection >+ // getDbc().bind(tableViewerDescription, >+ // new Property(catalog, "transporations"), null); >+ // Transportation transporation = catalog.getTransporations()[0]; >+ // tableViewer.editElement(transporation, 0); >+ // // Set the text property of the cell editor which is now active over >+ // the >+ // "firstName" column >+ // CellEditor[] cellEditors = tableViewer.getCellEditors(); >+ // TextCellEditor priceEditor = (TextCellEditor) cellEditors[0]; >+ // // Change the firstName and test it goes to the model >+ // enterText((Text) priceEditor.getControl(), "123.45"); >+ // // Verify the model is updated >+ // assertEquals(transporation.getPrice(),123.45,0); >+ // >+ } >+ >+ public void testScenario08_00() { >+ // // Verify that binding to a Collection property (rather than an >+ // array) works >+ // when specifying data type >+ // TableViewerDescription tableViewerDescription = new >+ // TableViewerDescription( >+ // tableViewer); >+ // tableViewerDescription.addEditableColumn("userId"); >+ // tableViewerDescription.addEditableColumn("password"); >+ // getDbc().bind(tableViewerDescription, >+ // new Property(catalog, "signons", Signon.class, null), null); >+ // Signon firstSignon = (Signon) catalog.getSignons().get(0); >+ // // Verify the UI matches the model >+ // TableItem firstTableItem = tableViewer.getTable().getItem(0); >+ // assertEquals(firstTableItem.getText(1),firstSignon.getPassword()); >+ // // Change the model and ensure the UI refreshes >+ // firstSignon.setPassword("Eclipse123Rocks"); >+ // assertEquals("Eclipse123Rocks",firstSignon.getPassword()); >+ // assertEquals(firstTableItem.getText(1),firstSignon.getPassword()); >+ // // Change the GUI and ensure the model refreshes >+ // tableViewer.editElement(firstSignon, 1); >+ // CellEditor[] cellEditors = tableViewer.getCellEditors(); >+ // TextCellEditor passwordEditor = (TextCellEditor) cellEditors[1]; >+ // enterText((Text) passwordEditor.getControl(), "Cricket11Players"); >+ // assertEquals("Cricket11Players",firstSignon.getPassword()); >+ // >+ } >+ >+ public void testScenario08_01() { >+ // // Verify that binding to a Collection property (rather than an >+ // array) works >+ // without specifying data type >+ // TableViewerDescription tableViewerDescription = new >+ // TableViewerDescription( >+ // tableViewer); >+ // tableViewerDescription.addEditableColumn("userId"); >+ // tableViewerDescription.addEditableColumn("password"); >+ // getDbc().bind(tableViewerDescription, >+ // new Property(catalog, "signons"), null); >+ // Signon firstSignon = (Signon) catalog.getSignons().get(0); >+ // // Verify the UI matches the model >+ // TableItem firstTableItem = tableViewer.getTable().getItem(0); >+ // assertEquals(firstTableItem.getText(1),firstSignon.getPassword()); >+ // // Change the model and ensure the UI refreshes >+ // firstSignon.setPassword("Eclipse123Rocks"); >+ // assertEquals("Eclipse123Rocks",firstSignon.getPassword()); >+ // assertEquals(firstTableItem.getText(1),firstSignon.getPassword()); >+ // // Change the GUI and ensure the model refreshes >+ // tableViewer.editElement(firstSignon, 1); >+ // CellEditor[] cellEditors = tableViewer.getCellEditors(); >+ // TextCellEditor passwordEditor = (TextCellEditor) cellEditors[1]; >+ // enterText((Text) passwordEditor.getControl(), "Cricket11Players"); >+ // assertEquals("Cricket11Players",firstSignon.getPassword()); >+ // >+ } >+ >+ public void testScenario09() { >+ // // Verify that nested properties work. Catalog has adventures. >+ // Adventure has >+ // defaultLodging. Loding has name. >+ // TableViewerDescription tableViewerDescription = new >+ // TableViewerDescription(tableViewer); >+ // tableViewerDescription.addColumn("name"); >+ // tableViewerDescription.addColumn("defaultLodging.name"); >+ // getDbc().bind(tableViewerDescription,new Property(category, >+ // "adventures"),null); >+ // >+ } >+ >+ /** >+ * public void testScenario10(){ // Verify that for TIME_EARLY updating >+ * occurs on a per key basic for a TextCellEditor // Show that converters >+ * work for table columns Account[] accounts = catalog.getAccounts(); >+ * Account firstAccount = accounts[0]; >+ * SampleData.getSWTObservableFactory().setUpdateTime(DataBindingContext.TIME_EARLY); >+ * TableViewerDescription tableViewerDescription = new >+ * TableViewerDescription(tableViewer); >+ * tableViewerDescription.addEditableColumn("lastName"); >+ * tableViewerDescription.addColumn("lastName"); >+ * getDbc().bind(tableViewerDescription,new Property(catalog, "accounts"), >+ * null); // Verify that the first account is shown in the first row with >+ * the last name correctly >+ * assertEquals(tableViewer.getTable().getItem(0).getData(),firstAccount); >+ * assertEquals(tableViewer.getTable().getItem(0).getText(0),firstAccount.getLastName()); >+ * assertEquals(tableViewer.getTable().getItem(0).getText(1),firstAccount.getLastName()); // >+ * Create a cell editor over the first column >+ * tableViewer.editElement(firstAccount, 0); // Set the text property of the >+ * cell editor which is now active over the "firstName" column CellEditor[] >+ * cellEditors = tableViewer.getCellEditors(); TextCellEditor >+ * lastNameCellEditor = (TextCellEditor) cellEditors[0]; >+ * ((Text)lastNameCellEditor.getControl()).setText("E"); // Verify that the >+ * key press goes to the model assertEquals(firstAccount.getLastName(),"E"); } >+ */ > } >- >Index: src/org/eclipse/jface/tests/internal/databinding/viewers/ViewersObservableFactoryTests.java >=================================================================== >RCS file: src/org/eclipse/jface/tests/internal/databinding/viewers/ViewersObservableFactoryTests.java >diff -N src/org/eclipse/jface/tests/internal/databinding/viewers/ViewersObservableFactoryTests.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/tests/internal/databinding/viewers/ViewersObservableFactoryTests.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,65 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.jface.tests.internal.databinding.viewers; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.jface.internal.databinding.internal.swt.TextObservableValue; >+import org.eclipse.jface.internal.databinding.provisional.observable.IObservable; >+import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersObservableFactory; >+import org.eclipse.jface.viewers.TableViewer; >+import org.eclipse.jface.viewers.TextCellEditor; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.widgets.Shell; >+ >+/** >+ * @since 3.2 >+ * >+ */ >+public class ViewersObservableFactoryTests extends TestCase { >+ private ViewersObservableFactory factory; >+ private TableViewer viewer; >+ >+ /* (non-Javadoc) >+ * @see junit.framework.TestCase#setUp() >+ */ >+ protected void setUp() throws Exception { >+ super.setUp(); >+ >+ factory = new ViewersObservableFactory(); >+ >+ Shell shell = new Shell(); >+ viewer = new TableViewer(shell, SWT.NONE); >+ } >+ >+ public void testCreateTextCellEditorObservable() throws Exception { >+ TextCellEditor editor = new TextCellEditor(viewer.getTable()); >+ IObservable observable = factory.createObservable(editor); >+ assertNotNull(observable); >+ assertTrue(observable instanceof TextObservableValue); >+ } >+ >+ /** >+ * TextCellEditor must have been constructed with a parent. >+ * >+ * @throws Exception >+ */ >+ public void testCreateTextCellEditorObservableWithoutViewerException() throws Exception { >+ try { >+ TextCellEditor editor = new TextCellEditor(); >+ factory.createObservable(editor); >+ fail("Exception should have been thrown."); >+ } catch (IllegalArgumentException e) { >+ assertTrue(true); >+ } >+ } >+} >Index: src/org/eclipse/jface/tests/internal/databinding/viewers/EditorBindingManagerTests.java >=================================================================== >RCS file: src/org/eclipse/jface/tests/internal/databinding/viewers/EditorBindingManagerTests.java >diff -N src/org/eclipse/jface/tests/internal/databinding/viewers/EditorBindingManagerTests.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/tests/internal/databinding/viewers/EditorBindingManagerTests.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,163 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.jface.tests.internal.databinding.viewers; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.jface.examples.databinding.model.SampleData; >+import org.eclipse.jface.internal.databinding.internal.ValueBinding; >+import org.eclipse.jface.internal.databinding.provisional.Binding; >+import org.eclipse.jface.internal.databinding.provisional.DataBindingContext; >+import org.eclipse.jface.internal.databinding.provisional.description.Property; >+import org.eclipse.jface.internal.databinding.provisional.description.TableModelDescription; >+import org.eclipse.jface.internal.databinding.provisional.observable.IObservable; >+import org.eclipse.jface.internal.databinding.provisional.viewers.TableViewerEditorManager; >+import org.eclipse.jface.viewers.CellEditor; >+import org.eclipse.jface.viewers.TableViewer; >+import org.eclipse.jface.viewers.TextCellEditor; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.widgets.Shell; >+ >+/** >+ * @since 3.2 >+ */ >+public class EditorBindingManagerTests extends TestCase { >+ private TableViewer viewer; >+ >+ private DataBindingContext context; >+ >+ private TableModelDescription description; >+ private TableViewerEditorManager manager; >+ >+ protected void setUp() throws Exception { >+ Shell shell = new Shell(); >+ >+ viewer = new TableViewer(shell, SWT.NONE); >+ context = SampleData.getDatabindingContext(shell); >+ description = new TableModelDescription(new Property(null, null), >+ new String[] { "firstName", "middleName", "lastName" }); >+ manager = new TableViewerEditorManager(viewer, description, context); >+ } >+ >+ public void testConstruction() throws Exception { >+ assertEquals(viewer, manager.getTableViewer()); >+ assertEquals(description, manager.getTableModelDescription()); >+ assertEquals(context, manager.getDataBindingContext()); >+ } >+ >+ public void testConstructionExceptions() throws Exception { >+ try { >+ manager = new TableViewerEditorManager(null, description, context); >+ fail("Exception should have been thrown."); >+ } catch (NullPointerException e) { >+ assertTrue(true); >+ } >+ >+ try { >+ manager = new TableViewerEditorManager(viewer, null, context); >+ fail("Exception should have been thrown."); >+ } catch (NullPointerException e) { >+ assertTrue(true); >+ } >+ >+ try { >+ manager = new TableViewerEditorManager(viewer, description, null); >+ fail("Exception should have been thrown."); >+ } catch (NullPointerException e) { >+ assertTrue(true); >+ } >+ } >+ >+ public void testCellModifierCreation() throws Exception { >+ assertNotNull(viewer.getCellModifier()); >+ } >+ >+ public void testCellEditorArrayCreation() throws Exception { >+ CellEditor[] editors = viewer.getCellEditors(); >+ assertNotNull(editors); >+ assertEquals(description.getColumnIDs().length, editors.length); >+ } >+ >+ public void testSetColumnProperties() throws Exception { >+ Object[] properties = viewer.getColumnProperties(); >+ Object[] columnIDs = description.getColumnIDs(); >+ assertNotNull(properties); >+ assertEquals(columnIDs.length, properties.length); >+ >+ for (int i = 0; i < properties.length; i++) { >+ assertEquals(columnIDs[i], properties[i]); >+ } >+ } >+ >+ public void testBindEditor() throws Exception { >+ Binding binding = manager.bind(new TextCellEditor(), "firstName", String.class, >+ null); >+ assertNotNull(binding); >+ assertTrue(binding instanceof ValueBinding); >+ } >+ >+ public void testSetEditorOnViewer() throws Exception { >+ CellEditor editor = new TextCellEditor(); >+ manager.bind(editor, "firstName", String.class, null); >+ assertEquals(editor, viewer.getCellEditors()[0]); >+ } >+ >+ public void testBindEditorNullPointerExceptions() throws Exception { >+ try { >+ manager.bind(null, "firstName", String.class, null); >+ fail("Exception should have been thrown."); >+ } catch (NullPointerException e) { >+ assertTrue(true); >+ } >+ >+ try { >+ manager.bind(new TextCellEditor(viewer.getTable()), null, String.class, null); >+ fail("Exception should have been thrown."); >+ } catch (NullPointerException e) { >+ assertTrue(true); >+ } >+ >+ try { >+ manager.bind(new TextCellEditor(viewer.getTable()), "firstName", null, null); >+ fail("Exception should have been thrown."); >+ } catch (NullPointerException e) { >+ assertTrue(true); >+ } >+ } >+ >+ public void testCreateControlIfNullWhenBound() throws Exception { >+ TextCellEditor editor = new TextCellEditor(); >+ assertNull(editor.getControl()); >+ manager.bind(editor, "firstName", String.class, null); >+ assertNotNull(editor.getControl()); >+ } >+ >+ public void testIAEIfColumnIDNotFound() throws Exception { >+ try { >+ manager.bind(new TextCellEditor(viewer.getTable()), "invalid column ID", String.class, null); >+ fail("Exception should have been thrown."); >+ } catch (IllegalArgumentException e) { >+ assertTrue(true); >+ } >+ } >+ >+ public void testReuseSelectionAcrossBindings() throws Exception { >+ manager.bind(new TextCellEditor(), "firstName", String.class, null); >+ IObservable selection1 = manager.getSelectionObservable(); >+ assertNotNull(selection1); >+ >+ manager.bind(new TextCellEditor(), "lastName", String.class, null); >+ IObservable selection2 = manager.getSelectionObservable(); >+ assertNotNull(selection2); >+ assertSame(selection1, selection2); >+ } >+} >Index: src/org/eclipse/jface/tests/databinding/swt/TextObservableValueTests.java >=================================================================== >RCS file: src/org/eclipse/jface/tests/databinding/swt/TextObservableValueTests.java >diff -N src/org/eclipse/jface/tests/databinding/swt/TextObservableValueTests.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/tests/databinding/swt/TextObservableValueTests.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,132 @@ >+package org.eclipse.jface.tests.databinding.swt; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.jface.internal.databinding.internal.swt.TextObservableValue; >+import org.eclipse.jface.internal.databinding.provisional.observable.value.IObservableValue; >+import org.eclipse.jface.internal.databinding.provisional.observable.value.IValueChangeListener; >+import org.eclipse.jface.internal.databinding.provisional.observable.value.ValueDiff; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.Text; >+ >+/** >+ * Tests for TextObservableValue. >+ * >+ * @since 3.2 >+ */ >+public class TextObservableValueTests extends TestCase { >+ private Shell shell; >+ >+ private Text text; >+ >+ protected void setUp() throws Exception { >+ super.setUp(); >+ >+ shell = new Shell(); >+ text = new Text(shell, SWT.NONE); >+ } >+ >+ /** >+ * Asserts that if the a <code>null</code> Text is passed TextObservableValue throws a NPE. >+ */ >+ public void testConstructor() { >+ try { >+ new TextObservableValue(null, SWT.NONE); >+ fail(); >+ } catch (NullPointerException e) { >+ assertTrue(true); >+ } >+ } >+ >+ /** >+ * Asserts that only valid SWT event types are accepted on construction of TextObservableValue. >+ */ >+ public void testConstructorUpdateEventTypes() { >+ try { >+ new TextObservableValue(text, SWT.NONE); >+ new TextObservableValue(text, SWT.FocusOut); >+ new TextObservableValue(text, SWT.Modify); >+ assertTrue(true); >+ } catch (IllegalArgumentException e) { >+ fail(); >+ } >+ >+ try { >+ new TextObservableValue(text, SWT.Verify); >+ fail(); >+ } catch (IllegalArgumentException e) { >+ assertTrue(true); >+ } >+ } >+ >+ public void testFireValueChangeEventsOnFocusOut() { >+ TextObservableValue observable = new TextObservableValue(text, >+ SWT.FocusOut); >+ ValueChangeCounter counter = new ValueChangeCounter(); >+ observable.addValueChangeListener(counter); >+ >+ text.setText("value"); >+ assertEquals(0, counter.count); >+ text.notifyListeners(SWT.FocusOut, null); >+ assertEquals(1, counter.count); >+ } >+ >+ public void testFireValueChangeEventsOnModify() { >+ TextObservableValue observable = new TextObservableValue(text, >+ SWT.Modify); >+ ValueChangeCounter counter = new ValueChangeCounter(); >+ observable.addValueChangeListener(counter); >+ >+ text.setText("value"); >+ assertEquals(1, counter.count); >+ } >+ >+ public void testSuppressFireValueChangeEvents() { >+ TextObservableValue observable = new TextObservableValue(text, SWT.NONE); >+ ValueChangeCounter counter = new ValueChangeCounter(); >+ observable.addValueChangeListener(counter); >+ >+ text.setText("value"); >+ assertEquals(0, counter.count); >+ text.notifyListeners(SWT.Modify, null); >+ assertEquals(0, counter.count); >+ text.notifyListeners(SWT.FocusOut, null); >+ assertEquals(0, counter.count); >+ } >+ >+ public void testFireChangeEventsOnTraversal() { >+ TextObservableValue observable = TextObservableValue.asTraversalObservable(text, SWT.TRAVERSE_RETURN | SWT.TRAVERSE_TAB_NEXT); >+ >+ ValueChangeCounter counter = new ValueChangeCounter(); >+ observable.addValueChangeListener(counter); >+ >+ text.setText("value"); >+ assertEquals(0, counter.count); >+ text.notifyListeners(SWT.Modify, null); >+ assertEquals(0, counter.count); >+ text.notifyListeners(SWT.FocusOut, null); >+ assertEquals(0, counter.count); >+ >+ Event event = new Event(); >+ event.detail = SWT.TRAVERSE_RETURN; >+ >+ text.notifyListeners(SWT.Traverse, event); >+ assertEquals(1, counter.count); >+ >+ event = new Event(); >+ event.detail = SWT.TRAVERSE_TAB_NEXT; >+ >+ text.notifyListeners(SWT.Traverse, event); >+ assertEquals(2, counter.count); >+ } >+ >+ private class ValueChangeCounter implements IValueChangeListener { >+ private int count; >+ >+ public void handleValueChange(IObservableValue source, ValueDiff diff) { >+ count++; >+ } >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 144260
:
42873
|
43411
|
45272
|
45438
|
82061
|
82072