Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.jface.databinding/.classpath7
-rw-r--r--bundles/org.eclipse.jface.databinding/.cvsignore1
-rw-r--r--bundles/org.eclipse.jface.databinding/.project28
-rw-r--r--bundles/org.eclipse.jface.databinding/.settings/org.eclipse.jdt.core.prefs71
-rw-r--r--bundles/org.eclipse.jface.databinding/.settings/org.eclipse.jdt.ui.prefs7
-rw-r--r--bundles/org.eclipse.jface.databinding/.settings/org.eclipse.pde.prefs14
-rw-r--r--bundles/org.eclipse.jface.databinding/META-INF/MANIFEST.MF29
-rw-r--r--bundles/org.eclipse.jface.databinding/about.html28
-rw-r--r--bundles/org.eclipse.jface.databinding/build.properties17
-rw-r--r--bundles/org.eclipse.jface.databinding/component.xml39
-rw-r--r--bundles/org.eclipse.jface.databinding/plugin.properties12
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/BindSpec.java364
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/Binding.java134
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/BindingAdapter.java32
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/BindingEvent.java214
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/BindingException.java50
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/DataBindingContext.java499
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/IBindingListener.java34
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/AbstractObservable.java190
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/Diffs.java176
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/IChangeListener.java40
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/IDiff.java32
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/IObservable.java78
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/IObservableCollection.java28
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/IStaleListener.java28
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/ObservableTracker.java150
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/Observables.java94
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/AbstractObservableList.java399
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/IListChangeListener.java29
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/IObservableList.java168
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/ListDiff.java61
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/ListDiffEntry.java53
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/ObservableList.java364
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/WritableList.java170
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/masterdetail/DetailObservableList.java113
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/masterdetail/DetailObservableSet.java114
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/masterdetail/DetailObservableValue.java124
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/masterdetail/IObservableFactory.java29
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/masterdetail/MasterDetailObservables.java91
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/AbstractObservableSet.java256
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/IObservableSet.java126
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/ISetChangeListener.java27
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/ListToSetAdapter.java77
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/MappedSet.java142
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/ObservableSet.java256
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/SetDiff.java49
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/UnionSet.java201
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/WritableSet.java130
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/AbstractObservableValue.java104
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/AbstractVetoableValue.java97
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/ChangeVetoException.java28
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/ComputedValue.java185
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/IObservableValue.java63
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/IValueChangeListener.java26
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/IValueChangingListener.java29
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/IVetoableValue.java38
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/ValueDiff.java74
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/WritableValue.java76
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/util/ILogger.java38
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/util/Policy.java74
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/BindingMessages.java44
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/ClassLookupSupport.java90
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/IdentityWrapper.java50
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/LazyListBinding.java494
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/ListBinding.java183
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/Pair.java57
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/RandomAccessListIterator.java135
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/ValidationErrorList.java129
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/ValueBinding.java314
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/messages.properties37
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/IStalenessConsumer.java24
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/NestedObservableList.java121
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/NestedObservableSet.java122
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/NestedObservableValue.java132
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/ProxyObservableSet.java71
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/StalenessTracker.java125
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/UnmodifiableObservableList.java72
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/AbstractDataBindingContextFactory.java96
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/BindSpec.java140
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/Binding.java101
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/BindingAdapter.java29
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/BindingEvent.java41
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/BindingException.java51
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/DataBindingContext.java310
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/IBindingListener.java35
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertDate2String.java37
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2BigDecimal.java42
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Boolean.java38
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2BooleanPrimitive.java44
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Byte.java38
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2BytePrimitive.java41
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Character.java50
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Date.java34
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Double.java38
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2DoublePrimitive.java41
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Float.java38
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2FloatPrimitive.java41
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Integer.java38
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2IntegerPrimitive.java41
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Long.java38
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2LongPrimitive.java41
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Short.java38
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2ShortPrimitive.java41
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/Converter.java41
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/DateConversionSupport.java104
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/IConverter.java51
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/IdentityConverter.java107
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ToStringConverter.java60
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/description/ListModelDescription.java50
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/description/NestedProperty.java61
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/description/Property.java123
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/description/TableModelDescription.java70
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/BindSupportFactory.java95
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactory.java648
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindingFactory.java87
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultObservableFactory.java48
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/IBindingFactory.java40
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/IObservableFactory.java40
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/NestedObservableFactory.java184
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/ILazyDataRequestor.java105
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/ILazyListElementProvider.java29
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/LazyDeleteEvent.java33
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/LazyInsertDeleteProvider.java54
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/LazyInsertEvent.java45
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/AbstractObservableMapping.java46
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/AbstractObservableMultiMapping.java47
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/BaseObservableMapping.java102
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/BidirectionalMapping.java172
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IBidirectionalMapping.java53
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IMapping.java32
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IMappingChangeListener.java29
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IMultiMapping.java34
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IObservableMapping.java45
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IObservableMappingWithDomain.java35
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IObservableMultiMapping.java46
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IObservableMultiMappingWithDomain.java37
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/MappingDiff.java47
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/ObservableMappingWithDomain.java81
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/ObservableMultiMappingWithDomain.java126
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/IDomainValidator.java46
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/IValidator.java51
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/ObjectToPrimitiveValidator.java91
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/ReadOnlyValidator.java52
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/RegexStringValidator.java70
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2BigDecimalValidator.java53
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2BytePrimitiveValidator.java49
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2ByteValidator.java28
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2DateValidator.java52
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2DoublePrimitiveValidator.java53
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2DoubleValidator.java28
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2FloatPrimitiveValidator.java45
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2FloatValidator.java28
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2IntegerPrimitiveValidator.java49
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2IntegerValidator.java29
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2LongPrimitiveValidator.java49
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2LongValidator.java28
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2ShortPrimitiveValidator.java49
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2ShortValidator.java28
-rw-r--r--bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/ValidationError.java97
-rw-r--r--examples/org.eclipse.jface.examples.databinding/.classpath7
-rw-r--r--examples/org.eclipse.jface.examples.databinding/.cvsignore1
-rw-r--r--examples/org.eclipse.jface.examples.databinding/.project30
-rw-r--r--examples/org.eclipse.jface.examples.databinding/.settings/org.eclipse.jdt.core.prefs71
-rw-r--r--examples/org.eclipse.jface.examples.databinding/.settings/org.eclipse.jdt.ui.prefs7
-rw-r--r--examples/org.eclipse.jface.examples.databinding/.settings/org.eclipse.pde.prefs14
-rw-r--r--examples/org.eclipse.jface.examples.databinding/META-INF/MANIFEST.MF27
-rw-r--r--examples/org.eclipse.jface.examples.databinding/about.html28
-rw-r--r--examples/org.eclipse.jface.examples.databinding/build.properties18
-rw-r--r--examples/org.eclipse.jface.examples.databinding/plugin.properties12
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/DataBindingFactory1.java90
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ExampleBinding.java86
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/HelloWorld.java59
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ModelObject.java82
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/AbsoluteLayout.java69
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/CompositeTable.java1273
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/IDeleteHandler.java37
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/IInsertHandler.java33
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/IRowContentProvider.java35
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/IRowFocusListener.java58
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/InternalCompositeTable.java2097
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/RowConstructionListener.java46
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/RowFocusAdapter.java46
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/ScrollEvent.java68
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/ScrollListener.java27
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/binding/CompositeTableObservableLazyDataRequestor.java176
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/binding/IRowBinder.java35
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/AbstractEventEditor.java195
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/CalendarableItemEvent.java47
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/CalendarableItemEventHandler.java44
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/CalendarableSelectionChangeListener.java36
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/DayEditor.java1411
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/DayEditorSelection.java69
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/DayEditorTest.java255
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/NewEvent.java52
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/SelectionChangeEvent.java43
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/TODO.txt40
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/binding/EventDateTimeDiff.java104
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/binding/EventEditorBindingDescription.java79
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/binding/EventEditorObservableLazyDataRequestor.java634
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/binding/EventEditorObservableLazyDataRequestorFactory.java36
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/binding/calendar-day-mode-binding.svg479
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/DayEditorCalendarableItemControl.java347
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/EventLayoutComputer.java226
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/ICalendarableItemControl.java97
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/TimeSlice.java375
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/TimeSlot.java311
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/clock.pngbin733 -> 0 bytes
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/clock.svg276
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/internal/EmptyTablePlaceholder.java201
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/internal/ISelectableRegionControl.java49
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/internal/TableRow.java204
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/MonthCalendar.java751
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/MonthCalendarSelectedDay.java49
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/MonthCalendarTest.java58
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/MonthCalendarableItemControl.java852
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/internal/Day.java404
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/internal/Week.java75
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/internal/WeekHeader.java113
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/reflect/DuckType.java122
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/reflect/ReflectedMethod.java86
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/reflect/ReflectedProperty.java104
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/reflect/RelaxedDuckType.java70
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/CompositeTableTest.java185
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/CompositeTableTestBinding.java142
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/Header.java51
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/Model.java64
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/Person.java63
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/Row.java42
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/Snippet004CompositeTable.java112
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/CalendarableItem.java536
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/CalendarableModel.java741
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/DisposeListener.java30
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/EventContentProvider.java31
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/EventCountProvider.java30
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/IEventEditor.java393
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/AsynchronousTestSet.java163
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/LabelProviderTest.java204
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/LabelProviderTest2.java204
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/RenamableItem.java53
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/SimpleNode.java39
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/SomeMathFunction.java119
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/StructuredContentProviderTest.java393
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/TreeContentProviderTest.java191
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/mask/EditMask.java446
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/mask/EditMaskParseException.java51
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/mask/EditMaskTest.java35
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/mask/internal/EditMaskLexerAndToken.java189
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/mask/internal/EditMaskParser.java147
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Account.java85
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Adventure.java113
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/AdventureFactory.java43
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/AggregateObservableValue.java101
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Cart.java25
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Catalog.java89
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Category.java40
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Lodging.java40
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/PriceModelObject.java61
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/SampleData.java219
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Signon.java41
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/SimpleModel.java37
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/SimpleOrder.java62
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/SimplePerson.java109
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Transportation.java40
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/nestedselection/BindingFactory.java98
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/nestedselection/TestMasterDetail.java224
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/radioGroup/RadioGroup.java549
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/radioGroup/VetoableSelectionListener.java19
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet000HelloWorld.java112
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet001NestedSelectionWithCombo.java217
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet002UpdateComboRetainSelection.java159
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet003UpdateComboBindUsingViewer.java160
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet004DataBindingContextErrorLabel.java78
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/spreadsheet/Spreadsheet.java295
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/layout/GridDataFactory.java400
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/layout/GridLayoutFactory.java300
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/layout/LayoutConstants.java80
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/layout/LayoutGenerator.java201
-rw-r--r--tests/org.eclipse.jface.tests.databinding/.classpath7
-rw-r--r--tests/org.eclipse.jface.tests.databinding/.cvsignore1
-rw-r--r--tests/org.eclipse.jface.tests.databinding/.project28
-rw-r--r--tests/org.eclipse.jface.tests.databinding/.settings/org.eclipse.jdt.core.prefs71
-rw-r--r--tests/org.eclipse.jface.tests.databinding/.settings/org.eclipse.jdt.ui.prefs7
-rw-r--r--tests/org.eclipse.jface.tests.databinding/.settings/org.eclipse.pde.prefs14
-rw-r--r--tests/org.eclipse.jface.tests.databinding/JFace-Data Binding Test Suite.launch36
-rw-r--r--tests/org.eclipse.jface.tests.databinding/META-INF/MANIFEST.MF18
-rw-r--r--tests/org.eclipse.jface.tests.databinding/about.html28
-rw-r--r--tests/org.eclipse.jface.tests.databinding/build.properties20
-rw-r--r--tests/org.eclipse.jface.tests.databinding/plugin.properties12
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/radiogroup/RadioGroupTest.java286
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/radiogroup/RadioGroupTestApplication.java60
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CMClientFixture.java104
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CMTimedEventFixture.java91
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CalendarControlTestSuite.java35
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CalendarableModel_TestTimedFindMethods.java275
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CalendarableModel_testInit.java102
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CalendarableModel_testRefreshResults.java341
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/DayModel_testGetColumnsForEvents.java296
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/IdentityConverterTest.java121
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryBooleanPrimitiveTest.java164
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryBytePrimitiveTest.java164
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryDoublePrimitiveTest.java164
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryFloatPrimitiveTest.java164
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryIntTest.java165
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryLongPrimitiveTest.java164
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryShortPrimitiveTest.java164
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryTest.java131
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/ObjectToPrimitiveValidatorTest.java56
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindSpecTests.java224
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindingTestSuite.java106
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/CalculatedValueTest.java184
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/DatabindingContextTest.java662
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/EventEditor.java249
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/EventEditorObservableLazyDataRequestorTest.java592
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/IDiffsTest.java136
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/JavaBeansScalarObservableValueFactoryTest.java45
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/LazyDataRequestor.java173
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/LazyListBindingTest.java138
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/ObservableTest.java162
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/RandomAccessListIteratorTest.java87
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/SelectionAwareObservableCollectionTest.java103
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/mask/EditMaskLexerAndTokenTest.java98
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/mask/EditMaskParserTest.java105
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/observable/value/WritableValueTest.java60
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/AutomationUtil.java59
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/BindingScenariosTestSuite.java105
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ButtonControlScenario.java105
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboScenarios.java528
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboUpdatingTest.java204
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboViewerScenario.java104
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomBeanBindSupportFactory.java95
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomBeanModelType.java58
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomBeanObservableFactory.java103
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomConverterScenarios.java96
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomScenarios.java92
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/LabelControlScenario.java57
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ListViewerScenario.java106
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/MasterDetailScenarios.java378
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/NPETestScenario.java66
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/NewTableScenarios.java445
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ObservableFactoriesTest.java147
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/PropertyScenarios.java570
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ScenariosTestCase.java146
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/SpinnerControlScenario.java60
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/TableScenarios.java412
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/TextControlScenario.java297
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/smoketest/swt.xswt301
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/AbstractGetAndSetSelectionObservableCollectionTest.java49
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/AutoSelectTableViewerCollectionExtendedTest.java56
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/AutoSelectTableViewerCollectionTest.java55
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/CComboObservableCollectionTest.java47
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/ComboObservableCollectionTest.java47
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/CopyOfAutoSelectTableViewerCollectionExtendedTest.java55
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/ListObservableCollectionTest.java47
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/ObservableCollectionViewerTest.java46
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/TableViewerObservableCollectionTest.java46
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/TextObservableValueTests.java57
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/util/Mocks.java321
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/util/MocksTest.java200
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/examples/model/PersonTests.java52
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/internal/ValueBindingTest.java55
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/internal/observable/UnmodifiableObservableListTest.java172
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/internal/viewers/SVOCWLTest.java114
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/internal/viewers/SelectionProviderSingleSelectionObservableValueTest.java141
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/provisional/observable/AbstractObservableTest.java216
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/provisional/observable/ObservablesTest.java47
-rw-r--r--tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/provisional/viewers/ViewersObservableFactoryTest.java92
-rw-r--r--tests/org.eclipse.jface.tests.databinding/test.xml50
367 files changed, 0 insertions, 48300 deletions
diff --git a/bundles/org.eclipse.jface.databinding/.classpath b/bundles/org.eclipse.jface.databinding/.classpath
deleted file mode 100644
index d512f63a..00000000
--- a/bundles/org.eclipse.jface.databinding/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/executionEnvironments/J2SE-1.4"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/bundles/org.eclipse.jface.databinding/.cvsignore b/bundles/org.eclipse.jface.databinding/.cvsignore
deleted file mode 100644
index ba077a40..00000000
--- a/bundles/org.eclipse.jface.databinding/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/bundles/org.eclipse.jface.databinding/.project b/bundles/org.eclipse.jface.databinding/.project
deleted file mode 100644
index e65e9851..00000000
--- a/bundles/org.eclipse.jface.databinding/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jface.databinding</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/bundles/org.eclipse.jface.databinding/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.jface.databinding/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 6013860a..00000000
--- a/bundles/org.eclipse.jface.databinding/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,71 +0,0 @@
-#Thu Aug 24 16:37:29 EDT 2006
-eclipse.preferences.version=1
-org.eclipse.jdt.core.builder.cleanOutputFolder=clean
-org.eclipse.jdt.core.builder.duplicateResourceTask=warning
-org.eclipse.jdt.core.builder.invalidClasspath=abort
-org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
-org.eclipse.jdt.core.circularClasspath=error
-org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
-org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.4
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.doc.comment.support=enabled
-org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=error
-org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=error
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=error
-org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
-org.eclipse.jdt.core.compiler.problem.missingJavadocComments=error
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
-org.eclipse.jdt.core.compiler.problem.missingJavadocTags=error
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=error
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=error
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=error
-org.eclipse.jdt.core.compiler.problem.unusedLabel=error
-org.eclipse.jdt.core.compiler.problem.unusedLocal=error
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.3
-org.eclipse.jdt.core.incompatibleJDKLevel=ignore
-org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/bundles/org.eclipse.jface.databinding/.settings/org.eclipse.jdt.ui.prefs b/bundles/org.eclipse.jface.databinding/.settings/org.eclipse.jdt.ui.prefs
deleted file mode 100644
index 59509e09..00000000
--- a/bundles/org.eclipse.jface.databinding/.settings/org.eclipse.jdt.ui.prefs
+++ /dev/null
@@ -1,7 +0,0 @@
-#Thu Aug 24 15:24:48 EDT 2006
-eclipse.preferences.version=1
-org.eclipse.jdt.ui.exception.name=e
-org.eclipse.jdt.ui.gettersetter.use.is=true
-org.eclipse.jdt.ui.javadoc=true
-org.eclipse.jdt.ui.overrideannotation=true
-org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return Returns the ${bare_field_name}.\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} The ${bare_field_name} to set.\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*******************************************************************************\n * Copyright (c) ${year} IBM Corporation and others.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http\://www.eclipse.org/legal/epl-v10.html\n *\n * Contributors\:\n * IBM Corporation - initial API and implementation\n ******************************************************************************/\n</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @since 3.3\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template></templates>
diff --git a/bundles/org.eclipse.jface.databinding/.settings/org.eclipse.pde.prefs b/bundles/org.eclipse.jface.databinding/.settings/org.eclipse.pde.prefs
deleted file mode 100644
index fee4b048..00000000
--- a/bundles/org.eclipse.jface.databinding/.settings/org.eclipse.pde.prefs
+++ /dev/null
@@ -1,14 +0,0 @@
-#Sat Mar 19 15:31:31 EST 2005
-compilers.p.deprecated=0
-compilers.p.illegal-att-value=0
-compilers.p.no-required-att=0
-compilers.p.not-externalized-att=0
-compilers.p.unknown-attribute=0
-compilers.p.unknown-class=0
-compilers.p.unknown-element=1
-compilers.p.unknown-resource=0
-compilers.p.unresolved-ex-points=0
-compilers.p.unresolved-import=0
-compilers.p.unused-element-or-attribute=1
-compilers.use-project=true
-eclipse.preferences.version=1
diff --git a/bundles/org.eclipse.jface.databinding/META-INF/MANIFEST.MF b/bundles/org.eclipse.jface.databinding/META-INF/MANIFEST.MF
deleted file mode 100644
index 7e24d4eb..00000000
--- a/bundles/org.eclipse.jface.databinding/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,29 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.jface.databinding
-Bundle-Version: 1.1.0.qualifier
-Bundle-ClassPath: .
-Bundle-Vendor: %providerName
-Bundle-Localization: plugin
-Eclipse-LazyStart: true
-Export-Package: org.eclipse.jface.databinding,
- org.eclipse.jface.databinding.observable,
- org.eclipse.jface.databinding.observable.list;x-internal:=false,
- org.eclipse.jface.databinding.observable.masterdetail,
- org.eclipse.jface.databinding.observable.set;x-internal:=false,
- org.eclipse.jface.databinding.observable.value;x-internal:=false,
- org.eclipse.jface.databinding.util,
- org.eclipse.jface.internal.databinding.internal;x-internal:=true,
- org.eclipse.jface.internal.databinding.internal.observable;x-internal:=true,
- org.eclipse.jface.internal.databinding.provisional;x-internal:=false,
- org.eclipse.jface.internal.databinding.provisional.conversion;x-internal:=false,
- org.eclipse.jface.internal.databinding.provisional.description;x-internal:=false,
- org.eclipse.jface.internal.databinding.provisional.factories;x-internal:=false,
- org.eclipse.jface.internal.databinding.provisional.observable;x-internal:=false,
- org.eclipse.jface.internal.databinding.provisional.observable.mapping;x-internal:=false,
- org.eclipse.jface.internal.databinding.provisional.validation;x-internal:=false
-Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.1.0,4.0.0)";resolution:=optional,
- org.eclipse.equinox.common;bundle-version="[3.2.0,4.0.0)";resolution:=optional
-Import-Package: com.ibm.icu.text
-Bundle-RequiredExecutionEnvironment: J2SE-1.4
diff --git a/bundles/org.eclipse.jface.databinding/about.html b/bundles/org.eclipse.jface.databinding/about.html
deleted file mode 100644
index 46023304..00000000
--- a/bundles/org.eclipse.jface.databinding/about.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
-<title>About</title>
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>June 2, 2006</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
-
-</body>
-</html> \ No newline at end of file
diff --git a/bundles/org.eclipse.jface.databinding/build.properties b/bundles/org.eclipse.jface.databinding/build.properties
deleted file mode 100644
index 67499e3d..00000000
--- a/bundles/org.eclipse.jface.databinding/build.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-###############################################################################
-# Copyright (c) 2003, 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
-###############################################################################
-bin.includes = .,\
- META-INF/,\
- plugin.properties,\
- about.html
-output.databinding.jar = bin/
-src.includes = about.html
-source.. = src/
diff --git a/bundles/org.eclipse.jface.databinding/component.xml b/bundles/org.eclipse.jface.databinding/component.xml
deleted file mode 100644
index 95944ec1..00000000
--- a/bundles/org.eclipse.jface.databinding/component.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<component xmlns="http://eclipse.org/component"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://eclipse.org/component ../component.xsd "
- name="JFace Data Binding">
- <plugin id="org.eclipse.jface.databinding" />
-
- <package name="org.eclipse.jface.internal.provisional.databinding" >
- <type name="BindingException" subclass="false"/>
- <type name="BindSpec"/>
- <type name="ChangeEvent" subclass="false"/>
- <type name="ConditionalUpdatableValue"/>
- <type name="Converter"/>
- <type name="DataBinding" subclass="false"/>
- <type name="DefaultCellModifier" subclass="false"/>
- <type name="IBindSpec" implement="false"/>
- <type name="IBindSupportFactory"/>
- <type name="IChangeEvent" implement="false"/>
- <type name="IChangeListener"/>
- <type name="IConverter"/>
- <type name="IDataBindingContext" implement="false"/>
- <type name="IdentityConverter" subclass="false"/>
- <type name="IUpdatable" implement="false"/>
- <type name="IUpdatableCollection"/>
- <type name="IUpdatableFactory"/>
- <type name="IUpdatableValue"/>
- <type name="IValidationContext" implement="false"/>
- <type name="IValidator"/>
- <type name="PropertyDescription" subclass="false"/>
- <type name="SettableValue"/>
- <type name="TableViewerDescription" subclass="false"/>
- <type name="Updatable"/>
- <type name="UpdatableValue"/>
- </package>
-
- <component-depends unrestricted="true"/>
-
-</component>
diff --git a/bundles/org.eclipse.jface.databinding/plugin.properties b/bundles/org.eclipse.jface.databinding/plugin.properties
deleted file mode 100644
index e18f3957..00000000
--- a/bundles/org.eclipse.jface.databinding/plugin.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 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
-###############################################################################
-pluginName = JFace Data Binding
-providerName = Eclipse.org
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/BindSpec.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/BindSpec.java
deleted file mode 100644
index 188cf35e..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/BindSpec.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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
- * Brad Reynolds (bug 135316)
- *******************************************************************************/
-package org.eclipse.jface.databinding;
-
-import org.eclipse.jface.internal.databinding.provisional.conversion.IConverter;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertDeleteProvider;
-import org.eclipse.jface.internal.databinding.provisional.validation.IDomainValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.IValidator;
-
-
-/**
- * Data binding has three concerns, the target, the model, and the data flow
- * between the target and model. BindSpec contains values and settings that
- * influence how data binding manages this data flow between the target and the
- * model.
- *
- * @since 1.0
- */
-public class BindSpec {
-
- private IConverter[] modelToTargetConverters;
-
- private IConverter[] targetToModelConverters;
-
- private IValidator[] targetValidators;
-
- private LazyInsertDeleteProvider lazyInsertDeleteProvider = new LazyInsertDeleteProvider();
-
- private IDomainValidator domainValidator;
-
- private Integer modelUpdatePolicy;
-
- private Integer validatePolicy;
-
- private Integer targetUpdatePolicy;
-
- private boolean updateModel = true;
-
- private boolean updateTarget = true;
-
- private static final IValidator[] EMPTY_VALIDATORS = new IValidator[0];
-
- private static final IConverter[] EMPTY_CONVERTERS = new IConverter[0];
-
- /**
- * Default constructor that initializes all objects to their defaults.
- */
- public BindSpec() {
- }
-
- /**
- * Creates a bind spec with the given converters, validators, and update
- * policies.
- *
- * @param modelToTargetConverter
- * @param targetToModelConverter
- * @param targetValidator
- * @param domainValidator
- * @param modelUpdatePolicy
- * @param validatePolicy
- * @param targetUpdatePolicy
- * @param lazyInsertDeleteProvider
- *
- */
- protected BindSpec(IConverter[] modelToTargetConverter,
- IConverter[] targetToModelConverter, IValidator[] targetValidator,
- IDomainValidator domainValidator, Integer modelUpdatePolicy,
- Integer validatePolicy, Integer targetUpdatePolicy,
- LazyInsertDeleteProvider lazyInsertDeleteProvider) {
-
- this.modelToTargetConverters = modelToTargetConverter;
- this.targetToModelConverters = targetToModelConverter;
- this.targetValidators = targetValidator;
- this.domainValidator = domainValidator;
- this.modelUpdatePolicy = modelUpdatePolicy;
- this.validatePolicy = validatePolicy;
- this.targetUpdatePolicy = targetUpdatePolicy;
- this.lazyInsertDeleteProvider = lazyInsertDeleteProvider;
- }
-
- /**
- * Returns the converter to be used, or <code>null</code> if a default
- * converter should be used.
- *
- * @return the converter, or <code>null</code>
- */
- public IConverter getModelToTargetConverter() {
- return (getModelToTargetConverters().length == 0) ? null
- : getModelToTargetConverters()[0];
- }
-
- /**
- * Returns the converters to be used, or an empty array if a default
- * converter should be used.
- *
- * @return the converters, or an empty array if none
- */
- public IConverter[] getModelToTargetConverters() {
- return (modelToTargetConverters == null) ? EMPTY_CONVERTERS
- : modelToTargetConverters;
- }
-
- /**
- * Returns the converter to be used, or <code>null</code> if a default
- * converter should be used.
- *
- * @return the converter, or <code>null</code>
- */
- public IConverter getTargetToModelConverter() {
- return (getTargetToModelConverters().length == 0) ? null
- : getTargetToModelConverters()[0];
- }
-
- /**
- * Returns the converters to be used, or <code>null</code> if a default
- * converter should be used.
- *
- * @return the converters, or an empty array if none
- */
- public IConverter[] getTargetToModelConverters() {
- return (targetToModelConverters == null) ? EMPTY_CONVERTERS
- : targetToModelConverters;
- }
-
- /**
- * Returns the validator to be used, or <code>null</code> if a default
- * validator should be used.
- *
- * @return the validator, or <code>null</code>
- */
- public IValidator getTypeConversionValidator() {
- return (getTypeConversionValidators().length == 0) ? null
- : getTypeConversionValidators()[0];
- }
-
- /**
- * Returns the validators to be used, or an empty array if a default
- * validator should be used.
- *
- * @return the validators or an empty array if none
- */
- public IValidator[] getTypeConversionValidators() {
- return (targetValidators == null) ? EMPTY_VALIDATORS : targetValidators;
- }
-
- /**
- * Returns the validator to be used, or <code>null</code> if a default
- * validator should be used.
- *
- * @return the validator, or <code>null</code>
- */
- public IDomainValidator getDomainValidator() {
- return domainValidator;
- }
-
- /**
- * Returns the update policy to be used for updating the model when the
- * target has changed
- *
- * @return the update policy, or <code>null</code> if unspecified
- *
- * @see DataBindingContext#POLICY_AUTOMATIC
- * @see DataBindingContext#POLICY_EXPLICIT
- */
- public Integer getModelUpdatePolicy() {
- return modelUpdatePolicy;
- }
-
- /**
- * Returns the validate policy to be used for validating changes to the
- * target
- *
- * @return the update policy, or <code>null</code> if unspecified
- *
- * @see DataBindingContext#POLICY_AUTOMATIC
- * @see DataBindingContext#POLICY_EXPLICIT
- */
- public Integer getValidatePolicy() {
- return validatePolicy;
- }
-
- /**
- * Returns the update policy to be used for updating the target when the
- * model has changed
- *
- * @return the update policy, or <code>null</code> if unspecified
- *
- * @see DataBindingContext#POLICY_AUTOMATIC
- * @see DataBindingContext#POLICY_EXPLICIT
- */
- public Integer getTargetUpdatePolicy() {
- return targetUpdatePolicy;
- }
-
- /**
- * Sets the model to target converter.
- *
- * @param converter <code>null</code> allowed and will remove all existing converters.
- * @return this BindSpec, to enable chaining of method calls
- */
- public BindSpec setModelToTargetConverter(IConverter converter) {
- return (converter == null) ? setModelToTargetConverters(null)
- : setModelToTargetConverters(new IConverter[] { converter });
- }
-
- /**
- * Sets the model to target converters.
- *
- * @param converters <code>null</code> allowed and will remove all existing converters.
- * @return this BindSpec, to enable chaining of method calls
- */
- public BindSpec setModelToTargetConverters(IConverter[] converters) {
- this.modelToTargetConverters = converters;
- return this;
- }
-
- /**
- * Sets the target to model converter.
- *
- * @param converter <code>null</code> allowed and will remove all existing converters.
- * @return this BindSpec, to enable chaining of method calls
- */
- public BindSpec setTargetToModelConverter(IConverter converter) {
- return (converter == null) ? setTargetToModelConverters(null)
- : setTargetToModelConverters(new IConverter[] { converter });
- }
-
- /**
- * Sets the target to model converters.
- *
- * @param converters <code>null</code> allowed and will remove all existing converters.
- * @return this BindSpec, to enable chaining of method calls
- */
- public BindSpec setTargetToModelConverters(IConverter[] converters) {
- this.targetToModelConverters = converters;
- return this;
- }
-
- /**
- * Sets the validator.
- *
- * @param validator <code>null</code> allowed and will remove all existing validators.
- * @return this BindSpec, to enable chaining of method calls
- */
- public BindSpec setValidator(IValidator validator) {
- return (validator == null) ? setValidators(null)
- : setValidators(new IValidator[] { validator });
- }
-
- /**
- * Sets the validators.
- *
- * @param validators <code>null</code> allowed and will remove all existing validators.
- * @return this BindSpec, to enable chaining of method calls
- */
- public BindSpec setValidators(IValidator[] validators) {
- this.targetValidators = validators;
- return this;
- }
-
- /**
- * Sets the domain validator.
- *
- * @param validator <code>null</code> allowed
- * @return this BindSpec, to enable chaining of method calls
- */
- public BindSpec setDomainValidator(IDomainValidator validator) {
- this.domainValidator = validator;
- return this;
- }
-
- /**
- * @return true if the model should be updated by the binding
- */
- public boolean isUpdateModel() {
- return updateModel;
- }
-
- /**
- * @return true if the target should be updated by the binding
- */
- public boolean isUpdateTarget() {
- return updateTarget;
- }
-
- /**
- * @param updateModel
- * The updateModel to set.
- * @return this BindSpec, to enable chaining of method calls
- */
- public BindSpec setUpdateModel(boolean updateModel) {
- this.updateModel = updateModel;
- return this;
- }
-
- /**
- * @param updateTarget
- * The updateTarget to set.
- * @return this BindSpec, to enable chaining of method calls
- */
- public BindSpec setUpdateTarget(boolean updateTarget) {
- this.updateTarget = updateTarget;
- return this;
- }
-
- /**
- * @param modelUpdatePolicy
- * The modelUpdatePolicy to set.
- * @return this BindSpec, to enable chaining of method calls
- */
- public BindSpec setModelUpdatePolicy(Integer modelUpdatePolicy) {
- this.modelUpdatePolicy = modelUpdatePolicy;
- return this;
- }
-
- /**
- * @param targetUpdatePolicy
- * The targetUpdatePolicy to set.
- * @return this BindSpec, to enable chaining of method calls
- */
- public BindSpec setTargetUpdatePolicy(Integer targetUpdatePolicy) {
- this.targetUpdatePolicy = targetUpdatePolicy;
- return this;
- }
-
- /**
- * @param validatePolicy
- * The validatePolicy to set.
- * @return this BindSpec, to enable chaining of method calls
- */
- public BindSpec setValidatePolicy(Integer validatePolicy) {
- this.validatePolicy = validatePolicy;
- return this;
- }
-
-
- /**
- * @return Returns the lazyInsertDeleteProvider.
- */
- public LazyInsertDeleteProvider getLazyInsertDeleteProvider() {
- return lazyInsertDeleteProvider;
- }
-
-
- /**
- * @param lazyInsertDeleteProvider The lazyInsertDeleteProvider to set.
- * @return this BindSpec, to enable chaining of method calls
- */
- public BindSpec setLazyInsertDeleteProvider(
- LazyInsertDeleteProvider lazyInsertDeleteProvider) {
- this.lazyInsertDeleteProvider = lazyInsertDeleteProvider;
- return this;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/Binding.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/Binding.java
deleted file mode 100644
index b3bbfa00..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/Binding.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * 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.databinding;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.internal.databinding.provisional.validation.ValidationError;
-
-/**
- * The interface that represents a binding between a model and a target.
- *
- * This interface is not intended to be implemented by clients.
- *
- * @since 1.0
- */
-public abstract class Binding {
-
- private List bindingEventListeners = new ArrayList();
-
- protected DataBindingContext context;
-
- /**
- * @param context
- */
- public Binding(DataBindingContext context) {
- this.context = context;
- }
-
- /**
- * Add a listener to the set of listeners that will be notified when an
- * event occurs in the data flow pipeline that is managed by this Binding.
- *
- * @param listener
- * The listener to add.
- */
- public void addBindingEventListener(IBindingListener listener) {
- bindingEventListeners.add(listener);
- }
-
- /**
- * Fires the given event to the binding event listeners, exiting early when
- * one of the listeners flags a validation error. If no listener flags a
- * validation error, the data binding context's binding listeners will be
- * notified in the same manner.
- *
- * @param event
- * @return the validation error, or null
- */
- protected ValidationError fireBindingEvent(BindingEvent event) {
- ValidationError result = null;
- IBindingListener[] listeners = (IBindingListener[]) bindingEventListeners
- .toArray(new IBindingListener[bindingEventListeners.size()]);
- for (int i = 0; i < listeners.length; i++) {
- IBindingListener listener = listeners[i];
- result = listener.bindingEvent(event);
- if (result != null)
- break;
- }
- if (result == null)
- result = context.fireBindingEvent(event);
- return result;
- }
-
- /**
- * @return an observable value containing the current partial validation
- * error or null
- */
- public abstract IObservableValue getPartialValidationError();
-
- /**
- * @return an observable value containing the current validation error or
- * null
- */
- public abstract IObservableValue getValidationError();
-
- /**
- * Removes a listener from the set of listeners that will be notified when
- * an event occurs in the data flow pipeline that is managed by this
- * Binding.
- *
- * @param listener
- * The listener to remove.
- */
- public void removeBindingEventListener(IBindingListener listener) {
- bindingEventListeners.remove(listener);
- }
-
- /**
- *
- */
- public abstract void updateModelFromTarget();
-
- /**
- *
- */
- public abstract void updateTargetFromModel();
-
- /**
- * Disposes of this Binding. Subclasses may extend, but must call super.dispose().
- */
- public void dispose() {
- bindingEventListeners = null;
- context = null;
- disposed = true;
- }
-
- protected boolean disposed = false;
-
- /**
- * @return true if the binding has been disposed. false otherwise.
- */
- public boolean isDisposed() {
- return disposed;
- }
-
- /**
- * @param context
- */
- public void setDataBindingContext(DataBindingContext context) {
- this.context = context;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/BindingAdapter.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/BindingAdapter.java
deleted file mode 100644
index f80f389c..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/BindingAdapter.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * 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.databinding;
-
-import org.eclipse.jface.internal.databinding.provisional.validation.ValidationError;
-
-/**
- * A default implementation for an IBindingListener event handler.
- *
- * @since 1.0
- *
- * implementation note: This class implements a deprecated interface for backwards compatibility.
- */
-public class BindingAdapter implements IBindingListener {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.IBindingListener#bindingEvent(org.eclipse.jface.databinding.BindingEvent)
- */
- public ValidationError bindingEvent(BindingEvent e) {
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/BindingEvent.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/BindingEvent.java
deleted file mode 100644
index f9f83f0a..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/BindingEvent.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*******************************************************************************
- * 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.databinding;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jface.databinding.observable.IDiff;
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.internal.databinding.provisional.validation.ValidationError;
-
-/**
- * The event that is passed to a #bindingEvent method of an IBindingListener.
- * This class is not intended to be subclassed by clients.
- *
- * @since 1.0
- */
-public class BindingEvent {
- /**
- * (Non-API Method) Construct a BindingEvent.
- *
- * @param model
- * @param target
- * @param diff
- * @param copyType
- * @param pipelinePosition
- * The initial processing pipeline position.
- */
- public BindingEvent(IObservable model, IObservable target, IDiff diff, int copyType,
- int pipelinePosition) {
- this.model = model;
- this.target = target;
- this.diff = diff;
- this.copyType = copyType;
- this.pipelinePosition = pipelinePosition;
- createSymbolTable();
- }
-
- /**
- * The model observable for the change that is being processed.
- */
- public final IObservable model;
-
- /**
- * The target observable for the change that is being processed.
- */
- public final IObservable target;
-
- /**
- * The diff describing the change, or <code>null</code> if no diff is
- * available.
- */
- public final IDiff diff;
-
- /**
- * The direction in which data is copied, either EVENT_COPY_TO_TARGET
- * or EVENT_COPY_TO_MODEL.
- */
- public final int copyType;
-
- /**
- * The position in the processing pipeline where this event is occuring. One
- * of the PIPELINE_* constants. The order in which these events occur may be
- * version or implementation dependent. The contract is that these events
- * will accurately reflect the internal processing that the data binding
- * framework is currently performing.
- * <p>
- * Although this value is not declared final, changing it does not have any
- * effect.
- */
- public int pipelinePosition;
-
- /**
- * The current ValidationError object (if there is one).
- */
- public ValidationError validationError;
-
- /**
- * Holds the value that was retrieved from the source updatable. Setting the
- * value of this field changes the value that will be processed by all
- * subsequent steps in the data flow pipeline.
- */
- public Object originalValue = null;
-
- /**
- * Holds the value that will be copied into the final updatable. This value
- * is null if the original value has not been converted into the final
- * updatable's data type or if no conversion will be performed. Setting the
- * value of this field changes the value that will be processed by all
- * subsequent steps in the data flow pipeline.
- */
- public Object convertedValue = null;
-
- /**
- * A constant indicating that this event is occuring during a copy from
- * model to target.
- */
- public static final int EVENT_COPY_TO_TARGET = 0;
-
- /**
- * A constant indicating that this event is occuring during a copy from
- * target to model.
- */
- public static final int EVENT_COPY_TO_MODEL = 1;
-
- /**
- * A constant indicating that this event is occuring during a partial
- * validation event.
- */
- public static final int EVENT_PARTIAL_VALIDATE = 2;
-
- /**
- * A constant indicating that this event is occuring during an element
- * remove operation.
- */
- public static final int EVENT_REMOVE = 3;
-
- /**
- * A constant indicating that this event is occuring during a lazy list
- * insert operation.
- */
- public static final int EVENT_LAZY_INSERT = 4;
-
- /**
- * A constant indicating that this event is occuring during a lazy list
- * delete operation.
- */
- public static final int EVENT_LAZY_DELETE = 5;
-
- /**
- * A constant indicating that this event is occuring immedately after the
- * value to copy has been gotten from its IUpdatable.
- */
- public static final int PIPELINE_AFTER_GET = 0;
-
- /**
- * A constant indicating that this event is occuring immedately after the
- * value has been validated as being possible to convert to the other
- * updatable's data type.
- */
- public static final int PIPELINE_AFTER_VALIDATE = 1;
-
- /**
- * A constant indicating that this event is occuring immedately after the
- * original value has been converted to the other updatable's data type.
- */
- public static final int PIPELINE_AFTER_CONVERT = 2;
-
- /**
- * A constant indicating that this event is occuring immedately after the
- * business rule validation has occured.
- */
- public static final int PIPELINE_AFTER_BUSINESS_VALIDATE = 3;
-
- /**
- * A constant indicating that this event is occuring immedately after the
- * converted value has been set/changed on the updatable.
- */
- public static final int PIPELINE_AFTER_CHANGE = 4;
-
- /**
- * A constant indicating that this event is occuring due to either a validation
- * error or warning occuring.
- */
- public static final int PIPELINE_VALIDATION_ERROR_OR_WARNING = 5;
-
- /**
- * A Map of Integer --> String mapping the integer constants for the
- * pipeline events defined in this class to their String symbols.
- */
- public final Map pipelineConstants = new HashMap();
- private HashMap eventConstants = new HashMap();
-
- /**
- * Creates a table of constants from this class.
- */
- private void createSymbolTable() {
- eventConstants.put(new Integer(0), "EVENT_COPY_TO_TARGET"); //$NON-NLS-1$
- eventConstants.put(new Integer(1), "EVENT_COPY_TO_MODEL"); //$NON-NLS-1$
- eventConstants.put(new Integer(2), "EVENT_PARTIAL_VALIDATE"); //$NON-NLS-1$
- eventConstants.put(new Integer(3), "EVENT_REMOVE"); //$NON-NLS-1$
-
- pipelineConstants.put(new Integer(0), "PIPELINE_AFTER_GET"); //$NON-NLS-1$
- pipelineConstants.put(new Integer(1), "PIPELINE_AFTER_VALIDATE"); //$NON-NLS-1$
- pipelineConstants.put(new Integer(2), "PIPELINE_AFTER_CONVERT"); //$NON-NLS-1$
- pipelineConstants.put(new Integer(3),
- "PIPELINE_AFTER_BUSINESS_VALIDATE"); //$NON-NLS-1$
- pipelineConstants.put(new Integer(4), "PIPELINE_AFTER_CHANGE"); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer result = new StringBuffer();
- result.append(eventConstants.get(new Integer(copyType)) + ": Diff(" + diff + "): "); //$NON-NLS-1$ //$NON-NLS-2$
- result.append("("); //$NON-NLS-1$
- result.append(pipelineConstants.get(new Integer(pipelinePosition)));
- result.append(")"); //$NON-NLS-1$
- return result.toString();
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/BindingException.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/BindingException.java
deleted file mode 100644
index a4335787..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/BindingException.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding;
-
-/**
- * An unchecked exception indicating a binding problem.
- *
- * <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>
- *
- * TODO API review issue: Use CoreException instead?
- *
- * @since 1.0
- */
-public class BindingException extends RuntimeException {
-
- /*
- * Needed because all Throwables are Serializable.
- */
- private static final long serialVersionUID = -4092828452936724217L;
-
- /**
- * Creates a new BindingException with the given message.
- * @param message
- */
- public BindingException(String message) {
- super(message);
- }
-
- /**
- * Creates a new BindingException with the given message and cause.
- * @param message
- * @param cause
- */
- public BindingException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/DataBindingContext.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/DataBindingContext.java
deleted file mode 100644
index 8f941d93..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/DataBindingContext.java
+++ /dev/null
@@ -1,499 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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
- * Brad Reynolds - bug 159539
- * Brad Reynolds - bug 140644
- * Brad Reynolds - bug 159940
- *******************************************************************************/
-package org.eclipse.jface.databinding;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.databinding.observable.Observables;
-import org.eclipse.jface.databinding.observable.list.IObservableList;
-import org.eclipse.jface.databinding.observable.list.ObservableList;
-import org.eclipse.jface.databinding.observable.list.WritableList;
-import org.eclipse.jface.databinding.observable.value.ComputedValue;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.internal.databinding.internal.ListBinding;
-import org.eclipse.jface.internal.databinding.internal.ValidationErrorList;
-import org.eclipse.jface.internal.databinding.internal.ValueBinding;
-import org.eclipse.jface.internal.databinding.provisional.conversion.IConverter;
-import org.eclipse.jface.internal.databinding.provisional.factories.BindSupportFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultBindSupportFactory;
-import org.eclipse.jface.internal.databinding.provisional.validation.IDomainValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.IValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.ValidationError;
-
-/**
- * A context for binding observable objects. This class is not intended to be
- * subclassed by clients.
- *
- * <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.1
- *
- */
-public class DataBindingContext {
-
- /**
- * Policy constant specifying that update or validation should occur
- * automatically whenever a bound observable object generates a change
- * event.
- */
- public static final int POLICY_AUTOMATIC = 1;
-
- /**
- * Policy constant specifying that update or validation should only occur
- * when explicitly requested by calling {@link #updateModels() } or
- * {@link #updateTargets() }.
- */
- public static final int POLICY_EXPLICIT = 2;
-
- /**
- * Constant specifiying that validation or update events from UI observables
- * should be triggered early, typically on each keystroke.
- */
- public static final int TIME_EARLY = 0;
-
- /**
- * Constant specifiying that validation or update events from UI observables
- * should be triggered late, typically on focus lost.
- */
- public static final int TIME_LATE = 1;
-
- private List bindingEventListeners = new ArrayList();
-
- private WritableList bindings = new WritableList();
-
- /**
- * Unmodifiable version of {@link #bindings} for exposure publicly.
- */
- private IObservableList unmodifiableBindings = Observables.unmodifiableObservableList(bindings);
-
- private List bindSupportFactories = new ArrayList();
-
- protected DataBindingContext parent;
-
- private ComputedValue partialValidationError = new ComputedValue() {
- protected Object calculate() {
- int size = partialValidationErrors.size();
- return size == 0 ? null : partialValidationErrors.get(size - 1);
- }
- };
-
- private ObservableList partialValidationErrors = new ValidationErrorList(
- bindings, true);
-
- private ComputedValue validationError = new ComputedValue() {
- protected Object calculate() {
- int size = validationErrors.size();
- return size == 0 ? null : validationErrors.get(size - 1);
- }
- };
-
- private ObservableList validationErrors = new ValidationErrorList(bindings,
- false);
-
- private List childContexts = new ArrayList();
-
- /**
- *
- */
- public DataBindingContext() {
- }
-
- /**
- * @param parent
- *
- */
- public DataBindingContext(DataBindingContext parent) {
- this.parent = parent;
- parent.addChild(this);
- }
-
- protected void addChild(DataBindingContext context) {
- childContexts.add(context);
- }
-
- /**
- * Add a listener to the set of listeners that will be notified when an
- * event occurs in the data flow pipeline that is managed by any binding
- * created by this data binding context.
- *
- * @param listener
- * The listener to add.
- */
- public void addBindingEventListener(IBindingListener listener) {
- bindingEventListeners.add(listener);
- }
-
- /**
- * Adds a factory that can create converters and validators. The list of
- * bind support factories is used for creating converters and validators
- * when binding without specifying a converter or validator.
- *
- * @param factory
- * the factory to add.
- */
- public void addBindSupportFactory(BindSupportFactory factory) {
- bindSupportFactories.add(factory);
- }
-
- /**
- * Binds two observable values using converter and validator as specified in
- * bindSpec. If bindSpec is null, a default converter and validator is used.
- *
- * @param targetObservableValue
- * @param modelObservableValue
- * @param bindSpec
- * the bind spec, or null. Any bindSpec object must not be reused
- * or changed after it is passed to #bind.
- * @return The Binding that manages this data flow
- */
- public Binding bindValue(IObservableValue targetObservableValue,
- IObservableValue modelObservableValue, BindSpec bindSpec) {
- if (bindSpec == null) {
- bindSpec = new BindSpec();
- }
- fillBindSpecDefaults(this, bindSpec, targetObservableValue
- .getValueType(), modelObservableValue.getValueType());
- Binding result = new ValueBinding(this, targetObservableValue,
- modelObservableValue, bindSpec);
- bindings.add(result);
- return result;
- }
-
- /**
- * Binds two observable lists using converter and validator as specified in
- * bindSpec. If bindSpec is null, a default converter and validator is used.
- *
- * @param targetObservableList
- * @param modelObservableList
- * @param bindSpec
- * the bind spec, or null. Any bindSpec object must not be reused
- * or changed after it is passed to #bind.
- * @return The Binding that manages this data flow
- */
- public Binding bindList(IObservableList targetObservableList,
- IObservableList modelObservableList, BindSpec bindSpec) {
- if (bindSpec == null) {
- bindSpec = new BindSpec();
- }
- fillBindSpecDefaults(this, bindSpec, targetObservableList.getElementType(), modelObservableList.getElementType());
- Binding result = new ListBinding(this, targetObservableList,
- modelObservableList, bindSpec);
- bindings.add(result);
- return result;
- }
-
- /**
- * Tries to create a converter that can convert from values of type
- * fromType. Returns <code>null</code> if no converter could be created.
- * Either toType or modelDescription can be <code>null</code>, but not
- * both. The implementation of this method will iterate over the registered
- * bind support factories in reverse order, passing the given arguments to
- * {@link BindSupportFactory#createConverter(Object, Object)}. The first
- * non-null converter will be returned.
- *
- * @param fromType
- * @param toType
- * @return an IConverter, or <code>null</code> if unsuccessful
- */
- public IConverter createConverter(Object fromType, Object toType) {
- for (int i = bindSupportFactories.size() - 1; i >= 0; i--) {
- BindSupportFactory bindSupportFactory = (BindSupportFactory) bindSupportFactories
- .get(i);
- IConverter converter = bindSupportFactory.createConverter(fromType,
- toType);
- if (converter != null) {
- return converter;
- }
- }
- if (parent != null) {
- return parent.createConverter(fromType, toType);
- }
- return null;
- }
-
- /**
- * @param modelType
- * @return an IValidator, or null if unsuccessful
- */
- public IDomainValidator createDomainValidator(Object modelType) {
- for (int i = bindSupportFactories.size() - 1; i >= 0; i--) {
- BindSupportFactory bindSupportFactory = (BindSupportFactory) bindSupportFactories
- .get(i);
- IDomainValidator validator = bindSupportFactory
- .createDomainValidator(modelType);
- if (validator != null) {
- return validator;
- }
- }
- if (parent != null) {
- return parent.createDomainValidator(modelType);
- }
- return null;
- }
-
- /**
- * Tries to create a validator that can validate values of type fromType.
- * Returns <code>null</code> if no validator could be created. Either
- * toType or modelDescription can be <code>null</code>, but not both. The
- * implementation of this method will iterate over the registered bind
- * support factories in reverse order, passing the given arguments to
- * {@link BindSupportFactory#createValidator(Class, Class, Object)}. The
- * first non-null validator will be returned.
- *
- * @param fromType
- * @param toType
- * @param modelDescription
- * @return an IValidator, or <code>null</code> if unsuccessful
- */
- public IValidator createValidator(Object fromType, Object toType) {
- for (int i = bindSupportFactories.size() - 1; i >= 0; i--) {
- BindSupportFactory bindSupportFactory = (BindSupportFactory) bindSupportFactories
- .get(i);
- IValidator validator = bindSupportFactory.createValidator(fromType,
- toType);
- if (validator != null) {
- return validator;
- }
- }
- if (parent != null) {
- return parent.createValidator(fromType, toType);
- }
- return null;
- }
-
- /**
- * Disposes of this data binding context and all observable objects created
- * in this context.
- */
- public void dispose() {
- for (Iterator it = bindings.iterator(); it.hasNext();) {
- Binding binding = (Binding) it.next();
- binding.dispose();
- }
- for (Iterator it = childContexts.iterator(); it.hasNext();) {
- DataBindingContext context = (DataBindingContext) it.next();
- context.dispose();
- }
- }
-
- /**
- * @param dataBindingContext
- * @param bindSpec
- * @param targetType
- * @param modelType
- */
- public void fillBindSpecDefaults(DataBindingContext dataBindingContext,
- BindSpec bindSpec, Object targetType, Object modelType) {
- if (bindSpec.getTypeConversionValidator() == null) {
- bindSpec.setValidator(dataBindingContext.createValidator(
- targetType, modelType));
- }
- if (bindSpec.getDomainValidator() == null) {
- bindSpec.setDomainValidator(dataBindingContext
- .createDomainValidator(modelType));
- }
- IConverter[] modelToTargetConverters = bindSpec
- .getModelToTargetConverters();
- if (modelToTargetConverters.length > 1) {
- for (int i = 0; i < modelToTargetConverters.length; i++) {
- if (modelToTargetConverters[i] == null) {
- modelToTargetConverters[i] = dataBindingContext
- .createConverter(modelType, targetType);
- }
- }
- } else {
- // There's code in setModelToTargetConverter() that converts the 0
- // element array that represents null to a 1 element array, so we'll
- // just call setMTTC() instead of manipulating the array directly
- if (bindSpec.getModelToTargetConverter() == null) {
- bindSpec.setModelToTargetConverter(dataBindingContext
- .createConverter(modelType, targetType));
- }
- }
- IConverter[] targetToModelConverters = bindSpec
- .getTargetToModelConverters();
- if (targetToModelConverters.length > 1) {
- for (int i = 0; i < targetToModelConverters.length; i++) {
- if (targetToModelConverters[i] == null) {
- targetToModelConverters[i] = dataBindingContext
- .createConverter(targetType, modelType);
- }
- }
- } else {
- // There's code in setTargetToModelConverter() that converts the 0
- // element array that represents null to a 1 element array, so we'll
- // just call setTTMC() instead of manipulating the array directly
- if (bindSpec.getTargetToModelConverter() == null) {
- bindSpec.setTargetToModelConverter(dataBindingContext
- .createConverter(targetType, modelType));
- }
- }
- }
-
- protected ValidationError fireBindingEvent(BindingEvent event) {
- ValidationError result = null;
- for (Iterator bindingEventIter = bindingEventListeners.iterator(); bindingEventIter
- .hasNext();) {
- IBindingListener listener = (IBindingListener) bindingEventIter
- .next();
- result = listener.bindingEvent(event);
- if (result != null)
- break;
- }
- return result;
- }
-
- /**
- * Returns an unmodifiable observable list with elements of type Binding, ordered by
- * creation time
- *
- * @return the observable list containing all bindings
- */
- public IObservableList getBindings() {
- return unmodifiableBindings;
- }
-
- /**
- * Returns an observable value of type ValidationError, containing the most
- * recent partial validation error
- *
- * @return the validation error observable
- */
- public IObservableValue getPartialValidationError() {
- return partialValidationError;
- }
-
- /**
- * Returns an observable value of type ValidationError, containing the most
- * recent full validation error, i.e. the last element of the list returned
- * by getValidationErrors().
- *
- * @return the validation observable
- */
- public IObservableValue getValidationError() {
- return validationError;
- }
-
- /**
- * Returns an observable list with elements of type ValidationError, ordered
- * by the time of detection
- *
- * @return the observable list containing all validation errors
- */
- public IObservableList getValidationErrors() {
- return validationErrors;
- }
-
- /**
- * @param fromType
- * @param toType
- * @return whether fromType is assignable to toType
- */
- public boolean isAssignableFromTo(Object fromType, Object toType) {
- for (int i = bindSupportFactories.size() - 1; i >= 0; i--) {
- BindSupportFactory bindSupportFactory = (BindSupportFactory) bindSupportFactories
- .get(i);
- Boolean result = bindSupportFactory.isAssignableFromTo(fromType,
- toType);
- if (result != null) {
- return result.booleanValue();
- }
- }
- if (parent != null) {
- return parent.isAssignableFromTo(fromType, toType);
- }
- // TODO does this default make sense?
- return true;
- }
-
- /**
- * Adds the given binding to this data binding context.
- *
- * @param binding
- * The binding to add.
- */
- public void addBinding(Binding binding) {
- bindings.add(binding);
- binding.setDataBindingContext(this);
- }
-
- /**
- * Removes a listener from the set of listeners that will be notified when
- * an event occurs in the data flow pipeline that is managed by any binding
- * created by this data binding context.
- *
- * @param listener
- * The listener to remove.
- */
- public void removeBindingEventListener(IBindingListener listener) {
- bindingEventListeners.remove(listener);
- }
-
- /**
- * Updates all model observable objects to reflect the current state of the
- * target observable objects.
- *
- */
- public void updateModels() {
- for (Iterator it = bindings.iterator(); it.hasNext();) {
- Binding binding = (Binding) it.next();
- binding.updateModelFromTarget();
- }
- }
-
- /**
- * Updates all target observable objects to reflect the current state of the
- * model observable objects.
- *
- */
- public void updateTargets() {
- for (Iterator it = bindings.iterator(); it.hasNext();) {
- Binding binding = (Binding) it.next();
- binding.updateTargetFromModel();
- }
- }
-
- /**
- * @return DataBindingContext with {@link IConverter converters} and
- * {@link IValidator validators} for java's primitive types.
- */
- public static DataBindingContext withDefaults() {
- DataBindingContext dbc = new DataBindingContext();
- dbc.addBindSupportFactory(new DefaultBindSupportFactory());
-
- return dbc;
- }
-
- /**
- * Removes the binding.
- *
- * @param binding
- * @return <code>true</code> if was associated with the context,
- * <code>false</code> if not
- */
- public boolean removeBinding(Binding binding) {
- if (bindings.contains(binding)) {
- binding.setDataBindingContext(null);
- }
-
- return bindings.remove(binding);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/IBindingListener.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/IBindingListener.java
deleted file mode 100644
index 2361a516..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/IBindingListener.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * 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.databinding;
-
-import org.eclipse.jface.internal.databinding.provisional.validation.ValidationError;
-
-/**
- * An interface for objects that need to listen to events that occur in the
- * data flow pipeline
- *
- * @since 1.0
- */
-public interface IBindingListener {
- /**
- * Method bindingEvent. The method that is called when something interesting
- * occurs in the data flow pipeline.
- *
- * @param e The IBindingEvent to handle.
- * @return null if no error or a ValidationError with an error status to
- * abort the operation. The error will be propagated to the data binding
- * context's error message updatable.
- */
- public ValidationError bindingEvent(BindingEvent e);
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/AbstractObservable.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/AbstractObservable.java
deleted file mode 100644
index 444c2def..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/AbstractObservable.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * @since 1.0
- *
- */
-public abstract class AbstractObservable implements IObservable {
-
- /**
- * Points to an instance of IChangeListener or a Collection of
- * IChangeListener
- */
- private Object changeListeners = null;
-
- /**
- * Points to an instance of IChangeListener or a Collection of
- * IChangeListener
- */
- private Object staleListeners = null;
-
- public void addChangeListener(IChangeListener listener) {
- if (changeListeners == null) {
- boolean hadListeners = hasListeners();
- changeListeners = listener;
- if (!hadListeners) {
- firstListenerAdded();
- }
- return;
- }
-
- Collection listenerList;
- if (changeListeners instanceof IChangeListener) {
- IChangeListener l = (IChangeListener) changeListeners;
-
- listenerList = new ArrayList();
- listenerList.add(l);
- changeListeners = listenerList;
- } else {
- listenerList = (Collection) changeListeners;
- }
-
- listenerList.add(listener);
- }
-
- public void removeChangeListener(IChangeListener listener) {
- if (changeListeners == listener) {
- changeListeners = null;
- if (!hasListeners()) {
- lastListenerRemoved();
- }
- return;
- }
-
- if (changeListeners instanceof Collection) {
- Collection listenerList = (Collection) changeListeners;
- listenerList.remove(listener);
- if (listenerList.isEmpty()) {
- changeListeners = null;
- if (!hasListeners()) {
- lastListenerRemoved();
- }
- }
- }
- }
-
- public void addStaleListener(IStaleListener listener) {
- if (staleListeners == null) {
- boolean hadListeners = hasListeners();
- staleListeners = listener;
- if (!hadListeners) {
- firstListenerAdded();
- }
- return;
- }
-
- Collection listenerList;
- if (staleListeners instanceof IStaleListener) {
- IStaleListener l = (IStaleListener) staleListeners;
-
- listenerList = new ArrayList();
- listenerList.add(l);
- staleListeners = listenerList;
- } else {
- listenerList = (Collection) staleListeners;
- }
-
- listenerList.add(listener);
- }
-
- public void removeStaleListener(IStaleListener listener) {
- if (staleListeners == listener) {
- staleListeners = null;
- if (!hasListeners()) {
- lastListenerRemoved();
- }
- return;
- }
-
- if (staleListeners instanceof Collection) {
- Collection listenerList = (Collection) staleListeners;
- listenerList.remove(listener);
- if (listenerList.isEmpty()) {
- staleListeners = null;
- if (!hasListeners()) {
- lastListenerRemoved();
- }
- }
- }
- }
-
- protected void fireChange() {
- if (changeListeners == null) {
- return;
- }
-
- if (changeListeners instanceof IChangeListener) {
- ((IChangeListener) changeListeners).handleChange(this);
- return;
- }
-
- Collection changeListenerCollection = (Collection) changeListeners;
-
- IChangeListener[] listeners = (IChangeListener[]) (changeListenerCollection)
- .toArray(new IChangeListener[changeListenerCollection.size()]);
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].handleChange(this);
- }
- }
-
- protected void fireStale() {
- if (staleListeners == null) {
- return;
- }
-
- if (staleListeners instanceof IStaleListener) {
- ((IStaleListener) staleListeners).handleStale(this);
- return;
- }
-
- Collection staleListenerCollection = (Collection) staleListeners;
-
- IStaleListener[] listeners = (IStaleListener[]) (staleListenerCollection)
- .toArray(new IStaleListener[staleListenerCollection.size()]);
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].handleStale(this);
- }
- }
-
- /**
- * @return true if this observable has listeners
- */
- protected boolean hasListeners() {
- return changeListeners != null || staleListeners != null;
- }
-
- /**
- *
- */
- protected void firstListenerAdded() {
- }
-
- /**
- *
- */
- protected void lastListenerRemoved() {
- }
-
- /**
- *
- */
- public void dispose() {
- changeListeners = null;
- staleListeners = null;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/Diffs.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/Diffs.java
deleted file mode 100644
index 63600ab6..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/Diffs.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.jface.databinding.observable.list.ListDiff;
-import org.eclipse.jface.databinding.observable.list.ListDiffEntry;
-import org.eclipse.jface.databinding.observable.set.SetDiff;
-import org.eclipse.jface.databinding.observable.value.ValueDiff;
-
-/**
- * @since 1.0
- *
- */
-public class Diffs {
-
- /**
- * @param oldList
- * @param newList
- * @return the differences between oldList and newList
- */
- public static ListDiff computeListDiff(List oldList, List newList) {
- List diffEntries = new ArrayList();
- for (Iterator it = oldList.iterator(); it.hasNext();) {
- Object oldElement = it.next();
- diffEntries.add(createListDiffEntry(0, false, oldElement));
- }
- int i = 0;
- for (Iterator it = newList.iterator(); it.hasNext();) {
- Object newElement = it.next();
- diffEntries.add(createListDiffEntry(i++, true, newElement));
- }
- ListDiff listDiff = createListDiff((ListDiffEntry[]) diffEntries
- .toArray(new ListDiffEntry[diffEntries.size()]));
- return listDiff;
- }
-
- /**
- * Checks whether the two objects are <code>null</code> -- allowing for
- * <code>null</code>.
- *
- * @param left
- * The left object to compare; may be <code>null</code>.
- * @param right
- * The right object to compare; may be <code>null</code>.
- * @return <code>true</code> if the two objects are equivalent;
- * <code>false</code> otherwise.
- */
- public static final boolean equals(final Object left, final Object right) {
- return left == null ? right == null : ((right != null) && left
- .equals(right));
- }
-
- /**
- * @param oldSet
- * @param newSet
- * @return a set diff
- */
- public static SetDiff computeSetDiff(Set oldSet, Set newSet) {
- Set additions = new HashSet(newSet);
- additions.removeAll(oldSet);
- Set removals = new HashSet(oldSet);
- removals.removeAll(newSet);
- return createSetDiff(additions, removals);
- }
-
- /**
- * @param oldValue
- * @param newValue
- * @return a value diff
- */
- public static ValueDiff createValueDiff(final Object oldValue,
- final Object newValue) {
- return new ValueDiff() {
-
- public Object getOldValue() {
- return oldValue;
- }
-
- public Object getNewValue() {
- return newValue;
- }
- };
- }
-
- /**
- * @param additions
- * @param removals
- * @return a set diff
- */
- public static SetDiff createSetDiff(Set additions, Set removals) {
- final Set unmodifiableAdditions = Collections
- .unmodifiableSet(additions);
- final Set unmodifiableRemovals = Collections.unmodifiableSet(removals);
- return new SetDiff() {
-
- public Set getAdditions() {
- return unmodifiableAdditions;
- }
-
- public Set getRemovals() {
- return unmodifiableRemovals;
- }
- };
- }
-
- /**
- * @param difference
- * @return a list diff with one differing entry
- */
- public static ListDiff createListDiff(ListDiffEntry difference) {
- return createListDiff(new ListDiffEntry[] { difference });
- }
-
- /**
- * @param difference1
- * @param difference2
- * @return a list diff with two differing entries
- */
- public static ListDiff createListDiff(ListDiffEntry difference1,
- ListDiffEntry difference2) {
- return createListDiff(new ListDiffEntry[] { difference1, difference2 });
- }
-
- /**
- * @param differences
- * @return a list diff with the given entries
- */
- public static ListDiff createListDiff(final ListDiffEntry[] differences) {
- return new ListDiff() {
- public ListDiffEntry[] getDifferences() {
- return differences;
- }
- };
- }
-
- /**
- * @param position
- * @param isAddition
- * @param element
- * @return a list diff entry
- */
- public static ListDiffEntry createListDiffEntry(final int position,
- final boolean isAddition, final Object element) {
- return new ListDiffEntry() {
-
- public int getPosition() {
- return position;
- }
-
- public boolean isAddition() {
- return isAddition;
- }
-
- public Object getElement() {
- return element;
- }
- };
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/IChangeListener.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/IChangeListener.java
deleted file mode 100644
index eef9f748..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/IChangeListener.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable;
-
-import org.eclipse.jface.databinding.observable.list.IListChangeListener;
-import org.eclipse.jface.databinding.observable.set.ISetChangeListener;
-import org.eclipse.jface.databinding.observable.value.IValueChangeListener;
-import org.eclipse.jface.internal.databinding.provisional.observable.mapping.IMappingChangeListener;
-
-/**
- * Listener for generic change events. Note that the change events do not carry information about
- * the change, they only specify the affected observable. To listen for specific change events, use
- * more specific change listeners.
- *
- * @see IValueChangeListener
- * @see IListChangeListener
- * @see ISetChangeListener
- * @see IMappingChangeListener
- *
- * @since 1.0
- */
-public interface IChangeListener {
-
- /**
- * Handle a generic change to the given observable.
- *
- * @param source
- */
- public void handleChange(IObservable source);
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/IDiff.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/IDiff.java
deleted file mode 100644
index 58368f66..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/IDiff.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable;
-
-import org.eclipse.jface.databinding.observable.list.ListDiff;
-import org.eclipse.jface.databinding.observable.set.SetDiff;
-import org.eclipse.jface.databinding.observable.value.ValueDiff;
-import org.eclipse.jface.internal.databinding.provisional.observable.mapping.MappingDiff;
-
-/**
- * A diff represents a state change of an observable object.
- *
- * @see ValueDiff
- * @see ListDiff
- * @see SetDiff
- * @see MappingDiff
- *
- * @since 1.0
- *
- */
-public interface IDiff {
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/IObservable.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/IObservable.java
deleted file mode 100644
index 748374ef..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/IObservable.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.observable;
-
-/**
- * An object with state that allows to listen for state changes.
- *
- * <p>
- * This interface is not intended to be implemented by clients. Clients should
- * instead subclass one of the classes that implement this interface. Note that
- * direct implementers of this interface outside of the framework will be broken
- * in future releases when methods are added to this interface.
- * </p>
- *
- * @since 1.0
- *
- */
-public interface IObservable {
-
- /**
- * Adds the given change listener to the list of change listeners.
- *
- * @param listener
- */
- public void addChangeListener(IChangeListener listener);
-
- /**
- * Removes the given change listener from the list of change listeners. Has
- * no effect if the given listener is not registered as a change listener.
- *
- * @param listener
- */
- public void removeChangeListener(IChangeListener listener);
-
- /**
- * Adds the given stale listener to the list of stale listeners.
- *
- * @param listener
- */
- public void addStaleListener(IStaleListener listener);
-
- /**
- * Removes the given stale listener from the list of stale listeners. Has no
- * effect if the given listener is not registered as a stale listener.
- *
- * @param listener
- */
- public void removeStaleListener(IStaleListener listener);
-
- /**
- * Returns whether the state of this observable is stale. A non-stale object
- * that becomes stale will notify its stale listeners. A stale object that
- * becomes non-stale does so by changing its state and notifying its change
- * listeners. Clients that do not expect asynchronous changes may ignore
- * staleness of observable objects.
- *
- * @return true if this observable's state is stale and will change soon.
- *
- * @TrackedGetter - implementers must call
- * {@link ObservableTracker#getterCalled(IObservable)}.
- */
- public boolean isStale();
-
- /**
- * Disposes of this observable object, removing all listeners registered
- * with this object, and all listeners this object might have registered on
- * other objects.
- */
- public void dispose();
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/IObservableCollection.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/IObservableCollection.java
deleted file mode 100644
index 3a0bf494..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/IObservableCollection.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable;
-
-/**
- * Marker interface for observable collections.
- *
- * <p>
- * This interface is not intended to be implemented by clients. Clients should
- * instead subclass one of the classes that implement this interface. Note that
- * direct implementers of this interface outside of the framework will be broken
- * in future releases when methods are added to this interface.
- * </p>
- *
- * @since 1.0
- */
-public interface IObservableCollection extends IObservable {
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/IStaleListener.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/IStaleListener.java
deleted file mode 100644
index dda6baaa..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/IStaleListener.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable;
-
-/**
- * Listener for staleness events. An observable object is stale if its state will change
- * eventually.
- *
- * @since 1.0
- */
-public interface IStaleListener {
-
- /**
- * Handle the event that the given observable object is now stale.
- * @param source
- */
- public void handleStale(IObservable source);
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/ObservableTracker.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/ObservableTracker.java
deleted file mode 100644
index e9e8234c..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/ObservableTracker.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.observable;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.jface.internal.databinding.internal.IdentityWrapper;
-
-/**
- * This class makes it possible to monitor whenever an IObservable is read from.
- * This can be used to automatically attach and remove listeners. How to use it:
- *
- * <p>
- * If you are implementing an IObservable, invoke getterCalled(this) whenever a
- * getter is called - that is, whenever your observable is read from. You only
- * need to do this once per method call. If one getter delegates to another, the
- * outer getter doesn't need to call the method since the inner one will.
- * </p>
- *
- * <p>
- * If you want to determine what observables were used in a particular block of
- * code, call runAndMonitor(Runnable). This will execute the given runnable and
- * return the set of observables that were read from.
- * </p>
- *
- * <p>
- * This can be used to automatically attach listeners. For example, imagine you
- * have a block of code that updates some widget by reading from a bunch of
- * observables. Whenever one of those observables changes, you want to re-run
- * the code and cause the widget to be refreshed. You could do this in the
- * traditional manner by attaching one listener to each observable and
- * re-running your widget update code whenever one of them changes, but this
- * code is repetitive and requires updating the listener code whenever you
- * refactor the widget updating code.
- * </p>
- *
- * <p>
- * Alternatively, you could use a utility class that runs the code in a
- * runAndMonitor block and automatically attach listeners to any observable used
- * in updating the widget. The advantage of the latter approach is that it,
- * eliminates the code for attaching and detaching listeners and will always
- * stay in synch with changes to the widget update logic.
- * </p>
- *
- * @since 1.0
- */
-public class ObservableTracker {
-
- /**
- * Threadlocal storage pointing to the current Set of IObservables, or null
- * if none. Note that this is actually the top of a stack. Whenever a method
- * changes the current value, it remembers the old value as a local variable
- * and restores the old value when the method exits.
- */
- private static ThreadLocal currentChangeListener = new ThreadLocal();
-
- private static ThreadLocal currentStaleListener = new ThreadLocal();
-
- private static ThreadLocal currentObservableSet = new ThreadLocal();
-
- /**
- * Invokes the given runnable, and returns the set of IObservables that were
- * read by the runnable. If the runnable calls this method recursively, the
- * result will not contain IObservables that were used within the inner
- * runnable.
- *
- * @param runnable
- * runnable to execute
- * @param changeListener
- * listener to register with all accessed observables
- * @param staleListener
- * listener to register with all accessed observables, or
- * <code>null</code> if no stale listener is to be registered
- * @return an array of unique observable objects
- */
- public static IObservable[] runAndMonitor(Runnable runnable,
- IChangeListener changeListener, IStaleListener staleListener) {
- // Remember the previous value in the listener stack
- Set lastObservableSet = (Set) currentObservableSet.get();
- IChangeListener lastChangeListener = (IChangeListener) currentChangeListener
- .get();
- IStaleListener lastStaleListener = (IStaleListener) currentStaleListener
- .get();
-
- Set observableSet = new HashSet();
- // Push the new listeners to the top of the stack
- currentObservableSet.set(observableSet);
- currentChangeListener.set(changeListener);
- currentStaleListener.set(staleListener);
- try {
- runnable.run();
- } finally {
- // Pop the new listener off the top of the stack (by restoring the
- // previous listener)
- currentObservableSet.set(lastObservableSet);
- currentChangeListener.set(lastChangeListener);
- currentStaleListener.set(lastStaleListener);
- }
-
- int i = 0;
- IObservable[] result = new IObservable[observableSet.size()];
- for (Iterator it = observableSet.iterator(); it.hasNext();) {
- IdentityWrapper wrapper = (IdentityWrapper) it.next();
- result[i++] = (IObservable) wrapper.unwrap();
- }
-
- return result;
- }
-
- /**
- * Notifies the ObservableTracker that an observable was read from. The
- * JavaDoc for methods that invoke this method should include the following
- * tag: "@TrackedGetter This method will notify ObservableTracker that the
- * receiver has been read from". This lets callers know that they can rely
- * on automatic updates from the object without explicitly attaching a
- * listener.
- *
- * @param observable
- */
- public static void getterCalled(IObservable observable) {
- Set lastObservableSet = (Set) currentObservableSet.get();
- IChangeListener lastChangeListener = (IChangeListener) currentChangeListener
- .get();
- IStaleListener lastStaleListener = (IStaleListener) currentStaleListener
- .get();
-
- boolean added = false;
- if (lastObservableSet != null) {
- added = lastObservableSet.add(new IdentityWrapper(observable));
- }
-
- // If anyone is listening for observable usage...
- if (added && lastChangeListener != null) {
- observable.addChangeListener(lastChangeListener);
- }
- if (added && lastStaleListener != null) {
- observable.addStaleListener(lastStaleListener);
- }
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/Observables.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/Observables.java
deleted file mode 100644
index b0be65bb..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/Observables.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Cerner 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:
- * Brad Reynolds - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.databinding.observable;
-
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.jface.databinding.observable.list.IListChangeListener;
-import org.eclipse.jface.databinding.observable.list.IObservableList;
-import org.eclipse.jface.databinding.observable.list.ObservableList;
-import org.eclipse.jface.databinding.observable.set.IObservableSet;
-import org.eclipse.jface.databinding.observable.set.ISetChangeListener;
-import org.eclipse.jface.databinding.observable.set.ObservableSet;
-import org.eclipse.jface.internal.databinding.internal.observable.ProxyObservableSet;
-import org.eclipse.jface.internal.databinding.internal.observable.UnmodifiableObservableList;
-
-/**
- * Contains static methods to operate on or return
- * {@link IObservable Observables}.
- *
- * @since 3.2
- */
-public class Observables {
- /**
- * @param list
- * @return list Returns an unmodifiable view of the provided
- * <code>list</code>.
- */
- public static IObservableList unmodifiableObservableList(
- IObservableList list) {
- if (list == null) {
- throw new IllegalArgumentException(
- "Parameter " + list + " was null."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- return new UnmodifiableObservableList(list);
- }
-
- /**
- * @param set
- * @return Returns an observableSet backed by the given set
- */
- public static IObservableSet staticObservableSet(Set set) {
- return new ObservableSet(set, Object.class) {
- public void addChangeListener(IChangeListener listener) {
- }
-
- public void addStaleListener(IStaleListener listener) {
- }
-
- public void addSetChangeListener(ISetChangeListener listener) {
- }
- };
- }
-
- /**
- * Returns an observable set that contains the same elements as the given
- * set, and fires the same events as the given set, but can be disposed of
- * without disposing of the wrapped set.
- *
- * @param target
- * the set to wrap
- * @return a proxy observable set
- */
- public static IObservableSet proxyObservableSet(IObservableSet target) {
- return new ProxyObservableSet(target);
- }
-
- /**
- * @param list
- * @return
- */
- public static IObservableList staticObservableList(List list) {
- return new ObservableList(list, Object.class) {
- public void addChangeListener(IChangeListener listener) {
- }
-
- public void addStaleListener(IStaleListener listener) {
- }
-
- public void addListChangeListener(IListChangeListener listener) {
- }
- };
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/AbstractObservableList.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/AbstractObservableList.java
deleted file mode 100644
index 81c60a8c..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/AbstractObservableList.java
+++ /dev/null
@@ -1,399 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable.list;
-
-import java.util.AbstractList;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.jface.databinding.observable.IChangeListener;
-import org.eclipse.jface.databinding.observable.IStaleListener;
-import org.eclipse.jface.databinding.observable.ObservableTracker;
-
-/**
- * Subclasses should override at least get(int index) and size()
- *
- * @since 1.0
- *
- */
-public abstract class AbstractObservableList extends AbstractList implements
- IObservableList {
-
- /**
- * Points to an instance of IListChangeListener or a Collection of
- * IListChangeListener
- */
- private Object listChangeListeners;
-
- /**
- * Points to an instance of IChangeListener or a Collection of
- * IChangeListener
- */
- private Object changeListeners = null;
-
- /**
- * Points to an instance of IChangeListener or a Collection of
- * IStaleListener
- */
- private Object staleListeners = null;
-
- public boolean isStale() {
- return false;
- }
-
- public void addListChangeListener(IListChangeListener listener) {
- if (listChangeListeners == null) {
- boolean hadListeners = hasListeners();
- listChangeListeners = listener;
- if (!hadListeners) {
- firstListenerAdded();
- }
- return;
- }
-
- Collection listenerList;
- if (listChangeListeners instanceof Collection) {
- listenerList = (Collection) listChangeListeners;
- } else {
- IListChangeListener l = (IListChangeListener) listChangeListeners;
-
- listenerList = new ArrayList();
- listenerList.add(l);
- listChangeListeners = listenerList;
- }
-
- listenerList.add(listener);
- }
-
- public void removeListChangeListener(IListChangeListener listener) {
-
- if (listChangeListeners == listener) {
- listChangeListeners = null;
- if (!hasListeners()) {
- lastListenerRemoved();
- }
- return;
- }
-
- if (listChangeListeners instanceof Collection) {
- Collection listenerList = (Collection) listChangeListeners;
- listenerList.remove(listener);
- if (listenerList.isEmpty()) {
- listChangeListeners = null;
- if (!hasListeners()) {
- lastListenerRemoved();
- }
- }
- }
- }
-
- protected void fireListChange(ListDiff diff) {
- // fire general change event first
- fireChange();
-
- if (listChangeListeners == null) {
- return;
- }
-
- if (listChangeListeners instanceof IListChangeListener) {
- ((IListChangeListener) listChangeListeners).handleListChange(this,
- diff);
- return;
- }
-
- Collection changeListenerCollection = (Collection) listChangeListeners;
-
- IListChangeListener[] listeners = (IListChangeListener[]) (changeListenerCollection)
- .toArray(new IListChangeListener[changeListenerCollection
- .size()]);
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].handleListChange(this, diff);
- }
- }
-
- public void addChangeListener(IChangeListener listener) {
- if (changeListeners == null) {
- boolean hadListeners = hasListeners();
- changeListeners = listener;
- if (!hadListeners) {
- firstListenerAdded();
- }
- return;
- }
-
- Collection listenerList;
- if (changeListeners instanceof IChangeListener) {
- IChangeListener l = (IChangeListener) changeListeners;
-
- listenerList = new ArrayList();
- listenerList.add(l);
- changeListeners = listenerList;
- } else {
- listenerList = (Collection) changeListeners;
- }
-
- listenerList.add(listener);
- }
-
- public void removeChangeListener(IChangeListener listener) {
- if (changeListeners == listener) {
- changeListeners = null;
- if (!hasListeners()) {
- lastListenerRemoved();
- }
- return;
- }
-
- if (changeListeners instanceof Collection) {
- Collection listenerList = (Collection) changeListeners;
- listenerList.remove(listener);
- if (listenerList.isEmpty()) {
- changeListeners = null;
- if (!hasListeners()) {
- lastListenerRemoved();
- }
- }
- }
- }
-
- public void addStaleListener(IStaleListener listener) {
- if (staleListeners == null) {
- boolean hadListeners = hasListeners();
- staleListeners = listener;
- if (!hadListeners) {
- firstListenerAdded();
- }
- return;
- }
-
- Collection listenerList;
- if (staleListeners instanceof IStaleListener) {
- IStaleListener l = (IStaleListener) staleListeners;
-
- listenerList = new ArrayList();
- listenerList.add(l);
- staleListeners = listenerList;
- } else {
- listenerList = (Collection) staleListeners;
- }
-
- listenerList.add(listener);
- }
-
- public void removeStaleListener(IStaleListener listener) {
- if (staleListeners == listener) {
- staleListeners = null;
- if (!hasListeners()) {
- lastListenerRemoved();
- }
- return;
- }
-
- if (staleListeners instanceof Collection) {
- Collection listenerList = (Collection) staleListeners;
- listenerList.remove(listener);
- if (listenerList.isEmpty()) {
- staleListeners = null;
- if (!hasListeners()) {
- lastListenerRemoved();
- }
- }
- }
- }
-
- protected void fireChange() {
- if (changeListeners == null) {
- return;
- }
-
- if (changeListeners instanceof IChangeListener) {
- ((IChangeListener) changeListeners).handleChange(this);
- return;
- }
-
- Collection changeListenerCollection = (Collection) changeListeners;
-
- IChangeListener[] listeners = (IChangeListener[]) (changeListenerCollection)
- .toArray(new IChangeListener[changeListenerCollection.size()]);
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].handleChange(this);
- }
- }
-
- protected void fireStale() {
- if (staleListeners == null) {
- return;
- }
-
- if (staleListeners instanceof IChangeListener) {
- ((IChangeListener) staleListeners).handleChange(this);
- return;
- }
-
- Collection changeListenerCollection = (Collection) staleListeners;
-
- IChangeListener[] listeners = (IChangeListener[]) (changeListenerCollection)
- .toArray(new IChangeListener[changeListenerCollection.size()]);
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].handleChange(this);
- }
- }
-
- /**
- * @return true if this observable has listeners
- */
- protected boolean hasListeners() {
- return changeListeners != null || staleListeners != null
- || listChangeListeners != null;
- }
-
- /**
- *
- */
- protected void firstListenerAdded() {
- }
-
- /**
- *
- */
- protected void lastListenerRemoved() {
- }
-
- /**
- *
- */
- public void dispose() {
- listChangeListeners = null;
- changeListeners = null;
- staleListeners = null;
- lastListenerRemoved();
- }
-
- public final int size() {
- getterCalled();
- return doGetSize();
- }
-
- /**
- * @return the size
- */
- protected abstract int doGetSize();
-
- /**
- *
- */
- private void getterCalled() {
- ObservableTracker.getterCalled(this);
- }
-
- public boolean isEmpty() {
- getterCalled();
- return super.isEmpty();
- }
-
- public boolean contains(Object o) {
- getterCalled();
- return super.contains(o);
- }
-
- public Iterator iterator() {
- final Iterator wrappedIterator = super.iterator();
- return new Iterator() {
- public void remove() {
- wrappedIterator.remove();
- }
-
- public boolean hasNext() {
- getterCalled();
- return wrappedIterator.hasNext();
- }
-
- public Object next() {
- getterCalled();
- return wrappedIterator.next();
- }
- };
- }
-
- public Object[] toArray() {
- getterCalled();
- return super.toArray();
- }
-
- public Object[] toArray(Object a[]) {
- getterCalled();
- return super.toArray(a);
- }
-
- // Modification Operations
-
- public boolean add(Object o) {
- getterCalled();
- return super.add(o);
- }
-
- public boolean remove(Object o) {
- getterCalled();
- return super.remove(o);
- }
-
- // Bulk Modification Operations
-
- public boolean containsAll(Collection c) {
- getterCalled();
- return super.containsAll(c);
- }
-
- public boolean addAll(Collection c) {
- getterCalled();
- return super.addAll(c);
- }
-
- public boolean addAll(int index, Collection c) {
- getterCalled();
- return super.addAll(c);
- }
-
- public boolean removeAll(Collection c) {
- getterCalled();
- return super.removeAll(c);
- }
-
- public boolean retainAll(Collection c) {
- getterCalled();
- return super.retainAll(c);
- }
-
- // Comparison and hashing
-
- public boolean equals(Object o) {
- getterCalled();
- return super.equals(o);
- }
-
- public int hashCode() {
- getterCalled();
- return super.hashCode();
- }
-
- public int indexOf(Object o) {
- getterCalled();
- return super.indexOf(o);
- }
-
- public int lastIndexOf(Object o) {
- getterCalled();
- return super.lastIndexOf(o);
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/IListChangeListener.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/IListChangeListener.java
deleted file mode 100644
index a5955822..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/IListChangeListener.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable.list;
-
-
-/**
- * Listener for changes of observable lists.
- *
- * @since 1.0
- */
-public interface IListChangeListener {
-
- /**
- * Handle a change to the given observable list. The change is described by the diff objects.
- * @param source
- * @param diff
- */
- void handleListChange(IObservableList source, ListDiff diff);
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/IObservableList.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/IObservableList.java
deleted file mode 100644
index ea81305e..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/IObservableList.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable.list;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jface.databinding.observable.IObservableCollection;
-
-/**
- * A list whose changes can be tracked by list change listeners.
- *
- * <p>
- * This interface is not intended to be implemented by clients. Clients should
- * instead subclass one of the classes that implement this interface. Note that
- * direct implementers of this interface outside of the framework will be broken
- * in future releases when methods are added to this interface.
- * </p>
- *
- * @since 1.0
- */
-public interface IObservableList extends List, IObservableCollection {
-
- /**
- * Adds the given list change listener to the list of list change listeners.
- * @param listener
- */
- public void addListChangeListener(IListChangeListener listener);
-
- /**
- * Removes the given list change listener from the list of list change listeners.
- * Has no effect if the given listener is not registered as a list change listener.
- *
- * @param listener
- */
- public void removeListChangeListener(IListChangeListener listener);
-
- /**
- * @TrackedGetter
- */
- public int size();
-
- /**
- * @TrackedGetter
- */
- public boolean isEmpty();
-
- /**
- * @TrackedGetter
- */
- public boolean contains(Object o);
-
- /**
- * @TrackedGetter
- */
- public Iterator iterator();
-
- /**
- * @TrackedGetter
- */
- public Object[] toArray();
-
- /**
- * @TrackedGetter
- */
- public Object[] toArray(Object a[]);
-
- /**
- * @TrackedGetter because of the returned boolean
- */
- public boolean add(Object o);
-
- /**
- * @TrackedGetter
- */
- public boolean remove(Object o);
-
- /**
- * @TrackedGetter
- */
- public boolean containsAll(Collection c);
-
- /**
- * @TrackedGetter
- */
- public boolean addAll(Collection c);
-
- /**
- * @TrackedGetter
- */
- public boolean addAll(int index, Collection c);
-
- /**
- * @TrackedGetter
- */
- public boolean removeAll(Collection c);
-
- /**
- * @TrackedGetter
- */
- public boolean retainAll(Collection c);
-
- /**
- * @TrackedGetter
- */
- public boolean equals(Object o);
-
- /**
- * @TrackedGetter
- */
- public int hashCode();
-
- /**
- * @TrackedGetter
- */
- public Object get(int index);
-
- /**
- * @TrackedGetter because of the returned object
- */
- public Object set(int index, Object element);
-
- /**
- * @TrackedGetter
- */
- public Object remove(int index);
-
- /**
- * @TrackedGetter
- */
- public int indexOf(Object o);
-
- /**
- * @TrackedGetter
- */
- public int lastIndexOf(Object o);
-
- /**
- * @TrackedGetter
- */
- public ListIterator listIterator();
-
- /**
- * @TrackedGetter
- */
- public ListIterator listIterator(int index);
-
- /**
- * @TrackedGetter
- */
- public List subList(int fromIndex, int toIndex);
-
- /**
- * @return the type of the elements
- */
- Object getElementType();
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/ListDiff.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/ListDiff.java
deleted file mode 100644
index 1cfeda3f..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/ListDiff.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable.list;
-
-import org.eclipse.jface.databinding.observable.IDiff;
-
-/**
- * Object describing a diff between two lists.
- *
- * @since 1.0
- */
-public abstract class ListDiff implements IDiff {
-
- /**
- * Returns a list of ListDiffEntry
- *
- * @return a list of ListDiffEntry
- */
- public abstract ListDiffEntry[] getDifferences();
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- ListDiffEntry[] differences = getDifferences();
- StringBuffer buffer = new StringBuffer();
- buffer.append(getClass().getName());
-
- if (differences == null || differences.length == 0) {
- buffer
- .append("{}"); //$NON-NLS-1$
- } else {
- buffer
- .append("{"); //$NON-NLS-1$
-
- for (int i = 0; i < differences.length; i++) {
- if (i > 0)
- buffer.append(", "); //$NON-NLS-1$
-
- buffer
- .append("difference[") //$NON-NLS-1$
- .append(i)
- .append("] [") //$NON-NLS-1$
- .append(differences[i] != null ? differences[i].toString() : "null") //$NON-NLS-1$
- .append("]"); //$NON-NLS-1$
- }
- buffer.append("}"); //$NON-NLS-1$
- }
-
- return buffer.toString();
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/ListDiffEntry.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/ListDiffEntry.java
deleted file mode 100644
index 32472b33..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/ListDiffEntry.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable.list;
-
-/**
- * A single addition of an element to a list or removal of an element from a list.
- *
- * @since 1.0
- */
-public abstract class ListDiffEntry {
-
- /**
- * @return the 0-based position of the addition or removal
- */
- public abstract int getPosition();
-
- /**
- * @return true if this represents an addition, false if this represents a removal
- */
- public abstract boolean isAddition();
-
- /**
- * @return the element that was added or removed
- */
- public abstract Object getElement();
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer
- .append(this.getClass().getName())
- .append("{position [") //$NON-NLS-1$
- .append(getPosition())
- .append("], isAddition [") //$NON-NLS-1$
- .append(isAddition())
- .append("], element [") //$NON-NLS-1$
- .append(getElement() != null ? getElement().toString() : "null") //$NON-NLS-1$
- .append("]}"); //$NON-NLS-1$
-
- return buffer.toString();
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/ObservableList.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/ObservableList.java
deleted file mode 100644
index b08356fb..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/ObservableList.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable.list;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jface.databinding.observable.AbstractObservable;
-import org.eclipse.jface.databinding.observable.Diffs;
-import org.eclipse.jface.databinding.observable.ObservableTracker;
-
-/**
- *
- * Abstract implementation of {@link IObservableList}, based on an underlying regular list.
- *
- * @since 1.0
- *
- */
-public abstract class ObservableList extends AbstractObservable implements
- IObservableList {
-
- protected List wrappedList;
-
- private boolean stale = false;
-
- private Object listChangeListeners;
-
- private Object elementType;
-
- protected ObservableList(List wrappedList, Object elementType) {
- this.wrappedList = wrappedList;
- this.elementType = elementType;
- }
-
- public void addListChangeListener(IListChangeListener listener) {
- if (listChangeListeners == null) {
- boolean hadListeners = hasListeners();
- listChangeListeners = listener;
- if (!hadListeners) {
- firstListenerAdded();
- }
- return;
- }
-
- Collection listenerList;
- if (listChangeListeners instanceof Collection) {
- listenerList = (Collection) listChangeListeners;
- } else {
- IListChangeListener l = (IListChangeListener) listChangeListeners;
-
- listenerList = new ArrayList();
- listenerList.add(l);
- listChangeListeners = listenerList;
- }
-
- listenerList.add(listener);
- }
-
- public void removeListChangeListener(IListChangeListener listener) {
-
- if (listChangeListeners == listener) {
- listChangeListeners = null;
- if (!hasListeners()) {
- lastListenerRemoved();
- }
- return;
- }
-
- if (listChangeListeners instanceof Collection) {
- Collection listenerList = (Collection) listChangeListeners;
- listenerList.remove(listener);
- if (listenerList.isEmpty()) {
- listChangeListeners = null;
- if (!hasListeners()) {
- lastListenerRemoved();
- }
- }
- }
- }
-
- protected boolean hasListeners() {
- return super.hasListeners() || listChangeListeners!=null;
- }
-
- protected void fireListChange(ListDiff diff) {
- // fire general change event first
- super.fireChange();
-
- if (listChangeListeners == null) {
- return;
- }
-
- if (listChangeListeners instanceof IListChangeListener) {
- ((IListChangeListener) listChangeListeners).handleListChange(this, diff);
- return;
- }
-
- Collection changeListenerCollection = (Collection) listChangeListeners;
-
- IListChangeListener[] listeners = (IListChangeListener[]) (changeListenerCollection)
- .toArray(new IListChangeListener[changeListenerCollection.size()]);
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].handleListChange(this, diff);
- }
- }
-
- public boolean contains(Object o) {
- getterCalled();
- return wrappedList.contains(o);
- }
-
- public boolean containsAll(Collection c) {
- getterCalled();
- return wrappedList.containsAll(c);
- }
-
- public boolean equals(Object o) {
- getterCalled();
- return wrappedList.equals(o);
- }
-
- public int hashCode() {
- getterCalled();
- return wrappedList.hashCode();
- }
-
- public boolean isEmpty() {
- getterCalled();
- return wrappedList.isEmpty();
- }
-
- public Iterator iterator() {
- final Iterator wrappedIterator = wrappedList.iterator();
- return new Iterator() {
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- public boolean hasNext() {
- ObservableTracker.getterCalled(ObservableList.this);
- return wrappedIterator.hasNext();
- }
-
- public Object next() {
- ObservableTracker.getterCalled(ObservableList.this);
- return wrappedIterator.next();
- }
- };
- }
-
- public int size() {
- getterCalled();
- return wrappedList.size();
- }
-
- public Object[] toArray() {
- getterCalled();
- return wrappedList.toArray();
- }
-
- public Object[] toArray(Object[] a) {
- getterCalled();
- return wrappedList.toArray(a);
- }
-
- public String toString() {
- getterCalled();
- return wrappedList.toString();
- }
-
- /**
- * @TrackedGetter
- */
- public Object get(int index) {
- getterCalled();
- return wrappedList.get(index);
- }
-
- /**
- * @TrackedGetter
- */
- public int indexOf(Object o) {
- getterCalled();
- return wrappedList.indexOf(o);
- }
-
- /**
- * @TrackedGetter
- */
- public int lastIndexOf(Object o) {
- getterCalled();
- return wrappedList.lastIndexOf(o);
- }
-
- // List Iterators
-
- /**
- * @TrackedGetter
- */
- public ListIterator listIterator() {
- return listIterator(0);
- }
-
- /**
- * @TrackedGetter
- */
- public ListIterator listIterator(int index) {
- final ListIterator wrappedIterator = wrappedList.listIterator(index);
- return new ListIterator() {
-
- public int nextIndex() {
- getterCalled();
- return wrappedIterator.nextIndex();
- }
-
- public int previousIndex() {
- getterCalled();
- return wrappedIterator.previousIndex();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- public boolean hasNext() {
- getterCalled();
- return wrappedIterator.hasNext();
- }
-
- public boolean hasPrevious() {
- getterCalled();
- return wrappedIterator.hasPrevious();
- }
-
- public Object next() {
- getterCalled();
- return wrappedIterator.next();
- }
-
- public Object previous() {
- getterCalled();
- return wrappedIterator.previous();
- }
-
- public void add(Object o) {
- throw new UnsupportedOperationException();
- }
-
- public void set(Object o) {
- throw new UnsupportedOperationException();
- }
- };
- }
-
-
- public List subList(int fromIndex, int toIndex) {
- getterCalled();
- return wrappedList.subList(fromIndex, toIndex);
- }
-
- protected void getterCalled() {
- ObservableTracker.getterCalled(this);
- }
-
- public Object set(int index, Object element) {
- throw new UnsupportedOperationException();
- }
-
- public Object remove(int index) {
- throw new UnsupportedOperationException();
- }
-
- public boolean add(Object o) {
- throw new UnsupportedOperationException();
- }
-
- public void add(int index, Object element) {
- throw new UnsupportedOperationException();
- }
-
- public boolean addAll(Collection c) {
- throw new UnsupportedOperationException();
- }
-
- public boolean addAll(int index, Collection c) {
- throw new UnsupportedOperationException();
- }
-
- public boolean remove(Object o) {
- throw new UnsupportedOperationException();
- }
-
- public boolean removeAll(Collection c) {
- throw new UnsupportedOperationException();
- }
-
- public boolean retainAll(Collection c) {
- throw new UnsupportedOperationException();
- }
-
- public void clear() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @return Returns the stale state.
- */
- public boolean isStale() {
- return stale;
- }
-
- /**
- * @param stale
- * The stale state to list. This will fire a stale event if the
- * given boolean is true and this observable list was not already
- * stale.
- */
- public void setStale(boolean stale) {
- boolean wasStale = this.stale;
- this.stale = stale;
- if (!wasStale && stale) {
- fireStale();
- }
- }
-
- protected void fireChange() {
- throw new RuntimeException("fireChange should not be called, use fireListChange() instead"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.provisional.databinding.observable.AbstractObservable#dispose()
- */
- public void dispose() {
- listChangeListeners = null;
- super.dispose();
- }
-
- public Object getElementType() {
- return elementType;
- }
-
- protected void updateWrappedList(List newList) {
- // TODO this is a naive list diff algorithm, we need a
- // smarter one
- List oldList = wrappedList;
- ListDiff listDiff = Diffs.computeListDiff(oldList, newList);
- wrappedList = newList;
- fireListChange(listDiff);
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/WritableList.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/WritableList.java
deleted file mode 100644
index 5cc02145..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/list/WritableList.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.observable.list;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.databinding.observable.Diffs;
-import org.eclipse.jface.internal.databinding.provisional.observable.ILazyListElementProvider;
-
-/**
- * Mutable observable list backed by an ArrayList.
- *
- * @since 1.0
- */
-public class WritableList extends ObservableList implements ILazyListElementProvider {
-
- /**
- * Creates an empty writable list containing elements of type Object.
- */
- public WritableList() {
- this(Object.class);
- }
-
- /**
- * Creates an empty writable list containing elements of the given type.
- *
- * @param elementType
- */
- public WritableList(Object elementType) {
- super(new ArrayList(), elementType);
- }
-
- /**
- * Creates a writable list containing elements of the given type,
- * wrapping an existing client-supplied list.
- *
- * @param toWrap The java.utilList to wrap
- * @param elementType
- */
- public WritableList(List toWrap, Object elementType) {
- super(toWrap, elementType);
- }
-
- public Object set(int index, Object element) {
- getterCalled();
- Object oldElement = wrappedList.set(index, element);
- fireListChange(Diffs.createListDiff(Diffs.createListDiffEntry(index,
- false, oldElement), Diffs.createListDiffEntry(index, true,
- element)));
- return oldElement;
- }
-
- public Object remove(int index) {
- getterCalled();
- Object oldElement = wrappedList.remove(index);
- fireListChange(Diffs.createListDiff(Diffs.createListDiffEntry(index,
- false, oldElement)));
- return oldElement;
- }
-
- public boolean add(Object element) {
- getterCalled();
- boolean added = wrappedList.add(element);
- if (added) {
- fireListChange(Diffs.createListDiff(Diffs.createListDiffEntry(
- wrappedList.size() - 1, true, element)));
- }
- return added;
- }
-
- public void add(int index, Object element) {
- wrappedList.add(index, element);
- fireListChange(Diffs.createListDiff(Diffs.createListDiffEntry(index,
- true, element)));
- }
-
- public boolean addAll(Collection c) {
- ListDiffEntry[] entries = new ListDiffEntry[c.size()];
- int i = 0;
- int addIndex = c.size();
- for (Iterator it = c.iterator(); it.hasNext();) {
- Object element = it.next();
- entries[i++] = Diffs.createListDiffEntry(addIndex++, true, element);
- }
- boolean added = wrappedList.addAll(c);
- fireListChange(Diffs.createListDiff(entries));
- return added;
- }
-
- public boolean addAll(int index, Collection c) {
- ListDiffEntry[] entries = new ListDiffEntry[c.size()];
- int i = 0;
- int addIndex = index;
- for (Iterator it = c.iterator(); it.hasNext();) {
- Object element = it.next();
- entries[i++] = Diffs.createListDiffEntry(addIndex++, true, element);
- }
- boolean added = wrappedList.addAll(index, c);
- fireListChange(Diffs.createListDiff(entries));
- return added;
- }
-
- public boolean remove(Object o) {
- int index = wrappedList.indexOf(o);
- if (index == -1) {
- return false;
- }
- wrappedList.remove(index);
- fireListChange(Diffs.createListDiff(Diffs.createListDiffEntry(index,
- false, o)));
- return true;
- }
-
- public boolean removeAll(Collection c) {
- List entries = new ArrayList();
- for (Iterator it = c.iterator(); it.hasNext();) {
- Object element = it.next();
- int removeIndex = wrappedList.indexOf(element);
- if (removeIndex != -1) {
- wrappedList.remove(removeIndex);
- entries.add(Diffs.createListDiffEntry(removeIndex, true,
- element));
- }
- }
- fireListChange(Diffs.createListDiff((ListDiffEntry[]) entries
- .toArray(new ListDiffEntry[entries.size()])));
- return entries.size() > 0;
- }
-
- public boolean retainAll(Collection c) {
- List entries = new ArrayList();
- int removeIndex = 0;
- for (Iterator it = wrappedList.iterator(); it.hasNext();) {
- Object element = it.next();
- if (!c.contains(element)) {
- entries.add(Diffs.createListDiffEntry(removeIndex, false,
- element));
- it.remove();
- } else {
- // only increment if we haven't removed the current element
- removeIndex++;
- }
- }
- fireListChange(Diffs.createListDiff((ListDiffEntry[]) entries
- .toArray(new ListDiffEntry[entries.size()])));
- return entries.size() > 0;
- }
-
- public void clear() {
- List entries = new ArrayList();
- for (Iterator it = wrappedList.iterator(); it.hasNext();) {
- Object element = it.next();
- // always report 0 as the remove index
- entries.add(Diffs.createListDiffEntry(0, false, element));
- }
- fireListChange(Diffs.createListDiff((ListDiffEntry[]) entries
- .toArray(new ListDiffEntry[entries.size()])));
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/masterdetail/DetailObservableList.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/masterdetail/DetailObservableList.java
deleted file mode 100644
index 4bc08f95..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/masterdetail/DetailObservableList.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.observable.masterdetail;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.databinding.observable.Diffs;
-import org.eclipse.jface.databinding.observable.list.IListChangeListener;
-import org.eclipse.jface.databinding.observable.list.IObservableList;
-import org.eclipse.jface.databinding.observable.list.ListDiff;
-import org.eclipse.jface.databinding.observable.list.ObservableList;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.databinding.observable.value.IValueChangeListener;
-import org.eclipse.jface.databinding.observable.value.ValueDiff;
-
-/**
- * @since 3.2
- *
- */
-
-/* package */class DetailObservableList extends ObservableList {
-
- private boolean updating = false;
-
- private IListChangeListener innerChangeListener = new IListChangeListener() {
- public void handleListChange(IObservableList source, ListDiff diff) {
- if (!updating) {
- fireListChange(diff);
- }
- }
- };
-
- private Object currentOuterValue;
-
- private IObservableList innerObservableList;
-
- private IObservableFactory factory;
-
- private IObservableValue outerObservableValue;
-
- /**
- * @param factory
- * @param outerObservableValue
- * @param feature
- * @param detailType
- */
- public DetailObservableList(IObservableFactory factory,
- IObservableValue outerObservableValue, Object detailType) {
- super(new ArrayList(), detailType);
- this.factory = factory;
- this.outerObservableValue = outerObservableValue;
- updateInnerObservableValue(outerObservableValue);
-
- outerObservableValue.addValueChangeListener(outerChangeListener);
- }
-
- IValueChangeListener outerChangeListener = new IValueChangeListener() {
- public void handleValueChange(IObservableValue source, ValueDiff diff) {
- List oldList = new ArrayList(wrappedList);
- updateInnerObservableValue(outerObservableValue);
- fireListChange(Diffs.computeListDiff(oldList, wrappedList));
- }
- };
-
- private void updateInnerObservableValue(
- IObservableValue outerObservableValue) {
- currentOuterValue = outerObservableValue.getValue();
- if (innerObservableList != null) {
- innerObservableList.removeListChangeListener(innerChangeListener);
- innerObservableList.dispose();
- }
- if (currentOuterValue == null) {
- innerObservableList = null;
- wrappedList = new ArrayList();
- } else {
- this.innerObservableList = (IObservableList) factory
- .createObservable(currentOuterValue);
- wrappedList = innerObservableList;
- Object innerValueType = innerObservableList.getElementType();
- Assert.isTrue(getElementType().equals(innerValueType),
- "Cannot change value type in a nested updatable value"); //$NON-NLS-1$
- innerObservableList.addListChangeListener(innerChangeListener);
- }
- }
-
- public void dispose() {
- super.dispose();
-
- if (outerObservableValue != null) {
- outerObservableValue.removeValueChangeListener(outerChangeListener);
- outerObservableValue.dispose();
- }
- if (innerObservableList != null) {
- innerObservableList.removeListChangeListener(innerChangeListener);
- innerObservableList.dispose();
- }
- currentOuterValue = null;
- factory = null;
- innerObservableList = null;
- innerChangeListener = null;
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/masterdetail/DetailObservableSet.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/masterdetail/DetailObservableSet.java
deleted file mode 100644
index e0ef7bc5..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/masterdetail/DetailObservableSet.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.observable.masterdetail;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.databinding.observable.Diffs;
-import org.eclipse.jface.databinding.observable.set.IObservableSet;
-import org.eclipse.jface.databinding.observable.set.ISetChangeListener;
-import org.eclipse.jface.databinding.observable.set.ObservableSet;
-import org.eclipse.jface.databinding.observable.set.SetDiff;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.databinding.observable.value.IValueChangeListener;
-import org.eclipse.jface.databinding.observable.value.ValueDiff;
-
-/**
- * @since 3.2
- *
- */
-/* package */class DetailObservableSet extends ObservableSet {
-
- private boolean updating = false;
-
- private ISetChangeListener innerChangeListener = new ISetChangeListener() {
- public void handleSetChange(IObservableSet source, SetDiff diff) {
- if (!updating) {
- fireSetChange(diff);
- }
- }
- };
-
- private Object currentOuterValue;
-
- private IObservableSet innerObservableSet;
-
- private IObservableValue outerObservableValue;
-
- private IObservableFactory factory;
-
- /**
- * @param factory
- * @param outerObservableValue
- * @param detailType
- */
- public DetailObservableSet(IObservableFactory factory,
- IObservableValue outerObservableValue, Object detailType) {
- super(new HashSet(), detailType);
- this.factory = factory;
- this.outerObservableValue = outerObservableValue;
- updateInnerObservableValue(outerObservableValue);
-
- outerObservableValue.addValueChangeListener(outerChangeListener);
- }
-
- IValueChangeListener outerChangeListener = new IValueChangeListener() {
- public void handleValueChange(IObservableValue source, ValueDiff diff) {
- Set oldSet = new HashSet(wrappedSet);
- updateInnerObservableValue(outerObservableValue);
- fireSetChange(Diffs.computeSetDiff(oldSet, wrappedSet));
- }
- };
-
- private void updateInnerObservableValue(
- IObservableValue outerObservableValue) {
- currentOuterValue = outerObservableValue.getValue();
- if (innerObservableSet != null) {
- innerObservableSet.removeSetChangeListener(innerChangeListener);
- innerObservableSet.dispose();
- }
- if (currentOuterValue == null) {
- innerObservableSet = null;
- wrappedSet = new HashSet();
- } else {
- this.innerObservableSet = (IObservableSet) factory
- .createObservable(currentOuterValue);
- wrappedSet = innerObservableSet;
- Object innerValueType = innerObservableSet.getElementType();
- if (elementType == null) {
- elementType = innerValueType;
- } else {
- Assert.isTrue(elementType.equals(innerValueType),
- "Cannot change value type in a nested updatable value"); //$NON-NLS-1$
- }
- innerObservableSet.addSetChangeListener(innerChangeListener);
- }
- }
-
- public void dispose() {
- super.dispose();
-
- if (outerObservableValue != null) {
- outerObservableValue.removeValueChangeListener(outerChangeListener);
- outerObservableValue.dispose();
- }
- if (innerObservableSet != null) {
- innerObservableSet.removeSetChangeListener(innerChangeListener);
- innerObservableSet.dispose();
- }
- currentOuterValue = null;
- factory = null;
- innerObservableSet = null;
- innerChangeListener = null;
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/masterdetail/DetailObservableValue.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/masterdetail/DetailObservableValue.java
deleted file mode 100644
index 66f87c85..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/masterdetail/DetailObservableValue.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.observable.masterdetail;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.databinding.observable.Diffs;
-import org.eclipse.jface.databinding.observable.value.AbstractObservableValue;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.databinding.observable.value.IValueChangeListener;
-import org.eclipse.jface.databinding.observable.value.ValueDiff;
-
-/**
- * @since 1.0
- *
- */
-/* package */class DetailObservableValue extends AbstractObservableValue {
-
- private boolean updating = false;
-
- private IValueChangeListener innerChangeListener = new IValueChangeListener() {
- public void handleValueChange(IObservableValue source, ValueDiff diff) {
- if (!updating) {
- fireValueChange(diff);
- }
- }
- };
-
- private Object currentOuterValue;
-
- private IObservableValue innerObservableValue;
-
- private Object detailType;
-
- private IObservableValue outerObservableValue;
-
- private IObservableFactory factory;
-
- /**
- * @param factory
- * @param outerObservableValue
- * @param detailType
- */
- public DetailObservableValue(IObservableFactory factory,
- IObservableValue outerObservableValue, Object detailType) {
- this.factory = factory;
- this.detailType = detailType;
- this.outerObservableValue = outerObservableValue;
- updateInnerObservableValue(outerObservableValue);
-
- outerObservableValue.addValueChangeListener(outerChangeListener);
- }
-
- IValueChangeListener outerChangeListener = new IValueChangeListener() {
- public void handleValueChange(IObservableValue source, ValueDiff diff) {
- Object oldValue = doGetValue();
- updateInnerObservableValue(outerObservableValue);
- fireValueChange(Diffs.createValueDiff(oldValue, doGetValue()));
- }
- };
-
- private void updateInnerObservableValue(
- IObservableValue outerObservableValue) {
- currentOuterValue = outerObservableValue.getValue();
- if (innerObservableValue != null) {
- innerObservableValue.removeValueChangeListener(innerChangeListener);
- innerObservableValue.dispose();
- }
- if (currentOuterValue == null) {
- innerObservableValue = null;
- } else {
- this.innerObservableValue = (IObservableValue) factory
- .createObservable(currentOuterValue);
- Object innerValueType = innerObservableValue.getValueType();
- if (detailType == null) {
- detailType = innerValueType;
- } else {
- Assert
- .isTrue(detailType.equals(innerValueType),
- "Cannot change value type in a nested observable value"); //$NON-NLS-1$
- }
- innerObservableValue.addValueChangeListener(innerChangeListener);
- }
- }
-
- public void setValue(Object value) {
- if (innerObservableValue != null)
- innerObservableValue.setValue(value);
- }
-
- public Object doGetValue() {
- return innerObservableValue == null ? null : innerObservableValue
- .getValue();
- }
-
- public Object getValueType() {
- return detailType;
- }
-
- public void dispose() {
- super.dispose();
-
- if (outerObservableValue != null) {
- outerObservableValue.removeValueChangeListener(outerChangeListener);
- outerObservableValue.dispose();
- }
- if (innerObservableValue != null) {
- innerObservableValue.removeValueChangeListener(innerChangeListener);
- innerObservableValue.dispose();
- }
- currentOuterValue = null;
- factory = null;
- innerObservableValue = null;
- innerChangeListener = null;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/masterdetail/IObservableFactory.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/masterdetail/IObservableFactory.java
deleted file mode 100644
index 2af81918..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/masterdetail/IObservableFactory.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable.masterdetail;
-
-import org.eclipse.jface.databinding.observable.IObservable;
-
-/**
- * @since 3.2
- *
- */
-public interface IObservableFactory {
-
- /**
- * Creates an observable for the given target object.
- * @param target
- * @return the new observable
- */
- public IObservable createObservable(Object target);
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/masterdetail/MasterDetailObservables.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/masterdetail/MasterDetailObservables.java
deleted file mode 100644
index e36e33f1..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/masterdetail/MasterDetailObservables.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable.masterdetail;
-
-import org.eclipse.jface.databinding.observable.list.IObservableList;
-import org.eclipse.jface.databinding.observable.set.IObservableSet;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-
-/**
- * @since 3.2
- *
- */
-public class MasterDetailObservables {
-
- /**
- * Creates a detail observable value from a master observable value and a
- * factory. This can be used to create observable values that represent a
- * property of a selected object in a table.
- *
- * @param master
- * the observable value to track
- * @param detailFactory
- * a factory for creating {@link IObservableValue} instances
- * given a current value of the master
- * @param detailType
- * the value type of the detail observable value, typically of
- * type java.lang.Class
- * @return an observable value of the given value type that, for any current
- * value of the given master value, behaves like the observable
- * value created by the factory for that current value.
- */
- public static IObservableValue getDetailValue(IObservableValue master,
- IObservableFactory detailFactory, Object detailType) {
- return new DetailObservableValue(detailFactory, master, detailType);
- }
-
- /**
- * Creates a detail observable list from a master observable value and a
- * factory. This can be used to create observable lists that represent a
- * list property of a selected object in a table.
- *
- * @param master
- * the observable value to track
- * @param detailFactory
- * a factory for creating {@link IObservableList} instances given
- * a current value of the master
- * @param detailElementType
- * the element type of the detail observable list, typically of
- * type java.lang.Class
- * @return an observable list with the given element type that, for any
- * current value of the given master value, behaves like the
- * observable list created by the factory for that current value.
- */
- public static IObservableList getDetailList(IObservableValue master,
- IObservableFactory detailFactory, Object detailElementType) {
- return new DetailObservableList(detailFactory, master,
- detailElementType);
- }
-
- /**
- * Creates a detail observable set from a master observable value and a
- * factory. This can be used to create observable sets that represent a set
- * property of a selected object in a table.
- *
- * @param master
- * the observable value to track
- * @param detailFactory
- * a factory for creating {@link IObservableSet} instances given
- * a current value of the master
- * @param detailElementType
- * the element type of the detail observable set, typically of
- * type java.lang.Class
- * @return an observable set with the given element type that, for any
- * current value of the given master value, behaves like the
- * observable set created by the factory for that current value.
- */
- public static IObservableSet getDetailSet(IObservableValue master,
- IObservableFactory detailFactory, Object detailElementType) {
- return new DetailObservableSet(detailFactory, master, detailElementType);
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/AbstractObservableSet.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/AbstractObservableSet.java
deleted file mode 100644
index ed653cf9..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/AbstractObservableSet.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable.set;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.jface.databinding.observable.AbstractObservable;
-import org.eclipse.jface.databinding.observable.ObservableTracker;
-
-/**
- *
- * Abstract implementation of {@link IObservableSet}.
- *
- * TODO: Boris - refactor this to merge whatever happens to be useful into
- * ObservableSet, then delete this class. AFAIK, the only major innovation
- * here is that you return the wrapped set from a getter rather than passing
- * it into the constructor, so it is not necessary for it to be initialized at
- * construction-time.
- *
- * @since 1.0
- *
- */
-public abstract class AbstractObservableSet extends AbstractObservable implements
- IObservableSet {
-
- private boolean stale = false;
-
- private Object setChangeListeners;
-
- protected AbstractObservableSet() {
- }
-
- public void addSetChangeListener(ISetChangeListener listener) {
- if (setChangeListeners == null) {
- boolean hadListeners = hasListeners();
- setChangeListeners = listener;
- if (!hadListeners) {
- firstListenerAdded();
- }
- return;
- }
-
- Collection listenerList;
- if (setChangeListeners instanceof Collection) {
- listenerList = (Collection) setChangeListeners;
- } else {
- ISetChangeListener l = (ISetChangeListener) setChangeListeners;
-
- listenerList = new ArrayList();
- listenerList.add(l);
- setChangeListeners = listenerList;
- }
-
- if (listenerList.size() > 16) {
- HashSet listenerSet = new HashSet();
- listenerSet.addAll(listenerList);
- setChangeListeners = listenerList;
- }
-
- listenerList.add(listener);
- }
-
- public void removeSetChangeListener(ISetChangeListener listener) {
-
- if (setChangeListeners == listener) {
- setChangeListeners = null;
- if (!hasListeners()) {
- lastListenerRemoved();
- }
- return;
- }
-
- if (setChangeListeners instanceof Collection) {
- Collection listenerList = (Collection) setChangeListeners;
- listenerList.remove(listener);
- if (listenerList.size() == 0) {
- setChangeListeners = null;
- if (!hasListeners()) {
- lastListenerRemoved();
- }
- }
- }
- }
-
- protected abstract Set getWrappedSet();
-
- /**
- * @return
- */
- protected boolean hasListeners() {
- return super.hasListeners() || setChangeListeners!=null;
- }
-
- protected void fireSetChange(SetDiff diff) {
- // fire general change event first
- super.fireChange();
-
- if (setChangeListeners == null) {
- return;
- }
-
- if (setChangeListeners instanceof ISetChangeListener) {
- ((ISetChangeListener) setChangeListeners).handleSetChange(this, diff);
- return;
- }
-
- Collection changeListenerCollection = (Collection) setChangeListeners;
-
- ISetChangeListener[] listeners = (ISetChangeListener[]) (changeListenerCollection)
- .toArray(new ISetChangeListener[changeListenerCollection.size()]);
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].handleSetChange(this, diff);
- }
- }
-
- public boolean contains(Object o) {
- getterCalled();
- return getWrappedSet().contains(o);
- }
-
- public boolean containsAll(Collection c) {
- getterCalled();
- return getWrappedSet().containsAll(c);
- }
-
- public boolean equals(Object o) {
- getterCalled();
- return getWrappedSet().equals(o);
- }
-
- public int hashCode() {
- getterCalled();
- return getWrappedSet().hashCode();
- }
-
- public boolean isEmpty() {
- getterCalled();
- return getWrappedSet().isEmpty();
- }
-
- public Iterator iterator() {
- final Iterator wrappedIterator = getWrappedSet().iterator();
- return new Iterator() {
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- public boolean hasNext() {
- ObservableTracker.getterCalled(AbstractObservableSet.this);
- return wrappedIterator.hasNext();
- }
-
- public Object next() {
- ObservableTracker.getterCalled(AbstractObservableSet.this);
- return wrappedIterator.next();
- }
- };
- }
-
- public int size() {
- getterCalled();
- return getWrappedSet().size();
- }
-
- public Object[] toArray() {
- getterCalled();
- return getWrappedSet().toArray();
- }
-
- public Object[] toArray(Object[] a) {
- getterCalled();
- return getWrappedSet().toArray(a);
- }
-
- public String toString() {
- getterCalled();
- return getWrappedSet().toString();
- }
-
- protected void getterCalled() {
- ObservableTracker.getterCalled(this);
- }
-
- public boolean add(Object o) {
- throw new UnsupportedOperationException();
- }
-
- public boolean addAll(Collection c) {
- throw new UnsupportedOperationException();
- }
-
- public boolean remove(Object o) {
- throw new UnsupportedOperationException();
- }
-
- public boolean removeAll(Collection c) {
- throw new UnsupportedOperationException();
- }
-
- public boolean retainAll(Collection c) {
- throw new UnsupportedOperationException();
- }
-
- public void clear() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @return Returns the stale state.
- */
- public boolean isStale() {
- return stale;
- }
-
- /**
- * @param stale
- * The stale state to set. This will fire a stale event if the
- * given boolean is true and this observable set was not already
- * stale.
- */
- public void setStale(boolean stale) {
- boolean wasStale = this.stale;
- this.stale = stale;
- if (!wasStale && stale) {
- fireStale();
- }
- }
-
-
- protected void fireChange() {
- throw new RuntimeException("fireChange should not be called, use fireSetChange() instead"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.provisional.databinding.observable.AbstractObservable#dispose()
- */
- public void dispose() {
- setChangeListeners = null;
- super.dispose();
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/IObservableSet.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/IObservableSet.java
deleted file mode 100644
index 5c41d6b7..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/IObservableSet.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable.set;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.jface.databinding.observable.IObservableCollection;
-
-/**
- * A set whose changes can be tracked by set change listeners.
- *
- * <p>
- * This interface is not intended to be implemented by clients. Clients should
- * instead subclass one of the classes that implement this interface. Note that
- * direct implementers of this interface outside of the framework will be broken
- * in future releases when methods are added to this interface.
- * </p>
- *
- * @since 1.0
- *
- */
-public interface IObservableSet extends Set, IObservableCollection {
-
- /**
- * @param listener
- */
- public void addSetChangeListener(ISetChangeListener listener);
-
- /**
- * @param listener
- */
- public void removeSetChangeListener(ISetChangeListener listener);
-
- /**
- * @return the element type
- */
- public Object getElementType();
-
- /**
- * @TrackedGetter
- */
- int size();
-
- /**
- * @TrackedGetter
- */
- boolean isEmpty();
-
- /**
- * @TrackedGetter
- */
- boolean contains(Object o);
-
- /**
- * @TrackedGetter
- */
- Iterator iterator();
-
- /**
- * @TrackedGetter
- */
- Object[] toArray();
-
- /**
- * @TrackedGetter
- */
- Object[] toArray(Object a[]);
-
- // Modification Operations
-
- /**
- * @TrackedGetter
- */
- boolean add(Object o);
-
- /**
- * @TrackedGetter
- */
- boolean remove(Object o);
-
- // Bulk Operations
-
- /**
- * @TrackedGetter
- */
- boolean containsAll(Collection c);
-
- /**
- * @TrackedGetter
- */
- boolean addAll(Collection c);
-
- /**
- * @TrackedGetter
- */
- boolean retainAll(Collection c);
-
- /**
- * @TrackedGetter
- */
- boolean removeAll(Collection c);
-
- // Comparison and hashing
-
- /**
- * @TrackedGetter
- */
- boolean equals(Object o);
-
- /**
- * @TrackedGetter
- */
- int hashCode();
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/ISetChangeListener.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/ISetChangeListener.java
deleted file mode 100644
index b7c2d5bc..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/ISetChangeListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable.set;
-
-
-/**
- * @since 1.0
- *
- */
-public interface ISetChangeListener {
-
- /**
- * @param source
- * @param diff
- */
- void handleSetChange(IObservableSet source, SetDiff diff);
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/ListToSetAdapter.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/ListToSetAdapter.java
deleted file mode 100644
index d8270549..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/ListToSetAdapter.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable.set;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.jface.databinding.observable.Diffs;
-import org.eclipse.jface.databinding.observable.list.IListChangeListener;
-import org.eclipse.jface.databinding.observable.list.IObservableList;
-import org.eclipse.jface.databinding.observable.list.ListDiff;
-import org.eclipse.jface.databinding.observable.list.ListDiffEntry;
-
-/**
- * Observable set backed by an observable list. The wrapped list must not
- * contain duplicate elements.
- *
- * @since 3.2
- *
- */
-public class ListToSetAdapter extends ObservableSet {
-
- private final IObservableList list;
-
- private IListChangeListener listener = new IListChangeListener() {
-
- public void handleListChange(IObservableList source, ListDiff diff) {
- Set added = new HashSet();
- Set removed = new HashSet();
- ListDiffEntry[] differences = diff.getDifferences();
- for (int i = 0; i < differences.length; i++) {
- ListDiffEntry entry = differences[i];
- Object element = entry.getElement();
- if (entry.isAddition()) {
- if (wrappedSet.add(element)) {
- if (!removed.remove(element))
- added.add(element);
- }
- } else {
- if (wrappedSet.remove(element)) {
- removed.add(element);
- added.remove(element);
- }
- }
- }
- fireSetChange(Diffs.createSetDiff(added, removed));
- }
- };
-
- /**
- * @param list
- */
- public ListToSetAdapter(IObservableList list) {
- super(new HashSet(), list.getElementType());
- this.list = list;
- wrappedSet.addAll(list);
- this.list.addListChangeListener(listener);
- }
-
- public void dispose() {
- super.dispose();
- if (list != null && listener != null) {
- list.removeListChangeListener(listener);
- listener = null;
- }
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/MappedSet.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/MappedSet.java
deleted file mode 100644
index 0cb7036f..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/MappedSet.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable.set;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.jface.databinding.observable.Diffs;
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.internal.databinding.provisional.observable.mapping.IMappingChangeListener;
-import org.eclipse.jface.internal.databinding.provisional.observable.mapping.IObservableMapping;
-import org.eclipse.jface.internal.databinding.provisional.observable.mapping.MappingDiff;
-
-/**
- * @since 1.0
- *
- */
-public class MappedSet extends ObservableSet {
-
- private final IObservableMapping wrappedMapping;
-
- /*
- * Map from values (range elements) to Integer ref counts
- */
- private Map valueCounts = new HashMap();
-
- private ISetChangeListener domainListener = new ISetChangeListener() {
- public void handleSetChange(IObservableSet source, SetDiff diff) {
- Set additions = new HashSet();
- for (Iterator it = diff.getAdditions().iterator(); it.hasNext();) {
- Object added = it.next();
- Object mappingValue = wrappedMapping.getMappingValue(added);
- if (handleAddition(mappingValue)) {
- additions.add(mappingValue);
- }
- }
- Set removals = new HashSet();
- for (Iterator it = diff.getRemovals().iterator(); it.hasNext();) {
- Object removed = it.next();
- Object mappingValue = wrappedMapping.getMappingValue(removed);
- if (handleRemoval(mappingValue)) {
- removals.add(mappingValue);
- }
- }
- fireSetChange(Diffs.createSetDiff(additions, removals));
- }
- };
-
- private IMappingChangeListener mappingChangeListener = new IMappingChangeListener() {
- public void handleMappingValueChange(IObservable source,
- MappingDiff diff) {
- Set affectedElements = diff.getElements();
- Set additions = new HashSet();
- Set removals = new HashSet();
- for (Iterator it = affectedElements.iterator(); it.hasNext();) {
- Object element = it.next();
- Object oldFunctionValue = diff.getOldMappingValues(element,
- new int[] { 0 })[0];
- Object newFunctionValue = diff.getNewMappingValues(element,
- new int[] { 0 })[0];
- if (handleRemoval(oldFunctionValue)) {
- removals.add(oldFunctionValue);
- }
- if (handleAddition(newFunctionValue)) {
- additions.add(newFunctionValue);
- }
- }
- fireSetChange(Diffs.createSetDiff(additions, removals));
- }
- };
-
- private IObservableSet input;
-
- /**
- * @param input
- * @param mapping
- */
- public MappedSet(IObservableSet input, IObservableMapping mapping) {
- super(Collections.EMPTY_SET, mapping.getValueType());
- setWrappedSet(valueCounts.keySet());
- this.wrappedMapping = mapping;
- this.input = input;
- for (Iterator it = input.iterator(); it.hasNext();) {
- Object element = it.next();
- Object functionValue = wrappedMapping.getMappingValue(element);
- handleAddition(functionValue);
- }
- input.addSetChangeListener(domainListener);
- mapping.addMappingChangeListener(mappingChangeListener);
- }
-
- /**
- * @param mappingValue
- * @return true if the given mappingValue was an addition
- */
- protected boolean handleAddition(Object mappingValue) {
- Integer count = (Integer) valueCounts.get(mappingValue);
- if (count == null) {
- valueCounts.put(mappingValue, new Integer(1));
- return true;
- }
- valueCounts.put(mappingValue, new Integer(count.intValue() + 1));
- return false;
- }
-
- /**
- * @param mappingValue
- * @return true if the given mappingValue has been removed
- */
- protected boolean handleRemoval(Object mappingValue) {
- Integer count = (Integer) valueCounts.get(mappingValue);
- if (count.intValue() <= 1) {
- valueCounts.remove(mappingValue);
- return true;
- }
- valueCounts.put(mappingValue, new Integer(count.intValue() - 1));
- return false;
- }
-
- public void dispose() {
- wrappedMapping.removeMappingChangeListener(mappingChangeListener);
- input.removeSetChangeListener(domainListener);
- }
-
- public Object getElementType() {
- return wrappedMapping.getValueType();
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/ObservableSet.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/ObservableSet.java
deleted file mode 100644
index 13662f7d..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/ObservableSet.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable.set;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.jface.databinding.observable.AbstractObservable;
-import org.eclipse.jface.databinding.observable.ObservableTracker;
-
-/**
- *
- * Abstract implementation of {@link IObservableSet}.
- *
- * @since 1.0
- *
- */
-public abstract class ObservableSet extends AbstractObservable implements
- IObservableSet {
-
- protected Set wrappedSet;
-
- private boolean stale = false;
-
- private Object setChangeListeners;
-
- protected Object elementType;
-
- protected ObservableSet(Set wrappedSet, Object elementType) {
- this.wrappedSet = wrappedSet;
- this.elementType = elementType;
- }
-
- public void addSetChangeListener(ISetChangeListener listener) {
- if (setChangeListeners == null) {
- boolean hadListeners = hasListeners();
- setChangeListeners = listener;
- if (!hadListeners) {
- firstListenerAdded();
- }
- return;
- }
-
- Collection listenerList;
- if (setChangeListeners instanceof Collection) {
- listenerList = (Collection) setChangeListeners;
- } else {
- ISetChangeListener l = (ISetChangeListener) setChangeListeners;
-
- listenerList = new ArrayList();
- listenerList.add(l);
- setChangeListeners = listenerList;
- }
-
- listenerList.add(listener);
- }
-
- public void removeSetChangeListener(ISetChangeListener listener) {
-
- if (setChangeListeners == listener) {
- setChangeListeners = null;
- if (!hasListeners()) {
- lastListenerRemoved();
- }
- return;
- }
-
- if (setChangeListeners instanceof Collection) {
- Collection listenerList = (Collection) setChangeListeners;
- listenerList.remove(listener);
- if (listenerList.isEmpty()) {
- setChangeListeners = null;
- if (!hasListeners()) {
- lastListenerRemoved();
- }
- }
- }
- }
-
- /**
- * @return
- */
- protected boolean hasListeners() {
- return super.hasListeners() || setChangeListeners!=null;
- }
-
- protected void fireSetChange(SetDiff diff) {
- // fire general change event first
- super.fireChange();
-
- if (setChangeListeners == null) {
- return;
- }
-
- if (setChangeListeners instanceof ISetChangeListener) {
- ((ISetChangeListener) setChangeListeners).handleSetChange(this, diff);
- return;
- }
-
- Collection changeListenerCollection = (Collection) setChangeListeners;
-
- ISetChangeListener[] listeners = (ISetChangeListener[]) (changeListenerCollection)
- .toArray(new ISetChangeListener[changeListenerCollection.size()]);
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].handleSetChange(this, diff);
- }
- }
-
- public boolean contains(Object o) {
- getterCalled();
- return wrappedSet.contains(o);
- }
-
- public boolean containsAll(Collection c) {
- getterCalled();
- return wrappedSet.containsAll(c);
- }
-
- public boolean equals(Object o) {
- getterCalled();
- return wrappedSet.equals(o);
- }
-
- public int hashCode() {
- getterCalled();
- return wrappedSet.hashCode();
- }
-
- public boolean isEmpty() {
- getterCalled();
- return wrappedSet.isEmpty();
- }
-
- public Iterator iterator() {
- final Iterator wrappedIterator = wrappedSet.iterator();
- return new Iterator() {
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- public boolean hasNext() {
- ObservableTracker.getterCalled(ObservableSet.this);
- return wrappedIterator.hasNext();
- }
-
- public Object next() {
- ObservableTracker.getterCalled(ObservableSet.this);
- return wrappedIterator.next();
- }
- };
- }
-
- public int size() {
- getterCalled();
- return wrappedSet.size();
- }
-
- public Object[] toArray() {
- getterCalled();
- return wrappedSet.toArray();
- }
-
- public Object[] toArray(Object[] a) {
- getterCalled();
- return wrappedSet.toArray(a);
- }
-
- public String toString() {
- getterCalled();
- return wrappedSet.toString();
- }
-
- protected void getterCalled() {
- ObservableTracker.getterCalled(this);
- }
-
- public boolean add(Object o) {
- throw new UnsupportedOperationException();
- }
-
- public boolean addAll(Collection c) {
- throw new UnsupportedOperationException();
- }
-
- public boolean remove(Object o) {
- throw new UnsupportedOperationException();
- }
-
- public boolean removeAll(Collection c) {
- throw new UnsupportedOperationException();
- }
-
- public boolean retainAll(Collection c) {
- throw new UnsupportedOperationException();
- }
-
- public void clear() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @return Returns the stale state.
- */
- public boolean isStale() {
- return stale;
- }
-
- /**
- * @param stale
- * The stale state to set. This will fire a stale event if the
- * given boolean is true and this observable set was not already
- * stale.
- */
- public void setStale(boolean stale) {
- boolean wasStale = this.stale;
- this.stale = stale;
- if (!wasStale && stale) {
- fireStale();
- }
- }
-
- /**
- * @param wrappedSet The wrappedSet to set.
- */
- protected void setWrappedSet(Set wrappedSet) {
- this.wrappedSet = wrappedSet;
- }
-
- protected void fireChange() {
- throw new RuntimeException("fireChange should not be called, use fireSetChange() instead"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.provisional.databinding.observable.AbstractObservable#dispose()
- */
- public void dispose() {
- setChangeListeners = null;
- super.dispose();
- }
-
- public Object getElementType() {
- return elementType;
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/SetDiff.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/SetDiff.java
deleted file mode 100644
index 910d1c73..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/SetDiff.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable.set;
-
-import java.util.Set;
-
-import org.eclipse.jface.databinding.observable.IDiff;
-
-/**
- * @since 1.0
- *
- */
-public abstract class SetDiff implements IDiff {
-
- /**
- * @return the set of added elements
- */
- public abstract Set getAdditions();
-
- /**
- * @return the set of removed elements
- */
- public abstract Set getRemovals();
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer
- .append(getClass().getName())
- .append("{additions [") //$NON-NLS-1$
- .append(getAdditions() != null ? getAdditions().toString() : "null") //$NON-NLS-1$
- .append("], removals [") //$NON-NLS-1$
- .append(getRemovals() != null ? getRemovals().toString() : "null") //$NON-NLS-1$
- .append("]}"); //$NON-NLS-1$
-
- return buffer.toString();
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/UnionSet.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/UnionSet.java
deleted file mode 100644
index 70a3769a..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/UnionSet.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable.set;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.jface.databinding.observable.Diffs;
-import org.eclipse.jface.internal.databinding.internal.observable.IStalenessConsumer;
-import org.eclipse.jface.internal.databinding.internal.observable.StalenessTracker;
-
-/**
- * Represents a set consisting of the union of elements from one or more other
- * sets. This object does not need to be explicitly disposed. If nobody is
- * listening to the UnionSet, the set will remove its listeners.
- *
- * @since 1.0
- */
-public final class UnionSet extends ObservableSet {
-
- /**
- * child sets
- */
- private IObservableSet[] childSets;
-
- private boolean stale = false;
-
- /**
- * Map of elements onto Integer reference counts. This map is constructed
- * when the first listener is added to the union set. Null if nobody is
- * listening to the UnionSet.
- */
- private HashMap refCounts = null;
-
- private StalenessTracker stalenessTracker;
-
- /**
- * @param childSets
- */
- public UnionSet(IObservableSet[] childSets) {
- super(null, childSets[0].getElementType());
- this.childSets = childSets;
- this.stalenessTracker = new StalenessTracker(childSets,
- stalenessConsumer);
- }
-
- private ISetChangeListener childSetChangeListener = new ISetChangeListener() {
- public void handleSetChange(IObservableSet source, SetDiff diff) {
- processAddsAndRemoves(diff.getAdditions(), diff.getRemovals());
- }
- };
-
- private IStalenessConsumer stalenessConsumer = new IStalenessConsumer() {
- public void setStale(boolean stale) {
- boolean oldStale = UnionSet.this.stale;
- UnionSet.this.stale = stale;
- if (stale && !oldStale) {
- fireStale();
- }
- }
- };
-
- public boolean isStale() {
- if (refCounts != null) {
- return stale;
- }
-
- for (int i = 0; i < childSets.length; i++) {
- IObservableSet childSet = childSets[i];
-
- if (childSet.isStale()) {
- return true;
- }
- }
- return false;
- }
-
- private void processAddsAndRemoves(Set adds, Set removes) {
- Set addsToFire = new HashSet();
- Set removesToFire = new HashSet();
-
- for (Iterator iter = adds.iterator(); iter.hasNext();) {
- Object added = iter.next();
-
- Integer refCount = (Integer) refCounts.get(added);
- if (refCount == null) {
- refCounts.put(added, new Integer(1));
- addsToFire.add(added);
- } else {
- int refs = refCount.intValue();
- refCount = new Integer(refs + 1);
- refCounts.put(added, refCount);
- }
- }
-
- for (Iterator iter = removes.iterator(); iter.hasNext();) {
- Object removed = iter.next();
-
- Integer refCount = (Integer) refCounts.get(removed);
- if (refCount != null) {
- int refs = refCount.intValue();
- if (refs <= 1) {
- removesToFire.add(removed);
- refCounts.remove(removed);
- } else {
- refCount = new Integer(refCount.intValue() - 1);
- refCounts.put(removed, refCount);
- }
- }
- }
-
- // just in case the removes overlapped with the adds
- addsToFire.removeAll(removesToFire);
-
- if (addsToFire.size() > 0 || removesToFire.size() > 0) {
- fireSetChange(Diffs.createSetDiff(addsToFire, removesToFire));
- }
- }
-
- protected void firstListenerAdded() {
- super.firstListenerAdded();
-
- refCounts = new HashMap();
- for (int i = 0; i < childSets.length; i++) {
- IObservableSet next = childSets[i];
- next.addSetChangeListener(childSetChangeListener);
- incrementRefCounts(next);
- }
- stalenessTracker = new StalenessTracker(childSets, stalenessConsumer);
- setWrappedSet(refCounts.keySet());
- }
-
- protected void lastListenerRemoved() {
- super.lastListenerRemoved();
-
- for (int i = 0; i < childSets.length; i++) {
- IObservableSet next = childSets[i];
-
- next.removeSetChangeListener(childSetChangeListener);
- stalenessTracker.removeObservable(next);
- }
- refCounts = null;
- stalenessTracker = null;
- setWrappedSet(null);
- }
-
- private ArrayList incrementRefCounts(Collection added) {
- ArrayList adds = new ArrayList();
-
- for (Iterator iter = added.iterator(); iter.hasNext();) {
- Object next = iter.next();
-
- Integer refCount = (Integer) refCounts.get(next);
- if (refCount == null) {
- adds.add(next);
- refCount = new Integer(1);
- refCounts.put(next, refCount);
- } else {
- refCount = new Integer(refCount.intValue() + 1);
- refCounts.put(next, refCount);
- }
- }
- return adds;
- }
-
- protected void getterCalled() {
- super.getterCalled();
- if (refCounts == null) {
- // no listeners, recompute
- setWrappedSet(computeElements());
- }
- }
-
- private Set computeElements() {
- // If there is no cached value, compute the union from scratch
- if (refCounts == null) {
- Set result = new HashSet();
- for (int i = 0; i < childSets.length; i++) {
- result.addAll(childSets[i]);
- }
- return result;
- }
-
- // Else there is a cached value. Return it.
- return refCounts.keySet();
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/WritableSet.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/WritableSet.java
deleted file mode 100644
index 2a150613..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/set/WritableSet.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable.set;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.jface.databinding.observable.Diffs;
-
-/**
- * @since 1.0
- *
- */
-public class WritableSet extends ObservableSet {
-
- /**
- * @param wrappedSet
- */
- public WritableSet() {
- this(Object.class);
- }
-
- /**
- * @param c
- */
- public WritableSet(Collection c) {
- this(c, Object.class);
- }
-
- /**
- * @param c
- * @param elementType
- */
- public WritableSet(Collection c, Object elementType) {
- super(new HashSet(c), elementType);
- this.elementType = elementType;
- }
-
- /**
- * @param elementType
- */
- public WritableSet(Object elementType) {
- super(new HashSet(), elementType);
- }
-
- public boolean add(Object o) {
- boolean added = wrappedSet.add(o);
- if (added) {
- fireSetChange(Diffs.createSetDiff(Collections.singleton(o), Collections.EMPTY_SET));
- }
- return added;
- }
-
- public boolean addAll(Collection c) {
- Set adds = new HashSet();
- Iterator it = c.iterator();
- while (it.hasNext()) {
- Object element = it.next();
- if (wrappedSet.add(element)) {
- adds.add(element);
- }
- }
- if (adds.size() > 0) {
- fireSetChange(Diffs.createSetDiff(adds, Collections.EMPTY_SET));
- return true;
- }
- return false;
- }
-
- public boolean remove(Object o) {
- boolean removed = wrappedSet.remove(o);
- if (removed) {
- fireSetChange(Diffs.createSetDiff(Collections.EMPTY_SET, Collections
- .singleton(o)));
- }
- return removed;
- }
-
- public boolean removeAll(Collection c) {
- Set removes = new HashSet();
- Iterator it = c.iterator();
- while (it.hasNext()) {
- Object element = it.next();
- if (wrappedSet.remove(element)) {
- removes.add(element);
- }
- }
- if (removes.size() > 0) {
- fireSetChange(Diffs.createSetDiff(Collections.EMPTY_SET, removes));
- return true;
- }
- return false;
- }
-
- public boolean retainAll(Collection c) {
- Set removes = new HashSet();
- Iterator it = wrappedSet.iterator();
- while (it.hasNext()) {
- Object element = it.next();
- if (!c.contains(element)) {
- it.remove();
- removes.add(element);
- }
- }
- if (removes.size() > 0) {
- fireSetChange(Diffs.createSetDiff(Collections.EMPTY_SET, removes));
- return true;
- }
- return false;
- }
-
- public void clear() {
- Set removes = new HashSet(wrappedSet);
- wrappedSet.clear();
- fireSetChange(Diffs.createSetDiff(Collections.EMPTY_SET, removes));
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/AbstractObservableValue.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/AbstractObservableValue.java
deleted file mode 100644
index 5a8f52f4..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/AbstractObservableValue.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.jface.databinding.observable.AbstractObservable;
-import org.eclipse.jface.databinding.observable.ObservableTracker;
-
-/**
- * @since 1.0
- *
- */
-abstract public class AbstractObservableValue extends AbstractObservable
- implements IObservableValue {
-
- private Collection valueChangeListeners = null;
-
- public void addValueChangeListener(IValueChangeListener listener) {
- if (valueChangeListeners == null) {
- boolean hadListeners = hasListeners();
- valueChangeListeners = new ArrayList();
- valueChangeListeners.add(listener);
- if (!hadListeners) {
- firstListenerAdded();
- }
- } else {
- valueChangeListeners.add(listener);
- }
- }
-
- public void removeValueChangeListener(IValueChangeListener listener) {
- if (valueChangeListeners == null) {
- return;
- }
- valueChangeListeners.remove(listener);
- if (valueChangeListeners.isEmpty()) {
- valueChangeListeners = null;
- }
- if (!hasListeners()) {
- lastListenerRemoved();
- }
- }
-
- public void setValue(Object value) {
- throw new UnsupportedOperationException();
- }
-
- protected void fireValueChange(ValueDiff diff) {
- // fire general change event first
- super.fireChange();
- if (valueChangeListeners != null) {
- IValueChangeListener[] listeners = (IValueChangeListener[]) valueChangeListeners
- .toArray(new IValueChangeListener[valueChangeListeners
- .size()]);
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].handleValueChange(this, diff);
- }
- }
- }
-
- public final Object getValue() {
- ObservableTracker.getterCalled(this);
- return doGetValue();
- }
-
- abstract protected Object doGetValue();
-
- public boolean isStale() {
- return false;
- }
-
- /**
- * @return
- */
- protected boolean hasListeners() {
- return super.hasListeners() || valueChangeListeners != null;
- }
-
- protected void fireChange() {
- throw new RuntimeException(
- "fireChange should not be called, use fireValueChange() instead"); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.provisional.databinding.observable.AbstractObservable#dispose()
- */
- public void dispose() {
- valueChangeListeners = null;
- super.dispose();
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/AbstractVetoableValue.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/AbstractVetoableValue.java
deleted file mode 100644
index 4b19fa1a..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/AbstractVetoableValue.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.observable.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.jface.databinding.observable.Diffs;
-
-/**
- * @since 1.0
- *
- */
-public abstract class AbstractVetoableValue extends AbstractObservableValue
- implements IVetoableValue {
-
- public void setValue(Object value) {
- Object currentValue = doGetValue();
- ValueDiff diff = Diffs.createValueDiff(currentValue, value);
- boolean okToProceed = fireValueChanging(diff);
- if (!okToProceed) {
- throw new ChangeVetoException("Change not permitted"); //$NON-NLS-1$
- }
- doSetValue(value);
- fireValueChange(diff);
- }
-
- private Collection valueChangingListeners = null;
-
- public void addValueChangingListener(IValueChangingListener listener) {
- if (valueChangingListeners == null) {
- boolean hadListeners = hasListeners();
- valueChangingListeners = new ArrayList();
- valueChangingListeners.add(listener);
- if (!hadListeners) {
- firstListenerAdded();
- }
- } else {
- valueChangingListeners.add(listener);
- }
- }
-
- public void removeValueChangingListener(IValueChangingListener listener) {
- if (valueChangingListeners == null) {
- return;
- }
- valueChangingListeners.remove(listener);
- if (valueChangingListeners.isEmpty()) {
- valueChangingListeners = null;
- }
- if (!hasListeners()) {
- lastListenerRemoved();
- }
- }
-
- /**
- * Notifies listeners about a pending change, and returns true if no
- * listener vetoed the change.
- *
- * @param diff
- * @return false if the change was vetoed, true otherwise
- */
- protected boolean fireValueChanging(ValueDiff diff) {
- if (valueChangingListeners != null) {
- IValueChangingListener[] listeners = (IValueChangingListener[]) valueChangingListeners
- .toArray(new IValueChangingListener[valueChangingListeners
- .size()]);
- for (int i = 0; i < listeners.length; i++) {
- boolean okToProceed = listeners[i].handleValueChanging(this,
- diff);
- if (!okToProceed) {
- return false;
- }
- }
- }
- return true;
- }
-
- protected abstract void doSetValue(Object value);
-
- protected boolean hasListeners() {
- return super.hasListeners();
- }
-
- public void dispose() {
- super.dispose();
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/ChangeVetoException.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/ChangeVetoException.java
deleted file mode 100644
index a6192e7c..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/ChangeVetoException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.observable.value;
-
-/**
- * @since 1.0
- *
- */
-public class ChangeVetoException extends RuntimeException {
-
- /**
- * @param string
- */
- public ChangeVetoException(String string) {
- super(string);
- }
-
- private static final long serialVersionUID = 1L;
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/ComputedValue.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/ComputedValue.java
deleted file mode 100644
index 69bac8d5..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/ComputedValue.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.observable.value;
-
-import org.eclipse.jface.databinding.observable.IChangeListener;
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.databinding.observable.IStaleListener;
-import org.eclipse.jface.databinding.observable.ObservableTracker;
-
-/**
- * A Lazily calculated value that automatically computes and registers listeners
- * on its dependencies as long as all of its dependencies are IObservable
- * objects
- *
- * @since 1.0
- */
-public abstract class ComputedValue extends AbstractObservableValue {
-
- private boolean dirty = true;
-
- private boolean stale = false;
-
- private Object cachedValue = null;
-
- /**
- * Dependencies list. This is a collection that contains no duplicates. It
- * is normally an ArrayList to conserve memory, but if it ever grows above a
- * certain number of elements, a HashSet is substited to conserve runtime.
- */
- private IObservable[] dependencies = new IObservable[0];
-
- /**
- *
- */
- public ComputedValue() {
- this(Object.class);
- }
-
- /**
- * @param valueType
- */
- public ComputedValue(Object valueType) {
- this.valueType = valueType;
- }
-
- /**
- * Inner class that implements interfaces that we don't want to expose as
- * public API. Each interface could have been implemented using a separate
- * anonymous class, but we combine them here to reduce the memory overhead
- * and number of classes.
- *
- * <p>
- * The Runnable calls computeValue and stores the result in cachedValue.
- * </p>
- *
- * <p>
- * The IUpdatableListener stores each updatable in the dependencies list.
- * This is registered as the listener when calling ObservableTracker, to
- * detect every updatable that is used by computeValue.
- * </p>
- *
- * <p>
- * The IChangeListener is attached to every dependency.
- * </p>
- *
- */
- private class PrivateInterface implements Runnable, IChangeListener,
- IStaleListener {
- public void run() {
- cachedValue = calculate();
- }
-
- public void handleStale(IObservable source) {
- if (!dirty && !stale) {
- stale = true;
- fireStale();
- }
- }
-
- public void handleChange(IObservable source) {
- makeDirty();
- }
- }
-
- private PrivateInterface privateInterface = new PrivateInterface();
-
- private Object valueType;
-
- public final Object doGetValue() {
- if (dirty) {
- // This line will do the following:
- // - Run the computeValue method
- // - While doing so, add any updatable that is touched to the
- // dependencies list
- IObservable[] newDependencies = ObservableTracker.runAndMonitor(
- privateInterface, privateInterface, null);
-
- stale = false;
- for (int i = 0; i < newDependencies.length; i++) {
- IObservable observable = newDependencies[i];
- // Add a change listener to the new dependency.
- if (observable.isStale()) {
- stale = true;
- } else {
- observable.addStaleListener(privateInterface);
- }
- }
-
- dependencies = newDependencies;
-
- dirty = false;
- }
-
- return cachedValue;
- }
-
- /**
- * Subclasses must override this method to provide the object's value.
- *
- * @return the object's value
- */
- protected abstract Object calculate();
-
- protected final void makeDirty() {
- if (!dirty) {
- dirty = true;
-
- // Stop listening for dependency changes.
- for (int i = 0; i < dependencies.length; i++) {
- IObservable observable = dependencies[i];
-
- observable.removeChangeListener(privateInterface);
- observable.removeStaleListener(privateInterface);
- }
-
- // copy the old value
- final Object oldValue = cachedValue;
- // Fire the "dirty" event. This implementation recomputes the new
- // value lazily.
- fireValueChange(new ValueDiff() {
-
- public Object getOldValue() {
- return oldValue;
- }
-
- public Object getNewValue() {
- return getValue();
- }
- });
- }
- }
-
- public boolean isStale() {
- // we need to recompute, otherwise staleness wouldn't mean anything
- getValue();
- return stale;
- }
-
- public Object getValueType() {
- return valueType;
- }
-
- public void addChangeListener(IChangeListener listener) {
- super.addChangeListener(listener);
- // If somebody is listening, we need to make sure we attach our own
- // listeners
- getValue();
- }
-
- public void addValueChangeListener(IValueChangeListener listener) {
- super.addValueChangeListener(listener);
- // If somebody is listening, we need to make sure we attach our own
- // listeners
- getValue();
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/IObservableValue.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/IObservableValue.java
deleted file mode 100644
index da1644e3..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/IObservableValue.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable.value;
-
-import org.eclipse.jface.databinding.observable.IObservable;
-
-/**
- * A value whose changes can be tracked by value change listeners.
- *
- * <p>
- * This interface is not intended to be implemented by clients. Clients should
- * instead subclass one of the classes that implement this interface. Note that
- * direct implementers of this interface outside of the framework will be broken
- * in future releases when methods are added to this interface.
- * </p>
- *
- * @since 1.0
- *
- */
-public interface IObservableValue extends IObservable {
-
- /**
- * The value type of this observable value, or <code>null</code> if this
- * observable value is untyped.
- *
- * @return the value type, or <code>null</null>
- */
- public Object getValueType();
-
- /**
- * @return the current value
- * @TrackedGetter
- */
- public Object getValue();
-
- /**
- * @param value
- * the value to set
- * @throws UnsupportedOperationException
- * if this observable value cannot be set.
- */
- public void setValue(Object value);
-
- /**
- *
- * @param listener
- */
- public void addValueChangeListener(IValueChangeListener listener);
-
- /**
- * @param listener
- */
- public void removeValueChangeListener(IValueChangeListener listener);
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/IValueChangeListener.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/IValueChangeListener.java
deleted file mode 100644
index c199cd01..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/IValueChangeListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable.value;
-
-/**
- * @since 1.0
- *
- */
-public interface IValueChangeListener {
-
- /**
- * @param source
- * @param diff
- */
- void handleValueChange(IObservableValue source, ValueDiff diff);
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/IValueChangingListener.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/IValueChangingListener.java
deleted file mode 100644
index 8e5bebcd..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/IValueChangingListener.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.observable.value;
-
-/**
- * @since 1.0
- *
- */
-public interface IValueChangingListener {
-
- /**
- * This method is called when the value is about to change and provides an
- * opportunity to veto the change.
- *
- * @param source
- * @param diff
- * @return false if this listener is vetoing the change, true otherwise
- */
- public boolean handleValueChanging(IVetoableValue source, ValueDiff diff);
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/IVetoableValue.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/IVetoableValue.java
deleted file mode 100644
index 62b78fcf..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/IVetoableValue.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.observable.value;
-
-/**
- * An observable value whose changes can be vetoed by listeners.
- *
- * <p>
- * This interface is not intended to be implemented by clients. Clients should
- * instead subclass one of the classes that implement this interface. Note that
- * direct implementers of this interface outside of the framework will be broken
- * in future releases when methods are added to this interface.
- * </p>
- *
- * @since 1.0
- *
- */
-public interface IVetoableValue extends IObservableValue {
-
- /**
- * @param listener
- */
- public void addValueChangingListener(IValueChangingListener listener);
-
- /**
- * @param listener
- */
- public void removeValueChangingListener(IValueChangingListener listener);
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/ValueDiff.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/ValueDiff.java
deleted file mode 100644
index 3043b5a7..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/ValueDiff.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * 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.databinding.observable.value;
-
-import org.eclipse.jface.databinding.observable.Diffs;
-import org.eclipse.jface.databinding.observable.IDiff;
-
-/**
- * @since 1.0
- *
- */
-public abstract class ValueDiff implements IDiff {
- /**
- * Creates a value diff.
- */
- public ValueDiff() {
- }
-
- /**
- * @return the old value
- */
- public abstract Object getOldValue();
-
- /**
- * @return the new value
- */
- public abstract Object getNewValue();
-
- public boolean equals(Object obj) {
- if (obj instanceof ValueDiff) {
- ValueDiff val = (ValueDiff) obj;
-
- return Diffs.equals(val.getNewValue(), getNewValue())
- && Diffs.equals(val.getOldValue(), getOldValue());
-
- }
- return false;
- }
-
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- Object nv = getNewValue();
- Object ov = getOldValue();
- result = prime * result + ((nv == null) ? 0 : nv.hashCode());
- result = prime * result + ((ov == null) ? 0 : ov.hashCode());
- return result;
- }
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer
- .append(getClass().getName())
- .append("{oldValue [") //$NON-NLS-1$
- .append(getOldValue() != null ? getOldValue().toString() : "null") //$NON-NLS-1$
- .append("], newValue [") //$NON-NLS-1$
- .append(getNewValue() != null ? getNewValue().toString() : "null") //$NON-NLS-1$
- .append("]}"); //$NON-NLS-1$
-
- return buffer.toString();
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/WritableValue.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/WritableValue.java
deleted file mode 100644
index d1098913..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/observable/value/WritableValue.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * 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
- * Brad Reynolds - bug 158687
- ******************************************************************************/
-
-package org.eclipse.jface.databinding.observable.value;
-
-import org.eclipse.jface.databinding.observable.Diffs;
-
-/**
- * @since 1.0
- *
- */
-public class WritableValue extends AbstractObservableValue {
-
- private final Object valueType;
-
- /**
- * @param initialValue
- */
- public WritableValue(Object initialValue) {
- this(null, initialValue);
- }
-
- /**
- * @param type
- */
- public WritableValue(Class type) {
- this(type, null);
- }
-
- /**
- * @param valueType
- * @param initialValue
- */
- public WritableValue(Object valueType, Object initialValue) {
- this.valueType = valueType;
- this.value = initialValue;
- }
-
- private Object value = null;
-
- public Object doGetValue() {
- return value;
- }
-
- /**
- * @param value
- * The value to set.
- */
- public void setValue(Object value) {
- boolean changed = false;
-
- if (this.value == null && value != null) {
- changed = true;
- } else if (this.value != null && !this.value.equals(value)) {
- changed = true;
- }
-
- if (changed) {
- fireValueChange(Diffs.createValueDiff(this.value, this.value = value));
- }
- }
-
- public Object getValueType() {
- return valueType;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/util/ILogger.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/util/ILogger.java
deleted file mode 100644
index b30f275e..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/util/ILogger.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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:
- * Chris Gross (schtoo@schtoo.com) - initial API and implementation
- * (bug 49497 [RCP] JFace dependency on org.eclipse.core.runtime enlarges standalone JFace applications)
- *******************************************************************************/
-
-package org.eclipse.jface.databinding.util;
-
-import org.eclipse.core.runtime.IStatus;
-
-/**
- * A mechanism to log errors throughout JFace Data Binding.
- * <p>
- * Clients may provide their own implementation to change how errors are logged
- * from within JFace Data Binding.
- * </p>
- *
- * @see org.eclipse.jface.util.Policy#getLog()
- * @see org.eclipse.jface.util.Policy#setLog(ILogger)
- * @since 1.1
- */
-public interface ILogger {
-
- /**
- * Logs the given status.
- *
- * @param status
- * the status to log
- */
- public void log(IStatus status);
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/util/Policy.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/util/Policy.java
deleted file mode 100644
index 2e535679..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/util/Policy.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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
- * Chris Gross (schtoo@schtoo.com) - support for ILogger added
- * (bug 49497 [RCP] JFace dependency on org.eclipse.core.runtime enlarges standalone JFace applications)
- *******************************************************************************/
-package org.eclipse.jface.databinding.util;
-
-import org.eclipse.core.runtime.IStatus;
-
-/**
- * The Policy class handles settings for behaviour, debug flags and logging
- * within JFace Data Binding.
- *
- * @since 1.1
- */
-public class Policy {
-
- /**
- * Constant for the the default setting for debug options.
- */
- public static final boolean DEFAULT = false;
-
- /**
- * The unique identifier of the JFace plug-in.
- */
- public static final String JFACE_DATABINDING = "org.eclipse.jface.databinding";//$NON-NLS-1$
-
- private static ILogger log;
-
- /**
- * Returns the dummy log to use if none has been set
- */
- private static ILogger getDummyLog() {
- return new ILogger() {
- public void log(IStatus status) {
- System.err.println(status.getMessage());
- }
- };
- }
-
- /**
- * Sets the logger used by JFace Data Binding to log errors.
- *
- * @param logger
- * the logger to use, or <code>null</code> to use the default
- * logger
- */
- public static void setLog(ILogger logger) {
- log = logger;
- }
-
- /**
- * Returns the logger used by JFace Data Binding to log errors.
- * <p>
- * The default logger prints the status to <code>System.err</code>.
- * </p>
- *
- * @return the logger
- */
- public static ILogger getLog() {
- if (log == null) {
- log = getDummyLog();
- }
- return log;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/BindingMessages.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/BindingMessages.java
deleted file mode 100644
index a23e766f..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/BindingMessages.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.internal.databinding.internal;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * @since 1.0
- *
- */
-public class BindingMessages {
-
- /**
- * The Binding resource bundle; eagerly initialized.
- */
- private static final ResourceBundle bundle = ResourceBundle
- .getBundle("org.eclipse.jface.internal.databinding.internal.messages"); //$NON-NLS-1$
-
- /**
- * Returns the resource object with the given key in the resource bundle for
- * JFace Data Binding. If there isn't any value under the given key, the key
- * is returned.
- *
- * @param key
- * the resource name
- * @return the string
- */
- public static String getString(String key) {
- try {
- return bundle.getString(key);
- } catch (MissingResourceException e) {
- return key;
- }
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/ClassLookupSupport.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/ClassLookupSupport.java
deleted file mode 100644
index 35f0ce58..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/ClassLookupSupport.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.internal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @since 1.0
- *
- */
-public class ClassLookupSupport {
-
- /*
- * code copied from AdapterManager.java
- */
- private static HashMap classSearchOrderLookup;
-
- /**
- * For a given class or interface, return an array containing the given type and all its direct and indirect supertypes.
- * @param type
- * @return
- */
- public static Class[] getTypeHierarchyFlattened(Class type) {
- List classes = null;
- //cache reference to lookup to protect against concurrent flush
- HashMap lookup = classSearchOrderLookup;
- if (lookup != null)
- classes = (List) lookup.get(type);
- // compute class order only if it hasn't been cached before
- if (classes == null) {
- classes = new ArrayList();
- computeClassOrder(type, classes);
- if (lookup == null)
- classSearchOrderLookup = lookup = new HashMap();
- lookup.put(type, classes);
- }
- return (Class[]) classes.toArray(new Class[classes.size()]);
- }
-
- /**
- * Builds and returns a table of adapters for the given adaptable type.
- * The table is keyed by adapter class name. The
- * value is the <b>sole<b> factory that defines that adapter. Note that
- * if multiple adapters technically define the same property, only the
- * first found in the search order is considered.
- *
- * Note that it is important to maintain a consistent class and interface
- * lookup order. See the class comment for more details.
- */
- private static void computeClassOrder(Class adaptable, Collection classes) {
- Class clazz = adaptable;
- Set seen = new HashSet(4);
- while (clazz != null) {
- classes.add(clazz);
- computeInterfaceOrder(clazz.getInterfaces(), classes, seen);
- clazz = clazz.getSuperclass();
- }
- }
-
- private static void computeInterfaceOrder(Class[] interfaces, Collection classes, Set seen) {
- List newInterfaces = new ArrayList(interfaces.length);
- for (int i = 0; i < interfaces.length; i++) {
- Class interfac = interfaces[i];
- if (seen.add(interfac)) {
- //note we cannot recurse here without changing the resulting interface order
- classes.add(interfac);
- newInterfaces.add(interfac);
- }
- }
- for (Iterator it = newInterfaces.iterator(); it.hasNext();)
- computeInterfaceOrder(((Class) it.next()).getInterfaces(), classes, seen);
- }
-
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/IdentityWrapper.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/IdentityWrapper.java
deleted file mode 100644
index 28231b00..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/IdentityWrapper.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * 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
- * Daniel Kruegler - bug 137435
- ******************************************************************************/
-
-package org.eclipse.jface.internal.databinding.internal;
-
-/**
- * Used for wrapping objects that define their own implementations of equals()
- * and hashCode() when putting them in sets or hashmaps to ensure identity
- * comparison.
- *
- * @since 1.0
- *
- */
-public class IdentityWrapper {
- final Object o;
-
- /**
- * @param o
- */
- public IdentityWrapper(Object o) {
- this.o = o;
- }
-
- /**
- * @return the unwrapped object
- */
- public Object unwrap() {
- return o;
- }
-
- public boolean equals(Object obj) {
- if (obj == null || obj.getClass() != IdentityWrapper.class) {
- return false;
- }
- return o == ((IdentityWrapper) obj).o;
- }
-
- public int hashCode() {
- return System.identityHashCode(o);
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/LazyListBinding.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/LazyListBinding.java
deleted file mode 100644
index aa4ecc2d..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/LazyListBinding.java
+++ /dev/null
@@ -1,494 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jface.internal.databinding.internal;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jface.databinding.observable.IChangeListener;
-import org.eclipse.jface.databinding.observable.IStaleListener;
-import org.eclipse.jface.databinding.observable.list.IListChangeListener;
-import org.eclipse.jface.databinding.observable.list.IObservableList;
-import org.eclipse.jface.databinding.observable.list.ListDiff;
-import org.eclipse.jface.databinding.observable.list.ListDiffEntry;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.databinding.observable.value.WritableValue;
-import org.eclipse.jface.internal.databinding.provisional.BindSpec;
-import org.eclipse.jface.internal.databinding.provisional.Binding;
-import org.eclipse.jface.internal.databinding.provisional.BindingEvent;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor;
-import org.eclipse.jface.internal.databinding.provisional.observable.ILazyListElementProvider;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyDeleteEvent;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertDeleteProvider;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertEvent;
-import org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor.NewObject;
-import org.eclipse.jface.internal.databinding.provisional.validation.ValidationError;
-
-/**
- * A binding for pairs of things that operate in a lazy but synchronous manner.
- * This binding purely synchronizes two list-like things where the target side
- * operates in an event-driven manner and the model side operates in a random-
- * access manner.
- * <p>
- * Unlike other list bindings, this binding does <strong>not</strong> attempt
- * to notify observers when the contents of the individual elements inside the
- * lists change, but only when the lists themselves receive new elements or
- * have elements removed.
- */
-public class LazyListBinding extends Binding implements ILazyListElementProvider {
-
- private boolean updating = false;
-
- private final ILazyDataRequestor targetList;
- private ILazyListElementProvider modelList;
-
- private LazyInsertDeleteProvider lazyInsertDeleteProvider;
-
- private class DelegatingInsertDeleteProvider extends LazyInsertDeleteProvider {
- private LazyInsertDeleteProvider localLazyInsertDeleteProvider;
-
- /**
- * @param parent
- */
- public DelegatingInsertDeleteProvider(LazyInsertDeleteProvider parent) {
- this.localLazyInsertDeleteProvider = parent;
- }
-
- public NewObject insertElementAt(LazyInsertEvent insertEvent) {
- NewObject newObject;
- try {
- updating = true;
- BindingEvent e = new BindingEvent(modelList, targetList, null,
- org.eclipse.jface.databinding.BindingEvent.EVENT_LAZY_INSERT,
- org.eclipse.jface.databinding.BindingEvent.PIPELINE_AFTER_GET);
- e.originalValue = insertEvent;
- if (failure(errMsg(fireBindingEvent(e)))) {
- return null;
- }
-
- newObject = localLazyInsertDeleteProvider.insertElementAt(insertEvent);
-
- e.pipelinePosition = org.eclipse.jface.databinding.BindingEvent.PIPELINE_AFTER_CHANGE;
- failure(errMsg(fireBindingEvent(e)));
- } finally {
- updating = false;
- }
- if (newObject != null) {
- fetchNewIterator();
- }
- return newObject;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertDeleteProvider#canDeleteElementAt(org.eclipse.jface.internal.databinding.provisional.observable.LazyDeleteEvent)
- */
- public boolean canDeleteElementAt(LazyDeleteEvent e) {
- return localLazyInsertDeleteProvider.canDeleteElementAt(e);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertDeleteProvider#deleteElementAt(org.eclipse.jface.internal.databinding.provisional.observable.LazyDeleteEvent)
- */
- public void deleteElementAt(LazyDeleteEvent deleteEvent) {
- try {
- updating = true;
- BindingEvent e = new BindingEvent(modelList, targetList, null,
- org.eclipse.jface.databinding.BindingEvent.EVENT_LAZY_DELETE,
- org.eclipse.jface.databinding.BindingEvent.PIPELINE_AFTER_GET);
- e.originalValue = deleteEvent;
- failure(errMsg(fireBindingEvent(e)));
-
- localLazyInsertDeleteProvider.deleteElementAt(deleteEvent);
-
- e.pipelinePosition = org.eclipse.jface.databinding.BindingEvent.PIPELINE_AFTER_CHANGE;
- failure(errMsg(fireBindingEvent(e)));
- } finally {
- updating = false;
- }
- fetchNewIterator();
- }
- }
-
- /**
- * @param context
- * @param targetList
- * @param target
- * @param modelList
- * @param model
- * @param bindSpec
- */
- public LazyListBinding(DataBindingContext context, ILazyDataRequestor targetList,
- ILazyListElementProvider modelList, BindSpec bindSpec) {
- super(context);
- this.targetList = targetList;
- this.modelList = modelList;
- this.targetList.addElementProvider(this);
- lazyInsertDeleteProvider = new DelegatingInsertDeleteProvider(bindSpec.getLazyInsertDeleteProvider());
- this.targetList.addInsertDeleteProvider(lazyInsertDeleteProvider);
-
- // TODO validation/conversion as specified by the bindSpec
- modelList.addListChangeListener(modelChangeListener);
-
- fetchNewIterator();
- updateTargetFromModel();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.Binding#dispose()
- */
- public void dispose() {
- targetList.removeElementProvider(this);
- targetList.removeInsertDeleteProvider(lazyInsertDeleteProvider);
- modelList.removeListChangeListener(modelChangeListener);
- disposed=true;
- }
-
- private IListChangeListener modelChangeListener = new IListChangeListener() {
- public void handleListChange(IObservableList source, ListDiff diff) {
- if (updating) {
- return;
- }
- fetchNewIterator();
-
- // TODO validation
- BindingEvent e = new BindingEvent(modelList, targetList, diff,
- org.eclipse.jface.databinding.BindingEvent.EVENT_COPY_TO_TARGET,
- org.eclipse.jface.databinding.BindingEvent.PIPELINE_AFTER_GET);
- if (failure(errMsg(fireBindingEvent(e)))) {
- return;
- }
- updating = true;
- try {
- // get setDiff from event object - might have been modified by a
- // listener
- ListDiff listDiff = (ListDiff) e.diff;
- ListDiffEntry[] differences = listDiff.getDifferences();
-
- // FIXME: guessing that 20 is a good number for a good user experience for now.
- if (differences.length > 1) {
- targetList.setSize(modelList.size());
- } else {
- for (int i = 0; i < differences.length; i++) {
- ListDiffEntry entry = differences[0];
- if (entry.isAddition()) {
- targetList.add(entry.getPosition(), entry.getElement());
- } else {
- targetList.remove(entry.getPosition());
- }
- }
- }
- e.pipelinePosition = org.eclipse.jface.databinding.BindingEvent.PIPELINE_AFTER_CHANGE;
- if (failure(errMsg(fireBindingEvent(e)))) {
- return;
- }
- } finally {
- updating = false;
- }
- }
- };
-
-
- private WritableValue partialValidationErrorObservable = new WritableValue(
- null);
-
- private WritableValue validationErrorObservable = new WritableValue(null);
-
-
- private ValidationError errMsg(ValidationError validationError) {
- partialValidationErrorObservable.setValue(null);
- validationErrorObservable.setValue(validationError);
- return validationError;
- }
-
- private boolean failure(ValidationError errorMessage) {
- // FIXME: Need to fire a BindingEvent here
- if (errorMessage != null
- && errorMessage.status == ValidationError.ERROR) {
- return true;
- }
- return false;
- }
-
- public void updateTargetFromModel() {
- updating = true;
- try {
- int sizeToSetOnTarget = modelList.size();
-
- BindingEvent e = new BindingEvent(modelList, targetList, null,
- org.eclipse.jface.databinding.BindingEvent.EVENT_COPY_TO_TARGET,
- org.eclipse.jface.databinding.BindingEvent.PIPELINE_AFTER_GET);
- e.originalValue = new Integer(sizeToSetOnTarget);
- if (failure(errMsg(fireBindingEvent(e)))) {
- return;
- }
-
- targetList.setSize(sizeToSetOnTarget);
-
- e.pipelinePosition = org.eclipse.jface.databinding.BindingEvent.PIPELINE_AFTER_CHANGE;
- if (failure(errMsg(fireBindingEvent(e)))) {
- return;
- }
- } finally {
- updating = false;
- }
- }
-
- public IObservableValue getValidationError() {
- return validationErrorObservable;
- }
-
- public IObservableValue getPartialValidationError() {
- return partialValidationErrorObservable;
- }
-
- public void updateModelFromTarget() {
- throw new UnsupportedOperationException("Lazy targets don't support full copies"); //$NON-NLS-1$
- }
-
- private RandomAccessListIterator iterator = null;
-
- /**
- *
- */
- public void fetchNewIterator() {
- iterator = new RandomAccessListIterator(modelList);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyListElementProvider#get(int)
- */
- public Object get(int position) {
- Object result = iterator.get(position);
-
- BindingEvent e = new BindingEvent(modelList, targetList, null,
- org.eclipse.jface.databinding.BindingEvent.EVENT_COPY_TO_TARGET,
- org.eclipse.jface.databinding.BindingEvent.PIPELINE_AFTER_GET);
- e.originalValue = new Integer(position);
- e.convertedValue = result;
-
- failure(errMsg(fireBindingEvent(e)));
-
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#add(java.lang.Object)
- */
- public boolean add(Object o) {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#addAll(java.util.Collection)
- */
- public boolean addAll(Collection c) {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#addAll(int, java.util.Collection)
- */
- public boolean addAll(int index, Collection c) {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#addListChangeListener(org.eclipse.jface.databinding.observable.list.IListChangeListener)
- */
- public void addListChangeListener(IListChangeListener listener) {
- //noop
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#contains(java.lang.Object)
- */
- public boolean contains(Object o) {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#containsAll(java.util.Collection)
- */
- public boolean containsAll(Collection c) {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#getElementType()
- */
- public Object getElementType() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#indexOf(java.lang.Object)
- */
- public int indexOf(Object o) {
- return 0;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#isEmpty()
- */
- public boolean isEmpty() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#iterator()
- */
- public Iterator iterator() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#lastIndexOf(java.lang.Object)
- */
- public int lastIndexOf(Object o) {
- return 0;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#listIterator()
- */
- public ListIterator listIterator() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#listIterator(int)
- */
- public ListIterator listIterator(int index) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#remove(java.lang.Object)
- */
- public boolean remove(Object o) {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#remove(int)
- */
- public Object remove(int index) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#removeAll(java.util.Collection)
- */
- public boolean removeAll(Collection c) {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#removeListChangeListener(org.eclipse.jface.databinding.observable.list.IListChangeListener)
- */
- public void removeListChangeListener(IListChangeListener listener) {
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#retainAll(java.util.Collection)
- */
- public boolean retainAll(Collection c) {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#set(int, java.lang.Object)
- */
- public Object set(int index, Object element) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#size()
- */
- public int size() {
- return 0;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#subList(int, int)
- */
- public List subList(int fromIndex, int toIndex) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#toArray()
- */
- public Object[] toArray() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.observable.list.IObservableList#toArray(java.lang.Object[])
- */
- public Object[] toArray(Object[] a) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see java.util.List#add(int, java.lang.Object)
- */
- public void add(int arg0, Object arg1) {
- //noop
- }
-
- /* (non-Javadoc)
- * @see java.util.List#clear()
- */
- public void clear() {
- //noop
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.IObservable#addChangeListener(org.eclipse.jface.internal.databinding.provisional.observable.IChangeListener)
- */
- public void addChangeListener(IChangeListener listener) {
- //noop
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.IObservable#addStaleListener(org.eclipse.jface.internal.databinding.provisional.observable.IStaleListener)
- */
- public void addStaleListener(IStaleListener listener) {
- //noop
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.IObservable#isStale()
- */
- public boolean isStale() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.IObservable#removeChangeListener(org.eclipse.jface.internal.databinding.provisional.observable.IChangeListener)
- */
- public void removeChangeListener(IChangeListener listener) {
- //noop
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.IObservable#removeStaleListener(org.eclipse.jface.internal.databinding.provisional.observable.IStaleListener)
- */
- public void removeStaleListener(IStaleListener listener) {
- //noop
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/ListBinding.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/ListBinding.java
deleted file mode 100644
index 95b8b758..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/ListBinding.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.internal.databinding.internal;
-
-import org.eclipse.jface.databinding.BindSpec;
-import org.eclipse.jface.databinding.BindingEvent;
-import org.eclipse.jface.databinding.DataBindingContext;
-import org.eclipse.jface.databinding.observable.list.IListChangeListener;
-import org.eclipse.jface.databinding.observable.list.IObservableList;
-import org.eclipse.jface.databinding.observable.list.ListDiff;
-import org.eclipse.jface.databinding.observable.list.ListDiffEntry;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.databinding.observable.value.WritableValue;
-import org.eclipse.jface.internal.databinding.provisional.validation.ValidationError;
-
-/**
- *
- * implementation note: this class extends a deprecated class for backwards compatibility.
- */
-public class ListBinding extends org.eclipse.jface.internal.databinding.provisional.Binding {
-
- private boolean updating = false;
-
- private IObservableList modelList;
-
- private final IObservableList targetList;
-
- /**
- * @param context
- * @param targetList
- * @param target
- * @param modelList
- * @param model
- * @param bindSpec
- */
- public ListBinding(DataBindingContext context, IObservableList targetList,
- IObservableList modelList, BindSpec bindSpec) {
- super(context);
- this.targetList = targetList;
- this.modelList = modelList;
- // TODO validation/conversion as specified by the bindSpec
- targetList.addListChangeListener(targetChangeListener);
- modelList.addListChangeListener(modelChangeListener);
- updateTargetFromModel();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.Binding#dispose()
- */
- public void dispose() {
- targetList.removeListChangeListener(targetChangeListener);
- modelList.removeListChangeListener(modelChangeListener);
- super.dispose();
- }
-
- private final IListChangeListener targetChangeListener = new IListChangeListener() {
- public void handleListChange(IObservableList source, ListDiff diff) {
- if (updating) {
- return;
- }
- // TODO validation
- BindingEvent e = new BindingEvent(modelList, targetList, diff,
- BindingEvent.EVENT_COPY_TO_MODEL,
- BindingEvent.PIPELINE_AFTER_GET);
- if (failure(errMsg(fireBindingEvent(e)))) {
- return;
- }
- updating = true;
- try {
- // get setDiff from event object - might have been modified by a
- // listener
- ListDiff setDiff = (ListDiff) e.diff;
- ListDiffEntry[] differences = setDiff.getDifferences();
- for (int i = 0; i < differences.length; i++) {
- ListDiffEntry entry = differences[i];
- if (entry.isAddition()) {
- modelList.add(entry.getPosition(), entry.getElement());
- } else {
- modelList.remove(entry.getPosition());
- }
- }
- e.pipelinePosition = BindingEvent.PIPELINE_AFTER_CHANGE;
- if (failure(errMsg(fireBindingEvent(e)))) {
- return;
- }
- } finally {
- updating = false;
- }
- }
- };
-
- private IListChangeListener modelChangeListener = new IListChangeListener() {
- public void handleListChange(IObservableList source, ListDiff diff) {
- if (updating) {
- return;
- }
- // TODO validation
- BindingEvent e = new BindingEvent(modelList, targetList, diff,
- BindingEvent.EVENT_COPY_TO_TARGET,
- BindingEvent.PIPELINE_AFTER_GET);
- if (failure(errMsg(fireBindingEvent(e)))) {
- return;
- }
- updating = true;
- try {
- // get setDiff from event object - might have been modified by a
- // listener
- ListDiff setDiff = (ListDiff) e.diff;
- ListDiffEntry[] differences = setDiff.getDifferences();
- for (int i = 0; i < differences.length; i++) {
- ListDiffEntry entry = differences[i];
- if (entry.isAddition()) {
- targetList.add(entry.getPosition(), entry.getElement());
- } else {
- targetList.remove(entry.getPosition());
- }
- }
- e.pipelinePosition = BindingEvent.PIPELINE_AFTER_CHANGE;
- if (failure(errMsg(fireBindingEvent(e)))) {
- return;
- }
- } finally {
- updating = false;
- }
- }
- };
-
- private WritableValue partialValidationErrorObservable = new WritableValue(
- null);
-
- private WritableValue validationErrorObservable = new WritableValue(null);
-
- private ValidationError errMsg(ValidationError validationError) {
- partialValidationErrorObservable.setValue(null);
- validationErrorObservable.setValue(validationError);
- return validationError;
- }
-
- private boolean failure(ValidationError errorMessage) {
- // FIXME: Need to fire a BindingEvent here
- if (errorMessage != null
- && errorMessage.status == ValidationError.ERROR) {
- return true;
- }
- return false;
- }
-
- public void updateTargetFromModel() {
- updating = true;
- try {
- targetList.clear();
- targetList.addAll(modelList);
- } finally {
- updating = false;
- }
- }
-
- public IObservableValue getValidationError() {
- return validationErrorObservable;
- }
-
- public IObservableValue getPartialValidationError() {
- return partialValidationErrorObservable;
- }
-
- public void updateModelFromTarget() {
- updating = true;
- try {
- modelList.clear();
- modelList.addAll(targetList);
- } finally {
- updating = false;
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/Pair.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/Pair.java
deleted file mode 100644
index ba296db0..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/Pair.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.internal.databinding.internal;
-
-/**
- * Class Pair. Represents a mathematical pair of objects (a, b).
- * @since 1.0
- */
-public class Pair {
-
- /**
- * a in the pair (a, b)
- */
- public final Object a;
-
- /**
- * b in the pair (a, b)
- */
- public final Object b;
-
- /**
- * Construct a Pair(a, b)
- *
- * @param a a in the pair (a, b)
- * @param b b in the pair (a, b)
- */
- public Pair(Object a, Object b) {
- this.a = a;
- this.b = b;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- if (obj.getClass() != Pair.class) {
- return false;
- }
- Pair other = (Pair) obj;
- return a.equals(other.a) && b.equals(other.b);
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return a.hashCode() + b.hashCode();
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/RandomAccessListIterator.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/RandomAccessListIterator.java
deleted file mode 100644
index 147056f9..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/RandomAccessListIterator.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.internal.databinding.internal;
-
-import java.util.List;
-import java.util.ListIterator;
-
-/**
- * Class RandomAccessListIterator. A ListIterator implementation that also
- * provides access to individual elements based on the element's index.
- *
- * @since 3.3
- */
-public class RandomAccessListIterator implements ListIterator {
- private ListIterator delegate = null;
-
- /**
- * @param iterator
- */
- public RandomAccessListIterator(ListIterator iterator) {
- this.delegate = iterator;
- }
-
- /**
- * @param list
- */
- public RandomAccessListIterator(List list) {
- if (list == null) {
- throw new IllegalArgumentException("list is null"); //$NON-NLS-1$
- }
- this.delegate = list.listIterator();
- }
-
- /* (non-Javadoc)
- * @see java.util.ListIterator#add(java.lang.Object)
- */
- public void add(Object arg0) {
- delegate.add(arg0);
- }
-
- /* (non-Javadoc)
- * @see java.util.ListIterator#hasNext()
- */
- public boolean hasNext() {
- return delegate.hasNext();
- }
-
- /* (non-Javadoc)
- * @see java.util.ListIterator#hasPrevious()
- */
- public boolean hasPrevious() {
- return delegate.hasPrevious();
- }
-
- /* (non-Javadoc)
- * @see java.util.ListIterator#next()
- */
- public Object next() {
- return delegate.next();
- }
-
- /* (non-Javadoc)
- * @see java.util.ListIterator#nextIndex()
- */
- public int nextIndex() {
- return delegate.nextIndex();
- }
-
- /* (non-Javadoc)
- * @see java.util.ListIterator#previous()
- */
- public Object previous() {
- return delegate.previous();
- }
-
- /* (non-Javadoc)
- * @see java.util.ListIterator#previousIndex()
- */
- public int previousIndex() {
- return delegate.previousIndex();
- }
-
- /* (non-Javadoc)
- * @see java.util.ListIterator#remove()
- */
- public void remove() {
- delegate.remove();
- }
-
- /* (non-Javadoc)
- * @see java.util.ListIterator#set(java.lang.Object)
- */
- public void set(Object arg0) {
- delegate.set(arg0);
- }
-
- /**
- * Return the element at the specified position by moving the iterator
- * forward or backward in the list until it reaches the correct element.
- * The iterator's position after returning the element will be one after
- * the element returned.
- *
- * @param index The (0-based) index of the element to return.
- * @return the Object at index
- */
- public Object get(int index) {
- if (delegate.nextIndex() == 0 && !delegate.hasNext()) {
- throw new IndexOutOfBoundsException("Request for element from empty list"); //$NON-NLS-1$
- }
- if (index < 0) {
- throw new IndexOutOfBoundsException("Request for negative element index"); //$NON-NLS-1$
- }
-
- while (nextIndex() < index && hasNext()) {
- next();
- }
- while (previousIndex() > index-1) {
- previous();
- }
- if (!hasNext()) {
- throw new IndexOutOfBoundsException("Request for element past end of list"); //$NON-NLS-1$
- }
- return next();
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/ValidationErrorList.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/ValidationErrorList.java
deleted file mode 100644
index f28648f4..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/ValidationErrorList.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.internal;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.databinding.observable.Diffs;
-import org.eclipse.jface.databinding.observable.IChangeListener;
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.databinding.observable.list.ListDiff;
-import org.eclipse.jface.databinding.observable.list.ListDiffEntry;
-import org.eclipse.jface.databinding.observable.list.ObservableList;
-import org.eclipse.jface.databinding.observable.list.WritableList;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.internal.databinding.provisional.Binding;
-import org.eclipse.jface.internal.databinding.provisional.observable.ILazyListElementProvider;
-import org.eclipse.jface.internal.databinding.provisional.validation.ValidationError;
-
-/**
- * @since 1.0
- *
- */
-public class ValidationErrorList extends ObservableList implements ILazyListElementProvider {
-
- private boolean isDirty = true;
-
- private final WritableList bindings;
-
- private final boolean usePartialErrors;
-
- private List dependencies = new ArrayList();
-
- private IChangeListener markDirtyChangeListener = new IChangeListener() {
- public void handleChange(IObservable source) {
- markDirty();
- }
- };
-
- /**
- * @param bindings
- * @param usePartialErrors
- */
- public ValidationErrorList(WritableList bindings,
- boolean usePartialErrors) {
- super(new ArrayList(), ValidationError.class);
- this.bindings = bindings;
- this.usePartialErrors = usePartialErrors;
- bindings.addChangeListener(markDirtyChangeListener);
- }
-
- protected void getterCalled() {
- recompute();
- super.getterCalled();
- }
-
- private void markDirty() {
- // since we are dirty, we don't need to listen anymore
- removeElementChangeListener();
- final List oldList = wrappedList;
- // lazy computation of diff
- ListDiff listDiff = new ListDiff() {
- ListDiffEntry[] cachedDifferences = null;
- public ListDiffEntry[] getDifferences() {
- if(cachedDifferences==null) {
- recompute();
- cachedDifferences = Diffs.computeListDiff(oldList, wrappedList).getDifferences();
- }
- return cachedDifferences;
- }
- };
- wrappedList = new ArrayList();
- isDirty = true;
- fireListChange(listDiff);
- }
-
- private void recompute() {
- if (isDirty) {
- List newContents = new ArrayList();
- for (Iterator it = bindings.iterator(); it.hasNext();) {
- Binding binding = (Binding) it.next();
- IObservableValue validationError = usePartialErrors ? binding
- .getPartialValidationError() : binding
- .getValidationError();
- dependencies.add(validationError);
- validationError.addChangeListener(markDirtyChangeListener);
- Object validationErrorValue = validationError.getValue();
- if (validationErrorValue != null) {
- newContents.add(validationErrorValue);
- }
- }
- wrappedList.addAll(newContents);
- isDirty = false;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.databinding.observable.list.ObservableList#dispose()
- */
- public void dispose() {
- bindings.removeChangeListener(markDirtyChangeListener);
- removeElementChangeListener();
- super.dispose();
- }
-
- private void removeElementChangeListener() {
- for (Iterator it = dependencies.iterator(); it.hasNext();) {
- IObservableValue observableValue = (IObservableValue) it.next();
- observableValue.removeChangeListener(markDirtyChangeListener);
- }
- }
-
- public Object getElementType() {
- return ValidationError.class;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/ValueBinding.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/ValueBinding.java
deleted file mode 100644
index 7b4ad5ee..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/ValueBinding.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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
- * Brad Reynolds - bug 152543
- *******************************************************************************/
-package org.eclipse.jface.internal.databinding.internal;
-
-import org.eclipse.jface.databinding.BindSpec;
-import org.eclipse.jface.databinding.BindingEvent;
-import org.eclipse.jface.databinding.BindingException;
-import org.eclipse.jface.databinding.DataBindingContext;
-import org.eclipse.jface.databinding.observable.Diffs;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.databinding.observable.value.IValueChangeListener;
-import org.eclipse.jface.databinding.observable.value.IValueChangingListener;
-import org.eclipse.jface.databinding.observable.value.IVetoableValue;
-import org.eclipse.jface.databinding.observable.value.ValueDiff;
-import org.eclipse.jface.databinding.observable.value.WritableValue;
-import org.eclipse.jface.internal.databinding.provisional.conversion.IConverter;
-import org.eclipse.jface.internal.databinding.provisional.validation.IDomainValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.IValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.ValidationError;
-
-/**
- * @since 1.0
- *
- * implementation note: this class extends a deprecated class for backwards compatibility
- */
-public class ValueBinding extends org.eclipse.jface.internal.databinding.provisional.Binding {
-
- private final IObservableValue target;
-
- private final IObservableValue model;
-
- private IValidator targetValidator;
-
- private IConverter targetToModelConverter;
-
- private IConverter modelToTargetConverter;
-
- private IDomainValidator domainValidator;
-
- private boolean updating = false;
-
- private WritableValue partialValidationErrorObservable = new WritableValue(
- ValidationError.class, null);
-
- private WritableValue validationErrorObservable = new WritableValue(
- ValidationError.class, null);
-
- /**
- * @param context
- * @param target
- * @param model
- * @param bindSpec
- */
- public ValueBinding(DataBindingContext context, IObservableValue target,
- IObservableValue model, BindSpec bindSpec) {
- super(context);
- this.target = target;
- this.model = model;
- if (bindSpec.isUpdateTarget()) {
- modelToTargetConverter = bindSpec.getModelToTargetConverter();
- if (modelToTargetConverter == null) {
- throw new BindingException(
- "Missing model to target converter from " + model.getValueType() + " to " + target.getValueType()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (!context.isAssignableFromTo(model.getValueType(),
- modelToTargetConverter.getFromType())) {
- throw new BindingException(
- "model to target converter does not convert from model type. Expected: " + model.getValueType() + ", actual: " + modelToTargetConverter.getFromType()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (!context.isAssignableFromTo(modelToTargetConverter.getToType(),
- target.getValueType())) {
- throw new BindingException(
- "model to target converter does convert to target type. Expected: " + target.getValueType() + ", actual: " + modelToTargetConverter.getToType()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- model.addValueChangeListener(modelChangeListener);
- }
- if (bindSpec.isUpdateModel()) {
- targetToModelConverter = bindSpec.getTargetToModelConverter();
- if (targetToModelConverter == null) {
- throw new BindingException(
- "Missing target to model converter from " + target.getValueType() + " to " + model.getValueType()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (!context.isAssignableFromTo(target.getValueType(),
- targetToModelConverter.getFromType())) {
- throw new BindingException(
- "target to model converter does not convert from target type. Expected: " + target.getValueType() + ", actual: " + targetToModelConverter.getFromType()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (!context.isAssignableFromTo(targetToModelConverter.getToType(),
- model.getValueType())) {
- throw new BindingException(
- "target to model converter does convert to model type. Expected: " + model.getValueType() + ", actual: " + targetToModelConverter.getToType()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- targetValidator = bindSpec.getTypeConversionValidator();
- if (targetValidator == null) {
- throw new BindingException("Missing validator"); //$NON-NLS-1$
- }
- domainValidator = bindSpec.getDomainValidator();
- target.addValueChangeListener(targetChangeListener);
- if (target instanceof IVetoableValue) {
- ((IVetoableValue) target)
- .addValueChangingListener(targetChangingListener);
- }
- }
- if (bindSpec.isUpdateTarget()) {
- updateTargetFromModel();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.Binding#dispose()
- */
- public void dispose() {
- target.removeValueChangeListener(targetChangeListener);
- if (target instanceof IVetoableValue) {
- ((IVetoableValue) target)
- .removeValueChangingListener(targetChangingListener);
- }
- model.removeValueChangeListener(modelChangeListener);
- super.dispose();
- }
-
- private final IValueChangingListener targetChangingListener = new IValueChangingListener() {
- public boolean handleValueChanging(IVetoableValue source, ValueDiff diff) {
- if (updating)
- return true;
- // we are notified of a pending change, do validation
- // and veto the change if it is not valid
- Object value = diff.getNewValue();
- ValidationError partialValidationError = targetValidator
- .isPartiallyValid(value);
- partialValidationErrorObservable.setValue(partialValidationError);
- return partialValidationError == null;
- }
- };
-
- private final IValueChangeListener targetChangeListener = new IValueChangeListener() {
- public void handleValueChange(IObservableValue source, ValueDiff diff) {
- if (updating)
- return;
- // the target (usually a widget) has changed, validate
- // the value and update the source
- updateModelFromTarget(diff);
- }
- };
-
- private IValueChangeListener modelChangeListener = new IValueChangeListener() {
- public void handleValueChange(IObservableValue source, ValueDiff diff) {
- if (updating)
- return;
- // The model has changed so we must update the target
- doUpdateTargetFromModel(diff);
- }
- };
-
- /**
- * This also does validation.
- *
- * @param diff
- *
- * @param changeEvent
- * TODO
- */
- public void updateModelFromTarget(ValueDiff diff) {
- BindingEvent e = new BindingEvent(model, target, diff,
- BindingEvent.EVENT_COPY_TO_MODEL,
- BindingEvent.PIPELINE_AFTER_GET) {
- };
- e.originalValue = target.getValue();
- if (failure(errMsg(fireBindingEvent(e)))) {
- return;
- }
-
- ValidationError validationError = doValidate(e.originalValue);
- if (validationError != null) {
- return;
- }
- e.pipelinePosition = BindingEvent.PIPELINE_AFTER_VALIDATE;
- if (failure(errMsg(fireBindingEvent(e)))) {
- return;
- }
-
- try {
- updating = true;
-
- e.convertedValue = targetToModelConverter.convert(e.originalValue);
- e.pipelinePosition = BindingEvent.PIPELINE_AFTER_CONVERT;
- if (failure(errMsg(fireBindingEvent(e)))) {
- return;
- }
-
- validationError = doDomainValidation(e.convertedValue);
- if (validationError != null) {
- return;
- }
- e.pipelinePosition = BindingEvent.PIPELINE_AFTER_BUSINESS_VALIDATE;
- if (failure(errMsg(fireBindingEvent(e)))) {
- return;
- }
-
- model.setValue(e.convertedValue);
- e.pipelinePosition = BindingEvent.PIPELINE_AFTER_CHANGE;
- fireBindingEvent(e);
- } catch (Exception ex) {
- ValidationError error = ValidationError.error(
- BindingMessages.getString("ValueBinding_ErrorWhileSettingValue"), //$NON-NLS-1$
- ex);
- validationErrorObservable.setValue(error);
- } finally {
- updating = false;
- }
- }
-
- /**
- * @param convertedValue
- * @return String
- */
- private ValidationError doDomainValidation(Object convertedValue) {
- if (domainValidator == null) {
- return null;
- }
- ValidationError validationError = domainValidator
- .isValid(convertedValue);
- return errMsg(validationError);
- }
-
- private ValidationError doValidate(Object value) {
- if (targetValidator == null)
- return null;
- ValidationError validationError = targetValidator.isValid(value);
- return errMsg(validationError);
- }
-
- private ValidationError errMsg(ValidationError validationError) {
- partialValidationErrorObservable.setValue(null);
- validationErrorObservable.setValue(validationError);
- return validationError;
- }
-
- private boolean failure(ValidationError errorMessage) {
- // FIXME: Need to fire a BindingEvent here
- if (errorMessage != null
- && errorMessage.status == ValidationError.ERROR) {
- return true;
- }
- return false;
- }
-
- public void updateTargetFromModel() {
- doUpdateTargetFromModel(Diffs.createValueDiff(null, model.getValue()));
- }
-
- /**
- * @param diff
- */
- public void doUpdateTargetFromModel(ValueDiff diff) {
- try {
- updating = true;
- BindingEvent e = new BindingEvent(model, target, diff,
- BindingEvent.EVENT_COPY_TO_TARGET,
- BindingEvent.PIPELINE_AFTER_GET) {
- };
- e.originalValue = model.getValue();
- if (failure(errMsg(fireBindingEvent(e)))) {
- return;
- }
-
- e.convertedValue = modelToTargetConverter.convert(e.originalValue);
- e.pipelinePosition = BindingEvent.PIPELINE_AFTER_CONVERT;
- if (failure(errMsg(fireBindingEvent(e)))) {
- return;
- }
-
- target.setValue(e.convertedValue);
- e.pipelinePosition = BindingEvent.PIPELINE_AFTER_CHANGE;
- if (failure(errMsg(fireBindingEvent(e)))) {
- return;
- }
-
- //FIXME ValueBinding Needs Separate modelValidator to perform model to target validation.
- doValidate(target.getValue());
- e.pipelinePosition = BindingEvent.PIPELINE_AFTER_VALIDATE;
- fireBindingEvent(e);
- } catch (Exception ex) {
- ValidationError error = ValidationError.error(
- BindingMessages.getString("ValueBinding_ErrorWhileSettingValue"), //$NON-NLS-1$
- ex);
- validationErrorObservable.setValue(error);
- } finally {
- updating = false;
- }
- }
-
- public IObservableValue getValidationError() {
- return validationErrorObservable;
- }
-
- public IObservableValue getPartialValidationError() {
- return partialValidationErrorObservable;
- }
-
- public void updateModelFromTarget() {
- updateModelFromTarget(Diffs.createValueDiff(target.getValue(), target
- .getValue()));
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/messages.properties b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/messages.properties
deleted file mode 100644
index 4fb25f46..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/messages.properties
+++ /dev/null
@@ -1,37 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 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
-###############################################################################
-# NLS file for JFace Data Binding
-###############################################################################
-Yes=Yes
-yes=yes
-No=No
-no=no
-True=True
-true=true
-False=False
-false=false
-and=and
-or=or
-Examples=Examples
-ValueBinding_ErrorWhileSettingValue=An error occurred while setting the value.
-Validate_BooleanHelp=Please type "Yes", "No", "True", or "False"
-Validate_ConversionToPrimitive="Null object values can not be converted to primatives."
-Validate_ConversionFromClassToPrimitive="Wrong object type to convert to primative."
-Validate_CharacterHelp=Please type a character
-Validate_NoChangeAllowedHelp=Changes are not allowed in this field
-Validate_RangeStart=Please enter a number between
-Validate_Like=Please enter a number like
-Validate_Number_Examples= 1.234, 256E-15, 42
-
-# The following two regular expressions express any of: Yes, yes, No, no, True, true, False, false
-# in both partially valid and fully valid forms.
-Validate_BooleanPartialValidRegex=^$|^Y$|^y$|^Ye$|^ye$|^Yes$|^yes$|^T$|^t$|^Tr$|^tr$|^Tru$|^tru$|^True$|^true$|^N$|^n$|^No$|^no$|^F$|^f$|^Fa$|^fa$|^Fal$|^fal$|^Fals$|^fals$|^False$|^false$
-Validate_BooleanValidRegex=^Yes$|^yes$|^No$|^no$|^True$|^true$|^False$|^false$
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/IStalenessConsumer.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/IStalenessConsumer.java
deleted file mode 100644
index 217352c4..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/IStalenessConsumer.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.internal.observable;
-
-/**
- * @since 1.0
- *
- */
-public interface IStalenessConsumer {
- /**
- * @param stale
- *
- */
- public void setStale(boolean stale);
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/NestedObservableList.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/NestedObservableList.java
deleted file mode 100644
index 3fa1b9c8..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/NestedObservableList.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.internal.databinding.internal.observable;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.databinding.observable.Diffs;
-import org.eclipse.jface.databinding.observable.list.IListChangeListener;
-import org.eclipse.jface.databinding.observable.list.IObservableList;
-import org.eclipse.jface.databinding.observable.list.ListDiff;
-import org.eclipse.jface.databinding.observable.list.ObservableList;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.databinding.observable.value.IValueChangeListener;
-import org.eclipse.jface.databinding.observable.value.ValueDiff;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.observable.ILazyListElementProvider;
-
-/**
- * @since 3.2
- *
- */
-public class NestedObservableList extends ObservableList implements ILazyListElementProvider {
-
- private boolean updating = false;
-
- private IListChangeListener innerChangeListener = new IListChangeListener() {
- public void handleListChange(IObservableList source, ListDiff diff) {
- if (!updating) {
- fireListChange(diff);
- }
- }
- };
-
- private Object currentOuterValue;
-
- private Object feature;
-
- private IObservableList innerObservableList;
-
- private DataBindingContext databindingContext;
-
- private IObservableValue outerObservableValue;
-
- /**
- * @param databindingContext
- * @param outerObservableValue
- * @param feature
- * @param featureType
- */
- public NestedObservableList(DataBindingContext databindingContext,
- IObservableValue outerObservableValue, Object feature,
- Class featureType) {
- super(new ArrayList(), featureType);
- this.databindingContext = databindingContext;
- this.feature = feature;
- this.outerObservableValue = outerObservableValue;
- updateInnerObservableValue(outerObservableValue);
-
- outerObservableValue.addValueChangeListener(outerChangeListener);
- }
-
- IValueChangeListener outerChangeListener = new IValueChangeListener() {
- public void handleValueChange(IObservableValue source, ValueDiff diff) {
- List oldList = new ArrayList(wrappedList);
- updateInnerObservableValue(outerObservableValue);
- fireListChange(Diffs.computeListDiff(oldList, wrappedList));
- }
- };
-
- private void updateInnerObservableValue(
- IObservableValue outerObservableValue) {
- currentOuterValue = outerObservableValue.getValue();
- if (innerObservableList != null) {
- innerObservableList.removeListChangeListener(innerChangeListener);
- innerObservableList.dispose();
- }
- if (currentOuterValue == null) {
- innerObservableList = null;
- wrappedList = new ArrayList();
- } else {
- this.innerObservableList = (IObservableList) databindingContext
- .createObservable(new Property(currentOuterValue, feature,
- (Class) getElementType(), Boolean.TRUE));
- wrappedList = innerObservableList;
- Object innerValueType = innerObservableList.getElementType();
- Assert.isTrue(getElementType().equals(innerValueType),
- "Cannot change value type in a nested updatable value"); //$NON-NLS-1$
- innerObservableList.addListChangeListener(innerChangeListener);
- }
- }
-
- public void dispose() {
- super.dispose();
-
- if (outerObservableValue != null) {
- outerObservableValue.removeValueChangeListener(outerChangeListener);
- outerObservableValue.dispose();
- }
- if (innerObservableList != null) {
- innerObservableList.removeListChangeListener(innerChangeListener);
- innerObservableList.dispose();
- }
- currentOuterValue = null;
- databindingContext = null;
- feature = null;
- innerObservableList = null;
- innerChangeListener = null;
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/NestedObservableSet.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/NestedObservableSet.java
deleted file mode 100644
index bb15144c..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/NestedObservableSet.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.internal.databinding.internal.observable;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.databinding.observable.Diffs;
-import org.eclipse.jface.databinding.observable.set.IObservableSet;
-import org.eclipse.jface.databinding.observable.set.ISetChangeListener;
-import org.eclipse.jface.databinding.observable.set.ObservableSet;
-import org.eclipse.jface.databinding.observable.set.SetDiff;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.databinding.observable.value.IValueChangeListener;
-import org.eclipse.jface.databinding.observable.value.ValueDiff;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-
-/**
- * @since 3.2
- *
- */
-public class NestedObservableSet extends ObservableSet {
-
- private boolean updating = false;
-
- private ISetChangeListener innerChangeListener = new ISetChangeListener() {
- public void handleSetChange(IObservableSet source, SetDiff diff) {
- if (!updating) {
- fireSetChange(diff);
- }
- }
- };
-
- private Object currentOuterValue;
-
- private Object feature;
-
- private IObservableSet innerObservableSet;
-
- private DataBindingContext databindingContext;
-
- private IObservableValue outerObservableValue;
-
- /**
- * @param databindingContext
- * @param outerObservableValue
- * @param feature
- * @param featureType
- */
- public NestedObservableSet(DataBindingContext databindingContext,
- IObservableValue outerObservableValue, Object feature,
- Object featureType) {
- super(new HashSet(), featureType);
- this.databindingContext = databindingContext;
- this.feature = feature;
- this.outerObservableValue = outerObservableValue;
- updateInnerObservableValue(outerObservableValue);
-
- outerObservableValue.addValueChangeListener(outerChangeListener);
- }
-
- IValueChangeListener outerChangeListener = new IValueChangeListener() {
- public void handleValueChange(IObservableValue source, ValueDiff diff) {
- Set oldSet = new HashSet(wrappedSet);
- updateInnerObservableValue(outerObservableValue);
- fireSetChange(Diffs.computeSetDiff(oldSet, wrappedSet));
- }
- };
-
- private void updateInnerObservableValue(
- IObservableValue outerObservableValue) {
- currentOuterValue = outerObservableValue.getValue();
- if (innerObservableSet != null) {
- innerObservableSet.removeSetChangeListener(innerChangeListener);
- innerObservableSet.dispose();
- }
- if (currentOuterValue == null) {
- innerObservableSet = null;
- wrappedSet = new HashSet();
- } else {
- this.innerObservableSet = (IObservableSet) databindingContext
- .createObservable(new Property(currentOuterValue, feature));
- wrappedSet = innerObservableSet;
- Object innerValueType = innerObservableSet.getElementType();
- if (elementType == null) {
- elementType = innerValueType;
- } else {
- Assert.isTrue(elementType.equals(innerValueType),
- "Cannot change value type in a nested updatable value"); //$NON-NLS-1$
- }
- innerObservableSet.addSetChangeListener(innerChangeListener);
- }
- }
-
- public void dispose() {
- super.dispose();
-
- if (outerObservableValue != null) {
- outerObservableValue.removeValueChangeListener(outerChangeListener);
- outerObservableValue.dispose();
- }
- if (innerObservableSet != null) {
- innerObservableSet.removeSetChangeListener(innerChangeListener);
- innerObservableSet.dispose();
- }
- currentOuterValue = null;
- databindingContext = null;
- feature = null;
- innerObservableSet = null;
- innerChangeListener = null;
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/NestedObservableValue.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/NestedObservableValue.java
deleted file mode 100644
index c7c6b5d0..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/NestedObservableValue.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.internal.databinding.internal.observable;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.databinding.observable.Diffs;
-import org.eclipse.jface.databinding.observable.value.AbstractObservableValue;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.databinding.observable.value.IValueChangeListener;
-import org.eclipse.jface.databinding.observable.value.ValueDiff;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-
-/**
- * @since 1.0
- *
- */
-public class NestedObservableValue extends AbstractObservableValue {
-
- private boolean updating = false;
-
- private IValueChangeListener innerChangeListener = new IValueChangeListener() {
- public void handleValueChange(IObservableValue source, ValueDiff diff) {
- if (!updating) {
- fireValueChange(diff);
- }
- }
- };
-
- private Object currentOuterValue;
-
- private Object feature;
-
- private IObservableValue innerObservableValue;
-
- private DataBindingContext databindingContext;
-
- private Object featureType;
-
- private IObservableValue outerObservableValue;
-
- /**
- * @param databindingContext
- * @param outerObservableValue
- * @param feature
- * @param featureType
- */
- public NestedObservableValue(DataBindingContext databindingContext,
- IObservableValue outerObservableValue, Object feature,
- Class featureType) {
- this.databindingContext = databindingContext;
- this.feature = feature;
- this.featureType = featureType;
- this.outerObservableValue = outerObservableValue;
- updateInnerObservableValue(outerObservableValue);
-
- outerObservableValue.addValueChangeListener(outerChangeListener);
- }
-
- IValueChangeListener outerChangeListener = new IValueChangeListener() {
- public void handleValueChange(IObservableValue source, ValueDiff diff) {
- Object oldValue = doGetValue();
- updateInnerObservableValue(outerObservableValue);
- fireValueChange(Diffs.createValueDiff(oldValue, doGetValue()));
- }
- };
-
- private void updateInnerObservableValue(
- IObservableValue outerObservableValue) {
- currentOuterValue = outerObservableValue.getValue();
- if (innerObservableValue != null) {
- innerObservableValue.removeValueChangeListener(innerChangeListener);
- innerObservableValue.dispose();
- }
- if (currentOuterValue == null) {
- innerObservableValue = null;
- } else {
- this.innerObservableValue = (IObservableValue) databindingContext
- .createObservable(new Property(currentOuterValue, feature));
- Object innerValueType = innerObservableValue.getValueType();
- if (featureType == null) {
- featureType = innerValueType;
- } else {
- Assert
- .isTrue(featureType.equals(innerValueType),
- "Cannot change value type in a nested observable value"); //$NON-NLS-1$
- }
- innerObservableValue.addValueChangeListener(innerChangeListener);
- }
- }
-
- public void setValue(Object value) {
- if (innerObservableValue != null)
- innerObservableValue.setValue(value);
- }
-
- public Object doGetValue() {
- return innerObservableValue == null ? null : innerObservableValue
- .getValue();
- }
-
- public Object getValueType() {
- return featureType;
- }
-
- public void dispose() {
- super.dispose();
-
- if (outerObservableValue != null) {
- outerObservableValue.removeValueChangeListener(outerChangeListener);
- outerObservableValue.dispose();
- }
- if (innerObservableValue != null) {
- innerObservableValue.removeValueChangeListener(innerChangeListener);
- innerObservableValue.dispose();
- }
- currentOuterValue = null;
- databindingContext = null;
- feature = null;
- innerObservableValue = null;
- innerChangeListener = null;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/ProxyObservableSet.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/ProxyObservableSet.java
deleted file mode 100644
index ad29cee0..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/ProxyObservableSet.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.internal.observable;
-
-import java.util.Set;
-
-import org.eclipse.jface.databinding.observable.set.AbstractObservableSet;
-import org.eclipse.jface.databinding.observable.set.IObservableSet;
-import org.eclipse.jface.databinding.observable.set.ISetChangeListener;
-import org.eclipse.jface.databinding.observable.set.SetDiff;
-
-/**
- * Wraps an observable set. This object acts like an exact copy of the original
- * set, and tracks all the changes in the original. The only difference is that
- * disposing the wrapper will not dispose the original. You can use this whenever
- * you need to return an IObservableSet from a method that expects the caller
- * to dispose the set, but you have an IObservableSet that you don't want disposed.
- */
-public final class ProxyObservableSet extends AbstractObservableSet {
-
- private IObservableSet toDelegateTo;
- private ISetChangeListener listener = new ISetChangeListener() {
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.set.ISetChangeListener#handleSetChange(org.eclipse.jface.internal.databinding.provisional.observable.set.IObservableSet, org.eclipse.jface.internal.databinding.provisional.observable.set.SetDiff)
- */
- public void handleSetChange(IObservableSet source, SetDiff diff) {
- fireSetChange(diff);
- }
- };
-
- /**
- * Constructs a DelegatingObservableSet that tracks the state of the given set.
- *
- * @param toDelegate
- */
- public ProxyObservableSet(IObservableSet toDelegate) {
- this.toDelegateTo = toDelegate;
- toDelegate.addSetChangeListener(listener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.set.AbstractObservableSet#getWrappedSet()
- */
- protected Set getWrappedSet() {
- return toDelegateTo;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.set.IObservableSet#getElementType()
- */
- public Object getElementType() {
- return toDelegateTo.getElementType();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.set.AbstractObservableSet#dispose()
- */
- public void dispose() {
- toDelegateTo.removeSetChangeListener(listener);
- super.dispose();
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/StalenessTracker.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/StalenessTracker.java
deleted file mode 100644
index 68a0b483..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/StalenessTracker.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.internal.observable;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jface.databinding.observable.IChangeListener;
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.databinding.observable.IStaleListener;
-import org.eclipse.jface.internal.databinding.internal.IdentityWrapper;
-
-/**
- * @since 1.0
- *
- */
-public class StalenessTracker {
-
- private Map staleMap = new HashMap();
-
- private int staleCount = 0;
-
- private final IStalenessConsumer stalenessConsumer;
-
- private class ChildListener implements IStaleListener, IChangeListener {
- public void handleStale(IObservable source) {
- processStalenessChange(source, true);
- }
-
- public void handleChange(IObservable source) {
- processStalenessChange(source, true);
- }
- }
-
- private ChildListener childListener = new ChildListener();
-
- /**
- * @param observables
- * @param stalenessConsumer
- */
- public StalenessTracker(IObservable[] observables,
- IStalenessConsumer stalenessConsumer) {
- this.stalenessConsumer = stalenessConsumer;
- for (int i = 0; i < observables.length; i++) {
- IObservable observable = observables[i];
- doAddObservable(observable, false);
- }
- stalenessConsumer.setStale(staleCount > 0);
- }
-
- /**
- * @param child
- * @param callback
- */
- public void processStalenessChange(IObservable child, boolean callback) {
- boolean oldStale = staleCount > 0;
- IdentityWrapper wrappedChild = new IdentityWrapper(child);
- boolean oldChildStale = getOldChildStale(wrappedChild);
- boolean newChildStale = child.isStale();
- if (oldChildStale != newChildStale) {
- if (oldChildStale) {
- staleCount--;
- } else {
- staleCount++;
- }
- staleMap.put(wrappedChild, newChildStale ? Boolean.TRUE : Boolean.FALSE);
- }
- boolean newStale = staleCount > 0;
- if (callback && (newStale != oldStale)) {
- stalenessConsumer.setStale(newStale);
- }
- }
-
- /**
- * @param wrappedChild
- */
- private boolean getOldChildStale(IdentityWrapper wrappedChild) {
- Object oldChildValue = staleMap.get(wrappedChild);
- boolean oldChildStale = oldChildValue == null ? false
- : ((Boolean) oldChildValue).booleanValue();
- return oldChildStale;
- }
-
- /**
- * @param observable
- */
- public void addObservable(IObservable observable) {
- doAddObservable(observable, true);
- }
-
- private void doAddObservable(IObservable observable, boolean callback) {
- processStalenessChange(observable, callback);
- observable.addChangeListener(childListener);
- observable.addStaleListener(childListener);
- }
-
- /**
- * @param observable
- */
- public void removeObservable(IObservable observable) {
- boolean oldStale = staleCount > 0;
- IdentityWrapper wrappedChild = new IdentityWrapper(observable);
- boolean oldChildStale = getOldChildStale(wrappedChild);
- if (oldChildStale) {
- staleCount--;
- }
- staleMap.remove(wrappedChild);
- observable.removeChangeListener(childListener);
- observable.removeStaleListener(childListener);
- boolean newStale = staleCount > 0;
- if (newStale != oldStale) {
- stalenessConsumer.setStale(newStale);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/UnmodifiableObservableList.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/UnmodifiableObservableList.java
deleted file mode 100644
index 545c7517..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/observable/UnmodifiableObservableList.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Cerner 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:
- * Brad Reynolds - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.internal.databinding.internal.observable;
-
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.databinding.observable.IStaleListener;
-import org.eclipse.jface.databinding.observable.list.IListChangeListener;
-import org.eclipse.jface.databinding.observable.list.IObservableList;
-import org.eclipse.jface.databinding.observable.list.ListDiff;
-import org.eclipse.jface.databinding.observable.list.ObservableList;
-
-/**
- * ObservableList implementation that prevents modification by consumers. Events
- * in the originating wrapped list are propagated and thrown from this instance
- * when appropriate. All mutators throw an UnsupportedOperationException.
- *
- * @since 3.2
- */
-/*
- * Implementation makes the assumption that the superclass (UnmodifiableList) is
- * unmodifiable and that all modify methods throw an
- * UnsupportedOperationException.
- */
-public class UnmodifiableObservableList extends ObservableList {
- /**
- * List that is being made unmodifiable.
- */
- private final IObservableList wrappedList;
-
- /**
- * @param wrappedList
- */
- public UnmodifiableObservableList(IObservableList wrappedList) {
- super(wrappedList, wrappedList.getElementType());
- this.wrappedList = wrappedList;
-
- wrappedList.addListChangeListener(new IListChangeListener() {
- public void handleListChange(IObservableList source, ListDiff diff) {
- // Fires a Change and then ListChange event.
- fireListChange(diff);
- }
- });
-
- wrappedList.addStaleListener(new IStaleListener() {
- public void handleStale(IObservable source) {
- fireStale();
- }
- });
- }
-
- /**
- * Because this instance is immutable staleness cannot be changed.
- *
- * @see org.eclipse.jface.internal.databinding.provisional.observable.list.ObservableList#setStale(boolean)
- */
- public void setStale(boolean stale) {
- throw new UnsupportedOperationException();
- }
-
- public boolean isStale() {
- return wrappedList.isStale();
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/AbstractDataBindingContextFactory.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/AbstractDataBindingContextFactory.java
deleted file mode 100644
index 8ab5c5ac..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/AbstractDataBindingContextFactory.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional;
-
-import org.eclipse.jface.internal.databinding.provisional.factories.BindSupportFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.IBindingFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.IObservableFactory;
-
-/**
- * Defines an interface for objects that can create data binding contexts
- *
- * @since 3.3
- * @deprecated this class is no longer part of the data binding API
- */
-public abstract class AbstractDataBindingContextFactory {
-
- private DataBindingContext context;
-
- /**
- * Adds the specified IObservableFactory objects to the data binding
- * context that is being configured in the specified order.
- * <p>
- * This method may be overridden in subclasses in order to intercept and
- * modify the set or order of factories that are configured
- * for a given data binding context factory.
- *
- * @param observableFactories An IObservableFactory[] containing the factories to add.
- */
- protected void addObservableFactories(IObservableFactory[] observableFactories) {
- for (int i = 0; i < observableFactories.length; i++) {
- context.addObservableFactory(observableFactories[i]);
- }
- }
-
- /**
- * Adds the specified BindSupportFactory objects to the data binding
- * context that is being configured in the specified order.
- * <p>
- * This method may be overridden in subclasses in order to intercept and
- * modify the set or order of factories that are configured
- * for a given data binding context factory.
- *
- * @param observableFactories An IObservableFactory[] containing the factories to add.
- */
- protected void addBindSupportFactories(BindSupportFactory[] bindSupportFactories) {
- for (int i = 0; i < bindSupportFactories.length; i++) {
- context.addBindSupportFactory(bindSupportFactories[i]);
- }
- }
-
- /**
- * Adds the specified IBindingFactory objects to the data binding
- * context that is being configured in the specified order.
- * <p>
- * This method may be overridden in subclasses in order to intercept and
- * modify the set or order of factories that are configured
- * for a given data binding context factory.
- *
- * @param observableFactories An IObservableFactory[] containing the factories to add.
- */
- protected void addBindingFactories(IBindingFactory[] bindingFactories) {
- for (int i = 0; i < bindingFactories.length; i++) {
- context.addBindingFactory(bindingFactories[i]);
- }
- }
-
- /**
- * Extenders must override this method and call
- * {@link #addObservableFactories(IObservableFactory[])},
- * {@link #addBindSupportFactories(BindSupportFactory[])}, and
- * {@link #addBindingFactories(IBindingFactory[])} with the appropriate
- * factories.
- * @param context TODO
- */
- protected abstract void configureContext(DataBindingContext context);
-
- /**
- * Creates, configures, and returns a new data binding context.
- *
- * @return DataBindingContext a configured data binding context.
- */
- public DataBindingContext createContext() {
- context = new DataBindingContext();
- configureContext(context);
- return context;
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/BindSpec.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/BindSpec.java
deleted file mode 100644
index 2329ea9d..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/BindSpec.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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
- * Brad Reynolds (bug 135316)
- *******************************************************************************/
-package org.eclipse.jface.internal.databinding.provisional;
-
-import org.eclipse.jface.internal.databinding.provisional.conversion.IConverter;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertDeleteProvider;
-import org.eclipse.jface.internal.databinding.provisional.validation.IDomainValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.IValidator;
-
-
-/**
- * Data binding has three concerns, the target, the model, and the data flow
- * between the target and model. BindSpec contains values and settings that
- * influence how data binding manages this data flow between the target and the
- * model.
- *
- * @since 1.0
- * @deprecated use {@link org.eclipse.jface.databinding.BindSpec} instead
- */
-public class BindSpec extends org.eclipse.jface.databinding.BindSpec {
-
- /**
- * Creates a bind spec with the given converters, validators, and update
- * policies.
- *
- * @param modelToTargetConverter or <code>null</code>
- * @param targetToModelConverter or <code>null</code>
- * @param targetValidator or <code>null</code>
- * @param domainValidator or <code>null</code>
- * @param modelUpdatePolicy
- * @param validatePolicy
- * @param targetUpdatePolicy
- *
- */
- public BindSpec(IConverter modelToTargetConverter,
- IConverter targetToModelConverter, IValidator targetValidator,
- IDomainValidator domainValidator, Integer modelUpdatePolicy,
- Integer validatePolicy, Integer targetUpdatePolicy) {
- this(
- (modelToTargetConverter != null) ? new IConverter[] { modelToTargetConverter }
- : null,
- (targetToModelConverter != null) ? new IConverter[] { targetToModelConverter }
- : null,
- (targetValidator != null) ? new IValidator[] { targetValidator }
- : null, domainValidator, modelUpdatePolicy,
- validatePolicy, targetUpdatePolicy);
- }
-
- /**
- * Creates a bind spec with the given converters, validators, and update
- * policies.
- *
- * @param modelToTargetConverters or <code>null</code>
- * @param targetToModelConverters or <code>null</code>
- * @param targetValidators or <code>null</code>
- * @param domainValidator or <code>null</code>
- * @param modelUpdatePolicy
- * @param validatePolicy
- * @param targetUpdatePolicy
- *
- */
- public BindSpec(IConverter[] modelToTargetConverters,
- IConverter[] targetToModelConverters, IValidator[] targetValidators,
- IDomainValidator domainValidator, Integer modelUpdatePolicy,
- Integer validatePolicy, Integer targetUpdatePolicy) {
- this(modelToTargetConverters, targetToModelConverters, targetValidators, domainValidator, modelUpdatePolicy, validatePolicy, targetUpdatePolicy, null);
- }
-
- /**
- * Creates a bind spec with the given converters, validators, and update
- * policies.
- *
- * @param modelToTargetConverters
- * @param targetToModelConverters
- * @param targetValidators
- * @param domainValidator
- * @param modelUpdatePolicy
- * @param validatePolicy
- * @param targetUpdatePolicy
- * @param lazyInsertDeleteProvider
- *
- */
- public BindSpec(IConverter[] modelToTargetConverters,
- IConverter[] targetToModelConverters, IValidator[] targetValidators,
- IDomainValidator domainValidator, Integer modelUpdatePolicy,
- Integer validatePolicy, Integer targetUpdatePolicy,
- LazyInsertDeleteProvider lazyInsertDeleteProvider) {
- super(modelToTargetConverters, targetToModelConverters, targetValidators, domainValidator, modelUpdatePolicy, validatePolicy, targetUpdatePolicy, lazyInsertDeleteProvider);
- }
-
- /**
- * Creates a bind spec with the given converter and validator. The update
- * policies are set to <code>IBindSpec.POLICY_CONTEXT</code>.
- *
- * @param modelToTargetConverter or <code>null</code>
- * @param targetToModelConverter or <code>null</code>
- * @param targetValidator or <code>null</code>
- * @param domainValidator or <code>null</code>
- *
- */
- public BindSpec(IConverter modelToTargetConverter,
- IConverter targetToModelConverter, IValidator targetValidator,
- IDomainValidator domainValidator) {
- this(modelToTargetConverter, targetToModelConverter, targetValidator,
- domainValidator, null, null, null);
- }
-
- /**
- * Default constructor that initializes all objects to their defaults.
- */
- public BindSpec() {
- this((IConverter) null, null, null, null, null, null, null);
- }
-
- /**
- * @return true if the model should be updated by the binding
- * @deprecated use {@link #isUpdateModel()} instead
- */
- public boolean updateModel() {
- return isUpdateModel();
- }
-
- /**
- * @return true if the target should be updated by the binding
- * @deprecated use {@link #isUpdateTarget()} instead
- */
- public boolean updateTarget() {
- return isUpdateTarget();
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/Binding.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/Binding.java
deleted file mode 100644
index 9fdc5e4d..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/Binding.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional;
-
-import org.eclipse.jface.databinding.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.validation.ValidationError;
-
-/**
- * The interface that represents a binding between a model and a target.
- *
- * This interface is not intended to be implemented by clients.
- *
- * @since 1.0
- * @deprecated use {@link org.eclipse.jface.databinding.Binding} instead
- */
-public abstract class Binding extends org.eclipse.jface.databinding.Binding {
-
- /**
- * @since 3.2
- *
- */
- private static class WrappingBindingListener implements
- org.eclipse.jface.databinding.IBindingListener {
- /**
- *
- */
- private final IBindingListener listener;
-
- /**
- * @param listener
- */
- private WrappingBindingListener(IBindingListener listener) {
- this.listener = listener;
- }
-
- public ValidationError bindingEvent(org.eclipse.jface.databinding.BindingEvent e) {
- return listener.bindingEvent(new BindingEvent(e.model,e.target,e.diff,e.copyType,e.pipelinePosition));
- }
-
- public int hashCode() {
- return listener.hashCode();
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final WrappingBindingListener other = (WrappingBindingListener) obj;
- if (listener == null) {
- if (other.listener != null)
- return false;
- } else if (!listener.equals(other.listener))
- return false;
- return true;
- }
-
- }
-
- /**
- * @param context
- */
- public Binding(DataBindingContext context) {
- super(context);
- }
-
- /**
- * Add a listener to the set of listeners that will be notified when an
- * event occurs in the data flow pipeline that is managed by this Binding.
- *
- * @param listener
- * The listener to add.
- */
- public void addBindingEventListener(final IBindingListener listener) {
- super.addBindingEventListener(new WrappingBindingListener(listener));
- }
-
- /**
- * Removes a listener from the set of listeners that will be notified when
- * an event occurs in the data flow pipeline that is managed by this
- * Binding.
- *
- * @param listener
- * The listener to remove.
- */
- public void removeBindingEventListener(IBindingListener listener) {
- super.removeBindingEventListener(new WrappingBindingListener(listener));
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/BindingAdapter.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/BindingAdapter.java
deleted file mode 100644
index 909b3761..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/BindingAdapter.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional;
-
-import org.eclipse.jface.internal.databinding.provisional.validation.ValidationError;
-
-
-/**
- * A default implementation for an IBindingListener event handler.
- *
- * @since 1.0
- * @deprecated use {@link org.eclipse.jface.databinding.BindingAdapter} instead
- */
-public class BindingAdapter implements IBindingListener {
-
- public ValidationError bindingEvent(BindingEvent e) {
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/BindingEvent.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/BindingEvent.java
deleted file mode 100644
index 4b46ea62..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/BindingEvent.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional;
-
-import org.eclipse.jface.databinding.observable.IDiff;
-import org.eclipse.jface.databinding.observable.IObservable;
-
-/**
- * The event that is passed to a #bindingEvent method of an IBindingListener.
- * This class is not intended to be subclassed by clients.
- *
- * @since 1.0
- * @deprecated use {@link org.eclipse.jface.databinding.BindingEvent} instead
- */
-public class BindingEvent extends org.eclipse.jface.databinding.BindingEvent {
-
- /**
- * (Non-API Method) Construct a BindingEvent.
- *
- * @param model
- * @param target
- * @param diff
- * @param copyType
- * @param pipelinePosition
- * The initial processing pipeline position.
- */
- public BindingEvent(IObservable model, IObservable target, IDiff diff, int copyType,
- int pipelinePosition) {
- super(model, target, diff, copyType, pipelinePosition);
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/BindingException.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/BindingException.java
deleted file mode 100644
index 1dc29520..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/BindingException.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.internal.databinding.provisional;
-
-/**
- * An unchecked exception indicating a binding problem.
- *
- * <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>
- *
- * TODO API review issue: Use CoreException instead?
- *
- * @since 1.0
- * @deprecated use {@link org.eclipse.jface.databinding.BindingException} instead
- */
-public class BindingException extends org.eclipse.jface.databinding.BindingException {
-
- /**
- *
- */
- private static final long serialVersionUID = -5163348527342184865L;
-
- /**
- * Creates a new BindingException with the given message.
- * @param message
- */
- public BindingException(String message) {
- super(message);
- }
-
- /**
- * Creates a new BindingException with the given message and cause.
- * @param message
- * @param cause
- */
- public BindingException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/DataBindingContext.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/DataBindingContext.java
deleted file mode 100644
index adb12096..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/DataBindingContext.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.internal.databinding.provisional;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.internal.databinding.provisional.factories.BindSupportFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultBindSupportFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultBindingFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.IBindingFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.IObservableFactory;
-
-/**
- * A context for binding observable objects with a shared lifecycle. The
- * factories registered with a data binding context determine how observable
- * objects are created from description objects, and which converters and
- * validators are used when no specific converter or validator is given.
- *
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- *
- * <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
- * @deprecated use {@link org.eclipse.jface.databinding.DataBindingContext} instead
- *
- */
-public final class DataBindingContext extends org.eclipse.jface.databinding.DataBindingContext {
-
- /**
- * Returns a new data binding context with the given parent.
- *
- * @param parent
- * @return a data binding context
- */
- public static DataBindingContext createContext(DataBindingContext parent) {
- DataBindingContext result = new DataBindingContext(parent);
- return result;
- }
-
- /**
- * Returns a new data binding context on which the given factories have been
- * registered using
- * {@link DataBindingContext#addObservableFactory(IObservableFactory)}. The
- * factories will be added in the order given.
- *
- * @param observableFactories
- * @return a data binding context
- */
- public static DataBindingContext createContext(
- IObservableFactory[] observableFactories) {
- return createContext(observableFactories,
- new BindSupportFactory[] { new DefaultBindSupportFactory() },
- new IBindingFactory[] { new DefaultBindingFactory() });
- }
-
- /**
- * Returns a new data binding context on which the given factories have been
- * registered using
- * {@link DataBindingContext#addObservableFactory(IObservableFactory)}. The
- * factories will be added in the order given.
- *
- * @param observableFactories
- * @param bindSupportFactories
- * @param bindingFactories
- * @return a data binding context
- */
- public static DataBindingContext createContext(
- IObservableFactory[] observableFactories,
- BindSupportFactory[] bindSupportFactories,
- IBindingFactory[] bindingFactories) {
- DataBindingContext result = new DataBindingContext();
- if (observableFactories != null)
- for (int i = 0; i < observableFactories.length; i++) {
- result.addObservableFactory(observableFactories[i]);
- }
- if (bindSupportFactories != null)
- for (int i = 0; i < bindSupportFactories.length; i++) {
- result.addBindSupportFactory(bindSupportFactories[i]);
- }
- if (bindingFactories != null)
- for (int i = 0; i < bindingFactories.length; i++) {
- result.addBindingFactory(bindingFactories[i]);
- }
- return result;
- }
-
- private List bindingFactories = new ArrayList();
-
- private List createdObservables = new ArrayList();
-
- private List factories = new ArrayList();
-
- /**
- *
- */
- public DataBindingContext() {
- }
-
- /**
- * @param parent
- *
- */
- public DataBindingContext(DataBindingContext parent) {
- super(parent);
- }
-
- /**
- * Adds a factory for creating observable objects from description objects
- * to this context. The list of observable factories is used for creating
- * observable objects when binding based on description objects.
- *
- * @param observableFactory
- * @deprecated no longer part of the API
- */
- public void addObservableFactory(IObservableFactory observableFactory) {
- // TODO: consider the fact that adding new factories for a given
- // description
- // may hide default ones (e.g., a new PropertyDescriptor may overide the
- // ond for EMF)
- factories.add(observableFactory);
- }
-
- /**
- * Adds the given factory to the list of binding factories.
- *
- * @param factory
- * @deprecated no longer part of the API
- */
- public void addBindingFactory(IBindingFactory factory) {
- bindingFactories.add(factory);
- }
-
- /**
- * Binds targetObservable and modelObservable using converter and validator
- * as specified in bindSpec. If bindSpec is null, a default converter and
- * validator is used.
- *
- * @param targetObservable
- * @param modelObservable
- * @param bindSpec
- * the bind spec, or null. Any bindSpec object must not be reused
- * or changed after it is passed to #bind.
- * @return The Binding that manages this data flow
- * @deprecated no longer part of the API
- */
- public Binding bind(IObservable targetObservable,
- IObservable modelObservable, org.eclipse.jface.databinding.BindSpec bindSpec) {
- Binding result = doCreateBinding(targetObservable, modelObservable,
- bindSpec, this);
- if (result != null)
- return result;
- throw new BindingException(
- "No binding found for target: " + targetObservable.getClass().getName() + ", model: " + modelObservable.getClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private Binding doCreateBinding(IObservable targetObservable,
- IObservable modelObservable, org.eclipse.jface.databinding.BindSpec bindSpec,
- DataBindingContext originatingContext) {
- for (int i = bindingFactories.size() - 1; i >= 0; i--) {
- IBindingFactory factory = (IBindingFactory) bindingFactories.get(i);
- Binding binding = null;
- if (bindSpec==null || bindSpec instanceof BindSpec) {
- binding = factory.createBinding(originatingContext, targetObservable,
- modelObservable, (BindSpec)bindSpec);
- }
- if (binding != null) {
- addBinding(binding);
- return binding;
- }
- }
- if (parent instanceof DataBindingContext) {
- return ((DataBindingContext)parent).doCreateBinding(targetObservable, modelObservable,
- bindSpec, originatingContext);
- }
- return null;
- }
-
- /**
- * Convenience method to bind targetObservable and
- * createObservable(modelDescription).
- *
- * @param targetObservable
- * @param modelDescription
- * @param bindSpec
- * the bind spec, or null. Any bindSpec object must not be reused
- * or changed after it is passed to #bind.
- * @return The Binding that manages this data flow
- * @deprecated no longer part of the API
- */
- public Binding bind(IObservable targetObservable, Object modelDescription,
- org.eclipse.jface.databinding.BindSpec bindSpec) {
- return bind(targetObservable, createObservable(modelDescription),
- bindSpec);
- }
-
- /**
- * Convenience method to bind createObservable(targetDescription) and
- * modelObservable.
- *
- * @param targetDescription
- * @param modelObservable
- * @param bindSpec
- * the bind spec, or null. Any bindSpec object must not be reused
- * or changed after it is passed to #bind.
- * @return The Binding that manages this data flow
- * @deprecated no longer part of the API
- */
- public Binding bind(Object targetDescription, IObservable modelObservable,
- org.eclipse.jface.databinding.BindSpec bindSpec) {
- return bind(createObservable(targetDescription), modelObservable,
- bindSpec);
- }
-
- /**
- * Convenience method to bind createObservable(targetDescription) and
- * createObservable(modelDescription).
- *
- * @param targetDescription
- * @param modelDescription
- * @param bindSpec
- * the bind spec, or null. Any bindSpec object must not be reused
- * or changed after it is passed to #bind.
- * @return The Binding that manages this data flow
- * @deprecated no longer part of the API
- */
- public Binding bind(Object targetDescription, Object modelDescription,
- org.eclipse.jface.databinding.BindSpec bindSpec) {
- return bind(createObservable(targetDescription), modelDescription,
- bindSpec);
- }
-
- /**
- * Creates an observable object from a description. Description objects are
- * interpreted by implementors of IObservableFactory, the data binding
- * framework does not impose any semantics on them.
- *
- * @param description
- * @return IObservable for the given description
- * @deprecated no longer part of the API
- */
- public IObservable createObservable(Object description) {
- IObservable observable = doCreateObservable(description, this);
- if (observable != null) {
- createdObservables.add(observable);
- }
- return observable;
- }
-
- /**
- * Disposes of this data binding context and all observable objects created
- * in this context.
- * @deprecated contract has changed in the replacement class
- */
- public void dispose() {
- super.dispose();
- for (Iterator it = createdObservables.iterator(); it.hasNext();) {
- IObservable observable = (IObservable) it.next();
- observable.dispose();
- }
- }
-
- private IObservable doCreateObservable(Object description,
- DataBindingContext thisDatabindingContext) {
- for (int i = factories.size() - 1; i >= 0; i--) {
- IObservableFactory factory = (IObservableFactory) factories.get(i);
- IObservable result = factory.createObservable(description);
- if (result != null) {
- return result;
- }
- }
- if (parent instanceof DataBindingContext) {
- return ((DataBindingContext)parent).doCreateObservable(description,
- thisDatabindingContext);
- }
- throw new BindingException("could not find observable for " //$NON-NLS-1$
- + description);
- }
-
- /**
- * Registers an IObservable with the data binding context so that it will be
- * disposed when all other IObservables are disposed. This is only necessary
- * for observables like SettableValue that are instantiated directly, rather
- * being created by a data binding context to begin with.
- *
- * @param observable
- * The IObservable to register.
- * @deprecated no longer part of the API
- */
- public void registerForDispose(IObservable observable) {
- createdObservables.add(observable);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/IBindingListener.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/IBindingListener.java
deleted file mode 100644
index 816a296b..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/IBindingListener.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional;
-
-import org.eclipse.jface.internal.databinding.provisional.validation.ValidationError;
-
-/**
- * An interface for objects that need to listen to events that occur in the
- * data flow pipeline
- *
- * @since 1.0
- * @deprecated no longer part of the API
- */
-public interface IBindingListener {
-
- /**
- * Method bindingEvent. The method that is called when something interesting
- * occurs in the data flow pipeline.
- *
- * @param e The IBindingEvent to handle.
- * @return null if no error or a ValidationError with an error status to
- * abort the operation. The error will be propagated to the data binding
- * context's error message updatable.
- */
- public ValidationError bindingEvent(BindingEvent e);
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertDate2String.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertDate2String.java
deleted file mode 100644
index f6814330..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertDate2String.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.conversion;
-
-import java.util.Date;
-
-
-/**
- * Convert a Java.util.Date to a String using the current locale. Null date
- * values are converted to an empty string.
- *
- * @since 1.0
- */
-public class ConvertDate2String extends DateConversionSupport implements IConverter {
- public Object convert(Object source) {
- if (source != null)
- return format((Date)source);
- return ""; //$NON-NLS-1$
- }
-
- public Object getFromType() {
- return Date.class;
- }
-
- public Object getToType() {
- return String.class;
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2BigDecimal.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2BigDecimal.java
deleted file mode 100644
index 8643e8c5..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2BigDecimal.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.conversion;
-
-import java.math.BigDecimal;
-
-
-
-/**
- * ConvertString2BigDecimal.
- */
-public class ConvertString2BigDecimal implements IConverter {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object)
- */
- public Object convert(Object source) {
- try {
- return new BigDecimal((String)source);
- } catch (Exception e) {
- throw new IllegalArgumentException("String2BigDecimal: " + e.getMessage() + ": " + source); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public Object getFromType() {
- return String.class;
- }
-
- public Object getToType() {
- return BigDecimal.class;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Boolean.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Boolean.java
deleted file mode 100644
index d3c61d0b..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Boolean.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.conversion;
-
-
-
-
-/**
- * ConvertString2Boolean.
- */
-public class ConvertString2Boolean extends ConvertString2BooleanPrimitive {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object)
- */
- public Object convert(Object source) {
- String sourceString = (String) source;
- if ("".equals(sourceString.trim())) { //$NON-NLS-1$
- return null;
- } else {
- return super.convert(source);
- }
- }
-
- public Object getToType() {
- return Boolean.class;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2BooleanPrimitive.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2BooleanPrimitive.java
deleted file mode 100644
index 0ed87dd3..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2BooleanPrimitive.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.conversion;
-
-import org.eclipse.jface.internal.databinding.internal.BindingMessages;
-
-
-
-/**
- * ConvertString2BooleanPrimitive.
- */
-public class ConvertString2BooleanPrimitive implements IConverter {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object)
- */
- public Object convert(Object source) {
- String s = (String) source;
- if (s.equals(BindingMessages.getString("Yes")) || s.equals(BindingMessages.getString("yes")) || s.equals(BindingMessages.getString("true")) || s.equals(BindingMessages.getString("True"))) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- return Boolean.TRUE;
- if (s.equals(BindingMessages.getString("No")) || s.equals(BindingMessages.getString("no")) || s.equals(BindingMessages.getString("false")) || s.equals(BindingMessages.getString("False"))) //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
- return Boolean.FALSE;
-
- throw new IllegalArgumentException(s + " is not a legal boolean value"); //$NON-NLS-1$
- }
-
- public Object getFromType() {
- return String.class;
- }
-
- public Object getToType() {
- return Boolean.TYPE;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Byte.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Byte.java
deleted file mode 100644
index 854f7e7b..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Byte.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.conversion;
-
-
-
-
-/**
- * ConvertString2Byte.
- */
-public class ConvertString2Byte extends ConvertString2BytePrimitive {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object)
- */
- public Object convert(Object source) {
- String sourceString = (String) source;
- if ("".equals(sourceString.trim())) { //$NON-NLS-1$
- return null;
- } else {
- return super.convert(source);
- }
- }
-
- public Object getToType() {
- return Byte.class;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2BytePrimitive.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2BytePrimitive.java
deleted file mode 100644
index 2f7ecc7f..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2BytePrimitive.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.conversion;
-
-
-
-
-/**
- * ConvertString2BytePrimitive.
- */
-public class ConvertString2BytePrimitive implements IConverter {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object)
- */
- public Object convert(Object source) {
- try {
- return new Byte(Byte.parseByte((String) source));
- } catch (Exception e) {
- throw new IllegalArgumentException("String2Byte: " + e.getMessage() + ": " + source); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public Object getFromType() {
- return String.class;
- }
-
- public Object getToType() {
- return Byte.TYPE;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Character.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Character.java
deleted file mode 100644
index bb630817..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Character.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.conversion;
-
-/**
- * ConvertString2Character.
- */
-public class ConvertString2Character implements IConverter {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object)
- */
- public Object convert(Object source) {
- String s = (String) source;
- Character result;
-
- if (s.length() > 1)
- throw new IllegalArgumentException(
- "String2Character: string too long: " + s); //$NON-NLS-1$
-
- try {
- result = new Character(s.charAt(0));
- } catch (Exception e) {
- throw new IllegalArgumentException(
- "String2Character: " + e.getMessage() + ": " + s); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- return result;
- }
-
- public Object getFromType() {
- return String.class;
- }
-
- public Object getToType() {
- return Character.class;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Date.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Date.java
deleted file mode 100644
index 122dbccf..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Date.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.conversion;
-
-import java.util.Date;
-
-
-/**
- * Convert a String to a java.util.Date, respecting the current locale
- *
- * @since 1.0
- */
-public class ConvertString2Date extends DateConversionSupport implements IConverter {
- public Object convert(Object source) {
- return parse(source.toString());
- }
-
- public Object getFromType() {
- return String.class;
- }
-
- public Object getToType() {
- return Date.class;
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Double.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Double.java
deleted file mode 100644
index 4bde2045..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Double.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.conversion;
-
-
-
-
-/**
- * ConvertString2Double.
- */
-public class ConvertString2Double extends ConvertString2DoublePrimitive {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object)
- */
- public Object convert(Object source) {
- String sourceString = (String) source;
- if ("".equals(sourceString.trim())) { //$NON-NLS-1$
- return null;
- } else {
- return super.convert(source);
- }
- }
-
- public Object getToType() {
- return Double.class;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2DoublePrimitive.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2DoublePrimitive.java
deleted file mode 100644
index 427351a2..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2DoublePrimitive.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.conversion;
-
-
-
-
-/**
- * ConvertString2DoublePrimitive.
- */
-public class ConvertString2DoublePrimitive implements IConverter {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object)
- */
- public Object convert(Object source) {
- try {
- return new Double(Double.parseDouble((String) source));
- } catch (Exception e) {
- throw new IllegalArgumentException("String2Double: " + e.getMessage() + ": " + source); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public Object getFromType() {
- return String.class;
- }
-
- public Object getToType() {
- return Double.TYPE;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Float.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Float.java
deleted file mode 100644
index 31c24146..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Float.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.conversion;
-
-
-
-
-/**
- * ConvertString2Float.
- */
-public class ConvertString2Float extends ConvertString2FloatPrimitive {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object)
- */
- public Object convert(Object source) {
- String sourceString = (String) source;
- if ("".equals(sourceString.trim())) { //$NON-NLS-1$
- return null;
- } else {
- return super.convert(source);
- }
- }
-
- public Object getToType() {
- return Float.class;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2FloatPrimitive.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2FloatPrimitive.java
deleted file mode 100644
index 1d349635..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2FloatPrimitive.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.conversion;
-
-
-
-
-/**
- * ConvertString2FloatPrimitive.
- */
-public class ConvertString2FloatPrimitive implements IConverter {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object)
- */
- public Object convert(Object source) {
- try {
- return new Float(Float.parseFloat((String) source));
- } catch (Exception e) {
- throw new IllegalArgumentException("String2Float: " + e.getMessage() + ": " + source); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public Object getFromType() {
- return String.class;
- }
-
- public Object getToType() {
- return Float.TYPE;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Integer.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Integer.java
deleted file mode 100644
index abc0285f..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Integer.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.conversion;
-
-
-
-
-/**
- * ConvertString2Integer.
- */
-public class ConvertString2Integer extends ConvertString2IntegerPrimitive {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object)
- */
- public Object convert(Object source) {
- String sourceString = (String) source;
- if ("".equals(sourceString.trim())) { //$NON-NLS-1$
- return null;
- } else {
- return super.convert(source);
- }
- }
-
- public Object getToType() {
- return Integer.class;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2IntegerPrimitive.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2IntegerPrimitive.java
deleted file mode 100644
index 404ab9cf..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2IntegerPrimitive.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.conversion;
-
-
-
-
-/**
- * ConvertString2IntegerPrimitive.
- */
-public class ConvertString2IntegerPrimitive implements IConverter {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object)
- */
- public Object convert(Object source) {
- try {
- return new Integer(Integer.parseInt((String) source));
- } catch (Exception e) {
- throw new IllegalArgumentException("String2Int: " + e.getMessage() + ": " + source); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public Object getFromType() {
- return String.class;
- }
-
- public Object getToType() {
- return Integer.TYPE;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Long.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Long.java
deleted file mode 100644
index eb38c817..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Long.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.conversion;
-
-
-
-
-/**
- * ConvertString2Long.
- */
-public class ConvertString2Long extends ConvertString2LongPrimitive {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object)
- */
- public Object convert(Object source) {
- String sourceString = (String) source;
- if ("".equals(sourceString.trim())) { //$NON-NLS-1$
- return null;
- } else {
- return super.convert(source);
- }
- }
-
- public Object getToType() {
- return Long.class;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2LongPrimitive.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2LongPrimitive.java
deleted file mode 100644
index c094fbf7..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2LongPrimitive.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.conversion;
-
-
-
-
-/**
- * ConvertString2LongPrimitive.
- */
-public class ConvertString2LongPrimitive implements IConverter {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object)
- */
- public Object convert(Object source) {
- try {
- return new Long(Long.parseLong((String) source));
- } catch (Exception e) {
- throw new IllegalArgumentException("String2Long: " + e.getMessage() + ": " + source); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public Object getFromType() {
- return String.class;
- }
-
- public Object getToType() {
- return Long.TYPE;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Short.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Short.java
deleted file mode 100644
index 8f40e01c..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2Short.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.conversion;
-
-
-
-
-/**
- * ConvertString2Long.
- */
-public class ConvertString2Short extends ConvertString2ShortPrimitive {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object)
- */
- public Object convert(Object source) {
- String sourceString = (String) source;
- if ("".equals(sourceString.trim())) { //$NON-NLS-1$
- return null;
- } else {
- return super.convert(source);
- }
- }
-
- public Object getToType() {
- return Short.class;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2ShortPrimitive.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2ShortPrimitive.java
deleted file mode 100644
index d2a60b0f..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ConvertString2ShortPrimitive.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.conversion;
-
-
-
-
-/**
- * ConvertString2ShortPrimitive.
- */
-public class ConvertString2ShortPrimitive implements IConverter {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object)
- */
- public Object convert(Object source) {
- try {
- return new Short(Short.parseShort((String) source));
- } catch (Exception e) {
- throw new IllegalArgumentException("String2Short: " + e.getMessage() + ": " + source); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public Object getFromType() {
- return String.class;
- }
-
- public Object getToType() {
- return Short.TYPE;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/Converter.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/Converter.java
deleted file mode 100644
index 804ef03c..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/Converter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.conversion;
-
-
-/**
- * @since 1.0
- *
- */
-public abstract class Converter implements IConverter {
-
- private Object fromType;
- private Object toType;
-
- /**
- * @param fromType
- * @param toType
- */
- public Converter(Object fromType, Object toType) {
- this.fromType = fromType;
- this.toType = toType;
- }
-
- public Object getFromType() {
- return fromType;
- }
-
- public Object getToType() {
- return toType;
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/DateConversionSupport.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/DateConversionSupport.java
deleted file mode 100644
index dbfe41be..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/DateConversionSupport.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.conversion;
-
-import com.ibm.icu.text.DateFormat;
-import java.text.ParsePosition;
-import com.ibm.icu.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Base support for date/string conversion handling according to the
- * default locale or in plain long milliseconds.
- *
- * NOTE: parse(format(date)) will generally *not* be equal to date, since the
- * string representation may not cover the sub-second range, time-only string
- * representations will be counted from the beginning of the era, etc.
- */
-public abstract class DateConversionSupport {
- private final static int DATE_FORMAT=DateFormat.SHORT;
- private final static int DEFAULT_FORMATTER_INDEX=0;
-
- private final static int NUM_VIRTUAL_FORMATTERS=1;
-
- /**
- * Alternative formatters for date, time and date/time.
- * Raw milliseconds are covered as a special case.
- */
- // TODO: These could be shared, but would have to be synchronized.
- private DateFormat[] formatters={
- new SimpleDateFormat("dd.MM.yyyy HH:mm:ss.SSS Z"), //$NON-NLS-1$
- new SimpleDateFormat("HH:mm:ss.SSS"), //$NON-NLS-1$
- DateFormat.getDateTimeInstance(DATE_FORMAT,DateFormat.SHORT),
- DateFormat.getDateInstance(DATE_FORMAT),
- DateFormat.getTimeInstance(DateFormat.SHORT),
- DateFormat.getDateTimeInstance(DATE_FORMAT,DateFormat.MEDIUM),
- DateFormat.getTimeInstance(DateFormat.MEDIUM)
- };
-
- /**
- * Tries all available formatters to parse the given string according to the
- * default locale or as a raw millisecond value and returns the result of the
- * first successful run.
- *
- * @param str A string specifying a date according to the default locale or in raw milliseconds
- * @return The parsed date, or null, if no available formatter could interpret the input string
- */
- protected Date parse(String str) {
- for (int formatterIdx = 0; formatterIdx < formatters.length; formatterIdx++) {
- Date parsed=parse(str,formatterIdx);
- if(parsed!=null) {
- return parsed;
- }
- }
- return null;
- }
-
- protected Date parse(String str,int formatterIdx) {
- if(formatterIdx>=0) {
- ParsePosition pos=new ParsePosition(0);
- if (str == null) {
- return null;
- }
- Date date=formatters[formatterIdx].parse(str,pos);
- if(pos.getErrorIndex()!=-1||pos.getIndex()!=str.length()) {
- return null;
- }
- return date;
- }
- try {
- long millisecs=Long.parseLong(str);
- return new Date(millisecs);
- }
- catch(NumberFormatException exc) {
- }
- return null;
- }
-
- /**
- * Formats the given date with the default formatter according to the default locale.
- */
- protected String format(Date date) {
- return format(date,DEFAULT_FORMATTER_INDEX);
- }
-
- protected String format(Date date,int formatterIdx) {
- if(formatterIdx>=0) {
- return formatters[formatterIdx].format(date);
- }
- return String.valueOf(date.getTime());
- }
-
- protected int numFormatters() {
- return formatters.length+NUM_VIRTUAL_FORMATTERS;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/IConverter.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/IConverter.java
deleted file mode 100644
index 63336f91..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/IConverter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.internal.databinding.provisional.conversion;
-
-/**
- * A one-way converter.
- * <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 interface IConverter {
-
- /**
- * Returns the type whose instances can be converted by this converter.
- *
- * @return the type whose instances can be converted, or null if this converter is untyped
- */
- public Object getFromType();
-
- /**
- * Returns the type to which this converter can convert.
- *
- * @return the type to which this converter can convert, or null if this converter is untyped
- */
- public Object getToType();
-
- /**
- * Returns the result of the conversion of the given object. The given
- * object must be an instance of getTargetType(), and the result must be an
- * instance of getModelType().
- *
- * @param fromObject
- * the object to convert
- * @return the converted object
- */
- public Object convert(Object fromObject);
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/IdentityConverter.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/IdentityConverter.java
deleted file mode 100644
index 71a6e520..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/IdentityConverter.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.conversion;
-
-import org.eclipse.jface.internal.databinding.provisional.BindingException;
-
-/**
- * TheIdentityConverter. Returns the source value (the identity function).
- */
-public class IdentityConverter implements IConverter {
-
- private Class fromType;
-
- private Class toType;
-
- /**
- * @param type
- */
- public IdentityConverter(Class type) {
- this.fromType = type;
- this.toType = type;
- }
-
- /**
- * @param fromType
- * @param toType
- */
- public IdentityConverter(Class fromType, Class toType) {
- this.fromType = fromType;
- this.toType = toType;
- }
-
- private Class[][] primitiveMap = new Class[][] {
- { Integer.TYPE, Integer.class }, { Short.TYPE, Short.class },
- { Long.TYPE, Long.class }, { Double.TYPE, Double.class },
- { Byte.TYPE, Byte.class }, { Float.TYPE, Float.class },
- { Boolean.TYPE, Boolean.class }, };
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object)
- */
- public Object convert(Object source) {
- if (toType.isPrimitive()) {
- if (source == null) {
- throw new BindingException("Cannot convert null to a primitive"); //$NON-NLS-1$
- }
- }
- if (source != null) {
- Class sourceClass = source.getClass();
- if (toType.isPrimitive() || sourceClass.isPrimitive()) {
- if (sourceClass.equals(toType)
- || isPrimitiveTypeMatchedWithBoxed(sourceClass, toType)) {
- return source;
- }
- throw new BindingException(
- "Boxed and unboxed types do not match"); //$NON-NLS-1$
- }
- if (!toType.isAssignableFrom(sourceClass)) {
- throw new BindingException(sourceClass.getName()
- + " is not assignable to " + toType.getName()); //$NON-NLS-1$
- }
- }
- return source;
- }
-
- /**
- * (Non-API) isPrimitiveTypeMatchedWithBoxed.
- *
- * @param sourceClass
- * @param toClass
- * @return true if sourceClass and toType are matched primitive/boxed types
- */
- public boolean isPrimitiveTypeMatchedWithBoxed(Class sourceClass,
- Class toClass) {
- for (int i = 0; i < primitiveMap.length; i++) {
- if (toClass.equals(primitiveMap[i][0])
- && sourceClass.equals(primitiveMap[i][1])) {
- return true;
- }
- if (sourceClass.equals(primitiveMap[i][0])
- && toClass.equals(primitiveMap[i][1])) {
- return true;
- }
- }
- return false;
- }
-
- public Object getFromType() {
- return fromType;
- }
-
- public Object getToType() {
- return toType;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ToStringConverter.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ToStringConverter.java
deleted file mode 100644
index 1c64074e..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/ToStringConverter.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.conversion;
-
-/**
- * Converts any object to a string by calling its toString() method.
- */
-public class ToStringConverter implements IConverter {
-
- /**
- * A singleton for the toString() converter function
- */
- public static final ToStringConverter TOSTRINGFUNCTION = new ToStringConverter();
-
- private final Class fromClass;
-
- /**
- *
- */
- public ToStringConverter() {
- this(Object.class);
- }
-
- /**
- * @param fromClass
- */
- public ToStringConverter(Class fromClass) {
- this.fromClass = fromClass;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object)
- */
- public Object convert(Object source) {
- if (source == null) {
- return ""; //$NON-NLS-1$
- }
- return source.toString();
- }
-
- public Object getFromType() {
- return fromClass;
- }
-
- public Object getToType() {
- return String.class;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/description/ListModelDescription.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/description/ListModelDescription.java
deleted file mode 100644
index ccff0bd1..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/description/ListModelDescription.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.description;
-
-/**
- * TODO Javadoc
- *
- * @since 1.0
- * @deprecated no longer part of the API
- *
- */
-public class ListModelDescription {
-
- private final Property collectionProperty;
-
- private final Object propertyID;
-
- /**
- * @param collectionProperty
- * @param propertyID
- */
- public ListModelDescription(Property collectionProperty, Object propertyID) {
- this.collectionProperty = collectionProperty;
- this.propertyID = propertyID;
- }
-
- /**
- * @return the collection property
- */
- public Property getCollectionProperty() {
- return collectionProperty;
- }
-
- /**
- * @return Returns the propertyID.
- */
- public Object getPropertyID() {
- return propertyID;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/description/NestedProperty.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/description/NestedProperty.java
deleted file mode 100644
index da4f32d2..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/description/NestedProperty.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.internal.databinding.provisional.description;
-
-
-/**
- * TODO Javadoc
- *
- * @since 1.0
- * @deprecated no longer part of the API
- *
- */
-public class NestedProperty extends Property {
-
- private Class[] types;
- private Class prototypeClass;
-
- /**
- * @param object
- * @param properties
- * @param types
- */
- public NestedProperty(Object object, String[] properties, Class[] types) {
- super(object, properties);
- this.types = types;
- }
-
- /**
- * @param object
- * @param properties
- * @param prototypeClass
- */
- public NestedProperty(Object object, String properties, Class prototypeClass) {
- super(object, properties);
- this.prototypeClass = prototypeClass;
- }
-
- /**
- * @return the array of types
- */
- public Class[] getTypes() {
- return types;
- }
-
- /**
- * @return the prototype class
- */
- public Class getPrototypeClass() {
- return prototypeClass;
- }
-
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/description/Property.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/description/Property.java
deleted file mode 100644
index 078f04d8..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/description/Property.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.internal.databinding.provisional.description;
-
-/**
- * A standard description type representing a property of an object. Description
- * objects can be passed to <code>DataBindingContext.bind()</code> or
- * <code>DataBindingContext.createUpdatable()</code>. They are passed to
- * <code>IUpdatableFactory.createUpdatable()</code> to create an updatable
- * object. It is up to the IUpdatableFactory objects to interpret this
- * description.
- * <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
- * @deprecated no longer part of the API
- *
- */
-public class Property {
-
- private final Object object;
-
- private final Object propertyID;
-
- private final Class propertyType;
-
- private final Boolean isCollectionProperty;
-
- /**
- * Creates a new property description from the given object and property
- * identifier.
- *
- * @param object
- * @param propertyID
- */
- public Property(Object object, Object propertyID) {
- this(object, propertyID, null, null);
- }
-
- /**
- * Creates a new property description from the given object, property
- * identifier, property type, and information whether the property is a
- * collection property.
- *
- * @param object
- * the object that has the given property
- * @param propertyID
- * the property identifier
- * @param propertyType
- * the property type, or <code>null</code> if unknown
- * @param isCollectionProperty
- * <code>Boolean.TRUE</code> if the property is a collection
- * property, <code>Boolean.FALSE</code> if it is a simple
- * property, or <code>null</code> if unknown
- */
- public Property(Object object, Object propertyID,
- Class propertyType, Boolean isCollectionProperty) {
- this.object = object;
- this.propertyID = propertyID;
- this.propertyType = propertyType;
- this.isCollectionProperty = isCollectionProperty;
- }
-
- /**
- * Returns the object of this property description.
- *
- * @return the object
- */
- public Object getObject() {
- return object;
- }
-
- /**
- * Returns the property identifier of this property description.
- *
- * @return the property identifier
- */
- public Object getPropertyID() {
- return propertyID;
- }
-
- /**
- * Returns the property type of this property description, or
- * <code>null</code> if unknown.
- *
- * @return the property identifier, or <code>null</code>
- */
- public Class getPropertyType() {
- return propertyType;
- }
-
- /**
- * Returns whether the property is a collection property, or
- * <code>null</code> if unknown. If the property is a collection property,
- * getPropertyType() returns the element type of the collection.
- *
- * @return <code>Boolean.TRUE</code> if the property is a collection
- * property, <code>null</code> if it is a simple property, or
- * <code>null</code> if unknown
- */
- public Boolean isCollectionProperty() {
- return isCollectionProperty;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return "Property(" + object.getClass().getName() + ", " + propertyID.toString() + ", ...)"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/description/TableModelDescription.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/description/TableModelDescription.java
deleted file mode 100644
index 5366661c..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/description/TableModelDescription.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.description;
-
-import org.eclipse.jface.databinding.observable.list.IObservableList;
-
-
-/**
- * TODO Javadoc
- *
- * @since 1.0
- * @deprecated no longer part of the API
- *
- */
-public class TableModelDescription {
-
- private final Property collectionProperty;
- private final IObservableList observableList;
- private final Object[] columnIDs;
-
- /**
- * @param collectionProperty
- * @param columnIDs
- */
- public TableModelDescription(Property collectionProperty, Object[] columnIDs) {
- this.collectionProperty = collectionProperty;
- this.columnIDs = columnIDs;
- this.observableList = null;
- }
-
- /**
- * @param observableList
- * @param columnIDs
- */
- public TableModelDescription(IObservableList observableList, Object[] columnIDs) {
- this.observableList = observableList;
- this.columnIDs = columnIDs;
- this.collectionProperty = null;
- }
-
- /**
- * @return the collection property
- */
- public Property getCollectionProperty() {
- return collectionProperty;
- }
-
- /**
- * @return the column identifiers
- */
- public Object[] getColumnIDs() {
- return columnIDs;
- }
-
- /**
- * @return the observable list
- */
- public IObservableList getObservableList() {
- return observableList;
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/BindSupportFactory.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/BindSupportFactory.java
deleted file mode 100644
index a22d85d1..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/BindSupportFactory.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.internal.databinding.provisional.factories;
-
-import org.eclipse.jface.internal.databinding.provisional.conversion.IConverter;
-import org.eclipse.jface.internal.databinding.provisional.validation.IDomainValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.IValidator;
-
-/**
- * A factory for creating validators and converters. This interface is not
- * intended to be implemented directly. Instead, extend the abstract
- * BindSupportFactory class.
- * <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 abstract class BindSupportFactory {
-
- /**
- * Creates a validator for the given from and to types and model
- * description. Either toType or modelDescription can be null, but not both.
- * The returned validator (if not null) should validate arbitrary values of
- * type toType, and (in the case that toType is given) ensure that they can
- * be converted to toType, and (in the case that modelDescription is given)
- * ensure that they can be converted to the type expected by updatable
- * objects created from the given model description.
- *
- * @param fromType
- * The type to validate
- * @param toType
- * The type to convert to after successful validation, or
- * <code>null</code> if not known
- * @return a validator, or <code>null</code> if this factory cannot create
- * a validator for the given arguments.
- */
- public IValidator createValidator(Object fromType, Object toType) {
- return null;
- }
-
- /**
- * Creates a domain validator for the given model description. Either
- * modelType or modelDescription can be null, but not both.
- *
- * @param modelType
- * The type to validate or <code>null</code> if not known
- * @return IDomainValidator
- */
- public IDomainValidator createDomainValidator(Object modelType) {
- return null;
- }
-
- /**
- * Creates a converter for the given from and to types and model
- * description. Either toType or modelDescription can be null, but not both.
- * The returned converter (if not null) should convert values of type
- * fromType to values of type toType (in the case that toType is given), and
- * (in the case that modelDescription is given) convert to the type expected
- * by updatable objects created from the given model description.
- *
- * @param fromType
- * The type to convert from
- * @param toType
- * The type to convert to, or <code>null</code> if not known
- * @return a converter, or <code>null</code> if this factory cannot create
- * a converter for the given arguments.
- */
- public IConverter createConverter(Object fromType, Object toType) {
- return null;
- }
-
- /**
- * @param fromType
- * @param toType
- * @return whether fromType is assignable to toType, or <code>null</code>
- * if this factory cannot determine assignability between the given
- * types
- */
- public Boolean isAssignableFromTo(Object fromType, Object toType) {
- return null;
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactory.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactory.java
deleted file mode 100644
index 39c6c6c2..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactory.java
+++ /dev/null
@@ -1,648 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.factories;
-
-import java.math.BigDecimal;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jface.internal.databinding.internal.ClassLookupSupport;
-import org.eclipse.jface.internal.databinding.internal.Pair;
-import org.eclipse.jface.internal.databinding.provisional.BindingException;
-import org.eclipse.jface.internal.databinding.provisional.conversion.IConverter;
-import org.eclipse.jface.internal.databinding.provisional.conversion.IdentityConverter;
-import org.eclipse.jface.internal.databinding.provisional.conversion.ToStringConverter;
-import org.eclipse.jface.internal.databinding.provisional.validation.IDomainValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.IValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.ObjectToPrimitiveValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.ReadOnlyValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.String2BigDecimalValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.String2BytePrimitiveValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.String2ByteValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.String2DateValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.String2DoublePrimitiveValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.String2DoubleValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.String2FloatPrimitiveValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.String2FloatValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.String2IntegerPrimitiveValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.String2IntegerValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.String2LongPrimitiveValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.String2LongValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.String2ShortPrimitiveValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.String2ShortValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.ValidationError;
-
-/**
- * Default bind support factory. This factory adds the following converters and
- * validators:
- *
- * TODO list converters and validators
- *
- * @since 1.0
- *
- */
-public final class DefaultBindSupportFactory extends BindSupportFactory {
-
- private static final String INTEGER_TYPE = "java.lang.Integer.TYPE"; //$NON-NLS-1$
-
- private static final String BYTE_TYPE = "java.lang.Byte.TYPE"; //$NON-NLS-1$
-
- private static final String DOUBLE_TYPE = "java.lang.Double.TYPE"; //$NON-NLS-1$
-
- private static final String BOOLEAN_TYPE = "java.lang.Boolean.TYPE"; //$NON-NLS-1$
-
- private static final String FLOAT_TYPE = "java.lang.Float.TYPE"; //$NON-NLS-1$
-
- private static final String LONG_TYPE = "java.lang.Long.TYPE"; //$NON-NLS-1$
-
- private static final String SHORT_TYPE = "java.lang.Short.TYPE"; //$NON-NLS-1$
-
- private ValidatorRegistry validatorRegistry = new ValidatorRegistry();
-
- private Map converterMap;
-
- public IValidator createValidator(Object fromType, Object toType) {
- if (fromType == null || toType == null) {
- return new IValidator() {
-
- public ValidationError isPartiallyValid(Object value) {
- return null;
- }
-
- public ValidationError isValid(Object value) {
- return null;
- }
- };
- }
-
- IValidator dataTypeValidator = findValidator(fromType, toType);
- if (dataTypeValidator == null) {
- throw new BindingException(
- "No IValidator is registered for conversions from " + fromType + " to " + toType); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return dataTypeValidator;
- }
-
- private IValidator findValidator(Object fromType, Object toType) {
- // TODO string-based lookup of validator
- return validatorRegistry.get(fromType, toType);
- }
-
- public IConverter createConverter(Object fromType, Object toType) {
- if (!(fromType instanceof Class) || !(toType instanceof Class)) {
- return null;
- }
- Class toClass = (Class) toType;
- if (toClass.isPrimitive()) {
- toClass = autoboxed(toClass);
- }
- Class fromClass = (Class) fromType;
- if (fromClass.isPrimitive()) {
- fromClass = autoboxed(fromClass);
- }
- if (!((Class)toType).isPrimitive() && toClass.isAssignableFrom(fromClass)) {
- return new IdentityConverter(fromClass, toClass);
- }
- if (((Class) fromType).isPrimitive() && ((Class) toType).isPrimitive() && fromType.equals(toType)) {
- return new IdentityConverter((Class) fromType, (Class) toType);
- }
- Map converterMap = getConverterMap();
- Class[] supertypeHierarchyFlattened = ClassLookupSupport
- .getTypeHierarchyFlattened(fromClass);
- for (int i = 0; i < supertypeHierarchyFlattened.length; i++) {
- Class currentFromClass = supertypeHierarchyFlattened[i];
- if (currentFromClass == toType) {
- // converting to toType is just a widening
- return new IdentityConverter(fromClass, toClass);
- }
- Pair key = new Pair(getKeyForClass(fromType, currentFromClass),
- getKeyForClass(toType, toClass));
- Object converterOrClassname = converterMap.get(key);
- if (converterOrClassname instanceof IConverter) {
- return (IConverter) converterOrClassname;
- } else if (converterOrClassname instanceof String) {
- String classname = (String) converterOrClassname;
- Class converterClass;
- try {
- converterClass = Class.forName(classname);
- IConverter result = (IConverter) converterClass
- .newInstance();
- converterMap.put(key, result);
- return result;
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- } catch (InstantiationException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
- }
- }
- // Since we found no converter yet, try a "downcast" converter;
- // the IdentityConverter will automatically check the actual types at runtime.
- if (fromClass.isAssignableFrom(toClass)) {
- return new IdentityConverter(fromClass, toClass);
- }
- return null;
- }
-
- private String getKeyForClass(Object originalValue, Class filteredValue) {
- if (originalValue instanceof Class) {
- Class originalClass = (Class) originalValue;
- if (originalClass.equals(Integer.TYPE)) {
- return INTEGER_TYPE;
- } else if (originalClass.equals(Byte.TYPE)) {
- return BYTE_TYPE;
- } else if (originalClass.equals(Boolean.TYPE)) {
- return BOOLEAN_TYPE;
- } else if (originalClass.equals(Double.TYPE)) {
- return DOUBLE_TYPE;
- } else if (originalClass.equals(Float.TYPE)) {
- return FLOAT_TYPE;
- } else if (originalClass.equals(Long.TYPE)) {
- return LONG_TYPE;
- } else if (originalClass.equals(Short.TYPE)) {
- return SHORT_TYPE;
- }
- }
- return filteredValue.getName();
- }
-
- private Map getConverterMap() {
- // using string-based lookup avoids loading of too many classes
- if (converterMap == null) {
- converterMap = new HashMap();
- converterMap
- .put(
- new Pair("java.util.Date", "java.lang.String"), "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertDate2String"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- converterMap
- .put(
- new Pair("java.lang.String", "java.math.BigDecimal"), "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2BigDecimal"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- converterMap
- .put(
- new Pair("java.lang.String", "java.lang.Boolean"), "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2Boolean"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- converterMap
- .put(
- new Pair("java.lang.String", "java.lang.Byte"), "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2Byte"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- converterMap
- .put(
- new Pair("java.lang.String", "java.lang.Character"), "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2Character"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- converterMap
- .put(
- new Pair("java.lang.String", "java.util.Date"), "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2Date"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- converterMap
- .put(
- new Pair("java.lang.String", "java.lang.Double"), "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2Double"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- converterMap
- .put(
- new Pair("java.lang.String", "java.lang.Float"), "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2Float"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- converterMap
- .put(
- new Pair("java.lang.String", "java.lang.Integer"), "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2Integer"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- converterMap
- .put(
- new Pair("java.lang.String", "java.lang.Long"), "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2Long"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- converterMap
- .put(
- new Pair("java.lang.String", "java.lang.Short"), "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2Short"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- converterMap
- .put(
- new Pair("java.lang.Object", "java.lang.String"), "org.eclipse.jface.internal.databinding.provisional.conversion.ToStringConverter"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
-
- // Integer.TYPE
- converterMap
- .put(
- new Pair(
- "java.lang.String", INTEGER_TYPE), "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2IntegerPrimitive"); //$NON-NLS-1$ //$NON-NLS-2$
- converterMap
- .put(
- new Pair(
- INTEGER_TYPE, "java.lang.Integer"), new IdentityConverter(Integer.TYPE, Integer.class)); //$NON-NLS-1$
- converterMap
- .put(
- new Pair(
- INTEGER_TYPE, "java.lang.String"), new ToStringConverter(Integer.TYPE)); //$NON-NLS-1$
- converterMap
- .put(
- new Pair(
- INTEGER_TYPE, "java.lang.Object"), new IdentityConverter(Integer.TYPE, Object.class)); //$NON-NLS-1$
-
- // Byte.TYPE
- converterMap
- .put(
- new Pair(
- "java.lang.String", BYTE_TYPE), "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2BytePrimitive"); //$NON-NLS-1$ //$NON-NLS-2$
- converterMap
- .put(
- new Pair(
- BYTE_TYPE, "java.lang.Byte"), new IdentityConverter(Byte.TYPE, Byte.class)); //$NON-NLS-1$
- converterMap
- .put(
- new Pair(
- BYTE_TYPE, "java.lang.String"), new ToStringConverter(Byte.TYPE)); //$NON-NLS-1$
- converterMap
- .put(
- new Pair(
- BYTE_TYPE, "java.lang.Object"), new IdentityConverter(Byte.TYPE, Object.class)); //$NON-NLS-1$
-
-
- // Double.TYPE
- converterMap
- .put(
- new Pair(
- "java.lang.String", DOUBLE_TYPE), "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2DoublePrimitive"); //$NON-NLS-1$ //$NON-NLS-2$
- converterMap
- .put(
- new Pair(
- DOUBLE_TYPE, "java.lang.Double"), new IdentityConverter(Double.TYPE, Double.class)); //$NON-NLS-1$
- converterMap
- .put(
- new Pair(
- DOUBLE_TYPE, "java.lang.String"), new ToStringConverter(Double.TYPE)); //$NON-NLS-1$
- converterMap
- .put(
- new Pair(
- DOUBLE_TYPE, "java.lang.Object"), new IdentityConverter(Double.TYPE, Object.class)); //$NON-NLS-1$
-
- // Boolean.TYPE
- converterMap
- .put(
- new Pair(
- "java.lang.String", BOOLEAN_TYPE), "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2BooleanPrimitive"); //$NON-NLS-1$ //$NON-NLS-2$
- converterMap
- .put(
- new Pair(
- BOOLEAN_TYPE, "java.lang.Boolean"), new IdentityConverter(Boolean.TYPE, Boolean.class)); //$NON-NLS-1$
- converterMap
- .put(
- new Pair(
- BOOLEAN_TYPE, "java.lang.String"), new ToStringConverter(Boolean.TYPE)); //$NON-NLS-1$
- converterMap
- .put(
- new Pair(
- BOOLEAN_TYPE, "java.lang.Object"), new IdentityConverter(Boolean.TYPE, Object.class)); //$NON-NLS-1$
-
- // Float.TYPE
- converterMap
- .put(
- new Pair(
- "java.lang.String", FLOAT_TYPE), "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2FloatPrimitive"); //$NON-NLS-1$ //$NON-NLS-2$
- converterMap
- .put(
- new Pair(
- FLOAT_TYPE, "java.lang.Float"), new IdentityConverter(Float.TYPE, Float.class)); //$NON-NLS-1$
- converterMap
- .put(
- new Pair(
- FLOAT_TYPE, "java.lang.String"), new ToStringConverter(Float.TYPE)); //$NON-NLS-1$
- converterMap
- .put(
- new Pair(
- FLOAT_TYPE, "java.lang.Object"), new IdentityConverter(Float.TYPE, Object.class)); //$NON-NLS-1$
-
-
- // Short.TYPE
- converterMap
- .put(
- new Pair(
- "java.lang.String", SHORT_TYPE), "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2ShortPrimitive"); //$NON-NLS-1$ //$NON-NLS-2$
- converterMap
- .put(
- new Pair(
- SHORT_TYPE, "java.lang.Short"), new IdentityConverter(Short.TYPE, Short.class)); //$NON-NLS-1$
- converterMap
- .put(
- new Pair(
- SHORT_TYPE, "java.lang.String"), new ToStringConverter(Short.TYPE)); //$NON-NLS-1$
- converterMap
- .put(
- new Pair(
- SHORT_TYPE, "java.lang.Object"), new IdentityConverter(Short.TYPE, Object.class)); //$NON-NLS-1$
-
-
- // Long.TYPE
- converterMap
- .put(
- new Pair(
- "java.lang.String", LONG_TYPE), "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2LongPrimitive"); //$NON-NLS-1$ //$NON-NLS-2$
- converterMap
- .put(
- new Pair(
- LONG_TYPE, "java.lang.Long"), new IdentityConverter(Long.TYPE, Long.class)); //$NON-NLS-1$
- converterMap
- .put(
- new Pair(
- LONG_TYPE, "java.lang.String"), new ToStringConverter(Long.TYPE)); //$NON-NLS-1$
- converterMap
- .put(
- new Pair(
- LONG_TYPE, "java.lang.Object"), new IdentityConverter(Long.TYPE, Object.class)); //$NON-NLS-1$
-
- }
-
- return converterMap;
- }
-
- // --------------------------- OLD
-
- // public IConverter createConverter(Object fromType, Object toType) {
- // if (!(fromType instanceof Class) || !(toType instanceof Class)) {
- // return null;
- // }
- // Class toClass = (Class) toType;
- // if (toClass.isPrimitive()) {
- // toClass = autoboxed(toClass);
- // }
- // Class fromClass = (Class) fromType;
- // if (fromClass.isPrimitive()) {
- // fromClass = autoboxed(fromClass);
- // }
- // if (toClass.isAssignableFrom(fromClass)) {
- // return new IdentityConverter(fromClass, toClass);
- // }
- // Map converterMap = getConverterMap();
- // Class[] supertypeHierarchyFlattened = ClassLookupSupport
- // .getTypeHierarchyFlattened(fromClass);
- // for (int i = 0; i < supertypeHierarchyFlattened.length; i++) {
- // Class currentFromClass = supertypeHierarchyFlattened[i];
- // if (currentFromClass == toType) {
- // // converting to toType is just a widening
- // return new IdentityConverter(fromClass, toClass);
- // }
- // Pair key = new Pair(currentFromClass.getName(), toClass.getName());
- // Object converterOrClassname = converterMap.get(key);
- // if (converterOrClassname instanceof IConverter) {
- // return (IConverter) converterOrClassname;
- // } else if (converterOrClassname instanceof String) {
- // String classname = (String) converterOrClassname;
- // Class converterClass;
- // try {
- // converterClass = Class.forName(classname);
- // IConverter result = (IConverter) converterClass
- // .newInstance();
- // converterMap.put(key, result);
- // return result;
- // } catch (ClassNotFoundException e) {
- // e.printStackTrace();
- // } catch (InstantiationException e) {
- // e.printStackTrace();
- // } catch (IllegalAccessException e) {
- // e.printStackTrace();
- // }
- // }
- // }
- // // Since we found no converter yet, try a "downcast" converter
- // if (fromClass.isAssignableFrom(toClass)) {
- // return new IdentityConverter(fromClass, toClass);
- // }
- // return null;
- // }
- //
- // private Map getConverterMap() {
- // // using string-based lookup avoids loading of too many classes
- // if (converterMap == null) {
- // converterMap = new HashMap();
- // converterMap
- // .put(
- // new Pair("java.util.Date", "java.lang.String"),
- // "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertDate2String");
- // //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- // converterMap
- // .put(
- // new Pair("java.lang.String", "java.math.BigDecimal"),
- // "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2BigDecimal");
- // //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- // converterMap
- // .put(
- // new Pair("java.lang.String", "java.lang.Boolean"),
- // "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2Boolean");
- // //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- // converterMap
- // .put(
- // new Pair("java.lang.String", "java.lang.Byte"),
- // "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2Byte");
- // //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- // converterMap
- // .put(
- // new Pair("java.lang.String", "java.lang.Character"),
- // "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2Character");
- // //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- // converterMap
- // .put(
- // new Pair("java.lang.String", "java.util.Date"),
- // "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2Date");
- // //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- // converterMap
- // .put(
- // new Pair("java.lang.String", "java.lang.Double"),
- // "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2Double");
- // //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- // converterMap
- // .put(
- // new Pair("java.lang.String", "java.lang.Float"),
- // "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2Float");
- // //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- // converterMap
- // .put(
- // new Pair("java.lang.String", "java.lang.Integer"),
- // "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2Integer");
- // //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- // converterMap
- // .put(
- // new Pair("java.lang.String", "java.lang.Long"),
- // "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2Long");
- // //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- // converterMap
- // .put(
- // new Pair("java.lang.String", "java.lang.Short"),
- // "org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2Short");
- // //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- // converterMap
- // .put(
- // new Pair("java.lang.Object", "java.lang.String"),
- // "org.eclipse.jface.internal.databinding.provisional.conversion.ToStringConverter");
- // //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- // }
- // return converterMap;
- // }
-
- // --------------------------- OLD
-
- public IDomainValidator createDomainValidator(Object modelType) {
- return new IDomainValidator() {
- public ValidationError isValid(Object value) {
- return null;
- }
- };
- }
-
- public Boolean isAssignableFromTo(Object fromType, Object toType) {
- if (fromType instanceof Class && toType instanceof Class) {
- Class toClass = (Class) toType;
- if (toClass.isPrimitive()) {
- toClass = autoboxed(toClass);
- }
- Class fromClass = (Class) fromType;
- if (fromClass.isPrimitive()) {
- fromClass = autoboxed(fromClass);
- }
- return Boolean.valueOf((toClass).isAssignableFrom(fromClass));
- }
- return null;
- }
-
- private Class autoboxed(Class clazz) {
- if (clazz == Float.TYPE)
- return Float.class;
- else if (clazz == Double.TYPE)
- return Double.class;
- else if (clazz == Short.TYPE)
- return Short.class;
- else if (clazz == Integer.TYPE)
- return Integer.class;
- else if (clazz == Long.TYPE)
- return Long.class;
- else if (clazz == Byte.TYPE)
- return Byte.class;
- else if (clazz == Boolean.TYPE)
- return Boolean.class;
- return clazz;
- }
-
- private static class ValidatorRegistry {
-
- private HashMap validators = new HashMap();
-
- /**
- * Associate a particular validator that can validate the conversion
- * (fromClass, toClass)
- *
- * @param fromClass
- * The Class to convert from
- * @param toClass
- * The Class to convert to
- * @param validator
- * The IValidator
- */
- private void associate(Object fromClass, Object toClass,
- IValidator validator) {
- validators.put(new Pair(fromClass, toClass), validator);
- }
-
- /**
- * Return an IVerifier for a specific class.
- *
- * @param fromClass
- * The Class to convert from
- * @param toClass
- * The Class to convert to
- * @return An appropriate IValidator
- */
- private IValidator get(Object fromClass, Object toClass) {
- IValidator result = (IValidator) validators.get(new Pair(fromClass,
- toClass));
- if (result != null)
- return result;
- if (fromClass != null && toClass != null && fromClass == toClass) {
- return new IValidator() {
- public ValidationError isPartiallyValid(Object value) {
- return null;
- }
-
- public ValidationError isValid(Object value) {
- return null;
- }
- };
- }
- return ReadOnlyValidator.getDefault();
- }
-
- /**
- * Adds the system-provided validators to the current validator
- * registry. This is done automatically for the validator registry
- * singleton.
- */
- private ValidatorRegistry() {
- // Standalone validators here...
- associate(String.class, Integer.TYPE,
- new String2IntegerPrimitiveValidator());
- associate(String.class, Byte.TYPE,
- new String2BytePrimitiveValidator());
- associate(String.class, Short.TYPE,
- new String2ShortPrimitiveValidator());
- associate(String.class, Long.TYPE,
- new String2LongPrimitiveValidator());
- associate(String.class, Float.TYPE,
- new String2FloatPrimitiveValidator());
- associate(String.class, Double.TYPE,
- new String2DoublePrimitiveValidator());
-
- associate(String.class, Integer.class, new String2IntegerValidator());
- associate(String.class, Byte.class, new String2ByteValidator());
- associate(String.class, Short.class, new String2ShortValidator());
- associate(String.class, Long.class, new String2LongValidator());
- associate(String.class, Float.class, new String2FloatValidator());
- associate(String.class, Double.class, new String2DoubleValidator());
- associate(String.class, Date.class, new String2DateValidator());
-
- associate(String.class, BigDecimal.class,
- new String2BigDecimalValidator());
-
-
- associate(Integer.class, Integer.TYPE, new ObjectToPrimitiveValidator(Integer.TYPE));
- associate(Byte.class, Byte.TYPE, new ObjectToPrimitiveValidator(Byte.TYPE));
- associate(Short.class, Short.TYPE, new ObjectToPrimitiveValidator(Short.TYPE));
- associate(Long.class, Long.TYPE, new ObjectToPrimitiveValidator(Long.TYPE));
- associate(Float.class, Float.TYPE, new ObjectToPrimitiveValidator(Float.TYPE));
- associate(Double.class, Double.TYPE, new ObjectToPrimitiveValidator(Double.TYPE));
- associate(Boolean.class, Boolean.TYPE, new ObjectToPrimitiveValidator(Boolean.TYPE));
-
- associate(Object.class, Integer.TYPE, new ObjectToPrimitiveValidator(Integer.TYPE));
- associate(Object.class, Byte.TYPE, new ObjectToPrimitiveValidator(Byte.TYPE));
- associate(Object.class, Short.TYPE, new ObjectToPrimitiveValidator(Short.TYPE));
- associate(Object.class, Long.TYPE, new ObjectToPrimitiveValidator(Long.TYPE));
- associate(Object.class, Float.TYPE, new ObjectToPrimitiveValidator(Float.TYPE));
- associate(Object.class, Double.TYPE, new ObjectToPrimitiveValidator(Double.TYPE));
- associate(Object.class, Boolean.TYPE, new ObjectToPrimitiveValidator(Boolean.TYPE));
-
- // Regex-implemented validators here...
- // associate(String.class, Character.TYPE, new RegexStringValidator(
- // "^.$|^$", ".",
- // BindingMessages.getString("Validate_CharacterHelp")));
- // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- // associate(String.class, Character.class, new
- // RegexStringValidator(
- // "^.$|^$", ".",
- // BindingMessages.getString("Validate_CharacterHelp")));
- // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- // associate(String.class, Boolean.TYPE, new RegexStringValidator(
- // BindingMessages.getString("Validate_BooleanPartialValidRegex"),
- // //$NON-NLS-1$
- // BindingMessages.getString("Validate_BooleanValidRegex"),
- // //$NON-NLS-1$
- // BindingMessages.getString("Validate_BooleanHelp")));
- // //$NON-NLS-1$
- // associate(String.class, Boolean.class, new RegexStringValidator(
- // BindingMessages.getString("Validate_BooleanPartialValidRegex"),
- // //$NON-NLS-1$
- // BindingMessages.getString("Validate_BooleanValidRegex"),
- // //$NON-NLS-1$
- // BindingMessages.getString("Validate_BooleanHelp")));
- // //$NON-NLS-1$
- // associate(String.class, String.class, new
- // RegexStringValidator("^.*$", "^.*$", "")); //$NON-NLS-1$
- // //$NON-NLS-2$ //$NON-NLS-3$
- }
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindingFactory.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindingFactory.java
deleted file mode 100644
index 5b11dc45..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindingFactory.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.factories;
-
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.databinding.observable.list.IObservableList;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.internal.databinding.internal.LazyListBinding;
-import org.eclipse.jface.internal.databinding.internal.ListBinding;
-import org.eclipse.jface.internal.databinding.internal.ValueBinding;
-import org.eclipse.jface.internal.databinding.provisional.BindSpec;
-import org.eclipse.jface.internal.databinding.provisional.Binding;
-import org.eclipse.jface.internal.databinding.provisional.BindingException;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor;
-import org.eclipse.jface.internal.databinding.provisional.observable.ILazyListElementProvider;
-
-/**
- * @since 3.2
- * @deprecated no longer part of the API
- *
- */
-public class DefaultBindingFactory implements IBindingFactory {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.internal.databinding.provisional.IBindingFactory#createBinding(org.eclipse.jface.internal.databinding.provisional.observable.IObservable,
- * org.eclipse.jface.internal.databinding.provisional.observable.IObservable,
- * org.eclipse.jface.internal.databinding.provisional.BindSpec)
- */
- public Binding createBinding(DataBindingContext dataBindingContext,
- IObservable targetObservable, IObservable modelObservable,
- BindSpec bindSpec) {
- Binding binding;
- if (bindSpec == null) {
- bindSpec = new BindSpec(null, null, null, null);
- }
- if (targetObservable instanceof IObservableValue) {
- if (modelObservable instanceof IObservableValue) {
- IObservableValue target = (IObservableValue) targetObservable;
- IObservableValue model = (IObservableValue) modelObservable;
- dataBindingContext.fillBindSpecDefaults(dataBindingContext,
- bindSpec, target.getValueType(), model.getValueType());
- binding = new ValueBinding(dataBindingContext, target, model,
- bindSpec);
- return binding;
- }
- throw new BindingException(
- "incompatible observables: target is value, model is " + modelObservable.getClass().getName()); //$NON-NLS-1$
- } else if (targetObservable instanceof IObservableList) {
- if (modelObservable instanceof IObservableList) {
- IObservableList target = (IObservableList) targetObservable;
- IObservableList model = (IObservableList) modelObservable;
-
- dataBindingContext.fillBindSpecDefaults(dataBindingContext,
- bindSpec, target.getElementType(), model
- .getElementType());
-
- return new ListBinding(dataBindingContext, target, model,
- bindSpec);
- }
- throw new BindingException(
- "incompatible observable: target is list, model is " + modelObservable.getClass().getName()); //$NON-NLS-1$
- }
- if (targetObservable instanceof ILazyDataRequestor
- && modelObservable instanceof ILazyListElementProvider) {
- if (bindSpec == null) {
- bindSpec = new BindSpec();
- }
- return new LazyListBinding(dataBindingContext,
- (ILazyDataRequestor) targetObservable,
- (ILazyListElementProvider) modelObservable, bindSpec);
- }
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultObservableFactory.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultObservableFactory.java
deleted file mode 100644
index c2feed33..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultObservableFactory.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.factories;
-
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.description.ListModelDescription;
-import org.eclipse.jface.internal.databinding.provisional.description.TableModelDescription;
-
-/**
- * @since 3.2
- * @deprecated no longer part of the API
- *
- */
-public class DefaultObservableFactory implements IObservableFactory {
-
- private final DataBindingContext dataBindingContext;
-
- /**
- * @param dataBindingContext
- * TODO
- *
- */
- public DefaultObservableFactory(DataBindingContext dataBindingContext) {
- this.dataBindingContext = dataBindingContext;
- }
-
- public IObservable createObservable(Object description) {
- if (description instanceof ListModelDescription) {
- ListModelDescription listModelDescription = (ListModelDescription) description;
- TableModelDescription tableModelDescription = new TableModelDescription(
- listModelDescription.getCollectionProperty(),
- new Object[] { listModelDescription.getPropertyID() });
- return dataBindingContext.createObservable(tableModelDescription);
- }
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/IBindingFactory.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/IBindingFactory.java
deleted file mode 100644
index fce61f07..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/IBindingFactory.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.factories;
-
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.internal.databinding.provisional.BindSpec;
-import org.eclipse.jface.internal.databinding.provisional.Binding;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-
-/**
- * @since 1.0
- * @deprecated no longer part of the API
- *
- */
-public interface IBindingFactory {
-
- /**
- * Creates a new binding between the given observable objects, using
- * additional information given in the bind spec. Returns null if this
- * factory cannot create bindings between the given observables.
- * @param dataBindingContext TODO
- * @param target
- * @param model
- * @param bindSpec the bind spec, or null
- *
- * @return a new binding, or null
- */
- public Binding createBinding(DataBindingContext dataBindingContext, IObservable target,
- IObservable model, BindSpec bindSpec);
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/IObservableFactory.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/IObservableFactory.java
deleted file mode 100644
index 0f8a96e8..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/IObservableFactory.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.internal.databinding.provisional.factories;
-
-import org.eclipse.jface.databinding.observable.IObservable;
-
-/**
- * A factory for creating observable objects from description objects.
- * <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
- * @deprecated no longer part of the API
- *
- */
-public interface IObservableFactory {
-
- /**
- * Returns an observable for the given description, or null if this factory
- * cannot create observables for this description. The BindingException is
- * only thrown in error cases, e.g. if the description itself is invalid, or
- * if an error occurred during the creation of the observable.
- * @param description
- *
- * @return an updatable
- */
- IObservable createObservable(Object description);
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/NestedObservableFactory.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/NestedObservableFactory.java
deleted file mode 100644
index 6d84d2b7..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/NestedObservableFactory.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.factories;
-
-import java.beans.BeanInfo;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.util.StringTokenizer;
-
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.internal.databinding.internal.observable.NestedObservableList;
-import org.eclipse.jface.internal.databinding.internal.observable.NestedObservableValue;
-import org.eclipse.jface.internal.databinding.provisional.BindingException;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.description.NestedProperty;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-
-/**
- *
- * TODO Javadoc
- *
- * @since 1.0
- * @deprecated no longer part of the API
- *
- */
-public class NestedObservableFactory implements IObservableFactory {
-
- private final DataBindingContext dataBindingContext;
-
- /**
- * @param dataBindingContext
- * TODO
- *
- */
- public NestedObservableFactory(DataBindingContext dataBindingContext) {
- this.dataBindingContext = dataBindingContext;
- }
-
- public IObservable createObservable(Object description) {
- if (description instanceof NestedProperty) {
- return createNestedObservable((NestedProperty) description,
- dataBindingContext);
- } else if (description instanceof Property) {
- Property propertyDescription = (Property) description;
- Object o = propertyDescription.getObject();
- if (o instanceof IObservableValue) {
- IObservableValue observableValue = (IObservableValue) o;
- Class propertyType = propertyDescription.getPropertyType();
- if (propertyType == null) {
- throw new BindingException(
- "Missing required property type for binding to a property of an IObservableValue."); //$NON-NLS-1$
- }
- Boolean isCollectionProperty = propertyDescription
- .isCollectionProperty();
- if (isCollectionProperty == null) {
- throw new BindingException(
- "Missing required property collection information for binding to a property of an IObservableValue."); //$NON-NLS-1$
- }
- Object propertyID = propertyDescription.getPropertyID();
- if (isCollectionProperty.booleanValue()) {
- return new NestedObservableList(dataBindingContext,
- observableValue, propertyID, propertyType);
- }
- return new NestedObservableValue(dataBindingContext,
- observableValue, propertyID, propertyType);
- }
- // else if (o instanceof List) {
- // return new ListObservableCollection(
- // (List) o,
- // propertyDescription.getPropertyType() == null ? Object.class
- // : propertyDescription.getPropertyType());
- // }
- }
- // else if (description instanceof TreeModelDescription) {
- // TreeModelDescription treeModelDescription = (TreeModelDescription)
- // description;
- // if (treeModelDescription.getRoot() != null) {
- // if (treeModelDescription.getRoot() instanceof IObservable) {
- // if (treeModelDescription.getRoot() instanceof IObservableTree)
- // return (IObservableTree) treeModelDescription
- // .getRoot();
- // // Nest the TreeModelDescription's root
- // return new NestedObservableTree(
- // bindingContext,
- // treeModelDescription);
- // } else if (treeModelDescription.getRoot() instanceof Property) {
- // // Create an Observable for the
- // // TreeModelDescription's root first
- // TreeModelDescription newDescription = new TreeModelDescription(
- // bindingContext
- // .createObservable(treeModelDescription
- // .getRoot()));
- // Class[] types = treeModelDescription.getTypes();
- // for (int i = 0; i < types.length; i++) {
- // String[] props = treeModelDescription
- // .getChildrenProperties(types[i]);
- // for (int j = 0; j < props.length; j++)
- // newDescription.addChildrenProperty(
- // types[i], props[j]);
- // }
- // return bindingContext
- // .createObservable(newDescription);
- // }
- // }
- // return null;
- // } else if (description instanceof TableModelDescription) {
- // TableModelDescription tableModelDescription = (TableModelDescription)
- // description;
- // Object master =
- // tableModelDescription.getCollectionProperty().getObject();
- // if(master instanceof IObservableValue) {
- // return new
- // NestedObservableCellProvider(bindingContext,(IObservableValue)
- // master,tableModelDescription);
- // }
- // }
- return null;
- }
-
- private IObservable createNestedObservable(NestedProperty nestedProperty,
- DataBindingContext bindingContext) {
- IObservable lastChildObservable = null;
- Object targetObject = nestedProperty.getObject();
- if (nestedProperty.getPrototypeClass() != null) {
- Class targetClazz = nestedProperty.getPrototypeClass();
- StringTokenizer tokenizer = new StringTokenizer(
- (String) nestedProperty.getPropertyID(), "."); //$NON-NLS-1$
- while (tokenizer.hasMoreElements()) {
- String nextDesc = (String) tokenizer.nextElement();
- try {
- BeanInfo beanInfo = Introspector.getBeanInfo(targetClazz);
- PropertyDescriptor[] propertyDescriptors = beanInfo
- .getPropertyDescriptors();
- Class discoveredClazz = null;
- for (int i = 0; i < propertyDescriptors.length; i++) {
- PropertyDescriptor descriptor = propertyDescriptors[i];
- if (descriptor.getName().equals(nextDesc)) {
- discoveredClazz = descriptor.getPropertyType();
- break;
- }
- }
- if (discoveredClazz != null) {
- targetClazz = discoveredClazz;
- } else {
- throw new BindingException(
- "Error using prototype class to determine binding types."); //$NON-NLS-1$
- }
- } catch (BindingException be) {
- throw be;
- } catch (Exception e) {
- e.printStackTrace();
- throw new BindingException(
- "Exeception using prototype class to determine binding types.", e); //$NON-NLS-1$
- }
- lastChildObservable = bindingContext
- .createObservable(new Property(targetObject, nextDesc,
- targetClazz, Boolean.FALSE));
- targetObject = lastChildObservable;
- }
-
- } else {
- String[] properties = (String[]) nestedProperty.getPropertyID();
- for (int i = 0; i < properties.length; i++) {
- String nextDesc = properties[i];
- Class clazz = nestedProperty.getTypes()[i];
- lastChildObservable = bindingContext
- .createObservable(new Property(targetObject, nextDesc,
- clazz, Boolean.FALSE));
- targetObject = lastChildObservable;
- }
- }
- return lastChildObservable;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/ILazyDataRequestor.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/ILazyDataRequestor.java
deleted file mode 100644
index 228afe29..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/ILazyDataRequestor.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.internal.databinding.provisional.observable;
-
-import org.eclipse.jface.databinding.observable.IObservable;
-
-
-/**
- * Marker interface for Observables that request data lazily.
- *
- * @since 3.3
- */
-public interface ILazyDataRequestor extends IObservable {
- /**
- * Represents a new object that was inserted into a lazy collection.
- * @since 3.3
- */
- public static class NewObject {
- /**
- * The position where the insert actually occurred
- */
- public int position;
-
- /**
- * The object that was inserted
- */
- public Object it;
-
- /**
- * @param position The position where the insert actually occurred
- * @param it The object that was inserted
- */
- public NewObject(int position, Object it) {
- this.position = position;
- this.it = it;
- }
- }
-
- /**
- * Sets the number of elements in the entire list that we are browsing.
- * Refreshes all visible elements in the list by retrieving them again
- * from the underlying model.
- *
- * @param size The new size to set.
- */
- void setSize(int size);
-
- /**
- * Adds the listener to the set of listeners that will be invoked when
- * a method in the ILazyElementListener interface is invoked.
- *
- * @param p The listener to add.
- */
- void addElementProvider(ILazyListElementProvider p);
-
- /**
- * Removes the listener from the set of listeners that will be invoked when
- * a method in the ILazyElementListener interface is invoked.
- *
- * @param p The listener to remove.
- */
- void removeElementProvider(ILazyListElementProvider p);
-
- /**
- * Adds the listener to the set of listeners that will be invoked when
- * a method in the LazyInsertDeleteProvider interface is invoked.
- *
- * @param p The listener to add.
- */
- void addInsertDeleteProvider(LazyInsertDeleteProvider p);
-
- /**
- * Removes the listener from the set of listeners that will be invoked when
- * a method in the LazyInsertDeleteProvider interface is invoked.
- *
- * @param p The listener to remove.
- */
- void removeInsertDeleteProvider(LazyInsertDeleteProvider p);
-
- /**
- * Notifies the receiver that the specified element was added to the observed
- * list at the specified position.
- *
- * @param position The position to insert the object
- * @param element The object to insert
- */
- void add(int position, Object element);
-
- /**
- * Notifies the receiver that the object at the specified position was
- * removed from the observed list.
- *
- * @param position The position where the delete occurred
- */
- void remove(int position);
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/ILazyListElementProvider.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/ILazyListElementProvider.java
deleted file mode 100644
index fe75b66c..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/ILazyListElementProvider.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.internal.databinding.provisional.observable;
-
-import org.eclipse.jface.databinding.observable.list.IObservableList;
-
-/**
- * Interface for Observables that can supply data lazily.
- *
- * @since 3.3
- */
-public interface ILazyListElementProvider extends IObservableList {
- /**
- * @param position The 0-based position in the receiver's collection
- * of the object to retrieve.
- *
- * @return The requested object.
- */
- abstract public Object get(int position);
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/LazyDeleteEvent.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/LazyDeleteEvent.java
deleted file mode 100644
index 84cd3282..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/LazyDeleteEvent.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.internal.databinding.provisional.observable;
-
-/**
- * Represents the data required to delete a new object from a lazy list.
- *
- * @since 3.3
- */
-public class LazyDeleteEvent {
- /**
- * The position of the object that must be deleted.
- */
- public final int position;
-
- /**
- * Construct a LazyDeleteEvent.
- *
- * @param position The 0-based position of the object that must be deleted.
- */
- public LazyDeleteEvent(final int position) {
- this.position = position;
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/LazyInsertDeleteProvider.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/LazyInsertDeleteProvider.java
deleted file mode 100644
index d474b3b2..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/LazyInsertDeleteProvider.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.internal.databinding.provisional.observable;
-
-/**
- * An API for objects that can perform inserts and/or deletes in a collection
- * upon request. This class supplies empty implementations of its methods and
- * is intended to be subclassed by clients.
- *
- * @since 3.3
- */
-public class LazyInsertDeleteProvider {
- /**
- * Requests that the client insert a new element at the specified position.
- * Clients are free to use or ignore the position (it's a hint) according
- * to their own policy.
- *
- * @param e the LazyInsertEvent TODO
- *
- * @return An ILazyDataRequestor.NewObject containing the actual position
- * where the object was inserted and the new object that was inserted, or
- * null to indicate that no object was inserted.
- */
- public ILazyDataRequestor.NewObject insertElementAt(LazyInsertEvent e) {
- return null;
- }
-
- /**
- * Returns if the client can delete the object at the specified position.
- *
- * @param e The position of the object to delete.
- * @return true if the object can be deleted; false otherwise.
- */
- public boolean canDeleteElementAt(LazyDeleteEvent e) {
- return false;
- }
-
- /**
- * Requests that the client delete the object at the specified position.
- *
- * @param e LazyInsertEvent TODO
- */
- public void deleteElementAt(LazyDeleteEvent e) {
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/LazyInsertEvent.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/LazyInsertEvent.java
deleted file mode 100644
index 00413ad0..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/LazyInsertEvent.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.internal.databinding.provisional.observable;
-
-/**
- * Represents the data required to insert a new object into a lazy list.
- *
- * @since 3.3
- */
-public class LazyInsertEvent {
- /**
- * The position where the target list is requesting that the model insert
- * the new object in its list. This is a *hint*. The model is free to
- * insert the event wherever it wishes according to its internal semantics.
- * (It must just return the actual place where the insert occurred back to
- * the target object.)
- */
- public final int positionHint;
-
- /**
- * A field that implementations may use to pass application-specific data
- * from the target list to the insert event handlers. This field may be null.
- */
- public final Object initializationData;
-
- /**
- * Construct a LazyInsertEvent.
- *
- * @param positionHint The position where the target is requesting the insert to occur.
- * @param initializationData Application-specific initialization data. This may be null.
- */
- public LazyInsertEvent(final int positionHint, final Object initializationData) {
- this.positionHint = positionHint;
- this.initializationData = initializationData;
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/AbstractObservableMapping.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/AbstractObservableMapping.java
deleted file mode 100644
index 843ad098..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/AbstractObservableMapping.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.observable.mapping;
-
-
-import org.eclipse.jface.databinding.observable.ObservableTracker;
-
-/**
- * @since 1.0
- *
- */
-public abstract class AbstractObservableMapping extends BaseObservableMapping
- implements IObservableMapping {
-
- final public Object getMappingValue(Object element) {
- ObservableTracker.getterCalled(this);
- return doGetMappingValue(element);
- }
-
- public void setMappingValue(Object element, Object value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @return the value of this mapping for the given element
- */
- abstract protected Object doGetMappingValue(Object element);
-
- public boolean isStale() {
- return false;
- }
-
- public void dispose() {
- mappingChangeListeners = null;
- super.dispose();
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/AbstractObservableMultiMapping.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/AbstractObservableMultiMapping.java
deleted file mode 100644
index 7c3ad2bf..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/AbstractObservableMultiMapping.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.observable.mapping;
-
-
-import org.eclipse.jface.databinding.observable.ObservableTracker;
-
-/**
- * @since 1.0
- *
- */
-public abstract class AbstractObservableMultiMapping extends BaseObservableMapping
- implements IObservableMultiMapping {
-
- final public Object[] getMappingValues(Object element, int[] indices) {
- ObservableTracker.getterCalled(this);
- return doGetMappingValues(element, indices);
- }
-
- public void setMappingValues(Object element, int[] indices, Object[] values) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @param indices
- * @return the value of this mapping for the given element
- */
- abstract protected Object[] doGetMappingValues(Object element, int[] indices);
-
- public boolean isStale() {
- return false;
- }
-
- public void dispose() {
- mappingChangeListeners = null;
- super.dispose();
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/BaseObservableMapping.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/BaseObservableMapping.java
deleted file mode 100644
index 6e5c3417..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/BaseObservableMapping.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.observable.mapping;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.jface.databinding.observable.AbstractObservable;
-import org.eclipse.jface.databinding.observable.IChangeListener;
-
-/**
- * @since 3.2
- *
- */
-public abstract class BaseObservableMapping extends AbstractObservable {
-
- /**
- * Points to an instance of IChangeListener or a Collection of
- * IMappingChangeListener
- */
- protected Object mappingChangeListeners = null;
-
- /**
- * @param listener
- */
- public void addMappingChangeListener(IMappingChangeListener listener) {
- if (mappingChangeListeners == null) {
- boolean hadListeners = hasListeners();
- mappingChangeListeners = listener;
- if (!hadListeners) {
- firstListenerAdded();
- }
- return;
- }
-
- Collection listenerList;
- if (mappingChangeListeners instanceof IMappingChangeListener) {
- IChangeListener l = (IChangeListener) mappingChangeListeners;
-
- listenerList = new ArrayList();
- listenerList.add(l);
- mappingChangeListeners = listenerList;
- } else {
- listenerList = (Collection) mappingChangeListeners;
- }
-
- listenerList.add(listener);
- }
-
- /**
- * @param listener
- */
- public void removeMappingChangeListener(IMappingChangeListener listener) {
- if (mappingChangeListeners == listener) {
- mappingChangeListeners = null;
- if (!hasListeners()) {
- lastListenerRemoved();
- }
- return;
- }
-
- if (mappingChangeListeners instanceof Collection) {
- Collection listenerList = (Collection) mappingChangeListeners;
- listenerList.remove(listener);
- if (listenerList.isEmpty()) {
- mappingChangeListeners = null;
- if (!hasListeners()) {
- lastListenerRemoved();
- }
- }
- }
- }
-
- protected void fireMappingValueChange(MappingDiff diff) {
- if (mappingChangeListeners == null) {
- return;
- }
-
- if (mappingChangeListeners instanceof IMappingChangeListener) {
- ((IMappingChangeListener) mappingChangeListeners).handleMappingValueChange(this, diff);
- return;
- }
-
- Collection changeListenerCollection = (Collection) mappingChangeListeners;
-
- IMappingChangeListener[] listeners = (IMappingChangeListener[]) (changeListenerCollection)
- .toArray(new IMappingChangeListener[changeListenerCollection.size()]);
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].handleMappingValueChange(this, diff);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/BidirectionalMapping.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/BidirectionalMapping.java
deleted file mode 100644
index ca8af91d..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/BidirectionalMapping.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.observable.mapping;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.databinding.observable.set.IObservableSet;
-import org.eclipse.jface.databinding.observable.set.ISetChangeListener;
-import org.eclipse.jface.databinding.observable.set.SetDiff;
-import org.eclipse.jface.databinding.observable.set.WritableSet;
-
-/**
- * @since 1.0
- *
- */
-public class BidirectionalMapping extends AbstractObservableMapping implements
- IBidirectionalMapping, IObservableMappingWithDomain {
-
- private final IObservableMapping wrappedMapping;
-
- private IObservableSet range;
-
- private Map valueToElements = new HashMap();
-
- private ISetChangeListener domainListener = new ISetChangeListener() {
- public void handleSetChange(IObservableSet source, SetDiff diff) {
- Set rangeAdditions = new HashSet();
- for (Iterator it = diff.getAdditions().iterator(); it.hasNext();) {
- Object added = it.next();
- Object mappingValue = wrappedMapping.getMappingValue(added);
- rangeAdditions.add(mappingValue);
- addMapping(mappingValue, added);
- }
- range.addAll(rangeAdditions);
- for (Iterator it = diff.getRemovals().iterator(); it.hasNext();) {
- Object removed = it.next();
- removeMapping(wrappedMapping.getMappingValue(removed), removed);
- }
- range.retainAll(valueToElements.keySet());
- }
- };
-
- private IMappingChangeListener mappingChangeListener = new IMappingChangeListener() {
- public void handleMappingValueChange(IObservable source,
- MappingDiff diff) {
- Set affectedElements = diff.getElements();
- for (Iterator it = affectedElements.iterator(); it.hasNext();) {
- Object element = it.next();
- Object oldFunctionValue = diff.getOldMappingValues(element,
- new int[0])[0];
- Object newFunctionValue = diff.getNewMappingValues(element,
- new int[0])[0];
- removeMapping(oldFunctionValue, element);
- addMapping(newFunctionValue, element);
- }
- Set tempRange = valueToElements.keySet();
- range.addAll(tempRange);
- range.retainAll(tempRange);
- fireMappingValueChange(diff);
- }
- };
-
- private IObservableSet domain;
-
- /**
- * @param functionWithDomain
- */
- public BidirectionalMapping(IObservableMappingWithDomain functionWithDomain) {
- this(functionWithDomain, functionWithDomain.getDomain());
- }
-
- /**
- * @param wrappedMapping
- * @param domain
- */
- public BidirectionalMapping(IObservableMapping wrappedMapping,
- IObservableSet domain) {
- this.wrappedMapping = wrappedMapping;
- this.domain = domain;
- Set tempRange = new HashSet();
- for (Iterator it = domain.iterator(); it.hasNext();) {
- Object element = it.next();
- Object functionValue = wrappedMapping.getMappingValue(element);
- addMapping(functionValue, element);
- tempRange.add(functionValue);
- }
- this.range = new WritableSet(tempRange);
- domain.addSetChangeListener(domainListener);
- }
-
- /**
- * @param functionValue
- * @param element
- * @param b
- */
- private void addMapping(Object functionValue, Object element) {
- Object elementOrSet = valueToElements.get(functionValue);
- if (elementOrSet == null) {
- valueToElements.put(functionValue, element);
- return;
- }
- if (!(elementOrSet instanceof Set)) {
- elementOrSet = new HashSet(Collections.singleton(elementOrSet));
- valueToElements.put(functionValue, elementOrSet);
- }
- Set set = (Set) elementOrSet;
- set.add(element);
- }
-
- /**
- * @param functionValue
- * @param element
- * @param b
- */
- private void removeMapping(Object functionValue, Object element) {
- Object elementOrSet = valueToElements.get(functionValue);
- if (elementOrSet instanceof Set) {
- Set set = (Set) elementOrSet;
- set.remove(element);
- if (set.size() == 0) {
- valueToElements.remove(functionValue);
- }
- } else {
- valueToElements.remove(functionValue);
- }
- }
-
- protected Object doGetMappingValue(Object element) {
- return wrappedMapping.getMappingValue(element);
- }
-
- public void setMappingValue(Object element, Object value) {
- wrappedMapping.setMappingValue(element, value);
- }
-
- public IObservableSet getRange() {
- return range;
- }
-
- public Set getDomainElementsForValue(Object value) {
- return null;
- }
-
- public void dispose() {
- wrappedMapping.removeMappingChangeListener(mappingChangeListener);
- domain.removeSetChangeListener(domainListener);
- }
-
- public IObservableSet getDomain() {
- return domain;
- }
-
- public Object getValueType() {
- return wrappedMapping.getValueType();
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IBidirectionalMapping.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IBidirectionalMapping.java
deleted file mode 100644
index 8d601933..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IBidirectionalMapping.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.observable.mapping;
-
-import java.util.Set;
-
-import org.eclipse.jface.databinding.observable.set.IObservableSet;
-
-/**
- * A bidirectional mapping whose changes can be tracked by a mapping change listener.
- *
- * <p>
- * This interface is not intended to be implemented by clients. Clients should
- * instead subclass one of the classes that implement this interface. Note that
- * direct implementers of this interface outside of the framework will be broken
- * in future releases when methods are added to this interface.
- * </p>
- *
- * @since 1.0
- *
- */
-public interface IBidirectionalMapping extends IObservableMapping {
-
- /**
- * Returns the current set of actual results of the function. Callers can
- * register listeners on this set to respond to changes in the range of the
- * function.
- *
- * @return the set of possible results of the function.
- */
- public IObservableSet getRange();
-
- /**
- * Returns the set of elements in the domain that map onto the given value
- * from the range. That is, it returns the set of objects that you can pass
- * to getFunctionValue that will end up returning the given value.
- *
- * @param value
- * element from the range
- * @return collection of all elements in the d
- */
- public Set getDomainElementsForValue(Object value);
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IMapping.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IMapping.java
deleted file mode 100644
index bd3eb544..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IMapping.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.observable.mapping;
-
-/**
- * @since 3.2
- *
- */
-public interface IMapping {
-
- /**
- * @param element
- * @return the mapping value for the given element
- */
- public Object getMappingValue(Object element);
-
- /**
- * @param element
- * @param value
- */
- public void setMappingValue(Object element, Object value);
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IMappingChangeListener.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IMappingChangeListener.java
deleted file mode 100644
index 14772e63..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IMappingChangeListener.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.observable.mapping;
-
-import org.eclipse.jface.databinding.observable.IObservable;
-
-/**
- * @since 1.0
- *
- */
-public interface IMappingChangeListener {
-
- /**
- * @param source
- * @param diff
- */
- void handleMappingValueChange(IObservable source,
- MappingDiff diff);
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IMultiMapping.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IMultiMapping.java
deleted file mode 100644
index 20e04ddd..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IMultiMapping.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.observable.mapping;
-
-/**
- * @since 3.2
- *
- */
-public interface IMultiMapping {
-
- /**
- * @param element
- * @param indices
- * @return the mapping value for the given element
- */
- public Object[] getMappingValues(Object element, int[] indices);
-
- /**
- * @param element
- * @param indices
- * @param values
- */
- public void setMappingValues(Object element, int[] indices, Object[] values);
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IObservableMapping.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IObservableMapping.java
deleted file mode 100644
index 7310652f..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IObservableMapping.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.observable.mapping;
-
-import org.eclipse.jface.databinding.observable.IObservable;
-
-/**
- * A mapping whose changes can be tracked by mapping change listeners.
- *
- * <p>
- * This interface is not intended to be implemented by clients. Clients should
- * instead subclass one of the classes that implement this interface. Note that
- * direct implementers of this interface outside of the framework will be broken
- * in future releases when methods are added to this interface.
- * </p>
- *
- * @since 1.0
- *
- */
-public interface IObservableMapping extends IObservable, IMapping {
-
- /**
- * @param listener
- */
- public void addMappingChangeListener(IMappingChangeListener listener);
-
- /**
- * @param listener
- */
- public void removeMappingChangeListener(IMappingChangeListener listener);
-
- /**
- * @return the type of the values
- */
- public Object getValueType();
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IObservableMappingWithDomain.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IObservableMappingWithDomain.java
deleted file mode 100644
index 63aaab3c..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IObservableMappingWithDomain.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.observable.mapping;
-
-import org.eclipse.jface.databinding.observable.set.IObservableSet;
-
-/**
- * A mapping with domain whose changes can be tracked by mapping change listeners.
- * <p>
- * This interface is not intended to be implemented by clients. Clients should
- * instead subclass one of the classes that implement this interface. Note that
- * direct implementers of this interface outside of the framework will be broken
- * in future releases when methods are added to this interface.
- * </p>
- *
- * @since 1.0
- *
- */
-public interface IObservableMappingWithDomain extends IObservableMapping {
-
- /**
- * @return the domain of this mapping (the set of elements that can be mapped)
- */
- public IObservableSet getDomain();
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IObservableMultiMapping.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IObservableMultiMapping.java
deleted file mode 100644
index 7ee86938..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IObservableMultiMapping.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.observable.mapping;
-
-import org.eclipse.jface.databinding.observable.IObservable;
-
-/**
- * A mapping that maps objects to multiple values, whose changes can be tracked by
- * mapping change listeners.
- *
- * <p>
- * This interface is not intended to be implemented by clients. Clients should
- * instead subclass one of the classes that implement this interface. Note that
- * direct implementers of this interface outside of the framework will be broken
- * in future releases when methods are added to this interface.
- * </p>
- *
- * @since 1.0
- *
- */
-public interface IObservableMultiMapping extends IObservable, IMultiMapping {
-
- /**
- * @param listener
- */
- public void addMappingChangeListener(IMappingChangeListener listener);
-
- /**
- * @param listener
- */
- public void removeMappingChangeListener(IMappingChangeListener listener);
-
- /**
- * @return the types of the values
- */
- public Object[] getValueTypes();
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IObservableMultiMappingWithDomain.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IObservableMultiMappingWithDomain.java
deleted file mode 100644
index 464d424e..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/IObservableMultiMappingWithDomain.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.observable.mapping;
-
-import org.eclipse.jface.databinding.observable.IObservableCollection;
-
-/**
- * An observable multi-mapping with domain.
- *
- * <p>
- * This interface is not intended to be implemented by clients. Clients should
- * instead subclass one of the classes that implement this interface. Note that
- * direct implementers of this interface outside of the framework will be broken
- * in future releases when methods are added to this interface.
- * </p>
- *
- * @since 1.0
- *
- */
-public interface IObservableMultiMappingWithDomain extends
- IObservableMultiMapping {
-
- /**
- * @return the domain
- */
- public IObservableCollection getDomain();
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/MappingDiff.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/MappingDiff.java
deleted file mode 100644
index 593c9f30..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/MappingDiff.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.observable.mapping;
-
-import java.util.Set;
-
-import org.eclipse.jface.databinding.observable.IDiff;
-
-/**
- * @since 1.0
- *
- */
-public abstract class MappingDiff implements IDiff {
- /**
- * @return the set of elements for which the mapping value has changed
- */
- public abstract Set getElements();
-
- /**
- * @return an array containing the affected indices.
- */
- public abstract int[] getAffectedIndices();
-
- /**
- * @param element
- * @param indices
- * @return the old values of the mapping for the given element at the given
- * indices.
- */
- public abstract Object[] getOldMappingValues(Object element, int[] indices);
-
- /**
- * @param element
- * @param indices
- * @return the new value of the mapping for the given element
- */
- public abstract Object[] getNewMappingValues(Object element, int[] indices);
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/ObservableMappingWithDomain.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/ObservableMappingWithDomain.java
deleted file mode 100644
index ba1cab3e..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/ObservableMappingWithDomain.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.observable.mapping;
-
-import java.util.Iterator;
-
-import org.eclipse.jface.databinding.observable.set.IObservableSet;
-import org.eclipse.jface.databinding.observable.set.ISetChangeListener;
-import org.eclipse.jface.databinding.observable.set.SetDiff;
-
-/**
- * @since 1.0
- *
- */
-abstract public class ObservableMappingWithDomain extends AbstractObservableMapping implements IObservableMappingWithDomain {
-
- private ISetChangeListener listener = new ISetChangeListener() {
- public void handleSetChange(IObservableSet source, SetDiff diff) {
- for (Iterator it = diff.getAdditions().iterator(); it.hasNext();) {
- addListenerTo(it.next());
- }
- for (Iterator it = diff.getRemovals().iterator(); it.hasNext();) {
- removeListenerFrom(it.next());
- }
- }
- };
-
- private IObservableSet domain;
-
- /**
- *
- */
- public ObservableMappingWithDomain() {
- }
-
- /**
- * @param domain
- */
- protected void initDomain(IObservableSet domain) {
- this.domain = domain;
- domain.addSetChangeListener(listener);
- for (Iterator it = domain.iterator(); it.hasNext();) {
- addListenerTo(it.next());
- }
- }
-
- /**
- * @return Returns the domain.
- */
- public IObservableSet getDomain() {
- return domain;
- }
-
- /**
- * @param domainElement
- */
- protected abstract void addListenerTo(Object domainElement);
-
- /**
- * @param domainElement
- */
- protected abstract void removeListenerFrom(Object domainElement);
-
- public void dispose() {
- for (Iterator iter = domain.iterator(); iter.hasNext();) {
- removeListenerFrom(iter.next());
- }
- domain.removeSetChangeListener(listener);
- super.dispose();
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/ObservableMultiMappingWithDomain.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/ObservableMultiMappingWithDomain.java
deleted file mode 100644
index 23ca0f3a..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/observable/mapping/ObservableMultiMappingWithDomain.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.observable.mapping;
-
-import java.util.Iterator;
-
-import org.eclipse.jface.databinding.observable.IObservableCollection;
-import org.eclipse.jface.databinding.observable.list.IListChangeListener;
-import org.eclipse.jface.databinding.observable.list.IObservableList;
-import org.eclipse.jface.databinding.observable.list.ListDiff;
-import org.eclipse.jface.databinding.observable.list.ListDiffEntry;
-import org.eclipse.jface.databinding.observable.set.IObservableSet;
-import org.eclipse.jface.databinding.observable.set.ISetChangeListener;
-import org.eclipse.jface.databinding.observable.set.SetDiff;
-
-/**
- * @since 1.0
- *
- */
-abstract public class ObservableMultiMappingWithDomain extends
- AbstractObservableMultiMapping implements
- IObservableMultiMappingWithDomain {
-
- private ISetChangeListener listener = new ISetChangeListener() {
- public void handleSetChange(IObservableSet source, SetDiff diff) {
- for (Iterator it = diff.getAdditions().iterator(); it.hasNext();) {
- addListenerTo(it.next());
- }
- for (Iterator it = diff.getRemovals().iterator(); it.hasNext();) {
- removeListenerFrom(it.next());
- }
- }
- };
-
- private IListChangeListener listListener = new IListChangeListener() {
-
- public void handleListChange(IObservableList source, ListDiff diff) {
- ListDiffEntry[] entries = diff.getDifferences();
- for (int i = 0; i < entries.length; i++) {
- ListDiffEntry entry = entries[i];
- if (entry.isAddition()) {
- addListenerTo(entry.getElement());
- } else {
- removeListenerFrom(entry.getElement());
- }
- }
- }
- };
-
- private IObservableCollection domain;
-
- /**
- *
- */
- public ObservableMultiMappingWithDomain() {
- }
-
- /**
- * @param domain
- */
- protected void initDomain(IObservableCollection domain) {
- this.domain = domain;
- if (domain instanceof IObservableList) {
- IObservableList listDomain = (IObservableList) domain;
- listDomain.addListChangeListener(listListener);
- } else {
- ((IObservableSet) domain).addSetChangeListener(listener);
- }
- for (Iterator it = getDomainIterator(domain); it.hasNext();) {
- addListenerTo(it.next());
- }
- }
-
- private Iterator getDomainIterator(IObservableCollection domain) {
- Iterator it;
- if (domain instanceof IObservableList) {
- IObservableList listDomain = (IObservableList) domain;
- it = listDomain.iterator();
- } else {
- IObservableSet setDomain = (IObservableSet) domain;
- it = setDomain.iterator();
- }
- return it;
- }
-
- /**
- * @return Returns the domain.
- */
- public IObservableCollection getDomain() {
- return domain;
- }
-
- /**
- * @param domainElement
- */
- protected abstract void addListenerTo(Object domainElement);
-
- /**
- * @param domainElement
- */
- protected abstract void removeListenerFrom(Object domainElement);
-
- public void dispose() {
- for (Iterator iter = getDomainIterator(domain); iter.hasNext();) {
- removeListenerFrom(iter.next());
- }
- if (domain instanceof IObservableList) {
- IObservableList listDomain = (IObservableList) domain;
- listDomain.removeListChangeListener(listListener);
- } else {
- IObservableSet setDomain = (IObservableSet) domain;
- setDomain.removeSetChangeListener(listener);
- }
- super.dispose();
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/IDomainValidator.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/IDomainValidator.java
deleted file mode 100644
index 25449678..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/IDomainValidator.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Coconut Palm Software, Inc. 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:
- * Coconut Palm Software, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.internal.databinding.provisional.validation;
-
-/**
- * A validator for domain model values. If this validator is associated with
- * a binding (via an BindSpec), then it will be applied immediately before
- * a value is stored in the model object. This validator operates in the
- * model's data type (after the conversion function object has been applied,
- * if applicable) and is responsible for applying range checks, special
- * formatting requirements, and so on.
- * <p>
- *
- * FIXME: This is wrong. See bug #128142. Eventually this class will go away
- * and be replaced entirely by IValidator.
- *
- * <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 interface IDomainValidator {
-
- /**
- * Determines if the given value is valid.
- *
- * @param value
- * the value to validate
- * @return the error message, or </code>null</code> if the value is valid.
- */
- public ValidationError isValid(Object value);
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/IValidator.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/IValidator.java
deleted file mode 100644
index d5fe0a1f..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/IValidator.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.internal.databinding.provisional.validation;
-
-
-/**
- * A validator. This validator is responsible for telling clients if its associated
- * type conversion function will succeed or fail. For example, a String2IntValidator would
- * only accept source Strings that can successfully be converted to an integer value.
- * <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 interface IValidator {
-
- /**
- * Determines if the given value is partially valid. This method is used to
- * determine, for example, if keystrokes can still be applied to the value.
- *
- * @param value
- * the value to validate
- * @return the ValidationError, or </code>null</code> if the value is
- * partially valid.
- */
- public ValidationError isPartiallyValid(Object value);
-
- /**
- * Determines if the given value is valid, that is if it can successfully
- * be converted to the target data type.
- *
- * @param value
- * the value to validate
- * @return the ValidationError, or </code>null</code> if the value is valid.
- */
- public ValidationError isValid(Object value);
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/ObjectToPrimitiveValidator.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/ObjectToPrimitiveValidator.java
deleted file mode 100644
index cdaf88b7..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/ObjectToPrimitiveValidator.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.validation;
-
-import org.eclipse.jface.internal.databinding.internal.BindingMessages;
-
-/**
- * @since 3.2
- *
- */
-public class ObjectToPrimitiveValidator implements IValidator {
-
- private Class toType;
-
-
- private Class[][] primitiveMap = new Class[][] {
- {Integer.TYPE, Integer.class},
- {Short.TYPE, Short.class},
- {Long.TYPE, Long.class},
- {Double.TYPE, Double.class},
- {Byte.TYPE, Byte.class},
- {Float.TYPE, Float.class},
- {Boolean.TYPE, Boolean.class},
- };
-
- /**
- * @param toType
- */
- public ObjectToPrimitiveValidator(Class toType) {
- this.toType = toType;
- }
-
- protected Class getToType() {
- return this.toType;
- }
-
- public ValidationError isPartiallyValid(Object value) {
- return validate(value);
- }
-
- public ValidationError isValid(Object value) {
- return validate(value);
- }
-
- private ValidationError validate(Object value) {
- if (value != null) {
- if (!mapContainsValues(toType, value.getClass())) {
- return ValidationError.error(getClassHint());
- }
- return null;
- }
- return ValidationError.error(getNullHint());
- }
-
- /**
- * @param toType2
- * @param class1
- * @return
- */
- private boolean mapContainsValues(Class toType, Class fromType) {
- for (int i = 0; i < primitiveMap.length; i++) {
- if ((primitiveMap[i][0].equals(toType)) && (primitiveMap[i][1].equals(fromType))) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * @return
- */
- public String getNullHint() {
- return BindingMessages.getString("Validate_ConversionToPrimitive"); //$NON-NLS-1$
- }
-
- /**
- * @return
- */
- public String getClassHint() {
- return BindingMessages.getString("Validate_ConversionFromClassToPrimitive"); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/ReadOnlyValidator.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/ReadOnlyValidator.java
deleted file mode 100644
index 0e1511b9..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/ReadOnlyValidator.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-
-package org.eclipse.jface.internal.databinding.provisional.validation;
-
-import org.eclipse.jface.internal.databinding.internal.BindingMessages;
-
-/**
- * ReadOnlyValidator. The validator that can be used for read-only fields.
- */
-public class ReadOnlyValidator implements IValidator {
-
- private static ReadOnlyValidator singleton = null;
-
- /**
- * Returns the ReadOnlyValidator
- *
- * @return the ReadOnlyValidator
- */
- public static ReadOnlyValidator getDefault() {
- if (singleton == null) {
- singleton = new ReadOnlyValidator();
- }
- return singleton;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.validator.IValidator#isPartiallyValid(java.lang.Object)
- */
- public ValidationError isPartiallyValid(Object fragment) {
- // No changes are allowed
- return ValidationError.error(BindingMessages.getString("Validate_NoChangeAllowedHelp")); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ICellEditorValidator#isValid(java.lang.Object)
- */
- public ValidationError isValid(Object value) {
- // The current value is always valid
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/RegexStringValidator.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/RegexStringValidator.java
deleted file mode 100644
index b8006318..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/RegexStringValidator.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-
-package org.eclipse.jface.internal.databinding.provisional.validation;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-
-/**
- * RegularExpressionVerifier. A generic String validator that uses regular expressions to
- * specify validation rules.
- */
-public class RegexStringValidator implements IValidator {
-
- private Pattern fragmentRegex;
- private Pattern fullValueRegex;
- private String hint;
-
- /**
- * Constructor RegularExpressionValidator. Construct a string validator based on regular
- * expressions.
- *
- * Verify input using regular expressions.
- *
- * @param partiallyValidRegex A regex that matches iff the value is partially valid
- * @param fullyValidRegex A regex that matches iff the value is fully valid
- * @param hint The hint to display if the value is invalid
- */
- public RegexStringValidator(String partiallyValidRegex,
- String fullyValidRegex, String hint) {
- super();
- this.fragmentRegex = Pattern.compile(partiallyValidRegex);
- this.fullValueRegex = Pattern.compile(fullyValidRegex);
- this.hint = hint;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.validator.IValidator#isPartiallyValid(java.lang.Object)
- */
- public ValidationError isPartiallyValid(Object fragment) {
- Matcher matcher = fragmentRegex.matcher((String)fragment);
- if (matcher.find())
- return null;
-
- return ValidationError.error(hint);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ICellEditorValidator#isValid(java.lang.Object)
- */
- public ValidationError isValid(Object value) {
- String stringValue = (String) value;
- Matcher matcher = fullValueRegex.matcher(stringValue);
- if (matcher.find())
- return null;
-
- return ValidationError.error(hint);
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2BigDecimalValidator.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2BigDecimalValidator.java
deleted file mode 100644
index 7d025a2e..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2BigDecimalValidator.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.validation;
-
-import java.math.BigDecimal;
-
-import org.eclipse.jface.internal.databinding.internal.BindingMessages;
-
-
-/**
- * DoubleValidator. Verify data input for Doubles
- *
- * @author djo
- */
-public class String2BigDecimalValidator implements IValidator {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.validator.IValidator#isPartiallyValid(java.lang.Object)
- */
- public ValidationError isPartiallyValid(Object fragment) {
- if (((String)fragment).matches("\\-?[0-9]*\\.?[0-9]*([0-9]+[e|E]\\-?([0-9]+\\.)?[0-9]*)?")) //$NON-NLS-1$
- return null;
-
- return ValidationError.error(getHint());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ICellEditorValidator#isValid(java.lang.Object)
- */
- public ValidationError isValid(Object value) {
- try {
- new BigDecimal((String)value);
- return null;
- } catch (Throwable t) {
- return ValidationError.error(getHint());
- }
- }
-
- private String getHint() {
- return BindingMessages.getString("Validate_Like") + //$NON-NLS-1$
- BindingMessages.getString("Validate_Number_Examples"); //$NON-NLS-1$
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2BytePrimitiveValidator.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2BytePrimitiveValidator.java
deleted file mode 100644
index d7ed14a2..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2BytePrimitiveValidator.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.validation;
-
-import org.eclipse.jface.internal.databinding.internal.BindingMessages;
-
-
-/**
- * ByteValidator. Validate String input for bytes
- */
-public class String2BytePrimitiveValidator implements IValidator {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.validator.IValidator#isPartiallyValid(java.lang.Object)
- */
- public ValidationError isPartiallyValid(Object fragment) {
- if (((String)fragment).matches("\\-?[0-9]*")) //$NON-NLS-1$
- return null;
-
- return ValidationError.error(getHint());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.validator.IValidator#isValid(java.lang.Object)
- */
- public ValidationError isValid(Object value) {
- try {
- Byte.parseByte((String)value);
- return null;
- } catch (Throwable t) {
- return ValidationError.error(getHint());
- }
- }
-
- private String getHint() {
- return BindingMessages.getString("Validate_RangeStart") + Byte.MIN_VALUE + //$NON-NLS-1$
- BindingMessages.getString("and") + Byte.MAX_VALUE + "."; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2ByteValidator.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2ByteValidator.java
deleted file mode 100644
index e9a6c7e2..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2ByteValidator.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.validation;
-
-/**
- * IntegerValidator. Validate String to Byte data input
- */
-public class String2ByteValidator extends String2BytePrimitiveValidator {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.validator.IValidator#isValid(java.lang.Object)
- */
- public ValidationError isValid(Object value) {
- if ("".equals(value)) { //$NON-NLS-1$
- return null;
- }
- return super.isValid(value);
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2DateValidator.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2DateValidator.java
deleted file mode 100644
index 07cdfe39..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2DateValidator.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.validation;
-
-import java.util.Date;
-
-import org.eclipse.jface.internal.databinding.internal.BindingMessages;
-import org.eclipse.jface.internal.databinding.provisional.conversion.DateConversionSupport;
-
-
-/**
- * DateValidator. An IValidator implementation for dates.
- */
-public class String2DateValidator extends DateConversionSupport implements IValidator {
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.validator.IValidator#isPartiallyValid(java.lang.Object)
- */
- public ValidationError isPartiallyValid(Object fragment) {
- // TODO: Can we do any sensible (locale-independent) checking here?
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.validator.IValidator#isValid(java.lang.Object)
- */
- public ValidationError isValid(Object value) {
- return parse((String)value)!=null ? null : ValidationError.error(getHint());
- }
-
- private String getHint() {
- Date sampleDate=new Date();
- StringBuffer samples=new StringBuffer();
- for(int formatterIdx=1;formatterIdx<numFormatters()-2;formatterIdx++) {
- samples.append('\'');
- samples.append(format(sampleDate,formatterIdx));
- samples.append("', "); //$NON-NLS-1$
- }
- samples.append('\'');
- samples.append(format(sampleDate,0));
- samples.append('\'');
- return BindingMessages.getString("Examples") + ": "+samples+",..."; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2DoublePrimitiveValidator.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2DoublePrimitiveValidator.java
deleted file mode 100644
index 3ba6782a..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2DoublePrimitiveValidator.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.validation;
-
-import org.eclipse.jface.internal.databinding.internal.BindingMessages;
-
-
-/**
- * DoubleValidator. Verify data input for doubles
- *
- * @author djo
- */
-public class String2DoublePrimitiveValidator implements IValidator {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.validator.IValidator#isPartiallyValid(java.lang.Object)
- */
- public ValidationError isPartiallyValid(Object fragment) {
- if (((String)fragment).matches("\\-?[0-9]*\\.?[0-9]*([0-9]+[e|E]\\-?([0-9]+\\.)?[0-9]*)?")) //$NON-NLS-1$
- return null;
-
- return ValidationError.error(getHint());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ICellEditorValidator#isValid(java.lang.Object)
- */
- public ValidationError isValid(Object value) {
- try {
- Double.parseDouble((String)value);
- return null;
- } catch (Throwable t) {
- return ValidationError.error(getHint());
- }
- }
-
- private String getHint() {
- return BindingMessages.getString("Validate_Like") + //$NON-NLS-1$
- BindingMessages.getString("Validate_Number_Examples") //$NON-NLS-1$
- + Double.MIN_VALUE +
- ", " + Double.MAX_VALUE + "."; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2DoubleValidator.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2DoubleValidator.java
deleted file mode 100644
index 8629a6ef..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2DoubleValidator.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.validation;
-
-/**
- * IntegerValidator. Validate String to Double data input
- */
-public class String2DoubleValidator extends String2DoublePrimitiveValidator {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.validator.IValidator#isValid(java.lang.Object)
- */
- public ValidationError isValid(Object value) {
- if ("".equals(value)) { //$NON-NLS-1$
- return null;
- }
- return super.isValid(value);
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2FloatPrimitiveValidator.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2FloatPrimitiveValidator.java
deleted file mode 100644
index eb31bdb0..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2FloatPrimitiveValidator.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.validation;
-
-import org.eclipse.jface.internal.databinding.internal.BindingMessages;
-
-
-/**
- * FloatValidator. Verify string to float data conversion
- */
-public class String2FloatPrimitiveValidator implements IValidator {
-
- public ValidationError isPartiallyValid(Object fragment) {
- if (((String)fragment).matches("\\-?[0-9]*\\.?[0-9]*([0-9]+[e|E]\\-?([0-9]+\\.)?[0-9]*)?")) //$NON-NLS-1$
- return null;
-
- return ValidationError.error(getHint());
- }
-
- public ValidationError isValid(Object value) {
- try {
- Float.parseFloat((String)value);
- return null;
- } catch (Exception e) {
- return ValidationError.error(getHint());
- }
- }
-
- private String getHint() {
- return BindingMessages.getString("Validate_Like") + //$NON-NLS-1$
- BindingMessages.getString("Validate_Number_Examples") //$NON-NLS-1$
- + Float.MIN_VALUE +
- ", " + Float.MAX_VALUE + "."; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2FloatValidator.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2FloatValidator.java
deleted file mode 100644
index 13e4614d..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2FloatValidator.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.validation;
-
-/**
- * IntegerValidator. Validate String to Float data input
- */
-public class String2FloatValidator extends String2FloatPrimitiveValidator {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.validator.IValidator#isValid(java.lang.Object)
- */
- public ValidationError isValid(Object value) {
- if ("".equals(value)) { //$NON-NLS-1$
- return null;
- }
- return super.isValid(value);
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2IntegerPrimitiveValidator.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2IntegerPrimitiveValidator.java
deleted file mode 100644
index 32c2d5fe..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2IntegerPrimitiveValidator.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.validation;
-
-import org.eclipse.jface.internal.databinding.internal.BindingMessages;
-
-
-/**
- * IntValidator. Validate String to int data input
- */
-public class String2IntegerPrimitiveValidator implements IValidator {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.validator.IValidator#isPartiallyValid(java.lang.Object)
- */
- public ValidationError isPartiallyValid(Object fragment) {
- if (((String)fragment).matches("\\-?[0-9]*")) //$NON-NLS-1$
- return null;
-
- return ValidationError.error(getHint());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.validator.IValidator#isValid(java.lang.Object)
- */
- public ValidationError isValid(Object value) {
- try {
- Integer.parseInt((String)value);
- return null;
- } catch (Throwable t) {
- return ValidationError.error(getHint());
- }
- }
-
- private String getHint() {
- return BindingMessages.getString("Validate_RangeStart") + Integer.MIN_VALUE + //$NON-NLS-1$
- BindingMessages.getString("and") + Integer.MAX_VALUE + "."; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2IntegerValidator.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2IntegerValidator.java
deleted file mode 100644
index edd010a5..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2IntegerValidator.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.validation;
-
-/**
- * IntegerValidator. Validate String to Integer data input
- */
-public class String2IntegerValidator extends String2IntegerPrimitiveValidator {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.validator.IValidator#isValid(java.lang.Object)
- */
- public ValidationError isValid(Object value) {
- if ("".equals(value)) { //$NON-NLS-1$
- return null;
- } else {
- return super.isValid(value);
- }
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2LongPrimitiveValidator.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2LongPrimitiveValidator.java
deleted file mode 100644
index cfe629d6..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2LongPrimitiveValidator.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.validation;
-
-import org.eclipse.jface.internal.databinding.internal.BindingMessages;
-
-
-/**
- * LongValidator. Validate String to long data input
- */
-public class String2LongPrimitiveValidator implements IValidator {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.validator.IValidator#isPartiallyValid(java.lang.Object)
- */
- public ValidationError isPartiallyValid(Object fragment) {
- if (((String)fragment).matches("\\-?[0-9]*")) //$NON-NLS-1$
- return null;
-
- return ValidationError.error(getHint());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.validator.IValidator#isValid(java.lang.Object)
- */
- public ValidationError isValid(Object value) {
- try {
- Long.parseLong((String)value);
- return null;
- } catch (Throwable t) {
- return ValidationError.error(getHint());
- }
- }
-
- private String getHint() {
- return BindingMessages.getString("Validate_RangeStart") + Long.MIN_VALUE + //$NON-NLS-1$
- BindingMessages.getString("and") + Long.MAX_VALUE + "."; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2LongValidator.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2LongValidator.java
deleted file mode 100644
index b8f692da..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2LongValidator.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.validation;
-
-/**
- * IntegerValidator. Validate String to Long data input
- */
-public class String2LongValidator extends String2LongPrimitiveValidator {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.validator.IValidator#isValid(java.lang.Object)
- */
- public ValidationError isValid(Object value) {
- if ("".equals(value)) { //$NON-NLS-1$
- return null;
- }
- return super.isValid(value);
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2ShortPrimitiveValidator.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2ShortPrimitiveValidator.java
deleted file mode 100644
index f70a2b38..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2ShortPrimitiveValidator.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.validation;
-
-import org.eclipse.jface.internal.databinding.internal.BindingMessages;
-
-
-/**
- * ShortValidator. Validate String to short data input
- */
-public class String2ShortPrimitiveValidator implements IValidator {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.validator.IValidator#isPartiallyValid(java.lang.Object)
- */
- public ValidationError isPartiallyValid(Object fragment) {
- if (((String)fragment).matches("\\-?[0-9]*")) //$NON-NLS-1$
- return null;
-
- return ValidationError.error(getHint());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.validator.IValidator#isValid(java.lang.Object)
- */
- public ValidationError isValid(Object value) {
- try {
- Short.parseShort((String)value);
- return null;
- } catch (Throwable t) {
- return ValidationError.error(getHint());
- }
- }
-
- private String getHint() {
- return BindingMessages.getString("Validate_RangeStart") + Short.MIN_VALUE + //$NON-NLS-1$
- BindingMessages.getString("and") + Short.MAX_VALUE + "."; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2ShortValidator.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2ShortValidator.java
deleted file mode 100644
index 8824ebea..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/String2ShortValidator.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.internal.databinding.provisional.validation;
-
-/**
- * IntegerValidator. Validate String to Short data input
- */
-public class String2ShortValidator extends String2ShortPrimitiveValidator {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.databinding.validator.IValidator#isValid(java.lang.Object)
- */
- public ValidationError isValid(Object value) {
- if ("".equals(value)) { //$NON-NLS-1$
- return null;
- }
- return super.isValid(value);
- }
-}
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/ValidationError.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/ValidationError.java
deleted file mode 100644
index 1af97665..00000000
--- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/ValidationError.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.validation;
-
-/**
- * @since 1.0
- *
- */
-public class ValidationError {
-
- /**
- * A constant indicating that something may not be quite right.
- */
- public static final int WARNING = 1;
-
- /**
- * A constant indicating that something bad has happened.
- */
- public static final int ERROR = 2;
-
- /**
- * Indicates the current status.
- */
- public final int status;
-
- /**
- * Holds the current error or warning message.
- */
- public final String message;
-
- /**
- * The exception that caused the error (if any). Note that this
- * field should not be used for user errors, but only when the program
- * has detected a failure and needs to capture and retain the
- * call stack for the programmer to evaluate later.
- */
- public final Throwable exception;
-
- /**
- * A convenience factory for {@link #ERROR} ValidationErrors.
- *
- * @param message The error message
- * @return A new ValidationError representing the error
- */
- public static ValidationError error(String message) {
- return new ValidationError(ERROR, message, null);
- }
-
- /**
- * A convenience factory for {@link #ERROR} ValidationErrors caused
- * by a program malfunction.
- *
- * @param message The error message
- * @param exception The exception representing the malfunction
- * @return A new ValidationError representing the error
- */
- public static ValidationError error(String message, Throwable exception) {
- return new ValidationError(ERROR, message, exception);
- }
-
- /**
- * A convenience factory for {@link #WARNING} ValidationErrors.
- *
- * @param message The warning message
- * @return A new ValidationError representing the warning
- */
- public static ValidationError warning(String message) {
- return new ValidationError(WARNING, message, null);
- }
-
- /**
- * Construct a ValidationError with a status and error message.
- *
- * @param status either {@link #WARNING} or {@link #ERROR}
- * @param message An error message string or warning.
- * @param exception The exception representing the program's malfunction or null if none
- */
- public ValidationError(int status, String message, Throwable exception) {
- this.status = status;
- this.message = message;
- this.exception = exception;
- }
-
- public String toString() {
- return message;
- }
-}
-
diff --git a/examples/org.eclipse.jface.examples.databinding/.classpath b/examples/org.eclipse.jface.examples.databinding/.classpath
deleted file mode 100644
index d512f63a..00000000
--- a/examples/org.eclipse.jface.examples.databinding/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/executionEnvironments/J2SE-1.4"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/examples/org.eclipse.jface.examples.databinding/.cvsignore b/examples/org.eclipse.jface.examples.databinding/.cvsignore
deleted file mode 100644
index ba077a40..00000000
--- a/examples/org.eclipse.jface.examples.databinding/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/examples/org.eclipse.jface.examples.databinding/.project b/examples/org.eclipse.jface.examples.databinding/.project
deleted file mode 100644
index 0ccc2284..00000000
--- a/examples/org.eclipse.jface.examples.databinding/.project
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jface.examples.databinding</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.jem.beaninfo.BeanInfoNature</nature>
- </natures>
-</projectDescription>
diff --git a/examples/org.eclipse.jface.examples.databinding/.settings/org.eclipse.jdt.core.prefs b/examples/org.eclipse.jface.examples.databinding/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 69aa6454..00000000
--- a/examples/org.eclipse.jface.examples.databinding/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,71 +0,0 @@
-#Mon Aug 28 13:26:41 EDT 2006
-eclipse.preferences.version=1
-org.eclipse.jdt.core.builder.cleanOutputFolder=clean
-org.eclipse.jdt.core.builder.duplicateResourceTask=warning
-org.eclipse.jdt.core.builder.invalidClasspath=abort
-org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
-org.eclipse.jdt.core.circularClasspath=error
-org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
-org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.4
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.doc.comment.support=enabled
-org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=error
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=error
-org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
-org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
-org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=error
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=error
-org.eclipse.jdt.core.compiler.problem.unusedLabel=error
-org.eclipse.jdt.core.compiler.problem.unusedLocal=error
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.3
-org.eclipse.jdt.core.incompatibleJDKLevel=ignore
-org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/examples/org.eclipse.jface.examples.databinding/.settings/org.eclipse.jdt.ui.prefs b/examples/org.eclipse.jface.examples.databinding/.settings/org.eclipse.jdt.ui.prefs
deleted file mode 100644
index 846d8bfc..00000000
--- a/examples/org.eclipse.jface.examples.databinding/.settings/org.eclipse.jdt.ui.prefs
+++ /dev/null
@@ -1,7 +0,0 @@
-#Thu Aug 24 15:24:48 EDT 2006
-eclipse.preferences.version=1
-org.eclipse.jdt.ui.exception.name=e
-org.eclipse.jdt.ui.gettersetter.use.is=true
-org.eclipse.jdt.ui.javadoc=true
-org.eclipse.jdt.ui.overrideannotation=true
-org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return Returns the ${bare_field_name}.\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} The ${bare_field_name} to set.\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*******************************************************************************\n * Copyright (c) ${year} IBM Corporation and others.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http\://www.eclipse.org/legal/epl-v10.html\n *\n * Contributors\:\n * IBM Corporation - initial API and implementation\n ******************************************************************************/\n</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @since 3.2\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template></templates>
diff --git a/examples/org.eclipse.jface.examples.databinding/.settings/org.eclipse.pde.prefs b/examples/org.eclipse.jface.examples.databinding/.settings/org.eclipse.pde.prefs
deleted file mode 100644
index 9ad123fb..00000000
--- a/examples/org.eclipse.jface.examples.databinding/.settings/org.eclipse.pde.prefs
+++ /dev/null
@@ -1,14 +0,0 @@
-#Tue Oct 18 13:46:33 EDT 2005
-compilers.p.deprecated=0
-compilers.p.illegal-att-value=0
-compilers.p.no-required-att=0
-compilers.p.not-externalized-att=0
-compilers.p.unknown-attribute=0
-compilers.p.unknown-class=1
-compilers.p.unknown-element=1
-compilers.p.unknown-resource=1
-compilers.p.unresolved-ex-points=0
-compilers.p.unresolved-import=0
-compilers.p.unused-element-or-attribute=1
-compilers.use-project=true
-eclipse.preferences.version=1
diff --git a/examples/org.eclipse.jface.examples.databinding/META-INF/MANIFEST.MF b/examples/org.eclipse.jface.examples.databinding/META-INF/MANIFEST.MF
deleted file mode 100644
index d910bf0f..00000000
--- a/examples/org.eclipse.jface.examples.databinding/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,27 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.jface.examples.databinding
-Bundle-Version: 1.0.100.qualifier
-Bundle-ClassPath: .
-Bundle-Vendor: %providerName
-Bundle-Localization: plugin
-Require-Bundle: org.eclipse.jface,
- org.eclipse.jface.databinding,
- org.eclipse.core.runtime,
- org.eclipse.jface.databinding.beans,
- org.eclipse.jface.databinding.ui
-Eclipse-LazyStart: true
-Export-Package: org.eclipse.jface.examples.databinding;x-internal:=false,
- org.eclipse.jface.examples.databinding.compositetable;x-internal:=false,
- org.eclipse.jface.examples.databinding.compositetable.binding;x-internal:=false,
- org.eclipse.jface.examples.databinding.compositetable.day;x-internal:=false,
- org.eclipse.jface.examples.databinding.compositetable.day.binding;x-internal:=false,
- org.eclipse.jface.examples.databinding.compositetable.day.internal;x-internal:=true,
- org.eclipse.jface.examples.databinding.compositetable.month;x-internal:=false,
- org.eclipse.jface.examples.databinding.compositetable.reflect;x-internal:=false,
- org.eclipse.jface.examples.databinding.compositetable.timeeditor;x-internal:=false,
- org.eclipse.jface.examples.databinding.mask;x-internal:=false,
- org.eclipse.jface.examples.databinding.mask.internal;x-internal:=true,
- org.eclipse.jface.examples.databinding.model;x-internal:=false,
- org.eclipse.jface.examples.databinding.radioGroup;x-internal:=false
diff --git a/examples/org.eclipse.jface.examples.databinding/about.html b/examples/org.eclipse.jface.examples.databinding/about.html
deleted file mode 100644
index 46023304..00000000
--- a/examples/org.eclipse.jface.examples.databinding/about.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
-<title>About</title>
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>June 2, 2006</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
-
-</body>
-</html> \ No newline at end of file
diff --git a/examples/org.eclipse.jface.examples.databinding/build.properties b/examples/org.eclipse.jface.examples.databinding/build.properties
deleted file mode 100644
index f6d4f34c..00000000
--- a/examples/org.eclipse.jface.examples.databinding/build.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-###############################################################################
-# Copyright (c) 2003, 2005 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
-###############################################################################
-bin.includes = plugin.xml,\
- .,\
- META-INF/,\
- plugin.properties,\
- about.html
-output.databindingexamples.jar = bin/
-src.includes = about.html
-source.. = src/
diff --git a/examples/org.eclipse.jface.examples.databinding/plugin.properties b/examples/org.eclipse.jface.examples.databinding/plugin.properties
deleted file mode 100644
index 759e715f..00000000
--- a/examples/org.eclipse.jface.examples.databinding/plugin.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2005 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
-###############################################################################
-pluginName = JFace Data Binding Examples
-providerName = Eclipse.org
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/DataBindingFactory1.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/DataBindingFactory1.java
deleted file mode 100644
index 146c6aad..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/DataBindingFactory1.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * 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.examples.databinding;
-
-import org.eclipse.jface.internal.databinding.provisional.AbstractDataBindingContextFactory;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.beans.BeanObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.BindSupportFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultBindSupportFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultBindingFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.IBindingFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.IObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.NestedObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.swt.SWTObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersBindingFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersObservableFactory;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Widget;
-
-
-/**
- * A data binding context factory that configures the data binding context with
- * all the default factories used by version 1.0 of the JFace data binding
- * framework. Once version 1.0 ship, the order and behavior of these factories
- * will be frozen so that clients can depend on this class's behavior.
- * <p>
- * If you need to add your own factories in addition to or instead of the default
- * ones, this class may be subclassed by overriding the
- * {@link #addObservableFactories(IObservableFactory[])},
- * {@link #addBindSupportFactories(BindSupportFactory[])}, and
- * {@link #addBindingFactories(IBindingFactory[])} methods, changing the
- * contents and/or order of the factories, and then delegating to super().
- *
- * @since 3.3
- * @deprecated no longer part of the API
- */
-public class DataBindingFactory1 extends AbstractDataBindingContextFactory {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.AbstractDataBindingContextFactory#createContext()
- */
- public void configureContext(DataBindingContext context) {
- addObservableFactories(new IObservableFactory[] {
- new NestedObservableFactory(context),
- new BeanObservableFactory(context, null, new Class[] { Widget.class }),
- new SWTObservableFactory(),
- new ViewersObservableFactory(),
- new DefaultObservableFactory(context)
- });
- addBindSupportFactories(new BindSupportFactory[] {
- new DefaultBindSupportFactory()
- });
- addBindingFactories(new IBindingFactory[] {
- new DefaultBindingFactory(),
- new ViewersBindingFactory()
- });
- }
-
- /**
- * Creates, configures, and returns a new data binding context.
- *
- * @param parentComposite
- * when parentComposite is disposed, it will automatically
- * dispose the DataBindingContext.
- * @return DataBindingContext a configured data binding context.
- */
- public DataBindingContext createContext(Composite parentComposite) {
- final DataBindingContext result = createContext();
-
- parentComposite.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- result.dispose();
- }
- });
-
- return result;
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ExampleBinding.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ExampleBinding.java
deleted file mode 100644
index 33662fdd..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ExampleBinding.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.examples.databinding;
-
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.beans.BeanObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.NestedObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.swt.SWTObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersObservableFactory;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Widget;
-
-/**
- * An example application-level data binding factory implementation. This should
- * be copied into your application and be modified to include the specific
- * updatable factories your application needs in the order it needs them.
- * <p>
- * Note that the search order for IUpdatableFactory implementations is last to
- * first.
- * </p>
- *
- * @since 1.0
- */
-public class ExampleBinding {
-
- /**
- * Creates a data binding context whose lifecycle is bound to an SWT
- * control, and which supports binding to SWT controls, JFace viewers, and
- * POJO model objects with JavaBeans-style notification.
- * <p>
- * This method is a convenience method; its implementation is equivalent to
- * calling {@link DataBinding#createContext(Control, IUpdatableFactory[]) }
- * where the array of factories consists of a {@link NestedUpdatableFactory},
- * a {@link BeanUpdatableFactory} instance, a {@link SWTUpdatableFactory},
- * and a {@link ViewersUpdatableFactory}.
- * </p>
- *
- * @param control
- * @return a data binding context
- */
- public static DataBindingContext createContext(Control control) {
- final DataBindingContext context = createContext();
- control.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- context.dispose();
- }
- });
- return context;
- }
-
- /**
- * Creates a data binding context which supports binding to SWT controls,
- * JFace viewers, and POJO model objects with JavaBeans-style notification.
- * This data binding context's life cycle is not bound to the dispose event
- * of any SWT control. Consequently, the programmer is responsible to
- * manually dispose any IUpdatables created using this data binding context
- * as necessary.
- * <p>
- * This method is a convenience method; its implementation is equivalent to
- * calling {@link DataBinding#createContext(Control, IUpdatableFactory[]) }
- * where the array of factories consists of a {@link NestedUpdatableFactory},
- * a {@link BeanUpdatableFactory} instance, a {@link SWTUpdatableFactory},
- * and a {@link ViewersUpdatableFactory}.
- * </p>
- *
- * @return a data binding context
- */
- public static DataBindingContext createContext() {
- DataBindingContext context = new DataBindingContext();
- context.addObservableFactory(new NestedObservableFactory(context));
- context.addObservableFactory(new BeanObservableFactory(context, null, new Class[]{Widget.class}));
- context.addObservableFactory(new SWTObservableFactory());
- context.addObservableFactory(new ViewersObservableFactory());
- return context;
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/HelloWorld.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/HelloWorld.java
deleted file mode 100644
index 95fde571..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/HelloWorld.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * 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
- * Brad Reynolds - bug 159539
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding;
-
-import org.eclipse.jface.databinding.DataBindingContext;
-import org.eclipse.jface.databinding.beans.BeansObservables;
-import org.eclipse.jface.databinding.observable.list.WritableList;
-import org.eclipse.jface.databinding.swt.SWTObservables;
-import org.eclipse.jface.examples.databinding.model.SimplePerson;
-import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * @since 3.2
- *
- */
-public class HelloWorld {
-
- public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
-
- DataBindingContext dbc = DataBindingContext.withDefaults();
- Combo combo = new Combo(shell, SWT.READ_ONLY);
- WritableList list = new WritableList();
- list.add("Hello");
- list.add("Bonjour");
- list.add("Guten Tag");
- dbc.bindList(SWTObservables.getItems(combo), list, null);
- combo.select(0);
- Text text = new Text(shell, SWT.BORDER);
- SimplePerson person = new SimplePerson("Boris", "1234 Carling Ave",
- "Ottawa", "Canada");
- dbc.bindValue(SWTObservables.getText(text, SWT.Modify),
- BeansObservables.getAttribute(person, "name"), null);
- GridLayoutFactory.swtDefaults().numColumns(2).generateLayout(shell);
- shell.pack();
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ModelObject.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ModelObject.java
deleted file mode 100644
index f5b67591..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ModelObject.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.examples.databinding;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-public class ModelObject {
- private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(
- this);
- private String id;
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- propertyChangeSupport.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String propertyName,
- PropertyChangeListener listener) {
- propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- propertyChangeSupport.removePropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(String propertyName,
- PropertyChangeListener listener) {
- propertyChangeSupport.removePropertyChangeListener(propertyName,
- listener);
- }
-
- protected void firePropertyChange(String propertyName, Object oldValue,
- Object newValue) {
- propertyChangeSupport.firePropertyChange(propertyName, oldValue,
- newValue);
- }
-
- protected void firePropertyChange(String propertyName, int oldValue,
- int newValue) {
- propertyChangeSupport.firePropertyChange(propertyName, oldValue,
- newValue);
- }
-
- protected void firePropertyChange(String propertyName, boolean oldValue,
- boolean newValue) {
- propertyChangeSupport.firePropertyChange(propertyName, oldValue,
- newValue);
- }
-
- public void setId(String string) {
- Object oldValue = id;
- id = string;
- firePropertyChange("id", oldValue, id);
- }
-
- protected Object[] append(Object[] array, Object object) {
- List newList = new ArrayList(Arrays.asList(array));
- newList.add(object);
- return newList.toArray((Object[]) Array.newInstance(array.getClass()
- .getComponentType(), newList.size()));
- }
-
- protected Object[] remove(Object[] array, Object object) {
- List newList = new ArrayList(Arrays.asList(array));
- newList.remove(object);
- return newList.toArray((Object[]) Array.newInstance(array.getClass()
- .getComponentType(), newList.size()));
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/AbsoluteLayout.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/AbsoluteLayout.java
deleted file mode 100644
index a588fed3..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/AbsoluteLayout.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Coconut Palm Software, Inc. 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:
- * Coconut Palm Software, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable;
-
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Layout;
-
-/**
- * A layout manager that lays out child controls in absolute positions.
- * Each control's bounds is specified by setting an SWT Rectangle
- * object specifying the control's bounds into the control's layout data.
- * <p>
- * Use this layout manager whenever you would have used a null layout
- * previously.
- *
- * @since 3.3
- */
-public class AbsoluteLayout extends Layout {
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Layout#computeSize(org.eclipse.swt.widgets.Composite, int, int, boolean)
- */
- protected Point computeSize(Composite composite, int wHint, int hHint, boolean flush) {
- Point result = new Point(0, 0);
- Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; i++) {
- Rectangle bounds = (Rectangle) children[i].getLayoutData();
- if (bounds == null) {
- continue;
- }
- int rightBounds = bounds.x + bounds.width;
- int bottomBounds = bounds.y + bounds.height;
- if (result.x < rightBounds) {
- result.x = rightBounds;
- }
- if (result.y < bottomBounds) {
- result.y = bottomBounds;
- }
- }
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Layout#layout(org.eclipse.swt.widgets.Composite, boolean)
- */
- protected void layout(Composite composite, boolean flush) {
- Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; i++) {
- Rectangle bounds = (Rectangle) children[i].getLayoutData();
- if (bounds == null) {
- continue;
- }
- children[i].setBounds(bounds);
- }
- }
-}
-
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/CompositeTable.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/CompositeTable.java
deleted file mode 100644
index d7c0933a..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/CompositeTable.java
+++ /dev/null
@@ -1,1273 +0,0 @@
-/*
- * Copyright (C) 2005 David Orme <djo@coconut-palm-software.com>
- *
- * 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:
- * David Orme - Initial API and implementation
- * Coconut Palm Software, Inc. - API cleanup
- */
-package org.eclipse.jface.examples.databinding.compositetable;
-
-import java.lang.reflect.Constructor;
-import java.util.ArrayList;
-import java.util.LinkedList;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Menu;
-
-/**
- * Class CompositeTable. n. (1) An SWT virtual table control that extends
- * Composite. (2) An SWT virtual table control that is composed of many
- * Composites, each representing a header or a row, one below the other.
- * <p>
- *
- * CompositeTable is designed specifically to work nicely in the Eclipse Visual
- * Editor, but it is equally easy to use in hand-coded layouts.
- * <p>
- *
- * <b>Synopsis:</b>
- * <p>
- *
- * In order to edit anything, one must:
- * <p>
- *
- * <ul>
- * <li>Extend Composite or Canvas and create an object that can be duplicated
- * to represent the rows in your table.
- * <li>Optionally, extend Composite or Canvas and create a header object in the
- * same way.
- * <li>If the canvas and row objects do not have a layout manager, the
- * CompositeTable will automatically supply one that lays out child controls in
- * a visual table. If they have a layout manager, CompositeTable will let them
- * use that.
- * <li>Create a CompositeTable object, either using VE or using hand-coded SWT.
- * <li>Drop the header (if applicable), then the row object on the
- * CompositeTable or simply write code that creates instances of these objects
- * in that order as child controls of your CompositeTable.
- * <li>Set the RunTime property to "true". Your control is now "live."
- * <li>Add a RowConstructionListener if you need to add event handlers to
- * individual row controls when a row is created.
- * <li>Add a RowContentProvider that knows how to put data into your row
- * object's controls on demand.
- * <li>Add a RowFocusListener to validate and save changed data.
- * <li>Set the NumRowsInCollection property to the number of rows in the
- * underlying data structure.
- * </ul>
- *
- * Detailed description:
- * <p>
- *
- * This control is designed to work inside of the Eclipse Visual Editor. To use
- * it, drop one on the design surface. (Even though it extends Canvas, it does
- * not make sense to put a layout manager on it.)
- * <p>
- *
- * Next create one or two new custom controls by using the Visual Editor to
- * extend Composite. If you create one custom control, it will be used as the
- * prototype for all rows that will be displayed in the table. If you create
- * two, the first one will be used as a prototype for the header and the second
- * one will be used as a prototype for the rows.
- * <p>
- *
- * If these custom controls are not given layout managers (null layout), then
- * CompositeTable will automatically detect this situation and will supply its
- * own layout manager that will automatically lay out the children of these
- * controls in columns to form a table. However, if you supply layout managers
- * for your header prototype and row prototype objects, CompositeTable will
- * respect your choice. If you use CompositeTable's built-in layout manager,
- * then the weights property will be used to determine what percentage of the
- * total width will be allocated to each column. If this property is not set or
- * if the sum of their elements does not equal 100, the columns are created as
- * equal sizes.
- * <p>
- *
- * Once you have created your (optional) Header and Row custom controls, simply
- * drop them onto your CompositeTable control in VE. The first of these two
- * custom controls to be instantiated in your code will be interpreted by the
- * CompositeTable as the header control and the second will be interpreted as
- * the row control.
- * <p>
- *
- * Now that you have defined the (optional) header and row, you can switch your
- * CompositeTable into run mode and use it. This is done by switching the
- * RunTime property to true.
- * <p>
- *
- * Once in run mode, all of the CompositeTable's properties will be active. In
- * order to use it, set the NumRowsInCollection property to the number of rows
- * in the collection you want to display. And add a RefreshContentProvider,
- * which will be called whenever CompositeTable needs to refresh a particular
- * row.
- * <p>
- *
- * Please refer to the remainder of the JavaDoc for information on the remaining
- * properties and events.
- * <p>
- *
- * Although this control extends Composite, it is not intended to be subclassed
- * except within its own implementation and it makes no sense to set a layout
- * manager on it (although as discussed above, the child controls may have
- * layout managers).
- *
- * @author djo
- * @since 3.2
- */
-public class CompositeTable extends Canvas {
-
- // Property fields here
- private boolean runTime = false;
-
- private int[] weights = new int[0];
-
- private int numRowsInCollection = 0;
-
- private int maxRowsVisible = Integer.MAX_VALUE;
-
- // Private fields here
- private Constructor headerConstructor = null;
-
- private Control headerControl = null;
-
- private Constructor rowConstructor = null;
-
- private Control rowControl = null;
-
- // TODO: on public API methods that reference contentPane, make sure it's not null before doing anything
- private InternalCompositeTable contentPane = null;
-
- /**
- * Constructor CompositeTable. Construct a CompositeTable control.
- * CompositeTable accepts the same style bits as the SWT Canvas.
- *
- * @param parent
- * The SWT parent control.
- * @param style
- * Style bits. These are the same as Canvas
- */
- public CompositeTable(Composite parent, int style) {
- super(parent, style);
- setBackground(Display.getCurrent().getSystemColor(
- SWT.COLOR_LIST_BACKGROUND));
- setLayout(new Layout() {
- protected Point computeSize(Composite composite, int wHint,
- int hHint, boolean flushCache) {
- if (headerControl == null && rowControl == null) {
- return new Point(2, 20);
- }
- Point headerSize = new Point(0, 0);
- if (headerControl != null) {
- headerSize = headerControl.computeSize(SWT.DEFAULT,
- SWT.DEFAULT);
- }
- Point rowSize = new Point(0, 0);
- if (rowControl != null) {
- rowSize = rowControl.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- }
- Point result = new Point(Math.max(headerSize.x, rowSize.x),
- headerSize.y + rowSize.y);
- return result;
- }
-
- protected void layout(Composite composite, boolean flushCache) {
- resize();
- }
- });
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.widgets.Control#setBackground(org.eclipse.swt.graphics.Color)
- */
- public void setBackground(Color color) {
- super.setBackground(color);
- if (contentPane != null) {
- contentPane.setBackground(color);
- }
- }
-
- private int numChildrenLastTime = 0;
-
- /**
- * (non-API) Method resize. Resize this table's contents. Called from within
- * the custom layout manager.
- */
- protected final void resize() {
- if (isRunTime()) {
- Control[] children = getChildren();
- int childrenLength = 0;
- for (int i = 0; i < children.length; i++) {
- if (!(children[i] instanceof InternalCompositeTable)) {
- ++childrenLength;
- }
- }
- if (numChildrenLastTime != childrenLength) {
- resizeAndRecordPrototypeRows();
- showPrototypes(false);
- contentPane.dispose();
- contentPane = new InternalCompositeTable(this, SWT.NULL);
- }
- updateVisibleRows();
- } else {
- resizeAndRecordPrototypeRows();
- }
- }
-
- /**
- * (non-API) Method updateVisibleRows. Makes sure that the content pane is
- * displaying the correct number of visible rows given the control's size.
- * Called from within #resize.
- */
- protected void updateVisibleRows() {
- if (contentPane == null) {
- switchToRunMode();
- }
- Point size = getSize();
- contentPane.setBounds(0, 0, size.x, size.y);
- }
-
- /**
- * Switch from design mode where prototype header/row objects can be dropped
- * on the control into run mode where all of the properties do what you
- * would expect.
- */
- private void switchToRunMode() {
- showPrototypes(false);
- contentPane = new InternalCompositeTable(this, SWT.NULL);
- }
-
- /**
- * Switch back to design mode so that the prototype header/row objects may
- * be manipulated directly in a GUI design tool.
- */
- private void switchToDesignMode() {
- contentPane.dispose();
- contentPane = null;
- showPrototypes(true);
- resizeAndRecordPrototypeRows();
- }
-
- /**
- * Turns display of the prototype objects on or off.
- *
- * @param newValue
- * true of the prototype objects should be displayed; false
- * otherwise.
- */
- private void showPrototypes(boolean newValue) {
- if (headerControl != null) {
- headerControl.setVisible(newValue);
- }
- if (rowControl != null) {
- rowControl.setVisible(newValue);
- }
- }
-
- /**
- * (non-API) Method resizeAndRecordPrototypeRows. Figure out what child
- * controls are the header and row prototype rows respectively and resize
- * them so they occupy the entire width and their preferred height.
- */
- protected void resizeAndRecordPrototypeRows() {
- Control[] children = getChildren();
- ArrayList realChildren = new ArrayList();
- Control[] finalChildren = children;
-
- // Find first two prototypes
- for (int i = 0; i < children.length; i++) {
- if (children[i] instanceof InternalCompositeTable) {
- continue;
- }
- if (realChildren.size() < 2) {
- realChildren.add(children[i]);
- }
- }
- finalChildren = (Control[]) realChildren
- .toArray(new Control[realChildren.size()]);
-
- if (finalChildren.length == 0) {
- headerConstructor = null;
- headerControl = null;
- rowConstructor = null;
- rowControl = null;
- return;
- }
-
- // Get a constructor for the header and/or the row prototype
- headerConstructor = null;
- headerControl = null;
- rowConstructor = null;
- rowControl = null;
-
- if (finalChildren.length == 1) {
- try {
- rowControl = (Composite) finalChildren[0];
- rowConstructor = finalChildren[0].getClass().getConstructor(
- new Class[] { Composite.class, Integer.TYPE });
- } catch (Exception e) {
- throw new RuntimeException("Unable to get constructor object for header or row", e);
- }
- } else {
- try {
- headerConstructor = finalChildren[0].getClass().getConstructor(
- new Class[] { Composite.class, Integer.TYPE });
- headerControl = finalChildren[0];
- rowConstructor = finalChildren[1].getClass().getConstructor(
- new Class[] { Composite.class, Integer.TYPE });
- rowControl = finalChildren[1];
- } catch (Exception e) {
- throw new RuntimeException("Unable to get constructor object for header or row", e);
- }
- }
-
- // Now actually resize the children
- int top = 0;
- int width = getSize().x;
- for (int i = 0; i < finalChildren.length; ++i) {
- int height = 50;
- if (finalChildren[i] instanceof Composite) {
- Composite child = (Composite) finalChildren[i];
- if (child.getLayout() == null) {
- height = layoutHeaderOrRow(child, i==0); // The 0th element is the header
- } else {
- height = finalChildren[i].computeSize(SWT.DEFAULT,
- SWT.DEFAULT).y;
- }
- } else {
- height = finalChildren[i].computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
- }
-
- finalChildren[i].setBounds(0, top, width, height);
- top += height;
- }
-
- numChildrenLastTime = children.length;
- Display.getCurrent().asyncExec(new Runnable() {
- public void run() {
- if (!CompositeTable.this.isDisposed()) {
- if (!getParent().isDisposed()) {
- getParent().layout(true);
- }
- }
- }
- });
- }
-
- /**
- * (non-API) Method layoutHeaderOrRow. If a header or row object does not
- * have a layout manager, this method will automatically be called to layout
- * the child controls of that header or row object.
- *
- * @param child
- * The child object to layout.
- * @param isHeader If we're laying out a header or a row object
- * @return the height of the header or row
- */
- int layoutHeaderOrRow(Composite child, boolean isHeader) {
- if (isFittingHorizontally() || isWidthWiderThanAllColumns()) {
- return layoutWeightedHeaderOrRow(child, isHeader);
- }
- return layoutAbsoluteWidthHeaderOrRow(child, isHeader);
- }
-
- boolean isWidthWiderThanAllColumns() {
- // isFittingHorizontally must be false because this is only called
- // as the second part of a short-circuit boolean evaluation
- int allColumnsTotalWidth = 0;
- for (int i = 0; i < weights.length; i++) {
- allColumnsTotalWidth += weights[i]+2;
- }
- return getSize().x > allColumnsTotalWidth;
- }
-
- private int layoutWeightedHeaderOrRow(Composite child, boolean isHeader) {
- Control[] children = child.getChildren();
- if (children.length == 0) {
- return 50;
- }
- int maxHeight = computeMaxHeight(isHeader, children);
-
- int[] weights = this.weights;
- if (isFittingHorizontally()) {
- weights = checkWeights(weights, children.length);
- } else {
- weights = computeWeights(weights, children.length);
- }
-
- int widthRemaining = child.getParent().getSize().x;
- int totalSize = widthRemaining;
- for (int i = 0; i < children.length - 1; i++) {
- int left = totalSize - widthRemaining;
- int desiredHeight = computeDesiredHeight(children[i], isHeader);
- int top = computeTop(maxHeight, desiredHeight);
- int width = (int) (((float) weights[i]) / 100 * totalSize);
- children[i].setBounds(left + 2, top, width - 4, desiredHeight);
- widthRemaining -= width;
- }
-
- int left = totalSize - widthRemaining;
- int desiredHeight = computeDesiredHeight(children[children.length - 1], isHeader);
- int top = computeTop(maxHeight, desiredHeight);
- children[children.length - 1].setBounds(left + 2, top,
- widthRemaining - 4, desiredHeight);
-
- return maxHeight;
- }
-
- private int layoutAbsoluteWidthHeaderOrRow(Composite child, boolean isHeader) {
- Control[] children = child.getChildren();
- if (children.length == 0) {
- return 50;
- }
- int maxHeight = computeMaxHeight(isHeader, children);
-
- int[] weights = this.weights;
- int left = 0;
- for (int i = 0; i < children.length; i++) {
- int desiredHeight = computeDesiredHeight(children[i], isHeader);
- int top = computeTop(maxHeight, desiredHeight);
- children[i].setBounds(left + 2, top, weights[i], desiredHeight);
- left += weights[i]+4;
- }
-
- return maxHeight;
- }
-
- private int computeTop(int maxHeight, int desiredHeight) {
- return maxHeight - desiredHeight - 1;
- }
-
- private int computeMaxHeight(boolean isHeader, Control[] children) {
- int maxHeight = 0;
- for (int i = 0; i < children.length; i++) {
- int height = computeDesiredHeight(children[i], isHeader);
- if (maxHeight < height) {
- maxHeight = height;
- }
- }
- ++maxHeight;
- return maxHeight;
- }
-
- int computeDesiredHeight(Control control, boolean isHeader) {
- int controlHeight = control.computeSize(SWT.DEFAULT,
- SWT.DEFAULT, false).y;
- if (maxRowsVisible == Integer.MAX_VALUE || isHeader) {
- return controlHeight;
- }
- if (contentPane != null && fittingVertically && isRunTime()) {
- // FIXME: Yuck: bad code smell here... (coupling with contentPane)
- int fitControlHeight = contentPane.clientAreaHeight / maxRowsVisible;
- if (fitControlHeight < controlHeight) {
- return controlHeight;
- }
- return fitControlHeight-2;
- }
- return controlHeight;
- }
-
- private int[] computeWeights(int[] weights, int numChildren) {
- if (weights.length != numChildren) {
- return checkWeights(weights, numChildren);
- }
- int allColumnsTotalWidth = 0;
- for (int i = 0; i < weights.length; i++) {
- allColumnsTotalWidth += weights[i];
- }
- int[] realWeights = new int[numChildren];
- int total=100;
- for (int i = 0; i < realWeights.length; i++) {
- realWeights[i] = (int) (((double)weights[i])/allColumnsTotalWidth * 100);
- total -= realWeights[i];
- }
- int i=0;
- while (total > 0) {
- ++realWeights[i];
- --total;
- ++i;
- if (i >= realWeights.length) {
- i = 0;
- }
- }
- return realWeights;
- }
-
- /**
- * Compute and return a weights array where each weight is the percentage
- * the corresponding column should occupy of the entire control width. If
- * the elements in the supplied weights array add up to 100 and the length
- * of the array is the same as the number of columns, the supplied weights
- * array is used. Otherwise, this method computes and returns a weights
- * array that makes each column an equal size.
- *
- * @param weights
- * The default or user-supplied weights array.
- * @param numChildren
- * The number of child controls.
- * @return The weights array that will be used by the layout manager.
- */
- private int[] checkWeights(int[] weights, int numChildren) {
- if (weights.length == numChildren) {
- int sum = 0;
- for (int i = 0; i < weights.length; i++) {
- sum += weights[i];
- }
- if (sum == 100) {
- return weights;
- }
- }
-
- // Either the number of weights doesn't match or they don't add up.
- // Compute something sane and return that instead.
- int[] result = new int[numChildren];
- int weight = 100 / numChildren;
- int extra = 100 % numChildren;
- for (int i = 0; i < result.length - 1; i++) {
- result[i] = weight;
- if (extra > 0) {
- result[i]++;
- extra--;
- }
- }
- result[numChildren - 1] = weight + extra;
- return result;
- }
-
- /**
- * Method isRunTime. Returns if the CompositeTable is in run time mode as
- * opposed to design time mode. In design time mode, the only permitted
- * operations are to add or remove child Composites to be used as the header
- * and/or row prototype objects.
- *
- * @return true if this CompositeTable is in run mode. false otherwise.
- */
- public boolean isRunTime() {
- return runTime;
- }
-
- /**
- * Method setRunTime. Turns run-time mode on or off. When run-time mode is
- * off, CompositeTable ignores most property operations and will accept
- * prototype child controls to be added. When run-time mode is on, the
- * prototype controls are interpreted and all properties become active.
- *
- * @param runTime
- * true if run-time mode should be enabled; false otherwise.
- */
- public void setRunTime(boolean runTime) {
- if (this.runTime != runTime) {
- this.runTime = runTime;
- if (runTime) {
- if (rowControl == null) {
- resizeAndRecordPrototypeRows();
- }
- switchToRunMode();
- } else {
- switchToDesignMode();
- }
- }
- }
-
- /**
- * Method getWeights. If isFittingHorizontally, returns an array
- * representing the percentage of the total width each column is allocated
- * or null if no weights have been specified.
- * <p>
- * If !isFittingHorizontally, returns an array where each element is the
- * absolute width in pixels of the corresponding column.
- * <p>
- * This property is ignored if the programmer has set a layout
- * manager on the header and/or the row prototype objects.
- *
- * @return the current weights array or null if no weights have been
- * specified.
- */
- public int[] getWeights() {
- return weights;
- }
-
- /**
- * Method setWeights. If isFittingHorizontally, specifies an array
- * representing the percentage of the total width each column is allocated
- * or null if no weights have been specified.
- * <p>
- * If !isFittingHorizontally, specifies an array where each element is the
- * absolute width in pixels of the corresponding column.
- * <p>
- * This property is ignored if the programmer has set a layout
- * manager on the header and/or the row prototype objects.
- * <p>
- * The number of elements in the array must match the number of columns and
- * if isFittingHorizontally, the sum of all elements must equal 100.
- * If either of these constraints is not true, this property will be ignored
- * and all columns will be created equal in width.
- *
- * @param weights
- * the weights to use if the CompositeTable is automatically
- * laying out controls.
- */
- public void setWeights(int[] weights) {
- this.weights = weights;
- if (contentPane != null) {
- contentPane.setWeights();
- }
- }
-
- boolean linesVisible = true;
-
- /**
- * Method getLinesVisible. Returns if the CompositeTable will draw grid lines
- * on the header and row Composite objects. This property is ignored if the
- * programmer has set a layout manager on the header and/or the row
- * prototype objects.
- *
- * @return true if the CompositeTable will draw grid lines; false otherwise.
- */
- public boolean getLinesVisible() {
- return linesVisible;
- }
-
- /**
- * Method setLinesVisible. Sets if the CompositeTable will draw grid lines on
- * the header and row Composite objects. This property is ignored if the
- * programmer has set a layout manager on the header and/or the row
- * prototype objects.
- *
- * @param linesVisible
- * true if the CompositeTable will draw grid lines; false
- * otherwise.
- */
- public void setLinesVisible(boolean linesVisible) {
- this.linesVisible = linesVisible;
- }
-
- String insertHint = "Press <Ctrl-INSERT> to insert new data."; //$NON-NLS-1$
-
- /**
- * Returns the hint string that will be displayed when there are no rows in
- * the table.
- *
- * @return The hint string that will be displayed when there are no rows in
- * the table.
- */
- public String getInsertHint() {
- return insertHint;
- }
-
- /**
- * Sets the hint string that will be displayed when there are no rows in the
- * table. The default value is "Press &lt;INS> to insert a new row."
- *
- * @param newHint
- */
- public void setInsertHint(String newHint) {
- this.insertHint = newHint;
- if (contentPane != null && numRowsInCollection < 1) {
- contentPane.emptyTablePlaceholder.setMessage(newHint);
- }
- }
-
- /**
- * Method getMaxRowsVisible. Returns the maximum number of rows that will be
- * permitted in the table at once. For example, setting this property to 1
- * will have the effect of creating a single editing area with a scroll bar
- * on the right allowing the user to scroll through all rows using either
- * the mouse or the PgUp/PgDn keys. The default value is Integer.MAX_VALUE.
- *
- * @return the maximum number of rows that are permitted to be visible at
- * one time, regardless of the control's size.
- */
- public int getMaxRowsVisible() {
- return maxRowsVisible;
- }
-
- /**
- * Method setMaxRowsVisible. Sets the maximum number of rows that will be
- * permitted in the table at once. For example, setting this property to 1
- * will have the effect of creating a single editing area with a scroll bar
- * on the right allowing the user to scroll through all rows using either
- * the mouse or the PgUp/PgDn keys. The default value is Integer.MAX_VALUE.
- *
- * @param maxRowsVisible
- * the maximum number of rows that are permitted to be visible at
- * one time, regardless of the control's size.
- */
- public void setMaxRowsVisible(int maxRowsVisible) {
- this.maxRowsVisible = maxRowsVisible;
- if (contentPane != null) {
- contentPane.setMaxRowsVisible(maxRowsVisible);
- }
- }
-
- private boolean fittingVertically = false;
-
- /**
- * Method isFittingVertically. Returns if the CompositeTable control will
- * scale the height of all rows so that maxRowsVisible rows exactly fits
- * vertically in the available space.
- *
- * @return true if the visible rows will be scaled; false otherwise.
- */
- public boolean isFittingVertically() {
- return fittingVertically;
- }
-
- /**
- * Method setFittingVertically. Sets if the CompositeTable will scale the
- * visible rows sot that maxRowsVisible rows will exactly fit vertically in
- * the available space.
- *
- * @param fittingVertically
- * true if the visible rows will be scaled; false otherwise.
- */
- public void setFittingVertically(boolean fittingVertically) {
- this.fittingVertically = fittingVertically;
- if (contentPane != null) {
- contentPane.setFittingVertically(fittingVertically);
- }
- }
-
- private boolean fittingHorizontally = true;
-
- /**
- * Method isFittingHorizontally. Returns if the CompositeTable control
- * will scale the widths of all columns so that they all fit into the
- * available space.
- *
- * @return Returns true if the table's actual width is set to equal the
- * visible width; false otherwise.
- */
- public boolean isFittingHorizontally() {
- return fittingHorizontally;
- }
-
- /**
- * Method setFittingHorizontally. Sets if the CompositeTable control
- * will scale the widths of all columns so that they all fit into the
- * available space.
- *
- * @param fittingHorizontally true if the table's actual width is set to
- * equal the visible width; false otherwise.
- */
- public void setFittingHorizontally(boolean fittingHorizontally) {
- this.fittingHorizontally = fittingHorizontally;
- if (contentPane != null) {
- contentPane.setFittingHorizontally(fittingHorizontally);
- }
- }
-
- /**
- * Method getNumRowsVisible. Returns the actual number of rows that are
- * currently visible. Normally CompositeTable displays as many rows as will
- * fit vertically given the control's size. This value can be clamped to a
- * maximum using the MaxRowsVisible property.
- *
- * @return the actual number of rows that are currently visible.
- */
- public int getNumRowsVisible() {
- if (contentPane != null)
- return contentPane.getNumRowsVisible();
-
- return -1;
- }
-
- /**
- * Method getNumRowsInCollection. Returns the number of rows in the data
- * structure that is being edited.
- *
- * @return the number of rows in the underlying data structure.
- */
- public int getNumRowsInCollection() {
- return numRowsInCollection;
- }
-
- /**
- * Method setNumRowsInCollection. Sets the number of rows in the data
- * structure that is being edited.
- *
- * @param numRowsInCollection
- * the number of rows represented by the underlying data
- * structure.
- */
- public void setNumRowsInCollection(int numRowsInCollection) {
- if (rowControl == null) {
- resizeAndRecordPrototypeRows();
- if (contentPane != null) {
- setRunTime(false);
- setRunTime(true);
- }
- }
- this.numRowsInCollection = numRowsInCollection;
- if (contentPane != null) {
- contentPane.setNumRowsInCollection(numRowsInCollection);
- }
- }
-
- private int topRow = 0;
-
- /**
- * Method getTopRow. Return the number of the line that is being displayed
- * in the top row of the CompositeTable editor (0-based).
- *
- * @return the number of the top line.
- */
- public int getTopRow() {
- if (contentPane != null) {
- return contentPane.getTopRow();
- }
- return topRow;
- }
-
- /**
- * Method setTopRow. Set the number of the line that is being displayed in
- * the top row of the CompositeTable editor (0-based). If the new top row is
- * not equal to the current top row, the table will automatically be
- * scrolled to the new position. This number must be greater than 0 and less
- * than NumRowsInCollection.
- *
- * @param topRow
- * the line number of the new top row.
- */
- public void setTopRow(int topRow) {
- this.topRow = topRow;
- if (contentPane != null) {
- contentPane.setTopRow(topRow);
- }
- }
-
- /**
- * Makes sure that the focused row is visible
- *
- * @return true if the display needed to be scrolled; false otherwise
- */
- public boolean makeFocusedRowVisible() {
- if (contentPane != null) {
- return contentPane.makeFocusedRowVisible();
- }
- return false;
- }
-
- /**
- * Method refreshAllRows. Refresh all visible rows in the CompositeTable
- * from the original data.
- */
- public void refreshAllRows() {
- if (contentPane != null) {
- contentPane.updateVisibleRows();
- contentPane.refreshAllRows();
- }
- }
-
- /**
- * Method getCurrentColumn. Returns the column number of the
- * currently-focused column (0-based).
- *
- * @return the column number of the currently-focused column.
- */
- public int getCurrentColumn() {
- if (contentPane == null) {
- return -1;
- }
- return getSelection().x;
- }
-
- /**
- * Method setCurrentColumn. Sets the column number of the currently-focused
- * column (0-based).
- *
- * @param column
- * The new column to focus.
- */
- public void setCurrentColumn(int column) {
- setSelection(column, getCurrentRow());
- }
-
- /**
- * Method getCurrentRow. Returns the current row number as an offset from
- * the top of the table window. In order to get the current row in the
- * underlying data structure, compute getTopRow() + getCurrentRow().
- *
- * @return the current row number as an offset from the top of the table
- * window.
- */
- public int getCurrentRow() {
- if (contentPane == null) {
- return -1;
- }
- return getSelection().y;
- }
-
- /**
- * Method setCurrentRow. Sets the current row number as an offset from the
- * top of the table window. In order to get the current row in the
- * underlying data structure, compute getTopRow() + getCurrentRow().
- *
- * @param row
- * the current row number as an offset from the top of the table
- * window.
- */
- public void setCurrentRow(int row) {
- setSelection(getCurrentColumn(), row);
- }
-
- /**
- * Method getCurrentRowControl. Returns the SWT control that displays the
- * current row.
- *
- * @return Control the current row control.
- */
- public Control getCurrentRowControl() {
- return contentPane.getCurrentRowControl();
- }
-
- /**
- * Method getRowControls. Returns an array of SWT controls where each
- * control represents a row control in the CompositeTable's current scrolled
- * position. If CompositeTable is resized, scrolled, such that the rows that
- * the CompositeTable control is displaying change in any way, the array
- * that is returned by this method will become out of date and need to be
- * retrieved again.
- *
- * @return Control[] An array of SWT Control objects, each representing an
- * SWT row object.
- */
- public Control[] getRowControls() {
- return contentPane.getRowControls();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#setMenu(org.eclipse.swt.widgets.Menu)
- */
- public void setMenu(Menu menu) {
- super.setMenu(menu);
- if (contentPane != null) {
- contentPane.setMenu(menu);
- }
- }
-
- /**
- * Method getControlRow. Given a row control, returns its row number
- * relative to the topRow.
- *
- * @param rowControl The row object to find
- * @return The row number of the rowControl relative to the topRow (0-based)
- * @throws IllegalArgumentException if rowControl is not currently visible
- */
- public int getControlRow(Control rowControl) {
- return contentPane.getControlRow(rowControl);
- }
-
- /**
- * Method getSelection. Returns the currently-selected (column, row) pair
- * where the row specifies the offset from the top of the table window. In
- * order to get the current row in the underlying data structure, use
- * getSelection().y + getTopRow().
- *
- * @return the currently-selected (column, row) pair where the row specifies
- * the offset from the top of the table window.
- */
- public Point getSelection() {
- if (contentPane == null) {
- return null;
- }
- return contentPane.getSelection();
- }
-
- /**
- * Method setSelection. Sets the currently-selected (column, row) pair where
- * the row specifies the offset from the top of the table window. In order
- * to get the current row in the underlying data structure, use
- * getSelection().y + getCurrentRow().
- *
- * @param selection
- * the (column, row) to select
- */
- public void setSelection(Point selection) {
- setSelection(selection.x, selection.y);
- }
-
- /**
- * Method setSelection. Sets the currently-selected (column, row) pair where
- * the row specifies the offset from the top of the table window. In order
- * to get the current row in the underlying data structure, use
- * getSelection().y + getCurrentRow().
- *
- * @param column
- * the column to select
- * @param row
- * the row to select as an offset from the top of the window
- */
- public void setSelection(int column, int row) {
- if (contentPane == null) {
- return;
- }
- contentPane.setSelection(column, row);
- }
-
- /**
- * (non-API) Method getHeaderConstructor. Returns the Constructor object
- * used internally to construct the table's header or null if there is none.
- *
- * @return the header's constructor.
- */
- public Constructor getHeaderConstructor() {
- return headerConstructor;
- }
-
- /**
- * (non-API) Method getRowConstructor. Returns the Constructor object used
- * internally to construct each row object.
- *
- * @return the rows' constructor
- */
- public Constructor getRowConstructor() {
- return rowConstructor;
- }
-
- /**
- * (non-API) Method getHeaderControl. Returns the prototype header control.
- *
- * @return the prototype header control.
- */
- public Control getHeaderControl() {
- return headerControl;
- }
-
- /**
- * (non-API) Method getRowControl. Returns the prototype row control.
- *
- * @return the prototype row control.
- */
- public Control getRowControl() {
- return rowControl;
- }
-
- LinkedList contentProviders = new LinkedList();
-
- /**
- * Method addRowContentProvider. Adds the specified content provider to the
- * list of content providers that will be called when a row needs to be
- * filled with data. Most of the time it only makes sense to add a single
- * one.
- *
- * @param contentProvider
- * The content provider to add.
- */
- public void addRowContentProvider(IRowContentProvider contentProvider) {
- contentProviders.add(contentProvider);
- }
-
- /**
- * Method removeRowContentProvider. Removes the specified content provider
- * from the list of content providers that will be called when a row needs
- * to be filled with data.
- *
- * @param contentProvider
- * The content provider to remove.
- */
- public void removeRowContentProvider(IRowContentProvider contentProvider) {
- contentProviders.remove(contentProvider);
- }
-
- LinkedList rowFocusListeners = new LinkedList();
-
- /**
- * Method addRowListener. Adds the specified listener to the set of
- * listeners that will be notified when the user wishes to leave a row and
- * when the user has already left a row. If any listener vetos leaving a
- * row, the focus remains in the row.
- *
- * @param rowListener
- * The listener to add.
- */
- public void addRowFocusListener(IRowFocusListener rowListener) {
- rowFocusListeners.add(rowListener);
- }
-
- /**
- * Method removeRowListener. Removes the specified listener from the set of
- * listeners that will be notified when the user wishes to leave a row and
- * when the user has already left a row. If any listener vetos leaving a
- * row, the focus remains in the row.
- *
- * @param listener
- * The listener to remove.
- */
- public void removeRowFocusListener(IRowFocusListener listener) {
- rowFocusListeners.remove(listener);
- }
-
- LinkedList insertHandlers = new LinkedList();
-
- /**
- * Method addInsertHandler. Adds the specified insertHandler to the set of
- * objects that will be used to handle insert requests.
- *
- * @param insertHandler
- * the insertHandler to add.
- */
- public void addInsertHandler(IInsertHandler insertHandler) {
- insertHandlers.add(insertHandler);
- }
-
- /**
- * Method removeInsertHandler. Removes the specified insertHandler from the
- * set of objects that will be used to handle insert requests.
- *
- * @param insertHandler
- * the insertHandler to remove.
- */
- public void removeInsertHandler(IInsertHandler insertHandler) {
- insertHandlers.remove(insertHandler);
- }
-
- LinkedList deleteHandlers = new LinkedList();
-
- /**
- * Method addDeleteHandler. Adds the specified deleteHandler to the set of
- * objects that will be used to handle delete requests.
- *
- * @param deleteHandler
- * the deleteHandler to add.
- */
- public void addDeleteHandler(IDeleteHandler deleteHandler) {
- deleteHandlers.add(deleteHandler);
- }
-
- /**
- * Method removeDeleteHandler. Removes the specified deleteHandler from the
- * set of objects that will be used to handle delete requests.
- *
- * @param deleteHandler
- * the deleteHandler to remove.
- */
- public void removeDeleteHandler(IDeleteHandler deleteHandler) {
- deleteHandlers.remove(deleteHandler);
- }
-
- LinkedList rowConstructionListeners = new LinkedList();
-
- /**
- * Method addRowConstructionListener. Adds the specified
- * rowConstructionListener to the set of objects that will be used to listen
- * to row construction events.
- *
- * @param rowConstructionListener
- * the rowConstructionListener to add.
- */
- public void addRowConstructionListener(
- RowConstructionListener rowConstructionListener) {
- rowConstructionListeners.add(rowConstructionListener);
- }
-
- /**
- * Method removeRowConstructionListener. Removes the specified
- * rowConstructionListener from the set of objects that will be used to
- * listen to row construction events.
- *
- * @param rowConstructionListener
- * the rowConstructionListener to remove.
- */
- public void removeRowConstructionListener(
- RowConstructionListener rowConstructionListener) {
- rowConstructionListeners.remove(rowConstructionListener);
- }
-
- boolean deleteEnabled = true;
-
- /**
- * Method isDeleteEnabled. Returns if delete is enabled. Deletions are only
- * processed if the DeleteEnabled property is true and at least one delete
- * handler has been registered.
- * <p>
- *
- * The default value is true.
- *
- * @return true if delete is enabled. false otherwise.
- */
- public boolean isDeleteEnabled() {
- return deleteEnabled;
- }
-
- /**
- * Method setDeleteEnabled. Sets if delete is enabled. Deletions are only
- * processed if the DeleteEnabled property is true and at least one delete
- * handler has been registered.
- * <p>
- *
- * The default value is true.
- *
- * @param deleteEnabled
- * true if delete should be enabled. false otherwise.
- */
- public void setDeleteEnabled(boolean deleteEnabled) {
- this.deleteEnabled = deleteEnabled;
- }
-
- LinkedList scrollListeners = new LinkedList();
-
- /**
- * Method addScrollListener. Adds the specified scroll listener to the
- * list of listeners that will be notified when this CompositeTable control
- * scrolls the top-visible row. This event is not fired when the
- * CompositeTable is resized.
- *
- * @param scrollListener the ScrollListener to add.
- */
- public void addScrollListener(ScrollListener scrollListener) {
- scrollListeners.add(scrollListener);
- }
-
- /**
- * Method removeScrollListener. Removes the specified scroll listener from the
- * list of listeners that will be notified when this CompositeTable control
- * scrolls the top-visible row.
- *
- * @param scrollListener the ScrollListener to remove.
- */
- public void removeScrollListener(ScrollListener scrollListener) {
- scrollListeners.remove(scrollListener);
- }
-
- private boolean traverseOnTabsEnabled = true;
-
- /**
- * Method isTraverseOnTabsEnabled. Returns true if Tab and Shift-tab cause
- * the focus to wrap from the end of the table back to the beginning and
- * Enter causes the focus to advance. Returns false otherwise.
- * <p>
- * This property defaults to true.
- *
- * @return true if CompositeTable is handling Tab, Shift-tab, and Enter key
- * behavior; false otherwise.
- */
- public boolean isTraverseOnTabsEnabled() {
- return traverseOnTabsEnabled;
- }
-
- /**
- * Method setTraverseOnTabsEnabled. Sets if Tab and Shift-tab cause
- * the focus to wrap from the end of the table back to the beginning and
- * Enter causes the focus to advance.
- * <p>
- * This property defaults to true.
- *
- * @param enabled true if CompositeTable is handling Tab, Shift-tab, and Enter key
- * behavior; false otherwise.
- */
- public void setTraverseOnTabsEnabled(boolean enabled) {
- this.traverseOnTabsEnabled = enabled;
- }
-
-} // @jve:decl-index=0:visual-constraint="10,10" \ No newline at end of file
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/IDeleteHandler.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/IDeleteHandler.java
deleted file mode 100644
index ec71880f..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/IDeleteHandler.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2005 David Orme <djo@coconut-palm-software.com>
- *
- * 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:
- * David Orme - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.compositetable;
-
-/**
- * Interface IDeleteHandler. An interface for objects that can manage deletions on behalf of
- * a CompositeTable.
- */
-public interface IDeleteHandler {
- /**
- * Method canDelete. This method is called to determine if the specified row can
- * be successfully deleted. The receiver may perform whatever validation that is required
- * If this is successful, the receiver should return true. If the object cannot
- * (or must not) be deleted, the receiver must return false.
- *
- * @param rowInCollection The row under consideration for deletion.
- * @return true if the row can be deleted; false otherwise.
- */
- public boolean canDelete(int rowInCollection);
-
- /**
- * Method deleteRow. This method is called when the user has requested to delete the
- * specified row.
- *
- * @param rowInCollection The row in the collection to delete (0-based).
- */
- public void deleteRow(int rowInCollection);
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/IInsertHandler.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/IInsertHandler.java
deleted file mode 100644
index ca2299aa..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/IInsertHandler.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2005 David Orme <djo@coconut-palm-software.com>
- *
- * 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:
- * David Orme - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.compositetable;
-
-/**
- * Interface IInsertHandler. An interface for objects that can handle requests to insert a new
- * object into a collection being edited by a CompositeTable.
- *
- * @author djo
- */
-public interface IInsertHandler {
- /**
- * Method insert. Requests that the receiver insert object(s) making up a new row at
- * the specified position. The receiver returns the actual position where the insert
- * occured (that doesn't have to be the same as the requested position).
- *
- * @param positionHint The user's current position in the user interface relative to the
- * beginning of the collection (0-based).
- *
- * @return the actual position of the new object or -1 if a new object could
- * not be inserted.
- */
- public int insert(int positionHint);
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/IRowContentProvider.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/IRowContentProvider.java
deleted file mode 100644
index 5c251d1c..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/IRowContentProvider.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2005 David Orme <djo@coconut-palm-software.com>
- *
- * 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:
- * David Orme - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.compositetable;
-
-import org.eclipse.swt.widgets.Control;
-
-/**
- * Interface IRowContentProvider. An interface for objects that are able to initialize an
- * arbitrary row control with values on demand.
- * @author djo
- */
-public interface IRowContentProvider {
-
- /**
- * Method refresh. Requests receiver to refresh the currentRowInTable with data
- * to edit.
- *
- * @param sender The CompositeTable sending the message.
- * @param currentObjectOffset The 0-based row number that is offset in the data structure of
- * the table's top row.
- * @param row The row control to fill with data. This will be a copy of your prototype
- * row object.
- */
- void refresh(CompositeTable sender, int currentObjectOffset, Control row);
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/IRowFocusListener.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/IRowFocusListener.java
deleted file mode 100644
index 64098260..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/IRowFocusListener.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2005 David Orme <djo@coconut-palm-software.com>
- *
- * 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:
- * David Orme - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.compositetable;
-
-import org.eclipse.swt.widgets.Control;
-
-/**
- * Interface IRowFocusListener. An interface for objects that want to listen to
- * and have the possibility of vetoing row change events on a CompositeTable.
- * This interface is not intended to be implemented except within the
- * CompositeTable implementation. Extend RowFocusAdapter instead.
- *
- * @author djo
- */
-public interface IRowFocusListener {
-
- /**
- * Method requestRowChange. Requests permission to change rows. This method is
- * called immediately before a row change occurs. Listeners must return true to
- * grant permission for the row change to occur or return false to veto it. If
- * any listener returns false, the entire row change operation is aborted.<p>
- *
- * @param sender The CompositeTable sending the event.
- * @param currentObjectOffset The offset of the current object in the data structure.
- * @param row The row control that is losing focus.
- * @return true to permit the row change to occur; false otherwise.
- */
- boolean requestRowChange(CompositeTable sender, int currentObjectOffset, Control row);
-
- /**
- * Method depart. Called after requstRowChange has been called to indicate that
- * the focus is departing the specified row.
- *
- * @param sender
- * @param currentObjectOffset
- * @param row
- */
- void depart(CompositeTable sender, int currentObjectOffset, Control row);
-
- /**
- * Method arrive. Notifies receiver that the current row has just been changed.
- *
- * @param sender The CompositeTable sending the event.
- * @param currentObjectOffset The 0-based offset to the row that should be populated
- * @param newRow The actual SWT row object that needs to be populated with data
- */
- void arrive(CompositeTable sender, int currentObjectOffset, Control newRow);
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/InternalCompositeTable.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/InternalCompositeTable.java
deleted file mode 100644
index 264adef3..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/InternalCompositeTable.java
+++ /dev/null
@@ -1,2097 +0,0 @@
-/*
- * Copyright (C) 2005 David Orme <djo@coconut-palm-software.com>
- *
- * 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:
- * David Orme - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.compositetable;
-
-import java.lang.reflect.Constructor;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.eclipse.jface.examples.databinding.compositetable.internal.EmptyTablePlaceholder;
-import org.eclipse.jface.examples.databinding.compositetable.internal.ISelectableRegionControl;
-import org.eclipse.jface.examples.databinding.compositetable.internal.TableRow;
-import org.eclipse.jface.examples.databinding.compositetable.reflect.DuckType;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Slider;
-import org.eclipse.swt.widgets.Widget;
-
-/**
- * (non-API) Class InternalCompositeTable. This is the run-time
- * CompositeTableControl. It gets its prototype row and (optional) header
- * objects from its SWT parent, then uses them to implement an SWT virtual table
- * control.
- *
- * @author djo
- */
-public class InternalCompositeTable extends Composite implements Listener {
- // The internal UI controls that make up this control.
- private Composite controlHolder = null;
- private Composite vSliderHolder = null;
- private Slider vSlider = null;
- private Composite hScroller;
- private Composite hSliderHolder = null;
- private Slider hSlider = null;
- EmptyTablePlaceholder emptyTablePlaceholder = null;
-
- // My parent CompositeTable
- private CompositeTable parent;
-
- // Property fields
- private int maxRowsVisible;
- private boolean fittingVertically;
- private boolean fittingHorizontally;
- private int numRowsInDisplay;
- private int numRowsInCollection;
- private int topRow;
- private int currentRow;
- private int currentColumn;
-
- // The visible/invisible row objects and bookeeping info about them
- private int currentVisibleTopRow = 0;
- private int numRowsVisible = 0;
- private LinkedList rows = new LinkedList();
- private LinkedList spareRows = new LinkedList();
- int clientAreaHeight;
-
- // The prototype header/row objects and Constructors so we can duplicate
- // them
- private Constructor headerConstructor;
- private Constructor rowConstructor;
- private Control headerControl;
- private Control myHeader = null;
- private Control rowControl;
-
- /**
- * Constructor InternalCompositeTable. The usual SWT constructor. The same
- * style bits are allowed here as are allowed on Composite.
- *
- * @param parentControl
- * The SWT parent.
- * @param style
- * Style bits.
- */
- public InternalCompositeTable(Composite parentControl, int style) {
- super(parentControl, style);
- initialize();
-
- this.parent = (CompositeTable) parentControl;
-
- setBackground(parentControl.getBackground());
- controlHolder.addListener(SWT.MouseWheel, this);
-
- maxRowsVisible = parent.getMaxRowsVisible();
- fittingVertically = parent.isFittingVertically();
- fittingHorizontally = parent.isFittingHorizontally();
- numRowsInCollection = parent.getNumRowsInCollection();
- topRow = parent.getTopRow();
-
- headerConstructor = parent.getHeaderConstructor();
- rowConstructor = parent.getRowConstructor();
- headerControl = parent.getHeaderControl();
- rowControl = parent.getRowControl();
-
- setMenu(parent.getMenu());
-
- currentVisibleTopRow = topRow;
- showHeader();
- updateVisibleRows();
-
- if (numRowsVisible < 1) {
- createEmptyTablePlaceholer();
- }
- }
-
- public void setBackground(Color color) {
- super.setBackground(color);
- controlHolder.setBackground(color);
- }
-
- /**
- * Initialize the overall table UI.
- */
- private void initialize() {
- GridLayout gl = new GridLayout();
- gl.numColumns = 2;
- gl.verticalSpacing = 0;
- gl.marginWidth = 0;
- gl.marginHeight = 0;
- gl.horizontalSpacing = 0;
- this.setLayout(gl);
- createControlHolder();
- createVSliderHolder();
- createHSliderHolder();
- }
-
- /**
- * Initialize the controlHolder, which is the holder Composite for the
- * header object (if applicable) and the row objects.
- */
- private void createControlHolder() {
- hScroller = new Composite(this, SWT.NULL);
- GridData gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.grabExcessHorizontalSpace = true;
- gridData.grabExcessVerticalSpace = true;
- gridData.verticalAlignment = GridData.FILL;
- hScroller.setLayoutData(gridData);
-
- controlHolder = new Composite(hScroller, SWT.NONE);
-
- controlHolder.setLayout(new Layout() {
- protected Point computeSize(Composite composite, int wHint,
- int hHint, boolean flushCache) {
- if (rowControl != null) {
- int height = 0;
- int width = 0;
- if (headerControl != null) {
- Point headerSize = headerControl.getSize();
- width = headerSize.x;
- height = headerSize.y;
- }
- Point rowSize = rowControl.getSize();
- height += rowSize.y * 2;
- if (width < rowSize.x) {
- width = rowSize.x;
- }
- return new Point(height, width);
- }
- return new Point(50, 50);
- }
-
- protected void layout(Composite composite, boolean flushCache) {
- layoutControlHolder();
- }
- });
-
- hScroller.addControlListener(scrollerResizeHandler);
- }
-
- ControlAdapter scrollerResizeHandler = new ControlAdapter() {
- public void controlResized(ControlEvent e) {
- Point size = hScroller.getSize();
-
- if (fittingHorizontally) {
- controlHolder.setBounds(0, 0, size.x, size.y);
- return;
- }
-
- int preferredWidth = computePreferredWidth(size);
-
- if (preferredWidth > size.x && !isHSliderVisible()) {
- setHSliderVisible(true);
- }
- if (preferredWidth <= size.x && isHSliderVisible()) {
- setHSliderVisible(false);
- }
-
- if (parent.isWidthWiderThanAllColumns()) {
- controlHolder.setBounds(0, 0, size.x, size.y);
- return;
- }
-
- if (isHSliderVisible()) {
- hSlider.setMaximum(preferredWidth);
- hSlider.setPageIncrement(size.x);
- hSlider.setThumb(preferredWidth - (preferredWidth-size.x));
- int currentSelection = hSlider.getSelection();
- if (preferredWidth-currentSelection < size.x) {
- hSlider.setSelection(preferredWidth-size.x);
- }
- }
- hSlider.notifyListeners(SWT.Selection, new Event());
- }
-
- };
-
- protected int computePreferredWidth(Point size) {
- int preferredWidth = size.x;
-
- Control[] children = controlHolder.getChildren();
- if (children.length > 0) {
- if (children[0] instanceof Composite) {
- Composite child = (Composite) children[0];
- // children instanceof Composite && programmer supplied a layout manager --> getPreferredSize()
- if (child.getLayout() != null || child instanceof EmptyTablePlaceholder) {
- preferredWidth = controlHolder.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x;
- } else {
- // children instanceof Composite && layout == null
- int[] weights = parent.getWeights();
- if (weights == null || weights.length != child.getChildren().length) {
- throw new IllegalArgumentException("Number of weights != number of child controls");
- }
- preferredWidth = 0;
- for (int i = 0; i < weights.length; i++) {
- preferredWidth += weights[i]+4;
- }
- }
- } else {
- // children instanceof Control --> Use getPreferredSize()
- preferredWidth = controlHolder.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x;
- }
- }
- return preferredWidth;
- }
-
-
- /**
- * Initialize the sliderHolder and slider. The SliderHolder is a Composite
- * that is responsible for showing and hiding the vertical slider upon
- * request.
- */
- private void createVSliderHolder() {
- GridData gd = getVSliderGridData();
- vSliderHolder = new Composite(this, SWT.NULL);
- vSlider = new Slider(vSliderHolder, SWT.VERTICAL);
- vSlider.addSelectionListener(sliderSelectionListener);
- vSliderHolder.setLayout(new FillLayout());
- vSliderHolder.setLayoutData(gd);
- vSliderHolder.setTabList(new Control[] {});
- }
-
- /**
- * Initialize the sliderHolder and slider. The SliderHolder is a Composite
- * that is responsible for showing and hiding the vertical slider upon
- * request.
- */
- private void createHSliderHolder() {
- GridData gd = getHSliderGridData();
- hSliderHolder = new Composite(this, SWT.NULL);
- hSlider = new Slider(hSliderHolder, SWT.HORIZONTAL);
- hSlider.setMinimum(0);
- hSlider.setIncrement(20);
- hSlider.addSelectionListener(sliderSelectionListener);
- hSliderHolder.setLayout(new FillLayout());
- hSliderHolder.setLayoutData(gd);
- hSliderHolder.setTabList(new Control[] {});
- hSlider.addSelectionListener(hSliderSelectionListener);
- }
-
- // Slider utility methods
- // ---------------------------------------------------------------------
-
- /**
- * Returns a GridData for the SliderHolder appropriate for if the slider is
- * visible or not.
- *
- * @return A GridData with a widthHint of 0 if the slider is not visible or
- * with a widthHint of SWT.DEFAULT otherwise.
- */
- private GridData getVSliderGridData() {
- GridData gd = new GridData();
- gd.grabExcessVerticalSpace = true;
- gd.verticalAlignment = GridData.FILL;
- gd.verticalSpan = 1;
- if (!vSliderVisible) {
- gd.widthHint = 0;
- }
- return gd;
- }
-
- /**
- * Returns a GridData for the SliderHolder appropriate for if the slider is
- * visible or not.
- *
- * @return A GridData with a heightHint of 0 if the slider is not visible or
- * with a heightHint of SWT.DEFAULT otherwise.
- */
- private GridData getHSliderGridData() {
- GridData gd = new GridData();
- gd.grabExcessHorizontalSpace = true;
- gd.horizontalAlignment = GridData.FILL;
- gd.horizontalSpan = 1;
- if (!hSliderVisible) {
- gd.heightHint = 0;
- }
- return gd;
- }
-
- private boolean vSliderVisible = false;
-
- /**
- * Sets if the slider is visible or not.
- *
- * @param visible
- * true if the slider should be visible; false otherwise.
- */
- public void setVSliderVisible(boolean visible) {
- this.vSliderVisible = visible;
- vSliderHolder.setLayoutData(getVSliderGridData());
- if (visible) {
- Display.getCurrent().addFilter(SWT.KeyDown, displayKeyDownFilter);
- } else {
- Display.getCurrent().removeFilter(SWT.KeyDown, displayKeyDownFilter);
- }
- Display.getCurrent().asyncExec(new Runnable() {
- public void run() {
- if (!InternalCompositeTable.this.isDisposed() &&
- !vSliderHolder.isDisposed() &&
- !vSliderHolder.getParent().isDisposed())
- {
- vSliderHolder.getParent().layout(true);
- vSliderHolder.layout(true);
- Point sliderHolderSize = vSliderHolder.getSize();
- vSlider.setBounds(0, 0, sliderHolderSize.x, sliderHolderSize.y);
- }
- }
- });
- }
-
- /**
- * Returns if the slider is visible.
- *
- * @return true if the slider is visible; false otherwise.
- */
- public boolean isVSliderVisible() {
- return vSliderVisible;
- }
-
- private boolean hSliderVisible = false;
-
- /**
- * Sets if the slider is visible or not.
- *
- * @param visible
- * true if the slider should be visible; false otherwise.
- */
- public void setHSliderVisible(boolean visible) {
- this.hSliderVisible = visible;
- hSliderHolder.setLayoutData(getHSliderGridData());
- Display.getCurrent().asyncExec(new Runnable() {
- public void run() {
- if (!InternalCompositeTable.this.isDisposed() &&
- !hSliderHolder.isDisposed() &&
- !hSliderHolder.getParent().isDisposed())
- {
- hSliderHolder.getParent().layout(true);
- hSliderHolder.layout(true);
- Point sliderHolderSize = hSliderHolder.getSize();
- hSlider.setBounds(0, 0, sliderHolderSize.x, sliderHolderSize.y);
- }
- }
- });
- }
-
- /**
- * Returns if the slider is visible.
- *
- * @return true if the slider is visible; false otherwise.
- */
- public boolean isHSliderVisible() {
- return hSliderVisible;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.widgets.Widget#dispose()
- */
- public void dispose() {
- disposeRows(rows);
- disposeRows(spareRows);
- super.dispose();
- }
-
- /**
- * Disposes all the row objects in the specified LinkedList.
- *
- * @param rowsCollection
- * The collection containing TableRow objects to dispose.
- */
- private void disposeRows(LinkedList rowsCollection) {
- for (Iterator rowsIter = rowsCollection.iterator(); rowsIter.hasNext();) {
- TableRow row = (TableRow) rowsIter.next();
- if (row instanceof IRowFocusListener) {
- parent.removeRowFocusListener((IRowFocusListener) row);
- }
- if (row instanceof IRowContentProvider) {
- parent.removeRowContentProvider((IRowContentProvider) row);
- }
- row.dispose();
- }
- }
-
- // Row object layout
- // --------------------------------------------------------------------------
-
- /**
- * Layout the child controls within the controlHolder Composite.
- */
- protected void layoutControlHolder() {
- if (myHeader != null)
- layoutChild(myHeader, true);
- for (Iterator rowsIter = rows.iterator(); rowsIter.hasNext();) {
- TableRow row = (TableRow) rowsIter.next();
- layoutChild(row.getRowControl(), false);
- }
- updateVisibleRows();
- }
-
- /**
- * Layout a particular row or header control (child control of the
- * controlHolder). If the child control has a layout manager, we delegate to
- * that layout manager. Otherwise, we use the built in table layout manager.
- *
- * @param child
- * The row or header control to layout.
- * @param isHeader
- * TODO
- * @return height of child
- */
- private int layoutChild(Control child, boolean isHeader) {
- if (child instanceof Composite) {
- Composite composite = (Composite) child;
- if (composite.getLayout() == null) {
- return parent.layoutHeaderOrRow(composite, isHeader);
- }
- composite.layout(true);
- return composite.getSize().y;
- }
- return child.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).y;
- }
-
- // Table control layout -- utility methods
- // ----------------------------------------------------
-
- /**
- * Construct a header or row object on demand. Logs an error and returns
- * null on failure.
- *
- * @param parent
- * The SWT parent.
- * @param constructor
- * The header or row object's constructor.
- * @return The constructed control or null if none could be constructed.
- */
- private Control createInternalControl(Composite parent,
- Constructor constructor) {
- Control result = null;
- try {
- result = (Control) constructor.newInstance(new Object[] { parent,
- new Integer(SWT.NULL) });
- } catch (Exception e) {
- throw new IllegalArgumentException("Unable to construct control"); //$NON-NLS-1$
- }
- if (result instanceof IRowFocusListener) {
- this.parent.addRowFocusListener((IRowFocusListener) result);
- }
- if (result instanceof IRowContentProvider) {
- this.parent.addRowContentProvider((IRowContentProvider) result);
- }
- return result;
- }
-
- /**
- * If the header control hasn't been created yet, create and show it.
- */
- private void showHeader() {
- if (myHeader == null && headerConstructor != null) {
- myHeader = createInternalControl(controlHolder, headerConstructor);
- fireHeaderConstructionEvent(myHeader);
- if (myHeader instanceof Composite) {
- Composite headerComp = (Composite) myHeader;
- if (headerComp.getLayout() == null) {
- headerComp.addPaintListener(headerPaintListener);
- }
- }
- layoutChild(myHeader, true);
- }
- }
-
- // Table control layout -- main refresh algorithm
- // ---------------------------------------------
-
- /**
- * Main refresh algorithm entry point. This method refreshes everything in
- * the table:
- *
- * <ul>
- * <li>Makes sure the correct number of rows are visible
- * <li>Makes sure each row has been refreshed with data from the underlying
- * model
- * </ul>
- */
- void updateVisibleRows() {
- // If we don't have our prototype row object yet, bail out
- if (rowControl == null) {
- return;
- }
-
- clientAreaHeight = controlHolder.getSize().y;
- if (clientAreaHeight <= 0) {
- return;
- }
-
- int topPosition = 0;
-
- int headerHeight = 0;
- if (myHeader != null) {
- headerHeight = headerControl.getSize().y + 3;
- clientAreaHeight -= headerHeight;
- topPosition += headerHeight;
- }
- numRowsInDisplay = clientAreaHeight / getRowHeight(clientAreaHeight);
-
- // Make sure we have something to lay out to begin with
- int userScrollDirection = 0;
- if (numRowsInCollection > 0) {
- numRowsVisible = numRowsInDisplay;
-
- disposeEmptyTablePlaceholder();
-
- int displayableRows = numRowsInCollection - topRow;
- if (numRowsVisible > displayableRows) {
- numRowsVisible = displayableRows;
- }
- if (numRowsVisible > maxRowsVisible) {
- numRowsVisible = maxRowsVisible;
- }
- if (numRowsVisible < 1) {
- numRowsVisible = 1;
- }
-
- // Keep track of if we're scrolling forwards or backwards
- if (currentVisibleTopRow - topRow > 0) {
- userScrollDirection = ScrollEvent.BACKWARD;
- } else if (topRow - currentVisibleTopRow > 0) {
- userScrollDirection = ScrollEvent.FORWARD;
- }
-
- // Scroll the view so that the right number of row
- // objects are showing and they have the right data
- if (rows.size() - Math.abs(currentVisibleTopRow - topRow) > 0) {
-// if (currentRow >= numRowsVisible) {
-// deleteRowAt(0);
-// ++currentVisibleTopRow;
-// ++topRow;
-// --currentRow;
-// }
- scrollTop();
- fixNumberOfRows();
- } else {
- currentVisibleTopRow = topRow;
- fixNumberOfRows();
- refreshAllRows();
- }
- } else {
- numRowsVisible = 0;
- topRow = 0;
- currentRow = 0;
- currentColumn = 0;
- currentVisibleTopRow = 0;
- numRowsVisible = 0;
-
- if (emptyTablePlaceholder == null) {
- fixNumberOfRows();
- createEmptyTablePlaceholer();
- }
- }
-
- // Make sure that the currentRow is within the visible range
- // (after PgDn, it could wind up outside the visible range)
- if (currentRow >= numRowsVisible && getNumRowsVisible() < numRowsInDisplay) {
- currentRow = numRowsVisible-1;
- }
-
- // Show, hide, reset the scroll bar
- if (numRowsVisible < numRowsInCollection) {
- int extra = numRowsInCollection - numRowsVisible;
- int pageIncrement = numRowsVisible;
- if (pageIncrement > extra)
- pageIncrement = extra;
-
- vSlider.setMaximum(numRowsInCollection);
- vSlider.setMinimum(0);
- vSlider.setIncrement(1);
- vSlider.setPageIncrement(pageIncrement);
- vSlider.setThumb(numRowsInCollection
- - (numRowsInCollection - numRowsVisible));
-
- vSlider.setSelection(topRow);
-
- if (!isVSliderVisible()) {
- setVSliderVisible(true);
- }
- } else {
- setVSliderVisible(false);
- }
-
- // Lay out the header and rows correctly in the display
- int width = controlHolder.getSize().x;
-
- // First, the header...
- if (myHeader != null) {
- myHeader.setBounds(0, 0, width, headerHeight);
- }
-
- // Make sure we have rows to lay out...
- if (numRowsInCollection < 1) {
- return;
- }
-
- // Now the rows.
- int rowHeight = getRowHeight(clientAreaHeight);
-
- // We have to move the controls front-to-back if we're scrolling
- // forwards and back-to-front if we're scrolling backwards to avoid ugly
- // screen refresh artifacts.
- if (userScrollDirection == ScrollEvent.FORWARD || userScrollDirection == ScrollEvent.NONE) {
- for (Iterator rowsIter = rows.iterator(); rowsIter.hasNext();) {
- TableRow row = (TableRow) rowsIter.next();
- Control rowControl = row.getRowControl();
- rowControl.setBounds(0, topPosition, width, rowHeight);
- layoutChild(rowControl, false);
- topPosition += rowHeight;
- }
- } else {
- ListIterator rowsIter = rows.listIterator();
- while (rowsIter.hasNext()) {
- rowsIter.next();
- }
- topPosition += rowHeight * (rows.size() - 1);
- while (rowsIter.hasPrevious()) {
- TableRow row = (TableRow) rowsIter.previous();
- Control rowControl = row.getRowControl();
- rowControl.setBounds(0, topPosition, width, rowHeight);
- layoutChild(rowControl, false);
- topPosition -= rowHeight;
- }
- }
-
- // If we scrolled, tell clients about it
- if (userScrollDirection != ScrollEvent.NONE) {
- fireScrollEvent(new ScrollEvent(userScrollDirection, parent));
- }
- }
-
- int getRowHeight(int clientAreaHeight) {
- int rowControlHeight = rowControl.getSize().y;
- if (maxRowsVisible == Integer.MAX_VALUE) {
- return rowControlHeight;
- }
- if (fittingVertically) {
- int fitControlHeight = clientAreaHeight / maxRowsVisible;
- if (fitControlHeight < rowControlHeight) {
- return rowControlHeight;
- }
- return fitControlHeight;
- }
- return rowControlHeight;
- }
-
- /**
- * Utility method: Makes sure that the currently visible top row is the same
- * as the top row specified in the TopRow property.
- */
- private void scrollTop() {
- while (currentVisibleTopRow < topRow) {
- deleteRowAt(0);
- ++currentVisibleTopRow;
- }
- while (currentVisibleTopRow > topRow) {
- --currentVisibleTopRow;
- insertRowAt(0);
- }
- }
-
- /**
- * Utility method: Makes sure that the number of rows that are visible
- * correspond with what should be visible given the table control's size,
- * where it is scrolled, and the number of rows in the underlying
- * collection.
- */
- private void fixNumberOfRows() {
- int numRows = rows.size();
- while (numRows > numRowsVisible) {
- deleteRowAt(numRows - 1);
- numRows = rows.size();
- }
- while (numRows < numRowsVisible) {
- insertRowAt(numRows);
- numRows = rows.size();
- }
- }
-
- /**
- * Fire the refresh event on all visible rows.
- */
- void refreshAllRows() {
- int row = 0;
- for (Iterator rowsIter = rows.iterator(); rowsIter.hasNext();) {
- TableRow rowControl = (TableRow) rowsIter.next();
- fireRefreshEvent(topRow + row, rowControl.getRowControl());
- ++row;
- }
- }
-
- /**
- * Insert a new row object at the specified 0-based position relatve to the
- * topmost row.
- *
- * @param position
- * The 0-based position relative to the topmost row.
- */
- private void insertRowAt(int position) {
- TableRow newRow = getNewRow();
- if (position > rows.size()) {
- position = rows.size();
- }
- rows.add(position, newRow);
- fireRefreshEvent(currentVisibleTopRow + position, newRow
- .getRowControl());
- }
-
- /**
- * Delete the row at the specified 0-based position relative to the topmost
- * row.
- *
- * @param position
- * The 0-based position relative to the topmost row.
- */
- private void deleteRowAt(int position) {
- TableRow row = (TableRow) rows.remove(position);
- row.setVisible(false);
- spareRows.addLast(row);
- }
-
- /**
- * Utility method: Creates a new row object or recycles one that had been
- * previously created but was no longer needed.
- *
- * @return The new row object.
- */
- private TableRow getNewRow() {
- if (spareRows.size() > 0) {
- TableRow recycledRow = (TableRow) spareRows.removeFirst();
- recycledRow.setVisible(true);
- return recycledRow;
- }
- Control newControl = createInternalControl(controlHolder,
- rowConstructor);
- if (menu != null) {
- newControl.setMenu(menu);
- }
- fireRowConstructionEvent(newControl);
- TableRow newRow = new TableRow(this, newControl);
- if (newRow.getRowControl() instanceof Composite) {
- Composite rowComp = (Composite) newRow.getRowControl();
- if (rowComp.getLayout() == null) {
- rowComp.setBackground(getBackground());
- rowComp.addPaintListener(rowPaintListener);
- }
- }
- return newRow;
- }
-
- // Property getters/setters
- // --------------------------------------------------------------
-
- /*
- * These are internal API. <p> Plese refer to the JavaDoc on CompositeTable
- * for detailed description of these property methods.
- */
-
- /**
- * (non-API) Method getHeaderControl. Return the prototype control being
- * used as a header.
- *
- * @return The header control
- */
- public Control getHeaderControl() {
- return headerControl;
- }
-
- /**
- * Method setMaxRowsVisible. Sets the maximum number of rows that will be
- * permitted in the table at once. For example, setting this property to 1
- * will have the effect of creating a single editing area with a scroll bar
- * on the right allowing the user to scroll through all rows using either
- * the mouse or the PgUp/PgDn keys. The default value is Integer.MAX_VALUE.
- *
- * @param maxRowsVisible
- * the maximum number of rows that are permitted to be visible at
- * one time, regardless of the control's size.
- */
- public void setMaxRowsVisible(int maxRowsVisible) {
- this.maxRowsVisible = maxRowsVisible;
- updateVisibleRows();
- }
-
- /**
- * @param fittingVertically
- */
- public void setFittingVertically(boolean fittingVertically) {
- this.fittingVertically = fittingVertically;
- updateVisibleRows();
- }
-
- /**
- * @param fittingHorizontally
- */
- public void setFittingHorizontally(boolean fittingHorizontally) {
- this.fittingHorizontally = fittingHorizontally;
- this.layout(true);
- }
-
- /**
- * Method getNumRowsVisible. Returns the actual number of rows that are
- * currently visible. Normally CompositeTable displays as many rows as will
- * fit vertically given the control's size. This value can be clamped to a
- * maximum using the MaxRowsVisible property.
- *
- * @return the actual number of rows that are currently visible.
- */
- public int getNumRowsVisible() {
- return rows.size();
- }
-
- /**
- * Method setNumRowsInCollection. Sets the number of rows in the data
- * structure that is being edited.
- *
- * @param numRowsInCollection
- * the number of rows represented by the underlying data
- * structure.
- */
- public void setNumRowsInCollection(int numRowsInCollection) {
- this.topRow = 0;
- if (topRow + currentRow > numRowsInCollection) {
- if (topRow < numRowsInCollection) {
- currentRow = numRowsInCollection - topRow;
- } else {
- topRow = numRowsInCollection - 1;
- currentRow = 0;
- }
- deferredSetFocus(getCurrentRowControl(), false);
- }
- this.numRowsInCollection = numRowsInCollection;
- updateVisibleRows();
- refreshAllRows();
- }
-
- /**
- * Method setTopRow. Set the number of the line that is being displayed in
- * the top row of the CompositeTable editor (0-based). If the new top row is
- * not equal to the current top row, the table will automatically be
- * scrolled to the new position. This number must be greater than 0 and less
- * than NumRowsInCollection.
- *
- * @param topRow
- * the line number of the new top row.
- */
- public void setTopRow(int topRow) {
- fireRowDepartEvent();
- this.topRow = topRow;
- updateVisibleRows();
- fireRowArriveEvent();
- }
-
- /**
- * Method getTopRow. Return the number of the line that is being displayed
- * in the top row of the CompositeTable editor (0-based).
- *
- * @return the number of the top line.
- */
- public int getTopRow() {
- return topRow;
- }
-
- /**
- * Method getSelection. Returns the currently-selected (column, row) pair
- * where the row specifies the offset from the top of the table window. In
- * order to get the current row in the underlying data structure, use
- * getSelection().y + getCurrentRow().
- *
- * @return the currently-selected (column, row) pair where the row specifies
- * the offset from the top of the table window.
- */
- public Point getSelection() {
- return new Point(currentColumn, currentRow);
- }
-
- /**
- * Method setSelection. Sets the currently-selected (column, row) pair where
- * the row specifies the offset from the top of the table window. In order
- * to get the current row in the underlying data structure, use
- * getSelection().y + getCurrentRow().
- *
- * @param column
- * the column to select
- * @param row
- * the row to select
- */
- public void setSelection(int column, int row) {
- int topRowDelta = computeTopRowDelta(row);
- if (topRowDelta != 0) {
- setTopRow(topRow + topRowDelta);
- row += -1 * topRowDelta;
- internalSetSelection(column, row, true);
- } else {
- if (row == currentRow)
- internalSetSelection(column, row, false);
- else {
- if (fireRequestRowChangeEvent())
- internalSetSelection(column, row, true);
- }
- }
- }
-
- /**
- * Method setWeights. Indicates that the column weights were just set and we
- * should re-layout the control holder object.
- */
- public void setWeights() {
- layoutControlHolder();
- }
-
- // Refresh Event API
- // --------------------------------------------------------------------------
-
- /**
- * Adds the specified listener to the set of listeners that will be notified
- * when a row refresh event occurs.
- *
- * @param listener
- * the listener to add.
- */
- public void addRefreshContentProvider(IRowContentProvider listener) {
- parent.contentProviders.add(listener);
- }
-
- /**
- * Remove the specified listener from the set of listeners that will be
- * notified when a row refresh event occurs.
- *
- * @param listener
- * the listener to remove.
- */
- public void removeRefreshContentProvider(IRowContentProvider listener) {
- parent.contentProviders.remove(listener);
- }
-
- private void fireRefreshEvent(int positionInCollection, Control rowControl) {
- if (numRowsInCollection < 1) {
- return;
- }
- for (Iterator refreshListenersIter = parent.contentProviders.iterator(); refreshListenersIter
- .hasNext();) {
- IRowContentProvider listener = (IRowContentProvider) refreshListenersIter
- .next();
- listener.refresh(parent, positionInCollection, rowControl);
- }
- }
-
- // Empty table placeholder
- // --------------------------------------------------------------------
-
- private void createEmptyTablePlaceholer() {
- emptyTablePlaceholder = new EmptyTablePlaceholder(controlHolder,
- SWT.NULL);
- if (rowControl != null)
- emptyTablePlaceholder.setBackground(rowControl.getBackground());
- emptyTablePlaceholder.setMessage(parent.getInsertHint());
- }
-
- private void disposeEmptyTablePlaceholder() {
- if (emptyTablePlaceholder != null) {
- emptyTablePlaceholder.dispose();
- emptyTablePlaceholder = null;
- }
- }
-
- // Event Handling
- // -----------------------------------------------------------------------------
-
- private boolean needToRequestRC = true;
-
- private Listener displayKeyDownFilter = new Listener() {
- public void handleEvent(Event event) {
- if (rowControl.getClass().isAssignableFrom(event.widget.getClass())) {
- makeFocusedRowVisible();
- }
- }
- };
-
- /**
- * Handle a keyPressed event on any row control.
- *
- * @param sender
- * The row that is sending the event
- * @param e
- * the actual KeyEvent
- */
- public void keyPressed(TableRow sender, KeyEvent e) {
- if (makeFocusedRowVisible()) return;
-
- if ((e.stateMask & SWT.CONTROL) != 0) {
- switch (e.keyCode) {
- case SWT.HOME:
- if (topRow <= 0) {
- return;
- }
-
- if (!fireRequestRowChangeEvent()) {
- return;
- }
- needToRequestRC = false;
-
- deselect(e.widget);
-
- // If the focus is already in the top visible row, we will need
- // to explicitly
- // fire an arrive event.
- boolean needToArrive = true;
- if (currentRow > 0) {
- needToArrive = false;
- }
-
- setTopRow(0);
-
- if (needToArrive) {
- internalSetSelection(currentColumn, 0, true);
- } else {
- internalSetSelection(currentColumn, 0, false);
- }
- return;
- case SWT.END:
- if (topRow + numRowsVisible < numRowsInCollection) {
- if (!fireRequestRowChangeEvent()) {
- return;
- }
- needToRequestRC = false;
-
- deselect(e.widget);
-
- // If the focus is already in the last visible row, we will
- // need to explicitly
- // fire an arrive event.
- needToArrive = true;
- if (currentRow < numRowsVisible - 1) {
- needToArrive = false;
- }
-
- setTopRow(numRowsInCollection - numRowsVisible);
-
- if (needToArrive) {
- internalSetSelection(currentColumn, numRowsVisible - 1,
- true);
- } else {
- internalSetSelection(currentColumn, numRowsVisible - 1,
- false);
- }
- }
- return;
- case SWT.INSERT:
- // If no insertHandler has been registered, bail out
- if (parent.insertHandlers.size() < 1) {
- return;
- }
-
- // Make sure we can leave the current row
- if (!fireRequestRowChangeEvent()) {
- return;
- }
- needToRequestRC = false;
-
- // Insert the new object
- int newRowPosition = fireInsertEvent();
- if (newRowPosition < 0) {
- // This should never happen, but...
- return;
- }
-
- disposeEmptyTablePlaceholder();
-
- // If the current widget has a selection, deselect it
- deselect(e.widget);
-
- // If the new row is in the visible space, refresh it
- if (topRow <= newRowPosition
- && numRowsVisible > newRowPosition - topRow) {
- insertRowAt(newRowPosition - topRow);
- ++numRowsInCollection;
- updateVisibleRows();
- int newRowNumber = newRowPosition - topRow;
- if (newRowNumber != currentRow) {
- internalSetSelection(currentColumn, newRowNumber, false);
- } else {
- internalSetSelection(currentColumn, newRowNumber, true);
- }
- return;
- }
-
- // else...
-
- ++numRowsInCollection;
-
- // If the new row is above us, scroll up to it
- if (newRowPosition < topRow + currentRow) {
- setTopRow(newRowPosition);
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- updateVisibleRows();
- if (currentRow != 0) {
- internalSetSelection(currentColumn, 0, false);
- } else {
- internalSetSelection(currentColumn, 0, true);
- }
- }
- });
- } else {
- // If we're appending
- if (numRowsInDisplay > numRowsVisible) {
- updateVisibleRows();
- int newRowNumber = newRowPosition - topRow;
- if (newRowNumber != currentRow) {
- internalSetSelection(currentColumn, newRowNumber,
- false);
- } else {
- internalSetSelection(currentColumn, newRowNumber,
- true);
- }
- } else {
- // It's somewhere in the middle below us; scroll down to
- // it
- setTopRow(newRowPosition - numRowsVisible + 1);
- int newRowNumber = numRowsVisible - 1;
- if (newRowNumber != currentRow) {
- internalSetSelection(currentColumn, newRowNumber,
- false);
- } else {
- internalSetSelection(currentColumn, newRowNumber,
- true);
- }
- }
- }
- return;
- case SWT.DEL:
- if (fireDeleteEvent()) {
- // We know the object is gone if we made it here, so now
- // refresh the display...
- --numRowsInCollection;
-
- // If we deleted the last row in the list
- if (currentRow >= numRowsVisible - 1) {
- // If that wasn't the last row in the collection, move
- // the focus
- if (numRowsInCollection > 0) {
-
- // If we're only displaying one row, scroll first
- if (currentRow < 1) {
- needToRequestRC = false;
- deleteRowAt(currentRow);
- setTopRow(topRow - 1);
- internalSetSelection(currentColumn, currentRow,
- true);
- } else {
- needToRequestRC = false;
- internalSetSelection(currentColumn,
- currentRow - 1, false);
- Display.getCurrent().asyncExec(new Runnable() {
- public void run() {
- deleteRowAt(currentRow + 1);
- updateVisibleRows();
- }
- });
- }
- } else {
- // Otherwise, show the placeholder object and give
- // it focus
- deleteRowAt(currentRow);
- --numRowsVisible;
- createEmptyTablePlaceholer();
- emptyTablePlaceholder.setFocus();
- }
- } else {
- // else, keep the focus where it was
- deleteRowAt(currentRow);
- updateVisibleRows();
- internalSetSelection(currentColumn, currentRow, true);
- }
- }
- return;
- default:
- return;
- }
- }
- switch (e.keyCode) {
- case SWT.ARROW_UP:
- if (maxRowsVisible <= 1)
- return;
-
- if (currentRow > 0) {
- if (!fireRequestRowChangeEvent()) {
- return;
- }
- needToRequestRC = false;
-
- deselect(e.widget);
-
- internalSetSelection(currentColumn, currentRow - 1, false);
- return;
- }
- if (topRow > 0) {
- if (!fireRequestRowChangeEvent()) {
- return;
- }
- needToRequestRC = false;
-
- deselect(e.widget);
-
- setTopRow(topRow - 1);
- internalSetSelection(currentColumn, currentRow, true);
- return;
- }
- return;
- case SWT.ARROW_DOWN:
- if (maxRowsVisible <= 1)
- return;
-
- if (currentRow < numRowsVisible - 1) {
- if (!fireRequestRowChangeEvent()) {
- return;
- }
- needToRequestRC = false;
-
- deselect(e.widget);
-
- internalSetSelection(currentColumn, currentRow + 1, false);
- return;
- }
- if (topRow + numRowsVisible < numRowsInCollection) {
- if (!fireRequestRowChangeEvent()) {
- return;
- }
- needToRequestRC = false;
-
- deselect(e.widget);
-
- setTopRow(topRow + 1);
- internalSetSelection(currentColumn, currentRow, true);
- return;
- }
- return;
- case SWT.PAGE_UP:
- if (topRow > 0) {
- if (!fireRequestRowChangeEvent()) {
- return;
- }
- needToRequestRC = false;
-
- int newTopRow = topRow - numRowsInDisplay;
- if (newTopRow < 0) {
- newTopRow = 0;
- }
- setTopRow(newTopRow);
- internalSetSelection(currentColumn, currentRow, true);
- }
- return;
- case SWT.PAGE_DOWN:
- if (topRow + numRowsVisible < numRowsInCollection) {
- if (!fireRequestRowChangeEvent()) {
- return;
- }
- needToRequestRC = false;
-
- int newTopRow = topRow + numRowsVisible;
- if (newTopRow >= numRowsInCollection - 1) {
- newTopRow = numRowsInCollection - 1;
- }
- setTopRow(newTopRow);
- internalSetSelection(currentColumn, currentRow, true);
- }
- return;
- }
- }
-
- /**
- * Handle the keyTraversed event on any child control in the table.
- *
- * @param sender
- * The row sending the event.
- * @param e
- * The SWT TraverseEvent
- */
- public void keyTraversed(TableRow sender, TraverseEvent e) {
- if (makeFocusedRowVisible()) return;
-
- if (parent.isTraverseOnTabsEnabled()) {
- if (e.detail == SWT.TRAVERSE_TAB_NEXT) {
- if (currentColumn >= sender.getNumColumns() - 1) {
- e.detail = SWT.TRAVERSE_NONE;
- handleNextRowNavigation();
- }
- } else if (e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
- if (currentColumn == 0) {
- e.detail = SWT.TRAVERSE_NONE;
- handlePreviousRowNavigation(sender);
- }
- } else if (e.detail == SWT.TRAVERSE_RETURN) {
- e.detail = SWT.TRAVERSE_NONE;
- if (currentColumn >= sender.getNumColumns() - 1) {
- handleNextRowNavigation();
- } else {
- deferredSetFocus(getControl(currentColumn + 1, currentRow),
- false);
- }
- }
- } else {
- if (e.detail == SWT.TRAVERSE_TAB_NEXT) {
- if (currentColumn >= sender.getNumColumns() - 1) {
- e.detail = SWT.TRAVERSE_NONE;
- }
- } else if (e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
- if (currentColumn == 0) {
- e.detail = SWT.TRAVERSE_NONE;
- }
- }
- }
- }
-
- /**
- * Makes sure that the focused row is visible
- *
- * @return true if the display needed to be scrolled; false otherwise
- */
- public boolean makeFocusedRowVisible() {
- if (numRowsVisible < 1) {
- return false;
- }
- int topRowDelta = computeTopRowDelta(currentRow);
- if (topRowDelta == 0) {
- return false;
- }
- currentRow += -1 * topRowDelta;
-
- setTopRow(topRow + topRowDelta);
- Control control = getControl(currentColumn, currentRow);
- if (control != null) {
- control.setFocus(); // ?? Can I get away with avoiding asyncExec here ??
- }
- return true;
- }
-
- private int computeTopRowDelta(int row) {
- int topRowDelta;
- if (row < 0) {
- topRowDelta = row;
- } else if (row >= getNumRowsVisible()) {
- topRowDelta = row - getNumRowsVisible() + 1;
- } else {
- return 0;
- }
- return topRowDelta;
- }
-
- /**
- * The SelectionListener for the table's vertical slider control.
- */
- private SelectionListener sliderSelectionListener = new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- if (vSlider.getSelection() == topRow) {
- return;
- }
-
- if (!fireRequestRowChangeEvent()) {
- vSlider.setSelection(topRow);
- return;
- }
-
- deselectCurrentRowIfVisible();
-
- int delta = topRow - vSlider.getSelection();
- int oldCurrentRow = currentRow;
- currentRow += delta;
-
- setTopRow(vSlider.getSelection());
-
- // If the focused row just became visible, show the focus
- if (oldCurrentRow < 0 || oldCurrentRow >= getNumRowsVisible()) {
- if (currentRow >= 0 && currentRow < getNumRowsVisible()) {
- Control newFocusControl = getControl(currentColumn, currentRow);
- if (newFocusControl == null) {
- return;
- }
- if (newFocusControl.isFocusControl()) {
- newFocusControl.notifyListeners(SWT.FocusIn, new Event());
- } else {
- deferredSetFocus(newFocusControl, true);
- }
- }
- } else {
- // If the new viewport doesn't overlap the old one, hide the focus
- if (currentRow < 0 || currentRow >= getNumRowsVisible()) {
- // deleteRowAt(oldCurrentRow);
-// getControl(currentColumn, oldCurrentRow).getParent().setVisible(false);
-// getControl(currentColumn, oldCurrentRow).getParent().setVisible(true);
- Control control = getControl(currentColumn, oldCurrentRow);
- if (control != null) {
- control.notifyListeners(SWT.FocusOut, new Event());
- }
- }
- }
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
- };
-
- private SelectionListener hSliderSelectionListener = new SelectionListener() {
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e) {
- Point scrollerSize = hScroller.getSize();
- int preferredWidth = computePreferredWidth(scrollerSize);
- Rectangle controlHolderBounds = new Rectangle(-1 * hSlider.getSelection(), 0, preferredWidth, scrollerSize.y);
- controlHolder.setBounds(controlHolderBounds);
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
- };
-
- /**
- * Scroll wheel event handling.
- */
- public void handleEvent(Event event) {
- if (event.count > 0) {
- if (topRow > 0) {
- if (!fireRequestRowChangeEvent()) {
- return;
- }
- deselectCurrentRowIfVisible();
- setTopRow(topRow - 1);
- ++currentRow;
- if (currentRow == 0) {
- deferredSetFocus(getControl(currentColumn, currentRow), true);
- }
- }
- } else {
- if (topRow < numRowsInCollection - numRowsVisible) {
- if (!fireRequestRowChangeEvent()) {
- return;
- }
- deselectCurrentRowIfVisible();
- setTopRow(topRow + 1);
- --currentRow;
- if (currentRow == getNumRowsVisible()-1) {
- deferredSetFocus(getControl(currentColumn, currentRow), true);
- }
- }
- }
- }
-
- private void deselectCurrentRowIfVisible() {
- if (currentRow >= 0 && currentRow < numRowsVisible) {
- Control control = getControl(currentColumn, currentRow);
- if (control != null) {
- deselect(control);
- }
- }
- }
-
- /**
- * Handle focusLost events on any child control. This is not currently used.
- *
- * @param sender
- * The row containing the sending control.
- * @param e
- * The SWT FocusEvent.
- */
- public void focusLost(TableRow sender, FocusEvent e) {
- }
-
- /**
- * Handle focusGained events on any child control.
- *
- * FIXME: Needs to automatically scroll horizontally if the newly-focused
- * control is fully or partially occluded.
- *
- * @param sender
- * The row containing the sending control.
- * @param e
- * The SWT FocusEvent.
- */
- public void focusGained(TableRow sender, FocusEvent e) {
- boolean rowChanged = false;
- int senderRowNumber = getRowNumber(sender);
- if (senderRowNumber != currentRow) {
- if (needToRequestRC) {
- if (!fireRequestRowChangeEvent()) {
- // Go back if we're not allowed to be here
- deferredSetFocus(getControl(currentColumn, currentRow),
- false);
- }
- } else {
- needToRequestRC = true;
- }
- rowChanged = true;
- }
-
- currentRow = senderRowNumber;
- currentColumn = sender.getColumnNumber((Control) e.widget);
-
- if (rowChanged)
- fireRowArriveEvent();
- }
-
- private PaintListener headerPaintListener = new PaintListener() {
- public void paintControl(PaintEvent e) {
- if (parent.linesVisible) {
- drawGridLines(e, true);
- }
- }
- };
-
- private PaintListener rowPaintListener = new PaintListener() {
- public void paintControl(PaintEvent e) {
- if (parent.linesVisible) {
- drawGridLines(e, false);
- }
- }
- };
-
- private void drawGridLines(PaintEvent e, boolean isHeader) {
- Color oldColor = e.gc.getForeground();
- try {
- // Get the colors we need
- Display display = Display.getCurrent();
- Color lineColor = display
- .getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW);
- Color secondaryColor = display
- .getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
- Color hilightColor = display
- .getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
- if (!isHeader) {
- lineColor = display
- .getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
- }
-
- // Get the control
- Control toPaint = (Control) e.widget;
- Point controlSize = toPaint.getSize();
-
- // Draw the bottom line(s)
- e.gc.setForeground(lineColor);
- e.gc.drawLine(0, controlSize.y - 1, controlSize.x,
- controlSize.y - 1);
- if (isHeader) {
- e.gc.setForeground(secondaryColor);
- e.gc.drawLine(0, controlSize.y - 2, controlSize.x,
- controlSize.y - 2);
- e.gc.setForeground(hilightColor);
- e.gc.drawLine(0, 1, controlSize.x, 1);
- }
-
- // Now draw lines around the child controls, if there are any
- if (toPaint instanceof Composite) {
- Composite row = (Composite) toPaint;
- Control[] children = row.getChildren();
- for (int i = 0; i < children.length; i++) {
- Rectangle childBounds = children[i].getBounds();
-
- // Paint the beginning lines
- if (isHeader) {
- e.gc.setForeground(hilightColor);
- e.gc.drawLine(childBounds.x - 2, 1, childBounds.x - 2,
- controlSize.y - 2);
- }
-
- // Paint the ending lines
- e.gc.setForeground(lineColor);
- int lineLeft = childBounds.x + childBounds.width + 1;
- e.gc.drawLine(lineLeft, 0, lineLeft, controlSize.y);
- if (isHeader) {
- e.gc.setForeground(secondaryColor);
- e.gc.drawLine(lineLeft - 1, 0, lineLeft - 1,
- controlSize.y - 1);
- }
- }
- }
- } finally {
- e.gc.setForeground(oldColor);
- }
- }
-
- // Event Firing
- // -------------------------------------------------------------------------------
-
- /**
- * Fire the row construction event
- *
- * @param newControl
- * The new row's SWT control
- */
- private void fireRowConstructionEvent(Control newControl) {
- for (Iterator rowConstructionListenersIter = parent.rowConstructionListeners
- .iterator(); rowConstructionListenersIter.hasNext();) {
- RowConstructionListener listener = (RowConstructionListener) rowConstructionListenersIter
- .next();
- listener.rowConstructed(newControl);
- }
- }
-
- /**
- * Fire the row construction event
- *
- * @param newControl
- * The new row's SWT control
- */
- private void fireHeaderConstructionEvent(Control newControl) {
- for (Iterator rowConstructionListenersIter = parent.rowConstructionListeners
- .iterator(); rowConstructionListenersIter.hasNext();) {
- RowConstructionListener listener = (RowConstructionListener) rowConstructionListenersIter
- .next();
- listener.headerConstructed(newControl);
- }
- }
-
- /**
- * Indicate to listeners that the focus is arriving on the specified row
- */
- private void fireRowArriveEvent() {
- if (rows.size() < 1 || currentRow < 0) {
- return;
- }
- for (Iterator rowChangeListenersIter = parent.rowFocusListeners
- .iterator(); rowChangeListenersIter.hasNext();) {
- IRowFocusListener listener =
- (IRowFocusListener) rowChangeListenersIter.next();
- // currentRow() can be null if it's scrolled off the top or bottom
- TableRow row = currentRow();
- Control control = row != null ? row.getRowControl() : null;
- listener.arrive(parent, topRow + currentRow, control);
- }
- }
-
- /**
- * Request permission from all listeners to leave the current row.
- *
- * @return true if all listeners permit the row change; false otherwise.
- */
- private boolean fireRequestRowChangeEvent() {
- if (rows.size() < 1 || currentRow < 1) {
- return true;
- }
- if (currentRow > rows.size() - 1) {
- // (if the other row is already gone)
- return true;
- }
- for (Iterator rowChangeListenersIter = parent.rowFocusListeners
- .iterator(); rowChangeListenersIter.hasNext();) {
- IRowFocusListener listener = (IRowFocusListener) rowChangeListenersIter
- .next();
- // currentRow() can be null if it's scrolled off the top or bottom
- TableRow row = currentRow();
- Control control = row != null ? row.getRowControl() : null;
- if (!listener.requestRowChange(parent, topRow + currentRow,
- control)) {
- return false;
- }
- }
- fireRowDepartEvent();
- return true;
- }
-
- /**
- * Indicate to listeners that the focus is about to leave the current row.
- */
- private void fireRowDepartEvent() {
- if (rows.size() < 1 || currentRow < 1) {
- return;
- }
- for (Iterator rowChangeListenersIter = parent.rowFocusListeners
- .iterator(); rowChangeListenersIter.hasNext();) {
- IRowFocusListener listener = (IRowFocusListener) rowChangeListenersIter
- .next();
- // currentRow() can be null if it's scrolled off the top or bottom
- TableRow row = currentRow();
- Control control = row != null ? row.getRowControl() : null;
- listener.depart(parent, topRow + currentRow, control);
- }
- }
-
- /**
- * Request deletion of the current row from the underlying data structure.
- *
- * @return true if the deletion was successful; false otherwise.
- */
- private boolean fireDeleteEvent() {
- if (parent.deleteHandlers.size() < 1) {
- return false;
- }
-
- int absoluteRow = topRow + currentRow;
- for (Iterator deleteHandlersIter = parent.deleteHandlers.iterator(); deleteHandlersIter
- .hasNext();) {
- IDeleteHandler handler = (IDeleteHandler) deleteHandlersIter.next();
- if (!handler.canDelete(absoluteRow)) {
- return false;
- }
- }
- for (Iterator deleteHandlersIter = parent.deleteHandlers.iterator(); deleteHandlersIter
- .hasNext();) {
- IDeleteHandler handler = (IDeleteHandler) deleteHandlersIter.next();
- handler.deleteRow(absoluteRow);
- }
- return true;
- }
-
- /**
- * Request that the model insert a new row into itself.
- *
- * @return The 0-based offset of the new row from the start of the
- * collection or -1 if a new row could not be inserted.
- */
- private int fireInsertEvent() {
- if (parent.insertHandlers.size() < 1) {
- return -1;
- }
-
- for (Iterator insertHandlersIter = parent.insertHandlers.iterator(); insertHandlersIter
- .hasNext();) {
- IInsertHandler handler = (IInsertHandler) insertHandlersIter.next();
- int resultRow = handler.insert(topRow + currentRow);
- if (resultRow >= 0) {
- return resultRow;
- }
- }
-
- return -1;
- }
-
- /**
- * Tell listeners that we just scrolled.
- * @param scrollEvent TODO
- */
- private void fireScrollEvent(ScrollEvent scrollEvent) {
- if (parent.scrollListeners.size() < 1) {
- return;
- }
-
- for (Iterator scrollListenersIter = parent.scrollListeners.iterator(); scrollListenersIter.hasNext();) {
- ScrollListener scrollListener = (ScrollListener) scrollListenersIter.next();
- scrollListener.tableScrolled(scrollEvent);
- }
- }
-
- // Event Handling, utility methods
- // ------------------------------------------------------------
-
- /**
- * Set the widget's selection to an empty selection.
- *
- * @param widget
- * The widget to deselect
- */
- private void deselect(Widget widget) {
- if (DuckType.instanceOf(ISelectableRegionControl.class, widget)) {
- ISelectableRegionControl control = (ISelectableRegionControl) DuckType
- .implement(ISelectableRegionControl.class, widget);
- control.setSelection(0, 0);
- }
- }
-
- /**
- * Try to go to the next row in the collection.
- */
- private void handleNextRowNavigation() {
- if (currentRow < numRowsVisible - 1) {
- if (!fireRequestRowChangeEvent()) {
- return;
- }
- needToRequestRC = false;
-
- deselect(getControl(currentColumn, currentRow));
-
- deferredSetFocus(getControl(0, currentRow + 1), false);
- } else {
- if (topRow + numRowsVisible >= numRowsInCollection) {
- // We're at the end; don't go anywhere
- return;
- }
- // We have to scroll forwards
- if (!fireRequestRowChangeEvent()) {
- return;
- }
- needToRequestRC = false;
-
- deselect(getControl(currentColumn, currentRow));
-
- setTopRow(topRow + 1);
- deferredSetFocus(getControl(0, currentRow), true);
- }
- }
-
- /**
- * Try to go to the previous row in the collection.
- *
- * @param row
- * The current table row.
- */
- private void handlePreviousRowNavigation(TableRow row) {
- if (currentRow == 0) {
- if (topRow == 0) {
- // We're at the beginning of the table; don't go anywhere
- return;
- }
- // We have to scroll backwards
- if (!fireRequestRowChangeEvent()) {
- return;
- }
- needToRequestRC = false;
-
- deselect(getControl(currentColumn, currentRow));
-
- setTopRow(topRow - 1);
- deferredSetFocus(getControl(row.getNumColumns() - 1, 0), true);
- } else {
- if (!fireRequestRowChangeEvent()) {
- return;
- }
- needToRequestRC = false;
-
- deselect(getControl(currentColumn, currentRow));
-
- deferredSetFocus(
- getControl(row.getNumColumns() - 1, currentRow - 1), false);
- }
- }
-
- /**
- * Gets the current TableRow.
- *
- * @return the current TableRow
- */
- private TableRow currentRow() {
- if (currentRow > rows.size() - 1) {
- return null;
- }
- return (TableRow) rows.get(currentRow);
- }
-
- /**
- * Returns the SWT control corresponding to the current row.
- *
- * @return the current row control.
- */
- public Control getCurrentRowControl() {
- TableRow currentRow = currentRow();
- if (currentRow == null) {
- return null;
- }
- return currentRow().getRowControl();
- }
-
- /**
- * Method getRowControls. Returns an array of SWT controls where each
- * control represents a row control in the CompositeTable's current scrolled
- * position. If CompositeTable is resized, scrolled, such that the rows that
- * the CompositeTable control is displaying change in any way, the array
- * that is returned by this method will become out of date and need to be
- * retrieved again.
- *
- * @return Control[] An array of SWT Control objects, each representing an
- * SWT row object.
- */
- public Control[] getRowControls() {
- Control[] rowControls = new Control[rows.size()];
- for (int i = 0; i < rowControls.length; i++) {
- rowControls[i] = getRowByNumber(i).getRowControl();
- }
- return rowControls;
- }
-
- private Menu menu = null;
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#setMenu(org.eclipse.swt.widgets.Menu)
- */
- public void setMenu(final Menu menu) {
- this.menu = menu;
- setMenuOnCollection(rows, menu);
- setMenuOnCollection(spareRows, menu);
- }
-
- private void setMenuOnCollection(LinkedList collection, Menu menu) {
- for (Iterator rowsIter = collection.iterator(); rowsIter.hasNext();) {
- TableRow row = (TableRow) rowsIter.next();
- row.getRowControl().setMenu(menu);
- }
- }
-
-
-
- /**
- * Method getControlRow. Given a row control, returns its row number
- * relative to the topRow.
- *
- * @param rowControl The row object to find
- * @return The row number of the rowControl relative to the topRow (0-based)
- * @throws IllegalArgumentException if rowControl is not currently visible
- */
- public int getControlRow(Control rowControl) {
- for (int row = 0; row < rows.size(); row++) {
- if (getRowByNumber(row).getRowControl() == rowControl) {
- return row;
- }
- }
- throw new IllegalArgumentException("getControlRow passed a control that is not visible inside CompositeTable");
- }
-
- /**
- * Method getControlRowObject. Given a row control, returns its row number
- * relative to the topRow.
- *
- * @param rowControl The row object to find
- * @return The row object managing the rowControl
- * @throws IllegalArgumentException if rowControl is not currently visible
- */
- public TableRow getControlRowObject(Control rowControl) {
- for (Iterator rowsIter = rows.iterator(); rowsIter.hasNext();) {
- TableRow row = (TableRow) rowsIter.next();
- if (row.getRowControl() == rowControl) {
- return row;
- }
- }
- throw new IllegalArgumentException("getControlRowObject passed a control that is not visible inside CompositeTable");
- }
-
- /**
- * Returns the TableRow by the specified 0-based offset from the top visible
- * row.
- *
- * @param rowNumber
- * 0-based offset of the requested fow starting from the top
- * visible row.
- * @return The corresponding TableRow or null if there is none.
- */
- private TableRow getRowByNumber(int rowNumber) {
- if (rowNumber > rows.size() - 1 || rowNumber < 0) {
- return null;
- }
- return (TableRow) rows.get(rowNumber);
- }
-
- /**
- * Return the SWT control at (column, row), where row is a 0-based number
- * starting from the top visible row.
- *
- * @param column
- * the 0-based column.
- * @param row
- * the 0-based row starting from the top visible row.
- * @return the SWT control at (column, row)
- */
- private Control getControl(int column, int row) {
- TableRow rowObject = getRowByNumber(row);
- if (rowObject == null) {
- throw new IndexOutOfBoundsException("Request for a nonexistent row"); //$NON-NLS-1$
- }
- Control result = rowObject.getColumnControl(column);
- return result;
- }
-
- /**
- * Return the 0-based row number corresponding to a particular TableRow
- * object.
- *
- * @param row
- * The TableRow to translate to row coordinates.
- * @return the 0-based row number or -1 if the specified TableRow is not
- * visible.
- */
- private int getRowNumber(TableRow row) {
- int rowNumber = 0;
- for (Iterator rowIter = rows.iterator(); rowIter.hasNext();) {
- TableRow candidate = (TableRow) rowIter.next();
- if (candidate == row) {
- return rowNumber;
- }
- ++rowNumber;
- }
- return -1;
- }
-
- /**
- * Set the focus to the specified (column, row). If rowChange is true, fire
- * a row change event, otherwise be silent.
- *
- * @param column
- * The 0-based column to focus
- * @param row
- * The 0-based row to focus
- * @param rowChange
- * true if a row change event should be fired; false otherwise.
- */
- private void internalSetSelection(int column, int row, boolean rowChange) {
- Control toFocus = getControl(column, row);
- if (toFocus == null) {
- return;
- }
- if (toFocus.isFocusControl()) {
- toFocus.notifyListeners(SWT.FocusIn, new Event());
- } else {
- deferredSetFocus(toFocus, rowChange);
- }
- }
-
- /**
- * Set the focus to the specified control after allowing all pending events
- * to complete first. If rowChange is true, fire a row arrive event after
- * the focus has been set.
- *
- * @param toFocus
- * The SWT Control to focus
- * @param rowChange
- * true if the rowArrive event should be fired; false otherwise.
- */
- private void deferredSetFocus(final Control toFocus, final boolean rowChange) {
- if (toFocus == null) {
- return;
- }
- Display.getCurrent().asyncExec(new Runnable() {
- public void run() {
- toFocus.setFocus();
- if (rowChange) {
- fireRowArriveEvent();
- }
- }
- });
- }
-
-
-} \ No newline at end of file
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/RowConstructionListener.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/RowConstructionListener.java
deleted file mode 100644
index 3f34aa0f..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/RowConstructionListener.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2005 David Orme <djo@coconut-palm-software.com>
- *
- * 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:
- * David Orme - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.compositetable;
-
-import org.eclipse.swt.widgets.Control;
-
-/**
- * Class RowConstructionListener. An "interface" for objects that need to
- * listen to row object construction events.
- *
- * @author djo
- */
-public abstract class RowConstructionListener {
- /**
- * Method rowConstructed. Called when the CompositeTable creates a new row
- * object. CompositeTable only creates a new row object when it needs on in
- * order to fill vacant space. During its life cycle, it never disposes a
- * row object, but rather caches unused row objects for later reuse if
- * needed. All row objects are disposed when the CompositeTable itself is
- * disposed.
- *
- * @param newRow
- * The new row object that was just constructed.
- */
- public abstract void rowConstructed(Control newRow);
-
- /**
- * Method headerConstructed. Called when the CompositeTable creates a new
- * header object. CompositeTable only creates a new header when the runTime
- * property is set to true. This method permits clients to modify the header
- * control that was created from the prototype header control as needed.
- *
- * @param newHeader
- * The new header object that was just constructed.
- */
- public abstract void headerConstructed(Control newHeader);
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/RowFocusAdapter.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/RowFocusAdapter.java
deleted file mode 100644
index fa340cae..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/RowFocusAdapter.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * 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.examples.databinding.compositetable;
-
-import org.eclipse.swt.widgets.Control;
-
-/**
- * An interface for objects that want to listen to and have the
- * possibility of vetoing row change events on a CompositeTable.
- *
- * @since 3.2
- */
-public class RowFocusAdapter implements IRowFocusListener {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.IRowFocusListener#arrive(org.eclipse.jface.examples.databinding.compositetable.CompositeTable, int, org.eclipse.swt.widgets.Control)
- */
- public void arrive(CompositeTable sender, int currentObjectOffset,
- Control newRow) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.IRowFocusListener#depart(org.eclipse.jface.examples.databinding.compositetable.CompositeTable, int, org.eclipse.swt.widgets.Control)
- */
- public void depart(CompositeTable sender, int currentObjectOffset,
- Control row) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.IRowFocusListener#requestRowChange(org.eclipse.jface.examples.databinding.compositetable.CompositeTable, int, org.eclipse.swt.widgets.Control)
- */
- public boolean requestRowChange(CompositeTable sender,
- int currentObjectOffset, Control row) {
- return true;
- }
-
-} \ No newline at end of file
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/ScrollEvent.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/ScrollEvent.java
deleted file mode 100644
index 509a1f5d..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/ScrollEvent.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * 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.examples.databinding.compositetable;
-
-/**
- * An event that is fired whenever the user scrolls a CompositeTable control.
- *
- * @since 3.2
- */
-public class ScrollEvent {
- /**
- * Scroll direction == forward relative to the user's viewport.
- */
- public static final int FORWARD = 1;
-
- /**
- * Scroll direction == none relative to the user's viewport.
- */
- public static final int NONE = 0;
-
- /**
- * Scroll direction == backward relative to the user's viewport.
- */
- public static final int BACKWARD = -1;
-
- /**
- * The direction that the user scrolled relative to the viewport. One
- * of: {FORWARD, BACKWARD}.
- */
- public final int userScrollDirection;
-
- /**
- * The CompositeTable that sent this event.
- */
- public final CompositeTable sender;
-
- /**
- * @param userScrollDirection
- * @param parent
- */
- public ScrollEvent(int userScrollDirection, CompositeTable parent) {
- this.userScrollDirection = userScrollDirection;
- this.sender = parent;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- public String toString() {
- if (userScrollDirection == FORWARD) {
- return "FORWARD Scroll";
- }
- if (userScrollDirection == BACKWARD) {
- return "BACKWARD Scroll";
- }
- return "no scroll";
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/ScrollListener.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/ScrollListener.java
deleted file mode 100644
index 34f4d0bf..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/ScrollListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * 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.examples.databinding.compositetable;
-
-/**
- * An "interface" for objects that need to listen to scrolling events on a
- * CompositeTable control.
- *
- * @since 3.2
- */
-public abstract class ScrollListener {
- /**
- * Method tableScrolled. Called after the CompositeTable has scrolled the
- * visible range.
- * @param scrollEvent TODO
- */
- public abstract void tableScrolled(ScrollEvent scrollEvent);
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/binding/CompositeTableObservableLazyDataRequestor.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/binding/CompositeTableObservableLazyDataRequestor.java
deleted file mode 100644
index 48707910..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/binding/CompositeTableObservableLazyDataRequestor.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Coconut Palm Software, Inc. 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:
- * Coconut Palm Software - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable.binding;
-
-import org.eclipse.jface.databinding.observable.AbstractObservable;
-import org.eclipse.jface.examples.databinding.compositetable.CompositeTable;
-import org.eclipse.jface.examples.databinding.compositetable.IDeleteHandler;
-import org.eclipse.jface.examples.databinding.compositetable.IInsertHandler;
-import org.eclipse.jface.examples.databinding.compositetable.IRowContentProvider;
-import org.eclipse.jface.examples.databinding.compositetable.IRowFocusListener;
-import org.eclipse.jface.examples.databinding.compositetable.RowFocusAdapter;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor;
-import org.eclipse.jface.internal.databinding.provisional.observable.ILazyListElementProvider;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyDeleteEvent;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertDeleteProvider;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertEvent;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * An ILazyDataRequestor implementation for CompositeTable.
- *
- * @since 3.3
- */
-public class CompositeTableObservableLazyDataRequestor extends AbstractObservable implements ILazyDataRequestor {
- private static final String DATABINDING_CONTEXT_KEY = "DATABINDING_CONTEXT";
- private DataBindingContext parentContext;
- private CompositeTable table;
- private IRowBinder rowBinder;
-
- /**
- * Construct a CompositeTableLazyDataRequestor.
- *
- * @param parentContext The parent data binding context.
- * @param table The CompositeTable to bind
- * @param rowBinder An IRowBinder that knows how to bind row objects in the CompositeTable
- */
- public CompositeTableObservableLazyDataRequestor(DataBindingContext parentContext, CompositeTable table, IRowBinder rowBinder) {
- this.parentContext = parentContext;
- this.table = table;
- this.rowBinder = rowBinder;
- table.addRowContentProvider(contentProvider);
- table.addRowFocusListener(rowListener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.IObservable#dispose()
- */
- public void dispose() {
- table.removeRowContentProvider(contentProvider);
- table.removeRowFocusListener(rowListener);
- if (insertDeleteProvider != null) {
- table.removeInsertHandler(insertHandler);
- table.removeDeleteHandler(deleteHandler);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor#setSize(int)
- */
- public void setSize(int size) {
- table.setNumRowsInCollection(size);
- }
-
- private ILazyListElementProvider elementProvider;
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor#addElementProvider(org.eclipse.jface.internal.databinding.provisional.observable.ILazyListElementProvider)
- */
- public void addElementProvider(ILazyListElementProvider p) {
- this.elementProvider = p;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor#removeElementProvider(org.eclipse.jface.internal.databinding.provisional.observable.ILazyListElementProvider)
- */
- public void removeElementProvider(ILazyListElementProvider p) {
- p = null;
- }
-
- private LazyInsertDeleteProvider insertDeleteProvider;
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor#addInsertDeleteProvider(org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertDeleteProvider)
- */
- public void addInsertDeleteProvider(LazyInsertDeleteProvider p) {
- this.insertDeleteProvider = p;
- table.addInsertHandler(insertHandler);
- table.addDeleteHandler(deleteHandler);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor#removeInsertDeleteProvider(org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertDeleteProvider)
- */
- public void removeInsertDeleteProvider(LazyInsertDeleteProvider p) {
- insertDeleteProvider = null;
- table.removeInsertHandler(insertHandler);
- table.removeDeleteHandler(deleteHandler);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor#add(int, java.lang.Object)
- */
- public void add(int position, Object element) {
- table.setNumRowsInCollection(table.getNumRowsInCollection()+1);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor#remove(int)
- */
- public void remove(int position) {
- table.setNumRowsInCollection(table.getNumRowsInCollection()-1);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.IObservable#isStale()
- */
- public boolean isStale() {
- // A CompositeTableLazyDataRequestor is never stale
- return false;
- }
-
- // Event handlers ----------------------------------------------------------
-
- private IRowContentProvider contentProvider = new IRowContentProvider() {
- public void refresh(CompositeTable sender, int currentObjectOffset, Control row) {
- DataBindingContext bindings = (DataBindingContext) row.getData(DATABINDING_CONTEXT_KEY);
- if (bindings != null) {
- bindings.dispose();
- }
-
- Object object = elementProvider.get(currentObjectOffset);
- bindings = new DataBindingContext(parentContext);
- row.setData(DATABINDING_CONTEXT_KEY, bindings);
-
- rowBinder.bindRow(bindings, row, object);
- }
- };
-
- private IInsertHandler insertHandler = new IInsertHandler() {
- public int insert(int positionHint) {
- NewObject newObject = insertDeleteProvider.insertElementAt(new LazyInsertEvent(positionHint, null));
- if (newObject == null) {
- return -1;
- }
- return newObject.position;
- }
- };
-
- private IDeleteHandler deleteHandler = new IDeleteHandler() {
- public boolean canDelete(int rowInCollection) {
- return insertDeleteProvider.canDeleteElementAt(new LazyDeleteEvent(rowInCollection));
- }
-
- public void deleteRow(int rowInCollection) {
- insertDeleteProvider.deleteElementAt(new LazyDeleteEvent(rowInCollection));
- }
- };
-
- /*
- * FIXME: Manage object-level commit / rollback here???
- *
- * Yes. Need to fire row validation events here? Will user scrolling
- * using the scroll bar cause a problem here?
- */
- private IRowFocusListener rowListener = new RowFocusAdapter();
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/binding/IRowBinder.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/binding/IRowBinder.java
deleted file mode 100644
index 9e4452a0..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/binding/IRowBinder.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Coconut Palm Software, Inc. 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:
- * Coconut Palm Software - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable.binding;
-
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * Defines an interface for objects that can bind a CompositeTable's row object
- * to an element of the collection to which the CompositeTable itself is bound.
- * @since 3.3
- */
-public interface IRowBinder {
- /**
- * Bind the controls inside the specified row object to the specified
- * object using the supplied data binding context.
- * <p>
- * The sender will automatically dispose the bindings at the right time
- * by disposing the supplied data binding context.
- *
- * @param context The data binding context
- * @param row The row Control to bind
- * @param object The business model object to bind
- */
- void bindRow(DataBindingContext context, Control row, Object object);
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/AbstractEventEditor.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/AbstractEventEditor.java
deleted file mode 100644
index 0fa02b21..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/AbstractEventEditor.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * 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.examples.databinding.compositetable.day;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @since 3.2
- *
- */
-public abstract class AbstractEventEditor extends Composite {
-
- private int defaultEventDuration;
- private List insertHandlers = new ArrayList();
-
- /**
- * @param parent Parent control
- * @param style SWT style bit
- *
- */
- public AbstractEventEditor(Composite parent, int style) {
- super(parent, style);
- }
-
- /**
- * Tells the IEventEditor to refresh all days in its display.
- */
- public abstract void refresh();
-
- /**
- * Requests that the event editor attempt to insert a new element by calling
- * its registered insert handlers
- *
- * @param date
- * The date/time on which to request the insert. The actual date
- * on which the insert is performed may be different. This is a
- * HINT.
- *
- * @param allDayEvent
- * Indicates if the new event should be an all-day event. This is
- * a HINT; the actual event inserted may be a timed event.
- *
- * @return NewEvent a NewEvent object describing the event that was
- * inserted.
- */
- public NewEvent fireInsert(Date date, boolean allDayEvent) {
- checkWidget();
- CalendarableItem item = new CalendarableItem(date);
- item.setAllDayEvent(allDayEvent);
- item.setStartTime(date);
- item.setEndTime(incrementHour(date, getDefaultEventDuration()));
- CalendarableItemEvent e = new CalendarableItemEvent();
- e.calendarableItem = item;
- if (fireEvents(e, insertHandlers)) {
- // TODO: Only refresh the affected days
- refresh();
- return (NewEvent) e.result;
- }
- return null;
- }
-
- /**
- * Adds the handler to the collection of handlers who will be notified when
- * a CalendarableItem is inserted in the receiver, by sending it one of the
- * messages defined in the <code>CalendarableItemInsertHandler</code>
- * abstract class.
- * <p>
- * <code>itemInserted</code> is called when the CalendarableItem is
- * inserted.
- * </p>
- *
- * @param handler
- * the handler which should be notified
- *
- * @exception IllegalArgumentException
- * <ul>
- * <li>ERROR_NULL_ARGUMENT - if the handler is null</li>
- * </ul>
- * @exception SWTException
- * <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed</li>
- * </ul>
- *
- * @see CalendarableItemInsertHandler
- * @see #removeItemInsertHandler
- */
- public void addItemInsertHandler(CalendarableItemEventHandler handler) {
- checkWidget();
- if (handler == null) {
- throw new IllegalArgumentException("The argument cannot be null");
- }
- if (isDisposed()) {
- throw new SWTException("Widget is disposed");
- }
- insertHandlers.add(handler);
- }
-
- /**
- * Removes the handler from the collection of handlers who will
- * be notified when a CalendarableItem is inserted into the receiver, by sending
- * it one of the messages defined in the <code>CalendarableItemInsertHandler</code>
- * abstract class.
- * <p>
- * <code>itemInserted</code> is called when the CalendarableItem is inserted.
- * </p>
- *
- * @param handler the handler which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the handler is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see CalendarableItemInsertHandler
- * @see #addItemInsertHandler
- */
- public void removeItemInsertHandler(CalendarableItemEventHandler handler) {
- checkWidget();
- if (handler == null) {
- throw new IllegalArgumentException("The argument cannot be null");
- }
- if (isDisposed()) {
- throw new SWTException("Widget is disposed");
- }
- insertHandlers.remove(handler);
- }
-
- /**
- * Returns the default duration of a new event, in hours.
- *
- * @return int the number of hours a new event occupies by default.
- */
- public int getDefaultEventDuration() {
- checkWidget();
- return defaultEventDuration;
- }
-
- /**
- * Sets the default duration of a new event, in hours.
- *
- * @param defaultEventDuration
- * int the number of hours a new event occupies by default.
- */
- public void setDefaultEventDuration(int defaultEventDuration) {
- checkWidget();
- this.defaultEventDuration = defaultEventDuration;
- }
-
- protected boolean fireEvents(CalendarableItemEvent e, List handlers) {
- for (Iterator i = handlers.iterator(); i.hasNext();) {
- CalendarableItemEventHandler h = (CalendarableItemEventHandler) i.next();
- h.handleRequest(e);
- if (!e.doit) {
- break;
- }
- }
- for (Iterator i = handlers.iterator(); i.hasNext();) {
- CalendarableItemEventHandler h = (CalendarableItemEventHandler) i.next();
- h.requestHandled(e);
- if (!e.doit) {
- break;
- }
- }
- return e.doit;
- }
-
- private Date incrementHour(Date date, int increment) {
- Calendar c = Calendar.getInstance();
- c.setTime(date);
- c.add(Calendar.HOUR_OF_DAY, increment);
- return c.getTime();
- }
-
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/CalendarableItemEvent.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/CalendarableItemEvent.java
deleted file mode 100644
index 1bdcc401..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/CalendarableItemEvent.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * 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.examples.databinding.compositetable.day;
-
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem;
-
-/**
- * Instances of this class are sent as a result of
- * events such insertion, deletion, or disposal of
- * CalendarableItem objects.
-
- * @since 3.2
- *
- */
-public class CalendarableItemEvent {
- /**
- * Set to true by default. Setting this field to false aborts the
- * requested operation, as appropriate. For example, setting this field
- * to false in a deletion operation cancels the delete operation.
- */
- public boolean doit = true;
-
- /**
- * The CalenderableItem that should be processed in this operation.
- */
- public CalendarableItem calendarableItem;
-
- /**
- * Returns the result of the operation. In the case of an edit operation,
- * this must contain (oldStartTime, oldEndTime, newStartTime, newEndTime)
- * if any of (startTime, endTime) have changed.
- */
- public Object result = null;
-
- public String toString() {
- return "calendarableItem = " + calendarableItem;
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/CalendarableItemEventHandler.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/CalendarableItemEventHandler.java
deleted file mode 100644
index ef6feb9b..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/CalendarableItemEventHandler.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * 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.examples.databinding.compositetable.day;
-
-
-/**
- * Abstract class CalendarableItemEventHandler. An abstract class defining
- * the API for objects that implement strategy pattern services such as
- * insert, edit, and delete from a DayEditor object.
- *
- * @since 3.2
- */
-public abstract class CalendarableItemEventHandler {
- /**
- * Process this CalenderableItemEvent, please.
- *
- * @param e
- * The CalendarableItemEvent to process.
- */
- public void handleRequest(CalendarableItemEvent e) {
- // NOOP by default
- }
-
- /**
- * This CalendarableItemEvent has been handled.
- *
- * @param e
- * The CalendarableItemEvent that was processed, including the
- * results of processing the event.
- */
- public void requestHandled(CalendarableItemEvent e) {
- // NOOP by default
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/CalendarableSelectionChangeListener.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/CalendarableSelectionChangeListener.java
deleted file mode 100644
index 7af565ea..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/CalendarableSelectionChangeListener.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * 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.examples.databinding.compositetable.day;
-
-
-/**
- * Classes which implement this interface provide methods
- * that deal with the events that are generated when selection
- * occurs in a control.
- * <p>
- * After creating an instance of a class that implements
- * this interface it can be added to a control using the
- * <code>addSelectionListener</code> method and removed using
- * the <code>removeSelectionListener</code> method. When
- * selection occurs in a control the appropriate method
- * will be invoked.
- *
- * @since 3.2
- */
-public abstract class CalendarableSelectionChangeListener {
- /**
- * Sent when selection occurs in the control.
- *
- * @param e an event containing information about the selection
- */
- public abstract void selectionChanged(SelectionChangeEvent e);
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/DayEditor.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/DayEditor.java
deleted file mode 100644
index ce383387..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/DayEditor.java
+++ /dev/null
@@ -1,1411 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jface.examples.databinding.compositetable.day;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.jface.examples.databinding.compositetable.CompositeTable;
-import org.eclipse.jface.examples.databinding.compositetable.IRowContentProvider;
-import org.eclipse.jface.examples.databinding.compositetable.RowConstructionListener;
-import org.eclipse.jface.examples.databinding.compositetable.ScrollEvent;
-import org.eclipse.jface.examples.databinding.compositetable.ScrollListener;
-import org.eclipse.jface.examples.databinding.compositetable.day.internal.DayEditorCalendarableItemControl;
-import org.eclipse.jface.examples.databinding.compositetable.day.internal.EventLayoutComputer;
-import org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl;
-import org.eclipse.jface.examples.databinding.compositetable.day.internal.TimeSlice;
-import org.eclipse.jface.examples.databinding.compositetable.day.internal.TimeSlot;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableModel;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventContentProvider;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventCountProvider;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.FocusAdapter;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Menu;
-
-/**
- * A DayEditor is an SWT control that can display events on a time line that can
- * span one or more days. This class is not intended to be subclassed.
- *
- * @since 3.2
- */
-public class DayEditor extends AbstractEventEditor implements IEventEditor {
- private CompositeTable compositeTable = null;
- private CalendarableModel model = new CalendarableModel();
- private List recycledCalendarableEventControls = new LinkedList();
- protected TimeSlice daysHeader = null;
- private final boolean headerDisabled;
- /**
- * NO_HEADER constant. A style bit constant to indicate that no header
- * should be displayed at the top of the editor window.
- */
- public static final int NO_HEADER=SWT.NO_TRIM;
-
- /**
- * Constructor DayEditor. Constructs a calendar control that can display
- * events on one or more days.
- *
- * @param parent
- * @param style DayEditor.NO_HEADER or SWT.NO_TRIM means not to display a header.
- */
- public DayEditor(Composite parent, int style) {
- super(parent, SWT.NULL);
- if ((style & NO_HEADER) != 0) {
- headerDisabled = true;
- } else {
- headerDisabled = false;
- }
- setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#setTimeBreakdown(int, int)
- */
- public void setTimeBreakdown(int numberOfDays, int numberOfDivisionsInHour) {
- checkWidget();
- model.setTimeBreakdown(numberOfDays, numberOfDivisionsInHour);
-
- if (compositeTable != null) {
- compositeTable.dispose();
- }
-
- createCompositeTable(numberOfDays, numberOfDivisionsInHour);
- }
-
- /**
- * This method initializes compositeTable
- *
- * @param numberOfDays
- * The number of day columns to display
- */
- private void createCompositeTable(final int numberOfDays,
- final int numberOfDivisionsInHour) {
-
- compositeTable = new CompositeTable(this, SWT.NONE);
- if (background != null) {
- compositeTable.setBackground(background);
- }
- compositeTable.setTraverseOnTabsEnabled(false);
-
- if (!headerDisabled) {
- new TimeSlice(compositeTable, SWT.BORDER); // The prototype header
- }
- new TimeSlice(compositeTable, SWT.NONE); // The prototype row
-
- compositeTable.setNumRowsInCollection(computeNumRowsInCollection(numberOfDivisionsInHour));
-
- compositeTable.addRowConstructionListener(new RowConstructionListener() {
- public void headerConstructed(Control newHeader) {
- daysHeader = (TimeSlice) newHeader;
- daysHeader.setHeaderControl(true);
- daysHeader.setNumberOfColumns(numberOfDays);
- if (model.getStartDate() == null) {
- return;
- }
- refreshColumnHeaders(daysHeader.getColumns());
- }
-
- public void rowConstructed(Control newRow) {
- TimeSlice timeSlice = (TimeSlice) newRow;
- timeSlice.setNumberOfColumns(numberOfDays);
- timeSlice.addCellFocusListener(cellFocusListener);
- timeSlice.addKeyListener(keyListener);
- timeSlice.addMouseListener(cellMouseListener);
- }
- });
- compositeTable.addRowContentProvider(new IRowContentProvider() {
- public void refresh(CompositeTable sender, int currentObjectOffset,
- Control row) {
- TimeSlice timeSlice = (TimeSlice) row;
- refreshRow(currentObjectOffset, timeSlice);
- }
- });
- compositeTable.addScrollListener(new ScrollListener() {
- public void tableScrolled(ScrollEvent scrollEvent) {
- layoutEventControls();
- }
- });
- addControlListener(new ControlAdapter() {
- public void controlResized(ControlEvent e) {
- Rectangle bounds = DayEditor.this.getBounds();
- compositeTable.setBounds(0, 0, bounds.width, bounds.height);
- layoutEventControlsDeferred();
- }
- });
-
- compositeTable.setRunTime(true);
- }
-
- private Menu menu = null;
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#setMenu(org.eclipse.swt.widgets.Menu)
- */
- public void setMenu(final Menu menu) {
- checkWidget();
- Display.getCurrent().asyncExec(new Runnable() {
- public void run() {
- if (isDisposed()) return;
- DayEditor.super.setMenu(menu);
- DayEditor.this.menu = menu;
- compositeTable.setMenu(menu);
- setMenuOnCollection(recycledCalendarableEventControls, menu);
- for (int day=0; day < model.getNumberOfDays(); ++day) {
- List calendarablesForDay = model.getCalendarableItems(day);
- setMenuOnCollection(calendarablesForDay, menu);
- }
- }
- });
- }
-
-
-
- private void setMenuOnCollection(List collection, Menu menu) {
- for (Iterator controls = collection.iterator(); controls.hasNext();) {
- ICalendarableItemControl control = (ICalendarableItemControl) controls.next();
- control.setMenu(menu);
- }
- }
-
- private ArrayList keyListeners = new ArrayList();
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#addKeyListener(org.eclipse.swt.events.KeyListener)
- */
- public void addKeyListener(KeyListener listener) {
- checkWidget();
- keyListeners.add(listener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#removeKeyListener(org.eclipse.swt.events.KeyListener)
- */
- public void removeKeyListener(KeyListener listener) {
- checkWidget();
- keyListeners.remove(listener);
- }
-
- private KeyListener keyListener = new KeyAdapter() {
- public void keyReleased(KeyEvent e) {
- for (Iterator i = keyListeners.iterator(); i.hasNext();) {
- KeyListener keyListener = (KeyListener) i.next();
- keyListener.keyReleased(e);
- if (!e.doit) return;
- }
- }
-
- public void keyPressed(KeyEvent e) {
- for (Iterator i = keyListeners.iterator(); i.hasNext();) {
- KeyListener keyListener = (KeyListener) i.next();
- keyListener.keyPressed(e);
- if (!e.doit) return;
- }
- CalendarableItem selection = selectedCalendarable;
- int selectedRow;
- int selectedDay;
- boolean allDayEventRowSelected = false;
- int compositeTableRow = compositeTable.getSelection().y + compositeTable.getTopRow();
- if (compositeTableRow < numberOfAllDayEventRows) {
- allDayEventRowSelected = true;
- }
-
- if (selection == null) {
- selectedRow = convertViewportRowToDayRow(compositeTable.getCurrentRow());
- selectedDay = compositeTable.getCurrentColumn();
- } else {
- selectedDay = model.getDay(selection);
- if (allDayEventRowSelected) {
- selectedRow = compositeTableRow;
- } else {
- Point selectedCoordinates = selection.getUpperLeftPositionInDayRowCoordinates();
- if (selectedCoordinates == null) {
- return;
- }
- selectedRow = selectedCoordinates.y;
- }
- }
-
- switch (e.character) {
- case SWT.TAB:
- if ((e.stateMask & SWT.SHIFT) != 0) {
- CalendarableItem newSelection = model.findPreviousCalendarable(selectedDay, selectedRow, selection, allDayEventRowSelected);
- if (newSelection == null) {
- // There was only 0 or one visible event--nothing to scroll to
- return;
- }
- int newTopRow = computeNewTopRowBasedOnSelection(newSelection);
- if (newTopRow != compositeTable.getTopRow()) {
- compositeTable.setTopRow(newTopRow);
- }
- setSelection(newSelection);
- } else {
- CalendarableItem newSelection = model.findNextCalendarable(selectedDay, selectedRow, selection, allDayEventRowSelected);
- if (newSelection == null) {
- // There was only 0 or one visible event--nothing to scroll to
- return;
- }
- int newTopRow = computeNewTopRowBasedOnSelection(newSelection);
- if (newTopRow != compositeTable.getTopRow()) {
- compositeTable.setTopRow(newTopRow);
- }
- setSelection(newSelection);
- }
- }
- }
- };
-
- private ArrayList mouseListeners = new ArrayList();
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#addMouseListener(org.eclipse.swt.events.MouseListener)
- */
- public void addMouseListener(MouseListener listener) {
- checkWidget();
- mouseListeners.add(listener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#removeMouseListener(org.eclipse.swt.events.MouseListener)
- */
- public void removeMouseListener(MouseListener listener) {
- checkWidget();
- mouseListeners.remove(listener);
- }
-
- private MouseListener cellMouseListener = new MouseListener() {
- public void mouseDoubleClick(MouseEvent e) {
- fireMouseDoubleClickEvent(e);
- }
- public void mouseDown(MouseEvent e) {
- fireMouseDownEvent(e);
- }
- public void mouseUp(MouseEvent e) {
- fireMouseUpEvent(e);
- }
- };
-
- protected void fireMouseDownEvent(MouseEvent e) {
- for (Iterator i = mouseListeners.iterator(); i.hasNext();) {
- MouseListener mouseListener = (MouseListener) i.next();
- mouseListener.mouseDown(e);
- }
- }
-
- protected void fireMouseUpEvent(MouseEvent e) {
- for (Iterator i = mouseListeners.iterator(); i.hasNext();) {
- MouseListener mouseListener = (MouseListener) i.next();
- mouseListener.mouseUp(e);
- }
- }
-
- protected void fireMouseDoubleClickEvent(MouseEvent e) {
- for (Iterator i = mouseListeners.iterator(); i.hasNext();) {
- MouseListener mouseListener = (MouseListener) i.next();
- mouseListener.mouseDoubleClick(e);
- }
- }
-
- private int computeNewTopRowBasedOnSelection(CalendarableItem newSelection) {
- int topRow = compositeTable.getTopRow();
- int numberOfRowsInDisplay = compositeTable.getNumRowsVisible();
- int newTopRow = topRow;
-
- Point endRowPoint = newSelection.getLowerRightPositionInDayRowCoordinates();
- if (endRowPoint != null) {
- int endRow = convertDayRowToViewportCoordinates(endRowPoint.y);
- if (endRow >= newTopRow + numberOfRowsInDisplay) {
- newTopRow += (endRow - (newTopRow + numberOfRowsInDisplay)) + 1;
- }
- int startRow = newSelection.getUpperLeftPositionInDayRowCoordinates().y;
- startRow = convertDayRowToViewportCoordinates(startRow);
- if (startRow < newTopRow) {
- newTopRow = startRow;
- }
- }
- return newTopRow;
- }
-
- private boolean selectCalendarableControlOnSetFocus = true;
-
- private FocusListener cellFocusListener = new FocusAdapter() {
- public void focusGained(FocusEvent e) {
- TimeSlice sendingRow = (TimeSlice) ((Composite) e.widget).getParent();
- int day = sendingRow.getControlColumn(e.widget);
- int row = compositeTable.getControlRow(sendingRow);
- if (selectCalendarableControlOnSetFocus) {
- setSelectionByDayAndRow(day, row, null);
- } else {
- selectCalendarableControlOnSetFocus = true;
- }
- }
- };
-
- private void setSelectionByDayAndRow(int day, int row, CalendarableItem aboutToSelect) {
- int dayRow = convertViewportRowToDayRow(row);
- if (aboutToSelect == null && dayRow >= 0)
- aboutToSelect = getFirstCalendarableAt(day, dayRow);
- if (aboutToSelect == null || dayRow < 0) {
- aboutToSelect = getAllDayCalendarableAt(day, row + compositeTable.getTopRow());
- }
- selectCalenderableControl(aboutToSelect);
- aboutToSelect = null;
- }
-
- /** (non-API)
- * Method getFirstCalendarableAt. Finds the calendarable event at the
- * specified day/row in DayRow coordinates. If no calendarable exists
- * at the specified coordinates, does nothing.
- *
- * @param day The day offset
- * @param row The row offset in DayRow coordinates
- * @return the first Calendarable in the specified (day, row) or null if none.
- */
- protected CalendarableItem getFirstCalendarableAt(int day, int row) {
- CalendarableItem[][] eventLayout = model.getEventLayout(day);
- CalendarableItem selectedCalendarable = null;
- for (int column=0; column < eventLayout.length; ++column) {
- CalendarableItem calendarable = eventLayout[column][row];
- if (calendarable != null) {
- if (selectedCalendarable == null) {
- selectedCalendarable = calendarable;
- } else if (calendarable.getStartTime().after(selectedCalendarable.getStartTime())) {
- selectedCalendarable = calendarable;
- }
- }
- }
- return selectedCalendarable;
- }
-
- /**
- * Find the all day event that is positioned at the specified day and row in viewport coordinates
- *
- * @param day
- * @param row
- * @return The found Calendarable or null if none
- */
- protected CalendarableItem getAllDayCalendarableAt(int day, int row) {
- CalendarableItem[] allDayEvents = model.getAllDayCalendarables(day);
- for (int allDayEventRow = 0; allDayEventRow < allDayEvents.length; allDayEventRow++) {
- CalendarableItem candidate = allDayEvents[allDayEventRow];
- if (allDayEventRow == row) {
- return candidate;
- }
- }
-// int allDayEventRow = 0;
-// for (Iterator calendarablesIter = model.getCalendarableEvents(day).iterator(); calendarablesIter.hasNext();) {
-// Calendarable candidate = (Calendarable) calendarablesIter.next();
-// if (candidate.isAllDayEvent()) {
-// if (allDayEventRow == row) {
-// return candidate;
-// }
-// ++allDayEventRow;
-// }
-// }
- return null;
- }
-
- private CalendarableItem selectedCalendarable = null;
-
- /**
- * Method selectCalendarable. Selects the specified Calendarable event.
- *
- * @param newSelection The Calendarable to select.
- */
- public void setSelection(CalendarableItem newSelection) {
- checkWidget();
- if (newSelection != null) {
- int day = model.getDay(newSelection);
- int row = computeRowForCalendarable(newSelection, day);
- selectCalendarableControlOnSetFocus = false;
- compositeTable.setSelection(day, row);
- selectCalenderableControl(newSelection);
- } else {
- selectCalenderableControl(null);
- }
- }
-
- private void selectCalenderableControl(CalendarableItem newSelection) {
- if (selectedCalendarable == newSelection) {
- return;
- }
- if (selectedCalendarable != null) {
- // The control could be null if it just got scrolled off the screen top or bottom
- if (selectedCalendarable.getControl() != null) {
- selectedCalendarable.getControl().setSelected(false);
- }
- }
-
- CalendarableItem oldSelection = selectedCalendarable;
- selectedCalendarable = newSelection;
-
- if (newSelection != null && newSelection.getControl() != null) {
- newSelection.getControl().setSelected(true);
- }
- fireSelectionChangeEvent(oldSelection, newSelection);
- }
-
- /**
- * Method getSelection. Returns the selection. This is computed as follows:
- * <ol>
- * <li>If a CalendarableItem is currently selected, it is returned.
- * <li>If the selection rectangle is in an all-day event row, null is returned.
- * <li>Otherwise, the date/time corresponding to the selection rectangle is returned as a java.util.Date.
- * </ol>
- *
- * @return the current DayEditorSelection
- */
- public DayEditorSelection getSelection() {
- checkWidget();
- DayEditorSelection selection = new DayEditorSelection();
- Point compositeTableSelection = compositeTable.getSelection();
-
- int visibleAllDayEventRows = model.computeNumberOfAllDayEventRows();
- visibleAllDayEventRows -= compositeTable.getTopRow();
-
- if (selectedCalendarable != null) {
- selection.setSelectedCalendarable(selectedCalendarable);
- if (selectedCalendarable.isAllDayEvent()) {
- selection.setAllDay(true);
- }
- } else {
- if (visibleAllDayEventRows > 0) {
- if (compositeTableSelection.y < visibleAllDayEventRows) {
- selection.setAllDay(true);
- }
- }
- }
- selection.setDateTime(computeDateTimeFromViewportCoordinates(
- compositeTableSelection, visibleAllDayEventRows));
- return selection;
- }
-
- private List selectionChangeListeners = new ArrayList();
-
- private void fireSelectionChangeEvent(CalendarableItem currentSelection, CalendarableItem newSelection) {
- SelectionChangeEvent sce = new SelectionChangeEvent(currentSelection, newSelection);
- for (Iterator listenersIter = selectionChangeListeners.iterator(); listenersIter.hasNext();) {
- CalendarableSelectionChangeListener listener = (CalendarableSelectionChangeListener) listenersIter.next();
- listener.selectionChanged(sce);
- }
- }
-
- /**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's selection changes, by sending
- * it one of the messages defined in the <code>CalendarableSelectionChangeListener</code>
- * interface.
- * <p>
- * <code>selectionChanged</code> is called when the selection changes.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see CalendarableSelectionChangeListener
- * @see #removeSelectionChangeListener
- * @see SelectionChangeEvent
- */
- public void addSelectionChangeListener(CalendarableSelectionChangeListener l) {
- checkWidget();
- if (l == null) {
- throw new IllegalArgumentException("The argument cannot be null");
- }
- if (isDisposed()) {
- throw new SWTException("Widget is disposed");
- }
- selectionChangeListeners.add(l);
- }
-
- private boolean fireEvents(CalendarableItem calendarableItem, List handlers) {
- CalendarableItemEvent e = new CalendarableItemEvent();
- e.calendarableItem = calendarableItem;
- for (Iterator iter = handlers.iterator(); iter.hasNext();) {
- CalendarableItemEventHandler handler = (CalendarableItemEventHandler) iter.next();
- handler.handleRequest(e);
- if (!e.doit) {
- break;
- }
- }
- for (Iterator i = handlers.iterator(); i.hasNext();) {
- CalendarableItemEventHandler h = (CalendarableItemEventHandler) i.next();
- h.requestHandled(e);
- if (!e.doit) {
- break;
- }
- }
- return e.doit;
- }
-
- private List editHandlers = new ArrayList();
-
- /**
- * Fire the itemEdit event.
- *
- * @param toEdit The CalendarableItem to edit.
- * @return true if the object represented by the CalendarableItem was changed; false otherwise.
- */
- public boolean fireEdit(CalendarableItem toEdit) {
- checkWidget();
- CalendarableItemEvent e = new CalendarableItemEvent();
- e.calendarableItem = toEdit;
- boolean changed = fireEvents(e, editHandlers);
- if (changed) {
- // TODO: only refresh the days that are necessary
- refresh();
- }
- return changed;
- }
-
- /**
- * Adds the handler to the collection of handlers who will hand editing of
- * calendarable events, by sending it one of the messages defined in the
- * <code>CalendarableItemInsertHandler</code> abstract class.
- * <p>
- * <code>itemInserted</code> is called when the CalendarableItem is
- * inserted.
- * </p>
- *
- * @param handler
- * the handler which should be notified
- *
- * @exception IllegalArgumentException
- * <ul>
- * <li>ERROR_NULL_ARGUMENT - if the handler is null</li>
- * </ul>
- * @exception SWTException
- * <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed</li>
- * </ul>
- *
- * @see CalendarableItemInsertHandler
- * @see #removeItemInsertHandler
- */
- public void addItemEditHandler(CalendarableItemEventHandler handler) {
- checkWidget();
- if (handler == null) {
- throw new IllegalArgumentException("The argument cannot be null");
- }
- if (isDisposed()) {
- throw new SWTException("Widget is disposed");
- }
- editHandlers.add(handler);
- }
-
- /**
- * Removes the handler from the collection of handlers who will hand editing of
- * calendarable events, by sending it one of the messages defined in the
- * <code>CalendarableItemInsertHandler</code> abstract class.
- * <p>
- * <code>itemInserted</code> is called when the CalendarableItem is
- * inserted.
- * </p>
- *
- * @param handler
- * the handler which should be notified
- *
- * @exception IllegalArgumentException
- * <ul>
- * <li>ERROR_NULL_ARGUMENT - if the handler is null</li>
- * </ul>
- * @exception SWTException
- * <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed</li>
- * </ul>
- *
- * @see CalendarableItemInsertHandler
- * @see #removeItemInsertHandler
- */
- public void removeItemEditHandler(CalendarableItemEventHandler handler) {
- checkWidget();
- if (handler == null) {
- throw new IllegalArgumentException("The argument cannot be null");
- }
- if (isDisposed()) {
- throw new SWTException("Widget is disposed");
- }
- editHandlers.remove(handler);
- }
-
- private List deleteHandlers = new ArrayList();
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#fireDelete(org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem)
- */
- public boolean fireDelete(CalendarableItem item) {
- checkWidget();
- boolean result = fireEvents(item, deleteHandlers);
- if (result) {
- // TODO: Only refresh the affected days.
- refresh();
- }
- return result;
- }
-
- /**
- * Adds the handler to the collection of handlers who will
- * be notified when a CalendarableItem is deleted from the receiver, by sending
- * it one of the messages defined in the <code>CalendarableItemEventHandler</code>
- * abstract class.
- * <p>
- * <code>itemDeleted</code> is called when the CalendarableItem is deleted.
- * </p>
- *
- * @param handler the handler which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the handler is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see CalendarableItemEventHandler
- * @see #removeDeleteItemHandler
- */
- public void addItemDeleteHandler(CalendarableItemEventHandler handler) {
- checkWidget();
- if (handler == null) {
- throw new IllegalArgumentException("The argument cannot be null");
- }
- if (isDisposed()) {
- throw new SWTException("Widget is disposed");
- }
- deleteHandlers.add(handler);
- }
-
- /**
- * Removes the handler from the collection of handlers who will
- * be notified when a CalendarableItem is deleted from the receiver, by sending
- * it one of the messages defined in the <code>CalendarableItemEventHandler</code>
- * abstract class.
- * <p>
- * <code>itemDeleted</code> is called when the CalendarableItem is deleted.
- * </p>
- *
- * @param handler the handler which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the handler is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see CalendarableItemEventHandler
- * @see #addDeleteItemHandler
- */
- public void removeItemDeleteHandler(CalendarableItemEventHandler handler) {
- checkWidget();
- deleteHandlers.remove(handler);
- }
-
- private List itemDisposeHandlers = new ArrayList();
-
- private boolean fireDisposeItemStrategy(CalendarableItem item) {
- return fireEvents(item, itemDisposeHandlers);
- }
-
- /**
- * Adds the handler to the collection of handler who will
- * be notified when a CalendarableItem's control is disposed, by sending
- * it one of the messages defined in the <code>CalendarableItemEventHandler</code>
- * abstract class. This is normally used to remove any data bindings
- * that may be attached to the (now-unused) CalendarableItem.
- * <p>
- * <code>itemDeleted</code> is called when the CalendarableItem is deleted.
- * </p>
- *
- * @param handler the handler which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the handler is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see CalendarableItemEventHandler
- * @see #removeCalendarableItemDisposeHandler
- */
- public void addItemDisposeHandler(CalendarableItemEventHandler handler) {
- checkWidget();
- if (handler == null) {
- throw new IllegalArgumentException("The argument cannot be null");
- }
- if (isDisposed()) {
- throw new SWTException("Widget is disposed");
- }
- itemDisposeHandlers.add(handler);
- }
-
- /**
- * Removes the handler from the collection of handlers who will
- * be notified when a CalendarableItem is disposed, by sending
- * it one of the messages defined in the <code>CalendarableItemEventHandler</code>
- * abstract class. This is normally used to remove any data bindings
- * that may be attached to the (now-unused) CalendarableItem.
- * <p>
- * <code>itemDeleted</code> is called when the CalendarableItem is deleted.
- * </p>
- *
- * @param handler the handler which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the handler is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see CalendarableItemEventHandler
- * @see #removeDeleteListener
- */
- public void removeItemDisposeHandler(CalendarableItemEventHandler handler) {
- checkWidget();
- itemDisposeHandlers.remove(handler);
- }
-
- /**
- * Removes the listener from the collection of listeners who will
- * be notified when the receiver's selection changes, by sending
- * it one of the messages defined in the <code>CalendarableSelectionChangeListener</code>
- * interface.
- * <p>
- * <code>selectionChanged</code> is called when the selection changes.
- * </p>
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see CalendarableSelectionChangeListener
- * @see #addSelectionChangeListener
- * @see SelectionChangeEvent
- */
- public void removeSelectionChangeListener(CalendarableSelectionChangeListener l) {
- checkWidget();
- if (l == null) {
- throw new IllegalArgumentException("The argument cannot be null");
- }
- if (isDisposed()) {
- throw new SWTException("Widget is disposed");
- }
- selectionChangeListeners.remove(l);
- }
-
- /**
- * @return Returns the defaultStartHour.
- */
- public int getDefaultStartHour() {
- return model.getDefaultStartHour();
- }
-
- /**
- * @param defaultStartHour The defaultStartHour to set.
- */
- public void setDefaultStartHour(int defaultStartHour) {
- checkWidget();
- model.setDefaultStartHour(defaultStartHour);
- updateVisibleRows();
- layoutEventControls();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#setDayEventCountProvider(org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventCountProvider)
- */
- public void setEventCountProvider(EventCountProvider eventCountProvider) {
- checkWidget();
- model.setEventCountProvider(eventCountProvider);
- updateVisibleRows();
- Display.getCurrent().asyncExec(new Runnable() {
- public void run() {
- if (isDisposed()) return;
- layoutEventControls();
- }
- });
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#setEventContentProvider(org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventContentProvider)
- */
- public void setEventContentProvider(EventContentProvider eventContentProvider) {
- checkWidget();
- model.setEventContentProvider(eventContentProvider);
- updateVisibleRows();
- Display.getCurrent().asyncExec(new Runnable() {
- public void run() {
- if (isDisposed()) return;
- layoutEventControls();
- }
- });
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#setStartDate(java.util.Date)
- */
- public void setStartDate(Date startDate) {
- checkWidget();
- List removedDays = model.setStartDate(startDate);
- computeEventRowsForNewDays();
- if (daysHeader != null) {
- refreshColumnHeaders(daysHeader.getColumns());
- }
- updateVisibleRows();
- freeObsoleteCalendarableEventControls(removedDays);
- if (compositeTable.getNumRowsVisible() > 0) {
- layoutEventControls();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#getStartDate()
- */
- public Date getStartDate() {
- checkWidget();
- return model.getStartDate();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#refresh(java.util.Date)
- */
- public void refresh(Date date) {
- checkWidget();
- computeLayoutFor(date);
- layoutEventControls();
- }
-
- private void computeLayoutFor(Date date) {
- List removedDays = model.refresh(date);
- freeObsoleteCalendarableEventControls(removedDays);
- updateVisibleRows();
- computeEventRowsForDate(date);
- }
-
- private boolean refreshing = false;
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#refresh()
- */
- public void refresh() {
- checkWidget();
- if (!refreshing) {
- refreshing = true;
- Display.getCurrent().asyncExec(new Runnable() {
- public void run() {
- if (isDisposed()) return;
- Date dateToRefresh = getStartDate();
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(dateToRefresh);
- for (int i=0; i < getNumberOfDays(); ++i) {
- computeLayoutFor(gc.getTime());
- gc.add(Calendar.DATE, 1);
- }
- layoutEventControls();
- refreshing = false;
- }
- });
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#getNumberOfDays()
- */
- public int getNumberOfDays() {
- checkWidget();
- return model.getNumberOfDays();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#getNumberOfDivisionsInHour()
- */
- public int getNumberOfDivisionsInHour() {
- checkWidget();
- return model.getNumberOfDivisionsInHour();
- }
-
- // Display Refresh logic here ----------------------------------------------
-
- /*
- * There are four main coordinate systems the refresh algorithm has to
- * deal with:
- *
- * 1) Rows starting from midnight (the way the DayModel computes the layout).
- * These are called Day Row coordinates.
- *
- * 2) Rows starting from the top visible row, taking into account all-day
- * event rows. These are called Viewport Row coordinates
- *
- * 3) Pixel coordinates for each TimeSlot, relative to its parent TimeSlice
- * (the CompositeTable row object) row. This is relevant because these
- * are transformed into #4 in order to place CalendarableEventControls.
- *
- * 4) Pixel coordinates relative to the top left (the origin) of the entire
- * DayEditor control.
- */
-
- private int numberOfAllDayEventRows = 0;
- Calendar calendar = new GregorianCalendar();
-
- private int computeNumRowsInCollection(final int numberOfDivisionsInHour) {
- numberOfAllDayEventRows = model.computeNumberOfAllDayEventRows();
- return (DISPLAYED_HOURS-model.computeStartHour()) * numberOfDivisionsInHour+numberOfAllDayEventRows;
- }
-
- private int convertViewportRowToDayRow(int row) {
- int topRowOffset = compositeTable.getTopRow() - numberOfAllDayEventRows;
- int startOfDayOffset = model.computeStartHour() * model.getNumberOfDivisionsInHour();
- return row + topRowOffset + startOfDayOffset;
- }
-
- private int convertDayRowToViewportCoordinates(int row) {
- row -= model.computeStartHour() * model.getNumberOfDivisionsInHour()
- - numberOfAllDayEventRows;
- return row;
- }
-
- private Date computeDateTimeFromViewportCoordinates(Point viewportSelection, int visibleAllDayEventRows) {
- Date startDate = model.calculateDate(getStartDate(), viewportSelection.x);
- GregorianCalendar calendar = new GregorianCalendar();
- calendar.setTime(startDate);
- calendar.set(Calendar.HOUR_OF_DAY,
- model.computeHourFromRow(viewportSelection.y - visibleAllDayEventRows));
- calendar.set(Calendar.MINUTE,
- model.computeMinuteFromRow(viewportSelection.y - visibleAllDayEventRows));
- calendar.set(Calendar.SECOND, 0);
- calendar.set(Calendar.MILLISECOND, 0);
- return calendar.getTime();
- }
-
- /**
- * @param calendarable
- * @param day
- * @return The row in DayRow coordinates
- */
- private int computeRowForCalendarable(CalendarableItem calendarable, int day) {
- int row = 0;
- if (calendarable.isAllDayEvent()) {
- CalendarableItem[] allDayEvents = model.getAllDayCalendarables(day);
- for (int allDayEventRow = 0; allDayEventRow < allDayEvents.length; allDayEventRow++) {
- if (allDayEvents[allDayEventRow] == calendarable) {
- row = allDayEventRow - compositeTable.getTopRow();
- break;
- }
- }
- } else {
- // Convert to viewport coordinates
- Point upperLeft = calendarable.getUpperLeftPositionInDayRowCoordinates();
- int topRowOffset = compositeTable.getTopRow() - numberOfAllDayEventRows;
- int startOfDayOffset = model.computeStartHour() * model.getNumberOfDivisionsInHour();
- row = upperLeft.y - topRowOffset - startOfDayOffset;
- if (row < 0) {
- row = 0;
- }
- }
- return row;
- }
-
-
- /*
- * Update the number of rows that are displayed inside the CompositeTable control
- */
- private void updateVisibleRows() {
- compositeTable.setNumRowsInCollection(computeNumRowsInCollection(getNumberOfDivisionsInHour()));
- }
-
- private void refreshRow(int currentObjectOffset, TimeSlice timeSlice) {
- // Decrement currentObjectOffset for each all-day event line we need.
- for (int allDayEventRow = 0; allDayEventRow < numberOfAllDayEventRows; ++allDayEventRow) {
- --currentObjectOffset;
- }
-
- if (currentObjectOffset < 0) {
- timeSlice.setCurrentTime(null);
- } else {
- calendar.set(Calendar.HOUR_OF_DAY,
- model.computeHourFromRow(currentObjectOffset));
- calendar.set(Calendar.MINUTE,
- model.computeMinuteFromRow(currentObjectOffset));
- timeSlice.setCurrentTime(calendar.getTime());
- }
- }
-
- /**
- * (non-API) Method initializeColumnHeaders. Called internally when the
- * column header text needs to be updated.
- *
- * @param columns A LinkedList of CLabels representing the column objects
- */
- protected void refreshColumnHeaders(LinkedList columns) {
- Date startDate = getStartDate();
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(startDate);
-
- SimpleDateFormat formatter = new SimpleDateFormat("EE, MMM d");
- formatter.applyPattern(formatter.toLocalizedPattern());
-
- for (Iterator iter = columns.iterator(); iter.hasNext();) {
- CLabel headerLabel = (CLabel) iter.next();
- headerLabel.setText(formatter.format(gc.getTime()));
- gc.add(Calendar.DATE, 1);
- }
- }
-
- private void freeObsoleteCalendarableEventControls(List removedCalendarables) {
- for (Iterator removedCalendarablesIter = removedCalendarables.iterator(); removedCalendarablesIter.hasNext();) {
- CalendarableItem toRemove = (CalendarableItem) removedCalendarablesIter.next();
- if (selectedCalendarable == toRemove) {
- setSelection(null);
- }
- freeCalendarableControl(toRemove);
- }
- }
-
- private void computeEventRowsForDate(Date date) {
- GregorianCalendar targetDate = new GregorianCalendar();
- targetDate.setTime(date);
- GregorianCalendar target = new GregorianCalendar();
- target.setTime(model.getStartDate());
- EventLayoutComputer dayModel = new EventLayoutComputer(model.getNumberOfDivisionsInHour());
- for (int dayOffset=0; dayOffset < model.getNumberOfDays(); ++dayOffset) {
- if (target.get(Calendar.DATE) == targetDate.get(Calendar.DATE) &&
- target.get(Calendar.MONTH) == targetDate.get(Calendar.MONTH) &&
- target.get(Calendar.YEAR) == targetDate.get(Calendar.YEAR))
- {
- computeEventLayout(dayModel, dayOffset);
- break;
- }
- target.add(Calendar.DATE, 1);
- }
- }
-
- private void computeEventRowsForNewDays() {
- EventLayoutComputer dayModel = new EventLayoutComputer(model.getNumberOfDivisionsInHour());
- for (int dayOffset=0; dayOffset < model.getNumberOfDays(); ++dayOffset) {
- if (model.getNumberOfColumnsWithinDay(dayOffset) == -1) {
- computeEventLayout(dayModel, dayOffset);
- }
- }
- }
-
- private void computeEventLayout(EventLayoutComputer dayModel, int dayOffset) {
- List events = model.getCalendarableItems(dayOffset);
- CalendarableItem[][] eventLayout = dayModel.computeEventLayout(events);
- model.setEventLayout(dayOffset, eventLayout);
- }
-
- private void layoutEventControlsDeferred() {
- if (getStartDate() == null) {
- return;
- }
- refreshEventControlPositions.run();
- Display.getCurrent().asyncExec(refreshEventControlPositions);
- }
-
- private void layoutEventControls() {
- if (getStartDate() == null) {
- return;
- }
- refreshEventControlPositions.run();
- }
-
- private Runnable refreshEventControlPositions = new Runnable() {
- public void run() {
- if (isDisposed()) return;
-
- Control[] gridRows = compositeTable.getRowControls();
-
- for (int day=0; day < model.getNumberOfDays(); ++day) {
- int columnsWithinDay = model.getNumberOfColumnsWithinDay(day);
- Point[] columnPositions = computeColumns(day, columnsWithinDay, gridRows);
-
- int allDayEventRow = 0;
-
- for (Iterator calendarablesIter = model.getCalendarableItems(day).iterator(); calendarablesIter.hasNext();) {
- CalendarableItem calendarable = (CalendarableItem) calendarablesIter.next();
- if (calendarable.isAllDayEvent()) {
- layoutAllDayEvent(day, allDayEventRow, calendarable, gridRows);
- ++allDayEventRow;
- } else {
- layoutTimedEvent(day, columnPositions, calendarable, gridRows);
- }
- }
- }
- }
- };
-
- protected Point[] computeColumns(int day, int numberOfColumns, Control[] gridRows) {
- Point[] columns = new Point[numberOfColumns];
- Rectangle timeSliceBounds = getTimeSliceBounds(day, compositeTable.getTopRow(), gridRows);
- timeSliceBounds.x += TimeSlot.TIME_BAR_WIDTH + 1;
- timeSliceBounds.width -= TimeSlot.TIME_BAR_WIDTH + 2;
-
- int baseWidth = timeSliceBounds.width / numberOfColumns;
- int extraWidth = timeSliceBounds.width % numberOfColumns;
-
- int startingPosition = timeSliceBounds.x;
- for (int column = 0; column < columns.length; column++) {
- int columnStart = startingPosition;
- int columnWidth = baseWidth;
- if (extraWidth > 0) {
- ++columnWidth;
- --extraWidth;
- }
- columns[column] = new Point(columnStart, columnWidth);
- startingPosition += columnWidth;
- }
- return columns;
- }
-
-
-
- private void fillControlData(CalendarableItem calendarable, int clippingStyle) {
- calendarable.getControl().setText(calendarable.getText());
- calendarable.getControl().setToolTipText(calendarable.getToolTipText());
- calendarable.getControl().setClipping(clippingStyle);
- }
-
- private DayEditorCalendarableItemControl getControl(CalendarableItem item) {
- return (DayEditorCalendarableItemControl) item.getControl();
- }
-
- private void layoutAllDayEvent(int day, int allDayEventRow, CalendarableItem calendarable, Control[] gridRows) {
- if (eventRowIsVisible(allDayEventRow)) {
- createCalendarableControl(calendarable);
- fillControlData(calendarable, SWT.NULL);
-
- Rectangle timeSliceBounds = getTimeSliceBounds(day, allDayEventRow, gridRows);
- int gutterWidth = TimeSlot.TIME_BAR_WIDTH + 1;
- timeSliceBounds.x += gutterWidth;
- timeSliceBounds.width -= gutterWidth;
- getControl(calendarable).setBounds(timeSliceBounds);
- getControl(calendarable).moveAbove(compositeTable);
- } else {
- freeCalendarableControl(calendarable);
- }
- }
-
- private void layoutTimedEvent(int day, Point[] columnPositions, CalendarableItem calendarable, Control[] gridRows) {
- int firstVisibleRow = model.computeStartHour() * model.getNumberOfDivisionsInHour();
-
- int scrolledRows = compositeTable.getTopRow() - numberOfAllDayEventRows;
- int visibleAllDayEventRows = 0;
- if (scrolledRows < 0) {
- visibleAllDayEventRows = -1 * scrolledRows;
- scrolledRows = 0;
- }
- firstVisibleRow += scrolledRows;
- int lastVisibleRow = firstVisibleRow + compositeTable.getNumRowsVisible() - visibleAllDayEventRows - 1;
-
- int startRow = calendarable.getUpperLeftPositionInDayRowCoordinates().y;
- int endRow = calendarable.getLowerRightPositionInDayRowCoordinates().y;
-
- if (timedEventIsVisible(firstVisibleRow, lastVisibleRow, startRow, endRow)) {
- int clippingStyle = SWT.NULL;
-
- if (startRow < firstVisibleRow) {
- startRow = firstVisibleRow;
- clippingStyle |= SWT.TOP;
- }
-
- if (endRow > lastVisibleRow) {
- endRow = lastVisibleRow;
- clippingStyle |= SWT.BOTTOM;
- }
-
- startRow = convertDayRowToViewportCoordinates(startRow);
- endRow = convertDayRowToViewportCoordinates(endRow);
-
- createCalendarableControl(calendarable);
- fillControlData(calendarable, clippingStyle);
-
- Rectangle startRowBounds = getTimeSliceBounds(day, startRow, gridRows);
- Rectangle endRowBounds = getTimeSliceBounds(day, endRow, gridRows);
-
- int leftmostColumn = calendarable.getUpperLeftPositionInDayRowCoordinates().x;
- int rightmostColumn = calendarable.getLowerRightPositionInDayRowCoordinates().x;
-
- int left = columnPositions[leftmostColumn].x;
- int top = startRowBounds.y + 1;
- int width = columnPositions[rightmostColumn].x - columnPositions[leftmostColumn].x + columnPositions[rightmostColumn].y;
- int height = endRowBounds.y - startRowBounds.y + endRowBounds.height - 1;
-
- Rectangle finalPosition = new Rectangle(left, top, width, height);
-
- getControl(calendarable).setBounds(finalPosition);
- getControl(calendarable).moveAbove(compositeTable);
- } else {
- freeCalendarableControl(calendarable);
- }
- }
-
- private boolean eventRowIsVisible(int eventRow) {
- int topRow = compositeTable.getTopRow();
- if (topRow <= eventRow) {
- if (eventRow < compositeTable.getNumRowsVisible() - topRow) {
- return true;
- }
- }
- return false;
- }
-
- private boolean timedEventIsVisible(int firstVisibleRow, int lastVisibleRow, int startRow, int endRow) {
- if (startRow < firstVisibleRow && endRow < firstVisibleRow)
- return false;
-
- if (startRow > lastVisibleRow && endRow > lastVisibleRow)
- return false;
-
- return true;
- }
-
- private void createCalendarableControl(CalendarableItem calendarable) {
- if (calendarable.getControl() == null) {
- calendarable.setControl(newCEC());
- if (calendarable == selectedCalendarable) {
- calendarable.getControl().setSelected(true);
- }
- }
- }
-
- private Rectangle getTimeSliceBounds(int day, int eventRow, Control[] gridRows) {
- int row = eventRow - compositeTable.getTopRow();
- TimeSlice rowObject = (TimeSlice) gridRows[row];
- Control slot = rowObject.getColumnControl(day);
- return getBoundsInDayEditorCoordinates(slot);
- }
-
- private void freeCalendarableControl(CalendarableItem calendarableItem) {
- if (calendarableItem.getControl() != null) {
- freeCEC(getControl(calendarableItem));
- calendarableItem.setControl(null);
- fireDisposeItemStrategy(calendarableItem);
- }
- }
-
- private Rectangle getBoundsInDayEditorCoordinates(Control slot) {
- return Display.getCurrent().map(slot.getParent(), this, slot.getBounds());
- }
-
- // CalendarableItemControl construction/destruction here -----------------
-
- MouseAdapter selectCompositeTableOnMouseDownAdapter = new MouseAdapter() {
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.MouseAdapter#mouseDown(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDown(MouseEvent e) {
- fireMouseDownEvent(e);
- ICalendarableItemControl control = (ICalendarableItemControl) e.widget;
- CalendarableItem aboutToSelect = control.getCalendarableItem();
- setSelection(aboutToSelect);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.MouseAdapter#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent e) {
- fireMouseDoubleClickEvent(e);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseUp(MouseEvent e) {
- fireMouseUpEvent(e);
- }
- };
-
- private DayEditorCalendarableItemControl newCEC() {
- if (recycledCalendarableEventControls.size() > 0) {
- DayEditorCalendarableItemControl result = (DayEditorCalendarableItemControl) recycledCalendarableEventControls.remove(0);
- result.setVisible(true);
- return result;
- }
- DayEditorCalendarableItemControl dayEditorCalendarableItemControl = new DayEditorCalendarableItemControl(this, SWT.NULL);
- if (menu != null) {
- dayEditorCalendarableItemControl.setMenu(menu);
- }
- dayEditorCalendarableItemControl.addMouseListener(selectCompositeTableOnMouseDownAdapter);
- return dayEditorCalendarableItemControl;
- }
-
- private void freeCEC(DayEditorCalendarableItemControl control) {
- control.setSelected(false);
- control.setCalendarableItem(null);
- control.setVisible(false);
- recycledCalendarableEventControls.add(control);
- }
-
- private Color background = null;
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#setBackground(org.eclipse.swt.graphics.Color)
- */
- public void setBackground(Color color) {
- checkWidget();
- super.setBackground(color);
- this.background = color;
- if (compositeTable != null) {
- compositeTable.setBackground(color);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Composite#setFocus()
- */
- public boolean setFocus() {
- checkWidget();
- if (!compositeTable.setFocus()) {
- return super.setFocus();
- }
- return true;
- }
-
-} // @jve:decl-index=0:visual-constraint="10,10"
-
-
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/DayEditorSelection.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/DayEditorSelection.java
deleted file mode 100644
index db4c781d..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/DayEditorSelection.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable.day;
-
-import java.util.Date;
-
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem;
-
-/**
- * Class DayEditorSelection. Represents the current selection in a DayEditor
- * control.
- *
- * @since 3.3
- */
-public class DayEditorSelection {
-
- /**
- * Represents the selected CalendarableItem or null if none is selected.
- */
- public CalendarableItem selectedCalendarable = null;
-
- /**
- * Sets the selectedCalendarable.
- *
- * @param selectedCalendarable the CalendarableItem to select
- */
- public void setSelectedCalendarable(CalendarableItem selectedCalendarable) {
- this.selectedCalendarable = selectedCalendarable;
- }
-
- /**
- * Indicates if the current selection is in an all-day event row.
- */
- public boolean allDay = false;
-
- /**
- * Sets the allDay flag.
- *
- * @param allDay true if the selection is in an all-day event row or if
- * the selectedCalenderable represents an all-day event; false otherwise.
- */
- public void setAllDay(boolean allDay) {
- this.allDay = allDay;
- }
-
- /**
- * The date/time of the currently selected cell or null if selectedCalenderable != null
- */
- public Date dateTime = null;
-
- /**
- * Sets the dateTime.
- *
- * @param date the Date to set.
- */
- public void setDateTime(Date date) {
- this.dateTime = date;
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/DayEditorTest.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/DayEditorTest.java
deleted file mode 100644
index 67915bed..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/DayEditorTest.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jface.examples.databinding.compositetable.day;
-
-import java.text.DateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventContentProvider;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventCountProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.2
- */
-public class DayEditorTest {
-
- private Shell sShell = null; // @jve:decl-index=0:visual-constraint="10,10"
- private Composite navBar = null;
- private Button left = null;
- private Button right = null;
- private Label startDateLabel = null;
- private DayEditor dayEditor = null;
-
- private static class Event {
- public boolean allDay = false;
- public Date startTime;
- public Date endTime;
- public String description;
-
- public Event(Date startTime, Date endTime, String description) {
- this.startTime = startTime;
- this.endTime = endTime;
- this.description = description;
- }
-
- public Event(String description) {
- this.allDay = true;
- this.description = description;
- }
- }
-
- private Date time(int hour, int minutes) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(new Date());
- gc.set(Calendar.HOUR_OF_DAY, hour);
- gc.set(Calendar.MINUTE, minutes);
- return gc.getTime();
- }
-
- private Event[][] events = new Event[][] {
- {new Event(time(5, 45), time(9, 45), "Stand-up meeting"),
- new Event(time(11, 00), time(12, 15), "Meet with customer")},
- {},
- {},
- {new Event("Nat. Conference"),
- new Event(time(7, 50), time(9, 00), "Stand-up meeting"),
- new Event(time(10, 15), time(12, 00), "Work on prototype")},
- {new Event("Nat. Conference"),
- new Event("Field trip to PC HQ"),
- new Event(time(8, 30), time(9, 30), "Stand-up meeting"),
- new Event(time(10, 00), time(13, 15), "Meet with customer"),
- new Event(time(12, 45), time(14, 15), "RC1 due"),
- new Event(time(13, 45), time(14, 15), "Way too much work"),
- new Event(time(10, 00), time(13, 30), "Callisto meeting")},
- {new Event("Nat. Conference")},
- {new Event(time(8, 30), time(11, 30), "Stand-up meeting"),
- new Event(time(10, 00), time(12, 15), "Meet with customer1"),
- new Event(time(11, 45), time(12, 15), "Meet with customer2"),
- new Event(time(11, 00), time(11, 15), "Meet with customer3")},
- {},
- {new Event(time(8, 50), time(9, 00), "Stand-up meeting"),
- new Event(time(10, 15), time(12, 00), "Work on prototype")},
- {new Event(time(8, 45), time(9, 45), "Stand-up meeting"),
- new Event(time(11, 00), time(12, 15), "Meet with customer")},
- {},
- {},
- {new Event(time(8, 12), time(9, 00), "Stand-up meeting"),
- new Event(time(10, 15), time(12, 00), "Work on prototype")},
- {},
- {},
- {new Event(time(8, 30), time(11, 30), "Stand-up meeting"),
- new Event(time(10, 00), time(12, 15), "Meet with customer"),
- new Event(time(11, 45), time(12, 15), "Meet with customer"),
- new Event(time(11, 00), time(2, 45), "Meet with customer")},
- {new Event(time(9, 50), time(9, 00), "Stand-up meeting"),
- new Event(time(10, 15), time(12, 00), "Work on prototype")},
- {},
- {},
- {},
- {},
- {},
- {},
- {},
- {},
- {},
- {},
- };
-
- /**
- * This method initializes navBar
- */
- private void createNavBar() {
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 3;
- GridData gridData1 = new org.eclipse.swt.layout.GridData();
- gridData1.horizontalAlignment = org.eclipse.swt.layout.GridData.CENTER;
- gridData1.verticalAlignment = org.eclipse.swt.layout.GridData.CENTER;
- navBar = new Composite(sShell, SWT.NONE);
- navBar.setLayoutData(gridData1);
- navBar.setLayout(gridLayout);
- left = new Button(navBar, SWT.LEFT | SWT.ARROW);
- left.addSelectionListener(previous);
- startDateLabel = new Label(navBar, SWT.NONE);
- right = new Button(navBar, SWT.RIGHT | SWT.ARROW);
- right.addSelectionListener(next);
- }
-
- /**
- * This method initializes dayEditor
- */
- private void createDayEditor() {
- GridData gridData = new org.eclipse.swt.layout.GridData();
- gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
- gridData.grabExcessHorizontalSpace = true;
- gridData.grabExcessVerticalSpace = true;
- gridData.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
- dayEditor = new DayEditor(sShell, SWT.NONE);
- dayEditor.setTimeBreakdown(7, 4);
-
- dayEditor.setDefaultStartHour(8);
- dayEditor.setEventCountProvider(eventCountProvider);
- dayEditor.setEventContentProvider(eventContentProvider);
- dayEditor.setLayoutData(gridData);
- updateStartDate();
- }
-
- private Date startDate = new Date();
-
- private void updateStartDate() {
- startDateLabel.setText(DateFormat.getDateInstance(DateFormat.FULL).format(startDate));
- startDateLabel.getParent().getParent().layout();
- dayEditor.setStartDate(startDate);
- }
-
- private void mutateDayOfMonth(int offset) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(startDate);
- gc.add(Calendar.DAY_OF_MONTH, offset);
- startDate = gc.getTime();
- updateStartDate();
- }
-
- private SelectionAdapter previous = new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- mutateDayOfMonth(-1);
- }
- };
-
- private SelectionAdapter next = new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- mutateDayOfMonth(1);
- }
- };
-
- private EventCountProvider eventCountProvider = new EventCountProvider() {
- public int getNumberOfEventsInDay(Date day) {
- return events[getOffset(day)].length;
- }
- };
-
- private EventContentProvider eventContentProvider = new EventContentProvider() {
- public void refresh(Date day, CalendarableItem[] controls) {
- int dayOffset = getOffset(day);
-
- for (int event=0; event < events[dayOffset].length; ++event) {
- fillEvent(controls[event], events[dayOffset][event]);
- }
- }
-
- private void fillEvent(CalendarableItem c, Event event) {
- if (event.allDay) {
- c.setAllDayEvent(true);
- } else {
- c.setStartTime(event.startTime);
- c.setEndTime(event.endTime);
- }
- c.setData(event);
- c.setText(event.description);
- }
- };
-
- protected int getOffset(Date day) {
- GregorianCalendar dateToFind = new GregorianCalendar();
- dateToFind.setTime(day);
- GregorianCalendar dateToTest = new GregorianCalendar();
- dateToTest.setTime(new Date());
- for (int i=0; i < events.length; ++i) {
- if (dateToTest.get(Calendar.MONTH) == dateToFind.get(Calendar.MONTH) &&
- dateToTest.get(Calendar.DAY_OF_MONTH) == dateToFind.get(Calendar.DAY_OF_MONTH) &&
- dateToTest.get(Calendar.YEAR) == dateToFind.get(Calendar.YEAR))
- {
- return i;
- }
- dateToTest.add(Calendar.DAY_OF_MONTH, 1);
- }
- throw new IndexOutOfBoundsException(day + " does not have any data");
- }
-
- /**
- * This method initializes sShell
- */
- private void createSShell() {
- sShell = new Shell();
- sShell.setText("Day Editor Test");
- sShell.setLayout(new GridLayout());
- createNavBar();
- createDayEditor();
- sShell.setSize(new org.eclipse.swt.graphics.Point(800, 592));
- }
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Display display = Display.getDefault();
- DayEditorTest thisClass = new DayEditorTest();
- thisClass.createSShell();
- thisClass.sShell.open();
- while (!thisClass.sShell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/NewEvent.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/NewEvent.java
deleted file mode 100644
index 133b8c1f..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/NewEvent.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable.day;
-
-import java.util.Date;
-
-/**
- * Encapsulates information about new events that have been added to the calendar.
- *
- * @since 3.3
- */
-public class NewEvent {
-
- /**
- * The application's event object. When an application returns a NewEvent,
- * normally it will create a domain model object that represents the event.
- * This field is for application use to pass that model object to listeners
- * who may have requested for the new event to be created. Clients are free
- * to pass null if this is not applicable to them.
- */
- public final Object event;
-
- /**
- * The start date/time and end date/time of the new event. A Date[2]
- * containing the start date/time and the end date/time of the new event.
- * The IEventEditor will automatically refresh any days it is displaying
- * that overlap this date/time range.
- */
- public final Date[] startTimeEndTime;
-
- /**
- * Construct a NewEvent.
- *
- * @param event The application-defined event object or null if none.
- * @param startTimeEndTime A Date[2] containing the range of dates/times
- * this event spans.
- */
- public NewEvent(final Object event, final Date[] startTimeEndTime) {
- super();
- this.event = event;
- this.startTimeEndTime = startTimeEndTime;
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/SelectionChangeEvent.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/SelectionChangeEvent.java
deleted file mode 100644
index a20a6090..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/SelectionChangeEvent.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * 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.examples.databinding.compositetable.day;
-
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem;
-
-/**
- * A SelectionChangeEvent for selected Calendarables in a DayEditor.
- *
- * @since 3.2
- */
-public class SelectionChangeEvent {
- /**
- * The previously selected Calendarable or null if no selection
- */
- public final CalendarableItem oldSelection;
-
- /**
- * The new selection or null if the selection is being cleared
- */
- public final CalendarableItem newSelection;
-
- /**
- * Constructor SelectionChangeEvent. Construct a SelectionChangeEvent from
- * the Calendarable objects that represent the old and new selection.
- *
- * @param oldSelection The previously selected Calendarable or null if no selection
- * @param newSelection The new selection or null if the selection is being cleared
- */
- public SelectionChangeEvent(final CalendarableItem oldSelection, final CalendarableItem newSelection) {
- this.oldSelection = oldSelection;
- this.newSelection = newSelection;
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/TODO.txt b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/TODO.txt
deleted file mode 100644
index 0a18eb6e..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/TODO.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-Calendar binding tasks:
-=======================
-
- * Create a Hibernate mapping for a java.util.List Events that we can bind **DONE**
- * Add code to implement insert and deletion using the above listeners **DONE**
- * Change the new event dialog so that it inserts the event by adding it to
- Hibernate's mapped collection, then calling flush() on the session. **DONE**
-
- * Create a LazyInsertDeleteProvider that displays the new event dialog and
- initializes its values to the current date/time.
- * In the action that opens a dialog to create a new event, detect if an
- IEventEditor is open, and if it is,
- call fireInsert to display the new event dialog and perform the insert
- operation.
- * When the user clicks OK in the new event dialog, detect if the calender is
- open and if it is not open, open it.
- * Hook up UI gestures (double-click, insert keypress, delete keypress) to
- insert/delete events
-
-
-CalendarableItem(Control)? tasks:
- * Needs an event model (change listeners, etc) **DONE**
- * Needs to update the control when the item is updated if the control is visible **DONE**
- * Needs an in-place editor (DEFERRED)
-
-DayEditor tasks:
- * Needs an event that is fired when a CalendarableItem is no longer visible
- (so bindings can be disposed) **DONE**
- * Needs an addInsertHandler/removeInsertHandler, ... **DONE**
- * Needs an addDeleteHandler/removeDeleteHandler, ... **DONE**
- * Needs an addEditHandler/removeEditHandler, ... **DONE**
-
-DayEditor data binding tasks: **DONE**
-
-In-place editing tasks: (DEFERRED)
- * Show in-place editor when user clicks a CalendarableItemControl (or maybe use
- an SWT Text to begin with)
- * Hook events on the editor and change the CalendarableItem's text property
- as the CalendarableItemControl's text property changes
-
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/binding/EventDateTimeDiff.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/binding/EventDateTimeDiff.java
deleted file mode 100644
index 0fd8f4e4..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/binding/EventDateTimeDiff.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable.day.binding;
-
-import java.util.Date;
-
-import org.eclipse.jface.databinding.observable.IDiff;
-
-/**
- * When a multi-day calendarable event is edited, clients may need to know
- * about changes in the span of days covered. This class encapsulates those
- * changes.
- *
- * @since 3.3
- */
-public class EventDateTimeDiff implements IDiff {
- private final Date oldStartDateTime;
- private final Date oldEndDateTime;
- private Date newStartDateTime;
- private Date newEndDateTime;
-
- /**
- * @param oldStartDateTime
- * @param oldEndDateTime
- */
- public EventDateTimeDiff(Date oldStartDateTime, Date oldEndDateTime) {
- this.oldStartDateTime = oldStartDateTime;
- this.oldEndDateTime = oldEndDateTime;
- }
-
- /**
- * @param oldStartDateTime
- * @param oldEndDateTime
- * @param newStartDateTime
- * @param newEndDateTime
- */
- public EventDateTimeDiff(Date oldStartDateTime, Date oldEndDateTime, Date newStartDateTime, Date newEndDateTime) {
- this.oldStartDateTime = oldStartDateTime;
- this.oldEndDateTime = oldEndDateTime;
- this.newStartDateTime = newStartDateTime;
- this.newEndDateTime = newEndDateTime;
- }
-
- /**
- * @return Returns the newEndDateTime.
- */
- public Date getNewEndDateTime() {
- return newEndDateTime;
- }
-
- /**
- * @param newEndDateTime The newEndDateTime to set.
- */
- public void setNewEndDateTime(Date newEndDateTime) {
- this.newEndDateTime = newEndDateTime;
- }
-
- /**
- * @return Returns the newStartDateTime.
- */
- public Date getNewStartDateTime() {
- return newStartDateTime;
- }
-
- /**
- * @param newStartDateTime The newStartDateTime to set.
- */
- public void setNewStartDateTime(Date newStartDateTime) {
- this.newStartDateTime = newStartDateTime;
- }
-
- /**
- * @return Returns the oldEndDateTime.
- */
- public Date getOldEndDateTime() {
- return oldEndDateTime;
- }
-
- /**
- * @return Returns the oldStartDateTime.
- */
- public Date getOldStartDateTime() {
- return oldStartDateTime;
- }
-
- /**
- * @param startDateTime
- * @param endDateTime
- */
- public void setNewDateTimes(Date startDateTime, Date endDateTime) {
- setNewStartDateTime(startDateTime);
- setNewEndDateTime(endDateTime);
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/binding/EventEditorBindingDescription.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/binding/EventEditorBindingDescription.java
deleted file mode 100644
index 001394d3..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/binding/EventEditorBindingDescription.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable.day.binding;
-
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-
-/**
- * A binding description for an IEventEditor control.
- *
- * @since 3.3
- */
-public class EventEditorBindingDescription {
-
- /**
- * The IEventEditor to bind
- */
- public final IEventEditor editor;
- /**
- * A data binding context for binding CalendarableItems
- */
- public final DataBindingContext dbc;
- /**
- * The name of the model-side start time property
- */
- public final String startTimePropertyName;
- /**
- * The name of the model-side end time property
- */
- public final String endTimePropertyName;
- /**
- * The name of the model-side text property
- */
- public final String textPropertyName;
- /**
- * The name of the model-side tool tip text property
- */
- public final String toolTipTextPropertyName;
- /**
- * The name of the model-side image property
- */
- public final String imagePropertyName;
- /**
- * The name of the all-day event flag property
- */
- public final String allDayEventPropertyName;
-
- /**
- * Construct a binding description for a particular IEventEditor
- *
- * @param editor The IEventEditor to bind
- * @param dbc A data binding context for binding CalendarableItems
- * @param startTimePropertyName The name of the model-side start time property
- * @param endTimePropertyName The name of the model-side end time property
- * @param allDayEventPropertyName The name of the all-day event flag property
- * @param textPropertyName The name of the model-side text property
- * @param toolTipTextPropertyName The name of the model-side tool tip text property
- * @param imagePropertyName The name of the model-side image property
- */
- public EventEditorBindingDescription(final IEventEditor editor, final DataBindingContext dbc, final String startTimePropertyName, final String endTimePropertyName, String allDayEventPropertyName, final String textPropertyName, final String toolTipTextPropertyName, final String imagePropertyName) {
- this.editor = editor;
- this.dbc = dbc;
- this.startTimePropertyName = startTimePropertyName;
- this.endTimePropertyName = endTimePropertyName;
- this.allDayEventPropertyName = allDayEventPropertyName;
- this.textPropertyName = textPropertyName;
- this.toolTipTextPropertyName = toolTipTextPropertyName;
- this.imagePropertyName = imagePropertyName;
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/binding/EventEditorObservableLazyDataRequestor.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/binding/EventEditorObservableLazyDataRequestor.java
deleted file mode 100644
index bab30137..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/binding/EventEditorObservableLazyDataRequestor.java
+++ /dev/null
@@ -1,634 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable.day.binding;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.eclipse.jface.databinding.observable.AbstractObservable;
-import org.eclipse.jface.examples.databinding.compositetable.day.CalendarableItemEvent;
-import org.eclipse.jface.examples.databinding.compositetable.day.CalendarableItemEventHandler;
-import org.eclipse.jface.examples.databinding.compositetable.day.CalendarableSelectionChangeListener;
-import org.eclipse.jface.examples.databinding.compositetable.day.NewEvent;
-import org.eclipse.jface.examples.databinding.compositetable.day.SelectionChangeEvent;
-import org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl;
-import org.eclipse.jface.examples.databinding.compositetable.reflect.ReflectedProperty;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventContentProvider;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventCountProvider;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor;
-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.observable.ILazyDataRequestor;
-import org.eclipse.jface.internal.databinding.provisional.observable.ILazyListElementProvider;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyDeleteEvent;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertDeleteProvider;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertEvent;
-import org.eclipse.swt.SWT;
-
-/**
- * An Observable for IEventEditor objects.
- *
- * @since 3.2
- */
-public class EventEditorObservableLazyDataRequestor extends AbstractObservable implements ILazyDataRequestor {
-
- private IEventEditor editor;
- private MultiDayEventCalendar multiDayEventCalendar = new MultiDayEventCalendar();
- protected int modelSize = 0;
-
- private DataBindingContext dbc;
- private String startTimePropertyName; // Required; rest are optional
- private String endTimePropertyName = null;
- private String textPropertyName = null;
- private String toolTipTextPropertyName = null;
- private String imagePropertyName = null;
- private String allDayEventPropertyName = null;
-
- private class EventToCalendarableItem {
- /**
- * a in the pair (a, b)
- */
- public Object event;
-
- /**
- * b in the pair (a, b)
- */
- public CalendarableItem item;
-
- /**
- * Construct a Pair(a, b)
- *
- * @param a a in the pair (a, b)
- * @param b b in the pair (a, b)
- */
- public EventToCalendarableItem(Object a, CalendarableItem b) {
- this.event = a;
- this.item = b;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- if (obj.getClass() != EventToCalendarableItem.class) {
- return false;
- }
- EventToCalendarableItem other = (EventToCalendarableItem) obj;
- return event.equals(other.event) && item.equals(other.item);
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return event.hashCode() + item.hashCode();
- }
- }
-
-
- private class MultiDayEventCalendar {
- private Map daysToEventsMap;
- private List eventsList;
-
- public MultiDayEventCalendar() {
- flush();
- }
-
- public void flush() {
- daysToEventsMap = new TreeMap();
- eventsList = new LinkedList();
- for (int i=0; i < modelSize; ++i) {
- Object event = getModelElementAt(i);
- add(event);
- }
- }
-
- public void add(Object event) {
- eventsList.add(event);
- addMultiDayEventToMap(event);
- }
-
- private void addMultiDayEventToMap(Object event) {
- Date beginningDate = getBeginningDate(event);
- Date endingDate = getEndingDate(event);
- for (Date currentDate = beginningDate;
- currentDate.before(endingDate);
- currentDate = nextDay(currentDate))
- {
- addEventToMap(currentDate, event);
- }
- }
-
- private void addEventToMap(Object date, Object event) {
- List events = (List) daysToEventsMap.get(date);
- if (events == null) {
- events = new LinkedList();
- daysToEventsMap.put(date, events);
- }
- EventToCalendarableItem eventToCalenderable = new EventToCalendarableItem(event, null);
- events.add(eventToCalenderable);
- daysToEventsMap.put(date, events);
- }
-
- public Object remove(int position) {
- Object toRemove = eventsList.remove(position);
- Date beginningDate = getBeginningDate(toRemove);
- Date endingDate = getEndingDate(toRemove);
- for (Date currentDate = beginningDate;
- currentDate.before(endingDate);
- currentDate = nextDay(currentDate))
- {
- removeEventFromMap(currentDate, toRemove);
- }
- return toRemove;
- }
-
- private void removeEventFromMap(Date date, Object event) {
- List events = (List) daysToEventsMap.get(date);
- if (events == null) {
- // TODO: Log warning here?
- return;
- }
- for (Iterator eventsIter = events.iterator(); eventsIter.hasNext();) {
- EventToCalendarableItem eventToCalendarable = (EventToCalendarableItem) eventsIter.next();
- if (eventToCalendarable.event.equals(event)) {
- eventsIter.remove();
- break;
- }
- }
- events.remove(event);
- if (events.size() < 1) {
- daysToEventsMap.remove(date);
- }
- }
-
- public void update(EventDateTimeDiff diff, Object event) {
- // Remove the event in the old position
- Date oldStartDateTime = setToStartOfDay(diff.getOldStartDateTime());
- Date oldEndDateTime = incrementDay(setToStartOfDay(diff.getOldEndDateTime()), 1);
- for (Date currentDate = oldStartDateTime;
- currentDate.before(oldEndDateTime);
- currentDate = nextDay(currentDate))
- {
- removeEventFromMap(currentDate, event);
- }
- addMultiDayEventToMap(event);
-// add(event); Can't do this because it adds dupes to the eventsList
- }
-
- private List get(Date date) {
- date = setToStartOfDay(date);
- return (List) daysToEventsMap.get(date);
- }
-
- public int indexOf(Object event) {
- return eventsList.indexOf(event);
- }
-
- public void setCalendarableSelection(Object event, boolean selected) {
- Date beginningDate = getBeginningDate(event);
- Date endingDate = getEndingDate(event);
-
- for (Date currentDate = beginningDate;
- currentDate.before(endingDate);
- currentDate = nextDay(currentDate))
- {
- List events = (List) daysToEventsMap.get(currentDate);
-
- if (events == null) { // If we just deleted this event, return
- return;
- }
-
- for (Iterator eventsIter = events.iterator(); eventsIter.hasNext();) {
- EventToCalendarableItem eventToCalendarable = (EventToCalendarableItem) eventsIter.next();
- if (eventToCalendarable.event.equals(event)) {
- if (eventToCalendarable.item != null) {
- ICalendarableItemControl control = eventToCalendarable.item.getControl();
- if (control != null) {
- control.setSelected(selected);
- }
- }
- break;
- }
- }
- }
- }
-
- public int getNumberOfEventsInDay(Date day) {
- List dataForDate = multiDayEventCalendar.get(day);
- if (dataForDate == null) {
- return 0;
- }
- return dataForDate.size();
- }
-
- public void refresh(Date day, CalendarableItem[] items) {
- List dataForDate = multiDayEventCalendar.get(day);
- if (dataForDate == null) {
- return;
- }
-
- Iterator sourceEventIter = dataForDate.iterator();
- for (int itemIndex = 0; itemIndex < items.length; itemIndex++) {
- EventToCalendarableItem sourceEventPair = (EventToCalendarableItem) sourceEventIter.next();
- sourceEventPair.item = items[itemIndex];
- Object sourceEvent = sourceEventPair.event;
- Date startDate = getBeginningDate(sourceEvent);
- Date endDate = getEndingTime(sourceEvent);
- int dayWithinEvent = differenceInDays(day, startDate);
- int numberOfDaysInEvent = differenceInDays(endDate, startDate)+1;
- bindCalendarableItemProperties(items[itemIndex], sourceEvent, dayWithinEvent, numberOfDaysInEvent);
- }
- }
-
- /**
- * Returns 11:59:999 PM of the ending date of the passed event.
- *
- * @param it The event
- * @return The ending of the last day
- */
- protected Date getEndingDate(Object it) {
- ReflectedProperty property = new ReflectedProperty(it, endTimePropertyName);
- Date endingDate = (Date) property.get();
- Date endOfEndingDate = setToEndOfDay(endingDate);
- return endOfEndingDate;
- }
-
- private int differenceInDays(Date date, Date daysToSubtract) {
- long difference = date.getTime() - daysToSubtract.getTime();
- difference /= (1000*60*60*24);
- return (int) difference;
- }
-
- }
-
- /**
- * @param d
- */
- public EventEditorObservableLazyDataRequestor(EventEditorBindingDescription d) {
- super();
- this.editor = d.editor;
- this.dbc = d.dbc;
- if (d.startTimePropertyName == null) {
- throw new IllegalArgumentException("Start time property description cannot be null");
- }
- this.startTimePropertyName = d.startTimePropertyName;
- this.endTimePropertyName = d.endTimePropertyName;
- this.allDayEventPropertyName = d.allDayEventPropertyName;
- this.textPropertyName = d.textPropertyName;
- this.toolTipTextPropertyName = d.toolTipTextPropertyName;
- this.imagePropertyName = d.imagePropertyName;
-
- editor.setEventCountProvider(eventCountProvider);
- editor.setEventContentProvider(eventContentProvider);
- editor.addItemDisposeHandler(itemDisposeHandler);
- editor.addItemInsertHandler(insertHandler);
- editor.addItemDeleteHandler(deleteHandler);
- editor.addItemEditHandler(editHandler);
- editor.addSelectionChangeListener(selectionListener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.AbstractObservable#dispose()
- */
- public void dispose() {
- super.dispose();
- if (editor == null) {
- return;
- }
- editor.removeItemInsertHandler(insertHandler);
- editor.removeItemDeleteHandler(deleteHandler);
- editor.removeItemDisposeHandler(itemDisposeHandler);
- editor.removeItemEditHandler(editHandler);
- editor.setEventCountProvider(null);
- editor.setEventContentProvider(null);
- editor = null; // encourage the garbage collector to run... ;-)
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.IObservable#isStale()
- */
- public boolean isStale() {
- return false;
- }
-
- private List elementProviders = new ArrayList();
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor#addElementProvider(org.eclipse.jface.internal.databinding.provisional.observable.ILazyListElementProvider)
- */
- public void addElementProvider(ILazyListElementProvider p) {
- elementProviders.add(p);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor#removeElementProvider(org.eclipse.jface.internal.databinding.provisional.observable.ILazyListElementProvider)
- */
- public void removeElementProvider(ILazyListElementProvider p) {
- elementProviders.remove(p);
- }
-
- private Object getModelElementAt(int index) {
- for (Iterator epIter = elementProviders.iterator(); epIter.hasNext();) {
- ILazyListElementProvider p = (ILazyListElementProvider) epIter.next();
- Object result = p.get(index);
- if (result != null) {
- return result;
- }
- }
- throw new IndexOutOfBoundsException("Request for a nonexistent element");
- }
-
- private List insertDeleteProviders = new ArrayList();
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor#addInsertDeleteProvider(org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertDeleteProvider)
- */
- public void addInsertDeleteProvider(LazyInsertDeleteProvider p) {
- insertDeleteProviders.add(p);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor#removeInsertDeleteProvider(org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertDeleteProvider)
- */
- public void removeInsertDeleteProvider(LazyInsertDeleteProvider p) {
- insertDeleteProviders.remove(p);
- }
-
- private NewObject fireInsert(CalendarableItem initializationData) {
- for (Iterator iter = insertDeleteProviders.iterator(); iter.hasNext();) {
- LazyInsertDeleteProvider p = (LazyInsertDeleteProvider) iter.next();
- NewObject result = p.insertElementAt(new LazyInsertEvent(0, initializationData));
- if (result != null) {
- return result;
- }
- }
- return null;
- }
-
- private boolean fireDelete(int position) {
- for (Iterator iter = insertDeleteProviders.iterator(); iter.hasNext();) {
- LazyInsertDeleteProvider p = (LazyInsertDeleteProvider) iter.next();
- LazyDeleteEvent e = new LazyDeleteEvent(position);
- boolean result = p.canDeleteElementAt(e);
- if (result) {
- p.deleteElementAt(e);
- return true;
- }
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor#setSize(int)
- */
- public void setSize(int size) {
- this.modelSize = size;
- multiDayEventCalendar.flush();
- editor.refresh();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor#add(int, java.lang.Object)
- */
- public void add(int position, Object element) {
- multiDayEventCalendar.add(element);
- modelSize++;
- editor.refresh();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor#remove(int)
- */
- public void remove(int position) {
- multiDayEventCalendar.remove(position);
- modelSize--;
- editor.refresh();
- }
-
- // Utility methods here ---------------------------------------------------
-
- protected Date incrementDay(Date initialDate, int increment) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(initialDate);
- gc.add(Calendar.DATE, increment);
- return gc.getTime();
- }
-
- protected Date nextDay(Date initialDate) {
- return incrementDay(initialDate, 1);
- }
-
- protected static Date setToStartOfDay(Date rawDate) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(rawDate);
- gc.set(Calendar.HOUR_OF_DAY, 0);
- gc.set(Calendar.MINUTE, 0);
- gc.set(Calendar.SECOND, 0);
- gc.set(Calendar.MILLISECOND, 0);
- return gc.getTime();
- }
-
- /**
- * Returns 12 AM of the beginning date of the passed event.
- *
- * @param it The event
- * @return The beginning of the start day.
- */
- protected Date getBeginningDate(Object it) {
- ReflectedProperty property = new ReflectedProperty(it, startTimePropertyName);
- Date date = setToStartOfDay((Date) property.get());
- return date;
- }
-
- protected static Date setToEndOfDay(Date date) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(date);
- gc.set(Calendar.HOUR_OF_DAY, 23);
- gc.set(Calendar.MINUTE, 59);
- gc.set(Calendar.SECOND, 59);
- gc.set(Calendar.MILLISECOND, 999);
- Date time = gc.getTime();
- return time;
- }
-
- private Date getBeginningTime(Object it) {
- ReflectedProperty property = new ReflectedProperty(it, startTimePropertyName);
- return ((Date) property.get());
- }
-
- private Date getEndingTime(Object it) {
- if (endTimePropertyName == null) {
- return getBeginningTime(it);
- }
- ReflectedProperty property = new ReflectedProperty(it, endTimePropertyName);
- return (Date)property.get();
- }
-
- // Event handlers here ----------------------------------------------------
-
- protected void bindCalendarableItemProperties(
- CalendarableItem item,
- Object sourceElement,
- int eventPosition,
- int eventLength) {
-
- // Optional bindings first...
- if (allDayEventPropertyName != null) {
- bindCalendarableItem(
- item, CalendarableItem.PROP_ALL_DAY_EVENT,
- sourceElement, allDayEventPropertyName, null);
- }
- if (textPropertyName != null) {
- bindCalendarableItem(
- item, CalendarableItem.PROP_TEXT,
- sourceElement, textPropertyName, null);
- }
- if (toolTipTextPropertyName != null) {
- bindCalendarableItem(
- item, CalendarableItem.PROP_TOOL_TIP_TEXT,
- sourceElement, toolTipTextPropertyName, null);
- }
- if (imagePropertyName != null) {
- bindCalendarableItem(
- item, CalendarableItem.PROP_IMAGE,
- sourceElement, imagePropertyName, null);
- }
-
- // Now the standard bindings...
- item.setContinued(SWT.NULL);
- if (eventLength == 1) {
- item.setDate(getBeginningDate(sourceElement));
- item.setStartTime(getBeginningTime(sourceElement));
- item.setEndTime(getEndingTime(sourceElement));
- } else { // multiday event
- if (eventPosition == 0) { // first day of event
- Date day = getBeginningDate(sourceElement);
- item.setDate(day);
- item.setStartTime(getBeginningTime(sourceElement));
- item.setEndTime(setToEndOfDay(day));
- if (!item.isAllDayEvent())
- item.setContinued(SWT.BOTTOM);
- } else if (eventPosition == eventLength - 1) { // last day of event
- Date beginningOfEndDay = setToStartOfDay(getEndingTime(sourceElement));
- item.setDate(beginningOfEndDay);
- item.setStartTime(beginningOfEndDay);
- item.setEndTime(getEndingTime(sourceElement));
- if (!item.isAllDayEvent())
- item.setContinued(SWT.TOP);
- } else { // in between first and last day of event
- Date day = incrementDay(getBeginningDate(sourceElement), eventPosition);
- Date startOfDay = setToStartOfDay(day);
- item.setDate(startOfDay);
- item.setStartTime(startOfDay);
- item.setEndTime(setToEndOfDay(day));
- if (!item.isAllDayEvent())
- item.setContinued(SWT.TOP | SWT.BOTTOM);
- }
- }
- item.setData(CalendarableItem.DATA_KEY, sourceElement);
- }
-
- private void bindCalendarableItem(CalendarableItem item, String itemPropertyName, Object sourceElement, String sourcePropertyName, BindSpec bindSpec) {
- Binding binding = dbc.bind(new Property(item, itemPropertyName),
- new Property(sourceElement, sourcePropertyName), bindSpec);
- List bindingList = (List) item.getData(CalendarableItem.BINDING_KEY);
- if (bindingList == null) {
- bindingList = new ArrayList();
- item.setData(CalendarableItem.BINDING_KEY, bindingList);
- }
- bindingList.add(binding);
- }
-
- private CalendarableItemEventHandler itemDisposeHandler = new CalendarableItemEventHandler() {
- public void handleRequest(CalendarableItemEvent e) {
- List bindings = (List)e.calendarableItem.getData(CalendarableItem.BINDING_KEY);
- if (bindings != null) {
- for (Iterator bindingIter = bindings.iterator(); bindingIter.hasNext();) {
- Binding binding = (Binding) bindingIter.next();
- binding.dispose();
- }
- }
- }
- };
-
- private EventCountProvider eventCountProvider = new EventCountProvider() {
- public int getNumberOfEventsInDay(Date day) {
- return multiDayEventCalendar.getNumberOfEventsInDay(day);
- }
- };
-
- private EventContentProvider eventContentProvider = new EventContentProvider() {
- public void refresh(Date day, CalendarableItem[] items) {
- multiDayEventCalendar.refresh(day, items);
- }
- };
-
- private CalendarableItemEventHandler insertHandler = new CalendarableItemEventHandler() {
- public void handleRequest(CalendarableItemEvent e) {
- NewObject newObject = fireInsert(e.calendarableItem);
- if (newObject == null) {
- e.doit = false;
- return;
- }
- multiDayEventCalendar.add(newObject.it);
- Date firstDayOfEvent = getBeginningTime(newObject.it);
- Date lastDayOfEvent = getEndingTime(newObject.it);
- e.result = new NewEvent(newObject.it, new Date[] {firstDayOfEvent, lastDayOfEvent});
- }
- };
-
- private CalendarableItemEventHandler deleteHandler = new CalendarableItemEventHandler() {
- public void handleRequest(CalendarableItemEvent e) {
- int objectToDelete = multiDayEventCalendar.indexOf(e.calendarableItem.getData(CalendarableItem.DATA_KEY));
- if (!fireDelete(objectToDelete)) {
- e.doit = false;
- return;
- }
- multiDayEventCalendar.remove(objectToDelete);
- }
- };
-
- private CalendarableItemEventHandler editHandler = new CalendarableItemEventHandler() {
- public void requestHandled(CalendarableItemEvent e) {
- if (e.result != null && e.doit) {
- multiDayEventCalendar.update((EventDateTimeDiff) e.result,
- e.calendarableItem.getData(CalendarableItem.DATA_KEY));
- }
- }
- };
-
- private CalendarableSelectionChangeListener selectionListener = new CalendarableSelectionChangeListener() {
- public void selectionChanged(SelectionChangeEvent e) {
- if (e.oldSelection != null) {
- multiDayEventCalendar.setCalendarableSelection(e.oldSelection.getData(CalendarableItem.DATA_KEY), false);
- }
- if (e.newSelection != null) {
- multiDayEventCalendar.setCalendarableSelection(e.newSelection.getData(CalendarableItem.DATA_KEY), true);
- }
- }
- };
-
-}
-
-
-
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/binding/EventEditorObservableLazyDataRequestorFactory.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/binding/EventEditorObservableLazyDataRequestorFactory.java
deleted file mode 100644
index 238605ed..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/binding/EventEditorObservableLazyDataRequestorFactory.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable.day.binding;
-
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.internal.databinding.provisional.factories.IObservableFactory;
-
-/**
- * An observable factory for EventEditorObservableLazyDataRequestors
- *
- * @since 3.3
- */
-public class EventEditorObservableLazyDataRequestorFactory implements
- IObservableFactory {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.factories.IObservableFactory#createObservable(java.lang.Object)
- */
- public IObservable createObservable(Object description) {
- if (description instanceof EventEditorBindingDescription) {
- return new EventEditorObservableLazyDataRequestor(
- (EventEditorBindingDescription) description);
- }
- return null;
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/binding/calendar-day-mode-binding.svg b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/binding/calendar-day-mode-binding.svg
deleted file mode 100644
index 3d05a8a0..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/binding/calendar-day-mode-binding.svg
+++ /dev/null
@@ -1,479 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://web.resource.org/cc/"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="744.09448819"
- height="1052.3622047"
- id="svg2"
- sodipodi:version="0.32"
- inkscape:version="0.43"
- sodipodi:docbase="C:\tpc\ipartner\org.eclipse.jface.examples.databinding\src\org\eclipse\jface\examples\databinding\compositetable\day\binding"
- sodipodi:docname="calendar-day-mode-binding.svg">
- <defs
- id="defs4">
- <marker
- inkscape:stockid="Arrow2Mend"
- orient="auto"
- refY="0.0"
- refX="0.0"
- id="Arrow2Mend"
- style="overflow:visible;">
- <path
- id="path2352"
- style="font-size:12.0;fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round;"
- d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
- transform="scale(0.6) rotate(180) translate(-5,0)" />
- </marker>
- </defs>
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="1.4"
- inkscape:cx="277.67367"
- inkscape:cy="509.61646"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- showguides="false"
- inkscape:window-width="805"
- inkscape:window-height="768"
- inkscape:window-x="32"
- inkscape:window-y="60" />
- <metadata
- id="metadata7">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1">
- <rect
- style="fill:#e9e9ff;fill-opacity:1;stroke:#010070;stroke-width:0.7170344;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect2198"
- width="94.916832"
- height="26.928858"
- x="245.04158"
- y="65.326324" />
- <text
- xml:space="preserve"
- style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="262.14285"
- y="82.362183"
- id="text1307"><tspan
- sodipodi:role="line"
- id="tspan1309"
- x="262.14285"
- y="82.362183">DayEditor</tspan></text>
- <rect
- style="fill:#e9e9ff;fill-opacity:1;stroke:#010070;stroke-width:1.79743409;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect1323"
- width="290"
- height="55.384613"
- x="153.57143"
- y="117.88416" />
- <text
- xml:space="preserve"
- style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="198.57143"
- y="133.6479"
- id="text1311"><tspan
- sodipodi:role="line"
- id="tspan1313"
- x="198.57143"
- y="133.6479">Count Provider</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="305.00003"
- y="133.6479"
- id="text1315"><tspan
- sodipodi:role="line"
- id="tspan1317"
- x="305.00003"
- y="133.6479">Content Provider</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:15.60923672px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="203.02376"
- y="131.83124"
- id="text1319"
- transform="scale(0.805401,1.241618)"><tspan
- sodipodi:role="line"
- id="tspan1321"
- x="203.02376"
- y="131.83124">EventEditorObservableLazyDataRequestor</tspan></text>
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Mend)"
- d="M 286.69252,84.858276 L 248.11338,124.53072"
- id="path2200"
- inkscape:connector-type="polyline"
- inkscape:connection-start="#text1307"
- inkscape:connection-end="#text1311" />
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Mend)"
- d="M 299.72266,84.858276 L 350.1687,124.53072"
- id="path2204"
- inkscape:connector-type="polyline"
- inkscape:connection-start="#text1307"
- inkscape:connection-end="#text1315" />
- <text
- xml:space="preserve"
- style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="463.57144"
- y="153.79076"
- id="text2397"><tspan
- sodipodi:role="line"
- id="tspan2399"
- x="463.57144"
- y="153.79076">(ILazyDataRequestor)</tspan></text>
- <rect
- style="fill:#e9e9ff;fill-opacity:1;stroke:#010070;stroke-width:1.79743409;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect2401"
- width="290"
- height="55.384613"
- x="152.85715"
- y="203.9556" />
- <text
- xml:space="preserve"
- style="font-size:15.60926533px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="364.43457"
- y="191.83397"
- id="text2411"
- transform="scale(0.805401,1.241618)"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- id="tspan2413"
- x="364.43457"
- y="191.83397">LazyListBinding</tspan></text>
- <rect
- style="fill:#e9e9ff;fill-opacity:1;stroke:#010070;stroke-width:1.79743409;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect2415"
- width="290"
- height="55.384613"
- x="150.71428"
- y="293.2413" />
- <text
- xml:space="preserve"
- style="font-size:15.60925674px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="367.98193"
- y="263.28452"
- id="text2425"
- transform="scale(0.805401,1.241618)"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- id="tspan2427"
- x="367.98193"
- y="263.28452">JavaBeanObservableList</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:100%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="542.28571"
- y="227.36218"
- id="text2433"
- sodipodi:linespacing="100%"><tspan
- sodipodi:role="line"
- id="tspan2435"
- x="542.28571"
- y="227.36218">(ILazyListElementProvider)</tspan><tspan
- sodipodi:role="line"
- x="542.28571"
- y="239.36218"
- id="tspan2437"
- style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:100%;writing-mode:lr-tb;text-anchor:middle;font-family:Bitstream Vera Sans">(extends IObservableList)</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:100%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="540.00293"
- y="321.84406"
- id="text2439"
- sodipodi:linespacing="100%"><tspan
- sodipodi:role="line"
- x="540.00293"
- y="321.84406"
- id="tspan2443"
- style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:100%;writing-mode:lr-tb;text-anchor:middle;font-family:Bitstream Vera Sans">(ILazyListElementProvider)</tspan></text>
- <rect
- style="fill:#e9e9ff;fill-opacity:1;stroke:#010070;stroke-width:1.79743409;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect2445"
- width="290"
- height="55.384613"
- x="150.71428"
- y="383.2413" />
- <text
- xml:space="preserve"
- style="font-size:15.60926819px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="367.98218"
- y="335.77084"
- id="text2447"
- transform="scale(0.805401,1.241618)"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- id="tspan2449"
- x="367.98218"
- y="335.77084">java.util.List</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="230.14285"
- y="253.93361"
- id="text2453"><tspan
- sodipodi:role="line"
- id="tspan2455"
- x="230.14285"
- y="253.93361">(sorted list of events)</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="229.21498"
- y="342.7012"
- id="text2457"><tspan
- sodipodi:role="line"
- id="tspan2459"
- x="229.21498"
- y="342.7012">(sorted list of events)</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="229.35783"
- y="433.41547"
- id="text2461"><tspan
- sodipodi:role="line"
- id="tspan2463"
- x="229.35783"
- y="433.41547">(sorted list of events)</tspan></text>
- <rect
- style="fill:#e9e9ff;fill-opacity:0.59259261;stroke:#010070;stroke-width:1.90017402;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.20987657"
- id="rect3361"
- width="229.60211"
- height="78.179375"
- x="189.8418"
- y="509.98679" />
- <rect
- style="fill:#e9e9ff;fill-opacity:1;stroke:#010070;stroke-width:1.0479157;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect1352"
- width="197.00496"
- height="27.711285"
- x="203.99753"
- y="517.36371" />
- <text
- xml:space="preserve"
- style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="212.14285"
- y="536.21936"
- id="text1348"><tspan
- sodipodi:role="line"
- id="tspan1350"
- x="212.14285"
- y="536.21936">5/1 5/1 5/1 5/3 5/6 5/6 6/1</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="217.85715"
- y="557.64795"
- id="text1354"><tspan
- sodipodi:role="line"
- id="tspan1356"
- x="217.85715"
- y="557.64795">0 1 2 3 4 5 6</tspan></text>
- <g
- id="g1373"
- transform="translate(5,579.6718)">
- <rect
- y="85.438545"
- x="263.61118"
- height="26.928858"
- width="94.916832"
- id="rect2399"
- style="fill:#e9e9ff;fill-opacity:1;stroke:#010070;stroke-width:0.7170344;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- <text
- id="text2401"
- y="102.4744"
- x="280.71246"
- style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- xml:space="preserve"><tspan
- y="102.4744"
- x="280.71246"
- id="tspan2403"
- sodipodi:role="line">DayEditor</tspan></text>
- </g>
- <rect
- style="fill:#e9e9ff;fill-opacity:0.59259261;stroke:#010070;stroke-width:4.54238749;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.20987657"
- id="rect2405"
- width="506.37619"
- height="202.57057"
- x="80.740479"
- y="712.53442" />
- <rect
- style="fill:#e9e9ff;fill-opacity:1;stroke:#010070;stroke-width:0.7170344;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect2253"
- width="94.916832"
- height="26.928858"
- x="142.68445"
- y="729.14099" />
- <text
- xml:space="preserve"
- style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="143.5696"
- y="746.28912"
- id="text2408"><tspan
- sodipodi:role="line"
- id="tspan2410"
- x="143.5696"
- y="746.28912">Count Provider</tspan></text>
- <rect
- style="fill:#e9e9ff;fill-opacity:1;stroke:#010070;stroke-width:0.76857412;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect2262"
- width="109.05227"
- height="26.928858"
- x="390.47388"
- y="727.99817" />
- <text
- xml:space="preserve"
- style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="394.99823"
- y="744.14624"
- id="text2413"><tspan
- sodipodi:role="line"
- id="tspan2415"
- x="394.99823"
- y="744.14624">Content Provider</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:43.58663559px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:0.17901234;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="169.62706"
- y="442.75912"
- id="text2434"
- transform="scale(0.52606,1.900923)"><tspan
- sodipodi:role="line"
- id="tspan2436"
- x="169.62706"
- y="442.75912">EventEditorObservableLazyDataRequestor</tspan></text>
- <g
- id="g2280"
- transform="translate(13.28572,518.2433)">
- <rect
- y="266.04062"
- x="249.68443"
- height="26.928858"
- width="94.916832"
- id="rect2266"
- style="fill:#e9e9ff;fill-opacity:1;stroke:#010070;stroke-width:0.7170344;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- <rect
- y="269.89774"
- x="253.39873"
- height="26.928858"
- width="94.916832"
- id="rect2268"
- style="fill:#e9e9ff;fill-opacity:1;stroke:#010070;stroke-width:0.7170344;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- <rect
- y="274.04059"
- x="258.25589"
- height="26.928858"
- width="94.916832"
- id="rect2270"
- style="fill:#e9e9ff;fill-opacity:1;stroke:#010070;stroke-width:0.7170344;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- <rect
- y="278.18347"
- x="263.25589"
- height="26.928858"
- width="94.916832"
- id="rect2272"
- style="fill:#e9e9ff;fill-opacity:1;stroke:#010070;stroke-width:0.7170344;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- <text
- id="text2276"
- y="294.21933"
- x="270.57144"
- style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- xml:space="preserve"><tspan
- y="294.21933"
- x="270.57144"
- id="tspan2278"
- sodipodi:role="line">Calendarable</tspan></text>
- </g>
- <g
- id="g2294"
- transform="translate(-42.85714,406.1004)">
- <rect
- y="459.61206"
- x="317.54156"
- height="26.928858"
- width="94.916832"
- id="rect2288"
- style="fill:#e9e9ff;fill-opacity:1;stroke:#010070;stroke-width:0.7170344;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- <text
- id="text2290"
- y="476.76013"
- x="318.42673"
- style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- xml:space="preserve"><tspan
- y="476.76013"
- x="318.42673"
- id="tspan2292"
- sodipodi:role="line">Event (domain)</tspan></text>
- </g>
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow2Mend);stroke-opacity:1"
- d="M 314.2974,865.35394 L 292.14287,826.31972"
- id="path2299"
- inkscape:connector-type="polyline"
- inkscape:connection-start="#g2294" />
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow2Mend);stroke-opacity:1"
- d="M 319.71449,865.35394 L 312.85715,826.31972"
- id="path2301"
- inkscape:connector-type="polyline"
- inkscape:connection-start="#g2294" />
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow2Mend);stroke-opacity:1"
- d="M 324.758,865.35394 L 332.14287,826.31972"
- id="path2303"
- inkscape:connector-type="polyline"
- inkscape:connection-start="#g2294" />
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow2Mend);stroke-opacity:1"
- d="M 329.8015,865.35394 L 351.42858,826.31972"
- id="path2305"
- inkscape:connector-type="polyline"
- inkscape:connection-start="#g2294" />
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow2Mend);stroke-opacity:1"
- d="M 288.20681,692.39775 L 197.95594,737.17192"
- id="path2307"
- inkscape:connector-type="polyline"
- inkscape:connection-end="#text1311"
- inkscape:connection-start="#g1373" />
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow2Mend);stroke-opacity:1"
- d="M 344.40894,692.39775 L 416.60783,727.61386"
- id="path2309"
- inkscape:connector-type="polyline"
- inkscape:connection-end="#rect2262"
- inkscape:connection-start="#g1373" />
- <text
- xml:space="preserve"
- style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="238.50069"
- y="582.84406"
- id="text3357"><tspan
- sodipodi:role="line"
- id="tspan3359"
- x="238.50069"
- y="582.84406">(sorted list of events)</tspan></text>
- </g>
-</svg>
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/DayEditorCalendarableItemControl.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/DayEditorCalendarableItemControl.java
deleted file mode 100644
index 373de701..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/DayEditorCalendarableItemControl.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable.day.internal;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem;
-import org.eclipse.jface.util.Policy;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Widget;
-
-/**
- * Represents a graphical item inside a multi-day event editor.
- *
- * @since 3.2
- */
-public class DayEditorCalendarableItemControl extends Canvas implements ICalendarableItemControl {
-
- private static final int MARGIN = 3;
- private Label label = null;
- private Color BORDER_COLOR;
- private Color SELECTED_BORDER_COLOR;
- private Color BACKGROUND_COLOR;
- private Color SELECTED_BACKGROUND_COLOR;
-
- /**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
- public DayEditorCalendarableItemControl(Composite parent, int style) {
- super(parent, style);
- Display display = parent.getDisplay();
-
- BACKGROUND_COLOR = new Color(display, lighten(saturate(display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT).getRGB(), .08f), .3f));
- BORDER_COLOR = new Color(display, lighten(saturate(display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND).getRGB(), .18f), .1f));
- SELECTED_BACKGROUND_COLOR = display.getSystemColor(SWT.COLOR_WHITE);
- SELECTED_BORDER_COLOR = new Color(display, saturate(BORDER_COLOR.getRGB(), .4f));
-
- initialize();
- }
-
- /**
- * Sets the color's saturation to the specified value.
- *
- * @param color The RGB of the color
- * @param saturation the new saturation (between 0 and 1)
- * @return a Color that is saturated by the specified amount
- */
- private RGB saturate(RGB color, float saturation) {
- float[] hsb = color.getHSB();
- return new RGB(hsb[0], saturation, hsb[2]);
- }
-
- /**
- * @param color The RGB of the color
- * @param amount The amount to lighten as a percentage expresssed as a float between -1 and 1.
- * @return The new RGB that is lightened by the specified amount
- */
- private RGB lighten(RGB color, float amount) {
- float[] hsb = color.getHSB();
- float b = hsb[2] + hsb[2] * amount;
- if (b < 0) b=0;
- if (b > 1) b=1;
- return new RGB(hsb[0], hsb[1], b);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#dispose()
- */
- public void dispose() {
- super.dispose();
- BORDER_COLOR.dispose();
- BACKGROUND_COLOR.dispose();
- SELECTED_BORDER_COLOR.dispose();
-// SELECTED_BACKGROUND_COLOR.dispose();
- }
-
- /**
- * Create the event control's layout
- */
- private void initialize() {
- setBackground(BACKGROUND_COLOR);
- label = new Label(this, SWT.WRAP);
- label.setText("Label");
- label.setBackground(BACKGROUND_COLOR);
- FillLayout fillLayout = new FillLayout();
- fillLayout.marginHeight = MARGIN;
- fillLayout.marginWidth = MARGIN;
- setBackground(BORDER_COLOR);
- setLayout(fillLayout);
- addPaintListener(paintListener);
- label.addMouseListener(labelMouseListener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#setMenu(org.eclipse.swt.widgets.Menu)
- */
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#setMenu(org.eclipse.swt.widgets.Menu)
- */
- public void setMenu(Menu menu) {
- super.setMenu(menu);
- label.setMenu(menu);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#setText(java.lang.String)
- */
- public void setText(String text) {
- if (text == null) {
- text = "";
- Exception e = new Exception();
- Policy.getLog().log(
- new Status(IStatus.WARNING, Policy.JFACE, IStatus.ERROR,
- "setText(null) not permitted--changing to empty string", e));
- }
- label.setText(text);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#setImage(org.eclipse.swt.graphics.Image)
- */
- public void setImage(Image image) {
- label.setImage(image);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#setToolTipText(java.lang.String)
- */
- public void setToolTipText(String text) {
- super.setToolTipText(text);
- label.setToolTipText(text);
- }
-
- private int clipping;
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#setClipping(int)
- */
- public void setClipping(int clipping) {
- this.clipping = clipping;
- redraw();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#getClipping()
- */
- public int getClipping() {
- return clipping;
- }
-
- private int continued;
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#setContinued(int)
- */
- public void setContinued(int continued) {
- this.continued = continued;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#getContinued()
- */
- public int getContinued() {
- return continued;
- }
-
- private PaintListener paintListener = new PaintListener() {
- public void paintControl(PaintEvent e) {
- Rectangle bounds = getBounds();
- Color savedForeground = e.gc.getForeground();
- Color savedBackground = e.gc.getBackground();
- if ((continued & SWT.TOP) != 0 && (clipping & SWT.TOP) == 0) {
- e.gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
- e.gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
- } else {
- e.gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY));
- e.gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY));
- }
- if ((clipping & SWT.TOP) != 0 || (continued & SWT.TOP) != 0) {
- for (int arrow = MARGIN; arrow < bounds.width - 2*MARGIN; arrow += 2*MARGIN + 3) {
- int[] arrowPoints = new int[] {arrow, MARGIN-1, arrow + MARGIN, 0, arrow + 2 * MARGIN, MARGIN-1};
- e.gc.fillPolygon(arrowPoints);
- e.gc.drawPolygon(arrowPoints);
- }
- }
- if ((continued & SWT.BOTTOM) != 0 && (clipping & SWT.BOTTOM) == 0) {
- e.gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
- e.gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
- } else {
- e.gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY));
- e.gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY));
- }
- if ((clipping & SWT.BOTTOM) != 0 || (continued & SWT.BOTTOM) != 0) {
- int bottom = bounds.height-1;
- int marginBottom = bounds.height - MARGIN;
- for (int arrow = MARGIN; arrow < bounds.width - 2*MARGIN; arrow += 2*MARGIN + 3) {
- int[] arrowPoints = new int[] {arrow, marginBottom, arrow + MARGIN, bottom, arrow + 2 * MARGIN, marginBottom};
- e.gc.fillPolygon(arrowPoints);
- e.gc.drawPolygon(arrowPoints);
- }
- }
- e.gc.setForeground(savedForeground);
- e.gc.setBackground(savedBackground);
- }
- };
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#setSelected(boolean)
- */
- public void setSelected(boolean selected) {
- if (selected) {
- setBackground(SELECTED_BORDER_COLOR);
- label.setBackground(SELECTED_BACKGROUND_COLOR);
- } else {
- setBackground(BORDER_COLOR);
- label.setBackground(BACKGROUND_COLOR);
- }
- }
-
- private List mouseListeners = new LinkedList();
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#addMouseListener(org.eclipse.swt.events.MouseListener)
- */
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#addMouseListener(org.eclipse.swt.events.MouseListener)
- */
- public void addMouseListener(MouseListener listener) {
- super.addMouseListener(listener);
- mouseListeners.add(listener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#removeMouseListener(org.eclipse.swt.events.MouseListener)
- */
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#removeMouseListener(org.eclipse.swt.events.MouseListener)
- */
- public void removeMouseListener(MouseListener listener) {
- super.removeMouseListener(listener);
- mouseListeners.remove(listener);
- }
-
- private MouseListener labelMouseListener = new MouseListener() {
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent e) {
- e.widget = DayEditorCalendarableItemControl.this;
- for (Iterator listenerIter = mouseListeners.iterator(); listenerIter.hasNext();) {
- MouseListener l = (MouseListener) listenerIter.next();
- l.mouseDoubleClick(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDown(MouseEvent e) {
- e.widget = DayEditorCalendarableItemControl.this;
- for (Iterator listenerIter = mouseListeners.iterator(); listenerIter.hasNext();) {
- MouseListener l = (MouseListener) listenerIter.next();
- l.mouseDown(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseUp(MouseEvent e) {
- e.widget = DayEditorCalendarableItemControl.this;
- for (Iterator listenerIter = mouseListeners.iterator(); listenerIter.hasNext();) {
- MouseListener l = (MouseListener) listenerIter.next();
- l.mouseUp(e);
- }
- }
- };
-
- private CalendarableItem calendarable;
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#setCalendarableItem(org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem)
- */
- public void setCalendarableItem(CalendarableItem calendarable) {
- this.calendarable = calendarable;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#getCalendarableItem()
- */
- public CalendarableItem getCalendarableItem() {
- return calendarable;
- }
-
-} // @jve:decl-index=0:visual-constraint="10,10"
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/EventLayoutComputer.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/EventLayoutComputer.java
deleted file mode 100644
index 2f051013..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/EventLayoutComputer.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jface.examples.databinding.compositetable.day.internal;
-
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor;
-import org.eclipse.swt.graphics.Point;
-
-/**
- * Represents a model of how the events are laid out in a particular day
- *
- * @since 3.2
- */
-public class EventLayoutComputer {
-
- private static final int START = 0;
- private static final int END = 1;
- private final int numberOfDivisionsInHour;
-
- /**
- * Construct a DayModel for an IEventEditor.
- * TODO: We could make numberOfDivisionsInHour a parameter to getEventLayout()
- *
- * @param numberOfDivisionsInHour
- */
- public EventLayoutComputer(int numberOfDivisionsInHour) {
- this.numberOfDivisionsInHour = numberOfDivisionsInHour;
- }
-
- private int computeBaseSlot(GregorianCalendar gc) {
- return gc.get(Calendar.HOUR_OF_DAY) * numberOfDivisionsInHour;
- }
-
- private float computeAdditionalSlots(GregorianCalendar gc) {
- return ((float)gc.get(Calendar.MINUTE)) / 60 * numberOfDivisionsInHour;
- }
-
- private int getSlotForStartTime(Date time) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(time);
- return computeBaseSlot(gc) + ((int) computeAdditionalSlots(gc));
- }
-
- private int getSlotForEndTime(Date time) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(time);
-
- int baseSlot = computeBaseSlot(gc);
- float additionalSlots = computeAdditionalSlots(gc);
-
- return keepExtraTimeIfEndTimePushesIntoNextTimeSlot(baseSlot, additionalSlots);
- }
-
- private int keepExtraTimeIfEndTimePushesIntoNextTimeSlot(int baseSlot, float additionalSlots) {
- if(additionalSlots % (int)additionalSlots > 0) {
- return baseSlot + (int)additionalSlots;
- }
- return baseSlot + (int)additionalSlots-1;
- }
-
- private int[] getSlotsForEvent(CalendarableItem event) {
- int startTime = getSlotForStartTime(event.getStartTime());
- int endTime = getSlotForEndTime(event.getEndTime());
- if (endTime >= startTime) {
- return new int[] {startTime, endTime};
- }
- return new int[] {startTime, startTime};
- }
-
- private class EventLayout {
- private CalendarableItem[][] eventLayout;
- private final int timeSlotsInDay;
-
- public EventLayout(int timeSlotsInDay) {
- this.timeSlotsInDay = timeSlotsInDay;
- eventLayout = new CalendarableItem[1][timeSlotsInDay];
- initializeColumn(0, timeSlotsInDay);
- }
-
- private void initializeColumn(int column, final int timeSlotsInDay) {
- eventLayout[column] = new CalendarableItem[timeSlotsInDay];
- for (int slot = 0; slot < eventLayout[column].length; slot++) {
- eventLayout[column][slot] = null;
- }
- }
-
- public void addColumn() {
- CalendarableItem[][] old = eventLayout;
- eventLayout = new CalendarableItem[old.length+1][timeSlotsInDay];
- for (int i = 0; i < old.length; i++) {
- eventLayout[i] = old[i];
- }
- initializeColumn(eventLayout.length-1, timeSlotsInDay);
- }
-
- public CalendarableItem[][] getLayout() {
- return eventLayout;
- }
-
- public int getNumberOfColumns() {
- return eventLayout.length;
- }
- }
-
- /**
- * Given an unsorted list of Calendarables, each of which has a start and an
- * end time, this method will compute the day row coordinates for each
- * Calendarable, set that information into each Calendarable, and will
- * return the number of columns that will be required to lay out the given
- * list of Calendarables.
- *
- * @param calendarables
- * A list of Calenderables
- * @return The number of columns required to lay out those Calendarables.
- */
- public CalendarableItem[][] computeEventLayout(List calendarables) {
- Collections.sort(calendarables, CalendarableItem.comparator);
-
- final int timeSlotsInDay = IEventEditor.DISPLAYED_HOURS * numberOfDivisionsInHour;
-
- EventLayout eventLayout = new EventLayout(timeSlotsInDay);
-
- // Lay out events
- for (Iterator eventsIter = calendarables.iterator(); eventsIter.hasNext();) {
- CalendarableItem event = (CalendarableItem) eventsIter.next();
- if (event.isAllDayEvent()) continue;
-
- int[] slotsEventSpans = getSlotsForEvent(event);
-
- int eventColumn = findColumnForEvent(eventLayout, slotsEventSpans);
- placeEvent(event, eventLayout.getLayout(), eventColumn, slotsEventSpans);
- }
-
- // Expand them horizontally if possible
- for (Iterator eventsIter = calendarables.iterator(); eventsIter.hasNext();) {
- CalendarableItem event = (CalendarableItem) eventsIter.next();
- if (event.isAllDayEvent()) continue;
-
- int[] slotsEventSpans = getSlotsForEvent(event);
- int eventColumn = findEventColumn(event, eventLayout.getLayout(), slotsEventSpans);
-
- if (eventColumn < eventLayout.getNumberOfColumns()) {
- for (int nextColumn = eventColumn+1; nextColumn < eventLayout.getNumberOfColumns(); ++nextColumn) {
- if (columnIsAvailable(nextColumn, eventLayout.getLayout(), slotsEventSpans)) {
- placeEvent(event, eventLayout.getLayout(), nextColumn, slotsEventSpans);
- } else {
- break;
- }
- }
- }
- }
-
- return eventLayout.getLayout();
- }
-
- private int findEventColumn(CalendarableItem event, CalendarableItem[][] layout, int[] slotsEventSpans) {
- for (int column = 0; column < layout.length; column++) {
- if (layout[column][slotsEventSpans[START]] == event) {
- return column;
- }
- }
- throw new IndexOutOfBoundsException("Could not find event");
- }
-
- private int findColumnForEvent(EventLayout eventLayout, int[] slotsEventSpans) {
- int currentColumn = 0;
- while (true) {
- CalendarableItem[][] layout = eventLayout.getLayout();
- if (columnIsAvailable(currentColumn, layout, slotsEventSpans)) {
- return currentColumn;
- }
- if (isNewColumnNeeded(currentColumn, layout)) {
- eventLayout.addColumn();
- }
- ++currentColumn;
- }
- }
-
- private boolean columnIsAvailable(int column, CalendarableItem[][] layout, int[] slotsEventSpans) {
- int currentSlot = slotsEventSpans[START];
- while (currentSlot <= slotsEventSpans[END]) {
- if (isSlotAlreadyOccupiedInColumn(currentSlot, layout, column)) {
- return false;
- }
- ++currentSlot;
- }
- return true;
- }
-
- private void placeEvent(CalendarableItem event, CalendarableItem[][] eventLayout, int currentColumn, int[] slotsEventSpans) {
- for (int slot = slotsEventSpans[START]; slot <= slotsEventSpans[END]; ++slot) {
- eventLayout[currentColumn][slot] = event;
- Point position = new Point(currentColumn, slot);
- if (event.getUpperLeftPositionInDayRowCoordinates() == null) {
- event.setUpperLeftPositionInDayRowCoordinates(position);
- } else {
- event.setLowerRightPositionInDayRowCoordinates(position);
- }
- }
- }
-
- private boolean isSlotAlreadyOccupiedInColumn(int slot, CalendarableItem[][] layout, int currentColumn) {
- return layout[currentColumn][slot] != null;
- }
-
- private boolean isNewColumnNeeded(int currentColumn, CalendarableItem[][] layout) {
- return currentColumn >= layout.length-1;
- }
-}
-
-
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/ICalendarableItemControl.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/ICalendarableItemControl.java
deleted file mode 100644
index fe941ecb..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/ICalendarableItemControl.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable.day.internal;
-
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Menu;
-
-/**
- * @since 3.2
- *
- */
-public interface ICalendarableItemControl {
-
- /* (non-Javadoc)
- * {@link org.eclipse.swt.widgets.Widget#dispose()}
- */
- public void dispose();
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#setMenu(org.eclipse.swt.widgets.Menu)
- */
- public void setMenu(Menu menu);
-
- /**
- * @param text
- */
- public void setText(String text);
-
- /**
- * @param image
- */
- public void setImage(Image image);
-
- public void setToolTipText(String text);
-
- /**
- * Sets the clipping style bits
- * @param clipping One of SWT.TOP or SWT.BOTTOM
- */
- public void setClipping(int clipping);
-
- /**
- * @return The clipping style bits
- */
- public int getClipping();
-
- /**
- * Sets the continued style bits
- * @param continued One of SWT.TOP or SWT.BOTTOM
- */
- public void setContinued(int continued);
-
- /**
- * @return the continued style bits
- */
- public int getContinued();
-
- /**
- * Set or clear the selection indicator in the UI.
- *
- * @param selected true if this control should appear selected; false otherwise.
- */
- public void setSelected(boolean selected);
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#addMouseListener(org.eclipse.swt.events.MouseListener)
- */
- public void addMouseListener(MouseListener listener);
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#removeMouseListener(org.eclipse.swt.events.MouseListener)
- */
- public void removeMouseListener(MouseListener listener);
-
- /**
- * Method setCalendarable. Sets the associated model.
- * @param calendarable
- */
- public void setCalendarableItem(CalendarableItem calendarable);
-
- /**
- * @return Returns the calendarable.
- */
- public CalendarableItem getCalendarableItem();
-
-} \ No newline at end of file
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/TimeSlice.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/TimeSlice.java
deleted file mode 100644
index 3f010277..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/TimeSlice.java
+++ /dev/null
@@ -1,375 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jface.examples.databinding.compositetable.day.internal;
-
-import java.text.DateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.LinkedList;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Widget;
-
-/**
- * Represents a time slice that is the same time but may span several days.
- * For example: 11:00 - 11:15 PM from Sunday through Saturday.
- *
- * @since 3.2
- */
-public class TimeSlice extends Composite {
-
- private final Image allDayImage = new Image(Display.getCurrent(), TimeSlice.class.getResourceAsStream("clock.png"));
-
- /**
- * The 0th control in the layout may have a java.lang.Integer LayoutData
- * indicating its preferred width. Otherwise, DaysLayout will ask the
- * control to compute its preferred size and will use the width returned by
- * that computation. All other controls will be equally allotted horizontal
- * width in the parent control.
- */
- private static class TimeSliceAcrossTimeLayout extends Layout {
- Point preferredSize = new Point(-1, -1);
-
- protected Point computeSize(Composite composite, int wHint, int hHint,
- boolean flushCache) {
- if (preferredSize.x == -1 || flushCache) {
- preferredSize.x = wHint;
- preferredSize.y = -1; // NOTE: This assumes at least one child
- // control
- Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; i++) {
- Control child = children[i];
- preferredSize.y = Math.max(preferredSize.y, child
- .computeSize(SWT.DEFAULT, SWT.DEFAULT, true).y);
- }
- }
- return preferredSize;
- }
-
- protected void layout(Composite composite, boolean flushCache) {
- Point parentSize = composite.getSize();
- Control[] children = composite.getChildren();
-
- // layout 0th control
- Integer preferredWidth = (Integer) children[0].getLayoutData();
- if (preferredWidth == null) {
- preferredWidth = new Integer(children[0].computeSize(
- SWT.DEFAULT, SWT.DEFAULT).x);
- }
- children[0].setBounds(0, 0, preferredWidth.intValue(), parentSize.y);
-
- // layout the rest of the controls
- int controlWidth = 0;
- int extraWidth = 0;
- if (children.length >= 2) {
- controlWidth = (parentSize.x - preferredWidth.intValue())
- / (children.length - 1);
- extraWidth = (parentSize.x - preferredWidth.intValue())
- % (children.length - 1);
- }
- int leftPosition = preferredWidth.intValue();
-
- for (int i = 1; i < children.length; i++) {
- Control control = children[i];
- int width = controlWidth;
- if (extraWidth > 0) {
- ++width;
- --extraWidth;
- }
- control.setBounds(leftPosition, 0, width, parentSize.y);
- leftPosition += width;
- }
- }
- }
-
- private CLabel timeLabel = null;
-
- private LinkedList columns = new LinkedList();
-
- /**
- * @return Returns the columns.
- */
- public LinkedList getColumns() {
- return columns;
- }
-
- /**
- * Returns the control that implements the specified column.
- *
- * @param column The column number.
- * @return Control the SWT control that implements this column.
- */
- public Control getColumnControl(int column) {
- return (Control) columns.get(column);
- }
-
- /**
- * Return the column number of the specified widget.
- *
- * @param widget the TimeSlot widget
- * @return the column number of the specified TimeSlot within this TimeSlice.
- */
- public int getControlColumn(Widget widget) {
- int columnNumber = 0;
- for (Iterator columnsIter = columns.iterator(); columnsIter.hasNext();) {
- if (columnsIter.next() == widget) {
- return columnNumber;
- }
- ++columnNumber;
- }
- throw new IllegalArgumentException("Unrecognized widget passed to getControlColumn");
- }
-
- /**
- * Constructor TimeSlice. Construct a TimeSlice control, passing the parent
- * and style bits.
- *
- * @param parent
- * The SWT parent object.
- * @param style
- * The set of style bits this control accepts. Currently SWT.NONE.
- */
- public TimeSlice(Composite parent, int style) {
- super(parent, SWT.NULL);
- initialize();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#setMenu(org.eclipse.swt.widgets.Menu)
- */
- public void setMenu(Menu menu) {
- super.setMenu(menu);
- for (Iterator columnsIter = columns.iterator(); columnsIter.hasNext();) {
- TimeSlot cell = (TimeSlot) columnsIter.next();
- cell.setMenu(menu);
- }
- }
-
- /**
- * Initialize the control
- */
- private void initialize() {
- timeLabel = new CLabel(this, SWT.RIGHT);
- timeLabel.setText("23:00 PM");
- Integer preferredWidth = new Integer(timeLabel.computeSize(SWT.DEFAULT,
- SWT.DEFAULT, false).x + 5);
- timeLabel.setLayoutData(preferredWidth);
- timeLabel.setText("");
- setBackground(Display.getCurrent().getSystemColor(
- SWT.COLOR_WIDGET_BACKGROUND));
- setSize(new Point(537, 16));
- setLayout(new TimeSliceAcrossTimeLayout());
- }
-
- private boolean headerControl = false;
-
- /**
- * @return Returns the headerControl.
- */
- public boolean isHeaderControl() {
- return headerControl;
- }
-
- /**
- * @param headerControl The headerControl to set.
- */
- public void setHeaderControl(boolean headerControl) {
- this.headerControl = headerControl;
- }
-
- private int numberOfColumns = 1;
-
- /**
- * Gets the number of columns that will be displayed in this row. The
- * default number of columns is 1.
- *
- * @return numberOfColumns The number of days to display.
- */
- public int getNumberOfColumns() {
- return numberOfColumns;
- }
-
- /**
- * Sets the number of columns that will be displayed in this row. The
- * default number of columns is 1. This method may only be called *once* at
- * the beginning of the control's life cycle, and the value passed must be
- * >1.
- * <p>
- * Calling this method more than once results in undefined behavior.
- *
- * @param numberOfColumns
- * The number of days to display.
- */
- public void setNumberOfColumns(int numberOfColumns) {
- this.numberOfColumns = numberOfColumns;
- Control[] tabStops = new Control[numberOfColumns];
- for (int i = numberOfColumns; i > 0; --i) {
- if (headerControl) {
- CLabel control = new CLabel(this, SWT.SHADOW_OUT | SWT.BORDER | SWT.CENTER);
- tabStops[numberOfColumns-i] = control;
- columns.add(control);
- } else {
- TimeSlot control = new TimeSlot(this, SWT.NONE);
- tabStops[numberOfColumns-i] = control;
- columns.add(control);
- }
- }
- setTabList(tabStops);
- }
-
- private Date currentTime = new Date();
-
- /**
- * @return The current time set in this "days" row.
- */
- public Date getCurrentTime() {
- return currentTime;
- }
-
- /**
- * @param currentTime
- */
- public void setCurrentTime(Date currentTime) {
- // if currentTime is null, we are becoming an all-day event row
- if (currentTime == null) {
- timeLabel.setImage(allDayImage);
- timeLabel.setText("");
- setAllDayEventOnDays(true);
- return;
- }
-
- setAllDayEventOnDays(false);
- timeLabel.setImage(null);
-
- setTimeOnDays(currentTime);
-
- this.currentTime = currentTime;
- Calendar calendar = new GregorianCalendar();
- calendar.setTime(currentTime);
-
- // Only the hours will display in the label
- if (calendar.get(Calendar.MINUTE) == 0) {
- DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
- String time = df.format(currentTime);
- timeLabel.setText(time);
- } else {
- timeLabel.setText("");
- }
- }
-
- private void setTimeOnDays(Date currentTime) {
- for (Iterator daysIter = columns.iterator(); daysIter.hasNext();) {
- Object dayCandidate = daysIter.next();
- if (dayCandidate instanceof TimeSlot) {
- TimeSlot day = (TimeSlot) dayCandidate;
- day.setTime(currentTime);
- }
- }
- }
-
- private void setAllDayEventOnDays(boolean isAllDayEvent) {
- for (Iterator daysIter = columns.iterator(); daysIter.hasNext();) {
- Object dayCandidate = daysIter.next();
- if (dayCandidate instanceof TimeSlot) {
- TimeSlot day = (TimeSlot) dayCandidate;
- day.setAllDay(isAllDayEvent);
- }
- }
- }
-
- /**
- * @see org.eclipse.swt.widgets.Control#addFocusListener
- *
- * @param listener
- */
- public void addCellFocusListener(FocusListener listener) {
- for (Iterator daysIter = columns.iterator(); daysIter.hasNext();) {
- Object dayCandidate = daysIter.next();
- if (dayCandidate instanceof TimeSlot) {
- TimeSlot day = (TimeSlot) dayCandidate;
- day.addFocusListener(listener);
- }
- }
- }
-
- /**
- * @see org.eclipse.swt.widgets.Control#removeFocusListener
- * @param listener
- */
- public void removeCellFocusListener(FocusListener listener) {
- for (Iterator daysIter = columns.iterator(); daysIter.hasNext();) {
- Object dayCandidate = daysIter.next();
- if (dayCandidate instanceof TimeSlot) {
- TimeSlot day = (TimeSlot) dayCandidate;
- day.removeFocusListener(listener);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#addKeyListener(org.eclipse.swt.events.KeyListener)
- */
- public void addKeyListener(KeyListener listener) {
- super.addKeyListener(listener);
- for (Iterator columnsIter = columns.iterator(); columnsIter.hasNext();) {
- TimeSlot cell = (TimeSlot) columnsIter.next();
- cell.addKeyListener(listener);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#removeKeyListener(org.eclipse.swt.events.KeyListener)
- */
- public void removeKeyListener(KeyListener listener) {
- super.removeKeyListener(listener);
- for (Iterator columnsIter = columns.iterator(); columnsIter.hasNext();) {
- TimeSlot cell = (TimeSlot) columnsIter.next();
- cell.removeKeyListener(listener);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#addKeyListener(org.eclipse.swt.events.KeyListener)
- */
- public void addMouseListener(MouseListener listener) {
- super.addMouseListener(listener);
- for (Iterator columnsIter = columns.iterator(); columnsIter.hasNext();) {
- TimeSlot cell = (TimeSlot) columnsIter.next();
- cell.addMouseListener(listener);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#removeKeyListener(org.eclipse.swt.events.KeyListener)
- */
- public void removeMouseListener(MouseListener listener) {
- super.removeMouseListener(listener);
- for (Iterator columnsIter = columns.iterator(); columnsIter.hasNext();) {
- TimeSlot cell = (TimeSlot) columnsIter.next();
- cell.removeMouseListener(listener);
- }
- }
-
-} // @jve:decl-index=0:visual-constraint="10,10"
-
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/TimeSlot.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/TimeSlot.java
deleted file mode 100644
index 98eb35e6..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/TimeSlot.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jface.examples.databinding.compositetable.day.internal;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontMetrics;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * Represents a particular range in time in a single day.
- *
- * @since 3.2
- */
-public class TimeSlot extends Canvas {
-
- private static final int FOCUS_LINE_WIDTH = 2;
-
- private boolean focusControl = false;
-
- private final Color WHITE;
- private final Color CELL_BACKGROUND_LIGHT;
- private final Color CELL_BACKGROUND_WHITE;
- private final Color CELL_BORDER_EMPHASIZED;
- private final Color CELL_BORDER_LIGHT;
- private final Color TIME_BAR_COLOR;
- private final Color FOCUS_RUBBERBAND;
-
- /**
- * Width of the bar between events
- */
- public static final int TIME_BAR_WIDTH = 3;
-
- /**
- * Constructor EmptyTablePlaceholder. Construct an EmptyTablePlaceholder
- * control.
- *
- * @param parent
- * The parent control
- * @param style
- * Style bits. These are the same as what Canvas accepts.
- */
- public TimeSlot(Composite parent, int style) {
- super(parent, style);
-
- addTraverseListener(traverseListener);
- addFocusListener(focusListener);
- addPaintListener(paintListener);
- addDisposeListener(disposeListener);
- addKeyListener(keyListener);
- addMouseListener(mouseListener);
-
- Display display = Display.getCurrent();
-
- WHITE = display.getSystemColor(SWT.COLOR_WHITE);
-
- CELL_BACKGROUND_WHITE = display.getSystemColor(SWT.COLOR_WHITE);
- CELL_BORDER_EMPHASIZED = display.getSystemColor(SWT.COLOR_LIST_SELECTION);
- CELL_BACKGROUND_LIGHT = new Color(display, new RGB(248, 248, 248));
- CELL_BORDER_LIGHT = new Color(display, saturate(CELL_BORDER_EMPHASIZED.getRGB(), .2f));
- TIME_BAR_COLOR = new Color(display, saturate(CELL_BORDER_EMPHASIZED.getRGB(), .1f));
- FOCUS_RUBBERBAND = new Color(display, lighten(saturate(display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND).getRGB(), .85f), -.333f));
-
- setBackground(CELL_BACKGROUND_LIGHT);
- }
-
- /**
- * Sets the color's saturation to the specified value.
- *
- * @param color The RGB of the color
- * @param saturation the new saturation (between 0 and 1)
- * @return a Color that is saturated by the specified amount
- */
- private RGB saturate(RGB color, float saturation) {
- float[] hsb = color.getHSB();
- return new RGB(hsb[0], saturation, hsb[2]);
- }
-
- /**
- * @param color The RGB of the color
- * @param amount The amount to lighten as a percentage expresssed as a float between -1 and 1.
- * @return The new RGB that is lightened by the specified amount
- */
- private RGB lighten(RGB color, float amount) {
- float[] hsb = color.getHSB();
- float b = hsb[2] + hsb[2] * amount;
- if (b < 0) b=0;
- if (b > 1) b=1;
- return new RGB(hsb[0], hsb[1], b);
- }
-
-
- /**
- * Make sure we remove our listeners...
- */
- private DisposeListener disposeListener = new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- removeTraverseListener(traverseListener);
- removeFocusListener(focusListener);
- removePaintListener(paintListener);
- removeMouseListener(mouseListener);
- removeKeyListener(keyListener);
- removeDisposeListener(disposeListener);
-
- // Dispose colors here
- CELL_BACKGROUND_LIGHT.dispose();
- CELL_BORDER_LIGHT.dispose();
- TIME_BAR_COLOR.dispose();
- FOCUS_RUBBERBAND.dispose();
- }
- };
-
- private KeyListener keyListener = new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- switch (e.keyCode) {
- case SWT.ARROW_LEFT:
- traverse(SWT.TRAVERSE_TAB_PREVIOUS);
- return;
- case SWT.ARROW_RIGHT:
- traverse(SWT.TRAVERSE_TAB_NEXT);
- return;
- }
- }
- };
-
- private Point preferredSize = new Point(-1, -1);
-
- public Point computeSize(int wHint, int hHint, boolean changed) {
- if (preferredSize.x == -1 || changed) {
- preferredSize.x = getSize().x;
- Display display = Display.getCurrent();
- GC gc = new GC(display);
- try {
- Font font = display.getSystemFont();
- gc.setFont(font);
- FontMetrics fm = gc.getFontMetrics();
- preferredSize.y = fm.getHeight();
- } finally {
- gc.dispose();
- }
- }
- return preferredSize;
- }
-
- /**
- * Paint the control.
- */
- private PaintListener paintListener = new PaintListener() {
- public void paintControl(PaintEvent e) {
- GC gc = e.gc;
- Color oldForeground = gc.getForeground();
- Color oldBackground = gc.getBackground();
- Point controlSize = getSize();
-
- // Draw basic background here
- try {
- // Draw "time bar" on left side
- gc.setBackground(WHITE);
- gc.setForeground(WHITE);
- gc.fillRectangle(0, 0, TIME_BAR_WIDTH, controlSize.y);
- gc.setForeground(CELL_BORDER_LIGHT);
- int lineStyle = gc.getLineStyle();
- gc.setLineStyle(SWT.LINE_DOT);
- gc.drawLine(TIME_BAR_WIDTH + 1, 0, TIME_BAR_WIDTH + 1,
- controlSize.y);
- gc.setLineStyle(lineStyle);
- gc.setForeground(TIME_BAR_COLOR);
- gc.drawLine(controlSize.x - 1, 0, controlSize.x - 1,
- controlSize.y);
- if (isMinutesAfterHour(0)) {
- gc.setForeground(CELL_BORDER_EMPHASIZED);
- } else {
- gc.setForeground(CELL_BORDER_LIGHT);
- }
-// gc.drawLine(TIME_BAR_WIDTH + 2, 0, controlSize.x - 2, 0);
- if (isMinutesAfterHour(0) || isMinutesAfterHour(30) && !isAllDay()) {
- gc.drawLine(0, 0, controlSize.x, 0);
- }
- } finally {
- gc.setBackground(oldBackground);
- gc.setForeground(oldForeground);
- }
-
- // Draw focus rubberband if we're focused
- int oldLineStyle = gc.getLineStyle();
- int oldLineWidth = gc.getLineWidth();
- try {
- if (focusControl) {
- gc.setLineStyle(SWT.LINE_DASH);
- gc.setLineWidth(FOCUS_LINE_WIDTH);
- gc.setForeground(FOCUS_RUBBERBAND);
- Point parentSize = getSize();
- gc.drawRectangle(FOCUS_LINE_WIDTH,
- FOCUS_LINE_WIDTH, parentSize.x - 4,
- parentSize.y - 3);
- }
-
- gc.setForeground(CELL_BACKGROUND_LIGHT);
- } finally {
- gc.setForeground(oldForeground);
- gc.setLineStyle(oldLineStyle);
- gc.setLineWidth(oldLineWidth);
- }
- }
- };
-
- /**
- * When we gain/lose focus, redraw ourselves appropriately
- */
- private FocusListener focusListener = new FocusListener() {
- public void focusGained(FocusEvent e) {
- focusControl = true;
- redraw();
- }
-
- public void focusLost(FocusEvent e) {
- focusControl = false;
- redraw();
- }
- };
-
- /**
- * Permit focus events via keyboard.
- */
- private TraverseListener traverseListener = new TraverseListener() {
- public void keyTraversed(TraverseEvent e) {
- // NOOP: this just lets us receive focus from SWT
- }
- };
-
- private MouseListener mouseListener = new MouseAdapter() {
- public void mouseDown(MouseEvent e) {
- setFocus();
- }
- };
-
- /**
- * @param minute The minute to check
- *
- * @return true if the time falls on the specified minute of the hour.
- * false otherwise.
- */
- public boolean isMinutesAfterHour(int minute) {
- Calendar calendar = new GregorianCalendar();
- calendar.setTime(time);
- return calendar.get(Calendar.MINUTE) == minute;
- }
-
- private boolean allDay = false;
-
- /**
- * @param isAllDayEvent
- */
- public void setAllDay(boolean isAllDayEvent) {
- this.allDay = isAllDayEvent;
- if (isAllDayEvent) {
- setBackground(CELL_BACKGROUND_WHITE);
- } else {
- setBackground(CELL_BACKGROUND_LIGHT);
- }
- }
-
- /**
- * @return Returns the allDay.
- */
- public boolean isAllDay() {
- return allDay;
- }
-
- private Date time = new Date();
-
- /**
- * @param currentTime
- */
- public void setTime(Date currentTime) {
- this.time = currentTime;
- redraw();
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/clock.png b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/clock.png
deleted file mode 100644
index d43f6cad..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/clock.png
+++ /dev/null
Binary files differ
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/clock.svg b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/clock.svg
deleted file mode 100644
index 557cbdee..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/day/internal/clock.svg
+++ /dev/null
@@ -1,276 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://web.resource.org/cc/"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="744.09448819"
- height="1052.3622047"
- id="svg2"
- sodipodi:version="0.32"
- inkscape:version="0.43"
- sodipodi:docbase="C:\Documents and Settings\dorme"
- sodipodi:docname="clock.svg">
- <defs
- id="defs4">
- <marker
- inkscape:stockid="Arrow1Send"
- orient="auto"
- refY="0.0"
- refX="0.0"
- id="Arrow1Send"
- style="overflow:visible;">
- <path
- id="path2364"
- d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
- style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;"
- transform="scale(0.2) rotate(180)" />
- </marker>
- <linearGradient
- id="linearGradient2452">
- <stop
- style="stop-color:#ffffff;stop-opacity:1;"
- offset="0"
- id="stop2454" />
- <stop
- style="stop-color:#7373ee;stop-opacity:1;"
- offset="1"
- id="stop2456" />
- </linearGradient>
- <marker
- inkscape:stockid="Arrow1Mend"
- orient="auto"
- refY="0.0"
- refX="0.0"
- id="Arrow1Mend"
- style="overflow:visible;">
- <path
- id="path2370"
- d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
- style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;"
- transform="scale(0.4) rotate(180)" />
- </marker>
- <marker
- inkscape:stockid="Arrow1Lend"
- orient="auto"
- refY="0.0"
- refX="0.0"
- id="Arrow1Lend"
- style="overflow:visible;">
- <path
- id="path2376"
- d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
- style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;"
- transform="scale(0.8) rotate(180)" />
- </marker>
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient2452"
- id="linearGradient2458"
- x1="131.28571"
- y1="372.36218"
- x2="560.85712"
- y2="667.36218"
- gradientUnits="userSpaceOnUse" />
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient2452"
- id="linearGradient2485"
- gradientUnits="userSpaceOnUse"
- x1="131.28571"
- y1="372.36218"
- x2="560.85712"
- y2="667.36218" />
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient2452"
- id="linearGradient2519"
- gradientUnits="userSpaceOnUse"
- x1="131.28571"
- y1="372.36218"
- x2="560.85712"
- y2="667.36218" />
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient2452"
- id="linearGradient2521"
- gradientUnits="userSpaceOnUse"
- x1="131.28571"
- y1="372.36218"
- x2="560.85712"
- y2="667.36218" />
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient2452"
- id="linearGradient2555"
- gradientUnits="userSpaceOnUse"
- x1="131.28571"
- y1="372.36218"
- x2="560.85712"
- y2="667.36218" />
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient2452"
- id="linearGradient2557"
- gradientUnits="userSpaceOnUse"
- x1="131.28571"
- y1="372.36218"
- x2="560.85712"
- y2="667.36218" />
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient2452"
- id="linearGradient2593"
- gradientUnits="userSpaceOnUse"
- x1="131.28571"
- y1="372.36218"
- x2="560.85712"
- y2="667.36218" />
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient2452"
- id="linearGradient2614"
- gradientUnits="userSpaceOnUse"
- x1="131.28571"
- y1="372.36218"
- x2="560.85712"
- y2="667.36218" />
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient2452"
- id="linearGradient2648"
- gradientUnits="userSpaceOnUse"
- x1="131.28571"
- y1="372.36218"
- x2="560.85712"
- y2="667.36218" />
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient2452"
- id="linearGradient2666"
- gradientUnits="userSpaceOnUse"
- x1="131.28571"
- y1="372.36218"
- x2="560.85712"
- y2="667.36218" />
- </defs>
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="1.4"
- inkscape:cx="409.08296"
- inkscape:cy="647.0534"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- inkscape:window-width="1383"
- inkscape:window-height="1276"
- inkscape:window-x="50"
- inkscape:window-y="58" />
- <metadata
- id="metadata7">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1">
- <g
- id="g2460"
- transform="translate(3.571429,-4.285714)">
- <path
- transform="translate(7.78572,-203.5715)"
- d="M 612.14285 513.79077 A 257.85715 257.14285 0 1 1 96.428558,513.79077 A 257.85715 257.14285 0 1 1 612.14285 513.79077 z"
- sodipodi:ry="257.14285"
- sodipodi:rx="257.85715"
- sodipodi:cy="513.79077"
- sodipodi:cx="354.28571"
- id="path1307"
- style="fill:url(#linearGradient2666);fill-opacity:1;stroke:#030084;stroke-width:6;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- sodipodi:type="arc" />
- <path
- id="path2182"
- d="M 362.07143,70.21925 L 362.07143,148.79068"
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#030084;stroke-width:6;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <path
- id="path2184"
- d="M 362.07143,462.36211 L 362.07143,540.93354"
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#030084;stroke-width:6;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <path
- id="path2192"
- d="M 597.42859,310.21924 L 518.85716,310.21924"
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#030084;stroke-width:6;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <path
- id="path2194"
- d="M 205.28573,310.21924 L 126.7143,310.21924"
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#030084;stroke-width:6;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <path
- sodipodi:nodetypes="cc"
- id="path2204"
- d="M 362.14286,313.79068 L 436.42857,153.0764"
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:8;stroke-linecap:round;stroke-linejoin:miter;marker-end:url(#Arrow1Mend);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <path
- sodipodi:nodetypes="cc"
- id="path2386"
- d="M 362.84711,313.15934 L 362.13282,411.73077"
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:8;stroke-linecap:round;stroke-linejoin:miter;marker-end:url(#Arrow1Mend);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- </g>
- <g
- id="g2657"
- inkscape:export-filename="C:\Documents and Settings\dorme\clock.png"
- inkscape:export-xdpi="9.6499996"
- inkscape:export-ydpi="9.6499996">
- <path
- transform="matrix(0.224029,4.215227e-2,0,0.27196,357.7523,565.618)"
- d="M 612.14285 513.79077 A 257.85715 257.14285 0 1 1 96.428558,513.79077 A 257.85715 257.14285 0 1 1 612.14285 513.79077 z"
- sodipodi:ry="257.14285"
- sodipodi:rx="257.85715"
- sodipodi:cy="513.79077"
- sodipodi:cx="354.28571"
- id="path2634"
- style="fill:url(#linearGradient2648);fill-opacity:1;stroke:#010070;stroke-width:22.98158073;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- sodipodi:type="arc" />
- <path
- id="path2636"
- d="M 437.12272,655.01196 L 437.12272,676.38022"
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#030084;stroke-width:3.24150491;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <path
- id="path2638"
- d="M 437.12272,761.659 L 437.12272,783.02726"
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#030084;stroke-width:3.24150491;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <path
- id="path2640"
- d="M 489.84966,730.20312 L 472.24735,726.89114"
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#030084;stroke-width:3.24150491;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <path
- id="path2642"
- d="M 401.9981,713.6734 L 384.39578,710.36144"
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#030084;stroke-width:3.24150491;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <path
- sodipodi:nodetypes="cc"
- id="path2644"
- d="M 437.13872,721.25657 L 468.10597,686.27961"
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <path
- sodipodi:nodetypes="cc"
- id="path2646"
- d="M 437.29649,721.11456 L 437.13647,754.72911"
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:10;stroke-linecap:round;stroke-linejoin:miter;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- </g>
- </g>
-</svg>
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/internal/EmptyTablePlaceholder.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/internal/EmptyTablePlaceholder.java
deleted file mode 100644
index b95200cf..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/internal/EmptyTablePlaceholder.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright (C) 2005 David Orme <djo@coconut-palm-software.com>
- *
- * 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:
- * David Orme - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.compositetable.internal;
-
-import org.eclipse.jface.examples.databinding.compositetable.InternalCompositeTable;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * Class EmptyTablePlaceholder. An SWT control that is displayed in the table when
- * there are no rows to display. It has four purposes:
- *
- * <ul>
- * <li>Prompt the user to hit <INS> to insert a new (first) row.
- * <li>Indicate if the table has focus using a dashed line around the outside.
- * <li>Actually accept focus for the table when there are no other controls to do so.
- * <li>Forward the insert key event back to the table when the user needs to insert a row.
- * </ul>
- *
- * @author djo
- */
-public class EmptyTablePlaceholder extends Canvas {
-
- private boolean focusControl = false;
- private InternalCompositeTable parentTable = null;
-
- private final Color RED;
-
- /**
- * Constructor EmptyTablePlaceholder. Construct an EmptyTablePlaceholder control.
- *
- * @param parent The parent control
- * @param style Style bits. These are the same as what Canvas accepts.
- */
- public EmptyTablePlaceholder(Composite parent, int style) {
- super(parent, style);
- parentTable = (InternalCompositeTable) parent.getParent().getParent();
-
- parent.addControlListener(controlListener);
-
- addTraverseListener(traverseListener);
- addFocusListener(focusListener);
- addKeyListener(keyListener);
- addPaintListener(paintListener);
- addDisposeListener(disposeListener);
-
- RED = Display.getCurrent().getSystemColor(SWT.COLOR_RED);
- setBackground(getParent().getBackground());
-
- resize();
- }
-
- /**
- * Make sure we remove our listeners...
- */
- private DisposeListener disposeListener = new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- removeTraverseListener(traverseListener);
- removeFocusListener(focusListener);
- removeKeyListener(keyListener);
- removePaintListener(paintListener);
- removeDisposeListener(disposeListener);
-
- getParent().removeControlListener(controlListener);
- }
- };
-
- /**
- * Handle resize events so we can redraw ourselves correctly.
- */
- private ControlListener controlListener = new ControlAdapter() {
- public void controlResized(ControlEvent e) {
- resize();
- }
- };
-
- /**
- * Actually resize ourself.
- */
- private void resize() {
- Point headerSize = new Point(0, 0);
- Control header = parentTable.getHeaderControl();
- if (header != null) {
- headerSize = header.getSize();
- }
- Point parentSize = getParent().getSize();
-
- setBounds(0, headerSize.y+2, parentSize.x-4, parentSize.y - headerSize.y-6);
- }
-
-
- // The message property
- private String message = ""; //$NON-NLS-1$
-
- /**
- * Return the prompt message that will be displayed to the user inside this control.
- *
- * @return The message string.
- */
- public String getMessage() {
- return message;
- }
-
- /**
- * Set the prompt message that will be displayed to the user inside this control.
- *
- * @param message The message to display.
- */
- public void setMessage(String message) {
- this.message = message;
- redraw();
- }
-
- /**
- * Paint the control.
- */
- private PaintListener paintListener = new PaintListener() {
- public void paintControl(PaintEvent e) {
- Color oldColor = e.gc.getForeground();
- int oldLineStyle = e.gc.getLineStyle();
- int oldLineWidth = e.gc.getLineWidth();
- try {
- if (focusControl) {
- e.gc.setLineStyle(SWT.LINE_DASH);
- e.gc.setLineWidth(2);
- Point parentSize = getSize();
- e.gc.drawRectangle(1, 2, parentSize.x-2, parentSize.y-3);
- }
-
- e.gc.setForeground(RED);
- e.gc.drawText(getMessage(), 3, 3);
- } finally {
- e.gc.setForeground(oldColor);
- e.gc.setLineStyle(oldLineStyle);
- e.gc.setLineWidth(oldLineWidth);
- }
- }
- };
-
- /**
- * When we gain/lose focus, redraw ourselves appropriately
- */
- private FocusListener focusListener = new FocusListener() {
- public void focusGained(FocusEvent e) {
- focusControl = true;
- redraw();
- }
- public void focusLost(FocusEvent e) {
- focusControl = false;
- redraw();
- }
- };
-
- /**
- * Permit focus events via keyboard.
- */
- private TraverseListener traverseListener = new TraverseListener() {
- public void keyTraversed(TraverseEvent e) {
- }
- };
-
- /**
- * Forward the insert key back to our parent for handling.
- */
- private KeyListener keyListener = new KeyListener() {
- public void keyPressed(KeyEvent e) {
- if (e.keyCode == SWT.INSERT)
- parentTable.keyPressed(null, e);
- }
- public void keyReleased(KeyEvent e) {
- }
- };
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/internal/ISelectableRegionControl.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/internal/ISelectableRegionControl.java
deleted file mode 100644
index f3b58e35..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/internal/ISelectableRegionControl.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2005 David Orme <djo@coconut-palm-software.com>
- *
- * 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:
- * David Orme - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.compositetable.internal;
-
-import org.eclipse.swt.SWTException;
-
-/**
- * A duck interface for controls that can select a specific range according to SWT
- * range selection semantics.
- *
- * @author djo
- */
-public interface ISelectableRegionControl {
- /**
- * Sets the selection to the range specified
- * by the given start and end indices.
- * <p>
- * Indexing is zero based. The range of
- * a selection is from 0..N where N is
- * the number of characters in the widget.
- * </p><p>
- * Text selections are specified in terms of
- * caret positions. In a text widget that
- * contains N characters, there are N+1 caret
- * positions, ranging from 0..N. This differs
- * from other functions that address character
- * position such as getText () that use the
- * usual array indexing rules.
- * </p>
- *
- * @param start the start of the range
- * @param end the end of the range
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
- public void setSelection (int start, int end);
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/internal/TableRow.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/internal/TableRow.java
deleted file mode 100644
index 197f40c4..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/internal/TableRow.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Copyright (C) 2005 David Orme <djo@coconut-palm-software.com>
- *
- * 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:
- * David Orme - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.compositetable.internal;
-
-import org.eclipse.jface.examples.databinding.compositetable.InternalCompositeTable;
-import org.eclipse.swt.events.FocusAdapter;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyAdapter;
-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.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * Class TableRow. Encapsulates operations on a SWT row control. Discovers the
- * SWT controls inside the row control representing columns and exposes those for
- * operations by the CompositeTable. Listens to SWT events on the column controls
- * and forwards them back to the table control for processing.
- *
- * @author djo
- */
-public class TableRow {
- private Control row;
- private Control[] columns;
- protected InternalCompositeTable parent;
-
- /**
- * Constructor TableRow. Construct a TableRow object.
- *
- * @param parent The table containing this row.
- * @param row The SWT control implementing this row.
- */
- public TableRow(InternalCompositeTable parent, Control row) {
- this.parent = parent;
- this.row = row;
- if (row instanceof Composite) {
- Composite rowComposite = (Composite) row;
- columns = rowComposite.getTabList();
- } else {
- columns = new Control[] {row};
- }
-
- addListeners(row);
- for (int i = 0; i < columns.length; i++) {
- addListeners(columns[i]);
- }
- }
-
- /**
- * Remove all listeners from each control.
- */
- public void dispose() {
- removeListeners(row);
- for (int i = 0; i < columns.length; i++) {
- removeListeners(columns[i]);
- }
- }
-
- /**
- * Add listeners to each control.
- *
- * @param control The control to listen to.
- */
- private void addListeners(Control control) {
- control.addKeyListener(keyListener);
- control.addFocusListener(focusListener);
- control.addTraverseListener(traverseListener);
- }
-
- /**
- * Remove listeners from each control.
- *
- * @param control The control to no longer listen to.
- */
- private void removeListeners(Control control) {
- control.removeKeyListener(keyListener);
- control.removeFocusListener(focusListener);
- control.removeTraverseListener(traverseListener);
- }
-
- /**
- * Forward key presses to the parent control
- */
- private KeyListener keyListener = new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- parent.keyPressed(TableRow.this, e);
- }
- };
-
- /**
- * Forward focuse events to the parent control
- */
- private FocusListener focusListener = new FocusAdapter() {
- public void focusLost(FocusEvent e) {
- parent.focusLost(TableRow.this, e);
- }
- public void focusGained(FocusEvent e) {
- parent.focusGained(TableRow.this, e);
- }
- };
-
- /**
- * Forward traverse events to the parent control
- */
- private TraverseListener traverseListener = new TraverseListener() {
- public void keyTraversed(TraverseEvent e) {
- /*
- * FEATURE IN SWT: When SWT needs to resolve a mnemonic (accelerator)
- * character, it recursively calls the traverse event down all
- * controls in the containership hierarchy. If e.doit is false,
- * no control has yet matched the mnemonic, and we don't have to
- * do anything since we don't do mnemonic matching and no mnemonic
- * has matched.
- */
- if (e.doit) {
- parent.keyTraversed(TableRow.this, e);
- }
- }
- };
-
- /**
- * Return the SWT control implementing the row's GUI.
- *
- * @return The row's SWT control
- */
- public Control getRowControl() {
- return row;
- }
-
- /**
- * Return the SWT control corresponding to a particular column within
- * this row.
- *
- * @param i the 0-based offset of the column to return.
- * @return The corresponding control or null if there is no control at the
- * specified position.
- */
- public Control getColumnControl(int i) {
- if (i < 0) {
- return row;
- }
- if (i < 1 && columns.length == 0) {
- return row;
- }
- if (i < columns.length) {
- return columns[i];
- }
- return null;
- }
-
- /**
- * Return the column number of a specified SWT control or -1 if not found.
- *
- * @param control The control to find.
- * @return control's column number or -1 if that column control is not in this row.
- */
- public int getColumnNumber(Control control) {
- for (int i = 0; i < columns.length; i++) {
- if (columns[i] == control) {
- return i;
- }
- }
- return -1;
- }
-
- /**
- * Return the number of columns in this row.
- *
- * @return The number of columns in this row.
- */
- public int getNumColumns() {
- return columns.length;
- }
-
- /**
- * Sets the visibility of this row.
- *
- * @param visible true if the row should be visible; false otherwise.
- */
- public void setVisible(boolean visible) {
- row.setVisible(visible);
- }
-
- /**
- * Returns if this row is visible.
- *
- * @return true if the row is visible; false otherwise.
- */
- public boolean getVisible() {
- return row.getVisible();
- }
-} \ No newline at end of file
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/MonthCalendar.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/MonthCalendar.java
deleted file mode 100644
index 88a6b31f..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/MonthCalendar.java
+++ /dev/null
@@ -1,751 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jface.examples.databinding.compositetable.month;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.jface.examples.databinding.compositetable.day.AbstractEventEditor;
-import org.eclipse.jface.examples.databinding.compositetable.day.CalendarableItemEventHandler;
-import org.eclipse.jface.examples.databinding.compositetable.day.CalendarableSelectionChangeListener;
-import org.eclipse.jface.examples.databinding.compositetable.month.internal.Day;
-import org.eclipse.jface.examples.databinding.compositetable.month.internal.Week;
-import org.eclipse.jface.examples.databinding.compositetable.month.internal.WeekHeader;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventContentProvider;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventCountProvider;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * An IEventEditor implementing a month calendar. This class is not intended
- * to be subclassed.
- */
-public class MonthCalendar extends AbstractEventEditor implements IEventEditor {
-
- private Date startDate;
- private WeekHeader weekHeader = null;
- private Composite weeksHolder = null;
- private Week[] weeks;
-
- /**
- * Constructor DayEditor. Constructs a calendar control that can display
- * events on one or more days.
- *
- * @param parent
- * @param style The same style bits as @see Composite
- */
- public MonthCalendar(Composite parent, int style) {
- super(parent, style);
- initialize();
- weeks = new Week[0];
- setStartDate(new Date());
- }
-
- private void initialize() {
- GridLayout gl = new GridLayout();
- gl.horizontalSpacing = 0;
- gl.marginWidth = 0;
- gl.verticalSpacing = 0;
- gl.marginHeight = 0;
- createWeekHeader();
- this.setLayout(gl);
- createWeeksHolder();
- }
-
- /**
- * This method initializes weekHeader
- *
- */
- private void createWeekHeader() {
- GridData gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.grabExcessHorizontalSpace = true;
- gridData.verticalAlignment = GridData.CENTER;
- weekHeader = new WeekHeader(this, SWT.NONE);
- weekHeader.setLayoutData(gridData);
- }
-
- /**
- * This method initializes composite
- *
- */
- private void createWeeksHolder() {
- weeksHolder = new Composite(this, SWT.NONE);
-
- GridLayout gridLayout = new GridLayout();
- gridLayout.horizontalSpacing = 0;
- gridLayout.marginWidth = 0;
- gridLayout.verticalSpacing = 1;
- gridLayout.marginHeight = 0;
- weeksHolder.setLayout(gridLayout);
-
- GridData gd = new GridData();
- gd.horizontalAlignment = GridData.FILL;
- gd.grabExcessHorizontalSpace = true;
- gd.grabExcessVerticalSpace = true;
- gd.verticalAlignment = GridData.FILL;
- weeksHolder.setLayoutData(gd);
- }
-
- /**
- * This method initializes week
- */
- private Week createWeek() {
- GridData gd = new GridData();
- gd.horizontalAlignment = GridData.FILL;
- gd.grabExcessHorizontalSpace = true;
- gd.grabExcessVerticalSpace = true;
- gd.verticalAlignment = GridData.FILL;
- Week week = new Week(weeksHolder, SWT.NONE);
- week.setLayoutData(gd);
- return week;
- }
-
- /**
- * Sets the start date for this MonthCalendar.
- * <p>
- * The date is set to the first day of the specified month and the time part
- * of the Date object is set to midnight before storing. Calling
- * {@link #getStartDate()} will return this mutilated version instead of the
- * original.
- *
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#setStartDate(java.util.Date)
- */
- public void setStartDate(Date startDate) {
- checkWidget();
-
- Calendar c = new GregorianCalendar();
- c.setTime(startDate);
- c.set(Calendar.DAY_OF_MONTH, 1);
- c.set(Calendar.HOUR_OF_DAY, 0);
- c.set(Calendar.MINUTE, 0);
- c.set(Calendar.SECOND, 0);
- c.set(Calendar.MILLISECOND, 0);
- this.startDate = c.getTime();
- refresh();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#getStartDate()
- */
- public Date getStartDate() {
- checkWidget();
-
- return startDate;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#refresh(java.util.Date)
- */
- public void refresh(Date date) {
- checkWidget();
-
- if (date == null) {
- refresh();
- return;
- }
-
- Calendar currentDay = new GregorianCalendar();
- currentDay.setTime(startDate);
- currentDay.set(Calendar.DAY_OF_MONTH, 1);
- currentDay.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
-
- Calendar endDay = new GregorianCalendar();
- endDay.setTime(date);
- endDay.set(Calendar.HOUR_OF_DAY, 0);
- endDay.set(Calendar.MINUTE, 0);
- endDay.set(Calendar.SECOND, 0);
- endDay.set(Calendar.MILLISECOND, 0);
- Date targetDate = endDay.getTime();
-
- Day currentDayControl = null;
- for (int week = 0; week < weeks.length; week++) {
- for (int day = 0; day < 7; day++) {
- currentDayControl = weeks[week].getDay(day);
-
- currentDay.add(Calendar.DAY_OF_MONTH, 1);
- if (currentDay.getTime().after(targetDate)) {
- refresh(date, currentDayControl);
- return;
- }
- }
- }
- }
-
- private void refresh(Date date, Day dayControl) {
- dayControl.setDate(date);
- if (eventCountProvider == null || eventContentProvider == null) {
- return;
- }
- int numberOfEventsInDay = eventCountProvider.getNumberOfEventsInDay(date);
- CalendarableItem controls[] = new CalendarableItem[numberOfEventsInDay];
- for (int i = 0; i < controls.length; i++) {
- controls[i] = new CalendarableItem(date);
- }
- eventContentProvider.refresh(date, controls);
- dayControl.setItems(controls);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#refresh()
- */
- public void refresh() {
- checkWidget();
-
- Calendar c = new GregorianCalendar();
- c.setTime(startDate);
- int currentMonth = c.get(Calendar.MONTH);
-
- Calendar nextMonthCalendar = new GregorianCalendar();
- nextMonthCalendar.setTime(c.getTime());
- nextMonthCalendar.add(Calendar.MONTH, 1);
- Date nextMonth = nextMonthCalendar.getTime();
-
- c.set(Calendar.DAY_OF_MONTH, 1);
- c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek());
-
- LinkedList newWeeksArray = new LinkedList();
-
- for (int week = 0; c.getTime().before(nextMonth); week++) {
- if (weeks.length > week) {
- newWeeksArray.addLast(weeks[week]);
- } else {
- Week newWeek = createWeek();
- newWeeksArray.addLast(newWeek);
- for (int day=0; day < 7; day++) {
- Day newDay = newWeek.getDay(day);
- newDay.setMonthPosition(new Point(day, week));
- newDay.addKeyListener(dayKeyListener);
- newDay.addMouseListener(dayMouseListener);
- newDay.addFocusListener(dayFocusListener);
- }
- }
- for (int day = 0; day < 7; day++) {
- Day currentDay = ((Week)newWeeksArray.get(week)).getDay(day);
- currentDay.setInCurrentMonth(c.get(Calendar.MONTH) == currentMonth);
- currentDay.setDayNumber(c.get(Calendar.DAY_OF_MONTH));
- refresh(c.getTime(), currentDay);
- currentDay.layout(true);
- c.add(Calendar.DAY_OF_MONTH, 1);
- }
- }
- if (weeks.length > newWeeksArray.size()) {
- for (int extraWeek=newWeeksArray.size(); extraWeek < weeks.length; ++extraWeek) {
- weeks[extraWeek].dispose();
- }
- }
- if (weeks.length != newWeeksArray.size()) {
- weeksHolder.layout(true);
- }
- weeks = (Week[]) newWeeksArray.toArray(new Week[newWeeksArray.size()]);
- }
-
- private EventContentProvider eventContentProvider = null;
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#setEventContentProvider(org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventContentProvider)
- */
- public void setEventContentProvider(EventContentProvider eventContentProvider) {
- checkWidget();
-
- this.eventContentProvider = eventContentProvider;
- }
-
- private EventCountProvider eventCountProvider = null;
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#setEventCountProvider(org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventCountProvider)
- */
- public void setEventCountProvider(EventCountProvider eventCountProvider) {
- checkWidget();
-
- this.eventCountProvider = eventCountProvider;
- }
-
- /*
- * FIXME: To be used when we support full editing
- */
-// private boolean fireEvents(CalendarableItem calendarableItem, List handlers) {
-// CalendarableItemEvent e = new CalendarableItemEvent();
-// e.calendarableItem = calendarableItem;
-// for (Iterator iter = handlers.iterator(); iter.hasNext();) {
-// CalendarableItemEventHandler handler = (CalendarableItemEventHandler) iter.next();
-// handler.handleRequest(e);
-// if (!e.doit) {
-// break;
-// }
-// }
-// for (Iterator i = handlers.iterator(); i.hasNext();) {
-// CalendarableItemEventHandler h = (CalendarableItemEventHandler) i.next();
-// h.requestHandled(e);
-// if (!e.doit) {
-// break;
-// }
-// }
-// return e.doit;
-// }
-
- private List deleteHandlers = new ArrayList();
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#addItemDeleteHandler(org.eclipse.jface.examples.databinding.compositetable.day.CalendarableItemEventHandler)
- */
- public void addItemDeleteHandler(CalendarableItemEventHandler deleteHandler) {
- checkWidget();
-
- deleteHandlers.add(deleteHandler);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#removeItemDeleteHandler(org.eclipse.jface.examples.databinding.compositetable.day.CalendarableItemEventHandler)
- */
- public void removeItemDeleteHandler(CalendarableItemEventHandler deleteHandler) {
- checkWidget();
-
- deleteHandlers.remove(deleteHandler);
- }
-
- private List disposeHandlers = new ArrayList();
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#addItemDisposeHandler(org.eclipse.jface.examples.databinding.compositetable.day.CalendarableItemEventHandler)
- */
- public void addItemDisposeHandler(CalendarableItemEventHandler itemDisposeHandler) {
- checkWidget();
-
- disposeHandlers.add(itemDisposeHandler);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#removeItemDisposeHandler(org.eclipse.jface.examples.databinding.compositetable.day.CalendarableItemEventHandler)
- */
- public void removeItemDisposeHandler(CalendarableItemEventHandler itemDisposeHandler) {
- checkWidget();
-
- disposeHandlers.remove(itemDisposeHandler);
- }
-
- private List itemEditHandlers = new ArrayList();
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#addItemEditHandler(org.eclipse.jface.examples.databinding.compositetable.day.CalendarableItemEventHandler)
- */
- public void addItemEditHandler(CalendarableItemEventHandler handler) {
- checkWidget();
-
- itemEditHandlers.add(handler);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#removeItemEditHandler(org.eclipse.jface.examples.databinding.compositetable.day.CalendarableItemEventHandler)
- */
- public void removeItemEditHandler(CalendarableItemEventHandler handler) {
- checkWidget();
-
- itemEditHandlers.remove(handler);
- }
-
- private List selectionChangeListeners = new ArrayList();
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#addSelectionChangeListener(org.eclipse.jface.examples.databinding.compositetable.day.CalendarableSelectionChangeListener)
- */
- public void addSelectionChangeListener(CalendarableSelectionChangeListener l) {
- checkWidget();
-
- selectionChangeListeners.add(l);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#removeSelectionChangeListener(org.eclipse.jface.examples.databinding.compositetable.day.CalendarableSelectionChangeListener)
- */
- public void removeSelectionChangeListener(CalendarableSelectionChangeListener l) {
- checkWidget();
-
- selectionChangeListeners.remove(l);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#fireDelete(org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem)
- */
- public boolean fireDelete(CalendarableItem toDelete) {
- checkWidget();
-
- // TODO Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#setTimeBreakdown(int,
- * int)
- */
- public void setTimeBreakdown(int numberOfDays, int numberOfDivisionsInHour) {
- checkWidget();
- // NOOP
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#getNumberOfDays()
- */
- public int getNumberOfDays() {
- checkWidget();
-
- // Return the number of days in the current month
- Calendar c = new GregorianCalendar();
- c.setTime(startDate);
- return c.getActualMaximum(Calendar.DAY_OF_MONTH);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#getNumberOfDivisionsInHour()
- */
- public int getNumberOfDivisionsInHour() {
- checkWidget();
-
- // NOOP
- return -1;
- }
-
- private MonthCalendarSelectedDay selectedDay = null;
-
- /**
- * Method getSelectedDay. Returns the currently-selected day.
- *
- * @return The current MonthCalendarSelection which represents the currently-
- * selected day.
- */
- public MonthCalendarSelectedDay getSelectedDay() {
- checkWidget();
-
- return selectedDay;
- }
-
- private List focusListeners = new ArrayList();
-
- /**
- * Adds the listener to the collection of listeners who will
- * be notified when the control gains or loses focus, by sending
- * it one of the messages defined in the <code>FocusListener</code>
- * interface.
- * <p>
- * In addition, e.data in the FocusEvent is the current MonthCalendarSelectedDay.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see FocusListener
- * @see #removeFocusListener
- * @see org.eclipse.swt.widgets.Control#addFocusListener(org.eclipse.swt.events.FocusListener)
- */
- public void addFocusListener(FocusListener listener) {
- checkWidget();
-
- super.addFocusListener(listener);
- focusListeners.add(listener);
- }
-
- /**
- * Removes the listener from the collection of listeners who will
- * be notified when the control gains or loses focus.
- * <p>
- * In addition, e.data in the FocusEvent is the current MonthCalendarSelectedDay.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see FocusListener
- * @see #addFocusListener
- * @see org.eclipse.swt.widgets.Control#removeFocusListener(org.eclipse.swt.events.FocusListener)
- */
- public void removeFocusListener(FocusListener listener) {
- checkWidget();
-
- super.removeFocusListener(listener);
- focusListeners.remove(listener);
- }
-
- private FocusListener dayFocusListener = new FocusListener() {
- public void focusGained(FocusEvent e) {
- Day day = (Day) e.widget;
- Point coordinates = day.getMonthPosition();
- selectedDay = new MonthCalendarSelectedDay(day.getDate(), coordinates);
- e.data = selectedDay;
-
- for (Iterator focusListenersIter = focusListeners.iterator(); focusListenersIter.hasNext();) {
- FocusListener listener = (FocusListener) focusListenersIter.next();
- listener.focusGained(e);
- }
- }
-
- public void focusLost(FocusEvent e) {
- Day day = (Day) e.widget;
- Point coordinates = day.getMonthPosition();
- e.data = new MonthCalendarSelectedDay(day.getDate(), coordinates);
-
- for (Iterator focusListenersIter = focusListeners.iterator(); focusListenersIter.hasNext();) {
- FocusListener listener = (FocusListener) focusListenersIter.next();
- listener.focusLost(e);
- }
- }
- };
-
- private List mouseListeners = new ArrayList();
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#addMouseListener(org.eclipse.swt.events.MouseListener)
- */
- public void addMouseListener(MouseListener listener) {
- checkWidget();
-
- super.addMouseListener(listener);
- mouseListeners.add(listener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#removeMouseListener(org.eclipse.swt.events.MouseListener)
- */
- public void removeMouseListener(MouseListener listener) {
- checkWidget();
-
- super.removeMouseListener(listener);
- mouseListeners.remove(listener);
- }
-
- private MouseListener dayMouseListener = new MouseListener() {
- private Day getDay(MouseEvent e) {
- Control control = (Control) e.widget;
- while (!(control instanceof Day)) {
- control = control.getParent();
- }
- Day day = (Day) control;
- return day;
- }
- public void mouseDown(MouseEvent e) {
- Day day = getDay(e);
- Point coordinates = day.getMonthPosition();
- e.data = new MonthCalendarSelectedDay(day.getDate(), coordinates);
-
- for (Iterator mouseListenersIter = mouseListeners.iterator(); mouseListenersIter.hasNext();) {
- MouseListener listener = (MouseListener) mouseListenersIter.next();
- listener.mouseDown(e);
- }
- }
- public void mouseUp(MouseEvent e) {
- Day day = getDay(e);
- Point coordinates = day.getMonthPosition();
- e.data = new MonthCalendarSelectedDay(day.getDate(), coordinates);
-
- for (Iterator mouseListenersIter = mouseListeners.iterator(); mouseListenersIter.hasNext();) {
- MouseListener listener = (MouseListener) mouseListenersIter.next();
- listener.mouseUp(e);
- }
- }
- public void mouseDoubleClick(MouseEvent e) {
- Day day = getDay(e);
- Point coordinates = day.getMonthPosition();
- e.data = new MonthCalendarSelectedDay(day.getDate(), coordinates);
-
- for (Iterator mouseListenersIter = mouseListeners.iterator(); mouseListenersIter.hasNext();) {
- MouseListener listener = (MouseListener) mouseListenersIter.next();
- listener.mouseDoubleClick(e);
- }
- }
- };
-
- private List keyListeners = new ArrayList();
-
- /**
- * Adds the listener to the collection of listeners who will
- * be notified when keys are pressed and released on the system keyboard, by
- * sending it one of the messages defined in the <code>KeyListener</code>
- * interface.
- * <p>
- * In addition to the usual KeyListener contract, MonthCalendar will honor
- * e.doit and will not perform its usual key processing if any KeyListener
- * sets e.doit to false.
- * <p>
- * In addition to the usual KeyEvent fields, e.data is set to the current
- * MonthCalendarSelection.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see org.eclipse.swt.widgets.Control#addKeyListener(org.eclipse.swt.events.KeyListener)
- */
- public void addKeyListener(KeyListener listener) {
- checkWidget();
-
- super.addKeyListener(listener);
- keyListeners.add(listener);
- }
-
- /**
- * Removes the listener from the collection of listeners who will
- * be notified when keys are pressed and released on the system keyboard.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see KeyListener
- * @see #addKeyListener
- * @see org.eclipse.swt.widgets.Control#removeKeyListener(org.eclipse.swt.events.KeyListener)
- */
- public void removeKeyListener(KeyListener listener) {
- checkWidget();
-
- super.removeKeyListener(listener);
- keyListeners.remove(listener);
- }
-
- private KeyListener dayKeyListener = new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- Day day = (Day) e.widget;
- Point coordinates = day.getMonthPosition();
- e.data = new MonthCalendarSelectedDay(day.getDate(), coordinates);
-
- for (Iterator keyListenersIter = keyListeners.iterator(); keyListenersIter.hasNext();) {
- KeyListener listener = (KeyListener) keyListenersIter.next();
- listener.keyPressed(e);
- }
-
- if (!e.doit) {
- return;
- }
-
- switch (e.keyCode) {
- case SWT.ARROW_UP:
- if (coordinates.y > 0) {
- Day newDay = weeks[coordinates.y-1].getDay(coordinates.x);
- newDay.setFocus();
- }
- return;
- case SWT.ARROW_DOWN:
- if (coordinates.y < weeks.length-1) {
- Day newDay = weeks[coordinates.y+1].getDay(coordinates.x);
- newDay.setFocus();
- }
- return;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.KeyAdapter#keyReleased(org.eclipse.swt.events.KeyEvent)
- */
- public void keyReleased(KeyEvent e) {
- Day day = (Day) e.widget;
- Point coordinates = day.getMonthPosition();
- e.data = new MonthCalendarSelectedDay(day.getDate(), coordinates);
-
- for (Iterator keyListenersIter = keyListeners.iterator(); keyListenersIter.hasNext();) {
- KeyListener listener = (KeyListener) keyListenersIter.next();
- listener.keyReleased(e);
- }
-
- // No need for this logic here yet, but leaving it commented
- // as a reminder...
-
- // if (!e.doit) return;
- }
- };
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Composite#setFocus()
- */
- public boolean setFocus() {
- checkWidget();
-
- Day newDay = weeks[0].getDay(0);
- return newDay.setFocus();
- }
-
-
-} // @jve:decl-index=0:visual-constraint="10,10"
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/MonthCalendarSelectedDay.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/MonthCalendarSelectedDay.java
deleted file mode 100644
index 5d53d3c6..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/MonthCalendarSelectedDay.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable.month;
-
-import java.util.Date;
-
-import org.eclipse.swt.graphics.Point;
-
-/**
- * Represents the currrently-selected day in the month calendar.
- *
- * @since 3.3
- */
-public class MonthCalendarSelectedDay {
-
- /**
- * The selected Date
- */
- public final Date date;
-
- /**
- * The coordinates (day, week) of the selected date in the current month
- * where day is a number 0-6 representing [Sunday .. Saturday] and week
- * is a 0-based offset representing the the week number of the selected
- * date's week within the month.
- */
- public final Point coordinates;
-
- /**
- * Constructor MonthCalendarSelection. Construct a MonthCalendarSelection.
- *
- * @param date The selected date.
- * @param coordinates The coordinates of the selected date.
- */
- public MonthCalendarSelectedDay(Date date, Point coordinates) {
- this.date = date;
- this.coordinates = coordinates;
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/MonthCalendarTest.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/MonthCalendarTest.java
deleted file mode 100644
index 1c138952..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/MonthCalendarTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2005 David Orme <djo@coconut-palm-software.com>
- *
- * 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:
- * David Orme - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.compositetable.month;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-public class MonthCalendarTest {
-
- private Shell sShell = null; // @jve:decl-index=0:visual-constraint="10,10"
-
- /**
- * This method initializes monthCalendar
- *
- */
- private void createMonthCalendar() {
- new MonthCalendar(sShell, SWT.NONE);
- }
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Display display = Display.getDefault();
- MonthCalendarTest thisClass = new MonthCalendarTest();
- thisClass.createSShell();
- thisClass.sShell.open();
-
- while (!thisClass.sShell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
-
- /**
- * This method initializes sShell
- */
- private void createSShell() {
- sShell = new Shell();
- sShell.setText("Shell");
- sShell.setLayout(new FillLayout());
- createMonthCalendar();
- sShell.setSize(new org.eclipse.swt.graphics.Point(624,578));
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/MonthCalendarableItemControl.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/MonthCalendarableItemControl.java
deleted file mode 100644
index 2250139e..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/MonthCalendarableItemControl.java
+++ /dev/null
@@ -1,852 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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
- * The Pampered Chef - Adapted for month calendar
- *******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable.month;
-
-import org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.accessibility.ACC;
-import org.eclipse.swt.accessibility.Accessible;
-import org.eclipse.swt.accessibility.AccessibleAdapter;
-import org.eclipse.swt.accessibility.AccessibleControlAdapter;
-import org.eclipse.swt.accessibility.AccessibleControlEvent;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * @since 3.2
- */
-public class MonthCalendarableItemControl extends Canvas
- implements ICalendarableItemControl
-{
-// private CLabel label;
-
- /** Gap between icon and text */
- private static final int GAP = 5;
- /** Left and right margins */
- private static final int INDENT = 3;
- /** a string inserted in the middle of text that has been shortened */
- private static final String ELLIPSIS = "..."; //$NON-NLS-1$ // could use the ellipsis glyph on some platforms "\u2026"
- /** the alignment. Either CENTER, RIGHT, LEFT. Default is LEFT*/
- private int align = SWT.LEFT;
- private int hIndent = INDENT;
- private int vIndent = INDENT;
- /** the current text */
- private String text;
- /** the current icon */
- private Image image;
- // The tooltip is used for two purposes - the application can set
- // a tooltip or the tooltip can be used to display the full text when the
- // the text has been truncated due to the label being too short.
- // The appToolTip stores the tooltip set by the application. Control.tooltiptext
- // contains whatever tooltip is currently being displayed.
- private String appToolTipText;
-
- private Image backgroundImage;
- private Color[] gradientColors;
- private int[] gradientPercents;
- private boolean gradientVertical;
- private Color background;
-
- private static int DRAW_FLAGS = SWT.DRAW_MNEMONIC | SWT.DRAW_TAB | SWT.DRAW_TRANSPARENT | SWT.DRAW_DELIMITER;
-
- /**
- * @param parent
- * @param style
- */
- public MonthCalendarableItemControl(Composite parent, int style) {
- super(parent, checkStyle(style));
- if ((style & (SWT.CENTER | SWT.RIGHT)) == 0) style |= SWT.LEFT;
- if ((style & SWT.CENTER) != 0) align = SWT.CENTER;
- if ((style & SWT.RIGHT) != 0) align = SWT.RIGHT;
- if ((style & SWT.LEFT) != 0) align = SWT.LEFT;
-
- addPaintListener(new PaintListener(){
- public void paintControl(PaintEvent event) {
- onPaint(event);
- }
- });
-
- addDisposeListener(new DisposeListener(){
- public void widgetDisposed(DisposeEvent event) {
- onDispose(event);
- }
- });
-
- initAccessible();
-
- setBackground(parent.getBackground());
- }
-
- private CalendarableItem calendarableItem = null;
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#getCalendarableItem()
- */
- public CalendarableItem getCalendarableItem() {
- return calendarableItem;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#setCalendarableItem(org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem)
- */
- public void setCalendarableItem(CalendarableItem calendarable) {
- this.calendarableItem = calendarable;
- }
-
- private int clipping = 0;
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#getClipping()
- */
- public int getClipping() {
- return clipping;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#setClipping(int)
- */
- public void setClipping(int clipping) {
- this.clipping = clipping;
- }
-
- private int continued = 0;
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#getContinued()
- */
- public int getContinued() {
- return continued;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#setContinued(int)
- */
- public void setContinued(int continued) {
- this.continued = continued;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#setSelected(boolean)
- */
- public void setSelected(boolean selected) {
- // noop
- // We currently don't allow an item to be selected.
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#setImage(org.eclipse.swt.graphics.Image)
- */
-// public void setImage(Image image) {
-// label.setImage(image);
-// }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl#setText(java.lang.String)
- */
-// public void setText(String text) {
-// label.setText(text);
-// }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#setMenu(org.eclipse.swt.widgets.Menu)
- */
-// public void setMenu(Menu menu) {
-// super.setMenu(menu);
-// label.setMenu(menu);
-// }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#setToolTipText(java.lang.String)
- */
-// public void setToolTipText(String string) {
-// super.setToolTipText(string);
-// label.setToolTipText(string);
-// }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#addMouseListener(org.eclipse.swt.events.MouseListener)
- */
-// public void addMouseListener(MouseListener listener) {
-// super.addMouseListener(listener);
-// label.addMouseListener(listener);
-// }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#removeMouseListener(org.eclipse.swt.events.MouseListener)
- */
-// public void removeMouseListener(MouseListener listener) {
-// super.removeMouseListener(listener);
-// label.removeMouseListener(listener);
-// }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#setBackground(org.eclipse.swt.graphics.Color)
- */
-// public void setBackground(Color color) {
-// super.setBackground(color);
-// label.setBackground(color);
-// }
-
- /**
- * Check the style bits to ensure that no invalid styles are applied.
- */
- private static int checkStyle (int style) {
- if ((style & SWT.BORDER) != 0) style |= SWT.SHADOW_IN;
- int mask = SWT.SHADOW_IN | SWT.SHADOW_OUT | SWT.SHADOW_NONE | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
- style = style & mask;
- return style |= SWT.NO_FOCUS | SWT.DOUBLE_BUFFERED;
- }
-
-// protected void checkSubclass () {
-// String name = getClass().getName ();
-// String validName = CLabel.class.getName();
-// if (!validName.equals(name)) {
-// SWT.error (SWT.ERROR_INVALID_SUBCLASS);
-// }
-// }
-
- public Point computeSize(int wHint, int hHint, boolean changed) {
- checkWidget();
- Point e = getTotalSize(image, text);
- if (wHint == SWT.DEFAULT){
- e.x += 2*hIndent;
- } else {
- e.x = wHint;
- }
- if (hHint == SWT.DEFAULT) {
- e.y += 2*vIndent;
- } else {
- e.y = hHint;
- }
- return e;
- }
- /**
- * Draw a rectangle in the given colors.
- */
- private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topleft, Color bottomright) {
- gc.setForeground(bottomright);
- gc.drawLine(x+w, y, x+w, y+h);
- gc.drawLine(x, y+h, x+w, y+h);
-
- gc.setForeground(topleft);
- gc.drawLine(x, y, x+w-1, y);
- gc.drawLine(x, y, x, y+h-1);
- }
- /*
- * Return the lowercase of the first non-'&' character following
- * an '&' character in the given string. If there are no '&'
- * characters in the given string, return '\0'.
- */
- char _findMnemonic (String string) {
- if (string == null) return '\0';
- int index = 0;
- int length = string.length ();
- do {
- while (index < length && string.charAt (index) != '&') index++;
- if (++index >= length) return '\0';
- if (string.charAt (index) != '&') return Character.toLowerCase (string.charAt (index));
- index++;
- } while (index < length);
- return '\0';
- }
- /**
- * Returns the alignment.
- * The alignment style (LEFT, CENTER or RIGHT) is returned.
- *
- * @return SWT.LEFT, SWT.RIGHT or SWT.CENTER
- */
- public int getAlignment() {
- //checkWidget();
- return align;
- }
- /**
- * Return the CLabel's image or <code>null</code>.
- *
- * @return the image of the label or null
- */
- public Image getImage() {
- //checkWidget();
- return image;
- }
- /**
- * Compute the minimum size.
- */
- private Point getTotalSize(Image image, String text) {
- Point size = new Point(0, 0);
-
- if (image != null) {
- Rectangle r = image.getBounds();
- size.x += r.width;
- size.y += r.height;
- }
-
- GC gc = new GC(this);
- if (text != null && text.length() > 0) {
- Point e = gc.textExtent(text, DRAW_FLAGS);
- size.x += e.x;
- size.y = Math.max(size.y, e.y);
- if (image != null) size.x += GAP;
- } else {
- size.y = Math.max(size.y, gc.getFontMetrics().getHeight());
- }
- gc.dispose();
-
- return size;
- }
- public int getStyle () {
- int style = super.getStyle();
- switch (align) {
- case SWT.RIGHT: style |= SWT.RIGHT; break;
- case SWT.CENTER: style |= SWT.CENTER; break;
- case SWT.LEFT: style |= SWT.LEFT; break;
- }
- return style;
- }
-
- /**
- * Return the Label's text.
- *
- * @return the text of the label or null
- */
- public String getText() {
- //checkWidget();
- return text;
- }
- public String getToolTipText () {
- checkWidget();
- return appToolTipText;
- }
- private void initAccessible() {
- Accessible accessible = getAccessible();
- accessible.addAccessibleListener(new AccessibleAdapter() {
- public void getName(AccessibleEvent e) {
- e.result = getText();
- }
-
- public void getHelp(AccessibleEvent e) {
- e.result = getToolTipText();
- }
-
- public void getKeyboardShortcut(AccessibleEvent e) {
- char mnemonic = _findMnemonic(MonthCalendarableItemControl.this.text);
- if (mnemonic != '\0') {
- e.result = "Alt+"+mnemonic; //$NON-NLS-1$
- }
- }
- });
-
- accessible.addAccessibleControlListener(new AccessibleControlAdapter() {
- public void getChildAtPoint(AccessibleControlEvent e) {
- e.childID = ACC.CHILDID_SELF;
- }
-
- public void getLocation(AccessibleControlEvent e) {
- Rectangle rect = getDisplay().map(getParent(), null, getBounds());
- e.x = rect.x;
- e.y = rect.y;
- e.width = rect.width;
- e.height = rect.height;
- }
-
- public void getChildCount(AccessibleControlEvent e) {
- e.detail = 0;
- }
-
- public void getRole(AccessibleControlEvent e) {
- e.detail = ACC.ROLE_LABEL;
- }
-
- public void getState(AccessibleControlEvent e) {
- e.detail = ACC.STATE_READONLY;
- }
- });
- }
- void onDispose(DisposeEvent event) {
- gradientColors = null;
- gradientPercents = null;
- backgroundImage = null;
- text = null;
- image = null;
- appToolTipText = null;
- }
-
- void onPaint(PaintEvent event) {
- Rectangle rect = getClientArea();
- if (rect.width == 0 || rect.height == 0) return;
-
- boolean shortenText = false;
- String t = text;
- Image img = image;
- int availableWidth = Math.max(0, rect.width - 2*hIndent);
- Point extent = getTotalSize(img, t);
- if (extent.x > availableWidth) {
- img = null;
- extent = getTotalSize(img, t);
- if (extent.x > availableWidth) {
- shortenText = true;
- }
- }
-
- GC gc = event.gc;
- String[] lines = text == null ? null : splitString(text);
-
- // shorten the text
- if (shortenText) {
- extent.x = 0;
- for(int i = 0; i < lines.length; i++) {
- Point e = gc.textExtent(lines[i], DRAW_FLAGS);
- if (e.x > availableWidth) {
- lines[i] = shortenText(gc, lines[i], availableWidth);
- extent.x = Math.max(extent.x, getTotalSize(null, lines[i]).x);
- } else {
- extent.x = Math.max(extent.x, e.x);
- }
- }
- if (appToolTipText == null) {
- super.setToolTipText(text);
- }
- } else {
- super.setToolTipText(appToolTipText);
- }
-
- // determine horizontal position
- int x = rect.x + hIndent;
- if (align == SWT.CENTER) {
- x = (rect.width - extent.x)/2;
- }
- if (align == SWT.RIGHT) {
- x = rect.width - hIndent - extent.x;
- }
-
- // draw a background image behind the text
- try {
- if (backgroundImage != null) {
- // draw a background image behind the text
- Rectangle imageRect = backgroundImage.getBounds();
- // tile image to fill space
- gc.setBackground(getBackground());
- gc.fillRectangle(rect);
- int xPos = 0;
- while (xPos < rect.width) {
- int yPos = 0;
- while (yPos < rect.height) {
- gc.drawImage(backgroundImage, xPos, yPos);
- yPos += imageRect.height;
- }
- xPos += imageRect.width;
- }
- } else if (gradientColors != null) {
- // draw a gradient behind the text
- final Color oldBackground = gc.getBackground();
- if (gradientColors.length == 1) {
- if (gradientColors[0] != null) gc.setBackground(gradientColors[0]);
- gc.fillRectangle(0, 0, rect.width, rect.height);
- } else {
- final Color oldForeground = gc.getForeground();
- Color lastColor = gradientColors[0];
- if (lastColor == null) lastColor = oldBackground;
- int pos = 0;
- for (int i = 0; i < gradientPercents.length; ++i) {
- gc.setForeground(lastColor);
- lastColor = gradientColors[i + 1];
- if (lastColor == null) lastColor = oldBackground;
- gc.setBackground(lastColor);
- if (gradientVertical) {
- final int gradientHeight = (gradientPercents[i] * rect.height / 100) - pos;
- gc.fillGradientRectangle(0, pos, rect.width, gradientHeight, true);
- pos += gradientHeight;
- } else {
- final int gradientWidth = (gradientPercents[i] * rect.width / 100) - pos;
- gc.fillGradientRectangle(pos, 0, gradientWidth, rect.height, false);
- pos += gradientWidth;
- }
- }
- if (gradientVertical && pos < rect.height) {
- gc.setBackground(getBackground());
- gc.fillRectangle(0, pos, rect.width, rect.height - pos);
- }
- if (!gradientVertical && pos < rect.width) {
- gc.setBackground(getBackground());
- gc.fillRectangle(pos, 0, rect.width - pos, rect.height);
- }
- gc.setForeground(oldForeground);
- }
- gc.setBackground(oldBackground);
- } else {
- if (background != null || (getStyle() & SWT.DOUBLE_BUFFERED) == 0) {
- gc.setBackground(getBackground());
- gc.fillRectangle(rect);
- }
- }
- } catch (SWTException e) {
- if ((getStyle() & SWT.DOUBLE_BUFFERED) == 0) {
- gc.setBackground(getBackground());
- gc.fillRectangle(rect);
- }
- }
-
- // draw border
- int style = getStyle();
- if ((style & SWT.SHADOW_IN) != 0 || (style & SWT.SHADOW_OUT) != 0) {
- paintBorder(gc, rect);
- }
-
- // draw the image
- if (img != null) {
- Rectangle imageRect = img.getBounds();
- gc.drawImage(img, 0, 0, imageRect.width, imageRect.height,
- x, (rect.height-imageRect.height)/2, imageRect.width, imageRect.height);
- x += imageRect.width + GAP;
- extent.x -= imageRect.width + GAP;
- }
- // draw the text
- if (lines != null) {
- int lineHeight = gc.getFontMetrics().getHeight();
- int textHeight = lines.length * lineHeight;
- int lineY = Math.max(vIndent, rect.y + (rect.height - textHeight) / 2);
- gc.setForeground(getForeground());
- for (int i = 0; i < lines.length; i++) {
- int lineX = x;
- if (lines.length > 1) {
- if (align == SWT.CENTER) {
- int lineWidth = gc.textExtent(lines[i], DRAW_FLAGS).x;
- lineX = x + Math.max(0, (extent.x - lineWidth) / 2);
- }
- if (align == SWT.RIGHT) {
- int lineWidth = gc.textExtent(lines[i], DRAW_FLAGS).x;
- lineX = Math.max(x, rect.x + rect.width - hIndent - lineWidth);
- }
- }
- gc.drawText(lines[i], lineX, lineY, DRAW_FLAGS);
- lineY += lineHeight;
- }
- }
- }
- /**
- * Paint the Label's border.
- */
- private void paintBorder(GC gc, Rectangle r) {
- Display disp= getDisplay();
-
- Color c1 = null;
- Color c2 = null;
-
- int style = getStyle();
- if ((style & SWT.SHADOW_IN) != 0) {
- c1 = disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
- c2 = disp.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
- }
- if ((style & SWT.SHADOW_OUT) != 0) {
- c1 = disp.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
- c2 = disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
- }
-
- if (c1 != null && c2 != null) {
- gc.setLineWidth(1);
- drawBevelRect(gc, r.x, r.y, r.width-1, r.height-1, c1, c2);
- }
- }
- /**
- * Set the alignment of the CLabel.
- * Use the values LEFT, CENTER and RIGHT to align image and text within the available space.
- *
- * @param align the alignment style of LEFT, RIGHT or CENTER
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_INVALID_ARGUMENT - if the value of align is not one of SWT.LEFT, SWT.RIGHT or SWT.CENTER</li>
- * </ul>
- */
- public void setAlignment(int align) {
- checkWidget();
- if (align != SWT.LEFT && align != SWT.RIGHT && align != SWT.CENTER) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- if (this.align != align) {
- this.align = align;
- redraw();
- }
- }
-
- public void setBackground (Color color) {
- super.setBackground (color);
- // Are these settings the same as before?
- if (backgroundImage == null &&
- gradientColors == null &&
- gradientPercents == null) {
- if (color == null) {
- if (background == null) return;
- } else {
- if (color.equals(background)) return;
- }
- }
- background = color;
- backgroundImage = null;
- gradientColors = null;
- gradientPercents = null;
- redraw ();
- }
-
- /**
- * Specify a gradient of colours to be drawn in the background of the CLabel.
- * <p>For example, to draw a gradient that varies from dark blue to blue and then to
- * white and stays white for the right half of the label, use the following call
- * to setBackground:</p>
- * <pre>
- * clabel.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE),
- * display.getSystemColor(SWT.COLOR_BLUE),
- * display.getSystemColor(SWT.COLOR_WHITE),
- * display.getSystemColor(SWT.COLOR_WHITE)},
- * new int[] {25, 50, 100});
- * </pre>
- *
- * @param colors an array of Color that specifies the colors to appear in the gradient
- * in order of appearance from left to right; The value <code>null</code>
- * clears the background gradient; the value <code>null</code> can be used
- * inside the array of Color to specify the background color.
- * @param percents an array of integers between 0 and 100 specifying the percent of the width
- * of the widget at which the color should change; the size of the percents
- * array must be one less than the size of the colors array.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_INVALID_ARGUMENT - if the values of colors and percents are not consistent</li>
- * </ul>
- */
- public void setBackground(Color[] colors, int[] percents) {
- setBackground(colors, percents, false);
- }
- /**
- * Specify a gradient of colours to be drawn in the background of the CLabel.
- * <p>For example, to draw a gradient that varies from dark blue to white in the vertical,
- * direction use the following call
- * to setBackground:</p>
- * <pre>
- * clabel.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE),
- * display.getSystemColor(SWT.COLOR_WHITE)},
- * new int[] {100}, true);
- * </pre>
- *
- * @param colors an array of Color that specifies the colors to appear in the gradient
- * in order of appearance from left/top to right/bottom; The value <code>null</code>
- * clears the background gradient; the value <code>null</code> can be used
- * inside the array of Color to specify the background color.
- * @param percents an array of integers between 0 and 100 specifying the percent of the width/height
- * of the widget at which the color should change; the size of the percents
- * array must be one less than the size of the colors array.
- * @param vertical indicate the direction of the gradient. True is vertical and false is horizontal.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_INVALID_ARGUMENT - if the values of colors and percents are not consistent</li>
- * </ul>
- *
- * @since 3.0
- */
- public void setBackground(Color[] colors, int[] percents, boolean vertical) {
- checkWidget();
- if (colors != null) {
- if (percents == null || percents.length != colors.length - 1) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- if (getDisplay().getDepth() < 15) {
- // Don't use gradients on low color displays
- colors = new Color[] {colors[colors.length - 1]};
- percents = new int[] { };
- }
- for (int i = 0; i < percents.length; i++) {
- if (percents[i] < 0 || percents[i] > 100) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- if (i > 0 && percents[i] < percents[i-1]) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- }
- }
-
- // Are these settings the same as before?
- final Color background = getBackground();
- if (backgroundImage == null) {
- if ((gradientColors != null) && (colors != null) &&
- (gradientColors.length == colors.length)) {
- boolean same = false;
- for (int i = 0; i < gradientColors.length; i++) {
- same = (gradientColors[i] == colors[i]) ||
- ((gradientColors[i] == null) && (colors[i] == background)) ||
- ((gradientColors[i] == background) && (colors[i] == null));
- if (!same) break;
- }
- if (same) {
- for (int i = 0; i < gradientPercents.length; i++) {
- same = gradientPercents[i] == percents[i];
- if (!same) break;
- }
- }
- if (same && this.gradientVertical == vertical) return;
- }
- } else {
- backgroundImage = null;
- }
- // Store the new settings
- if (colors == null) {
- gradientColors = null;
- gradientPercents = null;
- gradientVertical = false;
- } else {
- gradientColors = new Color[colors.length];
- for (int i = 0; i < colors.length; ++i)
- gradientColors[i] = (colors[i] != null) ? colors[i] : background;
- gradientPercents = new int[percents.length];
- for (int i = 0; i < percents.length; ++i)
- gradientPercents[i] = percents[i];
- gradientVertical = vertical;
- }
- // Refresh with the new settings
- redraw();
- }
- /**
- * Set the image to be drawn in the background of the label.
- *
- * @param image the image to be drawn in the background
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
- public void setBackground(Image image) {
- checkWidget();
- if (image == backgroundImage) return;
- if (image != null) {
- gradientColors = null;
- gradientPercents = null;
- }
- backgroundImage = image;
- redraw();
-
- }
- public void setFont(Font font) {
- super.setFont(font);
- redraw();
- }
- /**
- * Set the label's Image.
- * The value <code>null</code> clears it.
- *
- * @param image the image to be displayed in the label or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
- public void setImage(Image image) {
- checkWidget();
- if (image != this.image) {
- this.image = image;
- redraw();
- }
- }
- /**
- * Set the label's text.
- * The value <code>null</code> clears it.
- *
- * @param text the text to be displayed in the label or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
- public void setText(String text) {
- checkWidget();
- if (text == null) text = ""; //$NON-NLS-1$
- if (! text.equals(this.text)) {
- this.text = text;
- redraw();
- }
- }
- public void setToolTipText (String string) {
- super.setToolTipText (string);
- appToolTipText = super.getToolTipText();
- }
- /**
- * Shorten the given text <code>t</code> so that its length doesn't exceed
- * the given width. The default implementation replaces characters in the
- * center of the original string with an ellipsis ("...").
- * Override if you need a different strategy.
- *
- * @param gc the gc to use for text measurement
- * @param t the text to shorten
- * @param width the width to shorten the text to, in pixels
- * @return the shortened text
- */
- protected String shortenText(GC gc, String t, int width) {
- if (t == null) return null;
- int w = gc.textExtent(ELLIPSIS, DRAW_FLAGS).x;
- int l = t.length();
- int pivot = l/2;
- int s = pivot;
- int e = pivot+1;
- while (s >= 0 && e < l) {
- String s1 = t.substring(0, s);
- String s2 = t.substring(e, l);
- int l1 = gc.textExtent(s1, DRAW_FLAGS).x;
- int l2 = gc.textExtent(s2, DRAW_FLAGS).x;
- if (l1+w+l2 < width) {
- t = s1 + ELLIPSIS + s2;
- break;
- }
- s--;
- e++;
- }
- return t;
- }
-
- private String[] splitString(String text) {
- String[] lines = new String[1];
- int start = 0, pos;
- do {
- pos = text.indexOf('\n', start);
- if (pos == -1) {
- lines[lines.length - 1] = text.substring(start);
- } else {
- boolean crlf = (pos > 0) && (text.charAt(pos - 1) == '\r');
- lines[lines.length - 1] = text.substring(start, pos - (crlf ? 1 : 0));
- start = pos + 1;
- String[] newLines = new String[lines.length+1];
- System.arraycopy(lines, 0, newLines, 0, lines.length);
- lines = newLines;
- }
- } while (pos != -1);
- return lines;
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/internal/Day.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/internal/Day.java
deleted file mode 100644
index 3f26267f..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/internal/Day.java
+++ /dev/null
@@ -1,404 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jface.examples.databinding.compositetable.month.internal;
-
-import java.util.Date;
-import java.util.Iterator;
-import java.util.LinkedList;
-
-import org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl;
-import org.eclipse.jface.examples.databinding.compositetable.month.MonthCalendarableItemControl;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-
-/**
- * An SWT custom control representing a single day in a month-mode calendar.
- */
-public class Day extends Canvas implements PaintListener, DisposeListener {
- private final Color FOCUS_RUBBERBAND;
- private Color CURRENT_MONTH;
- private Color OTHER_MONTH;
- private Color CELL_BACKGROUND_LIGHT;
-
- private static final int FOCUS_LINE_WIDTH = 2;
- private boolean focusControl = false;
-
- private static final int _SIZE_MULTIPLIER = 7;
- private Label dayNumber = null;
- private Label spacer = null;
- private Point textBounds;
-
- private Point monthPosition = null;
-
- /**
- * @param parent
- * @param style
- */
- public Day(Composite parent, int style) {
- super(parent, style);
-
- Display display = Display.getCurrent();
- FOCUS_RUBBERBAND = new Color(display, lighten(saturate(display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND).getRGB(), .85f), -.333f));
- CURRENT_MONTH = display.getSystemColor(SWT.COLOR_WHITE);
- OTHER_MONTH = new Color(display, new RGB(230, 230, 230));
- CELL_BACKGROUND_LIGHT = new Color(display, new RGB(248, 248, 248));
-
- initialize();
-
- addTraverseListener(traverseListener);
- addKeyListener(keyListener);
- addMouseListener(mouseListener);
- spacer.addMouseListener(mouseListener);
- dayNumber.addMouseListener(mouseListener);
- addFocusListener(focusListener);
- addPaintListener(this);
- addDisposeListener(this);
- }
-
- /**
- * Sets the color's saturation to the specified value.
- *
- * @param color The RGB of the color
- * @param saturation the new saturation (between 0 and 1)
- * @return a Color that is saturated by the specified amount
- */
- private RGB saturate(RGB color, float saturation) {
- float[] hsb = color.getHSB();
- return new RGB(hsb[0], saturation, hsb[2]);
- }
-
- /**
- * @param color The RGB of the color
- * @param amount The amount to lighten as a percentage expresssed as a float between -1 and 1.
- * @return The new RGB that is lightened by the specified amount
- */
- private RGB lighten(RGB color, float amount) {
- float[] hsb = color.getHSB();
- float b = hsb[2] + hsb[2] * amount;
- if (b < 0) b=0;
- if (b > 1) b=1;
- return new RGB(hsb[0], hsb[1], b);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
- */
- public void widgetDisposed(DisposeEvent e) {
- FOCUS_RUBBERBAND.dispose();
- OTHER_MONTH.dispose();
- CELL_BACKGROUND_LIGHT.dispose();
-
- removeTraverseListener(traverseListener);
- removeKeyListener(keyListener);
- removeMouseListener(mouseListener);
- spacer.removeMouseListener(mouseListener);
- dayNumber.removeMouseListener(mouseListener);
- removeFocusListener(focusListener);
- removePaintListener(this);
- removeDisposeListener(this);
- }
-
- private void initialize() {
- GridData gd = new GridData();
- gd.horizontalSpan = 2;
- gd.verticalAlignment = GridData.FILL;
- gd.grabExcessVerticalSpace = true;
- gd.grabExcessHorizontalSpace = true;
- gd.horizontalAlignment = GridData.FILL;
- GridData gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.grabExcessHorizontalSpace = true;
- gridData.verticalAlignment = GridData.CENTER;
- spacer = new Label(this, SWT.NONE);
- spacer.setLayoutData(gridData);
- spacer.setBackground(Display.getCurrent().getSystemColor(
- SWT.COLOR_LIST_BACKGROUND));
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 2;
- gridLayout.verticalSpacing = 0;
- dayNumber = new Label(this, SWT.NONE);
- dayNumber.setFont(JFaceResources.getFontRegistry().get(
- JFaceResources.BANNER_FONT));
- dayNumber.setBackground(Display.getCurrent().getSystemColor(
- SWT.COLOR_LIST_BACKGROUND));
- dayNumber.setForeground(Display.getCurrent().getSystemColor(
- SWT.COLOR_LIST_SELECTION));
- dayNumber.setText("31");
- textBounds = dayNumber.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- this.setBackground(Display.getCurrent().getSystemColor(
- SWT.COLOR_LIST_BACKGROUND));
- this.setLayout(gridLayout);
- setSize(new org.eclipse.swt.graphics.Point(106, 101));
- setBackground(CELL_BACKGROUND_LIGHT);
- }
-
- public Point computeSize(int wHint, int hHint, boolean changed) {
- Point size = new Point(0, 0);
- size.x = textBounds.x * _SIZE_MULTIPLIER;
- size.y = textBounds.y * _SIZE_MULTIPLIER / 2;
- return size;
- }
-
- /**
- * @return The (day, week) of this day in the month.
- */
- public Point getMonthPosition() {
- return monthPosition;
- }
-
- /**
- * @param monthPosition The (day, week) of this day in the month.
- */
- public void setMonthPosition(Point monthPosition) {
- this.monthPosition = monthPosition;
- }
-
- /**
- * @return The day's number
- */
- public int getDayNumber() {
- return Integer.parseInt(dayNumber.getText());
- }
-
- /**
- * @param dayNum the day number to set
- */
- public void setDayNumber(int dayNum) {
- dayNumber.setText(Integer.toString(dayNum));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events.PaintEvent)
- */
- public void paintControl(PaintEvent e) {
- GC gc = e.gc;
-
- // Save stuff we're about to change so we can restore it later
- int oldLineStyle = gc.getLineStyle();
- int oldLineWidth = gc.getLineWidth();
-
- // Draw focus rubberband if we're focused
- try {
- if (focusControl) {
- gc.setLineStyle(SWT.LINE_DASH);
- gc.setLineWidth(FOCUS_LINE_WIDTH);
- gc.setForeground(FOCUS_RUBBERBAND);
- Point parentSize = getSize();
- gc.drawRectangle(FOCUS_LINE_WIDTH,
- FOCUS_LINE_WIDTH, parentSize.x - 4,
- parentSize.y - 3);
- }
- } finally {
- gc.setLineStyle(oldLineStyle);
- gc.setLineWidth(oldLineWidth);
- }
- }
-
- private LinkedList mouseListeners = new LinkedList();
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.widgets.Control#addMouseListener(org.eclipse.swt.events.MouseListener)
- */
- public void addMouseListener(MouseListener listener) {
- super.addMouseListener(listener);
- if (listener != mouseListener) mouseListeners.add(listener);
- }
-
- public void removeMouseListener(MouseListener listener) {
- super.removeMouseListener(listener);
- if (listener != mouseListener) mouseListeners.remove(listener);
- }
-
- private MouseListener mouseListener = new MouseListener() {
- public void mouseDown(MouseEvent e) {
- setFocus();
- for (Iterator i = mouseListeners.iterator(); i.hasNext();) {
- MouseListener listener = (MouseListener) i.next();
- listener.mouseDown(e);
- }
- }
- public void mouseUp(MouseEvent e) {
- for (Iterator i = mouseListeners.iterator(); i.hasNext();) {
- MouseListener listener = (MouseListener) i.next();
- listener.mouseUp(e);
- }
- }
- public void mouseDoubleClick(MouseEvent e) {
- for (Iterator i = mouseListeners.iterator(); i.hasNext();) {
- MouseListener listener = (MouseListener) i.next();
- listener.mouseDoubleClick(e);
- }
- }
- };
-
- private KeyListener keyListener = new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- switch (e.keyCode) {
- case SWT.ARROW_LEFT:
- if (monthPosition.x > 0) {
- traverse(SWT.TRAVERSE_TAB_PREVIOUS);
- }
- return;
- case SWT.ARROW_RIGHT:
- if (monthPosition.x < 6) {
- traverse(SWT.TRAVERSE_TAB_NEXT);
- }
- return;
- case SWT.TAB:
- if ((e.stateMask & SWT.SHIFT) != 0) {
- traverse(SWT.TRAVERSE_TAB_PREVIOUS);
- return;
- }
- traverse(SWT.TRAVERSE_TAB_NEXT);
- return;
- }
- }
- };
-
- /**
- * Permit focus events via keyboard.
- */
- private TraverseListener traverseListener = new TraverseListener() {
- public void keyTraversed(TraverseEvent e) {
- // NOOP: this just lets us receive focus from SWT
- }
- };
-
- /**
- * When we gain/lose focus, redraw ourselves appropriately
- */
- private FocusListener focusListener = new FocusListener() {
- public void focusGained(FocusEvent e) {
- focusControl = true;
- Color background = getBackgroundTakingIntoAccountIfWeAreInTheCurrentMonth(true);
- resetAllBackgrounds(Day.this, background);
- redraw();
- }
-
- public void focusLost(FocusEvent e) {
- focusControl = false;
- Color background = getBackgroundTakingIntoAccountIfWeAreInTheCurrentMonth(false);
- resetAllBackgrounds(Day.this, background);
- redraw();
- }
- };
-
- private void resetAllBackgrounds(Composite composite, Color color) {
- composite.setBackground(color);
- Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; i++) {
- if (children[i] instanceof Composite) {
- resetAllBackgrounds((Composite) children[i], color);
- } else {
- children[i].setBackground(color);
- }
- }
- }
-
- private Color getBackgroundTakingIntoAccountIfWeAreInTheCurrentMonth(boolean focused) {
- if (inCurrentMonth && focused) {
- return CURRENT_MONTH;
- }
- if (inCurrentMonth) {
- return CELL_BACKGROUND_LIGHT;
- }
- return OTHER_MONTH;
- }
-
- private boolean inCurrentMonth = false;
-
- /**
- * @param inCurrentMonth
- */
- public void setInCurrentMonth(boolean inCurrentMonth) {
- this.inCurrentMonth = inCurrentMonth;
- Color background = getBackgroundTakingIntoAccountIfWeAreInTheCurrentMonth(false);
- resetAllBackgrounds(this, background);
- }
-
- private CalendarableItem[] controls = null;
-
- /**
- * @param controls
- */
- public void setItems(CalendarableItem[] controls) {
- if (this.controls != null) {
- for (int i = 0; i < this.controls.length; i++) {
- ICalendarableItemControl control = this.controls[i].getControl();
- control.removeMouseListener(mouseListener);
- control.dispose();
- }
- }
- this.controls = controls;
- for (int i = 0; i < this.controls.length; i++) {
- MonthCalendarableItemControl control = new MonthCalendarableItemControl(this, SWT.NULL);
- getBackgroundTakingIntoAccountIfWeAreInTheCurrentMonth(false);
- control.setText(this.controls[i].getText());
- Image image = this.controls[i].getImage();
- if (image != null) {
- control.setImage(image);
- }
- control.setToolTipText(this.controls[i].getToolTipText());
- control.addMouseListener(mouseListener);
- GridData gd = new GridData(SWT.FILL, SWT.TOP, true, false);
- gd.horizontalSpan=2;
- control.setLayoutData(gd);
- this.controls[i].setControl(control);
- }
- }
-
- private Date date;
-
- /**
- * Sets the Date represented by this Day.
- *
- * @param date The date to set
- */
- public void setDate(Date date) {
- this.date = date;
- }
-
- /**
- * Returns the Date represented by this Day.
- *
- * @return This Day's date
- */
- public Date getDate() {
- return date;
- }
-
-} // @jve:decl-index=0:visual-constraint="10,10"
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/internal/Week.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/internal/Week.java
deleted file mode 100644
index bde80a38..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/internal/Week.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2005 David Orme <djo@coconut-palm-software.com>
- *
- * 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:
- * David Orme - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.compositetable.month.internal;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @since 3.2
- */
-public class Week extends Composite {
-
- private final Day[] days;
-
- /**
- * @param parent
- * @param style
- */
- public Week(Composite parent, int style) {
- super(parent, style);
- initialize();
- this.days = new Day[] {createDay(), createDay(), createDay(),
- createDay(), createDay(), createDay(), createDay()};
- }
-
- private void initialize() {
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 7;
- gridLayout.horizontalSpacing = 1;
- gridLayout.verticalSpacing = 1;
- gridLayout.marginHeight = 0;
- gridLayout.marginWidth = 0;
- gridLayout.makeColumnsEqualWidth = true;
- this.setLayout(gridLayout);
-// this.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND));
- this.setSize(new Point(870, 158));
- }
-
- /**
- * This method initializes day
- */
- private Day createDay() {
- GridData gd = new GridData();
- gd.horizontalAlignment = GridData.FILL;
- gd.grabExcessHorizontalSpace = true;
- gd.verticalAlignment = GridData.FILL;
- gd.grabExcessVerticalSpace = true;
- Day day = new Day(this, SWT.NONE);
- day.setLayoutData(gd);
- return day;
- }
-
- /**
- * Return a particular day in this week.
- *
- * @param dayNumber 0-based day number
- * @return The day corresponding to dayNumber
- */
- public Day getDay(int dayNumber) {
- return days[dayNumber];
- }
-
-} // @jve:decl-index=0:visual-constraint="8,13"
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/internal/WeekHeader.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/internal/WeekHeader.java
deleted file mode 100644
index ca9bd6a3..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/month/internal/WeekHeader.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2005 David Orme <djo@coconut-palm-software.com>
- *
- * 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:
- * David Orme - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.compositetable.month.internal;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.layout.GridData;
-
-public class WeekHeader extends Composite {
-
- private Label label = null;
- private Label label1 = null;
- private Label label2 = null;
- private Label label3 = null;
- private Label label4 = null;
- private Label label5 = null;
- private Label label6 = null;
-
- public WeekHeader(Composite parent, int style) {
- super(parent, style);
- initialize();
- }
-
- /**
- * This method initializes this
- *
- */
- private void initialize() {
- this.setSize(new org.eclipse.swt.graphics.Point(536, 54));
- GridData gridData6 = new GridData();
- gridData6.horizontalAlignment = GridData.FILL;
- gridData6.grabExcessHorizontalSpace = true;
- gridData6.verticalAlignment = GridData.CENTER;
- GridData gridData5 = new GridData();
- gridData5.horizontalAlignment = GridData.FILL;
- gridData5.grabExcessHorizontalSpace = true;
- gridData5.verticalAlignment = GridData.CENTER;
- GridData gridData4 = new GridData();
- gridData4.horizontalAlignment = GridData.FILL;
- gridData4.grabExcessHorizontalSpace = true;
- gridData4.verticalAlignment = GridData.CENTER;
- GridData gridData3 = new GridData();
- gridData3.horizontalAlignment = GridData.FILL;
- gridData3.grabExcessHorizontalSpace = true;
- gridData3.verticalAlignment = GridData.CENTER;
- GridData gridData2 = new GridData();
- gridData2.horizontalAlignment = GridData.FILL;
- gridData2.grabExcessHorizontalSpace = true;
- gridData2.verticalAlignment = GridData.CENTER;
- GridData gridData1 = new GridData();
- gridData1.horizontalAlignment = GridData.FILL;
- gridData1.grabExcessHorizontalSpace = true;
- gridData1.verticalAlignment = GridData.CENTER;
- GridData gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.grabExcessHorizontalSpace = true;
- gridData.verticalAlignment = GridData.CENTER;
- setLayout(new GridLayout(7, true));
- label = new Label(this, SWT.CENTER);
- label.setBounds(new org.eclipse.swt.graphics.Rectangle(23, 18, 53, 18));
- label.setLayoutData(gridData6);
- label.setText("Sunday");
- label1 = new Label(this, SWT.CENTER);
- label1
- .setBounds(new org.eclipse.swt.graphics.Rectangle(98, 18, 79,
- 17));
- label1.setLayoutData(gridData5);
- label1.setText("Monday");
- label2 = new Label(this, SWT.CENTER);
- label2
- .setBounds(new org.eclipse.swt.graphics.Rectangle(187, 18, 47,
- 17));
- label2.setLayoutData(gridData4);
- label2.setText("Tuesday");
- label3 = new Label(this, SWT.CENTER);
- label3
- .setBounds(new org.eclipse.swt.graphics.Rectangle(256, 17, 67,
- 17));
- label3.setLayoutData(gridData3);
- label3.setText("Wednesday");
- label4 = new Label(this, SWT.CENTER);
- label4
- .setBounds(new org.eclipse.swt.graphics.Rectangle(338, 17, 62,
- 20));
- label4.setLayoutData(gridData2);
- label4.setText("Thursday");
- label5 = new Label(this, SWT.CENTER);
- label5
- .setBounds(new org.eclipse.swt.graphics.Rectangle(415, 16, 43,
- 21));
- label5.setLayoutData(gridData1);
- label5.setText("Friday");
- label6 = new Label(this, SWT.CENTER);
- label6
- .setBounds(new org.eclipse.swt.graphics.Rectangle(469, 16, 61,
- 23));
- label6.setLayoutData(gridData);
- label6.setText("Saturday");
-
- }
-
-} // @jve:decl-index=0:visual-constraint="11,16"
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/reflect/DuckType.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/reflect/DuckType.java
deleted file mode 100644
index 423f574e..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/reflect/DuckType.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.compositetable.reflect;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-
-/**
- * DuckType. Implements Duck Typing for Java. ("If it walks like a duck,
- * quacks like a duck, it..."). Essentially allows programs to treat
- * objects from separate hierarchies as if they were designed with common
- * interfaces as long as they adhere to common naming conventions.
- * <p>
- * This version is the strict DuckType. All methods present in
- * interfaceToImplement must be present on the target object.
- *
- * @author djo
- */
-public class DuckType implements InvocationHandler {
-
- /**
- * Interface DuckType#Wrapper. An interface for DuckType proxies that
- * allows clients to access the proxied value. The value returned by
- * calling DuckType#implement always implements this interface.
- */
- public static interface Wrapper {
- /**
- * Method duckType_GetWrappedValue. Returns the proxied value.
- *
- * @return The proxied value.
- */
- public Object duckType_GetWrappedValue();
- }
-
- /**
- * Causes object to implement the interfaceToImplement and returns
- * an instance of the object implementing interfaceToImplement even
- * if interfaceToImplement was not declared in object.getClass()'s
- * implements declaration.<p>
- *
- * This works as long as all methods declared in interfaceToImplement
- * are present on object.
- *
- * @param interfaceToImplement The Java class of the interface to implement
- * @param object The object to force to implement interfaceToImplement
- * @return object, but now implementing interfaceToImplement
- */
- public static Object implement(Class interfaceToImplement, Object object) {
- return Proxy.newProxyInstance(interfaceToImplement.getClassLoader(),
- new Class[] {interfaceToImplement, Wrapper.class}, new DuckType(object));
- }
-
- /**
- * Indicates if object is a (DuckType) instace of intrface. That is,
- * is every method in intrface present on object.
- *
- * @param intrface The interface to implement
- * @param object The object to test
- * @return true if every method in intrface is present on object. false otherwise
- */
- public static boolean instanceOf(Class intrface, Object object) {
- final Method[] methods = intrface.getMethods();
- Class candclass=object.getClass();
- for (int methodidx = 0; methodidx < methods.length; methodidx++) {
- Method method=methods[methodidx];
- try {
- candclass.getMethod(method.getName(), method.getParameterTypes());
- } catch (NoSuchMethodException e) {
- return false;
- }
- }
- return true;
- }
-
- protected DuckType(Object object) {
- this.object = object;
- this.objectClass = object.getClass();
- }
-
- protected Object object;
- protected Class objectClass;
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- if (method.getName().equals("equals") && args != null && args.length == 1) {
- return new Boolean(equals(args[0]));
- }
- if (method.getName().equals("hashCode") && args == null) {
- return new Integer(hashCode());
- }
- if (method.getName().equals("duckType_GetWrappedValue") && args == null) {
- return object;
- }
- Method realMethod = objectClass.getMethod(method.getName(), method.getParameterTypes());
- if (!realMethod.isAccessible()) {
- realMethod.setAccessible(true);
- }
- return realMethod.invoke(object, args);
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof Wrapper) {
- Wrapper proxy = (Wrapper) obj;
- Object wrappedValue = proxy.duckType_GetWrappedValue();
- return wrappedValue.equals(object);
- }
- return obj == this || super.equals(obj) || object.equals(obj);
- }
-
- public int hashCode() {
- return object.hashCode();
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/reflect/ReflectedMethod.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/reflect/ReflectedMethod.java
deleted file mode 100644
index 0e756b91..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/reflect/ReflectedMethod.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.compositetable.reflect;
-
-import java.lang.reflect.Method;
-
-/**
- * ReflectedMethod. Encapsulates a method that may or may not exist on
- * some receiver. Invocation policy is that if the method can be invoked,
- * it is. On failure, returns null.
- *
- * @author djo
- */
-public class ReflectedMethod {
-
- private Object subject;
- private Method method;
-
- /**
- * Constructor ReflectedMethod. Create a ReflectedMethod object.
- *
- * @param subject The object on which the method lives.
- * @param methodName The name of the method.
- * @param paramTypes The method's parameter types.
- */
- public ReflectedMethod(Object subject, String methodName, Class[] paramTypes) {
- this.subject = subject;
- method = null;
- try {
- method = subject.getClass().getMethod(methodName, paramTypes);
- } catch (Exception e) {
- System.out.println(e);
- }
- }
-
- /**
- * Method exists. Returns true if the underlying method exists, false
- * otherwise.
- *
- * @return true if the underlying method exists, false otherwise.
- */
- public boolean exists() {
- return method != null;
- }
-
- /**
- * Method invoke. If possible, invoke the encapsulated method with the
- * specified parameters.
- *
- * @param params An Object[] containing the parameters to pass.
- * @return any return value or null if there was no return value or an
- * error occured.
- */
- public Object invoke(Object[] params) {
- if (method == null)
- return null;
- try {
- if (!method.isAccessible()) {
- method.setAccessible(true);
- }
- return method.invoke(subject, params);
- } catch (Exception e) {
- return null;
- }
- }
-
- /**
- * Method getType. Returns the return type of the method.
- *
- * @return The return type or null if none.
- */
- public Class getType() {
- return method.getReturnType();
- }
-}
-
-
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/reflect/ReflectedProperty.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/reflect/ReflectedProperty.java
deleted file mode 100644
index 901e0c78..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/reflect/ReflectedProperty.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable.reflect;
-
-/**
- * Encapsulates a single JavaBeans-style property
- *
- * @since 3.3
- */
-public class ReflectedProperty {
- private String propertyName;
- private ReflectedMethod getter;
- private ReflectedMethod setter;
-
- /**
- * Construct a ReflectedProperty on some object, given the property name.
- *
- * @param object The object
- * @param propertyName The property name
- */
- public ReflectedProperty(Object object, String propertyName) {
- this.propertyName = propertyName;
- getter = new ReflectedMethod(object, makeGetterName(propertyName), new Class[] {});
- if (!getter.exists()) {
- getter = new ReflectedMethod(object, makeBooleanGetterName(propertyName), new Class[] {});
- if (!getter.exists()) {
- throw new IllegalArgumentException("Cannot find getter for " + propertyName);
- }
- }
- setter = new ReflectedMethod(object, makeSetterName(propertyName), new Class[] {getter.getType()});
- }
-
- private String makeBooleanGetterName(String propertyName) {
- return "is" + capitalize(propertyName);
- }
-
- private String makeSetterName(String propertyName) {
- return "set" + capitalize(propertyName);
- }
-
- private String makeGetterName(String propertyName) {
- return "get" + capitalize(propertyName);
- }
-
- private String capitalize(String string) {
- return string.substring(0, 1).toUpperCase() + string.substring(1);
- }
-
- /**
- * Return the property's type. This is the same as the type returned by
- * the getter.
- *
- * @return The property's data type.
- */
- public Class getType() {
- return getter.getType();
- }
-
- /**
- * Return the property's value.
- *
- * @return The value in the property.
- */
- public Object get() {
- return getter.invoke(new Object[] {});
- }
-
- /**
- * Set the property's value. If the property is read-only, the request
- * is ignored.
- *
- * @param newValue The value to set.
- */
- public void set(Object newValue) {
- setter.invoke(new Object[] {newValue});
- }
-
- /**
- * Returns if the property is read-only.
- *
- * @return false if the property has a setter; true otherwise.
- */
- public boolean isReadOnly() {
- return !setter.exists();
- }
-
- /**
- * Returns the property's name.
- *
- * @return The property name.
- */
- public String getPropertyName() {
- return propertyName;
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/reflect/RelaxedDuckType.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/reflect/RelaxedDuckType.java
deleted file mode 100644
index a5b03e58..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/reflect/RelaxedDuckType.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
- *
- * 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:
- * db4objects - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.compositetable.reflect;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.HashMap;
-
-/**
- * RelaxedDuckType. Implements Duck Typing for Java. ("If it walks like a duck,
- * quacks like a duck, it..."). Essentially allows programs to treat
- * objects from separate hierarchies as if they were designed with common
- * interfaces as long as they adhere to common naming conventions.
- * <p>
- * This version is the relaxed DuckType. If a method in the interface is
- * not present on the underlying object, the proxy simply returns null.
- *
- * @author djo
- */
-public class RelaxedDuckType extends DuckType implements InvocationHandler {
-
- public static Object implement(Class interfaceToImplement, Object object) {
- return Proxy.newProxyInstance(interfaceToImplement.getClassLoader(),
- new Class[] {interfaceToImplement}, new RelaxedDuckType(object));
- }
-
- public static boolean includes(Object object, String method, Class[] args) {
- try {
- object.getClass().getMethod(method, args);
- } catch (NoSuchMethodException e) {
- return false;
- }
- return true;
- }
-
- private static final HashMap NULL_VALUES = new HashMap(); {
- NULL_VALUES.put(Boolean.TYPE, Boolean.FALSE);
- NULL_VALUES.put(Integer.TYPE, new Integer(0));
- NULL_VALUES.put(Float.TYPE, new Float(0));
- NULL_VALUES.put(Long.TYPE, new Long(0));
- NULL_VALUES.put(Double.TYPE, new Double(0));
- NULL_VALUES.put(Character.TYPE, new Character(' '));
- }
-
- protected RelaxedDuckType(Object object) {
- super(object);
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- try {
- Method realMethod = objectClass.getMethod(method.getName(), method.getParameterTypes());
- return realMethod.invoke(object, args);
- } catch (NoSuchMethodException e) {
- return NULL_VALUES.get(method.getReturnType());
- } catch (Throwable t) {
- throw t;
- }
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/CompositeTableTest.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/CompositeTableTest.java
deleted file mode 100644
index 75d255f0..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/CompositeTableTest.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (C) 2005 David Orme <djo@coconut-palm-software.com>
- *
- * 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:
- * David Orme - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.compositetable.test;
-
-import java.util.LinkedList;
-
-import org.eclipse.jface.examples.databinding.compositetable.CompositeTable;
-import org.eclipse.jface.examples.databinding.compositetable.IDeleteHandler;
-import org.eclipse.jface.examples.databinding.compositetable.IInsertHandler;
-import org.eclipse.jface.examples.databinding.compositetable.IRowContentProvider;
-import org.eclipse.jface.examples.databinding.compositetable.IRowFocusListener;
-import org.eclipse.jface.examples.databinding.compositetable.ScrollEvent;
-import org.eclipse.jface.examples.databinding.compositetable.ScrollListener;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.2
- *
- */
-public class CompositeTableTest {
-
- private Shell sShell = null; // @jve:decl-index=0:visual-constraint="10,10"
- private CompositeTable table = null;
-
- private LinkedList personList = new LinkedList();
-
- /**
- *
- */
- public CompositeTableTest() {
- personList.add(new Person("John", "1234", "Wheaton", "IL"));
- personList.add(new Person("Jane", "1234", "Wheaton", "IL"));
- personList.add(new Person("Frank", "1234", "Wheaton", "IL"));
- personList.add(new Person("Joe", "1234", "Wheaton", "IL"));
- personList.add(new Person("Chet", "1234", "Wheaton", "IL"));
- personList.add(new Person("Jane", "1234", "Wheaton", "IL"));
- personList.add(new Person("Frank", "1234", "Wheaton", "IL"));
- personList.add(new Person("Joe", "1234", "Wheaton", "IL"));
- personList.add(new Person("Chet", "1234", "Wheaton", "IL"));
- personList.add(new Person("Jane", "1234", "Wheaton", "IL"));
- personList.add(new Person("Frank", "1234", "Wheaton", "IL"));
- personList.add(new Person("Joe", "1234", "Wheaton", "IL"));
- personList.add(new Person("Chet", "1234", "Wheaton", "IL"));
- personList.add(new Person("Jane", "1234", "Wheaton", "IL"));
- personList.add(new Person("Frank", "1234", "Wheaton", "IL"));
- personList.add(new Person("Joe", "1234", "Wheaton", "IL"));
- personList.add(new Person("Chet", "1234", "Wheaton", "IL"));
- personList.add(new Person("Wilbur", "1234", "Wheaton", "IL"));
- personList.add(new Person("Elmo", "1234", "Wheaton", "IL"));
- }
-
- /**
- * This method initializes multiRowViewer
- *
- */
- private void createCompositeTable() {
- table = new CompositeTable(sShell, SWT.NONE);
- table.setRunTime(true);
- table.setWeights(new int[] {100, 100, 80, 40});
- table.setFittingHorizontally(false);
-// table.setWeights(new int[] {30, 30, 30, 10});
-// table.setFittingHorizontally(true);
- table.addRowContentProvider(rowContentProvider);
- table.addDeleteHandler(deleteHandler);
- table.addInsertHandler(insertHandler);
- table.addRowFocusListener(rowListener);
- table.addScrollListener(scrollListener);
- table.setNumRowsInCollection(personList.size());
- createHeader();
- createRow();
- }
-
- private ScrollListener scrollListener = new ScrollListener() {
- public void tableScrolled(ScrollEvent scrollEvent) {
- System.out.println(scrollEvent);
- }
- };
-
- private IRowContentProvider rowContentProvider = new IRowContentProvider() {
- public void refresh(CompositeTable table, int currentObjectOffset, Control row) {
- Row rowObj = (Row) row;
- Person person = (Person)personList.get(currentObjectOffset);
- rowObj.name.setText(person.name);
- rowObj.address.setText(person.address);
- rowObj.city.setText(person.city);
- rowObj.state.setText(person.state);
- }
- };
-
- private IDeleteHandler deleteHandler = new IDeleteHandler() {
- public boolean canDelete(int rowInCollection) {
- return true;
- }
- public void deleteRow(int rowInCollection) {
- personList.remove(rowInCollection);
- }
- };
-
- private IInsertHandler insertHandler = new IInsertHandler() {
- public int insert(int positionHint) {
- Person newPerson = new Person();
- personList.add(positionHint, newPerson);
- return positionHint;
-// int newPosition = (int)(Math.random() * (personList.size()+1));
-// personList.add(newPosition, newPerson);
-// return newPosition;
- }
- };
-
- private IRowFocusListener rowListener = new IRowFocusListener() {
- public boolean requestRowChange(CompositeTable sender, int currentObjectOffset, Control row) {
- System.out.println("requestRC");
- return true;
- }
- public void depart(CompositeTable sender, int currentObjectOffset, Control row) {
- System.out.println("depart");
- Person person = (Person)personList.get(currentObjectOffset);
- Row rowObj = (Row) row;
- person.name = rowObj.name.getText();
- person.address = rowObj.address.getText();
- person.city = rowObj.city.getText();
- person.state = rowObj.state.getText();
- }
- public void arrive(CompositeTable sender, int currentObjectOffset, Control row) {
- System.out.println("arrive");
- }
- };
-
- /**
- * This method initializes header
- *
- */
- private void createHeader() {
- new Header(table, SWT.NONE);
- }
-
- /**
- * This method initializes row
- *
- */
- private void createRow() {
- new Row(table, SWT.NONE);
- }
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Display display = Display.getDefault();
- CompositeTableTest thisClass = new CompositeTableTest();
- thisClass.createSShell();
- thisClass.sShell.open();
-
- while (!thisClass.sShell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
-
- /**
- * This method initializes sShell
- */
- private void createSShell() {
- sShell = new Shell();
- sShell.setText("Shell");
- sShell.setLayout(new FillLayout());
- createCompositeTable();
- sShell.setSize(new org.eclipse.swt.graphics.Point(445,243));
- }
-
-} \ No newline at end of file
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/CompositeTableTestBinding.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/CompositeTableTestBinding.java
deleted file mode 100644
index 98622dfa..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/CompositeTableTestBinding.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2005 David Orme <djo@coconut-palm-software.com>
- *
- * 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:
- * David Orme - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.compositetable.test;
-
-import java.util.List;
-
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.databinding.observable.list.WritableList;
-import org.eclipse.jface.examples.databinding.DataBindingFactory1;
-import org.eclipse.jface.examples.databinding.compositetable.CompositeTable;
-import org.eclipse.jface.examples.databinding.compositetable.binding.CompositeTableObservableLazyDataRequestor;
-import org.eclipse.jface.examples.databinding.compositetable.binding.IRowBinder;
-import org.eclipse.jface.internal.databinding.provisional.BindSpec;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyDeleteEvent;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertDeleteProvider;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertEvent;
-import org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor.NewObject;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.2
- *
- */
-public class CompositeTableTestBinding {
-
- private Shell sShell = null; // @jve:decl-index=0:visual-constraint="10,10"
- private CompositeTable table = null;
-
- private List personList = new WritableList();
-
- /**
- *
- */
- public CompositeTableTestBinding() {
- personList.add(new Person("John", "1234", "Wheaton", "IL"));
- personList.add(new Person("Jane", "1234", "Wheaton", "IL"));
- personList.add(new Person("Frank", "1234", "Wheaton", "IL"));
- personList.add(new Person("Joe", "1234", "Wheaton", "IL"));
- personList.add(new Person("Chet", "1234", "Wheaton", "IL"));
- personList.add(new Person("Jane", "1234", "Wheaton", "IL"));
- personList.add(new Person("Frank", "1234", "Wheaton", "IL"));
- personList.add(new Person("Joe", "1234", "Wheaton", "IL"));
- personList.add(new Person("Chet", "1234", "Wheaton", "IL"));
- personList.add(new Person("Jane", "1234", "Wheaton", "IL"));
- personList.add(new Person("Frank", "1234", "Wheaton", "IL"));
- personList.add(new Person("Joe", "1234", "Wheaton", "IL"));
- personList.add(new Person("Chet", "1234", "Wheaton", "IL"));
- personList.add(new Person("Jane", "1234", "Wheaton", "IL"));
- personList.add(new Person("Frank", "1234", "Wheaton", "IL"));
- personList.add(new Person("Joe", "1234", "Wheaton", "IL"));
- personList.add(new Person("Chet", "1234", "Wheaton", "IL"));
- personList.add(new Person("Wilbur", "1234", "Wheaton", "IL"));
- personList.add(new Person("Elmo", "1234", "Wheaton", "IL"));
- }
-
- private void createSShell() {
- sShell = new Shell();
- sShell.setText("Shell");
- sShell.setLayout(new FillLayout());
- sShell.setSize(new Point(445,243));
- table = new CompositeTable(sShell, SWT.NONE);
- table.setRunTime(true);
-// table.setWeights(new int[] {35, 35, 20, 10});
- table.setWeights(new int[] {200, 200, 100, 50});
- table.setFittingHorizontally(false);
- table.setTraverseOnTabsEnabled(true);
- new Header(table, SWT.NONE);
- new Row(table, SWT.NONE);
- bindGUI(sShell);
- }
-
- private void bindGUI(Shell shell) {
- DataBindingContext bindingContext = new DataBindingFactory1().createContext(shell);
-
- LazyInsertDeleteProvider insertDeleteProvider = new LazyInsertDeleteProvider() {
- public boolean canDeleteElementAt(LazyDeleteEvent e) {
- return true;
- }
-
- public void deleteElementAt(LazyDeleteEvent e) {
- personList.remove(e.position);
- }
-
- public NewObject insertElementAt(LazyInsertEvent e) {
- Person newPerson = new Person();
- personList.add(e.positionHint, newPerson);
- return new NewObject(e.positionHint, newPerson);
-// int newPosition = (int)(Math.random() * (personList.size()+1));
-// personList.add(newPosition, newPerson);
-// return newPosition;
- }
- };
-
- IRowBinder rowBinder = new IRowBinder() {
- public void bindRow(DataBindingContext context, Control row, Object object) {
- Row rowObj = (Row) row;
- context.bind(rowObj.name, new Property(object, "name"), null);
- context.bind(rowObj.address, new Property(object, "address"), null);
- context.bind(rowObj.city, new Property(object, "city"), null);
- context.bind(rowObj.state, new Property(object, "state"), null);
- }
- };
- CompositeTableObservableLazyDataRequestor tableObservable =
- new CompositeTableObservableLazyDataRequestor(bindingContext, table, rowBinder);
-
- bindingContext.bind(tableObservable, (IObservable)personList,
- new BindSpec().setLazyInsertDeleteProvider(insertDeleteProvider));
- }
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Display display = Display.getDefault();
- CompositeTableTestBinding thisClass = new CompositeTableTestBinding();
- thisClass.createSShell();
- thisClass.sShell.open();
-
- while (!thisClass.sShell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/Header.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/Header.java
deleted file mode 100644
index 505d5bf0..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/Header.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2005 David Orme <djo@coconut-palm-software.com>
- *
- * 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:
- * David Orme - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.compositetable.test;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-
-public class Header extends Composite {
-
- private Label label = null;
- private Label label1 = null;
- private Label label2 = null;
- private Label label3 = null;
-
- public Header(Composite parent, int style) {
- super(parent, style);
- initialize();
- }
-
- /**
- * This method initializes this
- *
- */
- private void initialize() {
- this.setSize(new org.eclipse.swt.graphics.Point(313,54));
- label = new Label(this, SWT.NONE);
- label.setBounds(new org.eclipse.swt.graphics.Rectangle(23,18,53,18));
- label.setText("Name");
- label1 = new Label(this, SWT.NONE);
- label1.setBounds(new org.eclipse.swt.graphics.Rectangle(98,18,79,17));
- label1.setText("Address");
- label2 = new Label(this, SWT.NONE);
- label2.setBounds(new org.eclipse.swt.graphics.Rectangle(199,18,35,17));
- label2.setText("City");
- label3 = new Label(this, SWT.NONE);
- label3.setBounds(new org.eclipse.swt.graphics.Rectangle(256,17,35,17));
- label3.setText("State");
-
- }
-
-} // @jve:decl-index=0:visual-constraint="11,16"
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/Model.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/Model.java
deleted file mode 100644
index 8f92594b..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/Model.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2005 David Orme <djo@coconut-palm-software.com>
- *
- * 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:
- * David Orme - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.compositetable.test;
-
-import java.util.LinkedList;
-
-import org.eclipse.jface.examples.databinding.compositetable.IDeleteHandler;
-import org.eclipse.jface.examples.databinding.compositetable.IInsertHandler;
-
-public class Model {
- public Model() {
- // Add some sample data to our personList...
-// personList.add(new Person("John", "1234", "Wheaton", "IL"));
-// personList.add(new Person("Jane", "1234", "Wheaton", "IL"));
-// personList.add(new Person("Frank", "1234", "Wheaton", "IL"));
-// personList.add(new Person("Joe", "1234", "Wheaton", "IL"));
-// personList.add(new Person("Chet", "1234", "Wheaton", "IL"));
-// personList.add(new Person("Wilbur", "1234", "Wheaton", "IL"));
-// personList.add(new Person("Elmo", "1234", "Wheaton", "IL"));
- }
-
- // Now a PersonList property...
-
- LinkedList personList = new LinkedList();
-
- public LinkedList getPersonList() {
- return personList;
- }
-
- public IDeleteHandler getPersonListDeleteHandler() {
- return new IDeleteHandler() {
- public boolean canDelete(int rowInCollection) {
- return true;
- }
-
- public void deleteRow(int rowInCollection) {
- personList.remove(rowInCollection);
- }
- };
- }
-
- public IInsertHandler getPersonListInsertHandler() {
- return new IInsertHandler() {
- public int insert(int positionHint) {
- Person newPerson = new Person();
- personList.add(positionHint, newPerson);
- return positionHint;
- // int newPosition = (int)(Math.random() *
- // (personList.size()+1));
- // personList.add(newPosition, newPerson);
- // return newPosition;
- }
- };
- }
-} \ No newline at end of file
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/Person.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/Person.java
deleted file mode 100644
index 48615ec6..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/Person.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2005 David Orme <djo@coconut-palm-software.com>
- *
- * 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:
- * David Orme - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.compositetable.test;
-
-public class Person {
-
- public String name = "";
- public String address = "";
- public String city = "Wheaton";
- public String state = "IL";
-
- public Person(String name, String address, String city, String state) {
- this.name = name;
- this.address = address;
- this.city = city;
- this.state = state;
- }
-
- public Person() {}
-
- public String getAddress() {
- return address;
- }
-
- public void setAddress(String address) {
- this.address = address;
- }
-
- public String getCity() {
- return city;
- }
-
- public void setCity(String city) {
- this.city = city;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getState() {
- return state;
- }
-
- public void setState(String state) {
- this.state = state;
- }
-
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/Row.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/Row.java
deleted file mode 100644
index 8913964e..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/Row.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2005 David Orme <djo@coconut-palm-software.com>
- *
- * 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:
- * David Orme - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.compositetable.test;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
-
-public class Row extends Composite {
-
- public Text name = null;
- public Text address = null;
- public Text city = null;
- public Text state = null;
-
- public Row(Composite parent, int style) {
- super(parent, style);
- initialize();
- }
-
- private void initialize() {
- this.setSize(new org.eclipse.swt.graphics.Point(131,52));
- name = new Text(this, SWT.NONE);
- name.setBounds(new org.eclipse.swt.graphics.Rectangle(12,12,10,25));
- address = new Text(this, SWT.NONE);
- address.setBounds(new org.eclipse.swt.graphics.Rectangle(43,12,10,25));
- city = new Text(this, SWT.NONE);
- city.setBounds(new org.eclipse.swt.graphics.Rectangle(75,14,10,25));
- state = new Text(this, SWT.NONE);
- state.setBounds(new org.eclipse.swt.graphics.Rectangle(109,16,10,25));
- }
-
-} // @jve:decl-index=0:visual-constraint="10,10"
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/Snippet004CompositeTable.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/Snippet004CompositeTable.java
deleted file mode 100644
index b3bf8772..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/test/Snippet004CompositeTable.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef, Inc. 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:
- * The Pampered Chef, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable.test;
-
-import org.eclipse.jface.examples.databinding.DataBindingFactory1;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Hello, databinding. Bind changes in a GUI to a Model object but don't worry
- * about propogating changes from the Model to the GUI.
- * <p>
- * Illustrates the basic Model-ViewModel-Binding-View architecture typically
- * used in data binding applications.
- */
-public class Snippet004CompositeTable {
- public static void main(String[] args) {
- ViewModel viewModel = new ViewModel();
- Shell shell = new View(viewModel).createShell();
-
- // The SWT event loop
- Display display = Display.getCurrent();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
-
- // Print the results
- System.out.println("person.getName() = " + viewModel.getPerson().getName());
- }
-
- // The data model class. This is normally a persistent class of some sort.
- //
- // In this example, we only push changes from the GUI to the model, so we
- // don't worry about implementing JavaBeans bound properties. If we need
- // our GUI to automatically reflect changes in the Person object, the
- // Person object would need to implement the JavaBeans property change
- // listener methods.
- static class Person {
- // A property...
- String name = "HelloWorld";
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
- }
-
- // The View's model--the root of our Model graph for this particular GUI.
- //
- // Typically each View class has a corresponding ViewModel class.
- // The ViewModel is responsible for getting the objects to edit from the
- // DAO. Since this snippet doesn't have any persistent objects to
- // retrieve, this ViewModel just instantiates a model object to edit.
- static class ViewModel {
- // The model to bind
- private Person person = new Person();
-
- public Person getPerson() {
- return person;
- }
- }
-
- // The GUI view
- static class View {
- private ViewModel viewModel;
-
- public View(ViewModel viewModel) {
- this.viewModel = viewModel;
- }
-
- public Shell createShell() {
- // Build a UI
- Shell shell = new Shell(Display.getCurrent());
- shell.setLayout(new RowLayout(SWT.VERTICAL));
-
- Text name = new Text(shell, SWT.BORDER);
-
- // Bind it
- DataBindingContext bindingContext = new DataBindingFactory1().createContext(shell);
-
- Person person = viewModel.getPerson();
- bindingContext.bind(name, new Property(person, "name"), null);
-
- // Open and return the Shell
- shell.pack();
- shell.open();
- return shell;
- }
- }
-
-}
-
-
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/CalendarableItem.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/CalendarableItem.java
deleted file mode 100644
index 743d607a..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/CalendarableItem.java
+++ /dev/null
@@ -1,536 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable.timeeditor;
-
-import java.util.Calendar;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jface.examples.databinding.ModelObject;
-import org.eclipse.jface.examples.databinding.compositetable.day.internal.ICalendarableItemControl;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-
-/**
- * This class represents an event that can be displayed on a calendar.
- *
- * @since 3.2
- */
-public class CalendarableItem extends ModelObject {
-
- /**
- *
- */
- private static final String PROP_DATE = "date";
-
- /**
- * A constant representing the name of the toolTipText property.
- */
- public static final String PROP_TOOL_TIP_TEXT = "toolTipText";
-
- /**
- * A constant representing the name of the data property.
- */
- public static final String PROP_DATA = "data";
-
- /**
- * A constant representing the name of the text property.
- */
- public static final String PROP_TEXT = "text";
-
- /**
- * A constant representing the name of the image property.
- */
- public static final String PROP_IMAGE = "image";
-
- /**
- * A constant representing the name of the endTime property.
- */
- public static final String PROP_END_TIME = "endTime";
-
- /**
- * A constant representing the name of the startTime property.
- */
- public static final String PROP_START_TIME = "startTime";
-
- /**
- * A constant representing the name of the allDayEvent property.
- */
- public static final String PROP_ALL_DAY_EVENT = "allDayEvent";
-
- /**
- * A constant representing the name of the continued property.
- */
- public static final String PROP_CONTINUED = "continued";
-
- /**
- * A comparator for CalendarableItem objects
- */
- public static final Comparator comparator = new Comparator() {
- public int compare(Object c1, Object c2) {
- CalendarableItem cal1 = (CalendarableItem) c1;
- CalendarableItem cal2 = (CalendarableItem) c2;
- if (cal1.isAllDayEvent()) {
- if (cal2.isAllDayEvent()) {
- return 0;
- }
- return -1;
- }
- if (cal2.isAllDayEvent()) {
- return 1;
- }
- return cal1.getStartTime().compareTo(cal2.getStartTime());
- }
- };
-
- public CalendarableItem(Date day) {
- setDate(day);
- }
-
- private boolean allDayEvent = false;
-
- /**
- * Returns if this Calenderable represents an all-day event.
- *
- * @return true if this is an all-day event; false otherwise.
- */
- public boolean isAllDayEvent() {
- return allDayEvent;
- }
-
- /**
- * Sets if this Calenderable represents an all-day event.
- *
- * @param allDayEvent true if this is an all-day event; false otherwise.
- */
- public void setAllDayEvent(boolean allDayEvent) {
- boolean oldValue = this.allDayEvent;
- this.allDayEvent = allDayEvent;
- firePropertyChange(PROP_ALL_DAY_EVENT, oldValue, allDayEvent);
- }
-
- /**
- * @return Returns the date on which the event falls.
- */
- public Date getDate() {
- return startTime;
- }
-
- /**
- * @param date Sets the date on which the event falls. Ignores the time
- * component of the date that is passed in.
- */
- public void setDate(Date date) {
- Date oldValue = this.startTime;
- this.startTime = setDateComponentOf(date, startTime);
- this.endTime = setDateComponentOf(date, endTime);
- firePropertyChange(PROP_DATE, oldValue, startTime);
- }
-
- /**
- * @param source
- * @param into
- */
- private Date setDateComponentOf(Date source, Date into) {
- GregorianCalendar mergeSource = new GregorianCalendar();
- mergeSource.setTime(source);
- GregorianCalendar mergeTarget = new GregorianCalendar();
- mergeTarget.setTime(into);
- mergeTarget.set(Calendar.MONTH, mergeSource.get(Calendar.MONTH));
- mergeTarget.set(Calendar.DAY_OF_MONTH, mergeSource.get(Calendar.DAY_OF_MONTH));
- mergeTarget.set(Calendar.YEAR, mergeSource.get(Calendar.YEAR));
- return mergeTarget.getTime();
- }
-
- /**
- * @param source
- * @param into
- */
- private Date setTimeComponentOf(Date source, Date into) {
- GregorianCalendar mergeSource = new GregorianCalendar();
- mergeSource.setTime(source);
- GregorianCalendar mergeTarget = new GregorianCalendar();
- mergeTarget.setTime(into);
- mergeTarget.set(Calendar.AM_PM, mergeSource.get(Calendar.AM_PM));
- mergeTarget.set(Calendar.HOUR, mergeSource.get(Calendar.HOUR));
- mergeTarget.set(Calendar.MINUTE, mergeSource.get(Calendar.MINUTE));
- mergeTarget.set(Calendar.SECOND, mergeSource.get(Calendar.SECOND));
- mergeTarget.set(Calendar.MILLISECOND, mergeSource.get(Calendar.MILLISECOND));
- return mergeTarget.getTime();
- }
-
- private Date startTime = new Date();
-
- /**
- * Gets the event's start time. This value is ignored if this is an all-day event.
- *
- * @return the start time for the event.
- */
- public Date getStartTime() {
- return startTime;
- }
-
- /**
- * Sets the event's start time. This value is ignored if this is an all-day event.
- *
- * @param startTime the event's start time.
- */
- public void setStartTime(Date startTime) {
- Date oldValue = this.startTime;
- this.startTime = setTimeComponentOf(startTime, this.startTime);
- firePropertyChange(PROP_START_TIME, oldValue, startTime);
- }
-
- private Date endTime = new Date();
-
- /**
- * Returns the event's end time. This value is ignored if this is an all-day event.
- *
- * @return the event's end time. This value is ignored if this is an all-day event.
- */
- public Date getEndTime() {
- return endTime;
- }
-
- /**
- * Sets the event's end time. This value is ignored if this is an all-day event.
- *
- * @param endTime the event's end time. This value is ignored if this is an all-day event.
- */
- public void setEndTime(Date endTime) {
- Date oldValue = this.endTime;
- this.endTime = setTimeComponentOf(endTime, this.endTime);
- firePropertyChange(PROP_END_TIME, oldValue, endTime);
- }
-
- private Image image;
-
- /**
- * Return the IEvent's image or <code>null</code>.
- *
- * @return the image of the label or null
- */
- public Image getImage() {
- return this.image;
- }
-
- /**
- * Set the IEvent's Image.
- * The value <code>null</code> clears it.
- *
- * @param image the image to be displayed in the label or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
- public void setImage(Image image) {
- Image oldValue = this.image;
- this.image = image;
- if (control != null) {
- control.setImage(image);
- }
- firePropertyChange(PROP_IMAGE, oldValue, image);
- }
-
- private String text = null;
-
- /**
- * Returns the widget text.
- * <p>
- * The text for a text widget is the characters in the widget, or
- * an empty string if this has never been set.
- * </p>
- *
- * @return the widget text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
- public String getText() {
- return text;
- }
-
- /**
- * Sets the contents of the receiver to the given string. If the receiver has style
- * SINGLE and the argument contains multiple lines of text, the result of this
- * operation is undefined and may vary from platform to platform.
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
- public void setText(String string) {
- String oldValue = this.text;
- this.text = string;
- if (control != null) {
- control.setText(string);
- }
- firePropertyChange(PROP_TEXT, oldValue, text);
- }
-
- private String toolTipText;
-
- /**
- * Returns the receiver's tool tip text, or null if it has
- * not been set.
- *
- * @return the receiver's tool tip text
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
- public String getToolTipText() {
- return toolTipText;
- }
-
- /**
- * Sets the receiver's tool tip text to the argument, which
- * may be null indicating that no tool tip text should be shown.
- *
- * @param string the new tool tip text (or null)
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
- public void setToolTipText(String string) {
- String oldValue = this.toolTipText;
- this.toolTipText = string;
- if (control != null) {
- control.setToolTipText(string);
- }
- firePropertyChange(PROP_TOOL_TIP_TEXT, oldValue, toolTipText);
- }
-
-
- private Object data = null;
-
- /**
- * Returns the application defined widget data associated
- * with the receiver, or null if it has not been set. The
- * <em>widget data</em> is a single, unnamed field that is
- * stored with every widget.
- * <p>
- * Applications may put arbitrary objects in this field. If
- * the object stored in the widget data needs to be notified
- * when the widget is disposed of, it is the application's
- * responsibility to hook the Dispose event on the widget and
- * do so.
- * </p>
- *
- * @return the widget data
- * @see #setData(Object)
- */
- public Object getData() {
- return data;
- }
-
- /**
- * Sets the application defined widget data associated
- * with the receiver to be the argument. The <em>widget
- * data</em> is a single, unnamed field that is stored
- * with every widget.
- * <p>
- * Applications may put arbitrary objects in this field. If
- * the object stored in the widget data needs to be notified
- * when the widget is disposed of, it is the application's
- * responsibility to hook the Dispose event on the widget and
- * do so.
- * </p>
- *
- * @param data the widget data
- * @see #getData()
- */
- public void setData(Object data) {
- Object oldValue = this.data;
- this.data = data;
- firePropertyChange(PROP_DATA, oldValue, data);
- }
-
- private Map dataMap = new HashMap();
-
- /**
- * Sets the application defined property of the receiver
- * with the specified name to the given value.
- * <p>
- * Applications may associate arbitrary objects with the
- * receiver in this fashion.
- * </p>
- *
- * @param key the name of the property
- * @param value the new value for the property
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the key is null</li>
- * </ul>
- *
- * @see #getData(String)
- */
- public void setData(String key, Object data) {
- if (key == null) {
- throw new IllegalArgumentException("key is null");
- }
- dataMap.put(key, data);
- }
-
- /**
- * Returns the application defined property of the receiver
- * with the specified name, or null if it has not been set.
- * <p>
- * Applications may have associated arbitrary objects with the
- * receiver in this fashion.
- * </p>
- *
- * @param key the name of the property
- * @return the value of the property or null if it has not been set
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the key is null</li>
- * </ul>
- *
- * @see #setData(String, Object)
- */
- public Object getData(String key) {
- if (key == null) {
- throw new IllegalArgumentException("key is null");
- }
- return dataMap.get(key);
- }
-
- private Point upperLeftPositionInDayRowCoordinates = null;
-
- /**
- * (non-API)
- * @return Returns the upperLeftPositionInDayRowCoordinates.
- */
- public Point getUpperLeftPositionInDayRowCoordinates() {
- return upperLeftPositionInDayRowCoordinates;
- }
-
- /**
- * (non-API)
- * Sets the upper left position of the bounding box and initializes the
- * lower right position to be the same as the upper left if the lower right
- * has not yet been set. If the lower right has been set, it is left as it
- * is.
- *
- * @param upperLeftPositionInDayRowCoordinates The upperLeftPositionInDayRowCoordinates to set.
- */
- public void setUpperLeftPositionInDayRowCoordinates(
- Point upperLeftPositionInDayRowCoordinates) {
- this.upperLeftPositionInDayRowCoordinates = upperLeftPositionInDayRowCoordinates;
-
- if (lowerRightPositionInDayRowCoordinates == null) {
- this.lowerRightPositionInDayRowCoordinates = upperLeftPositionInDayRowCoordinates;
- }
- }
-
- private Point lowerRightPositionInDayRowCoordinates = null;
-
- /**
- * (non-API)
- * @return Returns the lowerRightPositionInDayRowCoordinates.
- */
- public Point getLowerRightPositionInDayRowCoordinates() {
- return lowerRightPositionInDayRowCoordinates;
- }
-
- /**
- * (non-API)
- * Sets the lower right position of the bounding box.
- *
- * @param lowerRightPositionInDayRowCoordinates The lowerRightPositionInDayRowCoordinates to set.
- */
- public void setLowerRightPositionInDayRowCoordinates(
- Point lowerRightPositionInDayRowCoordinates) {
- this.lowerRightPositionInDayRowCoordinates = lowerRightPositionInDayRowCoordinates;
- }
-
- private ICalendarableItemControl control = null;
-
- /**
- * (non-API)
- * Returns the UI control for this CalendarableItem.
- *
- * @return The UI control for this CalendarableItem or null if there is none.
- */
- public ICalendarableItemControl getControl() {
- return control;
- }
-
- /**
- * (non-API)
- * Set the UI control for this CalendarableItem.
- *
- * @param control The control to set.
- */
- public void setControl(ICalendarableItemControl control) {
- if (control == null) {
- this.control.setCalendarableItem(null);
- }
- this.control = control;
- if (control != null) {
- control.setCalendarableItem(this);
- control.setContinued(continued);
- }
- }
-
- private int continued;
-
- /**
- * (Non-API)
- */
- public static final String BINDING_KEY = "BindingBinding";
-
- /**
- * (Non-API)
- */
- public static final String DATA_KEY = "BindingData";
-
- /**
- * Sets the "To be continued..." bitmask indicating that this event is
- * continued on the next or previous days respectively.
- *
- * @param continued One or both of SWT.TOP or SWT.BOTTOM
- */
- public void setContinued(int continued) {
- this.continued = continued;
- if (control != null) {
- control.setContinued(continued);
- }
- }
-
- /**
- * @return The continued bitmask; one or both of SWT.TOP or SWT.BOTTOM
- */
- public int getContinued() {
- return continued;
- }
-
-}
-
-
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/CalendarableModel.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/CalendarableModel.java
deleted file mode 100644
index 41389d47..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/CalendarableModel.java
+++ /dev/null
@@ -1,741 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable.timeeditor;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Represents the model behind the calendar control. This model manages three
- * concerns:
- * 1) Setting/maintaining the visible range of days (startDate, numberOfDays)
- * 2) Keeping the events for a particular day within the range of visible days
- * 3) Keeping track of the number of columns required to display the events
- * in a given day from the set of visible days.
- *
- * @since 3.2
- */
-public class CalendarableModel {
-
- private static final int DEFAULT_START_HOUR = 8;
-
- private int numberOfDays = -1;
- private int numberOfDivisionsInHour = -1;
- private ArrayList[] dayColumns = null;
- private CalendarableItem[][][] eventLayout = null; // [day][column][row]
-
- private int defaultStartHour = DEFAULT_START_HOUR;
-
- /**
- * @param dayOffset
- * @return the number of columns within the day or -1 if this has not been computed yet.
- */
- public int getNumberOfColumnsWithinDay(int dayOffset) {
- if (eventLayout == null) {
- return -1;
- }
- if (eventLayout[dayOffset] == null) {
- return -1;
- }
- return eventLayout[dayOffset].length;
- }
-
- /**
- * Sets the eventLayout for a particular dayOffset
- *
- * @param dayOffset
- * @param eventLayout
- */
- public void setEventLayout(int dayOffset, CalendarableItem[][] eventLayout) {
- this.eventLayout[dayOffset] = eventLayout;
- }
-
- /**
- * Gets the eventLayout for a particular dayOffset
- *
- * @param dayOffset
- * @return the eventLayout array for the specified day or null if none has been computed.
- */
- public CalendarableItem[][] getEventLayout(int dayOffset) {
- return eventLayout[dayOffset];
- }
-
- /**
- * @param numberOfDays
- * @param numberOfDivisionsInHour
- */
- public void setTimeBreakdown(int numberOfDays, int numberOfDivisionsInHour) {
- if (numberOfDivisionsInHour < 1) {
- throw new IllegalArgumentException("There must be at least one division in the hour");
- }
-
- if (numberOfDays < 1) {
- throw new IllegalArgumentException("There must be at least one day in the editor");
- }
-
- this.numberOfDays = numberOfDays;
- this.numberOfDivisionsInHour = numberOfDivisionsInHour;
- initializeDayArrays(numberOfDays);
-
- refresh();
- }
-
- private void initializeDayArrays(int numberOfDays) {
- dayColumns = new ArrayList[numberOfDays];
- for (int i=0; i < numberOfDays; ++i) {
- dayColumns[i] = new ArrayList();
- }
- eventLayout = new CalendarableItem[numberOfDays][][];
- }
-
- /**
- * @return The number of days to display
- */
- public int getNumberOfDays() {
- return numberOfDays;
- }
-
- /**
- * @return Returns the numberOfDivisionsInHour.
- */
- public int getNumberOfDivisionsInHour() {
- return numberOfDivisionsInHour;
- }
-
- private Date startDate = null;
-
- /**
- * @param startDate The starting date to display
- * @return The obsolete Calendarable objects
- */
- public List setStartDate(Date startDate) {
- // If there's no overlap between the old and new date ranges
- if (this.startDate == null ||
- startDate.after(calculateDate(this.startDate, numberOfDays-1)) ||
- calculateDate(startDate, numberOfDays-1).before(this.startDate))
- {
- this.startDate = startDate;
- eventLayout = new CalendarableItem[numberOfDays][][];
- return refresh();
- }
-
- // There's an overlap
- List obsoleteCalendarables = new LinkedList();
- int overlap = -1;
-
- // If we're scrolling viewport to the left
- if (startDate.before(this.startDate)) {
- // Calculate the overlap
- for (int day=0; day < numberOfDays; ++day) {
- Date candidate = calculateDate(startDate, day);
- if (candidate.equals(this.startDate))
- overlap = day;
- }
- for (int day=numberOfDays-1; day >= 0; --day) {
- if (numberOfDays - day <= overlap) {
- // Shift the arrays; track obsolete calendarables
- for (Iterator invalidated = dayColumns[day].iterator(); invalidated.hasNext();) {
- obsoleteCalendarables.add(invalidated.next());
- }
- dayColumns[day] = dayColumns[day-overlap];
- eventLayout[day] = eventLayout[day-overlap];
- } if (day >= overlap) {
- // Shift the arrays
- dayColumns[day] = dayColumns[day-overlap];
- eventLayout[day] = eventLayout[day-overlap];
- } else {
- // Recalculate new columns
- dayColumns[day] = new ArrayList();
- eventLayout[day] = null;
- refresh(calculateDate(startDate, day), day, obsoleteCalendarables);
- }
- }
- } else {
- // We're scrolling the viewport to the right
- for (int day=0; day < numberOfDays; ++day) {
- Date candidate = calculateDate(this.startDate, day);
- if (candidate.equals(startDate))
- overlap = day;
- }
- for (int day=0; day < numberOfDays; ++day) {
- if (day < overlap) {
- // Shift the arrays; track obsolete calendarables
- for (Iterator invalidated = dayColumns[day].iterator(); invalidated.hasNext();) {
- obsoleteCalendarables.add(invalidated.next());
- }
- dayColumns[day] = dayColumns[day+overlap];
- eventLayout[day] = eventLayout[day+overlap];
- } if (day < numberOfDays - overlap) {
- // Shift the arrays
- dayColumns[day] = dayColumns[day+overlap];
- eventLayout[day] = eventLayout[day+overlap];
- } else {
- // Recalculate new columns
- dayColumns[day] = new ArrayList();
- eventLayout[day] = null;
- refresh(calculateDate(startDate, day), day, obsoleteCalendarables);
- }
- }
- }
- this.startDate = startDate;
- return obsoleteCalendarables;
- }
-
- /**
- * @return The starting date to display
- */
- public Date getStartDate() {
- return startDate;
- }
-
- private EventCountProvider eventCountProvider = null;
-
- /**
- * Sets a strategy pattern object that can return the number of events
- * to display on a particulr day.
- *
- * @param eventCountProvider
- */
- public void setEventCountProvider(EventCountProvider eventCountProvider) {
- this.eventCountProvider = eventCountProvider;
- refresh();
- }
-
- private EventContentProvider eventContentProvider = null;
-
- /**
- * Sets a strategy pattern object that can set the data for the actual events for
- * a particular day.
- *
- * @param eventContentProvider
- */
- public void setEventContentProvider(EventContentProvider eventContentProvider) {
- this.eventContentProvider = eventContentProvider;
- refresh();
- }
-
- /**
- * Refresh everything in the display.
- */
- private List refresh() {
- if (startDate == null) {
- return new LinkedList();
- }
- LinkedList result = new LinkedList();
- if(!isInitialized()) {
- return result;
- }
- //refresh
- Date dateToRefresh = null;
- for (int i = 0; i < dayColumns.length; i++) {
- dateToRefresh = calculateDate(startDate, i);
- refresh(dateToRefresh, i, result);
- }
- return result;
- }
-
- /**
- * Returns the date that is the numberOfDaysFromStartDate.
- *
- * @param startDate The start date
- * @param numberOfDaysFromStartDate
- * @return Date
- */
- public Date calculateDate(Date startDate, int numberOfDaysFromStartDate) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(startDate);
- gc.add(Calendar.DATE, numberOfDaysFromStartDate);
- return gc.getTime();
- }
-
- /**
- * Has all data been set for a refresh.
- *
- */
- private boolean isInitialized() {
- return
- null != startDate &&
- numberOfDays > 0 &&
- numberOfDivisionsInHour > 0 &&
- null != eventContentProvider &&
- null != eventCountProvider;
- }
-
- private void refresh(Date date, int column, List invalidatedElements) {
- if (eventCountProvider == null || eventContentProvider == null) {
- return;
- }
-
- int numberOfEventsInDay = eventCountProvider.getNumberOfEventsInDay(date);
-
- while (dayColumns[column].size() > 0) {
- invalidatedElements.add(dayColumns[column].remove(0));
- }
- resizeList(date, dayColumns[column], numberOfEventsInDay);
-
- CalendarableItem[] tempEvents = (CalendarableItem[]) dayColumns[column]
- .toArray(new CalendarableItem[numberOfEventsInDay]);
-
- eventContentProvider.refresh(
- date,
- tempEvents);
- }
-
- private void resizeList(Date date, ArrayList list, int numberOfEventsInDay) {
- while (list.size() < numberOfEventsInDay) {
- list.add(new CalendarableItem(date));
- }
- while (list.size() > numberOfEventsInDay) {
- list.remove(0);
- }
- }
-
- /**
- * Refresh the display for the specified Date. If Date isn't being
- * displayed, this method ignores the request.
- *
- * @param date the date to refresh.
- * @return List any Calendarables that were invalidated
- */
- public List refresh(Date date) {
- LinkedList invalidatedCalendarables = new LinkedList();
- GregorianCalendar dateToRefresh = new GregorianCalendar();
- dateToRefresh.setTime(date);
- for (int offset=0; offset < numberOfDays; ++offset) {
- Date refreshTarget = calculateDate(startDate, offset);
- GregorianCalendar target = new GregorianCalendar();
- target.setTime(refreshTarget);
-
- if (target.get(Calendar.DATE) == dateToRefresh.get(Calendar.DATE) &&
- target.get(Calendar.MONTH) == dateToRefresh.get(Calendar.MONTH) &&
- target.get(Calendar.YEAR) == dateToRefresh.get(Calendar.YEAR))
- {
- refresh(date, offset, invalidatedCalendarables);
- break;
- }
- }
- return invalidatedCalendarables;
- }
-
- /**
- * Return the events for a particular day offset.
- *
- * @param dayOffset
- * @return A List of events.
- */
- public List getCalendarableItems(int dayOffset) {
- return dayColumns[dayOffset];
- }
-
- /**
- * Method computeNumberOfAllDayEventRows.
- *
- * @return int representing the max number of events in all visible days.
- */
- public int computeNumberOfAllDayEventRows() {
- int maxAllDayEvents = 0;
- for (int day = 0; day < dayColumns.length; day++) {
- ArrayList calendarables = dayColumns[day];
- int allDayEventsInCurrentDay = 0;
- for (Iterator iter = calendarables.iterator(); iter.hasNext();) {
- CalendarableItem event = (CalendarableItem) iter.next();
- if (event.isAllDayEvent()) {
- allDayEventsInCurrentDay++;
- }
- }
- if (allDayEventsInCurrentDay > maxAllDayEvents) {
- maxAllDayEvents = allDayEventsInCurrentDay;
- }
- }
- return maxAllDayEvents;
- }
-
- /**
- * Method computeStartHour. Computes the start hour of the day for all
- * days that are displayed. If no events are before the defaultStartHour,
- * the defaultStartHour is returned. If any day in the model has an event
- * beginning before defaultStartHour, the hour of the earliest event is
- * used instead.
- *
- * @return int The start hour.
- */
- public int computeStartHour() {
- GregorianCalendar gc = new GregorianCalendar();
-
- int startHour = getDefaultStartHour();
- for (int day = 0; day < dayColumns.length; day++) {
- ArrayList calendarables = dayColumns[day];
- for (Iterator iter = calendarables.iterator(); iter.hasNext();) {
- CalendarableItem event = (CalendarableItem) iter.next();
- if (event.isAllDayEvent()) {
- continue;
- }
- gc.setTime(event.getStartTime());
- int eventStartHour = gc.get(Calendar.HOUR_OF_DAY);
- if (eventStartHour < startHour) {
- startHour = eventStartHour;
- }
- }
- }
- return startHour;
- }
-
- /**
- * Method setDefaultStartHour.
- *
- * @param defaultStartHour The first hour to be displayed by default.
- */
- public void setDefaultStartHour(int defaultStartHour) {
- this.defaultStartHour = defaultStartHour;
- }
-
- /**
- * Method getDefaultStartHour
- *
- * @return int representing the first hour to be displayed by default.
- */
- public int getDefaultStartHour() {
- return defaultStartHour;
- }
-
-
- /**
- * Method getDay. Returns the day on which the specified Calendarable appers.
- *
- * @param calendarable The calendarable to find
- * @return The day offset (0-based)
- * @throws IllegalArgumentException if Calendarable isn't found
- */
- public int getDay(CalendarableItem calendarable) {
- for (int day = 0; day < dayColumns.length; day++) {
- for (Iterator calendarableIter = dayColumns[day].iterator(); calendarableIter.hasNext();) {
- CalendarableItem event = (CalendarableItem) calendarableIter.next();
- if (event == calendarable) {
- return day;
- }
- }
- }
- throw new IllegalArgumentException("Invalid Calenderable passed");
- }
-
- /**
- * FIXME: Test me please
- * @param row The row starting from the beginning of the day
- * @return The hour portion of the time that this row represents
- */
- public int computeHourFromRow(int row) {
- return row / getNumberOfDivisionsInHour() + computeStartHour();
- }
-
- /**
- * FIXME: Test me please
- * @param row The row starting from the beginning of the day
- * @return The minute portion of the time that this row represents
- */
- public int computeMinuteFromRow(int row) {
- int numberOfDivisionsInHour = getNumberOfDivisionsInHour();
- int minute = (int) ((double) row
- % numberOfDivisionsInHour
- / numberOfDivisionsInHour * 60);
- return minute;
- }
-
- /**
- * @param day The day to return all day Calendarables for
- * @return All the all day Calendarables for the specified day, order maintained
- */
- public CalendarableItem[] getAllDayCalendarables(int day) {
- List allDays = new LinkedList();
- for (Iterator calendarablesIter = getCalendarableItems(day).iterator(); calendarablesIter.hasNext();) {
- CalendarableItem candidate = (CalendarableItem) calendarablesIter.next();
- if (candidate.isAllDayEvent()) {
- allDays.add(candidate);
- }
- }
- return (CalendarableItem[]) allDays.toArray(new CalendarableItem[allDays.size()]);
- }
-
- /**
- * @param day The day to search
- * @param forward true if we're going forward; false if we're searching backward
- * @param selection The currently selected Calendarable or null if none
- * @return The next Calendarable in the specified direction where result != selection; null if none
- */
- public CalendarableItem findAllDayCalendarable(int day, boolean forward, CalendarableItem selection) {
- CalendarableItem[] calendarables = getAllDayCalendarables(day);
- if (forward) {
- if (calendarables.length < 1) {
- return null;
- }
- if (selection == null) {
- return null;
- } else if (selection == calendarables[calendarables.length-1]) {
- return null;
- }
- for (int selected = 0; selected < calendarables.length; selected++) {
- if (calendarables[selected] == selection) {
- return calendarables[selected+1];
- }
- }
- } else {
- if (calendarables.length < 1) {
- return null;
- }
- if (selection == null) {
- return calendarables[calendarables.length-1];
- } else if (selection == calendarables[0]) {
- return null;
- }
- for (int selected = 0; selected < calendarables.length; selected++) {
- if (calendarables[selected] == selection) {
- return calendarables[selected-1];
- }
- }
- }
- return null;
- }
-
- /**
- * @param day The day to search
- * @param currentRow The first row to search
- * @param stopPosition The row to stop searching on or -1 to search to the first/last element
- * @param forward true if we're going forward; false if we're searching backward
- * @param selection The Calendarable associated with currentRow or null if none
- * @return The next Calendarable in the specified direction where result != selection; null if none
- */
- public CalendarableItem findTimedCalendarable(int day, int currentRow, int stopPosition, boolean forward, CalendarableItem selection) {
- CalendarableItem[][] eventLayoutForDay = getEventLayout(day);
- if (eventLayoutForDay == null) {
- throw new IllegalArgumentException("Day " + day + " has no event data!!!");
- }
-
- int startColumn = 0;
- if (selection != null) {
- startColumn = findCalendarable(selection, currentRow, eventLayoutForDay);
- if (startColumn == -1) {
- throw new IllegalArgumentException("day " + day + ", row " + currentRow + " does not contain the specified Calendarable");
- }
- }
-
- int currentColumn = startColumn;
- if (forward) {
- if (stopPosition == -1) {
- stopPosition = eventLayoutForDay[0].length;
- }
- for (int row = currentRow; row < stopPosition; row++) {
- while (true) {
- CalendarableItem candidate = eventLayoutForDay[currentColumn][row];
- if (candidate != null && candidate != selection) {
- if (selection == null ||
- candidate.getStartTime().after(selection.getStartTime()) ||
- (currentColumn > startColumn && !candidate.getStartTime().before(selection.getStartTime())))
- {
- return candidate;
- }
- }
- ++currentColumn;
- if (currentColumn >= eventLayoutForDay.length) {
- currentColumn = 0;
- break;
- }
- }
- }
- } else {
- if (stopPosition == -1) {
- stopPosition = 0;
- }
- for (int row = currentRow; row >= stopPosition; --row) {
- while (true) {
- CalendarableItem candidate = eventLayoutForDay[currentColumn][row];
- if (candidate != null && candidate != selection && candidate.getUpperLeftPositionInDayRowCoordinates().y == row) {
- if (selection == null ||
- candidate.getStartTime().before(selection.getStartTime()) ||
- (currentColumn < startColumn && !candidate.getStartTime().after(selection.getStartTime())))
- {
- if (selection == null && currentColumn > 0) {
- // The candidate could have an earlier start time
- // than some other column
- for (int earlierColumn = currentColumn-1; earlierColumn >= 0; --earlierColumn) {
- CalendarableItem newCandidate = eventLayoutForDay[earlierColumn][row];
- if (newCandidate.getStartTime().after(candidate.getStartTime())) {
- candidate = newCandidate;
- }
- }
- }
- return candidate;
- }
- }
- --currentColumn;
- if (currentColumn < 0) {
- currentColumn = eventLayoutForDay.length-1;
- break;
- }
- }
- }
- }
- return null;
- }
-
- private int findCalendarable(CalendarableItem selection, int currentRow, CalendarableItem[][] eventLayoutForDay) {
- for (int column = 0; column < eventLayoutForDay.length; column++) {
- if (eventLayoutForDay[column][currentRow] == selection) {
- return column;
- }
- }
- return -1;
- }
-
- /**
- * @param selectedDay
- * @param selectedRow
- * @param selection
- * @param isAllDayEventRow
- * @return
- */
- public CalendarableItem findNextCalendarable(int selectedDay, int selectedRow, CalendarableItem selection, boolean isAllDayEventRow) {
- // Search the rest of the selectedDay starting at selectedRow
- CalendarableItem result = null;
- if (isAllDayEventRow) {
- result = findAllDayCalendarable(selectedDay, true, selection);
- if (result != null)
- return result;
- result = findTimedCalendarable(selectedDay, 0, -1, true, null);
- if (result != null)
- return result;
- } else {
- result = findTimedCalendarable(selectedDay, selectedRow, -1, true, selection);
- if (result != null) {
- return result;
- }
- }
-
- // Search all days other than selectedDay
- int currentDay = nextDay(selectedDay);
- while (currentDay != selectedDay) {
- // Is there an all-day event to select?
- CalendarableItem[] allDayCalendarables = getAllDayCalendarables(currentDay);
- if (allDayCalendarables.length > 0) {
- return allDayCalendarables[0];
- }
-
- // Nope, search for the first timed event
- result = findTimedCalendarable(currentDay, 0, -1, true, null);
- if (result != null) {
- return result;
- }
-
- currentDay = nextDay(currentDay);
- }
-
- // Search selectedDay from 0 to selectedRow
- CalendarableItem[] allDayCalendarables = getAllDayCalendarables(selectedDay);
- if (allDayCalendarables.length > 0) {
- return allDayCalendarables[0];
- }
-
- // If we started in an all-day event row, we're done searching.
- if (isAllDayEventRow) {
- return null;
- }
-
- // Search the last of the timed-events
- result = findTimedCalendarable(selectedDay, 0, selectedRow-1, true, null);
-// result = findTimedCalendarable(selectedDay, 0, selectedRow-1, true, selection);
- if (result != null) {
- return result;
- }
-
- // Nothing more to search; give up.
- return null;
- }
-
- private int nextDay(int selectedDay) {
- ++selectedDay;
- if (selectedDay >= numberOfDays) {
- selectedDay = 0;
- }
- return selectedDay;
- }
-
- /**
- * @param selectedDay
- * @param selectedRow
- * @param selection
- * @param isAllDayEventRow
- * @return
- */
- public CalendarableItem findPreviousCalendarable(int selectedDay, int selectedRow, CalendarableItem selection, boolean isAllDayEventRow) {
- CalendarableItem result = null;
-
- // Search to the beginning of the current day
- if (!isAllDayEventRow) {
- // search timed events to the beginning of the day
- result = findTimedCalendarable(selectedDay, selectedRow, -1, false, selection);
- if (result != null)
- return result;
-
- // Search all-day events
- result = findAllDayCalendarable(selectedDay, false, null);
- if (result != null)
- return result;
- } else {
- result = findAllDayCalendarable(selectedDay, false, selection);
- if (result != null)
- return result;
- }
-
- // Search all days other than selectedDay
- int currentDay = previousDay(selectedDay);
- while (currentDay != selectedDay) {
- // Nope, search for the first timed event
- result = findTimedCalendarable(currentDay,
- getEventLayout(selectedDay)[0].length-1,
- -1, false, null);
- if (result != null) {
- return result;
- }
-
- // Is there an all-day event to select?
- CalendarableItem[] allDayCalendarables = getAllDayCalendarables(currentDay);
- if (allDayCalendarables.length > 0) {
- return allDayCalendarables[allDayCalendarables.length-1];
- }
-
- currentDay = previousDay(currentDay);
- }
-
- // Search from the end of the current day to the current time
- result = findTimedCalendarable(currentDay,
- getEventLayout(selectedDay)[0].length-1,
- selectedRow+1, false, null);
- if (result != null) {
- return result;
- }
-
- return null;
- }
-
- private int previousDay(int selectedDay) {
- --selectedDay;
- if (selectedDay < 0) {
- selectedDay = numberOfDays-1;
- }
- return selectedDay;
- }
-}
-
-
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/DisposeListener.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/DisposeListener.java
deleted file mode 100644
index eb8111da..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/DisposeListener.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * 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.examples.databinding.compositetable.timeeditor;
-
-/**
- * A calendarable dispose listener because Calendarable objects don't have
- * any SWT parent.
- *
- * @since 3.2
- */
-public interface DisposeListener {
-
- /**
- * Called when the calendarable object is about to be removed from the
- * GUI. GUI elements hooked up to the calenderable should then dispose
- * themselves.
- *
- * @param sender The Calendarable being disposed.
- */
- public void widgetDisposed(CalendarableItem sender);
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/EventContentProvider.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/EventContentProvider.java
deleted file mode 100644
index b8468711..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/EventContentProvider.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * 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.examples.databinding.compositetable.timeeditor;
-
-import java.util.Date;
-
-/**
- * A strategy pattern object that can refresh all of the event controls
- * for a given day.
- *
- * @since 3.2
- */
-public abstract class EventContentProvider {
- /**
- * Refreshes the contents of the specified event controls for the specified
- * day.
- *
- * @param day The day
- * @param controls The controls to refresh
- */
- abstract public void refresh(Date day, CalendarableItem[] controls);
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/EventCountProvider.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/EventCountProvider.java
deleted file mode 100644
index 277e5158..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/EventCountProvider.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * 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.examples.databinding.compositetable.timeeditor;
-
-import java.util.Date;
-
-/**
- * A strategy pattern object that returns the number of events to display for a
- * specific time period.
- *
- * @since 3.2
- */
-public abstract class EventCountProvider {
- /**
- * Returns the number of events to display on a specific day.
- *
- * @param day The day to query.
- * @return The number of events on the specified day.
- */
- abstract public int getNumberOfEventsInDay(Date day);
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/IEventEditor.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/IEventEditor.java
deleted file mode 100644
index 5ceacf02..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/IEventEditor.java
+++ /dev/null
@@ -1,393 +0,0 @@
-/*******************************************************************************
- * 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.examples.databinding.compositetable.timeeditor;
-
-import java.util.Date;
-
-import org.eclipse.jface.examples.databinding.compositetable.day.CalendarableItemEventHandler;
-import org.eclipse.jface.examples.databinding.compositetable.day.CalendarableSelectionChangeListener;
-import org.eclipse.jface.examples.databinding.compositetable.day.NewEvent;
-import org.eclipse.jface.examples.databinding.compositetable.day.SelectionChangeEvent;
-import org.eclipse.swt.SWTException;
-
-/**
- * Interface IEventEditor. An interface for editors of time-based data that
- * can be visualized on various calendar-like controls.
- *
- * @since 3.2
- */
-public interface IEventEditor {
-
- /**
- * The number of hours to display at a time. Normally this is the number
- * of hours in a day.
- */
- public static final int DISPLAYED_HOURS = 24;
-
- /**
- * Method setTimeBreakdown. Call this method exactly once after constructing
- * the control in order to set the number of day columns to display.
- * <p>
- * This method may be executed exactly once. Executing more than once will
- * result in undefined behavior.
- * <p>
- * This method is a <b>hint</b>. It may be ignored by specific
- * implementations (ie: a month view).
- *
- * @param numberOfDays
- * The number of days to display.
- * @param numberOfDivisionsInHour
- * 1 == one line per hour; 2 == every 1/2 hour; 4 = every 1/4
- * hour; etc...
- */
- void setTimeBreakdown(int numberOfDays, int numberOfDivisionsInHour);
-
- /**
- * Method getNumberOfDays. Returns the number of days being displayed
- * in this IEventEditor.
- *
- * @return The number of days being displayed.
- */
- int getNumberOfDays();
-
- /**
- * Returns the numberOfDivisionsInHour. For example, to have a new
- * time slice every 1/4 hour, this value would be 4.
- *
- * @return Returns the numberOfDivisionsInHour.
- */
- int getNumberOfDivisionsInHour();
-
- /**
- * Set the start date for this event editor. How this is interpreted depends
- * on how time is being visualized.
- * <p>
- * For example, a month editor would only pay attention to the month portion
- * of the date. A multi-day editor would make the date passed be the first
- * date edited in the set of days being visualized.
- *
- * @param startDate The date representing what slice of time to visualize in the editor.
- * null is not permitted. Passing null will result in undefined behavior.
- */
- void setStartDate(Date startDate);
-
- /**
- * Return the current start date for this event editor. This is the date
- * that was set in setStartDate.
- *
- * @return The start date, or <code>null</code> if no start date has been specified yet.
- */
- Date getStartDate();
-
- /**
- * Set the strategy pattern object that can return how many events to
- * display for specific periods of time.
- * <p>
- * Note that having a separate event count provider and event content
- * provider assumes that the implementer is single-threaded and that the
- * count can't change between calling the count provider and the content
- * provider.
- *
- * @param eventCountProvider
- * The eventCountProvider to set.
- */
- void setEventCountProvider(EventCountProvider eventCountProvider);
-
- /**
- * Sets the strategy pattern object that can set the properties of the event
- * objects in order to display the data associated with the specified event.
- * <p>
- * Note that having a separate event count provider and event content
- * provider assumes that the implementer is single-threaded and that the
- * count can't change between calling the count provider and the content
- * provider.
- *
- * @param eventContentProvider
- * The eventContentProvider to set.
- */
- void setEventContentProvider(EventContentProvider eventContentProvider);
-
- /**
- * Tells the IEventEditor to refresh its display for the specified date.
- * If the specified date is not being displayed, the request will be ignored.
- * If null is passed as the date, the entire display is refreshed.
- *
- * @param date The date to refresh or null to refresh everything.
- */
- void refresh(Date date);
-
- /**
- * Tells the IEventEditor to refresh all days in its display.
- */
- void refresh();
-
- /**
- * Adds the handler to the collection of handlers who will
- * be notified when a CalendarableItem is inserted in the receiver, by sending
- * it one of the messages defined in the <code>CalendarableItemInsertHandler</code>
- * abstract class.
- * <p>
- * <code>itemInserted</code> is called when the CalendarableItem is inserted.
- * </p>
- *
- * @param handler the handler which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the handler is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see CalendarableItemInsertHandler
- * @see #removeItemInsertHandler
- */
- void addItemInsertHandler(CalendarableItemEventHandler insertHandler);
-
- /**
- * Removes the handler from the collection of handlers who will
- * be notified when a CalendarableItem is inserted into the receiver, by sending
- * it one of the messages defined in the <code>CalendarableItemInsertHandler</code>
- * abstract class.
- * <p>
- * <code>itemInserted</code> is called when the CalendarableItem is inserted.
- * </p>
- *
- * @param handler the handler which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the handler is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see CalendarableItemInsertHandler
- * @see #addItemInsertHandler
- */
- void removeItemInsertHandler(CalendarableItemEventHandler insertHandler);
-
- /**
- * Requests that the event editor attempt to insert a new element by calling
- * its registered insert handlers
- *
- * @param date
- * The date/time on which to request the insert. The actual date
- * on which the insert is performed may be different. This is a
- * HINT.
- *
- * @param allDayEvent
- * Indicates if the new event should be an all-day event. This is
- * a HINT; the actual event inserted may be a timed event.
- *
- * @return NewEvent a NewEvent object describing the event that was
- * inserted.
- */
- public NewEvent fireInsert(Date date, boolean allDayEvent);
-
- /**
- * Adds the handler to the collection of handlers who will
- * be notified when a CalendarableItem is deleted from the receiver, by sending
- * it one of the messages defined in the <code>CalendarableItemEventHandler</code>
- * abstract class.
- * <p>
- * <code>itemDeleted</code> is called when the CalendarableItem is deleted.
- * </p>
- *
- * @param handler the handler which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the handler is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see CalendarableItemEventHandler
- * @see #removeDeleteItemHandler
- */
- void addItemDeleteHandler(CalendarableItemEventHandler deleteHandler);
-
- /**
- * Requests that the event editor delete the specified CalendarableItem's
- * data.
- *
- * @param toDelete The CalendarableItem to delete.
- * @return true if successful; false otherwise.
- */
- public boolean fireDelete(CalendarableItem toDelete);
-
- /**
- * Removes the handler from the collection of handlers who will
- * be notified when a CalendarableItem is deleted from the receiver, by sending
- * it one of the messages defined in the <code>CalendarableItemEventHandler</code>
- * abstract class.
- * <p>
- * <code>itemDeleted</code> is called when the CalendarableItem is deleted.
- * </p>
- *
- * @param handler the handler which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the handler is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see CalendarableItemEventHandler
- * @see #addDeleteItemHandler
- */
- void removeItemDeleteHandler(CalendarableItemEventHandler deleteHandler);
-
- /**
- * Adds the handler to the collection of handler who will
- * be notified when a CalendarableItem's control is disposed, by sending
- * it one of the messages defined in the <code>CalendarableItemEventHandler</code>
- * abstract class. This is normally used to remove any data bindings
- * that may be attached to the (now-unused) CalendarableItem.
- * <p>
- * <code>itemDeleted</code> is called when the CalendarableItem is deleted.
- * </p>
- *
- * @param handler the handler which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the handler is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see CalendarableItemEventHandler
- * @see #removeCalendarableItemDisposeHandler
- */
- void addItemDisposeHandler(CalendarableItemEventHandler itemDisposeHandler);
-
- /**
- * Removes the handler from the collection of handlers who will
- * be notified when a CalendarableItem is disposed, by sending
- * it one of the messages defined in the <code>CalendarableItemEventHandler</code>
- * abstract class. This is normally used to remove any data bindings
- * that may be attached to the (now-unused) CalendarableItem.
- * <p>
- * <code>itemDeleted</code> is called when the CalendarableItem is deleted.
- * </p>
- *
- * @param handler the handler which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the handler is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see CalendarableItemEventHandler
- * @see #removeDeleteListener
- */
- void removeItemDisposeHandler(CalendarableItemEventHandler itemDisposeHandler);
-
- /**
- * Adds the handler to the collection of handlers who will
- * be notified when a CalendarableItem is inserted in the receiver, by sending
- * it one of the messages defined in the <code>CalendarableItemInsertHandler</code>
- * abstract class.
- * <p>
- * <code>itemInserted</code> is called when the CalendarableItem is inserted.
- * </p>
- *
- * @param handler the handler which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the handler is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see CalendarableItemInsertHandler
- * @see #removeItemInsertHandler
- */
- public void addItemEditHandler(CalendarableItemEventHandler handler);
-
- /**
- * Removes the handler from the collection of handlers who will
- * be notified when a CalendarableItem is inserted into the receiver, by sending
- * it one of the messages defined in the <code>CalendarableItemInsertHandler</code>
- * abstract class.
- * <p>
- * <code>itemInserted</code> is called when the CalendarableItem is inserted.
- * </p>
- *
- * @param handler the handler which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the handler is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see CalendarableItemInsertHandler
- * @see #addItemInsertHandler
- */
- public void removeItemEditHandler(CalendarableItemEventHandler handler);
-
- /**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's selection changes, by sending
- * it one of the messages defined in the <code>CalendarableSelectionChangeListener</code>
- * interface.
- * <p>
- * <code>selectionChanged</code> is called when the selection changes.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see CalendarableSelectionChangeListener
- * @see #removeSelectionChangeListener
- * @see SelectionChangeEvent
- */
- public void addSelectionChangeListener(CalendarableSelectionChangeListener l);
-
- /**
- * Removes the listener from the collection of listeners who will
- * be notified when the receiver's selection changes, by sending
- * it one of the messages defined in the <code>CalendarableSelectionChangeListener</code>
- * interface.
- * <p>
- * <code>selectionChanged</code> is called when the selection changes.
- * </p>
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see CalendarableSelectionChangeListener
- * @see #addSelectionChangeListener
- * @see SelectionChangeEvent
- */
- public void removeSelectionChangeListener(CalendarableSelectionChangeListener l);
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/AsynchronousTestSet.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/AsynchronousTestSet.java
deleted file mode 100644
index 9390f10a..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/AsynchronousTestSet.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.examples.databinding.contentprovider.test;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Random;
-
-import org.eclipse.jface.databinding.observable.Diffs;
-import org.eclipse.jface.databinding.observable.set.ObservableSet;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * Test set that simulates asynchronously computed elements. The elements of the
- * set are randomly generated Integers. Whenever the "recompute" method is
- * called, the set will spin off a job that sleeps for a period of time and then
- * randomly adds and removes elements from the set.
- *
- * <p>
- * This simulates a set that wraps a database query or network communication.
- * These would follow the same pattern (report the set as "stale", perform some
- * slow operation, then make changes to the set).
- * </p>
- *
- * @since 1.0
- */
-public class AsynchronousTestSet extends ObservableSet {
-
- private static Random randomNumberGenerator = new Random();
-
- private Display display;
-
- private boolean stale = false;
-
- /**
- * Average number of elements to add or remove
- */
- private static final int AVERAGE_DELTA = 4;
-
- /**
- * Average "computation" time -- time taken to do the simulated work (ms)
- */
- private static final int AVERAGE_BUSY_TIME = 1000;
-
- /**
- * List of all undisposed AsynchronousTestSet instances. Used for the
- * recomputeAll method.
- */
- private static List allSets = new ArrayList();
-
- public AsynchronousTestSet() {
- super(new HashSet(), Object.class);
- display = Display.getCurrent();
- if (display == null) {
- throw new IllegalStateException(
- "This object can only be created in the UI thread"); //$NON-NLS-1$
- }
- recompute();
- }
-
- protected void firstListenerAdded() {
- super.firstListenerAdded();
- allSets.add(this);
- }
-
- protected void lastListenerRemoved() {
- allSets.remove(this);
- super.lastListenerRemoved();
- }
-
- public static void recomputeAll() {
- for (Iterator iter = allSets.iterator(); iter.hasNext();) {
- AsynchronousTestSet next = (AsynchronousTestSet) iter.next();
-
- next.recompute();
- }
- }
-
- public void remove(Collection toRemove) {
- HashSet removed = new HashSet();
- removed.addAll(toRemove);
- removed.retainAll(wrappedSet);
-
- wrappedSet.removeAll(removed);
- fireSetChange(Diffs.createSetDiff(Collections.EMPTY_SET, removed));
- }
-
- public boolean isStale() {
- return stale;
- }
-
- public void recompute() {
- if (!isStale()) {
- setStale(true);
- final int sleepTime = (int) (randomNumberGenerator.nextDouble() * (double) (AVERAGE_BUSY_TIME * 2));
- Thread newThread = new Thread(new Runnable() {
- public void run() {
-
- // Simulate work by sleeping
- try {
- Thread.sleep(sleepTime);
- } catch (InterruptedException e) {
- }
-
- // Add and remove some elements -- important: fire all
- // events in the UI thread
- display.asyncExec(new Runnable() {
- public void run() {
- final HashSet toAdd = new HashSet();
- final HashSet toRemove = new HashSet();
-
- // Compute elements to add and remove (basically
- // just fills the toAdd
- // and toRemove sets with random elements)
- int delta = (randomNumberGenerator
- .nextInt(AVERAGE_DELTA * 4) - AVERAGE_DELTA * 2);
- int extraAdds = randomNumberGenerator
- .nextInt(AVERAGE_DELTA);
- int addCount = delta + extraAdds;
- int removeCount = -delta + extraAdds;
-
- if (addCount > 0) {
- for (int i = 0; i < addCount; i++) {
- toAdd.add(new Integer(randomNumberGenerator
- .nextInt(20)));
- }
- }
-
- if (removeCount > 0) {
- Iterator oldElements = wrappedSet.iterator();
- for (int i = 0; i < removeCount
- && oldElements.hasNext(); i++) {
- toRemove.add(oldElements.next());
- }
- }
-
- toAdd.removeAll(wrappedSet);
- wrappedSet.addAll(toAdd);
- wrappedSet.removeAll(toRemove);
-
- setStale(false);
- fireSetChange(Diffs.createSetDiff(toAdd, toRemove));
- }
- });
- }
- });
-
- newThread.start();
- }
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/LabelProviderTest.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/LabelProviderTest.java
deleted file mode 100644
index 18aad9c6..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/LabelProviderTest.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * 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.examples.databinding.contentprovider.test;
-
-import java.util.Collections;
-
-import org.eclipse.jface.databinding.observable.set.WritableSet;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.databinding.observable.value.IValueChangeListener;
-import org.eclipse.jface.databinding.observable.value.ValueDiff;
-import org.eclipse.jface.databinding.viewers.ObservableSetContentProvider;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ListeningLabelProvider;
-import org.eclipse.jface.internal.databinding.provisional.viewers.SelectionObservableValue;
-import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.layout.LayoutConstants;
-import org.eclipse.jface.viewers.ListViewer;
-import org.eclipse.jface.viewers.ViewerLabel;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Tests UpdatableTreeContentProvider and DirtyIndicationLabelProvider. Creates
- * a tree containing three randomly-generated sets of integers, and one node
- * that contains the union of the other sets.
- *
- * @since 1.0
- */
-public class LabelProviderTest {
-
- private Shell shell;
-
- private ListViewer list;
-
- private WritableSet setOfRenamables;
-
- private Button addButton;
-
- private Button removeButton;
-
- private Button renameButton;
-
- private SelectionListener buttonSelectionListener = new SelectionAdapter() {
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e) {
- Button pressed = (Button) e.widget;
- if (pressed == addButton) {
- setOfRenamables.add(new RenamableItem());
- } else if (pressed == removeButton) {
- setOfRenamables.remove(getCurrentSelection());
- } else if (pressed == renameButton) {
- rename(getCurrentSelection());
- }
-
- super.widgetSelected(e);
- }
- };
-
- private IObservableValue selectedRenamable;
-
- /**
- *
- */
- public LabelProviderTest() {
-
- // Create shell
- shell = new Shell(Display.getCurrent());
- { // Initialize shell
- setOfRenamables = new WritableSet();
-
- list = new ListViewer(shell);
- ObservableSetContentProvider contentProvider = new ObservableSetContentProvider();
- list.setContentProvider(contentProvider);
- list.setLabelProvider(new ListeningLabelProvider(contentProvider
- .getKnownElements()) {
- RenamableItem.Listener listener = new RenamableItem.Listener() {
- public void handleChanged(RenamableItem item) {
- fireChangeEvent(Collections.singleton(item));
- }
- };
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.databinding.viewers.ViewerLabelProvider#updateLabel(org.eclipse.jface.viewers.ViewerLabel,
- * java.lang.Object)
- */
- public void updateLabel(ViewerLabel label, Object element) {
- if (element instanceof RenamableItem) {
- RenamableItem item = (RenamableItem) element;
-
- label.setText(item.getName());
- }
- }
-
- protected void addListenerTo(Object next) {
- RenamableItem item = (RenamableItem) next;
-
- item.addListener(listener);
- }
-
- protected void removeListenerFrom(Object next) {
- RenamableItem item = (RenamableItem) next;
-
- item.removeListener(listener);
- }
- });
- list.setInput(setOfRenamables);
-
- selectedRenamable = new SelectionObservableValue(list);
-
- Composite buttonBar = new Composite(shell, SWT.NONE);
- { // Initialize buttonBar
- addButton = new Button(buttonBar, SWT.PUSH);
- addButton.setText("Add"); //$NON-NLS-1$
- addButton.addSelectionListener(buttonSelectionListener);
- removeButton = new Button(buttonBar, SWT.PUSH);
- removeButton.addSelectionListener(buttonSelectionListener);
- removeButton.setText("Remove"); //$NON-NLS-1$
- renameButton = new Button(buttonBar, SWT.PUSH);
- renameButton.addSelectionListener(buttonSelectionListener);
- renameButton.setText("Rename"); //$NON-NLS-1$
-
- selectedRenamable
- .addValueChangeListener(new IValueChangeListener() {
- public void handleValueChange(
- IObservableValue source, ValueDiff diff) {
- boolean shouldEnable = selectedRenamable
- .getValue() != null;
- removeButton.setEnabled(shouldEnable);
- renameButton.setEnabled(shouldEnable);
- }
- });
- removeButton.setEnabled(false);
- renameButton.setEnabled(false);
-
- GridLayoutFactory.fillDefaults().generateLayout(buttonBar);
- }
-
- }
- GridLayoutFactory.fillDefaults().numColumns(2).margins(
- LayoutConstants.getMargins()).generateLayout(shell);
- }
-
- /**
- * @param currentSelection
- */
- protected void rename(final RenamableItem currentSelection) {
- InputDialog inputDialog = new InputDialog(
- shell,
- "Edit name", "Enter the new item name", currentSelection.getName(), null); //$NON-NLS-1$ //$NON-NLS-2$
- if (Window.OK == inputDialog.open()) {
- currentSelection.setName(inputDialog.getValue());
- }
- }
-
- /**
- * @return
- */
- protected RenamableItem getCurrentSelection() {
- return (RenamableItem) selectedRenamable.getValue();
- }
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Display display = Display.getDefault();
- LabelProviderTest test = new LabelProviderTest();
- Shell s = test.getShell();
- s.pack();
- s.setVisible(true);
-
- while (!s.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
-
- private Shell getShell() {
- return shell;
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/LabelProviderTest2.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/LabelProviderTest2.java
deleted file mode 100644
index 08d8a880..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/LabelProviderTest2.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * 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.examples.databinding.contentprovider.test;
-
-import java.util.Collections;
-
-import org.eclipse.jface.databinding.observable.list.WritableList;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.databinding.observable.value.IValueChangeListener;
-import org.eclipse.jface.databinding.observable.value.ValueDiff;
-import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ListeningLabelProvider;
-import org.eclipse.jface.internal.databinding.provisional.viewers.SelectionObservableValue;
-import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.layout.LayoutConstants;
-import org.eclipse.jface.viewers.ListViewer;
-import org.eclipse.jface.viewers.ViewerLabel;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Tests UpdatableTreeContentProvider and DirtyIndicationLabelProvider. Creates
- * a tree containing three randomly-generated sets of integers, and one node
- * that contains the union of the other sets.
- *
- * @since 1.0
- */
-public class LabelProviderTest2 {
-
- private Shell shell;
-
- private ListViewer list;
-
- private WritableList listOfRenamables;
-
- private Button addButton;
-
- private Button removeButton;
-
- private Button renameButton;
-
- private SelectionListener buttonSelectionListener = new SelectionAdapter() {
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e) {
- Button pressed = (Button) e.widget;
- if (pressed == addButton) {
- listOfRenamables.add(new RenamableItem());
- } else if (pressed == removeButton) {
- listOfRenamables.remove(getCurrentSelection());
- } else if (pressed == renameButton) {
- rename(getCurrentSelection());
- }
-
- super.widgetSelected(e);
- }
- };
-
- private IObservableValue selectedRenamable;
-
- /**
- *
- */
- public LabelProviderTest2() {
-
- // Create shell
- shell = new Shell(Display.getCurrent());
- { // Initialize shell
- listOfRenamables = new WritableList();
-
- list = new ListViewer(shell);
- ObservableListContentProvider contentProvider = new ObservableListContentProvider();
- list.setContentProvider(contentProvider);
- list.setLabelProvider(new ListeningLabelProvider(contentProvider
- .getKnownElements()) {
- RenamableItem.Listener listener = new RenamableItem.Listener() {
- public void handleChanged(RenamableItem item) {
- fireChangeEvent(Collections.singleton(item));
- }
- };
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.databinding.viewers.ViewerLabelProvider#updateLabel(org.eclipse.jface.viewers.ViewerLabel,
- * java.lang.Object)
- */
- public void updateLabel(ViewerLabel label, Object element) {
- if (element instanceof RenamableItem) {
- RenamableItem item = (RenamableItem) element;
-
- label.setText(item.getName());
- }
- }
-
- protected void addListenerTo(Object next) {
- RenamableItem item = (RenamableItem) next;
-
- item.addListener(listener);
- }
-
- protected void removeListenerFrom(Object next) {
- RenamableItem item = (RenamableItem) next;
-
- item.removeListener(listener);
- }
- });
- list.setInput(listOfRenamables);
-
- selectedRenamable = new SelectionObservableValue(list);
-
- Composite buttonBar = new Composite(shell, SWT.NONE);
- { // Initialize buttonBar
- addButton = new Button(buttonBar, SWT.PUSH);
- addButton.setText("Add"); //$NON-NLS-1$
- addButton.addSelectionListener(buttonSelectionListener);
- removeButton = new Button(buttonBar, SWT.PUSH);
- removeButton.addSelectionListener(buttonSelectionListener);
- removeButton.setText("Remove"); //$NON-NLS-1$
- renameButton = new Button(buttonBar, SWT.PUSH);
- renameButton.addSelectionListener(buttonSelectionListener);
- renameButton.setText("Rename"); //$NON-NLS-1$
-
- selectedRenamable
- .addValueChangeListener(new IValueChangeListener() {
- public void handleValueChange(
- IObservableValue source, ValueDiff diff) {
- boolean shouldEnable = selectedRenamable
- .getValue() != null;
- removeButton.setEnabled(shouldEnable);
- renameButton.setEnabled(shouldEnable);
- }
- });
- removeButton.setEnabled(false);
- renameButton.setEnabled(false);
-
- GridLayoutFactory.fillDefaults().generateLayout(buttonBar);
- }
-
- }
- GridLayoutFactory.fillDefaults().numColumns(2).margins(
- LayoutConstants.getMargins()).generateLayout(shell);
- }
-
- /**
- * @param currentSelection
- */
- protected void rename(final RenamableItem currentSelection) {
- InputDialog inputDialog = new InputDialog(
- shell,
- "Edit name", "Enter the new item name", currentSelection.getName(), null); //$NON-NLS-1$ //$NON-NLS-2$
- if (Window.OK == inputDialog.open()) {
- currentSelection.setName(inputDialog.getValue());
- }
- }
-
- /**
- * @return
- */
- protected RenamableItem getCurrentSelection() {
- return (RenamableItem) selectedRenamable.getValue();
- }
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Display display = Display.getDefault();
- LabelProviderTest2 test = new LabelProviderTest2();
- Shell s = test.getShell();
- s.pack();
- s.setVisible(true);
-
- while (!s.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
-
- private Shell getShell() {
- return shell;
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/RenamableItem.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/RenamableItem.java
deleted file mode 100644
index a6d71515..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/RenamableItem.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * 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.examples.databinding.contentprovider.test;
-
-import java.util.ArrayList;
-
-/**
- * @since 1.0
- *
- */
-public class RenamableItem {
-
- public static interface Listener {
- public void handleChanged(RenamableItem item);
- };
-
- private String name;
- private ArrayList listeners = new ArrayList();
-
- public RenamableItem() {
- name = "RenamableItem"; //$NON-NLS-1$
- }
-
- public void addListener(Listener listener) {
- listeners.add(listener);
- }
-
- public void removeListener(Listener toRemove) {
- listeners.remove(toRemove);
- }
-
- public void setName(String newName) {
- this.name = newName;
-
- Listener[] l = (Listener[]) listeners.toArray(new Listener[listeners.size()]);
- for (int i = 0; i < l.length; i++) {
- l[i].handleChanged(this);
- }
- }
-
- public String getName() {
- return name;
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/SimpleNode.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/SimpleNode.java
deleted file mode 100644
index 30012418..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/SimpleNode.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.examples.databinding.contentprovider.test;
-
-import org.eclipse.jface.databinding.observable.set.IObservableSet;
-
-
-/**
- * This object will be given randomly-generated children
- *
- * @since 1.0
- */
-public class SimpleNode {
- private String nodeName;
- private IObservableSet children;
-
- public SimpleNode(String nodeName, IObservableSet children) {
- super();
- this.nodeName = nodeName;
- this.children = children;
- }
-
- public String getNodeName() {
- return nodeName;
- }
-
- public IObservableSet getChildren() {
- return children;
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/SomeMathFunction.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/SomeMathFunction.java
deleted file mode 100644
index 4a78d9ad..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/SomeMathFunction.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.examples.databinding.contentprovider.test;
-
-import java.util.Set;
-
-import org.eclipse.jface.databinding.observable.set.IObservableSet;
-import org.eclipse.jface.internal.databinding.provisional.observable.mapping.MappingDiff;
-import org.eclipse.jface.internal.databinding.provisional.observable.mapping.ObservableMappingWithDomain;
-
-/**
- * Simple function that performs one of three operations on Doubles:
- * <ul>
- * <li>Multiply by two</li>
- * <li>Round to nearest integer</li>
- * <li>Do nothing</li>
- * </ul>
- *
- * @since 1.0
- */
-public class SomeMathFunction extends ObservableMappingWithDomain {
-
- /**
- *
- */
- public static final int OP_IDENTITY = 0;
-
- /**
- *
- */
- public static final int OP_MULTIPLY = 1;
-
- /**
- *
- */
- public static final int OP_ROUND = 2;
-
- private int op = OP_ROUND;
-
- /**
- * @param domain
- */
- public SomeMathFunction(IObservableSet domain) {
- super();
- initDomain(domain);
- }
-
- /**
- * @param operation
- */
- public void setOperation(final int operation) {
- final int oldOp = this.op;
- this.op = operation;
-
- // Fire a change event. Changing the operation is going to affect every
- // answer returned by
- // this function, so include every element in the function domain in the
- // event.
- // If this was a change that would only affect a subset of elements, we
- // would include
- // the subset of affected elements rather than using
- // domain.toCollection()
- final int[] indices = new int[] { 0 };
- fireMappingValueChange(new MappingDiff() {
- public Set getElements() {
- return getDomain();
- }
-
- public int[] getAffectedIndices() {
- return indices;
- }
-
- public Object[] getOldMappingValues(Object element, int[] indices) {
- return new Object[] { doComputeResult(element, oldOp) };
- }
-
- public Object[] getNewMappingValues(Object element, int[] indices) {
- return new Object[] { doComputeResult(element, operation) };
- }
- });
- }
-
- protected Object doGetMappingValue(Object element) {
- return doComputeResult(element, this.op);
- }
-
- private Object doComputeResult(Object element, int op) {
- switch (op) {
- case OP_IDENTITY:
- return element;
- case OP_MULTIPLY:
- return new Double((((Double) element).doubleValue() * 2.0));
- case OP_ROUND:
- return new Double(Math.floor((((Double) element).doubleValue())));
- }
- return element;
- }
-
- protected void addListenerTo(Object domainElement) {
- // ignore, no need to listen to immutable Double objects
- }
-
- protected void removeListenerFrom(Object domainElement) {
- // ignore, no need to listen to immutable Double objects
- }
-
- public Object getValueType() {
- return Double.class;
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/StructuredContentProviderTest.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/StructuredContentProviderTest.java
deleted file mode 100644
index 0aab1a47..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/StructuredContentProviderTest.java
+++ /dev/null
@@ -1,393 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.examples.databinding.contentprovider.test;
-
-import java.util.Iterator;
-import java.util.Random;
-
-import org.eclipse.jface.databinding.observable.set.MappedSet;
-import org.eclipse.jface.databinding.observable.set.WritableSet;
-import org.eclipse.jface.databinding.observable.value.ComputedValue;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.databinding.observable.value.IValueChangeListener;
-import org.eclipse.jface.databinding.observable.value.ValueDiff;
-import org.eclipse.jface.databinding.observable.value.WritableValue;
-import org.eclipse.jface.databinding.viewers.ObservableSetContentProvider;
-import org.eclipse.jface.internal.databinding.provisional.swt.ControlUpdater;
-import org.eclipse.jface.internal.databinding.provisional.viewers.SelectionObservableValue;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewerLabelProvider;
-import org.eclipse.jface.viewers.ListViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Tests UpdatableSetContentProvider, ComputableValue, ControlUpdator,
- * UpdatableFunction, and ConvertingSet.
- *
- * <p>
- * This test displays a dialog with user-editable list of Doubles. It allows the
- * user to select a math function to apply to the set, and displays the result
- * in a new list. A line of text along the bottom of the dialog displays the sum
- * of the elements from the transformed set. Although this dialog is rather
- * silly, it is a good example of a dialog where a lot of things can change from
- * many directions.
- * </p>
- *
- * <p>
- * An UpdatableSetContentProvider is used to supply the contents each
- * ListViewer. ControlUpdators
- *
- * </p>
- *
- * @since 1.0
- */
-public class StructuredContentProviderTest {
-
- /**
- * Top-level shell for the dialog
- */
- private Shell shell;
-
- /**
- * Random number stream. Used for the "add" button.
- */
- protected Random random = new Random();
-
- // Data model ////////////////////////////////////////////////////////
-
- /**
- * inputSet stores a set of Doubles. The user is allowed to add and remove
- * Doubles from this set.
- */
- private WritableSet inputSet;
-
- /**
- * currentFunction is an Integer, set to one of the SomeMathFunction.OP_*
- * constants. It identifies which function will be applied to inputSet.
- */
- private WritableValue currentFunction;
-
- /**
- * mathFunction is the transformation. It can multiply by 2, round down to
- * the nearest integer, or do nothing (identity)
- */
- private SomeMathFunction mathFunction;
-
- /**
- * Set of Doubles. Holds the result of applying mathFunction to the
- * inputSet.
- */
- private MappedSet outputSet;
-
- /**
- * A Double. Stores the sum of the Doubles in outputSet
- */
- private IObservableValue sumOfOutputSet;
-
- /**
- * Creates the test dialog as a top-level shell.
- */
- public StructuredContentProviderTest() {
-
- // Initialize the data model
- createDataModel();
-
- shell = new Shell(Display.getCurrent(), SWT.SHELL_TRIM);
- { // Initialize shell
- final Label someDoubles = new Label(shell, SWT.NONE);
- someDoubles.setText("A list of random Doubles"); //$NON-NLS-1$
- someDoubles.setLayoutData(new GridData(
- GridData.HORIZONTAL_ALIGN_FILL
- | GridData.VERTICAL_ALIGN_FILL));
-
- Control addRemoveComposite = createInputControl(shell, inputSet);
-
- GridData addRemoveData = new GridData(GridData.FILL_BOTH);
- addRemoveData.minimumHeight = 1;
- addRemoveData.minimumWidth = 1;
-
- addRemoveComposite.setLayoutData(addRemoveData);
-
- Group operation = new Group(shell, SWT.NONE);
- { // Initialize operation group
- operation.setText("Select transformation"); //$NON-NLS-1$
-
- createRadioButton(operation, currentFunction, "f(x) = x", //$NON-NLS-1$
- new Integer(SomeMathFunction.OP_IDENTITY));
- createRadioButton(operation, currentFunction, "f(x) = 2 * x", //$NON-NLS-1$
- new Integer(SomeMathFunction.OP_MULTIPLY));
- createRadioButton(operation, currentFunction,
- "f(x) = floor(x)", new Integer( //$NON-NLS-1$
- SomeMathFunction.OP_ROUND));
-
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- operation.setLayout(layout);
- }
- operation.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.VERTICAL_ALIGN_FILL));
-
- Control outputControl = createOutputComposite(shell);
- GridData outputData = new GridData(GridData.FILL_BOTH);
- outputData.minimumHeight = 1;
- outputData.minimumWidth = 1;
- outputData.widthHint = 300;
- outputData.heightHint = 150;
-
- outputControl.setLayoutData(outputData);
-
- final Label sumLabel = new Label(shell, SWT.NONE);
- new ControlUpdater(sumLabel) {
- protected void updateControl() {
- double sum = ((Double) sumOfOutputSet.getValue())
- .doubleValue();
- int size = outputSet.size();
-
- sumLabel.setText("The sum of the above " + size //$NON-NLS-1$
- + " doubles is " + sum); //$NON-NLS-1$
- }
- };
- sumLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.VERTICAL_ALIGN_FILL));
-
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- shell.setLayout(layout);
- }
-
- }
-
- /**
- * Create the updatables for this dialog
- */
- private void createDataModel() {
- // Initialize data model. We will create a user-editable set of Doubles.
- // The user can run
- // a transformation on this set and view the result in a list viewer.
-
- // inputSet will be a writable set of doubles. The user will add and
- // remove entries from this set
- // through the UI.
- inputSet = new WritableSet();
-
- // currentFunction holds the ID currently selected function to apply to
- // elements in the inputSet.
- // We will allow the user to change the current function through a set
- // of radio buttons
- currentFunction = new WritableValue(new Integer(
- SomeMathFunction.OP_MULTIPLY));
-
- // mathFunction implements the selected function
- mathFunction = new SomeMathFunction(inputSet);
- currentFunction.addValueChangeListener(new IValueChangeListener() {
- public void handleValueChange(IObservableValue source,
- ValueDiff diff) {
- mathFunction
- .setOperation(((Integer) currentFunction.getValue())
- .intValue());
- }
- });
- mathFunction.setOperation(((Integer) currentFunction.getValue())
- .intValue());
-
- // outputSet holds the result. It displays the result of applying the
- // currently-selected
- // function on all the elements in the input set.
- outputSet = new MappedSet(inputSet, mathFunction);
-
- // sumOfOutputSet stores the current sum of the the Doubles in the
- // output set
- sumOfOutputSet = new ComputedValue() {
- protected Object calculate() {
- double sum = 0.0;
- for (Iterator iter = outputSet.iterator(); iter.hasNext();) {
- Double next = (Double) iter.next();
-
- sum += next.doubleValue();
- }
- return new Double(sum);
- }
- };
- }
-
- /**
- * Creates a radio button in the given parent composite. When selected, the
- * button will change the given SettableValue to the given value.
- *
- * @param parent
- * parent composite
- * @param model
- * SettableValue that will hold the value of the
- * currently-selected radio button
- * @param string
- * text to appear in the radio button
- * @param value
- * value of this radio button (SettableValue will hold this value
- * when the radio button is selected)
- */
- private void createRadioButton(Composite parent, final WritableValue model,
- String string, final Object value) {
- final Button button = new Button(parent, SWT.RADIO);
- button.setText(string);
- button.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- model.setValue(value);
- super.widgetSelected(e);
- }
- });
- new ControlUpdater(button) {
- protected void updateControl() {
- button.setSelection(model.getValue().equals(value));
- }
- };
- button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.VERTICAL_ALIGN_FILL));
- }
-
- private Control createOutputComposite(Composite parent) {
- ListViewer listOfInts = new ListViewer(parent, SWT.BORDER
- | SWT.V_SCROLL | SWT.H_SCROLL);
-
- listOfInts.setContentProvider(new ObservableSetContentProvider());
- listOfInts.setLabelProvider(new ViewerLabelProvider());
- listOfInts.setInput(outputSet);
- return listOfInts.getControl();
- }
-
- /**
- * Creates and returns a control that will allow the user to add and remove
- * Doubles from the given input set.
- *
- * @param parent
- * parent control
- * @param inputSet
- * input set
- * @return a newly created SWT control that displays Doubles from the input
- * set and allows the user to add and remove entries
- */
- private Control createInputControl(Composite parent,
- final WritableSet inputSet) {
- Composite addRemoveComposite = new Composite(parent, SWT.NONE);
- { // Initialize addRemoveComposite
- ListViewer listOfInts = new ListViewer(addRemoveComposite,
- SWT.BORDER);
-
- listOfInts.setContentProvider(new ObservableSetContentProvider());
- listOfInts.setLabelProvider(new ViewerLabelProvider());
- listOfInts.setInput(inputSet);
-
- final IObservableValue selectedInt = new SelectionObservableValue(
- listOfInts);
-
- GridData listData = new GridData(GridData.FILL_BOTH);
- listData.minimumHeight = 1;
- listData.minimumWidth = 1;
- listData.widthHint = 150;
- listData.heightHint = 150;
- listOfInts.getControl().setLayoutData(listData);
-
- Composite buttonBar = new Composite(addRemoveComposite, SWT.NONE);
- { // Initialize button bar
-
- Button add = new Button(buttonBar, SWT.PUSH);
- add.setText("Add"); //$NON-NLS-1$
- add.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- inputSet.add(new Double(random.nextDouble() * 100.0));
- super.widgetSelected(e);
- }
- });
- add.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.VERTICAL_ALIGN_FILL));
-
- final Button remove = new Button(buttonBar, SWT.PUSH);
- remove.setText("Remove"); //$NON-NLS-1$
- // Enable the Remove button if and only if there is currently an
- // element selected.
- new ControlUpdater(remove) {
- protected void updateControl() {
- // This block demonstrates auto-listening.
- // When updateControl is running, the framework
- // remembers each
- // updatable that gets touched. Since we're calling
- // selectedInt.getValue()
- // here, this updator will be flagged as dependant on
- // selectedInt. This
- // means that whenever selectedInt changes, this block
- // of code will re-run
- // itself.
-
- // The result is that the remove button will recompute
- // its enablement
- // whenever the selection in the listbox changes, and it
- // was not necessary
- // to attach any listeners.
- remove.setEnabled(selectedInt.getValue() != null);
- }
- };
-
- remove.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- inputSet.remove(selectedInt.getValue());
- super.widgetSelected(e);
- }
- });
- remove.setLayoutData(new GridData(
- GridData.HORIZONTAL_ALIGN_FILL
- | GridData.VERTICAL_ALIGN_FILL));
-
- GridLayout buttonLayout = new GridLayout();
- buttonLayout.numColumns = 1;
- buttonBar.setLayout(buttonLayout);
-
- } // End button bar
- buttonBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.VERTICAL_ALIGN_BEGINNING));
-
- GridLayout addRemoveLayout = new GridLayout();
- addRemoveLayout.numColumns = 2;
- addRemoveComposite.setLayout(addRemoveLayout);
- }
- return addRemoveComposite;
- }
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Display display = Display.getDefault();
- StructuredContentProviderTest test = new StructuredContentProviderTest();
- Shell s = test.getShell();
- s.pack();
- s.setVisible(true);
-
- while (!s.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
-
- private Shell getShell() {
- return shell;
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/TreeContentProviderTest.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/TreeContentProviderTest.java
deleted file mode 100644
index 37a06ba8..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/TreeContentProviderTest.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * 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.examples.databinding.contentprovider.test;
-
-import org.eclipse.jface.databinding.observable.Observables;
-import org.eclipse.jface.databinding.observable.set.IObservableSet;
-import org.eclipse.jface.databinding.observable.set.UnionSet;
-import org.eclipse.jface.databinding.observable.set.WritableSet;
-import org.eclipse.jface.databinding.viewers.IUnorderedTreeProvider;
-import org.eclipse.jface.databinding.viewers.UnorderedTreeContentProvider;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewerLabelProvider;
-import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.layout.LayoutConstants;
-import org.eclipse.jface.viewers.IViewerLabelProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerLabel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Tests UpdatableTreeContentProvider and DirtyIndicationLabelProvider.
- * Creates a tree containing three randomly-generated sets of integers,
- * and one node that contains the union of the other sets.
- *
- * @since 3.2
- */
-public class TreeContentProviderTest {
-
- private Shell shell;
- private TreeViewer tree;
-
- // Three randomly-generated sets of doubles
- private AsynchronousTestSet set1;
- private AsynchronousTestSet set2;
- private AsynchronousTestSet set3;
-
- // The union of the above three sets
- private UnionSet union;
- private Button randomize;
- public TreeContentProviderTest() {
-
- // Create the data model
- set1 = new AsynchronousTestSet();
- set2 = new AsynchronousTestSet();
- set3 = new AsynchronousTestSet();
-
- // A union of the above sets
- union = new UnionSet(new IObservableSet[] {set1, set2, set3});
-
- // Create shell
- shell = new Shell(Display.getCurrent());
-
- createTree();
-
- Composite buttonBar = new Composite(shell, SWT.NONE);
- {
- buttonBar.setLayout(new FillLayout(SWT.HORIZONTAL));
- randomize = new Button(buttonBar, SWT.PUSH);
- randomize.setText("Randomize");
- randomize.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- AsynchronousTestSet.recomputeAll();
- super.widgetSelected(e);
- }
- });
-
- GridLayoutFactory.fillDefaults().generateLayout(buttonBar);
- }
-
- GridLayoutFactory.fillDefaults().margins(LayoutConstants.getMargins()).generateLayout(shell);
-
- shell.addDisposeListener(new DisposeListener() {
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
- */
- public void widgetDisposed(DisposeEvent e) {
- dispose();
- }
- });
- }
-
- /**
- *
- */
- protected void dispose() {
- set1.dispose();
- set2.dispose();
- set3.dispose();
- union.dispose();
- }
-
- private void createTree() {
- // Create the tree provider. This provides the structure of the tree. This tree will
- // have an instance of RootNode as the root (which is really a placeholder), several
- // SimpleNodes as top-level nodes, and sets of randomly generated Doubles below each
- // SimpleNode.
- IUnorderedTreeProvider treeProvider = new IUnorderedTreeProvider() {
- public IObservableSet createChildSet(Object element) {
- // If the parent is the root node, return the union of some randomly-generated
- // nodes and some hardcoded nodes
- if (element == tree.getInput()) {
- // Set of hardcoded nodes
- WritableSet topElements = new WritableSet();
- topElements.add(new SimpleNode("Random Set 1", set1));
- topElements.add(new SimpleNode("Random Set 2", set2));
- topElements.add(new SimpleNode("Random Set 3", set3));
- topElements.add(new SimpleNode("Union of the other sets", union));
- return topElements;
- }
-
- // If the parent is a RandomChildrenNode, return a randomly-generated
- // set of Doubles for its children
- if (element instanceof SimpleNode) {
- // We return a new DelegatingObservableSet in order to prevent the
- // original from being disposed.
- return Observables.proxyObservableSet(((SimpleNode)element).getChildren());
- }
-
- // Otherwise the node is a Double, which will have no children
- return null;
- }
- };
-
- // Label provider for the tree
- IViewerLabelProvider labelProvider = new ViewerLabelProvider() {
- public void updateLabel(ViewerLabel label, Object element) {
- if (element instanceof SimpleNode) {
- SimpleNode node = (SimpleNode) element;
-
- label.setText(node.getNodeName());
- }
-
- if (element instanceof Integer) {
- Integer node = (Integer) element;
-
- label.setText("Integer " + node);
- }
- }
- };
-
- // Create tree viewer
- tree = new TreeViewer(shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
-
- // UpdatableTreeContentProvider converts an ITreeProvider into a standard JFace content provider
- UnorderedTreeContentProvider contentProvider = new UnorderedTreeContentProvider(treeProvider,
- "pending...");
-
- tree.setContentProvider(contentProvider);
- tree.setLabelProvider(labelProvider);
-
- // For the ITreeProvider above, it doesn't matter what we select as the input.
- tree.setInput(new Object());
- }
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Display display = Display.getDefault();
- TreeContentProviderTest test = new TreeContentProviderTest();
- Shell s = test.getShell();
- s.pack();
- s.setVisible(true);
-
- while (!s.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
-
- private Shell getShell() {
- return shell;
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/mask/EditMask.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/mask/EditMask.java
deleted file mode 100644
index 8bbcdc9d..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/mask/EditMask.java
+++ /dev/null
@@ -1,446 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.mask;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-
-import org.eclipse.jface.examples.databinding.mask.internal.EditMaskParser;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusAdapter;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.events.VerifyListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Ensures text widget has the format specified by the edit mask. Edit masks
- * are currently defined as follows:
- *
- * The following characters are reserved words that match specific kinds of
- * characters:
- *
- * # - digits 0-9
- * A - uppercase A-Z
- * a - upper or lowercase a-z, A-Z
- * n - alphanumeric 0-9, a-z, A-Z
- *
- * All other characters are literals. The above characters may be turned into
- * literals by preceeding them with a backslash. Use two backslashes to
- * denote a backslash.
- *
- * Examples:
- *
- * (###) ###-#### U.S. phone number
- * ###-##-#### U.S. Social Security number
- * \\\### A literal backslash followed by a literal pound symbol followed by two digits
- *
- * Ideas for future expansion:
- *
- * Quantifiers as postfix modifiers to a token. ie:
- *
- * #{1, 2}/#{1,2}/#### MM/DD/YYYY date format allowing 1 or 2 digit month or day
- *
- * Literals may only be quantified as {0,1} which means that they only appear
- * if placeholders on both sides of the literal have data. This will be used
- * along with:
- *
- * Right-to-left support for numeric entry. When digits are being entered and
- * a decimal point is present in the mask, digits to the left of the decimal
- * are entered right-to-left but digits to the right of the decimal left-to-right.
- * This might need to be a separate type of edit mask. (NumericMask, maybe?)
- *
- * Example:
- *
- * $#{0,3},{0,1}#{0,3}.#{0,2} ie: $123,456.12 or $12.12 or $1,234.12 or $123.12
- *
- *
- * Here's the basic idea of how the current implementation works (the actual
- * implementation is slightly more abstracted and complicated than this):
- *
- * We always let the verify event pass if the user typed a new character or selected/deleted anything.
- * During the verify event, we post an async runnable.
- * Inside that async runnable, we:
- * - Remember the selection position
- * - getText(), then
- * - Strip out all literal characters from text
- * - Truncate the resulting string to raw length of edit mask without literals
- * - Insert literal characters back in the correct positions
- * - setText() the resulting string
- * - reset the selection to the correct location
- *
- * @since 3.3
- */
-public class EditMask {
-
- public static final String FIELD_TEXT = "text";
- public static final String FIELD_RAW_TEXT = "rawText";
- public static final String FIELD_COMPLETE = "complete";
- protected Text text;
- protected EditMaskParser editMaskParser;
- private boolean fireChangeOnKeystroke = true;
- private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
-
- protected String oldValidRawText = "";
- protected String oldValidText = "";
-
- /**
- * Creates an instance that wraps around a text widget and manages its<br>
- * formatting.
- *
- * @param text
- * @param editMask
- */
- public EditMask(Text text) {
- this.text = text;
- }
-
- /**
- * @return the underlying Text control used by EditMask
- */
- public Text getControl() {
- return this.text;
- }
-
- /**
- * Set the edit mask string on the edit mask control.
- *
- * @param editMask The edit mask string
- */
- public void setMask(String editMask) {
- editMaskParser = new EditMaskParser(editMask);
- text.addVerifyListener(verifyListener);
- text.addFocusListener(focusListener);
- text.addDisposeListener(disposeListener);
- updateTextField.run();
- oldValidText = text.getText();
- oldValidRawText = editMaskParser.getRawResult();
- }
-
- /**
- * @param string Sets the text string in the receiver
- */
- public void setText(String string) {
- String oldValue = text.getText();
- if (editMaskParser != null) {
- editMaskParser.setInput(string);
- String formattedResult = editMaskParser.getFormattedResult();
- text.setText(formattedResult);
- firePropertyChange(FIELD_TEXT, oldValue, formattedResult);
- } else {
- text.setText(string);
- firePropertyChange(FIELD_TEXT, oldValue, string);
- }
- oldValidText = text.getText();
- oldValidRawText = editMaskParser.getRawResult();
- }
-
- /**
- * @return the actual (formatted) text
- */
- public String getText() {
- if (editMaskParser != null) {
- return editMaskParser.getFormattedResult();
- }
- return text.getText();
- }
-
- /**
- * setRawText takes raw text as a parameter but formats it before
- * setting the text in the Text control.
- *
- * @param string the raw (unformatted) text
- */
- public void setRawText(String string) {
- if (string == null) {
- string = "";
- }
- if (editMaskParser != null) {
- String oldValue = editMaskParser.getRawResult();
- editMaskParser.setInput(string);
- text.setText(editMaskParser.getFormattedResult());
- firePropertyChange(FIELD_RAW_TEXT, oldValue, string);
- } else {
- String oldValue = text.getText();
- text.setText(string);
- firePropertyChange(FIELD_RAW_TEXT, oldValue, string);
- }
- oldValidText = text.getText();
- oldValidRawText = editMaskParser.getRawResult();
- }
-
- /**
- * @return The input text with literals removed
- */
- public String getRawText() {
- if (editMaskParser != null) {
- return editMaskParser.getRawResult();
- }
- return text.getText();
- }
-
- /**
- * @return true if the field is complete according to the mask; false otherwise
- */
- public boolean isComplete() {
- if (editMaskParser == null) {
- return true;
- }
- return editMaskParser.isComplete();
- }
-
- /**
- * Returns the placeholder character. The placeholder
- * character must be a different character than any character that is
- * allowed as input anywhere in the edit mask. For example, if the edit
- * mask permits spaces to be used as input anywhere, the placeholder
- * character must be something other than a space character.
- * <p>
- * The space character is the default placeholder character.
- *
- * @return the placeholder character
- */
- public char getPlaceholder() {
- if (editMaskParser == null) {
- throw new IllegalArgumentException("Have to set an edit mask first");
- }
- return editMaskParser.getPlaceholder();
- }
-
- /**
- * Sets the placeholder character for the edit mask. The placeholder
- * character must be a different character than any character that is
- * allowed as input anywhere in the edit mask. For example, if the edit
- * mask permits spaces to be used as input anywhere, the placeholder
- * character must be something other than a space character.
- * <p>
- * The space character is the default placeholder character.
- *
- * @param placeholder The character to use as a placeholder
- */
- public void setPlaceholder(char placeholder) {
- if (editMaskParser == null) {
- throw new IllegalArgumentException("Have to set an edit mask first");
- }
- editMaskParser.setPlaceholder(placeholder);
- updateTextField.run();
- oldValidText = text.getText();
- }
-
- /**
- * Indicates if change notifications will be fired after every keystroke
- * that affects the value of the rawText or only when the value is either
- * complete or empty.
- *
- * @return true if every change (including changes from one invalid state to
- * another) triggers a change event; false if only empty or valid
- * values trigger a change event. Defaults to false.
- */
- public boolean isFireChangeOnKeystroke() {
- return fireChangeOnKeystroke;
- }
-
- /**
- * Sets if change notifications will be fired after every keystroke that
- * affects the value of the rawText or only when the value is either
- * complete or empty.
- *
- * @param fireChangeOnKeystroke
- * true if every change (including changes from one invalid state
- * to another) triggers a change event; false if only empty or
- * valid values trigger a change event. Defaults to false.
- */
- public void setFireChangeOnKeystroke(boolean fireChangeOnKeystroke) {
- this.fireChangeOnKeystroke = fireChangeOnKeystroke;
- }
-
- /**
- * JavaBeans boilerplate code...
- *
- * @param listener
- */
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- propertyChangeSupport.addPropertyChangeListener(listener);
- }
-
- /**
- * JavaBeans boilerplate code...
- *
- * @param propertyName
- * @param listener
- */
- public void addPropertyChangeListener(String propertyName,
- PropertyChangeListener listener) {
- propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
- }
-
- /**
- * JavaBeans boilerplate code...
- *
- * @param listener
- */
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- propertyChangeSupport.removePropertyChangeListener(listener);
- }
-
- /**
- * JavaBeans boilerplate code...
- *
- * @param propertyName
- * @param listener
- */
- public void removePropertyChangeListener(String propertyName,
- PropertyChangeListener listener) {
- propertyChangeSupport.removePropertyChangeListener(propertyName,
- listener);
- }
-
- private boolean isEitherValueNotNull(Object oldValue, Object newValue) {
- return oldValue != null || newValue != null;
- }
-
- private void firePropertyChange(String propertyName, Object oldValue,
- Object newValue) {
- if (isEitherValueNotNull(oldValue, newValue)) {
- propertyChangeSupport.firePropertyChange(propertyName,
- oldValue, newValue);
- }
- }
-
- protected boolean updating = false;
-
- protected int oldSelection = 0;
- protected int selection = 0;
- protected String oldRawText = "";
- protected boolean replacedSelectedText = false;
-
- private VerifyListener verifyListener = new VerifyListener() {
- public void verifyText(VerifyEvent e) {
- // If the edit mask is already full, don't let the user type
- // any new characters
- if (editMaskParser.isComplete() && // should eventually be .isFull() to account for optional characters
- e.start == e.end &&
- e.text.length() > 0)
- {
- e.doit=false;
- return;
- }
-
- oldSelection = selection;
- Point selectionRange = text.getSelection();
- selection = selectionRange.x;
-
- if (!updating) {
- replacedSelectedText = false;
- if (selectionRange.y - selectionRange.x > 0 && e.text.length() > 0) {
- replacedSelectedText = true;
- }
- Display.getCurrent().asyncExec(updateTextField);
- }
- }
- };
-
- private Runnable updateTextField = new Runnable() {
- public void run() {
- updating = true;
- try {
- if (!text.isDisposed()) {
- Boolean oldIsComplete = new Boolean(editMaskParser.isComplete());
-
- editMaskParser.setInput(text.getText());
- text.setText(editMaskParser.getFormattedResult());
- String newRawText = editMaskParser.getRawResult();
-
- updateSelectionPosition(newRawText);
- firePropertyChangeEvents(oldIsComplete, newRawText);
- }
- } finally {
- updating = false;
- }
- }
-
- private void updateSelectionPosition(String newRawText) {
-
- // Adjust the selection
- if (isInsertingNewCharacter(newRawText) || replacedSelectedText) {
- // Find the position after where the new character was actually inserted
- int selectionDelta =
- editMaskParser.getNextInputPosition(oldSelection)
- - oldSelection;
- if (selectionDelta == 0) {
- selectionDelta = editMaskParser.getNextInputPosition(selection)
- - selection;
- }
- selection += selectionDelta;
- }
-
- // Did we just type something that was accepted by the mask?
- if (!newRawText.equals(oldRawText)) { // yep
-
- // If the user hits <end>, bounce them back to the end of their actual input
- int firstIncompletePosition = editMaskParser.getFirstIncompleteInputPosition();
- if (firstIncompletePosition > 0 && selection > firstIncompletePosition)
- selection = firstIncompletePosition;
- text.setSelection(new Point(selection, selection));
-
- } else { // nothing was accepted by the mask
-
- // Either we backspaced over a literal or we typed an illegal character
- if (selection > oldSelection) { // typed an illegal character; backup
- text.setSelection(new Point(selection-1, selection-1));
- } else { // backspaced over a literal; don't interfere with selection position
- text.setSelection(new Point(selection, selection));
- }
- }
- oldRawText = newRawText;
- }
-
- private boolean isInsertingNewCharacter(String newRawText) {
- return newRawText.length() > oldRawText.length();
- }
-
- private void firePropertyChangeEvents(Boolean oldIsComplete, String newRawText) {
- Boolean newIsComplete = new Boolean(editMaskParser.isComplete());
- if (!oldIsComplete.equals(newIsComplete)) {
- firePropertyChange(FIELD_COMPLETE, oldIsComplete, newIsComplete);
- }
- if (!newRawText.equals(oldValidRawText)) {
- if ( newIsComplete.booleanValue() || "".equals(newRawText) || fireChangeOnKeystroke) {
- firePropertyChange(FIELD_RAW_TEXT, oldValidRawText, newRawText);
- firePropertyChange(FIELD_TEXT, oldValidText, text.getText());
- oldValidText = text.getText();
- oldValidRawText = newRawText;
- }
- }
- }
- };
-
- private FocusListener focusListener = new FocusAdapter() {
- public void focusGained(FocusEvent e) {
- selection = editMaskParser.getFirstIncompleteInputPosition();
- text.setSelection(selection, selection);
- }
- };
-
- private DisposeListener disposeListener = new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- text.removeVerifyListener(verifyListener);
- text.removeFocusListener(focusListener);
- text.removeDisposeListener(disposeListener);
- }
- };
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/mask/EditMaskParseException.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/mask/EditMaskParseException.java
deleted file mode 100644
index f2b6aece..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/mask/EditMaskParseException.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.mask;
-
-/**
- * Indicates a parse error while parsing an edit mask.
- *
- * @since 3.3
- */
-public class EditMaskParseException extends RuntimeException {
-
- private static final long serialVersionUID = 8142999683999681500L;
-
- /**
- * Construct a MaskParseException
- */
- public EditMaskParseException() {
- super();
- }
-
- /**
- * @param message
- * @param cause
- */
- public EditMaskParseException(String message, Throwable cause) {
- super(message, cause);
- }
-
- /**
- * @param message
- */
- public EditMaskParseException(String message) {
- super(message);
- }
-
- /**
- * @param cause
- */
- public EditMaskParseException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/mask/EditMaskTest.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/mask/EditMaskTest.java
deleted file mode 100644
index f5d7139f..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/mask/EditMaskTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.eclipse.jface.examples.databinding.mask;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-public class EditMaskTest {
-
- public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
-
- Text text = new Text(shell, SWT.BORDER);
- text.setText("XXXXXXXXXXXXX");// Put some X's in there to pad out the field's default size
-
- Text text2 = new Text(shell, SWT.BORDER);
- text2.setText("630XXXXXXXXXX");
-
- shell.setLayout(new RowLayout(SWT.VERTICAL));
- shell.setSize(800, 600);
-
- new EditMask(text).setMask("(###) ###-####");
- new EditMask(text2).setMask("(###) ###-####");
-
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/mask/internal/EditMaskLexerAndToken.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/mask/internal/EditMaskLexerAndToken.java
deleted file mode 100644
index d9c61b49..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/mask/internal/EditMaskLexerAndToken.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.mask.internal;
-
-import java.util.ArrayList;
-
-import org.eclipse.jface.examples.databinding.mask.EditMaskParseException;
-
-/**
- * Lexical analyzer and token for an input mask. Since input masks have exactly
- * one token type, we use the same class to be the recognizer and the token
- * itself.
- *
- * @since 3.3
- */
-public class EditMaskLexerAndToken {
-
- /*
- * First the literals that represent the types of characters
- */
- private static ArrayList reservedWords = new ArrayList();{
- reservedWords.add("#");
- reservedWords.add("A");
- reservedWords.add("a");
- reservedWords.add("n");
- }
-
- /*
- * ...and their corresponding regular expressions
- */
- private static ArrayList inputRegexes = new ArrayList();{
- inputRegexes.add("^[0-9]$");
- inputRegexes.add("^[A-Z]$");
- inputRegexes.add("^[a-zA-Z]$");
- inputRegexes.add("^[0-9a-zA-Z]$");
- }
-
- private String charRegex = null; // A regex for matching input characters or null
- private String literal = null; // The literal character if charRegex is null
- private boolean readOnly;
- private String input = null; // The user's input
-
- private boolean recognizeReservedWord(String inputMask, int position) {
- String input = inputMask.substring(position, position+1);
- for (int reservedWord = 0; reservedWord < reservedWords.size(); reservedWord++) {
- if (input.equals(reservedWords.get(reservedWord))) {
- charRegex = (String) inputRegexes.get(reservedWord);
- literal = null;
- input = null;
- readOnly = false;
- return true;
- }
- }
- return false;
- }
-
- private boolean recognizeBackslashLiteral(String inputMask, int position) throws EditMaskParseException {
- String input = inputMask.substring(position, position+1);
- if (input.equals("\\")) {
- try {
- input = inputMask.substring(position+1, position+2);
- charRegex = null;
- this.input = input;
- literal = input;
- readOnly = true;
- return true;
- } catch (Throwable t) {
- throw new EditMaskParseException("Found a \\ without a character after it: " + inputMask);
- }
- }
- return false;
- }
-
- private boolean recognizeLiteral(String inputMask, int position) {
- literal = inputMask.substring(position, position+1);
- this.input = literal;
- charRegex = null;
- readOnly = true;
- return true;
- }
-
- /**
- * Initializes itself based on characters in edit mask starting at position;
- * returns number of chars consumed
- *
- * @param inputMask The entire edit mask
- * @param position The position to begin parsing
- * @return The number of characters consumed
- * @throws EditMaskParseException If it encountered a syntax error during the parse
- */
- public int initializeEditMask(String inputMask, int position) throws EditMaskParseException {
- clear();
- if (recognizeReservedWord(inputMask, position)) {
- return 1;
- }
- if (recognizeBackslashLiteral(inputMask, position)) {
- return 2;
- }
- if (!recognizeLiteral(inputMask, position)) {
- throw new EditMaskParseException("Should never see this error in this implementation!");
- }
- readOnly = true;
- return 1;
- }
-
- /**
- * ignores invalid input; stores valid input
- * @param inputCharacter
- * @return
- */
- public boolean accept(String inputCharacter) {
- if (readOnly) {
- return false;
- }
- if (literal != null) {
- return false;
- }
- if (!canAcceptMoreCharacters()) {
- return false;
- }
- if (inputCharacter.matches(charRegex)) {
- this.input = inputCharacter;
- return true;
- }
- return false;
- }
-
- /**
- * @return Returns the characters it has accepted. In the current implementation,
- * this is exactly one character. Once quantifiers are implemented, this could
- * be many characters. If no characters have been accepted, returns null.
- */
- public String getInput() {
- return input;
- }
-
- /**
- * Clear any accepted input
- */
- public void clear() {
- if (!isReadOnly())
- input = null;
- }
-
- /**
- * @return true if it's a literal; false if it's a placeholder
- */
- public boolean isReadOnly() {
- return readOnly;
- }
-
- /**
- * @return true if it is a literal or if it has accepted the minimum
- * required number of characters
- */
- public boolean isComplete() {
- if (input != null) {
- return true;
- }
- return false;
- }
-
- /**
- * @return A position may be complete and yet able to accept more characters if
- * the position includes optional characters via a quantifier of some type.
- * Not implemented right now.
- */
- public boolean canAcceptMoreCharacters() {
- return !isComplete();
- }
-
- /**
- * @return the minimum number of characters this RegexLexer must accept
- * in order to be complete. Because we don't yet support quantifiers, this
- * is currently always 1.
- */
- public int getMinimumLength() {
- return 1;
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/mask/internal/EditMaskParser.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/mask/internal/EditMaskParser.java
deleted file mode 100644
index fc87f9e3..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/mask/internal/EditMaskParser.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.mask.internal;
-
-import java.util.LinkedList;
-
-import org.eclipse.jface.examples.databinding.mask.EditMaskParseException;
-
-/**
- * @since 3.3
- */
-public class EditMaskParser {
- private EditMaskLexerAndToken[] expectedTokens;
- private char placeholder = ' ';
-
- /**
- * @param editMask The complete edit mask
- * @throws EditMaskParseException
- */
- public EditMaskParser(String editMask) throws EditMaskParseException {
- LinkedList tokens = new LinkedList();
- int position = 0;
- while (position < editMask.length()) {
- EditMaskLexerAndToken token = new EditMaskLexerAndToken();
- position += token.initializeEditMask(editMask, position);
- tokens.add(token);
- }
- expectedTokens = (EditMaskLexerAndToken[]) tokens.toArray(new EditMaskLexerAndToken[tokens.size()]);
- }
-
- /**
- * @param input the user input which may or may not be in valid format
- */
- public void setInput(String input) {
- for (int i = 0; i < expectedTokens.length; i++) {
- expectedTokens[i].clear();
- }
- int tokenPosition = 0;
- int inputPosition = 0;
- while (inputPosition < input.length() && tokenPosition < expectedTokens.length) {
- while (tokenPosition < expectedTokens.length &&
- (expectedTokens[tokenPosition].isComplete() ||
- expectedTokens[tokenPosition].isReadOnly()))
- {
- ++tokenPosition;
- }
- if (tokenPosition < expectedTokens.length) {
- while (inputPosition < input.length() && !expectedTokens[tokenPosition].isComplete()) {
- String inputChar = input.substring(inputPosition, inputPosition+1);
- expectedTokens[tokenPosition].accept(inputChar);
- ++inputPosition;
- }
- }
- }
- }
-
- /**
- * @return the formatted version of the user input
- */
- public String getFormattedResult() {
- StringBuffer result = new StringBuffer();
- for (int i = 0; i < expectedTokens.length; i++) {
- String outputChar = expectedTokens[i].getInput();
- if (outputChar == null) {
- outputChar = "" + placeholder;
- }
- result.append(outputChar);
- }
- return result.toString();
- }
-
- /**
- * @return the user input with all literals removed
- */
- public String getRawResult() {
- StringBuffer result = new StringBuffer();
- for (int i = 0; i < expectedTokens.length; i++) {
- if (expectedTokens[i].isReadOnly()) {
- continue;
- }
- String outputChar = expectedTokens[i].getInput();
- if (outputChar == null) {
- outputChar = "";
- }
- result.append(outputChar);
- }
- return result.toString();
- }
-
- /**
- * @return true if the current input is a valid input
- */
- public boolean isComplete() {
- for (int i = 0; i < expectedTokens.length; i++) {
- if (!expectedTokens[i].isComplete()) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * @param startingAt The current index within the user input string
- * @return The first non-read-only index greater than or equal to startingAt
- */
- public int getNextInputPosition(int startingAt) {
- while (startingAt < expectedTokens.length-1 && expectedTokens[startingAt].isReadOnly()) {
- ++startingAt;
- }
- return startingAt;
- }
-
- /**
- * @return the first input position whose token is not marked as complete. Returns -1 if all are complete
- */
- public int getFirstIncompleteInputPosition() {
- for (int position = 0; position < expectedTokens.length; position++) {
- if (!expectedTokens[position].isComplete()) {
- return position;
- }
- }
- return -1;
- }
-
- /**
- * @return Returns the placeholder.
- */
- public char getPlaceholder() {
- return placeholder;
- }
-
- /**
- * @param placeholder The placeholder to set.
- */
- public void setPlaceholder(char placeholder) {
- this.placeholder = placeholder;
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Account.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Account.java
deleted file mode 100644
index 7509d647..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Account.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.examples.databinding.model;
-
-import java.util.Date;
-
-import org.eclipse.jface.examples.databinding.ModelObject;
-
-public class Account extends ModelObject {
-
- private String country;
- private String firstName;
- private String lastName;
- private String state;
- private String phone;
- private Date expiryDate;
-
- public void setFirstName(String string) {
- String oldValue = firstName;
- firstName = string;
- firePropertyChange("firstName", oldValue, string);
- }
-
- public void setLastName(String string) {
- String oldValue = lastName;
- lastName = string;
- firePropertyChange("lastName", oldValue, string);
- }
-
- public void setState(String string) {
- String oldValue = state;
- state = string;
- firePropertyChange("state", oldValue, string);
- }
-
- public void setPhone(String string) {
- String oldValue = phone;
- phone = string;
- firePropertyChange("phone", oldValue, phone);
- }
-
- public void setCountry(String string) {
- Object oldValue = country;
- country = string;
- firePropertyChange("country", oldValue, string);
- }
-
- public String getCountry() {
- return country;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public String getState() {
- return state;
- }
-
- public String getPhone() {
- return phone;
- }
-
- public Date getExpiryDate() {
- return expiryDate;
- }
-
- public void setExpiryDate(Date expiryDate) {
- firePropertyChange("expiryDate", this.expiryDate,
- this.expiryDate = expiryDate);
- }
-
-} \ No newline at end of file
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Adventure.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Adventure.java
deleted file mode 100644
index 1d75ae8b..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Adventure.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.examples.databinding.model;
-
-import org.eclipse.jface.examples.databinding.ModelObject;
-import org.eclipse.jface.internal.databinding.provisional.validation.IDomainValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.ValidationError;
-
-public class Adventure extends ModelObject {
-
- private boolean petsAllowed;
-
- private double price;
-
- private Lodging defaultLodging;
-
- private String name;
-
- private String description;
-
- private String location;
-
- private int maxNumberOfPeople;
-
- public String getName() {
- return name;
- }
-
- public void setName(String string) {
- Object oldValue = name;
- name = string;
- firePropertyChange("name", oldValue, name);
- }
-
- public int getMaxNumberOfPeople(){
- return maxNumberOfPeople;
- }
-
- public void setMaxNumberOfPeople(int anInt) {
- int oldValue = maxNumberOfPeople;
- maxNumberOfPeople = anInt;
- firePropertyChange("maxNumberOfPeople", oldValue, maxNumberOfPeople);
- }
-
- public IDomainValidator getMaxNumberOfPeopleDomainValidator() {
- return new IDomainValidator() {
- public ValidationError isValid(Object value) {
- int intValue = ((Integer)value).intValue();
- if (intValue < 1 || intValue > 20) {
- return ValidationError
- .error("Max number of people must be between 1 and 20 inclusive");
- }
- return null;
- }
- };
- }
-
- public Lodging getDefaultLodging() {
- return defaultLodging;
- }
-
- public void setDefaultLodging(Lodging lodging) {
- Object oldValue = defaultLodging;
- defaultLodging = lodging;
- firePropertyChange("defaultLodging", oldValue, defaultLodging);
- }
-
- public void setPrice(double d) {
- double oldValue = price;
- price = d;
- firePropertyChange("price", new Double(oldValue), new Double(price));
- }
-
- public double getPrice() {
- return price;
- }
-
- public void setPetsAllowed(boolean b) {
- boolean oldValue = petsAllowed;
- petsAllowed = b;
- firePropertyChange("petsAllowed", new Boolean(oldValue), new Boolean(
- petsAllowed));
- }
-
- public boolean isPetsAllowed() {
- return petsAllowed;
- }
-
- public void setDescription(String string) {
- Object oldValue = description;
- description = string;
- firePropertyChange("description", oldValue, description);
- }
-
- public void setLocation(String string) {
- Object oldValue = location;
- location = string;
- firePropertyChange("location", oldValue, location);
- }
-
- public String getDescription() {
- return description;
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/AdventureFactory.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/AdventureFactory.java
deleted file mode 100644
index 2b95e139..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/AdventureFactory.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.examples.databinding.model;
-
-public class AdventureFactory {
-
- public Catalog createCatalog() {
- return new Catalog();
- }
-
- public Category createCategory() {
- return new Category();
- }
-
- public Adventure createAdventure() {
- return new Adventure();
- }
-
- public Lodging createLodging() {
- return new Lodging();
- }
-
- public Transportation createTransportation() {
- return new Transportation();
- }
-
- public Account createAccount() {
- return new Account();
- }
-
- public Cart createCart() {
- return new Cart();
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/AggregateObservableValue.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/AggregateObservableValue.java
deleted file mode 100644
index 08e6cc0d..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/AggregateObservableValue.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.examples.databinding.model;
-
-import java.util.StringTokenizer;
-
-import org.eclipse.jface.databinding.observable.Diffs;
-import org.eclipse.jface.databinding.observable.value.AbstractObservableValue;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.databinding.observable.value.IValueChangeListener;
-import org.eclipse.jface.databinding.observable.value.ValueDiff;
-
-/**
- * @since 3.2
- *
- */
-public class AggregateObservableValue extends AbstractObservableValue {
-
- private IObservableValue[] observableValues;
-
- private String delimiter;
-
- private boolean updating = false;
-
- private String currentValue;
-
- private IValueChangeListener listener = new IValueChangeListener() {
- public void handleValueChange(IObservableValue source, ValueDiff diff) {
- if (!updating) {
- fireValueChange(Diffs.createValueDiff(currentValue,
- doGetValue()));
- }
- }
- };
-
- /**
- * @param observableValues
- * @param delimiter
- */
- public AggregateObservableValue(IObservableValue[] observableValues,
- String delimiter) {
- this.observableValues = observableValues;
- this.delimiter = delimiter;
- for (int i = 0; i < observableValues.length; i++) {
- observableValues[i].addValueChangeListener(listener);
- }
- doGetValue();
- }
-
- public void setValue(Object value) {
- Object oldValue = doGetValue();
- StringTokenizer tokenizer = new StringTokenizer((String) value,
- delimiter);
- try {
- updating = true;
- for (int i = 0; i < observableValues.length; i++) {
- if (tokenizer.hasMoreElements()) {
- observableValues[i].setValue(tokenizer.nextElement());
- } else {
- observableValues[i].setValue(null);
- }
- }
- } finally {
- updating = false;
- }
- doGetValue();
- fireValueChange(Diffs.createValueDiff(oldValue, value));
- }
-
- public Object doGetValue() {
- StringBuffer result = new StringBuffer();
- for (int i = 0; i < observableValues.length; i++) {
- if (i > 0 & i < observableValues.length) {
- result.append(delimiter);
- }
- result.append(observableValues[i].getValue());
- }
- currentValue = result.toString();
- return currentValue;
- }
-
- public Object getValueType() {
- return String.class;
- }
-
- public void dispose() {
- for (int i = 0; i < observableValues.length; i++) {
- observableValues[i].removeValueChangeListener(listener);
- }
- super.dispose();
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Cart.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Cart.java
deleted file mode 100644
index b82f45eb..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Cart.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.examples.databinding.model;
-
-public class Cart {
-
- public void setAdventureDays(int i) {
- // TODO Auto-generated method stub
-
- }
-
- public int getLodgingDays() {
- // TODO Auto-generated method stub
- return 0;
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Catalog.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Catalog.java
deleted file mode 100644
index ee0273a6..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Catalog.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.examples.databinding.model;
-
-import java.util.*;
-
-import org.eclipse.jface.examples.databinding.ModelObject;
-
-public class Catalog extends ModelObject {
-
- private Category[] categories = new Category[0];
-
- private Lodging[] lodgings = new Lodging[0];
-
- private Transportation[] transportations = new Transportation[0];
-
- private Account[] accounts = new Account[0];
-
- private List signons = new ArrayList();
-
- public List getSignons(){
- return signons;
- }
-
- public void addSignon(Signon aSignon){
- signons.add(aSignon);
- firePropertyChange("signons",null,null);
- }
-
- public void removeSignon(Signon aSignon){
- signons.remove(aSignon);
- firePropertyChange("signons",null,null);
- }
-
- public Category[] getCategories() {
- return categories;
- }
-
- public void addCategory(Category category) {
- categories = (Category[]) append(categories, category);
- firePropertyChange("categories", null, null);
- }
-
- public void addLodging(Lodging lodging) {
- lodgings = (Lodging[]) append(lodgings, lodging);
- firePropertyChange("lodgings", null, null);
- }
-
- public void addTransportation(Transportation transportation) {
- transportations = (Transportation[]) append(transportations, transportation);
- firePropertyChange("transportations", null, null);
- }
-
- public void addAccount(Account account) {
- accounts = (Account[]) append(accounts, account);
- firePropertyChange("accounts", null, null);
- }
-
- public Lodging[] getLodgings() {
- return lodgings;
- }
-
- public void removeLodging(Lodging lodging) {
- lodgings = (Lodging[]) remove(lodgings, lodging);
- firePropertyChange("lodgings", null, null);
- }
-
- public void removeAccount(Account anAccount) {
- accounts = (Account[]) remove(accounts, anAccount);
- firePropertyChange("accounts", null, null);
- }
-
- public Account[] getAccounts() {
- return accounts;
- }
-
- public Transportation[] getTransporations(){
- return transportations;
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Category.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Category.java
deleted file mode 100644
index f4a14313..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Category.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.examples.databinding.model;
-
-import org.eclipse.jface.examples.databinding.ModelObject;
-
-public class Category extends ModelObject {
-
- private String name;
-
- private Adventure[] adventures = new Adventure[0];
-
- public void setName(String string) {
- Object oldValue = name;
- name = string;
- firePropertyChange("name", oldValue, name);
- }
-
- public void addAdventure(Adventure adventure) {
- adventures = (Adventure[]) append(adventures, adventure);
- firePropertyChange("adventures", null, null);
- }
-
- public Adventure[] getAdventures() {
- return adventures;
- }
-
- public String getName() {
- return name;
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Lodging.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Lodging.java
deleted file mode 100644
index 642bb1a7..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Lodging.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.examples.databinding.model;
-
-import org.eclipse.jface.examples.databinding.ModelObject;
-
-public class Lodging extends ModelObject {
-
- private String name;
- private String description;
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String string) {
- Object oldValue = description;
- description = string;
- firePropertyChange("description",oldValue,description);
- }
-
- public void setName(String string) {
- Object oldValue = name;
- name = string;
- firePropertyChange("name",oldValue,name);
- }
-
- public String getName() {
- return name;
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/PriceModelObject.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/PriceModelObject.java
deleted file mode 100644
index d15f9dd3..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/PriceModelObject.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.examples.databinding.model;
-
-import org.eclipse.jface.examples.databinding.ModelObject;
-
-
-public class PriceModelObject extends ModelObject {
-
- private double price;
-
- public double getDouble(){
- return price;
- }
- public void setPrice(double aPrice){
- int oldDollars = getDollars();
- int oldCents = getCents();
- double oldValue = price;
- price = aPrice;
- firePropertyChange("dollars",oldDollars,getDollars());
- firePropertyChange("cents",oldCents,getCents());
- firePropertyChange("price",new Double(oldValue), new Double(price));
- }
-
- public double getPrice(){
- return price;
- }
-
- public int getCents(){
- return (int) (100*price - 100*Math.floor(price));
- }
-
- public void setCents(int cents){
- double oldPrice = getPrice();
- int oldCents = getCents();
- price = getDollars() + cents *.01;
- firePropertyChange("cents",oldCents,getCents());
- firePropertyChange("price", new Double(oldPrice), new Double(price));
- }
-
- public int getDollars(){
- return new Double(price).intValue();
- }
-
- public void setDollars(int dollars){
- double oldPrice = getPrice();
- int oldDollars = getDollars();
- price = dollars + getCents() *.01;
- firePropertyChange("dollars",oldDollars,getDollars());
- firePropertyChange("price", new Double(oldPrice), new Double(price));
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/SampleData.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/SampleData.java
deleted file mode 100644
index daaf2f55..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/SampleData.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.examples.databinding.model;
-
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.beans.BeanObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultBindSupportFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultBindingFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.NestedObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.swt.SWTObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersBindingFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersObservableFactory;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Widget;
-
-public class SampleData {
-
- public static Category WINTER_CATEGORY;
-
- public static Category SUMMER_CATEGORY;
-
- public static Adventure BEACH_HOLIDAY;
-
- public static Adventure RAFTING_HOLIDAY;
-
- public static Adventure WINTER_HOLIDAY;
-
- public static Adventure ICE_FISHING;
-
- public static Lodging FIVE_STAR_HOTEL;
-
- public static Lodging YOUTH_HOSTEL;
-
- public static Lodging CAMP_GROUND;
-
- public static Catalog CATALOG_2005;
-
- public static Transportation GREYHOUND_BUS;
-
- public static Transportation EXECUTIVE_JET;
-
- public static Account PRESIDENT;
-
- public static Account DENTIST;
-
- public static Account SANTA_CLAUS;
-
- public static Cart CART;
-
- public static AdventureFactory FACTORY;
-
- // public static ITree CATALOG_TREE;
- //
- // public static ITree CATEGORY_TREE;
-
- public static Signon SIGNON_ADMINISTRATOR;
-
- public static Signon SIGNON_JOEBLOGGS;
-
- private static SWTObservableFactory swtObservableFactory = new SWTObservableFactory();
-
- private static ViewersObservableFactory viewersObservableFactory = new ViewersObservableFactory();
-
- static {
- initializeData();
- }
-
- public static void initializeData() {
-
- FACTORY = new AdventureFactory();
-
- CATALOG_2005 = FACTORY.createCatalog();
-
- // Categories
- WINTER_CATEGORY = FACTORY.createCategory();
- WINTER_CATEGORY.setName("Freeze Adventures");
- WINTER_CATEGORY.setId("100");
- CATALOG_2005.addCategory(WINTER_CATEGORY);
-
- SUMMER_CATEGORY = FACTORY.createCategory();
- SUMMER_CATEGORY.setName("Hot Adventures");
- SUMMER_CATEGORY.setId("200");
- CATALOG_2005.addCategory(SUMMER_CATEGORY);
-
- // Adventures
- WINTER_HOLIDAY = FACTORY.createAdventure();
- WINTER_HOLIDAY.setDescription("Winter holiday in France");
- WINTER_HOLIDAY.setName("Ski Alps");
- WINTER_HOLIDAY.setLocation("Chamonix");
- WINTER_HOLIDAY.setPrice(4000.52d);
- WINTER_HOLIDAY.setId("150");
- WINTER_HOLIDAY.setMaxNumberOfPeople(3);
- WINTER_CATEGORY.addAdventure(WINTER_HOLIDAY);
-
- ICE_FISHING = FACTORY.createAdventure();
- ICE_FISHING.setDescription("Ice Fishing in Helsinki");
- ICE_FISHING.setName("Ice Fishing");
- ICE_FISHING.setLocation("Finland");
- ICE_FISHING.setPrice(375.55d);
- WINTER_CATEGORY.addAdventure(ICE_FISHING);
-
- BEACH_HOLIDAY = FACTORY.createAdventure();
- BEACH_HOLIDAY.setDescription("Beach holiday in Spain");
- BEACH_HOLIDAY.setName("Playa");
- BEACH_HOLIDAY.setLocation("Lloret de Mar");
- BEACH_HOLIDAY.setPrice(2000.52d);
- BEACH_HOLIDAY.setId("250");
- SUMMER_CATEGORY.addAdventure(BEACH_HOLIDAY);
-
- RAFTING_HOLIDAY = FACTORY.createAdventure();
- RAFTING_HOLIDAY
- .setDescription("White water rafting on the Ottawa river");
- RAFTING_HOLIDAY.setName("Whitewater");
- RAFTING_HOLIDAY.setLocation("Ottawa");
- RAFTING_HOLIDAY.setPrice(8000.52d);
- RAFTING_HOLIDAY.setId("270");
- SUMMER_CATEGORY.addAdventure(RAFTING_HOLIDAY);
-
- // Lodgings
- FIVE_STAR_HOTEL = FACTORY.createLodging();
- FIVE_STAR_HOTEL.setDescription("Deluxe palace");
- FIVE_STAR_HOTEL.setName("Flashy");
- YOUTH_HOSTEL = FACTORY.createLodging();
- YOUTH_HOSTEL.setDescription("Youth Hostel");
- YOUTH_HOSTEL.setName("Basic");
- CAMP_GROUND = FACTORY.createLodging();
- CAMP_GROUND.setDescription("Camp ground");
- CAMP_GROUND.setName("WetAndCold");
- CATALOG_2005.addLodging(FIVE_STAR_HOTEL);
- CATALOG_2005.addLodging(YOUTH_HOSTEL);
- CATALOG_2005.addLodging(CAMP_GROUND);
- WINTER_HOLIDAY.setDefaultLodging(YOUTH_HOSTEL);
-
- // Transporation
- GREYHOUND_BUS = FACTORY.createTransportation();
- GREYHOUND_BUS.setArrivalTime("14:30");
- GREYHOUND_BUS.setPrice(25.50);
- CATALOG_2005.addTransportation(GREYHOUND_BUS);
- EXECUTIVE_JET = FACTORY.createTransportation();
- EXECUTIVE_JET.setArrivalTime("11:10");
- EXECUTIVE_JET.setPrice(1500.99);
- CATALOG_2005.addTransportation(EXECUTIVE_JET);
-
- // Accounts
- PRESIDENT = FACTORY.createAccount();
- PRESIDENT.setFirstName("George");
- PRESIDENT.setLastName("Bush");
- PRESIDENT.setState("TX");
- PRESIDENT.setPhone("1112223333");
- PRESIDENT.setCountry("U.S.A");
- DENTIST = FACTORY.createAccount();
- DENTIST.setFirstName("Tooth");
- DENTIST.setLastName("Fairy");
- DENTIST.setState("CA");
- DENTIST.setPhone("4543219876");
- DENTIST.setCountry("PainLand");
- SANTA_CLAUS = FACTORY.createAccount();
- SANTA_CLAUS.setFirstName("Chris");
- SANTA_CLAUS.setLastName("Chringle");
- SANTA_CLAUS.setState("WI");
- SANTA_CLAUS.setPhone("8617429856");
- SANTA_CLAUS.setCountry("NorthPole");
- CATALOG_2005.addAccount(PRESIDENT);
- CATALOG_2005.addAccount(DENTIST);
- CATALOG_2005.addAccount(SANTA_CLAUS);
-
- // Signons
- SIGNON_ADMINISTRATOR = new Signon("Administrator", "Foo123Bar");
- SIGNON_JOEBLOGGS = new Signon("JoeBloggs", "Harry5Potter");
- CATALOG_2005.addSignon(SIGNON_ADMINISTRATOR);
- CATALOG_2005.addSignon(SIGNON_JOEBLOGGS);
-
- CART = FACTORY.createCart();
-
- // initTrees();
- }
-
- /**
- * @param aControl
- * @return
- */
- public static DataBindingContext getDatabindingContext(Control aControl) {
- final DataBindingContext context = new DataBindingContext();
- context.addObservableFactory(new DefaultObservableFactory(context));
- context.addObservableFactory(new BeanObservableFactory(context, null, new Class[]{Widget.class}));
- context.addObservableFactory(new NestedObservableFactory(context));
- context.addObservableFactory(swtObservableFactory);
- context.addObservableFactory(viewersObservableFactory);
- context.addBindingFactory(new DefaultBindingFactory());
- context.addBindingFactory(new ViewersBindingFactory());
- context.addBindSupportFactory(new DefaultBindSupportFactory());
- aControl.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- context.dispose();
- }
- });
- return context;
- }
-
- public static SWTObservableFactory getSWTObservableFactory() {
- return swtObservableFactory;
- }
-
- public static ViewersObservableFactory getViewersObservableFactory() {
- return viewersObservableFactory;
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Signon.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Signon.java
deleted file mode 100644
index 69cd381c..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Signon.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.examples.databinding.model;
-
-import org.eclipse.jface.examples.databinding.ModelObject;
-
-public class Signon extends ModelObject {
-
- String userId;
- String password;
-
- public Signon(String aUserId, String aPassword) {
- userId = aUserId;
- password = aPassword;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String aPassword) {
- String oldValue = password;
- password = aPassword;
- firePropertyChange("password",oldValue,password);
- }
- public String getUserId() {
- return userId;
- }
- public void setUserId(String aUserId) {
- String oldValue = userId;
- userId = aUserId;
- firePropertyChange("userId",oldValue,userId);
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/SimpleModel.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/SimpleModel.java
deleted file mode 100644
index cec1927d..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/SimpleModel.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2005 David Orme <djo@coconut-palm-software.com>
- *
- * 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:
- * David Orme - Initial API and implementation
- */
-package org.eclipse.jface.examples.databinding.model;
-
-import java.util.LinkedList;
-
-
-public class SimpleModel {
- public SimpleModel() {
- // Add some sample data to our personList...
- personList.add(new SimplePerson("John", "1234", "Wheaton", "IL"));
- personList.add(new SimplePerson("Jane", "1234", "Glen Ellyn", "IL"));
- personList.add(new SimplePerson("Frank", "1234", "Lombard", "IL"));
- personList.add(new SimplePerson("Joe", "1234", "Elmhurst", "IL"));
- personList.add(new SimplePerson("Chet", "1234", "Oak Lawn", "IL"));
- personList.add(new SimplePerson("Wilbur", "1234", "Austin", "IL"));
- personList.add(new SimplePerson("Elmo", "1234", "Chicago", "IL"));
- }
-
- // Now a PersonList property...
-
- LinkedList personList = new LinkedList();
-
- public LinkedList getPersonList() {
- return personList;
- }
-
-} \ No newline at end of file
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/SimpleOrder.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/SimpleOrder.java
deleted file mode 100644
index 99a68fc9..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/SimpleOrder.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.model;
-
-import java.util.Date;
-
-/**
- * @since 1.0
- *
- */
-public class SimpleOrder {
-
- private int orderNumber;
- private Date date;
-
- /**
- * @return Returns the date.
- */
- public Date getDate() {
- return date;
- }
-
- /**
- * @param date The date to set.
- */
- public void setDate(Date date) {
- this.date = date;
- }
-
- /**
- * @return Returns the orderNumber.
- */
- public int getOrderNumber() {
- return orderNumber;
- }
-
- /**
- * @param orderNumber The orderNumber to set.
- */
- public void setOrderNumber(int orderNumber) {
- this.orderNumber = orderNumber;
- }
-
- /**
- * @param i
- * @param date
- */
- public SimpleOrder(int i, Date date) {
- this.orderNumber = i;
- this.date = date;
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/SimplePerson.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/SimplePerson.java
deleted file mode 100644
index 63ba02e4..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/SimplePerson.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2005 David Orme <djo@coconut-palm-software.com>
- *
- * 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:
- * David Orme - Initial API and implementation
- * Brad Reynolds (bug 139407)
- */
-package org.eclipse.jface.examples.databinding.model;
-
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.jface.examples.databinding.ModelObject;
-
-public class SimplePerson extends ModelObject {
-
- private String name = "";
- private String address = "";
- private String city = "";
- private String state = "";
-
- private List orders = new LinkedList();
-
- public SimplePerson(String name, String address, String city, String state) {
- this.name = name;
- this.address = address;
- this.city = city;
- this.state = state;
-
- int numOrders = (int) (Math.random() * 5);
- for (int i=0; i < numOrders; ++i) {
- orders.add(new SimpleOrder(i, new Date()));
- }
- }
-
- public SimplePerson() {}
-
- /**
- * @return Returns the address.
- */
- public String getAddress() {
- return address;
- }
-
- /**
- * @param address The address to set.
- */
- public void setAddress(String address) {
- String old = this.address;
- this.address = address;
- firePropertyChange("address", old, address);
- }
-
- /**
- * @return Returns the city.
- */
- public String getCity() {
- return city;
- }
-
- /**
- * @param city The city to set.
- */
- public void setCity(String city) {
- String old = this.city;
- firePropertyChange("city", old, this.city = city);
- }
-
- /**
- * @return Returns the name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name The name to set.
- */
- public void setName(String name) {
- firePropertyChange("name", this.name, this.name = name);
- }
-
- /**
- * @return Returns the state.
- */
- public String getState() {
- return state;
- }
-
- /**
- * @param state The state to set.
- */
- public void setState(String state) {
- firePropertyChange("state", this.state, this.state = state); //$NON-NLS-1$
- }
-
- /**
- * @return Returns the orders.
- */
- public List getOrders() {
- return orders;
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Transportation.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Transportation.java
deleted file mode 100644
index d4f0b4df..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Transportation.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.examples.databinding.model;
-
-import org.eclipse.jface.examples.databinding.ModelObject;
-
-public class Transportation extends ModelObject {
-
- private String arrivalTime;
- private double price;
-
- public void setArrivalTime(String string) {
- String oldValue = arrivalTime;
- arrivalTime = string;
- firePropertyChange("arrivaltime",oldValue,string);
- }
-
- public String getArrivalTime(){
- return arrivalTime;
- }
-
- public double getPrice() {
- return price;
- }
-
- public void setPrice(double aPrice) {
- double oldPrice = price;
- price = aPrice;
- firePropertyChange("price",new Double(oldPrice),new Double(price));
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/nestedselection/BindingFactory.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/nestedselection/BindingFactory.java
deleted file mode 100644
index 6aee0a83..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/nestedselection/BindingFactory.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.examples.databinding.nestedselection;
-
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.beans.BeanObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultBindSupportFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultBindingFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.IObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.NestedObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.swt.SWTObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersBindingFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersObservableFactory;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Widget;
-
-/**
- * An example application-level data binding factory implementation. This should
- * be copied into your application and be modified to include the specific
- * updatable factories your application needs in the order it needs them.
- * <p>
- * Note that the search order for IObservableFactory implementations is last to
- * first.
- * </p>
- *
- * @since 1.0
- */
-public class BindingFactory {
-
- /**
- * Creates a data binding context whose lifecycle is bound to an SWT
- * control, and which supports binding to SWT controls, JFace viewers, and
- * POJO model objects with JavaBeans-style notification.
- * <p>
- * This method is a convenience method; its implementation is equivalent to
- * calling
- * {@link DataBindingContext#createContext(Control, IObservableFactory[]) }
- * where the array of factories consists of a
- * {@link NestedObservableFactory}, a {@link BeanObservableFactory}
- * instance, a {@link SWTObservableFactory}, and a
- * {@link ViewersObservableFactory}.
- * </p>
- *
- * @param control
- * @return a data binding context
- */
- public static DataBindingContext createContext(Control control) {
- final DataBindingContext context = createContext();
- control.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- context.dispose();
- }
- });
- return context;
- }
-
- /**
- * Creates a data binding context which supports binding to SWT controls,
- * JFace viewers, and POJO model objects with JavaBeans-style notification.
- * This data binding context's life cycle is not bound to the dispose event
- * of any SWT control. Consequently, the programmer is responsible to
- * manually dispose any IObservables created using this data binding context
- * as necessary.
- * <p>
- * This method is a convenience method; its implementation is equivalent to
- * calling
- * {@link DataBindingContext#createContext(Control, IObservableFactory[]) }
- * where the array of factories consists of a
- * {@link NestedObservableFactory}, a {@link BeanObservableFactory}
- * instance, a {@link SWTObservableFactory}, and a
- * {@link ViewersObservableFactory}.
- * </p>
- *
- * @return a data binding context
- */
- public static DataBindingContext createContext() {
- DataBindingContext context = new DataBindingContext();
- context.addObservableFactory(new NestedObservableFactory(context));
- context.addObservableFactory(new BeanObservableFactory(context, null,
- new Class[] { Widget.class }));
- context.addObservableFactory(new SWTObservableFactory());
- context.addObservableFactory(new ViewersObservableFactory());
- context.addBindSupportFactory(new DefaultBindSupportFactory());
- context.addBindingFactory(new DefaultBindingFactory());
- context.addBindingFactory(new ViewersBindingFactory());
- return context;
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/nestedselection/TestMasterDetail.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/nestedselection/TestMasterDetail.java
deleted file mode 100644
index 79573d7d..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/nestedselection/TestMasterDetail.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*******************************************************************************
- * 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.examples.databinding.nestedselection;
-
-import java.util.Date;
-
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.examples.databinding.model.SimpleOrder;
-import org.eclipse.jface.examples.databinding.model.SimplePerson;
-import org.eclipse.jface.examples.databinding.model.SimpleModel;
-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.viewers.ViewersProperties;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * @since 1.0
- *
- */
-public class TestMasterDetail {
- /**
- * @param args
- */
- public static void main(String[] args) {
- new TestMasterDetail().run();
- }
-
- private Shell shell = null; // @jve:decl-index=0:visual-constraint="10,10"
-
- private Table personsTable = null;
-
- private Label label1 = null;
-
- private Text name = null;
-
- private Label label2 = null;
-
- private Text address = null;
-
- private Label label3 = null;
-
- private Text city = null;
-
- private Label label4 = null;
-
- private Text state = null;
-
- private Table ordersTable = null;
-
- private Label label5;
-
- private Text orderDate;
-
- private Label validationError;
-
- /**
- * This method initializes table
- *
- */
- private void createTable() {
- GridData gridData = new org.eclipse.swt.layout.GridData();
- gridData.grabExcessHorizontalSpace = true;
- gridData.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
- gridData.horizontalSpan = 2;
- gridData.grabExcessVerticalSpace = true;
- gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
- personsTable = new Table(shell, SWT.FULL_SELECTION);
- personsTable.setHeaderVisible(true);
- personsTable.setLayoutData(gridData);
- personsTable.setLinesVisible(true);
- TableColumn tableColumn = new TableColumn(personsTable, SWT.NONE);
- tableColumn.setWidth(60);
- tableColumn.setText("Name");
- TableColumn tableColumn1 = new TableColumn(personsTable, SWT.NONE);
- tableColumn1.setWidth(60);
- tableColumn1.setText("State");
- }
-
- /**
- * This method initializes table1
- *
- */
- private void createTable1() {
- GridData gridData5 = new org.eclipse.swt.layout.GridData();
- gridData5.horizontalSpan = 2;
- gridData5.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
- gridData5.grabExcessHorizontalSpace = true;
- gridData5.grabExcessVerticalSpace = true;
- gridData5.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
- ordersTable = new Table(shell, SWT.FULL_SELECTION);
- ordersTable.setHeaderVisible(true);
- ordersTable.setLayoutData(gridData5);
- ordersTable.setLinesVisible(true);
- TableColumn tableColumn2 = new TableColumn(ordersTable, SWT.NONE);
- tableColumn2.setWidth(60);
- tableColumn2.setText("Order No");
- TableColumn tableColumn3 = new TableColumn(ordersTable, SWT.NONE);
- tableColumn3.setWidth(60);
- tableColumn3.setText("Date");
- }
-
- /**
- * This method initializes sShell
- */
- private void createShell() {
- GridData gridData5 = new org.eclipse.swt.layout.GridData();
- gridData5.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
- gridData5.verticalAlignment = org.eclipse.swt.layout.GridData.CENTER;
- GridData gridData4 = new org.eclipse.swt.layout.GridData();
- gridData4.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
- gridData4.verticalAlignment = org.eclipse.swt.layout.GridData.CENTER;
- GridData gridData3 = new org.eclipse.swt.layout.GridData();
- gridData3.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
- gridData3.verticalAlignment = org.eclipse.swt.layout.GridData.CENTER;
- GridData gridData2 = new org.eclipse.swt.layout.GridData();
- gridData2.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
- gridData2.verticalAlignment = org.eclipse.swt.layout.GridData.CENTER;
- GridData gridData1 = new org.eclipse.swt.layout.GridData();
- gridData1.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
- gridData1.verticalAlignment = org.eclipse.swt.layout.GridData.CENTER;
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 2;
- shell = new Shell();
- shell.setText("Shell");
- createTable();
- shell.setLayout(gridLayout);
- shell.setSize(new org.eclipse.swt.graphics.Point(495, 357));
- label1 = new Label(shell, SWT.NONE);
- label1.setText("Name");
- name = new Text(shell, SWT.BORDER);
- name.setLayoutData(gridData1);
- label2 = new Label(shell, SWT.NONE);
- label2.setText("Address");
- address = new Text(shell, SWT.BORDER);
- address.setLayoutData(gridData2);
- label3 = new Label(shell, SWT.NONE);
- label3.setText("City");
- city = new Text(shell, SWT.BORDER);
- city.setLayoutData(gridData4);
- label4 = new Label(shell, SWT.NONE);
- label4.setText("State");
- state = new Text(shell, SWT.BORDER);
- state.setLayoutData(gridData3);
- createTable1();
- label5 = new Label(shell, SWT.NONE);
- label5.setText("Order Date");
- orderDate = new Text(shell, SWT.BORDER);
- orderDate.setLayoutData(gridData5);
- validationError = new Label(shell, SWT.NONE);
- validationError.setLayoutData(new GridData(SWT.LEFT,SWT.TOP,true,false,2,1));
- }
-
- private void run() {
- Display display = new Display();
-
- createShell();
- bind(shell);
-
- shell.setSize(600, 600);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
-
- SimpleModel model = new SimpleModel();
-
- private void bind(Control parent) {
- DataBindingContext dbc = BindingFactory.createContext(parent);
- TableViewer peopleViewer = new TableViewer(personsTable);
- dbc.bind(peopleViewer, new TableModelDescription(new Property(model,
- "personList", SimplePerson.class, Boolean.TRUE), new Object[] {
- "name", "state" }), null);
-
- IObservable selectedPerson = dbc.createObservable(new Property(
- peopleViewer, ViewersProperties.SINGLE_SELECTION));
-
- dbc.bind(name, new Property(selectedPerson, "name", String.class,
- Boolean.FALSE), null);
- dbc.bind(address, new Property(selectedPerson, "address", String.class,
- Boolean.FALSE), null);
- dbc.bind(city, new Property(selectedPerson, "city", String.class,
- Boolean.FALSE), null);
- dbc.bind(state, new Property(selectedPerson, "state", String.class,
- Boolean.FALSE), null);
-
- TableViewer ordersViewer = new TableViewer(ordersTable);
- dbc.bind(ordersViewer, new TableModelDescription(new Property(
- selectedPerson, "orders", SimpleOrder.class, Boolean.TRUE),
- new Object[] { "orderNumber", "date" }), null);
-
- IObservable selectedOrder = dbc.createObservable(new Property(ordersViewer, ViewersProperties.SINGLE_SELECTION));
-
- Binding b = dbc.bind(orderDate, new Property(selectedOrder, "date", Date.class,
- Boolean.FALSE), null);
- dbc.bind(validationError, b.getValidationError(),
- new BindSpec().setUpdateModel(false));
-
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/radioGroup/RadioGroup.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/radioGroup/RadioGroup.java
deleted file mode 100644
index 69172133..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/radioGroup/RadioGroup.java
+++ /dev/null
@@ -1,549 +0,0 @@
-package org.eclipse.jface.examples.databinding.radioGroup;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.jface.examples.databinding.compositetable.reflect.DuckType;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-
-/**
- * This object decorates a bunch of SWT.RADIO buttons and provides saner
- * selection semantics than you get by default with those radio buttons.
- * <p>
- * Its API is basically the same API as List, but with unnecessary methods
- * removed.
- */
-public class RadioGroup {
-
- private final IRadioButton[] buttons;
- private final Object[] values;
- IRadioButton oldSelection = null;
- IRadioButton selectedButton = null;
- IRadioButton potentialNewSelection = null;
-
- /** (Non-API)
- * Interface IRadioButton. A duck interface that is used internally by RadioGroup
- * and by RadioGroup's unit tests.
- */
- public static interface IRadioButton {
- void setData(String string, Object object);
- void addSelectionListener(SelectionListener selectionListener);
- void setSelection(boolean b);
- boolean getSelection();
- boolean isFocusControl();
- String getText();
- void setText(String string);
- void notifyListeners(int eventType, Event object);
- }
-
- /**
- * Constructs an instance of this widget given an array of Button objects to wrap.
- * The Button objects must have been created with the SWT.RADIO style bit set,
- * and they must all be in the same Composite.
- *
- * @param radioButtons Object[] an array of radio buttons to wrap.
- * @param values Object[] an array of objects corresponding to the value of each radio button.
- */
- public RadioGroup(Object[] radioButtons, Object[] values) {
- IRadioButton[] buttons = new IRadioButton[radioButtons.length];
- if (buttons.length < 1) {
- throw new IllegalArgumentException("A RadioGroup must manage at least one Button");
- }
- for (int i = 0; i < buttons.length; i++) {
- if (!DuckType.instanceOf(IRadioButton.class, radioButtons[i])) {
- throw new IllegalArgumentException("A radio button was not passed");
- }
- buttons[i] = (IRadioButton) DuckType.implement(IRadioButton.class, radioButtons[i]);
- buttons[i].setData(Integer.toString(i), new Integer(i));
- buttons[i].addSelectionListener(selectionListener);
- }
- this.buttons = buttons;
- this.values = values;
- }
-
- /**
- * Returns the object corresponding to the currently-selected radio button
- * or null if no radio button is selected.
- *
- * @return the object corresponding to the currently-selected radio button
- * or null if no radio button is selected.
- */
- public Object getSelection() {
- int selectionIndex = getSelectionIndex();
- if (selectionIndex < 0)
- return "";
- return values[selectionIndex];
- }
-
- /**
- * Sets the selected radio button to the radio button whose model object
- * equals() the object specified by newSelection. If !newSelection.equals()
- * any model object managed by this radio group, deselects all radio buttons.
- *
- * @param newSelection A model object corresponding to one of the model
- * objects associated with one of the radio buttons.
- */
- public void setSelection(Object newSelection) {
- deselectAll();
- for (int i = 0; i < values.length; i++) {
- if (values[i].equals(newSelection)) {
- setSelection(i);
- return;
- }
- }
- }
-
- private SelectionListener selectionListener = new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
-
- public void widgetSelected(SelectionEvent e) {
- potentialNewSelection = getButton(e);
- if (! potentialNewSelection.getSelection()) {
- return;
- }
- if (potentialNewSelection.equals(selectedButton)) {
- return;
- }
-
- if (fireWidgetChangeSelectionEvent(e)) {
- oldSelection = selectedButton;
- selectedButton = potentialNewSelection;
- if (oldSelection == null) {
- oldSelection = selectedButton;
- }
-
- fireWidgetSelectedEvent(e);
- }
- }
-
- private IRadioButton getButton(SelectionEvent e) {
- // If the actual IRadioButton is a test fixture, then the test fixture can't
- // set e.widget, so the button object will be in e.data instead and a dummy
- // Widget will be in e.widget.
- if (e.data != null) {
- return (IRadioButton) e.data;
- }
- return (IRadioButton) DuckType.implement(IRadioButton.class, e.widget);
- }
- };
-
- private List widgetChangeListeners = new LinkedList();
-
- protected boolean fireWidgetChangeSelectionEvent(SelectionEvent e) {
- for (Iterator listenersIter = widgetChangeListeners.iterator(); listenersIter.hasNext();) {
- VetoableSelectionListener listener = (VetoableSelectionListener) listenersIter.next();
- listener.canWidgetChangeSelection(e);
- if (!e.doit) {
- rollbackSelection();
- return false;
- }
- }
- return true;
- }
-
- private void rollbackSelection() {
- Display.getCurrent().asyncExec(new Runnable() {
- public void run() {
- potentialNewSelection.setSelection(false);
- selectedButton.setSelection(true);
-// selectedButton.notifyListeners(SWT.Selection, null);
- }
- });
- }
-
-
- /**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's selection is about to change, by sending
- * it one of the messages defined in the <code>VetoableSelectionListener</code>
- * interface.
- * <p>
- * <code>widgetSelected</code> is called when the selection changes.
- * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see VetoableSelectionListener
- * @see #removeVetoableSelectionListener
- * @see SelectionEvent
- */
- public void addVetoableSelectionListener(VetoableSelectionListener listener) {
- widgetChangeListeners.add(listener);
- }
-
- /**
- * Removes the listener from the collection of listeners who will
- * be notified when the receiver's selection is about to change.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see VetoableSelectionListener
- * @see #addVetoableSelectionListener
- */
- public void removeVetoableSelectionListener(VetoableSelectionListener listener) {
- widgetChangeListeners.remove(listener);
- }
-
-
- private List widgetSelectedListeners = new ArrayList();
-
- protected void fireWidgetSelectedEvent(SelectionEvent e) {
- for (Iterator listenersIter = widgetSelectedListeners.iterator(); listenersIter.hasNext();) {
- SelectionListener listener = (SelectionListener) listenersIter.next();
- listener.widgetSelected(e);
- }
- }
-
- protected void fireWidgetDefaultSelectedEvent(SelectionEvent e) {
- fireWidgetSelectedEvent(e);
- }
-
- /**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's selection changes, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * <code>widgetSelected</code> is called when the selection changes.
- * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
- public void addSelectionListener(SelectionListener listener) {
- widgetSelectedListeners.add(listener);
- }
-
- /**
- * Removes the listener from the collection of listeners who will
- * be notified when the receiver's selection changes.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #addSelectionListener
- */
- public void removeSelectionListener(SelectionListener listener) {
- widgetSelectedListeners.remove(listener);
- }
-
- /**
- * Deselects the item at the given zero-relative index in the receiver.
- * If the item at the index was already deselected, it remains
- * deselected. Indices that are out of range are ignored.
- *
- * @param index the index of the item to deselect
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
- public void deselect (int index) {
- if (index < 0 || index >= buttons.length)
- return;
- buttons[index].setSelection(false);
- }
-
- /**
- * Deselects all selected items in the receiver.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
- public void deselectAll () {
- for (int i = 0; i < buttons.length; i++)
- buttons[i].setSelection(false);
- }
-
- /**
- * Returns the zero-relative index of the item which currently
- * has the focus in the receiver, or -1 if no item has focus.
- *
- * @return the index of the selected item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
- public int getFocusIndex () {
- for (int i = 0; i < buttons.length; i++) {
- if (buttons[i].isFocusControl()) {
- return i;
- }
- }
- return -1;
- }
-
- /**
- * Returns the item at the given, zero-relative index in the
- * receiver. Throws an exception if the index is out of range.
- *
- * @param index the index of the item to return
- * @return the item at the given index
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * FIXME: tck - this should be renamed to getItemText()
- */
- public String getItem (int index) {
- if (index < 0 || index >= buttons.length)
- SWT.error(SWT.ERROR_INVALID_RANGE, null, "getItem for a nonexistant item");
- return buttons[index].getText();
- }
-
- /**
- * Returns the number of items contained in the receiver.
- *
- * @return the number of items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
- public int getItemCount () {
- return buttons.length;
- }
-
- /**
- * Returns a (possibly empty) array of <code>String</code>s which
- * are the items in the receiver.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the items in the receiver's list
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
- public String [] getItems () {
- List itemStrings = new ArrayList();
- for (int i = 0; i < buttons.length; i++) {
- itemStrings.add(buttons[i].getText());
- }
- return (String[]) itemStrings.toArray(new String[itemStrings.size()]);
- }
-
- public Object[] getButtons() {
- return buttons;
- }
-
- /**
- * Returns the zero-relative index of the item which is currently
- * selected in the receiver, or -1 if no item is selected.
- *
- * @return the index of the selected item or -1
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
- public int getSelectionIndex () {
- for (int i = 0; i < buttons.length; i++) {
- if (buttons[i].getSelection() == true) {
- return i;
- }
- }
- return -1;
- }
-
- /**
- * Gets the index of an item.
- * <p>
- * The list is searched starting at 0 until an
- * item is found that is equal to the search item.
- * If no item is found, -1 is returned. Indexing
- * is zero based.
- *
- * @param string the search item
- * @return the index of the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
- public int indexOf (String string) {
- for (int i = 0; i < buttons.length; i++) {
- if (buttons[i].getText().equals(string)) {
- return i;
- }
- }
- return -1;
- }
-
- /**
- * Searches the receiver's list starting at the given,
- * zero-relative index until an item is found that is equal
- * to the argument, and returns the index of that item. If
- * no item is found or the starting index is out of range,
- * returns -1.
- *
- * @param string the search item
- * @param start the zero-relative index at which to start the search
- * @return the index of the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
- public int indexOf (String string, int start) {
- for (int i = start; i < buttons.length; i++) {
- if (buttons[i].getText().equals(string)) {
- return i;
- }
- }
- return -1;
- }
-
- /**
- * Returns <code>true</code> if the item is selected,
- * and <code>false</code> otherwise. Indices out of
- * range are ignored.
- *
- * @param index the index of the item
- * @return the visibility state of the item at the index
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
- public boolean isSelected (int index) {
- return buttons[index].getSelection();
- }
-
- /**
- * Selects the item at the given zero-relative index in the receiver's
- * list. If the item at the index was already selected, it remains
- * selected. Indices that are out of range are ignored.
- *
- * @param index the index of the item to select
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
- public void select (int index) {
- if (index < 0 || index >= buttons.length)
- return;
- buttons[index].setSelection(true);
- }
-
- /**
- * Sets the text of the item in the receiver's list at the given
- * zero-relative index to the string argument. This is equivalent
- * to <code>remove</code>'ing the old item at the index, and then
- * <code>add</code>'ing the new item at that index.
- *
- * @param index the index for the item
- * @param string the new text for the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
- public void setItem (int index, String string) {
- if (index < 0 || index >= buttons.length)
- SWT.error(SWT.ERROR_INVALID_RANGE, null, "setItem for a nonexistant item");
- buttons[index].setText(string);
- }
-
- /**
- * Selects the item at the given zero-relative index in the receiver.
- * If the item at the index was already selected, it remains selected.
- * The current selection is first cleared, then the new item is selected.
- * Indices that are out of range are ignored.
- *
- * @param index the index of the item to select
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @see List#deselectAll()
- * @see List#select(int)
- */
- public void setSelection (int index) {
- if (index < 0 || index > buttons.length - 1) {
- return;
- }
- buttons[index].setSelection(true);
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/radioGroup/VetoableSelectionListener.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/radioGroup/VetoableSelectionListener.java
deleted file mode 100644
index 949346a8..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/radioGroup/VetoableSelectionListener.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.eclipse.jface.examples.databinding.radioGroup;
-
-import org.eclipse.swt.events.SelectionEvent;
-
-/**
- * Interface VetoableSelectionListener. An interface for SelectionListeners
- * that permit the new selection to be vetoed before widgetSelected or
- * widgetDefaultSelected is called.
- */
-public interface VetoableSelectionListener {
- /**
- * Method widgetCanChangeSelection. Indicates that the selection is
- * about to be changed. Setting e.doit to false will prevent the
- * selection from changing.
- *
- * @param e The SelectionEvent that is being processed.
- */
- public void canWidgetChangeSelection(SelectionEvent e);
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet000HelloWorld.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet000HelloWorld.java
deleted file mode 100644
index 1b3d857e..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet000HelloWorld.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef, Inc. 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:
- * The Pampered Chef, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.snippets;
-
-import org.eclipse.jface.databinding.DataBindingContext;
-import org.eclipse.jface.databinding.beans.BeansObservables;
-import org.eclipse.jface.databinding.swt.SWTObservables;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Hello, databinding. Bind changes in a GUI to a Model object but don't worry
- * about propogating changes from the Model to the GUI.
- * <p>
- * Illustrates the basic Model-ViewModel-Binding-View architecture typically
- * used in data binding applications.
- */
-public class Snippet000HelloWorld {
- public static void main(String[] args) {
- ViewModel viewModel = new ViewModel();
- Shell shell = new View(viewModel).createShell();
-
- // The SWT event loop
- Display display = Display.getCurrent();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
-
- // Print the results
- System.out.println("person.getName() = "
- + viewModel.getPerson().getName());
- }
-
- // The data model class. This is normally a persistent class of some sort.
- //
- // In this example, we only push changes from the GUI to the model, so we
- // don't worry about implementing JavaBeans bound properties. If we need
- // our GUI to automatically reflect changes in the Person object, the
- // Person object would need to implement the JavaBeans property change
- // listener methods.
- static class Person {
- // A property...
- String name = "HelloWorld";
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
- }
-
- // The View's model--the root of our Model graph for this particular GUI.
- //
- // Typically each View class has a corresponding ViewModel class.
- // The ViewModel is responsible for getting the objects to edit from the
- // DAO. Since this snippet doesn't have any persistent objects to
- // retrieve, this ViewModel just instantiates a model object to edit.
- static class ViewModel {
- // The model to bind
- private Person person = new Person();
-
- public Person getPerson() {
- return person;
- }
- }
-
- // The GUI view
- static class View {
- private ViewModel viewModel;
-
- public View(ViewModel viewModel) {
- this.viewModel = viewModel;
- }
-
- public Shell createShell() {
- // Build a UI
- Shell shell = new Shell(Display.getCurrent());
- shell.setLayout(new RowLayout(SWT.VERTICAL));
-
- Text name = new Text(shell, SWT.BORDER);
-
- // Bind it
- DataBindingContext bindingContext = new DataBindingContext();
-
- Person person = viewModel.getPerson();
- bindingContext.bindValue(SWTObservables.getText(name, SWT.Modify),
- BeansObservables.getAttribute(person, "name"), null);
-
- // Open and return the Shell
- shell.pack();
- shell.open();
- return shell;
- }
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet001NestedSelectionWithCombo.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet001NestedSelectionWithCombo.java
deleted file mode 100644
index a0bbd2c9..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet001NestedSelectionWithCombo.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef, Inc. 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:
- * The Pampered Chef, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.snippets;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.util.ArrayList;
-
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.examples.databinding.DataBindingFactory1;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.description.ListModelDescription;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersProperties;
-import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.ListViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Demonstrates nested selection.<br>
- * At the first level, user may select a person.<br>
- * At the second level, user may select a city to associate with the selected<br>
- * person or edit the person's name.
- */
-public class Snippet001NestedSelectionWithCombo {
- public static void main(String[] args) {
- ViewModel viewModel = new ViewModel();
- Shell shell = new View(viewModel).createShell();
-
- // The SWT event loop
- Display display = Display.getCurrent();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- }
-
- // Minimal JavaBeans support
- static abstract class AbstractModelObject {
- private PropertyChangeSupport propertyChangeSupport =
- new PropertyChangeSupport(this);
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- propertyChangeSupport.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String propertyName,
- PropertyChangeListener listener) {
- propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- propertyChangeSupport.removePropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(String propertyName,
- PropertyChangeListener listener) {
- propertyChangeSupport.removePropertyChangeListener(propertyName,
- listener);
- }
-
- protected void firePropertyChange(String propertyName, Object oldValue,
- Object newValue) {
- propertyChangeSupport.firePropertyChange(propertyName, oldValue,
- newValue);
- }
- }
-
- // The data model class. This is normally a persistent class of some sort.
- //
- // This example implements full JavaBeans bound properties so that changes
- // to instances of this class will automatically be propogated to the UI.
- static class Person extends AbstractModelObject {
- // Constructor
- public Person(String name, String city) {
- this.name = name;
- this.city = city;
- }
-
- // Some JavaBean bound properties...
- String name;
- String city;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- String oldValue = this.name;
- this.name = name;
- firePropertyChange("name", oldValue, name);
- }
-
- public String getCity() {
- return city;
- }
-
- public void setCity(String city) {
- String oldValue = this.city;
- this.city = city;
- firePropertyChange("city", oldValue, city);
- }
- }
-
- // The View's model--the root of our GUI's Model graph
- //
- // Typically each View class has a corresponding ViewModel class.
- // The ViewModel is responsible for getting the objects to edit from the
- // DAO. Since this snippet doesn't have any persistent objects to
- // retrieve, this ViewModel just instantiates some objects to edit.
- //
- // This ViewModel also implements JavaBean bound properties.
- static class ViewModel extends AbstractModelObject {
- // The model to bind
- private ArrayList people = new ArrayList(); {
- people.add(new Person("Wile E. Coyote", "Tucson"));
- people.add(new Person("Road Runner", "Lost Horse"));
- people.add(new Person("Bugs Bunny", "Forrest"));
- }
-
- // Choice of cities for the Combo
- private ArrayList cities = new ArrayList(); {
- cities.add("Tucson");
- cities.add("AcmeTown");
- cities.add("Lost Horse");
- cities.add("Forrest");
- cities.add("Lost Mine");
- }
-
- public ArrayList getPeople() {
- return people;
- }
-
- public ArrayList getCities() {
- return cities;
- }
- }
-
- // The GUI view
- static class View {
- private ViewModel viewModel;
-
- public View(ViewModel viewModel) {
- this.viewModel = viewModel;
- }
-
- public Shell createShell() {
- // Build a UI
- Shell shell = new Shell(Display.getCurrent());
- shell.setLayout(new RowLayout(SWT.VERTICAL));
-
- List peopleList = new List(shell, SWT.BORDER);
- Text name = new Text(shell, SWT.BORDER);
- Combo city = new Combo(shell, SWT.BORDER | SWT.READ_ONLY);
-
- // Bind it
- DataBindingContext bindingContext = new DataBindingFactory1().createContext(shell);
-
- ListViewer peopleListViewer = new ListViewer(peopleList);
- ComboViewer cityViewer = new ComboViewer(city);
-
- bindingContext.bind(peopleListViewer,
- new ListModelDescription(
- new Property(viewModel,
- "people",
- Person.class,
- Boolean.TRUE), "name"),
- null);
-
- IObservable selectedObservable = bindingContext.createObservable(
- new Property(peopleListViewer,
- ViewersProperties.SINGLE_SELECTION,
- Person.class,
- Boolean.FALSE));
-
- bindingContext.bind(name,
- new Property(selectedObservable,
- "name",
- String.class,
- Boolean.FALSE),
- null);
-
- bindingContext.bind(new Property(cityViewer, ViewersProperties.CONTENT),
- new Property(viewModel, "cities"),
- null);
-
- bindingContext.bind(new Property(cityViewer, ViewersProperties.SINGLE_SELECTION),
- new Property(selectedObservable,
- "city",
- String.class,
- Boolean.FALSE),
- null);
-
- // Open and return the Shell
- shell.pack();
- shell.open();
- return shell;
- }
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet002UpdateComboRetainSelection.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet002UpdateComboRetainSelection.java
deleted file mode 100644
index f6d07c49..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet002UpdateComboRetainSelection.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef, Inc. 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:
- * The Pampered Chef, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.snippets;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.examples.databinding.DataBindingFactory1;
-import org.eclipse.jface.internal.databinding.internal.swt.ComboObservableValue;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.swt.SWTProperties;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Shows how to bind a Combo so that when update its items, the selection is
- * retained if at all possible.
- *
- * @since 3.2
- */
-public class Snippet002UpdateComboRetainSelection {
- public static void main(String[] args) {
- ViewModel viewModel = new ViewModel();
- Shell shell = new View(viewModel).createShell();
-
- // The SWT event loop
- Display display = Display.getCurrent();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
-
- // Print the results
- System.out.println(viewModel.getText());
- }
-
- // Minimal JavaBeans support
- static abstract class AbstractModelObject {
- private PropertyChangeSupport propertyChangeSupport =
- new PropertyChangeSupport(this);
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- propertyChangeSupport.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String propertyName,
- PropertyChangeListener listener) {
- propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- propertyChangeSupport.removePropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(String propertyName,
- PropertyChangeListener listener) {
- propertyChangeSupport.removePropertyChangeListener(propertyName,
- listener);
- }
-
- protected void firePropertyChange(String propertyName, Object oldValue,
- Object newValue) {
- propertyChangeSupport.firePropertyChange(propertyName, oldValue,
- newValue);
- }
- }
-
- // The View's model--the root of our Model graph for this particular GUI.
- static class ViewModel extends AbstractModelObject {
- private String text = "beef";
- private List choices = new ArrayList(); {
- choices.add("pork");
- choices.add("beef");
- choices.add("poultry");
- choices.add("vegatables");
- }
-
- public List getChoices() {
- return choices;
- }
- public void setChoices(List choices) {
- this.choices = choices;
- firePropertyChange("choices", null, null);
- }
- public String getText() {
- return text;
- }
- public void setText(String text) {
- String oldValue = this.text;
- this.text = text;
- firePropertyChange("test", oldValue, text);
- }
- }
-
- // The GUI view
- static class View {
- private ViewModel viewModel;
-
- public View(ViewModel viewModel) {
- this.viewModel = viewModel;
- }
-
- public Shell createShell() {
- // Build a UI
- Shell shell = new Shell(Display.getCurrent());
- shell.setLayout(new RowLayout(SWT.VERTICAL));
-
- Combo combo = new Combo(shell, SWT.BORDER | SWT.READ_ONLY);
- Button reset = new Button(shell, SWT.NULL);
- reset.setText("reset collection");
- reset.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- List newList = new ArrayList();
- newList.add("Chocolate");
- newList.add("Vanilla");
- newList.add("Mango Parfait");
- newList.add("beef");
- newList.add("Cheesecake");
- viewModel.setChoices(newList);
- }
- });
-
- // Print value out first
- System.out.println(viewModel.getText());
-
- // Bind it
- DataBindingContext bindingContext = new DataBindingFactory1().createContext(shell);
-
- ComboObservableValue comboValue = (ComboObservableValue) bindingContext.createObservable(new Property(combo, SWTProperties.TEXT));
- bindingContext.bind(comboValue.getItems(), new Property(viewModel, "choices"), null);
- bindingContext.bind(comboValue, new Property(viewModel, "text"), null);
-// bindingContext.bind(combo, new Property(viewModel, "choices", String.class, Boolean.TRUE), null);
-
- // Open and return the Shell
- shell.pack();
- shell.open();
- return shell;
- }
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet003UpdateComboBindUsingViewer.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet003UpdateComboBindUsingViewer.java
deleted file mode 100644
index 7956bae6..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet003UpdateComboBindUsingViewer.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef, Inc. 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:
- * The Pampered Chef, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.snippets;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.examples.databinding.DataBindingFactory1;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersProperties;
-import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Shows how to bind a Combo so that when update its items, the selection is
- * retained if at all possible.
- *
- * @since 3.2
- */
-public class Snippet003UpdateComboBindUsingViewer {
- public static void main(String[] args) {
- ViewModel viewModel = new ViewModel();
- Shell shell = new View(viewModel).createShell();
-
- // The SWT event loop
- Display display = Display.getCurrent();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
-
- // Print the results
- System.out.println(viewModel.getText());
- }
-
- // Minimal JavaBeans support
- static abstract class AbstractModelObject {
- private PropertyChangeSupport propertyChangeSupport =
- new PropertyChangeSupport(this);
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- propertyChangeSupport.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String propertyName,
- PropertyChangeListener listener) {
- propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- propertyChangeSupport.removePropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(String propertyName,
- PropertyChangeListener listener) {
- propertyChangeSupport.removePropertyChangeListener(propertyName,
- listener);
- }
-
- protected void firePropertyChange(String propertyName, Object oldValue,
- Object newValue) {
- propertyChangeSupport.firePropertyChange(propertyName, oldValue,
- newValue);
- }
- }
-
- // The View's model--the root of our Model graph for this particular GUI.
- static class ViewModel extends AbstractModelObject {
- private String text = "beef";
- private List choices = new ArrayList(); {
- choices.add("pork");
- choices.add("beef");
- choices.add("poultry");
- choices.add("vegatables");
- }
-
- public List getChoices() {
- return choices;
- }
- public void setChoices(List choices) {
- this.choices = choices;
- firePropertyChange("choices", null, null);
- }
- public String getText() {
- return text;
- }
- public void setText(String text) {
- String oldValue = this.text;
- this.text = text;
- firePropertyChange("test", oldValue, text);
- }
- }
-
- // The GUI view
- static class View {
- private ViewModel viewModel;
-
- public View(ViewModel viewModel) {
- this.viewModel = viewModel;
- }
-
- public Shell createShell() {
- // Build a UI
- Shell shell = new Shell(Display.getCurrent());
- shell.setLayout(new RowLayout(SWT.VERTICAL));
-
- Combo combo = new Combo(shell, SWT.BORDER | SWT.READ_ONLY);
- ComboViewer viewer = new ComboViewer(combo);
- Button reset = new Button(shell, SWT.NULL);
- reset.setText("reset collection");
- reset.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- List newList = new ArrayList();
- newList.add("Chocolate");
- newList.add("Vanilla");
- newList.add("Mango Parfait");
- newList.add("beef");
- newList.add("Cheesecake");
- viewModel.setChoices(newList);
- }
- });
-
- // Print value out first
- System.out.println(viewModel.getText());
-
- // Bind it
- DataBindingContext bindingContext = new DataBindingFactory1().createContext(shell);
-
- bindingContext.bind(new Property(viewer, ViewersProperties.CONTENT),
- new Property(viewModel, "choices"), null);
- bindingContext.bind(new Property(viewer, ViewersProperties.SINGLE_SELECTION),
- new Property(viewModel, "text"), null);
-
- // Open and return the Shell
- shell.pack();
- shell.open();
- return shell;
- }
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet004DataBindingContextErrorLabel.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet004DataBindingContextErrorLabel.java
deleted file mode 100644
index 0b8720ea..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet004DataBindingContextErrorLabel.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Brad Reynolds 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:
- * Brad Reynolds - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.snippets;
-
-import org.eclipse.jface.databinding.BindSpec;
-import org.eclipse.jface.databinding.DataBindingContext;
-import org.eclipse.jface.databinding.observable.value.WritableValue;
-import org.eclipse.jface.databinding.swt.SWTObservables;
-import org.eclipse.jface.internal.databinding.provisional.validation.IDomainValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.ValidationError;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Snippet that displays how to bind the validation error of the
- * {@link DataBindingContext} to a label.
- *
- * @since 3.2
- */
-public class Snippet004DataBindingContextErrorLabel {
- public static void main(String[] args) {
- Shell shell = new Shell();
- Display display = shell.getDisplay();
- shell.setLayout(new GridLayout(2, false));
-
- new Label(shell, SWT.NONE).setText("Enter '5' to be valid:");
-
- Text text = new Text(shell, SWT.BORDER);
- WritableValue value = new WritableValue(String.class);
- new Label(shell, SWT.NONE).setText("Error:");
-
- Label errorLabel = new Label(shell, SWT.BORDER);
- errorLabel.setForeground(display.getSystemColor(SWT.COLOR_RED));
- GridDataFactory.swtDefaults().hint(200, SWT.DEFAULT).applyTo(errorLabel);
-
- DataBindingContext dbc = DataBindingContext.withDefaults();
-
- // Bind the text to the value.
- dbc.bindValue(SWTObservables.getText(text, SWT.Modify),
- value,
- new BindSpec().setDomainValidator(new FiveValidator()));
-
- // Bind the error label to the validation error on the dbc.
- dbc.bindValue(SWTObservables.getText(errorLabel), dbc.getValidationError(), null);
-
- shell.pack();
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- }
-
- /**
- * Validator that returns validation errors for any value other than 5.
- *
- * @since 3.2
- */
- private static class FiveValidator implements IDomainValidator {
- public ValidationError isValid(Object value) {
- return ("5".equals(value)) ? null : ValidationError.error("the value was '" + value + "', not '5'");
- }
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/spreadsheet/Spreadsheet.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/spreadsheet/Spreadsheet.java
deleted file mode 100644
index 26ed787b..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/spreadsheet/Spreadsheet.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*******************************************************************************
- * 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.examples.databinding.spreadsheet;
-
-import java.text.NumberFormat;
-import java.text.ParseException;
-
-import org.eclipse.jface.databinding.observable.value.ComputedValue;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.databinding.observable.value.WritableValue;
-import org.eclipse.jface.internal.databinding.provisional.swt.TableUpdater;
-import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ControlEditor;
-import org.eclipse.swt.custom.TableCursor;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * @since 1.1
- *
- */
-public class Spreadsheet {
-
- private static final int COUNTER_UPDATE_DELAY = 1000;
-
- private static final int NUM_COLUMNS = 26;
-
- private static final int NUM_ROWS = 200;
-
- /**
- * 0 for no output, 1 for some, 2 for more
- */
- private static int DEBUG_LEVEL = 0;
-
- /**
- * If true, there will be a automatic counter at B1.
- */
- private static boolean FUNKY_COUNTER = true;
-
- /**
- * // * If true, all formulas (except for row 1 and column A) will be the
- * sum of the values of their left and top neighbouring cells.
- */
- private static boolean FUNKY_FORMULAS = true;
-
- static WritableValue[][] cellFormulas = new WritableValue[NUM_ROWS][NUM_COLUMNS];
-
- static ComputedValue[][] cellValues = new ComputedValue[NUM_ROWS][NUM_COLUMNS];
-
- static class ComputedCellValue extends ComputedValue {
- private final IObservableValue cellFormula;
-
- private boolean calculating;
-
- ComputedCellValue(IObservableValue cellFormula) {
- this.cellFormula = cellFormula;
- }
-
- protected Object calculate() {
- if (calculating) {
- return "#cycle";
- }
- try {
- calculating = true;
- return evaluate(cellFormula.getValue());
- } finally {
- calculating = false;
- }
- }
-
- private Object evaluate(Object value) {
- if (DEBUG_LEVEL >= 2) {
- System.out.println("evaluating " + this + " ...");
- }
- if (value == null) {
- return "";
- }
- try {
- String s = (String) value;
- if (!s.startsWith("=")) {
- return s;
- }
- String addition = s.substring(1);
- int indexOfPlus = addition.indexOf('+');
- String operand1 = addition.substring(0, indexOfPlus);
- double value1 = eval(operand1);
- String operand2 = addition.substring(indexOfPlus + 1);
- double value2 = eval(operand2);
- return NumberFormat.getNumberInstance().format(value1 + value2);
- } catch (Exception ex) {
- return ex.getMessage();
- }
- }
-
- /**
- * @param s
- * @return
- * @throws ParseException
- */
- private double eval(String s) throws ParseException {
- if (s.length() == 0) {
- return 0;
- }
- char character = s.charAt(0);
- if (Character.isLetter(character)) {
- character = Character.toLowerCase(character);
- // reference to other cell
- int columnIndex = character - 'a';
- int rowIndex = 0;
- rowIndex = NumberFormat.getNumberInstance().parse(
- s.substring(1)).intValue() - 1;
- String value = (String) cellValues[rowIndex][columnIndex]
- .getValue();
- return value.length() == 0 ? 0 : NumberFormat
- .getNumberInstance().parse(value).doubleValue();
- }
- return NumberFormat.getNumberInstance().parse(s).doubleValue();
- }
- }
-
- protected static int counter;
-
- public static void main(String[] args) {
-
- final Display display = new Display();
- Shell shell = new Shell(display);
-
- final Table table = new Table(shell, SWT.BORDER | SWT.MULTI
- | SWT.FULL_SELECTION);
- table.setLinesVisible(true);
- table.setHeaderVisible(true);
-
- for (int i = 0; i < NUM_COLUMNS; i++) {
- TableColumn tableColumn = new TableColumn(table, SWT.NONE);
- tableColumn.setText(Character.toString((char) ('A' + i)));
- tableColumn.setWidth(40);
- }
- for (int i = 0; i < NUM_ROWS; i++) {
- new TableItem(table, SWT.NONE);
- for (int j = 0; j < NUM_COLUMNS; j++) {
- cellFormulas[i][j] = new WritableValue(null);
- cellValues[i][j] = new ComputedCellValue(cellFormulas[i][j]);
- if (!FUNKY_FORMULAS || i == 0 || j == 0) {
- cellFormulas[i][j].setValue("");
- } else {
- cellFormulas[i][j].setValue("=" + cellReference(i - 1, j)
- + "+" + cellReference(i, j - 1));
- }
- }
- }
-
- new TableUpdater(table) {
- protected void updateItem(TableItem item) {
- int rowIndex = item.getParent().indexOf(item);
- if (DEBUG_LEVEL >= 1) {
- System.out.println("updating row " + rowIndex);
- }
- for (int j = 0; j < NUM_COLUMNS; j++) {
- item
- .setText(j, (String) cellValues[rowIndex][j]
- .getValue());
- }
- }
- };
-
- if (FUNKY_COUNTER) {
- // counter in A1
- display.asyncExec(new Runnable() {
- public void run() {
- cellFormulas[0][1].setValue("" + counter++);
- display.timerExec(COUNTER_UPDATE_DELAY, this);
- }
- });
- }
-
- // create a TableCursor to navigate around the table
- final TableCursor cursor = new TableCursor(table, SWT.NONE);
- // create an editor to edit the cell when the user hits "ENTER"
- // while over a cell in the table
- final ControlEditor editor = new ControlEditor(cursor);
- editor.grabHorizontal = true;
- editor.grabVertical = true;
-
- cursor.addSelectionListener(new SelectionAdapter() {
- // when the TableEditor is over a cell, select the corresponding row
- // in
- // the table
- public void widgetSelected(SelectionEvent e) {
- table.setSelection(new TableItem[] { cursor.getRow() });
- }
-
- // when the user hits "ENTER" in the TableCursor, pop up a text
- // editor so that
- // they can change the text of the cell
- public void widgetDefaultSelected(SelectionEvent e) {
- final Text text = new Text(cursor, SWT.NONE);
- TableItem row = cursor.getRow();
- int rowIndex = table.indexOf(row);
- int columnIndex = cursor.getColumn();
- text.setText((String) cellFormulas[rowIndex][columnIndex]
- .getValue());
- text.addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- // close the text editor and copy the data over
- // when the user hits "ENTER"
- if (e.character == SWT.CR) {
- TableItem row = cursor.getRow();
- int rowIndex = table.indexOf(row);
- int columnIndex = cursor.getColumn();
- cellFormulas[rowIndex][columnIndex].setValue(text
- .getText());
- text.dispose();
- }
- // close the text editor when the user hits "ESC"
- if (e.character == SWT.ESC) {
- text.dispose();
- }
- }
- });
- editor.setEditor(text);
- text.setFocus();
- }
- });
- // Hide the TableCursor when the user hits the "MOD1" or "MOD2" key.
- // This alows the user to select multiple items in the table.
- cursor.addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- if (e.keyCode == SWT.MOD1 || e.keyCode == SWT.MOD2
- || (e.stateMask & SWT.MOD1) != 0
- || (e.stateMask & SWT.MOD2) != 0) {
- cursor.setVisible(false);
- }
- }
- });
- // Show the TableCursor when the user releases the "MOD2" or "MOD1" key.
- // This signals the end of the multiple selection task.
- table.addKeyListener(new KeyAdapter() {
- public void keyReleased(KeyEvent e) {
- if (e.keyCode == SWT.MOD1 && (e.stateMask & SWT.MOD2) != 0)
- return;
- if (e.keyCode == SWT.MOD2 && (e.stateMask & SWT.MOD1) != 0)
- return;
- if (e.keyCode != SWT.MOD1 && (e.stateMask & SWT.MOD1) != 0)
- return;
- if (e.keyCode != SWT.MOD2 && (e.stateMask & SWT.MOD2) != 0)
- return;
-
- TableItem[] selection = table.getSelection();
- TableItem row = (selection.length == 0) ? table.getItem(table
- .getTopIndex()) : selection[0];
- table.showItem(row);
- cursor.setSelection(row, 0);
- cursor.setVisible(true);
- cursor.setFocus();
- }
- });
-
- GridLayoutFactory.fillDefaults().generateLayout(shell);
- shell.setSize(400, 300);
- shell.open();
-
- // The SWT event loop
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
-
- }
-
- private static String cellReference(int rowIndex, int columnIndex) {
- String cellReference = "" + ((char) ('A' + columnIndex))
- + (rowIndex + 1);
- return cellReference;
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/layout/GridDataFactory.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/layout/GridDataFactory.java
deleted file mode 100644
index bdb67f1c..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/layout/GridDataFactory.java
+++ /dev/null
@@ -1,400 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.layout;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * This class provides a convienient shorthand for creating and initializing
- * GridData. This offers several benefits over creating GridData normal way:
- *
- * <ul>
- * <li>The same factory can be used many times to create several GridData instances</li>
- * <li>The setters on GridDataFactory all return "this", allowing them to be chained</li>
- * <li>GridDataFactory uses vector setters (it accepts Points), making it easy to
- * set X and Y values together</li>
- * </ul>
- *
- * <p>
- * GridDataFactory instances are created using one of the static methods on this class.
- * </p>
- *
- * <p>
- * Example usage:
- * </p>
- * <code>
- *
- * ////////////////////////////////////////////////////////////
- * // Example 1: Typical grid data for a non-wrapping label
- *
- * // GridDataFactory version
- * GridDataFactory.fillDefaults().applyTo(myLabel);
- *
- * // Equivalent SWT version
- * GridData labelData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
- * myLabel.setLayoutData(labelData);
- *
- * ///////////////////////////////////////////////////////////
- * // Example 2: Typical grid data for a wrapping label
- *
- * // GridDataFactory version
- * GridDataFactory.fillDefaults()
- * .align(SWT.FILL, SWT.CENTER)
- * .hint(150, SWT.DEFAULT)
- * .grab(true, false)
- * .applyTo(wrappingLabel);
- *
- * // Equivalent SWT version
- * GridData wrappingLabelData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
- * wrappingLabelData.minimumWidth = 1;
- * wrappingLabelData.widthHint = 150;
- * wrappingLabel.setLayoutData(wrappingLabelData);
- *
- * //////////////////////////////////////////////////////////////
- * // Example 3: Typical grid data for a scrollable control (a list box, tree, table, etc.)
- *
- * // GridDataFactory version
- * GridDataFactory.fillDefaults().grab(true, true).hint(150, 150).applyTo(listBox);
- *
- * // Equivalent SWT version
- * GridData listBoxData = new GridData(GridData.FILL_BOTH);
- * listBoxData.widthHint = 150;
- * listBoxData.heightHint = 150;
- * listBoxData.minimumWidth = 1;
- * listBoxData.minimumHeight = 1;
- * listBox.setLayoutData(listBoxData);
- *
- * /////////////////////////////////////////////////////////////
- * // Example 4: Typical grid data for a button
- *
- * // GridDataFactory version
- * Point preferredSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
- * Point hint = Geometry.max(LayoutConstants.getMinButtonSize(), preferredSize);
- * GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).hint(hint).applyTo(button);
- *
- * // Equivalent SWT version
- * Point preferredSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
- * Point hint = Geometry.max(LayoutConstants.getMinButtonSize(), preferredSize);
- * GridData buttonData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
- * buttonData.widthHint = hint.x;
- * buttonData.heightHint = hint.y;
- * button.setLayoutData(buttonData);
- * </code>
- *
- * <p>
- * IMPORTANT: WHEN ASSIGNING LAYOUT DATA TO A CONTROL, BE SURE TO USE
- * gridDataFactory.applyTo(control) AND NEVER
- * control.setLayoutData(gridDataFactory).
- * </p>
- *
- */
-public final class GridDataFactory {
- private GridData data;
-
- /**
- * Creates a GridDataFactory that creates copes of the given GridData.
- *
- * @param d template GridData to copy
- */
- private GridDataFactory(GridData d) {
- this.data = d;
- }
-
- /**
- * Creates a new GridDataFactory initialized with the SWT defaults.
- * This factory will generate GridData that is equivalent to
- * "new GridData()".
- *
- * <p>
- * Initial values are:
- * </p>
- *
- * <ul>
- * <li>align(SWT.BEGINNING, SWT.CENTER)</li>
- * <li>exclude(false)</li>
- * <li>grab(false, false)</li>
- * <li>hint(SWT.DEFAULT, SWT.DEFAULT)</li>
- * <li>indent(0,0)</li>
- * <li>minSize(0,0)</li>
- * <li>span(1,1)</li>
- * </ul>
- *
- * @return a new GridDataFactory instance
- * @see fillDefaults
- */
- public static GridDataFactory swtDefaults() {
- return new GridDataFactory(new GridData());
- }
-
- /**
- * Creates a new GridDataFactory that creates copies of the given GridData
- * by default.
- *
- * @param data GridData to copy
- * @return a new GridDataFactory that creates copies of the argument by default
- */
- public static GridDataFactory createFrom(GridData data) {
- return new GridDataFactory(copyData(data));
- }
-
- /**
- * Creates a GridDataFactory initialized with defaults that will cause
- * the control to fill its cell.
- *
- * <p>
- * Initial values are:
- * </p>
- *
- * <ul>
- * <li>align(SWT.FILL, SWT.FILL)</li>
- * <li>exclude(false)</li>
- * <li>grab(false, false)</li>
- * <li>hint(SWT.DEFAULT, SWT.DEFAULT)</li>
- * <li>indent(0,0)</li>
- * <li>minSize(1,1)</li>
- * <li>span(1,1)</li>
- * </ul>
- *
- * @return a GridDataFactory that makes controls fill their grid by default
- *
- * @see swtDefaults
- */
- public static GridDataFactory fillDefaults() {
- GridData data = new GridData();
- data.minimumWidth = 1;
- data.minimumHeight = 1;
- data.horizontalAlignment = SWT.FILL;
- data.verticalAlignment = SWT.FILL;
-
- return new GridDataFactory(data);
- }
-
- /**
- * Sets the GridData span. The span controls how many cells
- * are filled by the control.
- *
- * @param hSpan number of columns spanned by the control
- * @param vSpan number of rows spanned by the control
- * @return this
- */
- public GridDataFactory span(int hSpan, int vSpan) {
- data.horizontalSpan = hSpan;
- data.verticalSpan = vSpan;
- return this;
- }
-
- /**
- * Sets the GridData span. The span controls how many cells
- * are filled by the control.
- *
- * @param span the new span. The x coordinate indicates the number of
- * columns spanned, and the y coordinate indicates the number of rows.
- * @return this
- */
- public GridDataFactory span(Point span) {
- data.horizontalSpan = span.x;
- data.verticalSpan = span.y;
- return this;
- }
-
- /**
- * Sets the width and height hints. The width and height hints override
- * the control's preferred size. If either hint is set to SWT.DEFAULT,
- * the control's preferred size is used.
- *
- * @param xHint horizontal hint (pixels), or SWT.DEFAULT to use the control's preferred size
- * @param yHint vertical hint (pixels), or SWT.DEFAULT to use the control's preferred size
- * @return this
- */
- public GridDataFactory hint(int xHint, int yHint) {
- data.widthHint = xHint;
- data.heightHint = yHint;
- return this;
- }
-
- /**
- * Sets the width and height hints. The width and height hints override
- * the control's preferred size. If either hint is set to SWT.DEFAULT,
- * the control's preferred size is used.
- *
- * @param hint size (pixels) to be used instead of the control's preferred size. If
- * the x or y values are set to SWT.DEFAULT, the control's computeSize() method will
- * be used to obtain that dimension of the preferred size.
- * @return this
- */
- public GridDataFactory hint(Point hint) {
- data.widthHint = hint.x;
- data.heightHint = hint.y;
- return this;
- }
-
- /**
- * Sets the alignment of the control within its cell.
- *
- * @param hAlign horizontal alignment. One of SWT.BEGINNING, SWT.CENTER, SWT.END, or SWT.FILL.
- * @param vAlign vertical alignment. One of SWT.BEGINNING, SWT.CENTER, SWT.END, or SWT.FILL.
- * @return this
- */
- public GridDataFactory align(int hAlign, int vAlign) {
- data.horizontalAlignment = hAlign;
- data.verticalAlignment = vAlign;
- return this;
- }
-
- /**
- * Sets the indent of the control within the cell. Moves the position of the control
- * by the given number of pixels. Positive values move toward the lower-right, negative
- * values move toward the upper-left.
- *
- * @param hIndent distance to move to the right (negative values move left)
- * @param vIndent distance to move down (negative values move up)
- * @return this
- */
- public GridDataFactory indent(int hIndent, int vIndent) {
- data.horizontalIndent = hIndent;
- data.verticalIndent = vIndent;
- return this;
- }
-
- /**
- * Sets the indent of the control within the cell. Moves the position of the control
- * by the given number of pixels. Positive values move toward the lower-right, negative
- * values move toward the upper-left.
- *
- * @param indent offset to move the control
- * @return this
- */
- public GridDataFactory indent(Point indent) {
- data.horizontalIndent = indent.x;
- data.verticalIndent = indent.y;
- return this;
- }
-
- /**
- * Determines whether extra horizontal or vertical space should be allocated to
- * this control's column when the layout resizes. If any control in the column
- * is set to grab horizontal then the whole column will grab horizontal space.
- * If any control in the row is set to grab vertical then the whole row will grab
- * vertical space.
- *
- * @param horizontal true if the control's column should grow horizontally
- * @param vertical true if the control's row should grow vertically
- * @return this
- */
- public GridDataFactory grab(boolean horizontal, boolean vertical) {
- data.grabExcessHorizontalSpace = horizontal;
- data.grabExcessVerticalSpace = vertical;
- return this;
- }
-
- /**
- * Sets the minimum size for the control. The control will not be permitted
- * to shrink below this size. Note: GridLayout treats a minimum size of 0
- * as an undocumented special value, so the smallest possible minimum size
- * is a size of 1. A minimum size of SWT.DEFAULT indicates that the result
- * of computeSize(int, int, boolean) should be used as the control's minimum
- * size.
- *
- *
- * @param minX minimum a value of 1 or more is a horizontal size of the control (pixels).
- * SWT.DEFAULT indicates that the control's preferred size should be used. A size
- * of 0 has special semantics defined by GridLayout.
- * @param minY minimum a value of 1 or more is a vertical size of the control (pixels). SWT.DEFAULT
- * indicates that the control's preferred size should be used. A size
- * of 0 has special semantics defined by GridLayout.
- * @return this
- */
- public GridDataFactory minSize(int minX, int minY) {
- data.minimumWidth = minX;
- data.minimumHeight = minY;
- return this;
- }
-
- /**
- * Sets the minimum size for the control. The control will not be permitted
- * to shrink below this size. Note: GridLayout treats a minimum size of 0
- * as an undocumented special value, so the smallest possible minimum size
- * is a size of 1. A minimum size of SWT.DEFAULT indicates that the result
- * of computeSize(int, int, boolean) should be used as the control's minimum
- * size.
- *
- * @param min minimum size of the control
- * @return this
- */
- public GridDataFactory minSize(Point min) {
- data.minimumWidth = min.x;
- data.minimumHeight = min.y;
- return this;
- }
-
- /**
- * Instructs the GridLayout to ignore this control when performing layouts.
- *
- * @param shouldExclude true iff the control should be excluded from layouts
- * @return this
- */
- public GridDataFactory exclude(boolean shouldExclude) {
- data.exclude = shouldExclude;
- return this;
- }
-
- /**
- * Creates a new GridData instance. All attributes of the GridData instance
- * will be initialized by the factory.
- *
- * @return a new GridData instance
- */
- public GridData create() {
- return copyData(data);
- }
-
- /**
- * Creates a copy of the reciever.
- *
- * @return a copy of the reciever
- */
- public GridDataFactory copy() {
- return new GridDataFactory(create());
- }
-
- /**
- * Returns a copy of the given GridData
- *
- * @param data GridData to copy
- * @return a copy of the argument
- */
- public static GridData copyData(GridData data) {
- GridData newData = new GridData(data.horizontalAlignment, data.verticalAlignment, data.grabExcessHorizontalSpace, data.grabExcessVerticalSpace, data.horizontalSpan,
- data.verticalSpan);
- newData.exclude = data.exclude;
- newData.heightHint = data.heightHint;
- newData.horizontalIndent = data.horizontalIndent;
- newData.minimumHeight = data.minimumHeight;
- newData.minimumWidth = data.minimumWidth;
- newData.verticalIndent = data.verticalIndent;
- newData.widthHint = data.widthHint;
-
- return newData;
- }
-
- /**
- * Sets the layout data on the given control. Creates a new GridData instance and
- * assigns it to the control by calling control.setLayoutData.
- *
- * @param control control whose layout data will be initialized
- */
- public void applyTo(Control control) {
- control.setLayoutData(create());
- }
-
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/layout/GridLayoutFactory.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/layout/GridLayoutFactory.java
deleted file mode 100644
index 623d40f8..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/layout/GridLayoutFactory.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.layout;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * GridLayoutFactory creates and initializes grid layouts. There are two ways to use GridLayoutFactory.
- * Normally, it is used as a shorthand for writing "new GridLayout()" and initializing a bunch
- * of fields. In this case the main benefit is a more concise syntax and the ability to create more
- * than one identical GridLayout from the same factory. Changing a property of the factory will affect
- * future layouts created by the factory, but has no effect on layouts that have already been created.
- *
- * <p>
- * GridLayoutFactory can also generate grid data for all the controls in a layout. This is done with
- * the generateLayout method. To use this feature:
- * </p>
- *
- * <ol>
- * <li>Create the composite</li>
- * <li>Create all the controls in the composite</li>
- * <li>Call generateLayout</li>
- * </ol>
- *
- * <p>
- * The order here is important. generateLayout must be called after all the child controls have
- * been created. generateLayout will not change any layout data that has already been attached
- * to a child control and it will not recurse into nested composites.
- * </p>
- *
- * @since 1.0
- */
-public final class GridLayoutFactory {
-
- /**
- * Template layout. The factory will create copies of this layout.
- */
- private GridLayout l;
-
- /**
- * Creates a new GridLayoutFactory that will create copies of the given layout.
- *
- * @param l layout to copy
- */
- private GridLayoutFactory(GridLayout l) {
- this.l = l;
- }
-
- /**
- * Creates a factory that creates copies of the given layout.
- *
- * @param l layout to copy
- * @return a new GridLayoutFactory instance that creates copies of the given layout
- */
- public static GridLayoutFactory createFrom(GridLayout l) {
- return new GridLayoutFactory(copyLayout(l));
- }
-
- /**
- * Creates a copy of the reciever.
- *
- * @return a copy of the reciever
- */
- public GridLayoutFactory copy() {
- return new GridLayoutFactory(create());
- }
-
- /**
- * Creates a GridLayoutFactory that creates GridLayouts with the default SWT
- * values.
- *
- * <p>
- * Initial values are:
- * </p>
- *
- * <ul>
- * <li>numColumns(1)</li>
- * <li>margins(5,5)</li>
- * <li>spacing(5,5)</li>
- * <li>equalWidth(false)</li>
- * </ul>
- *
- * @return a GridLayoutFactory that creates GridLayouts as though created with
- * their default constructor
- * @see #fillDefaults
- */
- public static GridLayoutFactory swtDefaults() {
- return new GridLayoutFactory(new GridLayout());
- }
-
- /**
- * Creates a GridLayoutFactory that creates GridLayouts with no margins and
- * default dialog spacing.
- *
- * <p>
- * Initial values are:
- * </p>
- *
- * <ul>
- * <li>numColumns(1)</li>
- * <li>margins(0,0)</li>
- * <li>spacing(LayoutConstants.getSpacing())</li>
- * <li>equalWidth(false)</li>
- * </ul>
- *
- * @return a GridLayoutFactory that creates GridLayouts as though created with
- * their default constructor
- * @see #swtDefaults
- */
- public static GridLayoutFactory fillDefaults() {
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- Point defaultSpacing = LayoutConstants.getSpacing();
- layout.horizontalSpacing = defaultSpacing.x;
- layout.verticalSpacing = defaultSpacing.y;
- return new GridLayoutFactory(layout);
- }
-
- /**
- * Sets whether the columns should be forced to be equal width
- *
- * @param equal true iff the columns should be forced to be equal width
- * @return this
- */
- public GridLayoutFactory equalWidth(boolean equal) {
- l.makeColumnsEqualWidth = equal;
- return this;
- }
-
- /**
- * Sets the spacing for layouts created with this factory. The spacing
- * is the distance between cells within the layout.
- *
- * @param hSpacing horizontal spacing (pixels)
- * @param vSpacing vertical spacing (pixels)
- * @return this
- * @see #margins
- */
- public GridLayoutFactory spacing(int hSpacing, int vSpacing) {
- l.horizontalSpacing = hSpacing;
- l.verticalSpacing = vSpacing;
- return this;
- }
-
- /**
- * Sets the spacing for layouts created with this factory. The spacing
- * is the distance between cells within the layout.
- *
- * @param spacing space between controls in the layout (pixels)
- * @return this
- * @see #margins
- */
- public GridLayoutFactory spacing(Point spacing) {
- l.horizontalSpacing = spacing.x;
- l.verticalSpacing = spacing.y;
- return this;
- }
-
- /**
- * Sets the margins for layouts created with this factory. The margins
- * are the distance between the outer cells and the edge of the layout.
- *
- * @param margins margin size (pixels)
- * @return this
- * @see #spacing
- */
- public GridLayoutFactory margins(Point margins) {
- l.marginWidth = margins.x;
- l.marginHeight = margins.y;
- return this;
- }
-
- /**
- * Sets the margins for layouts created with this factory. The margins
- * are the distance between the outer cells and the edge of the layout.
- *
- * @param x horizontal margin size (pixels)
- * @param y vertical margin size (pixels)
- * @return this
- * @see #spacing
- */
- public GridLayoutFactory margins(int x, int y) {
- l.marginWidth = x;
- l.marginHeight = y;
- return this;
- }
-
- /**
- * Sets the number of columns in the layout
- *
- * @param numColumns number of columns in the layout
- * @return this
- */
- public GridLayoutFactory numColumns(int numColumns) {
- l.numColumns = numColumns;
- return this;
- }
-
- /**
- * Creates a new GridLayout, and initializes it with values from the factory.
- *
- * @return a new initialized GridLayout.
- * @see #applyTo
- */
- public GridLayout create() {
- return copyLayout(l);
- }
-
- /**
- * Creates a new GridLayout and attaches it to the given composite.
- * Does not create the GridData of any of the controls in the composite.
- *
- * @param c composite whose layout will be set
- * @see #generateLayout
- * @see #create
- * @see GridLayoutFactory
- */
- public void applyTo(Composite c) {
- c.setLayout(copyLayout(l));
- }
-
- /**
- * Copies the given GridLayout instance
- *
- * @param l layout to copy
- * @return a new GridLayout
- */
- public static GridLayout copyLayout(GridLayout l) {
- GridLayout result = new GridLayout(l.numColumns, l.makeColumnsEqualWidth);
- result.horizontalSpacing = l.horizontalSpacing;
- result.marginBottom = l.marginBottom;
- result.marginHeight = l.marginHeight;
- result.marginLeft = l.marginLeft;
- result.marginRight = l.marginRight;
- result.marginTop = l.marginTop;
- result.marginWidth = l.marginWidth;
- result.verticalSpacing = l.verticalSpacing;
-
- return result;
- }
-
- /**
- * Applies this layout to the given composite, and attaches default GridData
- * to all immediate children that don't have one. The layout is generated using
- * heuristics based on the widget types. In most cases, it will create exactly the same
- * layout that would have been hardcoded by the programmer. In any situation
- * where it does not produce the desired layout, the GridData for any child can be
- * overridden by attaching the layout data before calling this method. In these cases,
- * the special-case layout data can be hardcoded and the algorithm can supply defaults
- * to the rest.
- *
- * <p>
- * This must be called <b>AFTER</b> all of the child controls have been created and their
- * layouts attached. This method will attach a layout to the given composite. If any new
- * children are created after calling this method, their GridData must be created manually.
- * The algorithm does not recurse into child composites. To generate all the layouts in
- * a widget hierarchy, the method must be called bottom-up for each Composite.
- * </p>
- *
- * <p>
- * All controls are made to span a single cell. The algorithm tries to classify controls into one
- * of the following categories:
- * </p>
- *
- * <ul>
- * <li>Pushbuttons: Set to a constant size large enough to fit their text and no smaller
- * than the default button size.</li>
- * <li>Wrapping with text (labels, read-only text boxes, etc.): override the preferred horizontal
- * size with the default wrapping point, fill horizontally, grab horizontal space, keep the
- * preferred vertical size</li>
- * <li>Wrapping without text (toolbars, coolbars, etc.): fill align, don't grab, use the preferred size</li>
- * <li>Horizontally scrolling controls (anything with horizontal scrollbars or where the user edits
- * text and can cursor through it from left-to-right): override the preferred horizontal size with
- * a constant, grab horizontal, fill horizontal.</li>
- * <li>Vertically scrolling controls (anything with vertical scrollbars or where the user edits
- * text and can cursor through it up and down): override the preferred vertical size with a constant,
- * grab vertical, fill vertical</li>
- * <li>Nested layouts: fill align both directions, grab along any dimension if the layout would
- * be able to expand along that dimension.</li>
- * <li>Non-wrapping non-scrollable read-only text: fill horizontally, center vertically, default size, don't grab </li>
- * <li>Non-wrapping non-scrollable non-text: fill both, default size, don't grab</li>
- * </ul>
- *
- * @param c composite whose layout will be generated
- */
- public void generateLayout(Composite c) {
- applyTo(c);
- LayoutGenerator.generateLayout(c);
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/layout/LayoutConstants.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/layout/LayoutConstants.java
deleted file mode 100644
index 33632b4d..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/layout/LayoutConstants.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.layout;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.graphics.FontMetrics;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * Contains various layout constants
- *
- * @since 1.0
- */
-public final class LayoutConstants {
- private static Point dialogMargins = null;
- private static Point dialogSpacing = null;
- private static Point minButtonSize = null;
-
- private static void initializeConstants() {
- if (dialogMargins != null) {
- return;
- }
-
- GC gc = new GC(Display.getCurrent());
- gc.setFont(JFaceResources.getDialogFont());
- FontMetrics fontMetrics = gc.getFontMetrics();
-
- dialogMargins = new Point(Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_MARGIN),
- Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_MARGIN));
-
- dialogSpacing = new Point(Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_SPACING),
- Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_SPACING));
-
- minButtonSize = new Point(Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH), 0);
-
- gc.dispose();
- }
-
- /**
- * Returns the default dialog margins, in pixels
- *
- * @return the default dialog margins, in pixels
- */
- public static final Point getMargins() {
- initializeConstants();
- return dialogMargins;
- }
-
- /**
- * Returns the default dialog spacing, in pixels
- *
- * @return the default dialog spacing, in pixels
- */
- public static final Point getSpacing() {
- initializeConstants();
- return dialogSpacing;
- }
-
- /**
- * Returns the default minimum button size, in pixels
- *
- * @return the default minimum button size, in pixels
- */
- public static final Point getMinButtonSize() {
- initializeConstants();
- return minButtonSize;
- }
-}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/layout/LayoutGenerator.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/layout/LayoutGenerator.java
deleted file mode 100644
index 1b2c8ac9..00000000
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/layout/LayoutGenerator.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.layout;
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Scrollable;
-
-/* package */class LayoutGenerator {
-
- /**
- * Default size for controls with varying contents
- */
- private static final Point defaultSize = new Point(150, 150);
-
- /**
- * Default wrapping size for wrapped labels
- */
- private static final int wrapSize = 350;
-
- private static final GridDataFactory nonWrappingLabelData = GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).grab(false, false);
-
- private static boolean hasStyle(Control c, int style) {
- return (c.getStyle() & style) != 0;
- }
-
- /**
- * Generates a GridLayout for the given composite by examining its child
- * controls and attaching layout data to any immediate children that do not
- * already have layout data.
- *
- * @param toGenerate
- * composite to generate a layout for
- * @param columns
- * number of columns for the layout
- */
- public static void generateLayout(Composite toGenerate) {
- Control[] children = toGenerate.getChildren();
-
- for (int i = 0; i < children.length; i++) {
- Control control = children[i];
-
- // Skip any children that already have layout data
- if (control.getLayoutData() != null) {
- continue;
- }
-
- applyLayoutDataTo(control);
- }
- }
-
- private static void applyLayoutDataTo(Control control) {
- if (control instanceof Button) {
- Button button = (Button) control;
-
- if (hasStyle(button, SWT.CHECK)) {
- nonWrappingLabelData.applyTo(button);
- } else {
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).hint(Geometry.max(button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true), LayoutConstants.getMinButtonSize()))
- .applyTo(button);
- }
- return;
- }
-
- // if (control instanceof Label) {
- // Label label = (Label) control;
- //
- // if (hasStyle(label, SWT.WRAP)) {
- // wrappingLabelData.applyTo(label);
- // } else {
- // nonWrappingLabelData.applyTo(label);
- // }
- // return;
- // }
-
- if (control instanceof Scrollable) {
- Scrollable scrollable = (Scrollable) control;
-
- if (scrollable instanceof Composite) {
- Composite composite = (Composite) scrollable;
-
- Layout theLayout = composite.getLayout();
- if (theLayout instanceof GridLayout) {
- boolean growsHorizontally = false;
- boolean growsVertically = false;
-
- Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; i++) {
- Control child = children[i];
-
- GridData data = (GridData) child.getLayoutData();
-
- if (data != null) {
- if (data.grabExcessHorizontalSpace) {
- growsHorizontally = true;
- }
- if (data.grabExcessVerticalSpace) {
- growsVertically = true;
- }
- }
- }
-
- GridDataFactory.fillDefaults().grab(growsHorizontally, growsVertically).applyTo(control);
- return;
- }
- }
- }
-
- boolean wrapping = hasStyle(control, SWT.WRAP);
-
- // Assume any control with the H_SCROLL or V_SCROLL flags are
- // horizontally or vertically
- // scrollable, respectively.
- boolean hScroll = hasStyle(control, SWT.H_SCROLL);
- boolean vScroll = hasStyle(control, SWT.V_SCROLL);
-
- boolean containsText = hasMethod(control, "setText", new Class[] { String.class }); //$NON-NLS-1$
-
- // If the control has a setText method, an addModifyListener method, and
- // does not have
- // the SWT.READ_ONLY flag, assume it contains user-editable text.
- boolean userEditable = !hasStyle(control, SWT.READ_ONLY) && containsText && hasMethod(control, "addModifyListener", new Class[] { ModifyListener.class }); //$NON-NLS-1$
-
- // For controls containing user-editable text...
- if (userEditable) {
- if (hasStyle(control, SWT.MULTI)) {
- vScroll = true;
- }
-
- if (!wrapping) {
- hScroll = true;
- }
- }
-
- // Compute the horizontal hint
- int hHint = SWT.DEFAULT;
- boolean grabHorizontal = hScroll;
-
- // For horizontally-scrollable controls, override their horizontal
- // preferred size
- // with a constant
- if (hScroll) {
- hHint = defaultSize.x;
- } else {
- // For wrapping controls, there are two cases.
- // 1. For controls that contain text (like wrapping labels,
- // read-only text boxes,
- // etc.) override their preferred size with the preferred wrapping
- // point and
- // make them grab horizontal space.
- // 2. For non-text controls (like wrapping toolbars), assume that
- // their non-wrapped
- // size is best.
-
- if (wrapping) {
- if (containsText) {
- hHint = wrapSize;
- grabHorizontal = true;
- }
- }
- }
-
- int vAlign = SWT.FILL;
-
- // Heuristic for labels: Controls that contain non-wrapping read-only
- // text should be
- // center-aligned rather than fill-aligned
- if (!vScroll && !wrapping && !userEditable && containsText) {
- vAlign = SWT.CENTER;
- }
-
- GridDataFactory.fillDefaults().grab(grabHorizontal, vScroll).align(SWT.FILL, vAlign).hint(hHint, vScroll ? defaultSize.y : SWT.DEFAULT).applyTo(control);
- return;
- }
-
- private static boolean hasMethod(Control control, String name, Class[] parameterTypes) {
- Class c = control.getClass();
- try {
- return c.getMethod(name, parameterTypes) != null;
- } catch (SecurityException e) {
- return false;
- } catch (NoSuchMethodException e) {
- return false;
- }
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/.classpath b/tests/org.eclipse.jface.tests.databinding/.classpath
deleted file mode 100644
index d512f63a..00000000
--- a/tests/org.eclipse.jface.tests.databinding/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/executionEnvironments/J2SE-1.4"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/tests/org.eclipse.jface.tests.databinding/.cvsignore b/tests/org.eclipse.jface.tests.databinding/.cvsignore
deleted file mode 100644
index ba077a40..00000000
--- a/tests/org.eclipse.jface.tests.databinding/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/tests/org.eclipse.jface.tests.databinding/.project b/tests/org.eclipse.jface.tests.databinding/.project
deleted file mode 100644
index 815de410..00000000
--- a/tests/org.eclipse.jface.tests.databinding/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jface.tests.databinding</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/tests/org.eclipse.jface.tests.databinding/.settings/org.eclipse.jdt.core.prefs b/tests/org.eclipse.jface.tests.databinding/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 3268699f..00000000
--- a/tests/org.eclipse.jface.tests.databinding/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,71 +0,0 @@
-#Mon Aug 28 10:09:27 EDT 2006
-eclipse.preferences.version=1
-org.eclipse.jdt.core.builder.cleanOutputFolder=clean
-org.eclipse.jdt.core.builder.duplicateResourceTask=warning
-org.eclipse.jdt.core.builder.invalidClasspath=abort
-org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
-org.eclipse.jdt.core.circularClasspath=error
-org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
-org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.4
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.doc.comment.support=enabled
-org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore
-org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=error
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=error
-org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
-org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
-org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=error
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=error
-org.eclipse.jdt.core.compiler.problem.unusedLabel=error
-org.eclipse.jdt.core.compiler.problem.unusedLocal=error
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.3
-org.eclipse.jdt.core.incompatibleJDKLevel=ignore
-org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/tests/org.eclipse.jface.tests.databinding/.settings/org.eclipse.jdt.ui.prefs b/tests/org.eclipse.jface.tests.databinding/.settings/org.eclipse.jdt.ui.prefs
deleted file mode 100644
index 846d8bfc..00000000
--- a/tests/org.eclipse.jface.tests.databinding/.settings/org.eclipse.jdt.ui.prefs
+++ /dev/null
@@ -1,7 +0,0 @@
-#Thu Aug 24 15:24:48 EDT 2006
-eclipse.preferences.version=1
-org.eclipse.jdt.ui.exception.name=e
-org.eclipse.jdt.ui.gettersetter.use.is=true
-org.eclipse.jdt.ui.javadoc=true
-org.eclipse.jdt.ui.overrideannotation=true
-org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return Returns the ${bare_field_name}.\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} The ${bare_field_name} to set.\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*******************************************************************************\n * Copyright (c) ${year} IBM Corporation and others.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http\://www.eclipse.org/legal/epl-v10.html\n *\n * Contributors\:\n * IBM Corporation - initial API and implementation\n ******************************************************************************/\n</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @since 3.2\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template></templates>
diff --git a/tests/org.eclipse.jface.tests.databinding/.settings/org.eclipse.pde.prefs b/tests/org.eclipse.jface.tests.databinding/.settings/org.eclipse.pde.prefs
deleted file mode 100644
index 630927bb..00000000
--- a/tests/org.eclipse.jface.tests.databinding/.settings/org.eclipse.pde.prefs
+++ /dev/null
@@ -1,14 +0,0 @@
-#Tue Oct 18 11:35:02 EDT 2005
-compilers.p.deprecated=0
-compilers.p.illegal-att-value=0
-compilers.p.no-required-att=0
-compilers.p.not-externalized-att=0
-compilers.p.unknown-attribute=0
-compilers.p.unknown-class=1
-compilers.p.unknown-element=1
-compilers.p.unknown-resource=1
-compilers.p.unresolved-ex-points=0
-compilers.p.unresolved-import=0
-compilers.p.unused-element-or-attribute=1
-compilers.use-project=true
-eclipse.preferences.version=1
diff --git a/tests/org.eclipse.jface.tests.databinding/JFace-Data Binding Test Suite.launch b/tests/org.eclipse.jface.tests.databinding/JFace-Data Binding Test Suite.launch
deleted file mode 100644
index 5f458730..00000000
--- a/tests/org.eclipse.jface.tests.databinding/JFace-Data Binding Test Suite.launch
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
-<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
-<stringAttribute key="bootstrap" value=""/>
-<booleanAttribute key="useProduct" value="false"/>
-<booleanAttribute key="tracing" value="false"/>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="4"/>
-</listAttribute>
-<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
-<booleanAttribute key="automaticValidate" value="false"/>
-<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
-<booleanAttribute key="automaticAdd" value="true"/>
-<stringAttribute key="checked" value="[NONE]"/>
-<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
-<stringAttribute key="application" value="org.eclipse.pde.junit.runtime.coretestapplication"/>
-<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
-<booleanAttribute key="clearws" value="true"/>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.jface.tests.databinding.BindingTestSuite"/>
-<stringAttribute key="pde.version" value="3.2a"/>
-<stringAttribute key="templateConfig" value=""/>
-<booleanAttribute key="default" value="true"/>
-<booleanAttribute key="clearConfig" value="true"/>
-<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
-<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
-<booleanAttribute key="useDefaultConfigArea" value="false"/>
-<booleanAttribute key="useDefaultConfig" value="true"/>
-<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.jface.tests.databinding"/>
-<booleanAttribute key="askclear" value="false"/>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/org.eclipse.jface.tests.databinding"/>
-</listAttribute>
-<booleanAttribute key="includeOptional" value="true"/>
-<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
-</launchConfiguration>
diff --git a/tests/org.eclipse.jface.tests.databinding/META-INF/MANIFEST.MF b/tests/org.eclipse.jface.tests.databinding/META-INF/MANIFEST.MF
deleted file mode 100644
index 3bd6b94e..00000000
--- a/tests/org.eclipse.jface.tests.databinding/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,18 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.jface.tests.databinding
-Bundle-Version: 1.0.100.qualifier
-Bundle-ClassPath: jfacebindingtests.jar
-Bundle-Vendor: %providerName
-Bundle-Localization: plugin
-Eclipse-LazyStart: true
-Require-Bundle: org.eclipse.jface.databinding,
- org.junit,
- org.eclipse.swt,
- org.eclipse.jface,
- org.eclipse.core.runtime,
- org.eclipse.jface.examples.databinding,
- org.eclipse.jface.databinding.beans,
- org.eclipse.jface.databinding.ui
-Export-Package: org.eclipse.jface.tests.databinding.util;x-internal:=false
diff --git a/tests/org.eclipse.jface.tests.databinding/about.html b/tests/org.eclipse.jface.tests.databinding/about.html
deleted file mode 100644
index 46023304..00000000
--- a/tests/org.eclipse.jface.tests.databinding/about.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
-<title>About</title>
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>June 2, 2006</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
-
-</body>
-</html> \ No newline at end of file
diff --git a/tests/org.eclipse.jface.tests.databinding/build.properties b/tests/org.eclipse.jface.tests.databinding/build.properties
deleted file mode 100644
index e671f5a5..00000000
--- a/tests/org.eclipse.jface.tests.databinding/build.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 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
-###############################################################################
-source.jfacebindingtests.jar = src/
-
-src.includes = about.html
-output.jfacebindingtests.jar = bin/
-bin.includes = META-INF/,\
- about.html,\
- test.xml,\
- *.html,\
- jfacebindingtests.jar,\
- plugin.properties
diff --git a/tests/org.eclipse.jface.tests.databinding/plugin.properties b/tests/org.eclipse.jface.tests.databinding/plugin.properties
deleted file mode 100644
index 6f8acfcf..00000000
--- a/tests/org.eclipse.jface.tests.databinding/plugin.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2005 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
-###############################################################################
-pluginName = JFace Data Binding Tests
-providerName = Eclipse.org
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/radiogroup/RadioGroupTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/radiogroup/RadioGroupTest.java
deleted file mode 100644
index 3f8f9553..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/radiogroup/RadioGroupTest.java
+++ /dev/null
@@ -1,286 +0,0 @@
-package org.eclipse.jface.examples.databinding.compositetable.radiogroup;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.examples.databinding.radioGroup.RadioGroup;
-import org.eclipse.jface.examples.databinding.radioGroup.VetoableSelectionListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Shell;
-
-public class RadioGroupTest extends TestCase {
-
- private static final String NEW_STRING = "**New String**";
- private static final String BUTTON_2_DATA = "2";
- private static final String BUTTON_1_DATA = "1";
- private static final String BUTTON_2_TEXT = "Button 2";
- private static final String BUTTON_1_TEXT = "Button 1";
- private MockRadioButton b1;
- private MockRadioButton b2;
- private RadioGroup rg;
-
- List listenerFired;
-
- protected void setUp() throws Exception {
- super.setUp();
-
- b1 = new MockRadioButton();
- b1.setText(BUTTON_1_TEXT);
- b2 = new MockRadioButton();
- b2.setText(BUTTON_2_TEXT);
- b1.setSiblings(new MockRadioButton[] {b2});
- b2.setSiblings(new MockRadioButton[] {b1});
- rg = new RadioGroup(new Object[] {b1, b2}, new Object[] {BUTTON_1_DATA, BUTTON_2_DATA});
-
- listenerFired = new ArrayList();
- }
-
- public void test_getButtons() throws Exception {
- assertEquals(rg.getButtons()[0], b1);
- assertEquals(rg.getButtons()[1], b2);
- }
-
- public void test_deselect() throws Exception {
- b1.setSelection(true);
- assertTrue(b1.getSelection());
- rg.deselect(0);
- assertFalse(b1.getSelection());
- }
-
- public void test_mock_deselectBehavior() throws Exception {
- b1.setSelection(true);
- assertTrue(b1.getSelection());
- b2.setSelection(true);
- assertFalse(b1.getSelection());
- assertTrue(b2.getSelection());
- }
-
- public void test_deselectAll() throws Exception {
- b1.setSelection(true);
- assertTrue(b1.getSelection());
- rg.deselectAll();
- assertFalse(b1.getSelection());
- assertFalse(b2.getSelection());
- }
-
- public void test_getFocusIndex() throws Exception {
- b2.setSelection(true);
- assertEquals(1, rg.getFocusIndex());
- }
-
- public void test_getItem() throws Exception {
- assertEquals(b1.getText(), rg.getItem(0));
- assertEquals(b2.getText(), rg.getItem(1));
- }
-
- public void test_getItemCount() throws Exception {
- assertEquals(2, rg.getItemCount());
- }
-
- public void test_getSelection() throws Exception {
- b2.setSelection(true);
- assertEquals(BUTTON_2_DATA, rg.getSelection());
- b1.setSelection(true);
- assertEquals(BUTTON_1_DATA, rg.getSelection());
- }
-
- public void test_getSelectionIndex() throws Exception {
- b2.setSelection(true);
- assertEquals(1, rg.getSelectionIndex());
- b1.setSelection(true);
- assertEquals(0, rg.getSelectionIndex());
- }
-
- public void test_indexOfString() throws Exception {
- assertEquals(0, rg.indexOf(BUTTON_1_TEXT));
- assertEquals(1, rg.indexOf(BUTTON_2_TEXT));
- assertEquals(-1, rg.indexOf("Barf, please"));
- }
-
- public void test_indexOfStringInt() throws Exception {
- assertEquals(-1, rg.indexOf(BUTTON_1_TEXT, 1));
- assertEquals(1, rg.indexOf(BUTTON_2_TEXT, 1));
- assertEquals(-1, rg.indexOf("Barf, please", 1));
- }
-
- public void test_isSelected() throws Exception {
- b2.setSelection(true);
- assertFalse(rg.isSelected(0));
- assertTrue(rg.isSelected(1));
- }
-
- public void test_select() throws Exception {
- rg.select(0);
- assertTrue(b1.getSelection());
- assertFalse(b2.getSelection());
- rg.select(1);
- assertFalse(b1.getSelection());
- assertTrue(b2.getSelection());
- }
-
- public void test_setItem() throws Exception {
- rg.setItem(0, NEW_STRING);
- assertEquals(NEW_STRING, b1.getText());
- }
-
- public void test_setSelection_index() throws Exception {
- rg.setSelection(1);
- assertTrue(b2.getSelection());
- rg.setSelection(0);
- assertTrue(b1.getSelection());
- }
-
- public void test_setSelection_object() throws Exception {
- rg.setSelection(BUTTON_2_DATA);
- assertTrue(b2.getSelection());
- rg.setSelection(BUTTON_1_DATA);
- assertTrue(b1.getSelection());
- }
-
- public void test_listenerFired_allSelectable_newButtonSelected() throws Exception {
- rg.setSelection(0);
- SelectionListener rgListener = new MockSelectionListener(null);
- rg.addSelectionListener(rgListener);
-
- rg.setSelection(1);
- assertEquals(1, listenerFired.size());
-
- Object[] expectedListeners = new Object[] {b2};
- assertListenersFired(expectedListeners);
- }
-
- public void test_listenerFired_allSelectable_selectedButtonSelected() throws Exception {
- rg.setSelection(0);
- SelectionListener rgListener = new MockSelectionListener(null);
- rg.addSelectionListener(rgListener);
-
- rg.setSelection(0);
- assertEquals(0, listenerFired.size());
- }
-
- public void test_listenerFired_veto2_selectedButtonSelected() throws Exception {
- rg.setSelection(0);
- MockSelectionListener rgListener = new MockSelectionListener(b2);
- rg.addSelectionListener(rgListener);
- rg.addVetoableSelectionListener(rgListener);
-
- rg.setSelection(1);
- twiddleEventLoopPlease();
- assertEquals(0, listenerFired.size());
-
- assertEquals(0, rg.getSelectionIndex());
-
- }
-
- private void twiddleEventLoopPlease() {
- while (Display.getCurrent().readAndDispatch()) {/**/}
- }
-
-
-
- private void assertListenersFired(Object[] expectedListeners) {
- for (int i = 0; i < expectedListeners.length; i++) {
- Object object = expectedListeners[i];
- assertEquals(object, listenerFired.remove(0));
- }
- }
-
- final class MockSelectionListener implements SelectionListener, VetoableSelectionListener {
- private Object notSelectable = null;
-
- public MockSelectionListener(Object notSelectable) {
- this.notSelectable = notSelectable;
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- listenerFired.add(e.data);
- }
-
- public void widgetSelected(SelectionEvent e) {
- listenerFired.add(e.data);
- }
-
- public void canWidgetChangeSelection(SelectionEvent e) {
- e.doit = !e.data.equals(notSelectable);
- }
- }
-
- private class MockRadioButton implements RadioGroup.IRadioButton {
-
- private MockRadioButton[] siblings = null;
-
- public void setSiblings(MockRadioButton[] siblings) {
- this.siblings = siblings;
- }
-
- private List listeners = new LinkedList();
-
- public void addSelectionListener(SelectionListener selectionListener) {
- listeners.add(selectionListener);
- }
-
- private void fireSelectionChangeEvent(boolean oldValue, boolean newValue) {
- for (Iterator iter = listeners.iterator(); iter.hasNext();) {
- SelectionListener listener = (SelectionListener) iter.next();
- Event event = new Event();
- event.widget = new Button(new Shell(), 0);
- event.data = this;
- listener.widgetSelected(new SelectionEvent(event));
- }
- }
-
- private boolean selection = false;
-
- public boolean getSelection() {
- return selection;
- }
-
- public void setSelection(boolean newValue) {
-
- // OS event; set any other selected button to de-selected
- if (newValue == true) {
- for (int i = 0; i < siblings.length; i++) {
- MockRadioButton mock = siblings[i];
- if (mock.selection) {
- mock.setSelection(false);
- }
- }
- }
-
- boolean oldValue = this.selection;
- selection = newValue;
- fireSelectionChangeEvent(oldValue, newValue);
- }
-
- public boolean isFocusControl() {
- return selection;
- }
-
- public void setData(String string, Object object) {
- // NOOP
- }
-
- private String text;
-
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
- public void notifyListeners(int eventType, Event object) {
- fireSelectionChangeEvent(selection, selection);
- }
- }
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/radiogroup/RadioGroupTestApplication.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/radiogroup/RadioGroupTestApplication.java
deleted file mode 100644
index 175d0544..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/radiogroup/RadioGroupTestApplication.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.eclipse.jface.examples.databinding.compositetable.radiogroup;
-
-import org.eclipse.jface.examples.databinding.radioGroup.RadioGroup;
-import org.eclipse.jface.examples.databinding.radioGroup.VetoableSelectionListener;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-public class RadioGroupTestApplication {
- public static void main(String[] args) {
- new RadioGroupTestApplication().run();
- }
-
- private Shell shell;
-
- private void run() {
- Display display = new Display();
- shell = new Shell(display);
-
- shell.setLayout(new RowLayout(SWT.VERTICAL));
- Button b1 = new Button(shell, SWT.RADIO);
- b1.setText("Button 1");
- Button b2 = new Button(shell, SWT.RADIO);
- b2.setText("Button 2");
-
- final Button b3 = new Button(shell, SWT.CHECK);
- b3.setText("Read-only");
-
- RadioGroup rg = new RadioGroup(new Object[] {b1, b2}, new Object[] {"1", "2"});
- rg.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
- public void widgetSelected(SelectionEvent e) {
- Button b = (Button) e.widget;
- System.out.println("Selected " + b.getText());
- }
- });
- rg.addVetoableSelectionListener(new VetoableSelectionListener() {
- public void canWidgetChangeSelection(SelectionEvent e) {
- if (b3.getSelection()) {
- e.doit = false;
- }
- }});
-
- shell.setSize(100, 100);
- shell.open();
-
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- display.dispose();
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CMClientFixture.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CMClientFixture.java
deleted file mode 100644
index 4139acbc..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CMClientFixture.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable.timeeditor.test;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventContentProvider;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventCountProvider;
-
-/**
- * Fixture for testing CalendarableModel
- */
-public class CMClientFixture {
-
- /**
- * Hard-code a start date that's easy to do arithmetic with
- */
- public final Date startDate;
-
- /**
- */
- public CMClientFixture() {
- GregorianCalendar gc = new GregorianCalendar();
- gc.set(Calendar.MONTH, 1);
- gc.set(Calendar.YEAR, 2006);
- gc.set(Calendar.DATE, 1);
- startDate = gc.getTime();
- }
-
- private int getOffset(Date day) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(day);
- return gc.get(Calendar.DATE) - 1;
- }
-
- /**
- */
- private class ECTP extends EventCountProvider {
- public int getNumberOfEventsInDay(Date day) {
- return data[getOffset(day)].length;
- }
- }
-
- /**
- */
- private class ECNP extends EventContentProvider {
- public void refresh(Date day, CalendarableItem[] controls) {
- if (controls.length != data[getOffset(day)].length) {
- throw new RuntimeException("Number of elements to fill != amount of data we've got");
- }
- int dateOffset = getOffset(day);
- for (int i = 0; i < controls.length; i++) {
- String text = data[dateOffset][i];
- if (text.startsWith("1")) {
- controls[i].setText(text);
- controls[i].setAllDayEvent(true);
- } else {
- controls[i].setText(text);
- controls[i].setAllDayEvent(false);
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(new Date());
- gc.set(Calendar.HOUR_OF_DAY, Integer.parseInt(text));
- controls[i].setStartTime(gc.getTime());
- }
- }
- }
- }
-
- /**
- */
- public ECTP eventCountProvider = new ECTP();
-
- /**
- */
- public ECNP eventContentProvider = new ECNP();
-
- private String[][] data;
-
- /**
- * @return Returns the data.
- */
- public String[][] getData() {
- return data;
- }
-
- /**
- * @param data The data to set.
- */
- public void setData(String[][] data) {
- this.data = data;
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CMTimedEventFixture.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CMTimedEventFixture.java
deleted file mode 100644
index 1df2d435..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CMTimedEventFixture.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable.timeeditor.test;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventContentProvider;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventCountProvider;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.test.CalendarableModel_TestTimedFindMethods.Event;
-
-/**
- * Fixture for testing CalendarableModel
- */
-public class CMTimedEventFixture {
-
- private CalendarableModel_TestTimedFindMethods.Event[][] data;
-
- /**
- * Hard-code a start date that's easy to do arithmetic with
- */
- public final Date startDate;
-
- public CMTimedEventFixture(Event[][] data) {
- this.data = data;
- GregorianCalendar gc = new GregorianCalendar();
- gc.set(Calendar.MONTH, 1);
- gc.set(Calendar.YEAR, 2006);
- gc.set(Calendar.DATE, 1);
- startDate = gc.getTime();
- }
-
- private int getOffset(Date day) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(day);
- return gc.get(Calendar.DATE) - 1;
- }
-
- /**
- */
- private class ECTP extends EventCountProvider {
- public int getNumberOfEventsInDay(Date day) {
- return data[getOffset(day)].length;
- }
- }
-
- /**
- */
- private class ECNP extends EventContentProvider {
- public void refresh(Date day, CalendarableItem[] controls) {
- if (controls.length != data[getOffset(day)].length) {
- throw new RuntimeException("Number of elements to fill != amount of data we've got");
- }
- int dateOffset = getOffset(day);
- for (int i = 0; i < controls.length; i++) {
- controls[i].setText(data[dateOffset][i].text);
- controls[i].setAllDayEvent(data[dateOffset][i].allDay);
- controls[i].setStartTime(data[dateOffset][i].startTime);
- controls[i].setEndTime(data[dateOffset][i].endTime);
- }
- }
- }
-
- /**
- */
- public ECTP eventCountProvider = new ECTP();
-
- /**
- */
- public ECNP eventContentProvider = new ECNP();
-
- /**
- */
- public int getNumberOfDays() {
- return data.length;
- }
-
-
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CalendarControlTestSuite.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CalendarControlTestSuite.java
deleted file mode 100644
index 40b95bff..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CalendarControlTestSuite.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * 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.examples.databinding.compositetable.timeeditor.test;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @since 3.2
- *
- */
-public class CalendarControlTestSuite {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(
- "Test for org.eclipse.jface.examples.databinding.compositetable.timeeditor.test");
- //$JUnit-BEGIN$
- suite.addTestSuite(DayModel_testGetColumnsForEvents.class);
- suite.addTestSuite(CalendarableModel_testInit.class);
- suite.addTestSuite(CalendarableModel_testRefreshResults.class);
- suite.addTestSuite(CalendarableModel_TestTimedFindMethods.class);
- //$JUnit-END$
- return suite;
- }
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CalendarableModel_TestTimedFindMethods.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CalendarableModel_TestTimedFindMethods.java
deleted file mode 100644
index b40a30ff..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CalendarableModel_TestTimedFindMethods.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*******************************************************************************
- * 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.examples.databinding.compositetable.timeeditor.test;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.examples.databinding.compositetable.day.internal.EventLayoutComputer;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableModel;
-
-/**
- * Test for find methods against timed Calendarables.
- */
-public class CalendarableModel_TestTimedFindMethods extends TestCase {
- private CalendarableModel cm;
- private CalendarableModel cm0;
- private CMTimedEventFixture cmf = new CMTimedEventFixture(events);
- private CMTimedEventFixture cmf0 = new CMTimedEventFixture(events0);
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- cm = new CalendarableModel();
- cm.setTimeBreakdown(cmf.getNumberOfDays(), 4);
- cm.setEventCountProvider(cmf.eventCountProvider);
- cm.setEventContentProvider(cmf.eventContentProvider);
- cm.setStartDate(cmf.startDate);
- EventLayoutComputer dm = new EventLayoutComputer(4);
- for (int day = 0; day < cmf.getNumberOfDays(); ++day ) {
- CalendarableItem[][] eventLayout = dm.computeEventLayout(cm.getCalendarableItems(day));
- cm.setEventLayout(day, eventLayout);
- }
-
- cm0 = new CalendarableModel();
- cm0.setTimeBreakdown(cmf0.getNumberOfDays(), 4);
- cm0.setEventCountProvider(cmf0.eventCountProvider);
- cm0.setEventContentProvider(cmf0.eventContentProvider);
- cm0.setStartDate(cmf0.startDate);
- for (int day = 0; day < cmf0.getNumberOfDays(); ++day ) {
- CalendarableItem[][] eventLayout = dm.computeEventLayout(cm0.getCalendarableItems(day));
- cm0.setEventLayout(day, eventLayout);
- }
- }
-
- public static class Event {
- public boolean allDay = false;
- public Date startTime;
- public Date endTime;
- public String text;
-
- public Event(Date startTime, Date endTime, String description) {
- this.startTime = startTime;
- this.endTime = endTime;
- this.text = description;
- }
-
- public Event(String description) {
- this.allDay = true;
- this.text = description;
- }
- }
-
- private static Date time(int hour, int minutes) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(new Date());
- gc.set(Calendar.HOUR_OF_DAY, hour);
- gc.set(Calendar.MINUTE, minutes);
- return gc.getTime();
- }
-
- private static final Event[][] events = new Event[][] {
- {new Event(time(5, 45), time(9, 45), "Stand-up meeting"),
- new Event(time(11, 00), time(12, 15), "Meet with customer")},
- {},
- {},
- {new Event("Nat. Conference"),
- new Event(time(7, 50), time(9, 00), "Stand-up meeting"),
- new Event(time(10, 15), time(12, 00), "Work on prototype")},
- {new Event("Field trip to PC HQ"),
- new Event("Nat. Conference"),
- new Event(time(8, 30), time(9, 30), "Stand-up meeting"),
- new Event(time(10, 00), time(13, 15), "Meet with customer"),
- new Event(time(12, 45), time(14, 15), "RC1 due"),
- new Event(time(13, 45), time(14, 15), "Way too much work"),
- new Event(time(10, 00), time(13, 30), "Callisto meeting")},
- {new Event("Nat. Conference")},
- {new Event(time(8, 30), time(11, 30), "Stand-up meeting"),
- new Event(time(10, 00), time(12, 15), "Meet with customer1"),
- new Event(time(11, 45), time(12, 15), "Meet with customer2"),
- new Event(time(11, 00), time(11, 15), "Meet with customer3")},
- {},
- {new Event(time(8, 50), time(9, 00), "Stand-up meeting"),
- new Event(time(10, 15), time(12, 00), "Work on prototype")},
- {new Event(time(8, 45), time(9, 45), "Stand-up meeting"),
- new Event(time(11, 00), time(12, 15), "Meet with customer")},
- {},
- {},
- {new Event(time(8, 12), time(9, 00), "Stand-up meeting"),
- new Event(time(10, 15), time(12, 00), "Work on prototype")},
- {},
- {},
- {new Event(time(9, 50), time(9, 00), "Stand-up meeting"),
- new Event(time(10, 15), time(12, 00), "Work on prototype")},
- {},
- };
-
- private static final Event[][] events0 = new Event[][] {
- {},
- {},
- {},
- {},
- {},
- {},
- {},
- {},
- {},
- {},
- {},
- {},
- {},
- {},
- {},
- {},
- {},
- };
-
- private CalendarableItem calendarable(int day, int event) {
- return (CalendarableItem) cm.getCalendarableItems(day).get(event);
- }
-
- public void testFindTimedCalendarable_ForwardWithoutSelection_NothingToFind() throws Exception {
- CalendarableItem found = cm.findTimedCalendarable(0, 51, -1, true, null);
- assertNull("Should not find any Calendarable", found);
- }
-
- public void testFindTimedCalendarable_BackwardWithoutSelection_NothingToFind() throws Exception {
- CalendarableItem found = cm.findTimedCalendarable(0, 20, -1, false, null);
- assertNull("Should not find any Calendarable", found);
- }
-
- public void testFindTimedCalendarable_ForwardWithoutSelection_GotAHit() throws Exception {
- CalendarableItem found = cm.findTimedCalendarable(0, 40, -1, true, null);
- assertEquals("Should have found Calendarable", calendarable(0, 1), found);
- }
-
- public void testFindTimedCalendarable_BackwardWithoutSelection_GotAHit() throws Exception {
- CalendarableItem found = cm.findTimedCalendarable(0, 40, -1, false, null);
- assertEquals("Should have found Calendarable", calendarable(0, 0), found);
- }
-
- public void testFindTimedCalendarable_ForwardWithSelection_NothingToFind() throws Exception {
- CalendarableItem found = cm.findTimedCalendarable(0, 46, -1, true, calendarable(0, 1));
- assertNull("Should not find any Calendarable", found);
- }
-
- public void testFindTimedCalendarable_BackwardWithSelection_NothingToFind() throws Exception {
- CalendarableItem found = cm.findTimedCalendarable(0, 25, -1, false, calendarable(0, 0));
- assertNull("Should not find any Calendarable", found);
- }
-
- public void testFindTimedCalendarable_ForwardWithSelection_GotAHit() throws Exception {
- CalendarableItem found = cm.findTimedCalendarable(0, 25, -1, true, calendarable(0, 0));
- assertEquals("Should have found Calendarable", calendarable(0, 1), found);
- }
-
- public void testFindTimedCalendarable_BackwardWithSelection_GotAHit() throws Exception {
- CalendarableItem found = cm.findTimedCalendarable(0, 46, -1, false, calendarable(0, 1));
- assertEquals("Should have found Calendarable", calendarable(0, 0), found);
- }
-
- public void testFindTimedCalendarable_ForwardEventCollision_GotAHit() throws Exception {
- CalendarableItem found = cm.findTimedCalendarable(4, 52, -1, true, calendarable(4, 4));
- assertEquals("Should have found Calendarable", calendarable(4, 5), found);
- }
-
- public void testFindTimedCalendarable_BackwardEventCollision_GotAHit() throws Exception {
- CalendarableItem found = cm.findTimedCalendarable(6, 48, -1, false, calendarable(6, 3));
- assertEquals("Should have found Calendarable", calendarable(6, 2), found);
- }
-
- public void testFindTimedCalendarable_ForwardEventCollision_NothingToFind() throws Exception {
- CalendarableItem found = cm.findTimedCalendarable(6, 47, -1, true, calendarable(6, 3));
- assertNull("Should not find any Calendarable", found);
- }
-
- public void testFindTimedCalendarable_BackwardEventCollision_NothingToFind() throws Exception {
- CalendarableItem found = cm.findTimedCalendarable(6, 41, -1, false, calendarable(6, 0));
- assertNull("Should not find any Calendarable", found);
- }
-
- // findNextCalendarable tests ---------------------------------------------
-
- public void testFindNextCalendarable_FindNextAlldayEventInSameDay() throws Exception {
- CalendarableItem found = cm.findNextCalendarable(4, 0, calendarable(4, 0), true);
- assertEquals("Should have found Calendarable", calendarable(4, 1), found);
- }
-
- public void testFindNextCalendarable_StartWithAllday_GetFirstTimedEventFromAllDaySelection() throws Exception {
- CalendarableItem found = cm.findNextCalendarable(4, 1, calendarable(4, 1), true);
- assertEquals("Should have found Calendarable", calendarable(4, 2), found);
- }
-
- public void testFindNextCalendarable_StartWithAllday_GetFirstTimedEventFromNoSelection() throws Exception {
- CalendarableItem found = cm.findNextCalendarable(4, 2, null, false);
- assertEquals("Should have found Calendarable", calendarable(4, 2), found);
- }
-
- public void testFindNextCalendarable_WrapToNextDay() throws Exception {
- CalendarableItem found = cm.findNextCalendarable(6, 47, calendarable(6, 3), false);
- assertEquals("Should have found Calendarable", calendarable(8, 0), found);
- }
-
- public void testFindNextCalendarable_WrapFromLastDayToFirstDay() throws Exception {
- CalendarableItem found = cm.findNextCalendarable(15, 42, calendarable(15, 1), false);
- assertEquals("Should have found Calendarable", calendarable(0, 0), found);
- }
-
- public void testFindNextCalendarable_NoEventsInDisplay() throws Exception {
- CalendarableItem found = cm0.findNextCalendarable(15, 42, null, false);
- assertNull("Should find no events", found);
- }
-
- // findPreviousCalendarable tests -----------------------------------------
-
- public void testFindPreviousCalendarable_FindPreviousTimedEventInSameDay() throws Exception {
- CalendarableItem found = cm.findPreviousCalendarable(0, 44, calendarable(0, 1), false);
- assertEquals("Should have found Calendarable", calendarable(0, 0), found);
- }
-
- public void testFindPreviousCalendarable_FindLastAlldayEventInSameDay() throws Exception {
- CalendarableItem found = cm.findPreviousCalendarable(3, 32, calendarable(3, 1), false);
- assertEquals("Should have found Calendarable", calendarable(3, 0), found);
- }
-
- public void testFindPreviousCalendarable_FindPreviousAlldayEventInSameDay() throws Exception {
- CalendarableItem found = cm.findPreviousCalendarable(4, 1, calendarable(4, 1), true);
- assertEquals("Should have found Calendarable", calendarable(4, 0), found);
- }
-
- public void testFindPreviousCalendarable_WrapToPreviousDay_AllDayEvent() throws Exception {
- CalendarableItem found = cm.findPreviousCalendarable(4, 0, calendarable(4, 0), true);
- assertEquals("Should have found Calendarable", calendarable(3, 2), found);
- }
-
- public void testFindPreviousCalendarable_WrapToPreviousDay_TimedEvent() throws Exception {
- CalendarableItem found = cm.findPreviousCalendarable(8, 35, calendarable(8, 0), false);
- assertEquals("Should have found Calendarable", calendarable(6, 3), found);
- }
-
- public void testFindPreviousCalendarable_WrapFromFirstDayToLastDay() throws Exception {
- CalendarableItem found = cm.findPreviousCalendarable(0, 24, calendarable(0, 0), false);
- assertEquals("Should have found Calendarable", calendarable(15, 1), found);
- }
-
- public void testFindPreviousCalendarable_NoEventsInDisplay() throws Exception {
- CalendarableItem found = cm0.findPreviousCalendarable(15, 42, null, false);
- assertNull("Should find no events", found);
- }
-}
-
-
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CalendarableModel_testInit.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CalendarableModel_testInit.java
deleted file mode 100644
index 3b9edfb3..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CalendarableModel_testInit.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable.timeeditor.test;
-
-import java.util.Date;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableModel;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventContentProvider;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventCountProvider;
-
-/**
- * @since 3.2
- *
- */
-public class CalendarableModel_testInit extends TestCase {
- final boolean[] initCalled = new boolean[] {false};
- private CalendarableModel cm;
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- cm = new CalendarableModel();
- }
-
- public void testInitCalledAfterAllSettersSet() throws Exception {
- EventCountProvider ecp = new EventCountProvider() {
- public int getNumberOfEventsInDay(Date day) {
- initCalled[0] = true;
- return 0;
- };
- };
-
- cm.setEventCountProvider(ecp);
- assertNoRefreshCalled();
- cm.setTimeBreakdown(1, 2);
- assertNoRefreshCalled();
- cm.setEventContentProvider(new EventContentProvider() {
- public void refresh(Date day, CalendarableItem[] controls) {
- }});
- assertNoRefreshCalled();
- cm.setStartDate(new Date());
- assertRefreshCalled();
- }
-
- private void assertNoRefreshCalled() {
- assertFalse("no refresh yet", initCalled[0]);
- }
-
- private void assertRefreshCalled() {
- assertTrue("refresh already", initCalled[0]);
- }
-
- public void testSetTimeBreakdown_numberOfDivisionsInHourNotSet() throws Exception {
- try {
- cm.setTimeBreakdown(1, 0);
- fail("IllegalArgumentException expected");
- } catch(IllegalArgumentException e) {
- //success
- }
- }
-
- public void testSetTimeBreakdown_numberOfDaysNotSet() throws Exception {
- try {
- cm.setTimeBreakdown(0, 1);
- fail("IllegalArgumentException expected");
- } catch(IllegalArgumentException e) {
- //success
- }
- }
-
- public void testColumnWithinDayIsInitializedForOneDay() throws Exception {
- final int NUM_DAYS=1;
- cm.setTimeBreakdown(NUM_DAYS, 4);
- assertColumnWithinDayIsInitialized(NUM_DAYS);
- }
-
- public void testColumnWithinDayIsInitializedForSeveralDays() throws Exception {
- final int NUM_DAYS=5;
- cm.setTimeBreakdown(NUM_DAYS, 4);
- assertColumnWithinDayIsInitialized(NUM_DAYS);
- }
-
- private void assertColumnWithinDayIsInitialized(final int NUM_DAYS) {
- for (int i=0; i < NUM_DAYS; ++i) {
- assertEquals("It's initialized", -1, cm.getNumberOfColumnsWithinDay(i));
- }
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CalendarableModel_testRefreshResults.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CalendarableModel_testRefreshResults.java
deleted file mode 100644
index f3466fd1..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/CalendarableModel_testRefreshResults.java
+++ /dev/null
@@ -1,341 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable.timeeditor.test;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.List;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableModel;
-
-/**
- * @since 3.2
- *
- */
-public class CalendarableModel_testRefreshResults extends TestCase {
-
- // Test fixtures ----------------------------------------------------------
-
- private CMClientFixture cmf;
- private CalendarableModel cm;
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- cmf = new CMClientFixture();
- cm = new CalendarableModel();
- }
-
- private void setupModel(String[][] data) {
- cmf.setData(data);
- cm.setTimeBreakdown(data.length, 4);
- cm.setEventCountProvider(cmf.eventCountProvider);
- cm.setEventContentProvider(cmf.eventContentProvider);
- cm.setStartDate(cmf.startDate);
-
- verifyModel(cm, data);
- }
-
- private void verifyModel(CalendarableModel cm, String[][] data) {
- assertEquals("number of days equal", cm.getNumberOfDays(), data.length);
- for (int day = 0; day < data.length; day++) {
- List events = cm.getCalendarableItems(day);
- assertEquals("number of events equal", events.size(), data[day].length);
- for (int element = 0; element < data[day].length; element++) {
- assertEquals("Event " + element + ", day " + day + "equal", data[day][element], ((CalendarableItem)events.get(element)).getText());
- }
- }
- }
-
- private void verifyModelShouldFail(CalendarableModel cm, String[][] data) throws AssertionFailedError {
- try {
- // This should throw an assertion failed error
- verifyModel(cm, data);
- } catch (AssertionFailedError e) {
- // Make sure we got the correct assertion failure
- if (e.getMessage().indexOf("number of events equal") == -1) {
- throw e;
- }
- // Success
- }
- }
-
- private CalendarableModel testModelLoading(String[][] data) {
- CalendarableModel cm = new CalendarableModel();
- setupModel(data);
- return cm;
- }
-
- private Date getNextDate(Date date) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(date);
- gc.add(Calendar.DATE, 1);
- return gc.getTime();
- }
-
- private CalendarableItem[] getAllDayEvents(String[][] data) {
- setupModel(data);
- CalendarableItem[] allDayEvents = cm.getAllDayCalendarables(0);
- return allDayEvents;
- }
-
- // Tests ------------------------------------------------------------------
-
- public void testOneDayOneEvent() throws Exception {
- testModelLoading(new String[][] {
- {"1"}
- });
- }
-
- public void testTwoDaysTwoEvents() throws Exception {
- testModelLoading(new String[][] {
- {"1", "2"},
- {"3", "4"}
- });
- }
-
- public void testOneDayZeroEvents() throws Exception {
- testModelLoading(new String[][] {
- {}
- });
- }
-
- public void testIncreaseNumberOfEventsInDay() throws Exception {
- String[][] data = new String[][] {
- {"1", "2", "3"}
- };
- setupModel(data);
-
- data[0] = new String[] {"1", "2", "3", "4", "5"};
- cm.refresh(cmf.startDate);
-
- verifyModel(cm, data);
- }
-
- public void testDecreaseNumberOfEventsInDay() throws Exception {
- String[][] data = new String[][] {
- {"1", "2", "3"}
- };
- setupModel(data);
-
- data[0] = new String[] {"1"};
- cm.refresh(cmf.startDate);
-
- verifyModel(cm, data);
- }
-
- public void testRefreshDateOutsideDisplayedRange() throws Exception {
- String[][] data = new String[][] {
- {"1", "2", "3"}
- };
- setupModel(data);
-
- data[0] = new String[] {"1"};
-
- cm.refresh(getNextDate(cmf.startDate)); // This refresh should not occur
- verifyModelShouldFail(cm, data);
- }
-
- public void testRefreshSecondDay() throws Exception {
- String[][] data = new String[][] {
- {"1", "2", "3"},
- {"0", "3", "6", "9"}
- };
- setupModel(data);
-
- data[1] = new String[] {"42"};
-
- cm.refresh(cmf.startDate); // This refresh should do nothing (the data for that day didn't change)
- verifyModelShouldFail(cm, data);
- cm.refresh(getNextDate(cmf.startDate)); // This refresh should
- verifyModel(cm, data);
- }
-
- // Number of all day event row tests --------------------------------------
-
- public void testComputeNumberOfAllDayEventRows_OneAllDayEvent() throws Exception {
- String[][] data = new String[][] {
- {"1", "3", "3"},
- {"0", "3", "6", "9"}
- };
- setupModel(data);
-
- assertEquals("max one event", 1, cm.computeNumberOfAllDayEventRows());
- }
-
- public void testComputeNumberOfAllDayEventRows_TwoAllDayEvent() throws Exception {
- String[][] data = new String[][] {
- {"4", "1", "1"},
- {"0", "3", "6", "9"}
- };
- setupModel(data);
-
- assertEquals("max two event", 2, cm.computeNumberOfAllDayEventRows());
- }
-
- public void testComputeNumberOfAllDayEventRows_ThreeAllDayEvent() throws Exception {
- String[][] data = new String[][] {
- {"4", "1", "1"},
- {"1", "1", "1", "9"}
- };
- setupModel(data);
-
- assertEquals("max three event", 3, cm.computeNumberOfAllDayEventRows());
- }
-
- public void testComputeNumberOfAllDayEventRows_ZeroAllDayEvent() throws Exception {
- String[][] data = new String[][] {
- {"0", "2", "4"},
- {"0", "3", "5", "9"}
- };
- setupModel(data);
-
- assertEquals("no all day events", 0, cm.computeNumberOfAllDayEventRows());
- }
-
- // Start time -------------------------------------------------------------
-
- public void testComputeStartHour_UsingDefault() throws Exception {
- String[][] data = new String[][] {
- {"9", "22", "8"},
- {"21", "11", "14", "16"}
- };
- setupModel(data);
-
- assertEquals("8 am start", 8, cm.computeStartHour());
- }
-
- public void testComputeStartHour_Midnight() throws Exception {
- String[][] data = new String[][] {
- {"9", "22", "8"},
- {"21", "11", "0", "16"}
- };
- setupModel(data);
-
- assertEquals("midnight start", 0, cm.computeStartHour());
- }
-
- public void testComputeStartHour_7am() throws Exception {
- String[][] data = new String[][] {
- {"9", "22", "8"},
- {"21", "11", "7", "16"}
- };
- setupModel(data);
-
- assertEquals("midnight start", 7, cm.computeStartHour());
- }
-
- public void testComputeStartHour_7amWithAllDayEvents() throws Exception {
- String[][] data = new String[][] {
- {"9", "1", "8"},
- {"21", "11", "7", "16"}
- };
- setupModel(data);
-
- assertEquals("midnight start", 7, cm.computeStartHour());
- }
-
- // Test all-day event methods ---------------------------------------------
-
- public void testGetAllDayEvents_noEvents() throws Exception {
- String[][] data = new String[][] {
- {"2", "3"}
- };
- setupModel(data);
-
- assertEquals("Should find no all-day events", 0, cm.getAllDayCalendarables(0).length);
- }
-
- public void testGetAllDayEvents_oneEvent() throws Exception {
- String[][] data = new String[][] {
- {"1First", "2", "3"}
- };
- CalendarableItem[] allDayEvents = getAllDayEvents(data);
-
- assertEquals("Should find one all-day event", 1, allDayEvents.length);
- assertEquals("Found 1First", "1First", allDayEvents[0].getText());
- }
-
- public void testGetAllDayEvents_threeEvents() throws Exception {
- String[][] data = new String[][] {
- {"0", "1First", "1Second", "2", "1Third"}
- };
- CalendarableItem[] allDayEvents = getAllDayEvents(data);
-
- assertEquals("Should find three all-day event", 3, allDayEvents.length);
- assertEquals("Found 1First", "1First", allDayEvents[0].getText());
- assertEquals("Found 1Third", "1Third", allDayEvents[2].getText());
- }
-
- // Test methods that integrate the eventLayout and everything else --------
-
- public void testFindAllDayCalendarable_ForwardNoData() throws Exception {
- String[][] data = new String[][] {
- {"5", "5", "2", "3", "5", "5"}
- };
- setupModel(data);
- CalendarableItem result = cm.findAllDayCalendarable(0, true, null);
- assertNull("No calendarables forward", result);
- }
-
- public void testFindAllDayCalendarable_BackwardNoData() throws Exception {
- String[][] data = new String[][] {
- {"5", "5", "2", "3", "5", "5"}
- };
- getAllDayEvents(data);
- CalendarableItem result = cm.findAllDayCalendarable(0, false, null);
- assertNull("No calendarables forward", result);
- }
-
- public void testFindAllDayCalendarable_BackwardButAtFirst() throws Exception {
- String[][] data = new String[][] {
- {"1First", "1Second", "2", "3", "1Third", "1Fourth"}
- };
- CalendarableItem[] allDayEvents = getAllDayEvents(data);
- CalendarableItem result = cm.findAllDayCalendarable(0, false, allDayEvents[0]);
- assertNull("No Calendarables backward from first", result);
- }
-
- public void testFindAllDayCalendarable_ForwardAtLast() throws Exception {
- String[][] data = new String[][] {
- {"1First", "1Second", "2", "3", "1Third", "1Fourth"}
- };
- CalendarableItem[] allDayEvents = getAllDayEvents(data);
- CalendarableItem result = cm.findAllDayCalendarable(0, true, allDayEvents[3]);
- assertNull("No calendarables forward", result);
- }
-
- public void testFindAllDayCalendarable_ForwardWithSelection() throws Exception {
- String[][] data = new String[][] {
- {"1First", "1Second", "2", "3", "1Third", "1Fourth"}
- };
- CalendarableItem[] allDayEvents = getAllDayEvents(data);
- CalendarableItem result = cm.findAllDayCalendarable(0, true, allDayEvents[1]);
- assertEquals("Should find third event", allDayEvents[2], result);
- }
-
- public void testFindAllDayCalendarable_BackwardWithSelection() throws Exception {
- String[][] data = new String[][] {
- {"1First", "1Second", "2", "3", "1Third", "1Fourth"}
- };
- CalendarableItem[] allDayEvents = getAllDayEvents(data);
- CalendarableItem result = cm.findAllDayCalendarable(0, false, allDayEvents[1]);
- assertEquals("Should find first event", allDayEvents[0], result);
- }
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/DayModel_testGetColumnsForEvents.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/DayModel_testGetColumnsForEvents.java
deleted file mode 100644
index ae918570..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/examples/databinding/compositetable/timeeditor/test/DayModel_testGetColumnsForEvents.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.examples.databinding.compositetable.timeeditor.test;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.examples.databinding.compositetable.day.internal.EventLayoutComputer;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor;
-import org.eclipse.swt.graphics.Point;
-
-/**
- * @since 3.2
- *
- */
-public class DayModel_testGetColumnsForEvents extends TestCase {
- // Fixtures ---------------------------------------------------------------
-
- private CalendarableItem event(int number) {
- return (CalendarableItem) expectedEvents.get(number);
- }
-
- private Date time(int hour, int minutes) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(new Date());
- gc.set(Calendar.HOUR_OF_DAY, hour);
- gc.set(Calendar.MINUTE, minutes);
- return gc.getTime();
- }
-
- private CalendarableItem addCalendarable(Date startTime, Date endTime, String description) {
- CalendarableItem c = new CalendarableItem(new Date());
- c.setStartTime(startTime);
- c.setEndTime(endTime);
- c.setText(description);
- expectedEvents.add(c);
- return c;
- }
-
- private CalendarableItem addCalendarable(String description) {
- CalendarableItem c = new CalendarableItem(new Date());
- c.setText(description);
- c.setAllDayEvent(true);
- expectedEvents.add(c);
- return c;
- }
-
- private void assertEventInColumnInPositions(CalendarableItem event, int column, int[] expectedSlotsForEvent) {
- int firstSlotForEvent = expectedSlotsForEvent[0];
- int lastSlotForEvent = expectedSlotsForEvent[expectedSlotsForEvent.length-1];
- int lastSlotInDay = eventLayout[column].length;
-
- //before event
- for (int slot=0; slot < firstSlotForEvent; ++slot) {
- assertNotSame("slots before event != event: " + slot, event, eventLayout[column][slot]);
- }
-
- //during event
- for (int slot=firstSlotForEvent; slot <= lastSlotForEvent; ++slot) {
- assertEquals("should find event here: " + slot, event, eventLayout[column][slot]);
- }
-
- //after event
- for (int slot=lastSlotForEvent+1; slot < lastSlotInDay; ++slot) {
- assertNotSame("slots after event != event: " + slot, event, eventLayout[column][slot]);
- }
- }
-
- private void assertEventNotInColumn(CalendarableItem event, int column) {
- for (int slot = 0; slot < eventLayout[column].length; slot++) {
- assertFalse("event not in column: " + column + ", " + slot, event == eventLayout[column][slot]);
- }
- }
-
- private void assertExpectedColumns(int expected) {
- assertEquals(expected+ " columns", expected, eventLayout.length);
- }
-
- private void assertBounds(CalendarableItem c, Point leftTop, Point rightBottom) {
- assertEquals("top left position", leftTop, c.getUpperLeftPositionInDayRowCoordinates());
- assertEquals("bottom right position", rightBottom, c.getLowerRightPositionInDayRowCoordinates());
- }
-
- // Tests ------------------------------------------------------------------
-
- private static final int DIVISIONS_IN_HOUR = 2;
-
- private EventLayoutComputer dayModel;
- private List expectedEvents;
- private CalendarableItem[][] eventLayout;
-
- protected void setUp() throws Exception {
- super.setUp();
- dayModel = new EventLayoutComputer(DIVISIONS_IN_HOUR);
- expectedEvents = new ArrayList();
- }
-
- public void test_getEventLayout_NoEventsInDay() throws Exception {
- eventLayout = dayModel.computeEventLayout(expectedEvents);
- assertExpectedColumns(1);
-
- assertEquals("One column", 1, eventLayout.length);
- assertEquals(IEventEditor.DISPLAYED_HOURS * DIVISIONS_IN_HOUR
- + " time slots", IEventEditor.DISPLAYED_HOURS
- * DIVISIONS_IN_HOUR, eventLayout[0].length);
-
- for (int column = 0; column < eventLayout.length; column++) {
- for (int timeSlot = 0; timeSlot < eventLayout[column].length; timeSlot++) {
- assertNull(eventLayout[column][timeSlot]);
- }
- }
- }
-
- public void test_getEventLayout_OneEventNoSpan() throws Exception {
- CalendarableItem c = addCalendarable(time(8, 00), time(8, 30), "One event");
- eventLayout = dayModel.computeEventLayout(expectedEvents);
-
- assertExpectedColumns(1);
- assertEventInColumnInPositions(event(0), 0, new int[] {16});
- assertBounds(c, new Point(0, 16), new Point(0, 16));
- }
-
- public void test_getEventLayout_TwoEventsOneIsAllDaySpan3FullBlocks() throws Exception {
- CalendarableItem c = addCalendarable(time(8, 00), time(9, 30), "One event, 3 timeslots");
- addCalendarable("All-day-event");
- eventLayout = dayModel.computeEventLayout(expectedEvents);
-
- assertExpectedColumns(1);
- assertEventInColumnInPositions(event(1), 0, new int[] {16, 18});
- assertBounds(c, new Point(0, 16), new Point(0, 18));
- }
-
- public void test_getEventLayout_OneEventSpanWithPartialBlock() throws Exception {
- addCalendarable(time(00, 00), time(0, 31), "One event, 3 timeslots");
- eventLayout = dayModel.computeEventLayout(expectedEvents);
-
- assertExpectedColumns(1);
- assertEventInColumnInPositions(event(0), 0, new int[] {0, 1});
- }
-
- public void test_getEventLayout_OneEventStartAndEndTimesSame() throws Exception {
- addCalendarable(time(01, 00), time(01, 00), "One event, same start and end times");
- eventLayout = dayModel.computeEventLayout(expectedEvents);
-
- assertExpectedColumns(1);
- assertEventInColumnInPositions(event(0), 0, new int[] {2});
- }
-
- public void test_getEventLayout_OneEventEndTimeBeforeStartTime() throws Exception {
- addCalendarable(time(01, 00), time(00, 30), "One event, end time before start time");
- eventLayout = dayModel.computeEventLayout(expectedEvents);
-
- assertExpectedColumns(1);
- assertEventInColumnInPositions(event(0), 0, new int[] {2});
- }
-
- public void test_getEventLayout_OneDayTwoSequentialEventsInputUnsorted() throws Exception {
- addCalendarable(time(01, 30), time(2, 00), "Second event");
- addCalendarable(time(01, 00), time(1, 30), "First event");
- eventLayout = dayModel.computeEventLayout(expectedEvents);
-
- assertExpectedColumns(1);
-
- assertEventInColumnInPositions(event(0), 0, new int[] {2});
- assertEventInColumnInPositions(event(1), 0, new int[] {3});
- }
-
- public void test_getEventLayout_OneDayTwoEventsTwoColumnsInputUnsorted() throws Exception {
- addCalendarable(time(01, 30), time(2, 00), "Second event");
- addCalendarable(time(01, 00), time(2, 00), "First event");
- eventLayout = dayModel.computeEventLayout(expectedEvents);
-
- assertExpectedColumns(2);
-
- assertEventInColumnInPositions(event(0), 0, new int[] {2, 3});
- assertEventNotInColumn(event(0), 1);
-
- assertEventInColumnInPositions(event(1), 1, new int[] {3});
- assertEventNotInColumn(event(1), 0);
- }
-
- public void test_getEventLayout_OneDay4EventsThreeColumnsInputSorted() throws Exception {
- addCalendarable(time(01, 00), time(3, 00), "First event");
- addCalendarable(time(01, 30), time(3, 00), "Second event");
- addCalendarable(time(02, 00), time(4, 00), "Third event");
- CalendarableItem c = addCalendarable(time(03, 00), time(4, 00), "Fourth event");
- eventLayout = dayModel.computeEventLayout(expectedEvents);
-
- assertExpectedColumns(3);
-
- assertEventInColumnInPositions(event(0), 0, new int[] {2, 5});
- assertEventNotInColumn(event(0), 1);
- assertEventNotInColumn(event(0), 2);
-
- assertEventNotInColumn(event(1), 0);
- assertEventInColumnInPositions(event(1), 1, new int[] {3, 5});
- assertEventNotInColumn(event(1), 2);
-
- assertEventNotInColumn(event(2), 0);
- assertEventNotInColumn(event(2), 1);
- assertEventInColumnInPositions(event(2), 2, new int[] {4, 7});
-
- assertEventInColumnInPositions(event(3), 0, new int[] {6, 7});
- assertEventInColumnInPositions(event(3), 1, new int[] {6, 7});
- assertEventNotInColumn(event(3), 2);
- assertBounds(c, new Point(0, 6), new Point(1, 7));
- }
-
- public void test_getEventLayout_OneDay4EventsThreeColumnsInputSortedWithAllDayEvents() throws Exception {
- addCalendarable(time(01, 00), time(3, 00), "First event");
- addCalendarable("ad1");
- addCalendarable(time(01, 30), time(3, 00), "Second event");
- addCalendarable(time(02, 00), time(4, 00), "Third event");
- addCalendarable("ad2");
- CalendarableItem c = addCalendarable(time(03, 00), time(4, 00), "Fourth event");
- eventLayout = dayModel.computeEventLayout(expectedEvents);
-
- assertExpectedColumns(3);
-
- assertEventInColumnInPositions(event(2), 0, new int[] {2, 5});
- assertEventNotInColumn(event(2), 1);
- assertEventNotInColumn(event(2), 2);
-
- assertEventNotInColumn(event(3), 0);
- assertEventInColumnInPositions(event(3), 1, new int[] {3, 5});
- assertEventNotInColumn(event(3), 2);
-
- assertEventNotInColumn(event(4), 0);
- assertEventNotInColumn(event(4), 1);
- assertEventInColumnInPositions(event(4), 2, new int[] {4, 7});
-
- assertEventInColumnInPositions(event(5), 0, new int[] {6, 7});
- assertEventInColumnInPositions(event(5), 1, new int[] {6, 7});
- assertEventNotInColumn(event(5), 2);
- assertBounds(c, new Point(0, 6), new Point(1, 7));
- }
-
- public void test_getEventLayout_OneDay6EventsFourColumnsInputSorted() throws Exception {
- addCalendarable(time(01, 00), time(3, 00), "First event");
- addCalendarable(time(01, 30), time(3, 00), "Second event");
- addCalendarable(time(02, 00), time(3, 00), "Third event");
- addCalendarable(time(02, 30), time(5, 00), "Fourth event");
- addCalendarable(time(03, 00), time(5, 00), "Fifth event");
- addCalendarable(time(04, 00), time(5, 00), "Sixth event");
- eventLayout = dayModel.computeEventLayout(expectedEvents);
-
- assertExpectedColumns(4);
-
- assertEventInColumnInPositions(event(0), 0, new int[] {2, 5});
- assertEventNotInColumn(event(0), 1);
- assertEventNotInColumn(event(0), 2);
- assertEventNotInColumn(event(0), 3);
-
- assertEventNotInColumn(event(1), 0);
- assertEventInColumnInPositions(event(1), 1, new int[] {3, 5});
- assertEventNotInColumn(event(1), 2);
- assertEventNotInColumn(event(1), 3);
-
- assertEventNotInColumn(event(2), 0);
- assertEventNotInColumn(event(2), 1);
- assertEventInColumnInPositions(event(2), 2, new int[] {4, 5});
- assertEventNotInColumn(event(2), 3);
-
- assertEventNotInColumn(event(3), 0);
- assertEventNotInColumn(event(3), 1);
- assertEventNotInColumn(event(3), 2);
- assertEventInColumnInPositions(event(3), 3, new int[] {5, 9});
-
- assertEventInColumnInPositions(event(4), 0, new int[] {6, 9});
- assertEventNotInColumn(event(4), 1);
- assertEventNotInColumn(event(4), 2);
- assertEventNotInColumn(event(4), 3);
-
- assertEventNotInColumn(event(5), 0);
- assertEventInColumnInPositions(event(5), 1, new int[] {8, 9});
- assertEventInColumnInPositions(event(5), 2, new int[] {8, 9});
- assertEventNotInColumn(event(5), 3);
- }
-
-}
-
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/IdentityConverterTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/IdentityConverterTest.java
deleted file mode 100644
index 9686be32..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/conversion/IdentityConverterTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.conversion;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.internal.databinding.provisional.BindingException;
-
-/**
- * @since 3.2
- *
- */
-public class IdentityConverterTest extends TestCase {
-
- private IdentityConverter c;
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- c = new IdentityConverter(Integer.TYPE, Integer.TYPE);
- }
-
- public void testIsPrimitiveTypeMatchedWithBoxed() throws Exception {
- assertTrue(c.isPrimitiveTypeMatchedWithBoxed(Integer.class, Integer.TYPE));
- assertTrue(c.isPrimitiveTypeMatchedWithBoxed(Integer.TYPE, Integer.class));
-
- assertTrue(c.isPrimitiveTypeMatchedWithBoxed(Byte.class, Byte.TYPE));
- assertTrue(c.isPrimitiveTypeMatchedWithBoxed(Byte.TYPE, Byte.class));
-
- assertTrue(c.isPrimitiveTypeMatchedWithBoxed(Short.class, Short.TYPE));
- assertTrue(c.isPrimitiveTypeMatchedWithBoxed(Short.TYPE, Short.class));
-
- assertTrue(c.isPrimitiveTypeMatchedWithBoxed(Long.class, Long.TYPE));
- assertTrue(c.isPrimitiveTypeMatchedWithBoxed(Long.TYPE, Long.class));
-
- assertTrue(c.isPrimitiveTypeMatchedWithBoxed(Float.class, Float.TYPE));
- assertTrue(c.isPrimitiveTypeMatchedWithBoxed(Float.TYPE, Float.class));
-
- assertTrue(c.isPrimitiveTypeMatchedWithBoxed(Double.class, Double.TYPE));
- assertTrue(c.isPrimitiveTypeMatchedWithBoxed(Double.TYPE, Double.class));
-
- assertTrue(c.isPrimitiveTypeMatchedWithBoxed(Boolean.class, Boolean.TYPE));
- assertTrue(c.isPrimitiveTypeMatchedWithBoxed(Boolean.TYPE, Boolean.class));
-
- assertFalse(c.isPrimitiveTypeMatchedWithBoxed(Boolean.class, Integer.TYPE));
- }
-
- public void testConvert_NullToPrimitive() {
- IdentityConverter p2b = new IdentityConverter(Float.TYPE, Float.TYPE);
- try {
- p2b.convert(null);
- fail("Should have thrown an exception");
- } catch (BindingException b) {
- // success
- }
- }
-
- public void testConvert_PrimitiveToBoxed() throws Exception {
- IdentityConverter p2b = new IdentityConverter(Float.class, Float.TYPE);
- assertEquals("4.2", new Float(4.2), p2b.convert(new Float(4.2)));
- }
-
- public void testConvert_BoxedToPrimitive() throws Exception {
- IdentityConverter p2b = new IdentityConverter(Float.TYPE, Float.class);
- assertEquals("4.2", new Float(4.2), p2b.convert(new Float(4.2)));
- }
-
- public void testConvert_PrimitiveToPrimitive() throws Exception {
- IdentityConverter p2b = new IdentityConverter(Float.TYPE, Float.TYPE);
- assertEquals("4.2", new Float(4.2), p2b.convert(new Float(4.2)));
- }
-
- public void testConvert_BoxedToBoxed() throws Exception {
- IdentityConverter p2b = new IdentityConverter(Float.class, Float.class);
- assertEquals("4.2", new Float(4.2), p2b.convert(new Float(4.2)));
- }
-
- public static class Person {
- public String foo = "blah";
- }
-
- public static class Animal {
- public String name="fido";
- }
-
- public void test_Convert_ValidAssignment() throws Exception {
- IdentityConverter pc = new IdentityConverter(Object.class, Person.class);
- Person orig = new Person();
- Object person = pc.convert(orig);
- assertTrue("Person class", person.getClass().equals(Person.class));
- assertTrue("Need correct Person", person.equals(orig));
- }
-
- public void test_Convert_ValidAssignment2() throws Exception {
- IdentityConverter pc = new IdentityConverter(Person.class, Object.class);
- Person orig = new Person();
- Object person = pc.convert(orig);
- assertTrue("Person class", person.getClass().equals(Person.class));
- assertTrue("Need correct Person", person.equals(orig));
- }
-
- public void testConvert_InvalidAssignment() throws Exception {
- IdentityConverter pc = new IdentityConverter(Object.class, Person.class);
- try {
- pc.convert(new Animal());
- fail("Should have gotten an exception");
- } catch (Exception e) {
- // success
- }
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryBooleanPrimitiveTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryBooleanPrimitiveTest.java
deleted file mode 100644
index d0ff2d08..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryBooleanPrimitiveTest.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.factories;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.examples.databinding.ModelObject;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.beans.BeanObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.swt.SWTObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersBindingFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersObservableFactory;
-import org.eclipse.swt.widgets.Widget;
-
-public class DefaultBindSupportFactoryBooleanPrimitiveTest extends TestCase {
- private DataBindingContext ctx;
- private TestDataObject dataObject;
-
- public void setUp() {
- ctx = getDatabindingContext();
- dataObject = new TestDataObject();
- dataObject.setStringVal("0");
- dataObject.setBooleanPrimitiveVal(false);
- dataObject.setBooleanVal(new Boolean(false));
- }
-
- public void testStringToBooleanPrimitiveConverter() {
- ctx.bind(new Property(dataObject, "stringVal"), new Property(dataObject, "booleanPrimitiveVal"), null);
-
- dataObject.setBooleanPrimitiveVal(true);
- assertEquals("boolean value does not match", true, dataObject.getBooleanPrimitiveVal());
- assertEquals("String value does not match", "true", dataObject.getStringVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setStringVal("false");
- assertEquals("boolean value does not match", false, dataObject.getBooleanPrimitiveVal());
- assertEquals("String value does not match", "false", dataObject.getStringVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setStringVal("");
- assertEquals("boolean value does not match", false, dataObject.getBooleanPrimitiveVal());
- assertEquals("String value does not match", "", dataObject.getStringVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setStringVal(null);
- assertEquals("boolean value does not match", false, dataObject.getBooleanPrimitiveVal());
- assertNull("String value does not match", dataObject.getStringVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
- }
-
- public void testBooleanToBooleanPrimitiveConverter() {
- ctx.bind(new Property(dataObject, "booleanVal"), new Property(dataObject, "booleanPrimitiveVal"), null);
-
- dataObject.setBooleanPrimitiveVal(true);
- assertEquals("boolean value does not match", true, dataObject.getBooleanPrimitiveVal());
- assertEquals("Boolean value does not match", new Boolean(true), dataObject.getBooleanVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setBooleanVal(new Boolean(false));
- assertEquals("boolean value does not match", false, dataObject.getBooleanPrimitiveVal());
- assertEquals("Boolean value does not match", new Boolean(false), dataObject.getBooleanVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setBooleanVal(null);
- assertEquals("boolean value does not match", false, dataObject.getBooleanPrimitiveVal());
- assertNull("Boolean value does not match", dataObject.getBooleanVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
- }
-
- public void testObjectToBooleanPrimitiveConverter() {
- ctx.bind(new Property(dataObject, "objectVal"), new Property(dataObject, "booleanPrimitiveVal"), null);
-
- dataObject.setBooleanPrimitiveVal(true);
- assertEquals("boolean value does not match", true, dataObject.getBooleanPrimitiveVal());
- assertEquals("Object value does not match", new Boolean(true), dataObject.getObjectVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setObjectVal(new Boolean(false));
- assertEquals("boolean value does not match", false, dataObject.getBooleanPrimitiveVal());
- assertEquals("Object value does not match", new Boolean(false), dataObject.getObjectVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setObjectVal(null);
- assertEquals("boolean value does not match", false, dataObject.getBooleanPrimitiveVal());
- assertNull("Object value does not match", dataObject.getObjectVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
-
- Object object = new Object();
- dataObject.setObjectVal(object);
- assertEquals("boolean value does not match", false, dataObject.getBooleanPrimitiveVal());
- assertSame("Object value does not match", object, dataObject.getObjectVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
- }
-
- public class TestDataObject extends ModelObject {
- private boolean booleanPrimitiveValue;
- private String stringVal;
- private Boolean booleanVal;
- private Object objectVal;
-
- public Boolean getBooleanVal() {
- return booleanVal;
- }
- public void setBooleanVal(Boolean booleanVal) {
- Object oldVal = this.booleanVal;
- this.booleanVal = booleanVal;
- firePropertyChange("booleanVal", oldVal, this.booleanVal);
- }
-
- public boolean getBooleanPrimitiveVal() {
- return booleanPrimitiveValue;
- }
- public void setBooleanPrimitiveVal(boolean booleanPrimitiveValue) {
- boolean oldVal = this.booleanPrimitiveValue;
- this.booleanPrimitiveValue = booleanPrimitiveValue;
- firePropertyChange("booleanPrimitiveVal", new Boolean(oldVal), new Boolean(this.booleanPrimitiveValue));
- }
-
- public String getStringVal() {
- return stringVal;
- }
- public void setStringVal(String stringVal) {
- Object oldVal = this.stringVal;
- this.stringVal = stringVal;
- firePropertyChange("stringVal", oldVal, this.stringVal);
- }
-
- public Object getObjectVal() {
- return objectVal;
- }
- public void setObjectVal(Object objectVal) {
- Object oldVal = this.objectVal;
- this.objectVal = objectVal;
- firePropertyChange("objectVal", oldVal, this.objectVal);
- }
- }
-
- /**
- * @param aControl
- * @return
- */
- public static DataBindingContext getDatabindingContext() {
- final DataBindingContext context = new DataBindingContext();
- context.addObservableFactory(new DefaultObservableFactory(context));
- context.addObservableFactory(new BeanObservableFactory(context, null, new Class[]{Widget.class}));
- context.addObservableFactory(new NestedObservableFactory(context));
- context.addObservableFactory(new SWTObservableFactory());
- context.addObservableFactory(new ViewersObservableFactory());
- context.addBindingFactory(new DefaultBindingFactory());
- context.addBindingFactory(new ViewersBindingFactory());
- context.addBindSupportFactory(new DefaultBindSupportFactory());
- return context;
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryBytePrimitiveTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryBytePrimitiveTest.java
deleted file mode 100644
index beec59f7..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryBytePrimitiveTest.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.factories;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.examples.databinding.ModelObject;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.beans.BeanObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.swt.SWTObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersBindingFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersObservableFactory;
-import org.eclipse.swt.widgets.Widget;
-
-public class DefaultBindSupportFactoryBytePrimitiveTest extends TestCase {
- private DataBindingContext ctx;
- private TestDataObject dataObject;
-
- public void setUp() {
- ctx = getDatabindingContext();
- dataObject = new TestDataObject();
- dataObject.setStringVal("0");
- dataObject.setBytePrimitiveVal((byte) 0);
- dataObject.setByteVal(new Byte((byte) 0));
- }
-
- public void testStringToBytePrimitiveConverter() {
- ctx.bind(new Property(dataObject, "stringVal"), new Property(dataObject, "bytePrimitiveVal"), null);
-
- dataObject.setBytePrimitiveVal((byte)110);
- assertEquals("byte value does not match", 110, dataObject.getBytePrimitiveVal(), .001);
- assertEquals("String value does not match", "110", dataObject.getStringVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setStringVal("70");
- assertEquals("byte value does not match", 70, dataObject.getBytePrimitiveVal(), .001);
- assertEquals("String value does not match", "70", dataObject.getStringVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setStringVal("");
- assertEquals("byte value does not match", 70, dataObject.getBytePrimitiveVal(), .001);
- assertEquals("String value does not match", "", dataObject.getStringVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setStringVal(null);
- assertEquals("byte value does not match", 70, dataObject.getBytePrimitiveVal(), .001);
- assertNull("String value does not match", dataObject.getStringVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
- }
-
- public void testByteToBytePrimitiveConverter() {
- ctx.bind(new Property(dataObject, "byteVal"), new Property(dataObject, "bytePrimitiveVal"), null);
-
- dataObject.setBytePrimitiveVal((byte)110);
- assertEquals("byte value does not match", 110, dataObject.getBytePrimitiveVal(), .001);
- assertEquals("Byte value does not match", new Byte((byte)110), dataObject.getByteVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setByteVal(new Byte((byte)70));
- assertEquals("byte value does not match", 70, dataObject.getBytePrimitiveVal(), .001);
- assertEquals("Byte value does not match", new Byte((byte)70), dataObject.getByteVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setByteVal(null);
- assertEquals("byte value does not match", 70, dataObject.getBytePrimitiveVal(), .001);
- assertNull("Byte value does not match", dataObject.getByteVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
- }
-
- public void testObjectToBytePrimitiveConverter() {
- ctx.bind(new Property(dataObject, "objectVal"), new Property(dataObject, "bytePrimitiveVal"), null);
-
- dataObject.setBytePrimitiveVal((byte)110);
- assertEquals("byte value does not match", 110, dataObject.getBytePrimitiveVal(), .001);
- assertEquals("Object value does not match", new Byte((byte)110), dataObject.getObjectVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setObjectVal(new Byte((byte)70));
- assertEquals("byte value does not match", 70, dataObject.getBytePrimitiveVal(), .001);
- assertEquals("Object value does not match", new Byte((byte)70), dataObject.getObjectVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setObjectVal(null);
- assertEquals("byte value does not match", 70, dataObject.getBytePrimitiveVal());
- assertNull("Object value does not match", dataObject.getObjectVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
-
- Object object = new Object();
- dataObject.setObjectVal(object);
- assertEquals("byte value does not match", 70, dataObject.getBytePrimitiveVal());
- assertSame("Object value does not match", object, dataObject.getObjectVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
- }
-
- public class TestDataObject extends ModelObject {
- private byte bytePrimitiveValue;
- private String stringVal;
- private Byte byteVal;
- private Object objectVal;
-
- public Byte getByteVal() {
- return byteVal;
- }
- public void setByteVal(Byte byteVal) {
- Object oldVal = this.byteVal;
- this.byteVal = byteVal;
- firePropertyChange("byteVal", oldVal, this.byteVal);
- }
-
- public byte getBytePrimitiveVal() {
- return bytePrimitiveValue;
- }
- public void setBytePrimitiveVal(byte bytePrimitiveValue) {
- byte oldVal = this.bytePrimitiveValue;
- this.bytePrimitiveValue = bytePrimitiveValue;
- firePropertyChange("bytePrimitiveVal", new Byte(oldVal), new Byte(this.bytePrimitiveValue));
- }
-
- public String getStringVal() {
- return stringVal;
- }
- public void setStringVal(String stringVal) {
- Object oldVal = this.stringVal;
- this.stringVal = stringVal;
- firePropertyChange("stringVal", oldVal, this.stringVal);
- }
-
- public Object getObjectVal() {
- return objectVal;
- }
- public void setObjectVal(Object objectVal) {
- Object oldVal = this.objectVal;
- this.objectVal = objectVal;
- firePropertyChange("objectVal", oldVal, this.objectVal);
- }
- }
-
- /**
- * @param aControl
- * @return
- */
- public static DataBindingContext getDatabindingContext() {
- final DataBindingContext context = new DataBindingContext();
- context.addObservableFactory(new DefaultObservableFactory(context));
- context.addObservableFactory(new BeanObservableFactory(context, null, new Class[]{Widget.class}));
- context.addObservableFactory(new NestedObservableFactory(context));
- context.addObservableFactory(new SWTObservableFactory());
- context.addObservableFactory(new ViewersObservableFactory());
- context.addBindingFactory(new DefaultBindingFactory());
- context.addBindingFactory(new ViewersBindingFactory());
- context.addBindSupportFactory(new DefaultBindSupportFactory());
- return context;
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryDoublePrimitiveTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryDoublePrimitiveTest.java
deleted file mode 100644
index f09c27dc..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryDoublePrimitiveTest.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.factories;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.examples.databinding.ModelObject;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.beans.BeanObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.swt.SWTObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersBindingFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersObservableFactory;
-import org.eclipse.swt.widgets.Widget;
-
-public class DefaultBindSupportFactoryDoublePrimitiveTest extends TestCase {
- private DataBindingContext ctx;
- private TestDataObject dataObject;
-
- public void setUp() {
- ctx = getDatabindingContext();
- dataObject = new TestDataObject();
- dataObject.setStringVal("0");
- dataObject.setDoublePrimitiveVal(0);
- dataObject.setDoubleVal(new Double(0));
- }
-
- public void testStringToDoublePrimitiveConverter() {
- ctx.bind(new Property(dataObject, "stringVal"), new Property(dataObject, "doublePrimitiveVal"), null);
-
- dataObject.setDoublePrimitiveVal(789.5);
- assertEquals("double value does not match", 789.5, dataObject.getDoublePrimitiveVal(), .001);
- assertEquals("String value does not match", "789.5", dataObject.getStringVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setStringVal("910.5");
- assertEquals("double value does not match", 910.5, dataObject.getDoublePrimitiveVal(), .001);
- assertEquals("String value does not match", "910.5", dataObject.getStringVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setStringVal("");
- assertEquals("double value does not match", 910.5, dataObject.getDoublePrimitiveVal(), .001);
- assertEquals("String value does not match", "", dataObject.getStringVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setStringVal(null);
- assertEquals("double value does not match", 910.5, dataObject.getDoublePrimitiveVal(), .001);
- assertNull("String value does not match", dataObject.getStringVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
- }
-
- public void testDoubleToDoublePrimitiveConverter() {
- ctx.bind(new Property(dataObject, "doubleVal"), new Property(dataObject, "doublePrimitiveVal"), null);
-
- dataObject.setDoublePrimitiveVal(789.5);
- assertEquals("double value does not match", 789.5, dataObject.getDoublePrimitiveVal(), .001);
- assertEquals("Double value does not match", new Double(789.5), dataObject.getDoubleVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setDoubleVal(new Double(910.5));
- assertEquals("double value does not match", 910.5, dataObject.getDoublePrimitiveVal(), .001);
- assertEquals("Double value does not match", new Double(910.5), dataObject.getDoubleVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setDoubleVal(null);
- assertEquals("double value does not match", 910.5, dataObject.getDoublePrimitiveVal(), .001);
- assertNull("Double value does not match", dataObject.getDoubleVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
- }
-
- public void testObjectToDoublePrimitiveConverter() {
- ctx.bind(new Property(dataObject, "objectVal"), new Property(dataObject, "doublePrimitiveVal"), null);
-
- dataObject.setDoublePrimitiveVal(789.5);
- assertEquals("double value does not match", 789.5, dataObject.getDoublePrimitiveVal(), .001);
- assertEquals("Object value does not match", new Double(789.5), dataObject.getObjectVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setObjectVal(new Double(910.5));
- assertEquals("double value does not match", 910.5, dataObject.getDoublePrimitiveVal(), .001);
- assertEquals("Object value does not match", new Double(910.5), dataObject.getObjectVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setObjectVal(null);
- assertEquals("double value does not match", 910.5, dataObject.getDoublePrimitiveVal(), .001);
- assertNull("Object value does not match", dataObject.getObjectVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
-
- Object object = new Object();
- dataObject.setObjectVal(object);
- assertEquals("double value does not match", 910.5, dataObject.getDoublePrimitiveVal(), .001);
- assertSame("Object value does not match", object, dataObject.getObjectVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
- }
-
- public class TestDataObject extends ModelObject {
- private double doublePrimitiveValue;
- private String stringVal;
- private Double doubleVal;
- private Object objectVal;
-
- public Double getDoubleVal() {
- return doubleVal;
- }
- public void setDoubleVal(Double doubleVal) {
- Object oldVal = this.doubleVal;
- this.doubleVal = doubleVal;
- firePropertyChange("doubleVal", oldVal, this.doubleVal);
- }
-
- public double getDoublePrimitiveVal() {
- return doublePrimitiveValue;
- }
- public void setDoublePrimitiveVal(double doublePrimitiveValue) {
- double oldVal = this.doublePrimitiveValue;
- this.doublePrimitiveValue = doublePrimitiveValue;
- firePropertyChange("doublePrimitiveVal", new Double(oldVal), new Double(this.doublePrimitiveValue));
- }
-
- public String getStringVal() {
- return stringVal;
- }
- public void setStringVal(String stringVal) {
- Object oldVal = this.stringVal;
- this.stringVal = stringVal;
- firePropertyChange("stringVal", oldVal, this.stringVal);
- }
-
- public Object getObjectVal() {
- return objectVal;
- }
- public void setObjectVal(Object objectVal) {
- Object oldVal = this.objectVal;
- this.objectVal = objectVal;
- firePropertyChange("objectVal", oldVal, this.objectVal);
- }
- }
-
- /**
- * @param aControl
- * @return
- */
- public static DataBindingContext getDatabindingContext() {
- final DataBindingContext context = new DataBindingContext();
- context.addObservableFactory(new DefaultObservableFactory(context));
- context.addObservableFactory(new BeanObservableFactory(context, null, new Class[]{Widget.class}));
- context.addObservableFactory(new NestedObservableFactory(context));
- context.addObservableFactory(new SWTObservableFactory());
- context.addObservableFactory(new ViewersObservableFactory());
- context.addBindingFactory(new DefaultBindingFactory());
- context.addBindingFactory(new ViewersBindingFactory());
- context.addBindSupportFactory(new DefaultBindSupportFactory());
- return context;
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryFloatPrimitiveTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryFloatPrimitiveTest.java
deleted file mode 100644
index f84c6892..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryFloatPrimitiveTest.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.factories;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.examples.databinding.ModelObject;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.beans.BeanObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.swt.SWTObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersBindingFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersObservableFactory;
-import org.eclipse.swt.widgets.Widget;
-
-public class DefaultBindSupportFactoryFloatPrimitiveTest extends TestCase {
- private DataBindingContext ctx;
- private TestDataObject dataObject;
-
- public void setUp() {
- ctx = getDatabindingContext();
- dataObject = new TestDataObject();
- dataObject.setStringVal("0");
- dataObject.setFloatPrimitiveVal(0);
- dataObject.setFloatVal(new Float(0));
- }
-
- public void testStringToFloatPrimitiveConverter() {
- ctx.bind(new Property(dataObject, "stringVal"), new Property(dataObject, "floatPrimitiveVal"), null);
-
- dataObject.setFloatPrimitiveVal((float)789.5);
- assertEquals("float value does not match", 789.5, dataObject.getFloatPrimitiveVal(), .001);
- assertEquals("String value does not match", "789.5", dataObject.getStringVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setStringVal("910.5");
- assertEquals("float value does not match", 910.5, dataObject.getFloatPrimitiveVal(), .001);
- assertEquals("String value does not match", "910.5", dataObject.getStringVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setStringVal("");
- assertEquals("float value does not match", 910.5, dataObject.getFloatPrimitiveVal(), .001);
- assertEquals("String value does not match", "", dataObject.getStringVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setStringVal(null);
- assertEquals("float value does not match", 910.5, dataObject.getFloatPrimitiveVal(), .001);
- assertNull("String value does not match", dataObject.getStringVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
- }
-
- public void testFloatToFloatPrimitiveConverter() {
- ctx.bind(new Property(dataObject, "floatVal"), new Property(dataObject, "floatPrimitiveVal"), null);
-
- dataObject.setFloatPrimitiveVal((float)789.5);
- assertEquals("float value does not match", 789.5, dataObject.getFloatPrimitiveVal(), .001);
- assertEquals("Float value does not match", new Float(789.5), dataObject.getFloatVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setFloatVal(new Float(910.5));
- assertEquals("float value does not match", 910.5, dataObject.getFloatPrimitiveVal(), .001);
- assertEquals("Float value does not match", new Float(910.5), dataObject.getFloatVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setFloatVal(null);
- assertEquals("float value does not match", 910.5, dataObject.getFloatPrimitiveVal(), .001);
- assertNull("Float value does not match", dataObject.getFloatVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
- }
-
- public void testObjectToFloatPrimitiveConverter() {
- ctx.bind(new Property(dataObject, "objectVal"), new Property(dataObject, "floatPrimitiveVal"), null);
-
- dataObject.setFloatPrimitiveVal((float)789.5);
- assertEquals("float value does not match", 789.5, dataObject.getFloatPrimitiveVal(), .001);
- assertEquals("Object value does not match", new Float(789.5), dataObject.getObjectVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setObjectVal(new Float(910.5));
- assertEquals("float value does not match", 910.5, dataObject.getFloatPrimitiveVal(), .001);
- assertEquals("Object value does not match", new Float(910.5), dataObject.getObjectVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setObjectVal(null);
- assertEquals("float value does not match", 910.5, dataObject.getFloatPrimitiveVal(), .001);
- assertNull("Object value does not match", dataObject.getObjectVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
-
- Object object = new Object();
- dataObject.setObjectVal(object);
- assertEquals("float value does not match", 910.5, dataObject.getFloatPrimitiveVal(), .001);
- assertSame("Object value does not match", object, dataObject.getObjectVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
- }
-
- public class TestDataObject extends ModelObject {
- private float floatPrimitiveValue;
- private String stringVal;
- private Float floatVal;
- private Object objectVal;
-
- public Float getFloatVal() {
- return floatVal;
- }
- public void setFloatVal(Float floatVal) {
- Object oldVal = this.floatVal;
- this.floatVal = floatVal;
- firePropertyChange("floatVal", oldVal, this.floatVal);
- }
-
- public float getFloatPrimitiveVal() {
- return floatPrimitiveValue;
- }
- public void setFloatPrimitiveVal(float floatPrimitiveValue) {
- float oldVal = this.floatPrimitiveValue;
- this.floatPrimitiveValue = floatPrimitiveValue;
- firePropertyChange("floatPrimitiveVal", new Float(oldVal), new Float(this.floatPrimitiveValue));
- }
-
- public String getStringVal() {
- return stringVal;
- }
- public void setStringVal(String stringVal) {
- Object oldVal = this.stringVal;
- this.stringVal = stringVal;
- firePropertyChange("stringVal", oldVal, this.stringVal);
- }
-
- public Object getObjectVal() {
- return objectVal;
- }
- public void setObjectVal(Object objectVal) {
- Object oldVal = this.objectVal;
- this.objectVal = objectVal;
- firePropertyChange("objectVal", oldVal, this.objectVal);
- }
- }
-
- /**
- * @param aControl
- * @return
- */
- public static DataBindingContext getDatabindingContext() {
- final DataBindingContext context = new DataBindingContext();
- context.addObservableFactory(new DefaultObservableFactory(context));
- context.addObservableFactory(new BeanObservableFactory(context, null, new Class[]{Widget.class}));
- context.addObservableFactory(new NestedObservableFactory(context));
- context.addObservableFactory(new SWTObservableFactory());
- context.addObservableFactory(new ViewersObservableFactory());
- context.addBindingFactory(new DefaultBindingFactory());
- context.addBindingFactory(new ViewersBindingFactory());
- context.addBindSupportFactory(new DefaultBindSupportFactory());
- return context;
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryIntTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryIntTest.java
deleted file mode 100644
index aa871b8a..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryIntTest.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.factories;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.examples.databinding.ModelObject;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.beans.BeanObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.swt.SWTObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersBindingFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersObservableFactory;
-import org.eclipse.swt.widgets.Widget;
-
-public class DefaultBindSupportFactoryIntTest extends TestCase {
- private DataBindingContext ctx;
- private TestDataObject dataObject;
-
- public void setUp() {
- ctx = getDatabindingContext();
- dataObject = new TestDataObject();
- dataObject.setStringVal("0");
- dataObject.setIntVal(0);
- dataObject.setIntegerVal(new Integer(0));
- }
-
- public void testStringToIntConverter() {
- ctx.bind(new Property(dataObject, "stringVal"), new Property(dataObject, "intVal"), null);
-
- dataObject.setIntVal(789);
- assertEquals("Int value does not match", 789, dataObject.getIntVal());
- assertEquals("String value does not match", "789", dataObject.getStringVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setStringVal("910");
- assertEquals("Int value does not match", 910, dataObject.getIntVal());
- assertEquals("String value does not match", "910", dataObject.getStringVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setStringVal("");
- assertEquals("Int value does not match", 910, dataObject.getIntVal());
- assertEquals("String value does not match", "", dataObject.getStringVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setStringVal(null);
- assertEquals("Int value does not match", 910, dataObject.getIntVal());
- assertNull("String value does not match", dataObject.getStringVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
- }
-
- public void testIntegerToIntConverter() {
- ctx.bind(new Property(dataObject, "integerVal"), new Property(dataObject, "intVal"), null);
-
- dataObject.setIntVal(789);
- assertEquals("Int value does not match", 789, dataObject.getIntVal());
- assertEquals("Integer value does not match", new Integer(789), dataObject.getIntegerVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setIntegerVal(new Integer(910));
- assertEquals("Int value does not match", 910, dataObject.getIntVal());
- assertEquals("Integer value does not match", new Integer(910), dataObject.getIntegerVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setIntegerVal(null);
- assertEquals("Int value does not match", 910, dataObject.getIntVal());
- assertNull("Integer value does not match", dataObject.getIntegerVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
- }
-
- public void testObjectToIntegerConverter() {
- ctx.bind(new Property(dataObject, "objectVal"), new Property(dataObject, "intVal"), null);
-
- dataObject.setIntVal(789);
- assertEquals("Int value does not match", 789, dataObject.getIntVal());
- assertEquals("Object value does not match", new Integer(789), dataObject.getObjectVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setObjectVal(new Integer(910));
- assertEquals("Int value does not match", 910, dataObject.getIntVal());
- assertEquals("Object value does not match", new Integer(910), dataObject.getObjectVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setObjectVal(null);
- assertEquals("Int value does not match", 910, dataObject.getIntVal());
- assertNull("Object value does not match", dataObject.getObjectVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
-
- Object object = new Object();
- dataObject.setObjectVal(object);
- assertEquals("Int value does not match", 910, dataObject.getIntVal());
- assertSame("Object value does not match", object, dataObject.getObjectVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
- }
-
- public class TestDataObject extends ModelObject {
- private int intVal;
- private String stringVal;
- private Integer integerVal;
- private Object objectVal;
-
- public Integer getIntegerVal() {
- return integerVal;
- }
- public void setIntegerVal(Integer integerVal) {
- Object oldVal = this.integerVal;
- this.integerVal = integerVal;
- firePropertyChange("integerVal", oldVal, this.integerVal);
- }
-
- public int getIntVal() {
- return intVal;
- }
- public void setIntVal(int intVal) {
- int oldVal = this.intVal;
- this.intVal = intVal;
- firePropertyChange("intVal", oldVal, this.intVal);
- }
-
- public String getStringVal() {
- return stringVal;
- }
- public void setStringVal(String stringVal) {
- Object oldVal = this.stringVal;
- this.stringVal = stringVal;
- firePropertyChange("stringVal", oldVal, this.stringVal);
- }
-
- public Object getObjectVal() {
- return objectVal;
- }
- public void setObjectVal(Object objectVal) {
- Object oldVal = this.objectVal;
- this.objectVal = objectVal;
- firePropertyChange("objectVal", oldVal, this.objectVal);
- }
- }
-
- /**
- * @param aControl
- * @return
- */
- public static DataBindingContext getDatabindingContext() {
- final DataBindingContext context = new DataBindingContext();
- context.addObservableFactory(new DefaultObservableFactory(context));
- context.addObservableFactory(new BeanObservableFactory(context, null, new Class[]{Widget.class}));
- context.addObservableFactory(new NestedObservableFactory(context));
- context.addObservableFactory(new SWTObservableFactory());
- context.addObservableFactory(new ViewersObservableFactory());
- context.addBindingFactory(new DefaultBindingFactory());
- context.addBindingFactory(new ViewersBindingFactory());
- context.addBindSupportFactory(new DefaultBindSupportFactory());
- return context;
- }
-}
- \ No newline at end of file
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryLongPrimitiveTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryLongPrimitiveTest.java
deleted file mode 100644
index c81917a8..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryLongPrimitiveTest.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.factories;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.examples.databinding.ModelObject;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.beans.BeanObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.swt.SWTObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersBindingFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersObservableFactory;
-import org.eclipse.swt.widgets.Widget;
-
-public class DefaultBindSupportFactoryLongPrimitiveTest extends TestCase {
- private DataBindingContext ctx;
- private TestDataObject dataObject;
-
- public void setUp() {
- ctx = getDatabindingContext();
- dataObject = new TestDataObject();
- dataObject.setStringVal("0");
- dataObject.setLongPrimitiveVal((long) 0);
- dataObject.setLongVal(new Long((long) 0));
- }
-
- public void testStringToLongPrimitiveConverter() {
- ctx.bind(new Property(dataObject, "stringVal"), new Property(dataObject, "longPrimitiveVal"), null);
-
- dataObject.setLongPrimitiveVal((long)110);
- assertEquals("long value does not match", 110, dataObject.getLongPrimitiveVal(), .001);
- assertEquals("String value does not match", "110", dataObject.getStringVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setStringVal("70");
- assertEquals("long value does not match", 70, dataObject.getLongPrimitiveVal(), .001);
- assertEquals("String value does not match", "70", dataObject.getStringVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setStringVal("");
- assertEquals("long value does not match", 70, dataObject.getLongPrimitiveVal(), .001);
- assertEquals("String value does not match", "", dataObject.getStringVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setStringVal(null);
- assertEquals("long value does not match", 70, dataObject.getLongPrimitiveVal(), .001);
- assertNull("String value does not match", dataObject.getStringVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
- }
-
- public void testLongToLongPrimitiveConverter() {
- ctx.bind(new Property(dataObject, "longVal"), new Property(dataObject, "longPrimitiveVal"), null);
-
- dataObject.setLongPrimitiveVal((long)110);
- assertEquals("long value does not match", 110, dataObject.getLongPrimitiveVal(), .001);
- assertEquals("Long value does not match", new Long((long)110), dataObject.getLongVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setLongVal(new Long((long)70));
- assertEquals("long value does not match", 70, dataObject.getLongPrimitiveVal(), .001);
- assertEquals("Long value does not match", new Long((long)70), dataObject.getLongVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setLongVal(null);
- assertEquals("long value does not match", 70, dataObject.getLongPrimitiveVal(), .001);
- assertNull("Long value does not match", dataObject.getLongVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
- }
-
- public void testObjectToLongPrimitiveConverter() {
- ctx.bind(new Property(dataObject, "objectVal"), new Property(dataObject, "longPrimitiveVal"), null);
-
- dataObject.setLongPrimitiveVal((long)110);
- assertEquals("long value does not match", 110, dataObject.getLongPrimitiveVal(), .001);
- assertEquals("Object value does not match", new Long((long)110), dataObject.getObjectVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setObjectVal(new Long((long)70));
- assertEquals("long value does not match", 70, dataObject.getLongPrimitiveVal(), .001);
- assertEquals("Object value does not match", new Long((long)70), dataObject.getObjectVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setObjectVal(null);
- assertEquals("long value does not match", 70, dataObject.getLongPrimitiveVal(), .001);
- assertNull("Object value does not match", dataObject.getObjectVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
-
- Object object = new Object();
- dataObject.setObjectVal(object);
- assertEquals("long value does not match", 70, dataObject.getLongPrimitiveVal(), .001);
- assertSame("Object value does not match", object, dataObject.getObjectVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
- }
-
- public class TestDataObject extends ModelObject {
- private long longPrimitiveValue;
- private String stringVal;
- private Long longVal;
- private Object objectVal;
-
- public Long getLongVal() {
- return longVal;
- }
- public void setLongVal(Long longVal) {
- Object oldVal = this.longVal;
- this.longVal = longVal;
- firePropertyChange("longVal", oldVal, this.longVal);
- }
-
- public long getLongPrimitiveVal() {
- return longPrimitiveValue;
- }
- public void setLongPrimitiveVal(long longPrimitiveValue) {
- long oldVal = this.longPrimitiveValue;
- this.longPrimitiveValue = longPrimitiveValue;
- firePropertyChange("longPrimitiveVal", new Long(oldVal), new Long(this.longPrimitiveValue));
- }
-
- public String getStringVal() {
- return stringVal;
- }
- public void setStringVal(String stringVal) {
- Object oldVal = this.stringVal;
- this.stringVal = stringVal;
- firePropertyChange("stringVal", oldVal, this.stringVal);
- }
-
- public Object getObjectVal() {
- return objectVal;
- }
- public void setObjectVal(Object objectVal) {
- Object oldVal = this.objectVal;
- this.objectVal = objectVal;
- firePropertyChange("objectVal", oldVal, this.objectVal);
- }
- }
-
- /**
- * @param aControl
- * @return
- */
- public static DataBindingContext getDatabindingContext() {
- final DataBindingContext context = new DataBindingContext();
- context.addObservableFactory(new DefaultObservableFactory(context));
- context.addObservableFactory(new BeanObservableFactory(context, null, new Class[]{Widget.class}));
- context.addObservableFactory(new NestedObservableFactory(context));
- context.addObservableFactory(new SWTObservableFactory());
- context.addObservableFactory(new ViewersObservableFactory());
- context.addBindingFactory(new DefaultBindingFactory());
- context.addBindingFactory(new ViewersBindingFactory());
- context.addBindSupportFactory(new DefaultBindSupportFactory());
- return context;
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryShortPrimitiveTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryShortPrimitiveTest.java
deleted file mode 100644
index 0bdafd8b..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryShortPrimitiveTest.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.factories;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.examples.databinding.ModelObject;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.beans.BeanObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.swt.SWTObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersBindingFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersObservableFactory;
-import org.eclipse.swt.widgets.Widget;
-
-public class DefaultBindSupportFactoryShortPrimitiveTest extends TestCase {
- private DataBindingContext ctx;
- private TestDataObject dataObject;
-
- public void setUp() {
- ctx = getDatabindingContext();
- dataObject = new TestDataObject();
- dataObject.setStringVal("0");
- dataObject.setShortPrimitiveVal((short) 0);
- dataObject.setShortVal(new Short((short) 0));
- }
-
- public void testStringToShortPrimitiveConverter() {
- ctx.bind(new Property(dataObject, "stringVal"), new Property(dataObject, "shortPrimitiveVal"), null);
-
- dataObject.setShortPrimitiveVal((short)110);
- assertEquals("short value does not match", 110, dataObject.getShortPrimitiveVal());
- assertEquals("String value does not match", "110", dataObject.getStringVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setStringVal("70");
- assertEquals("short value does not match", 70, dataObject.getShortPrimitiveVal());
- assertEquals("String value does not match", "70", dataObject.getStringVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setStringVal("");
- assertEquals("short value does not match", 70, dataObject.getShortPrimitiveVal());
- assertEquals("String value does not match", "", dataObject.getStringVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setStringVal(null);
- assertEquals("short value does not match", 70, dataObject.getShortPrimitiveVal());
- assertNull("String value does not match", dataObject.getStringVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
- }
-
- public void testShortToShortPrimitiveConverter() {
- ctx.bind(new Property(dataObject, "shortVal"), new Property(dataObject, "shortPrimitiveVal"), null);
-
- dataObject.setShortPrimitiveVal((short)110);
- assertEquals("short value does not match", 110, dataObject.getShortPrimitiveVal());
- assertEquals("Short value does not match", new Short((short)110), dataObject.getShortVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setShortVal(new Short((short)70));
- assertEquals("short value does not match", 70, dataObject.getShortPrimitiveVal());
- assertEquals("Short value does not match", new Short((short)70), dataObject.getShortVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setShortVal(null);
- assertEquals("short value does not match", 70, dataObject.getShortPrimitiveVal());
- assertNull("Short value does not match", dataObject.getShortVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
- }
-
- public void testObjectToShortPrimitiveConverter() {
- ctx.bind(new Property(dataObject, "objectVal"), new Property(dataObject, "shortPrimitiveVal"), null);
-
- dataObject.setShortPrimitiveVal((short)110);
- assertEquals("short value does not match", 110, dataObject.getShortPrimitiveVal());
- assertEquals("Object value does not match", new Short((short)110), dataObject.getObjectVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setObjectVal(new Short((short)70));
- assertEquals("short value does not match", 70, dataObject.getShortPrimitiveVal());
- assertEquals("Object value does not match", new Short((short)70), dataObject.getObjectVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
- dataObject.setObjectVal(null);
- assertEquals("short value does not match", 70, dataObject.getShortPrimitiveVal());
- assertNull("Object value does not match", dataObject.getObjectVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
-
- Object object = new Object();
- dataObject.setObjectVal(object);
- assertEquals("short value does not match", 70, dataObject.getShortPrimitiveVal());
- assertSame("Object value does not match", object, dataObject.getObjectVal());
- assertNotNull("Errors should be found.", ctx.getValidationError().getValue());
- }
-
- public class TestDataObject extends ModelObject {
- private short shortPrimitiveValue;
- private String stringVal;
- private Short shortVal;
- private Object objectVal;
-
- public Short getShortVal() {
- return shortVal;
- }
- public void setShortVal(Short shortVal) {
- Object oldVal = this.shortVal;
- this.shortVal = shortVal;
- firePropertyChange("shortVal", oldVal, this.shortVal);
- }
-
- public short getShortPrimitiveVal() {
- return shortPrimitiveValue;
- }
- public void setShortPrimitiveVal(short shortPrimitiveValue) {
- short oldVal = this.shortPrimitiveValue;
- this.shortPrimitiveValue = shortPrimitiveValue;
- firePropertyChange("shortPrimitiveVal", new Short(oldVal), new Short(this.shortPrimitiveValue));
- }
-
- public String getStringVal() {
- return stringVal;
- }
- public void setStringVal(String stringVal) {
- Object oldVal = this.stringVal;
- this.stringVal = stringVal;
- firePropertyChange("stringVal", oldVal, this.stringVal);
- }
-
- public Object getObjectVal() {
- return objectVal;
- }
- public void setObjectVal(Object objectVal) {
- Object oldVal = this.objectVal;
- this.objectVal = objectVal;
- firePropertyChange("objectVal", oldVal, this.objectVal);
- }
- }
-
- /**
- * @param aControl
- * @return
- */
- public static DataBindingContext getDatabindingContext() {
- final DataBindingContext context = new DataBindingContext();
- context.addObservableFactory(new DefaultObservableFactory(context));
- context.addObservableFactory(new BeanObservableFactory(context, null, new Class[]{Widget.class}));
- context.addObservableFactory(new NestedObservableFactory(context));
- context.addObservableFactory(new SWTObservableFactory());
- context.addObservableFactory(new ViewersObservableFactory());
- context.addBindingFactory(new DefaultBindingFactory());
- context.addBindingFactory(new ViewersBindingFactory());
- context.addBindSupportFactory(new DefaultBindSupportFactory());
- return context;
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryTest.java
deleted file mode 100644
index 4e1e0e1a..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/factories/DefaultBindSupportFactoryTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.factories;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.examples.databinding.ModelObject;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.beans.BeanObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.swt.SWTObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersBindingFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersObservableFactory;
-import org.eclipse.swt.widgets.Widget;
-
-/**
- * @since 3.2
- *
- */
-public class DefaultBindSupportFactoryTest extends TestCase {
- /**
- * Asserts that the instances of Boolean that are returned from
- * {@link DefaultBindSupportFactory#isAssignableFromTo()} are not new
- * instances of Boolean.
- */
- public void test_isAssignableFromToBooleanInstances() {
- DefaultBindSupportFactory factory = new DefaultBindSupportFactory();
- Boolean b1 = factory.isAssignableFromTo(String.class, String.class);
- Boolean b2 = factory.isAssignableFromTo(String.class, String.class);
-
- assertNotNull(b1);
- assertNotNull(b2);
- assertTrue(b1.booleanValue());
- assertSame(b1, b2);
-
- b1 = factory.isAssignableFromTo(String.class, Integer.class);
- b2 = factory.isAssignableFromTo(String.class, Integer.class);
-
- assertNotNull(b1);
- assertNotNull(b2);
- assertFalse(b1.booleanValue());
- assertSame(b1, b2);
- }
-
- public void testStringToIntegerConverter() {
- DataBindingContext ctx = getDatabindingContext();
- TestDataObject dataObject = new TestDataObject();
- dataObject.setIntegerStringVal("123");
- dataObject.setIntStringVal("456");
- ctx.bind(new Property(dataObject, "intStringVal"), new Property(dataObject, "intVal"), null);
- ctx.bind(new Property(dataObject, "integerStringVal"), new Property(dataObject, "integerVal"), null);
-
- dataObject.setIntegerStringVal("789");
- assertEquals("Integer value does not match", new Integer(789), dataObject.getIntegerVal());
-
- dataObject.setIntStringVal("789");
- assertEquals("Int value does not match", 789, dataObject.getIntVal());
- assertNull("No errors should be found.", ctx.getValidationError().getValue());
-
-
- dataObject.setIntegerStringVal("");
- assertNull("Integer value not null", dataObject.getIntegerVal());
-
- dataObject.setIntStringVal("");
- assertNotNull("Validation error expected.", ctx.getValidationError().getValue());
- assertEquals("Int value should not have changed.", 789, dataObject.getIntVal());
- }
-
- public class TestDataObject extends ModelObject {
- private int intVal;
- private Integer integerVal;
- private String intStringVal;
- private String integerStringVal;
-
- public Integer getIntegerVal() {
- return integerVal;
- }
- public void setIntegerVal(Integer integerVal) {
- this.integerVal = integerVal;
- }
-
- public int getIntVal() {
- return intVal;
- }
- public void setIntVal(int intVal) {
- this.intVal = intVal;
- }
- public String getIntegerStringVal() {
- return integerStringVal;
- }
- public void setIntegerStringVal(String integerStringVal) {
- Object oldVal = this.integerStringVal;
- this.integerStringVal = integerStringVal;
- firePropertyChange("integerStringVal", oldVal, this.integerStringVal);
- }
- public String getIntStringVal() {
- return intStringVal;
- }
- public void setIntStringVal(String intStringVal) {
- Object oldVal = this.intStringVal;
- this.intStringVal = intStringVal;
- firePropertyChange("intStringVal", oldVal, this.intStringVal);
- }
- }
-
- /**
- * @param aControl
- * @return
- */
- public static DataBindingContext getDatabindingContext() {
- final DataBindingContext context = new DataBindingContext();
- context.addObservableFactory(new DefaultObservableFactory(context));
- context.addObservableFactory(new BeanObservableFactory(context, null, new Class[]{Widget.class}));
- context.addObservableFactory(new NestedObservableFactory(context));
- context.addObservableFactory(new SWTObservableFactory());
- context.addObservableFactory(new ViewersObservableFactory());
- context.addBindingFactory(new DefaultBindingFactory());
- context.addBindingFactory(new ViewersBindingFactory());
- context.addBindSupportFactory(new DefaultBindSupportFactory());
- return context;
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/ObjectToPrimitiveValidatorTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/ObjectToPrimitiveValidatorTest.java
deleted file mode 100644
index 458cf1bf..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/internal/databinding/provisional/validation/ObjectToPrimitiveValidatorTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * 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.internal.databinding.provisional.validation;
-
-import junit.framework.TestCase;
-
-/**
- * @since 3.2
- *
- */
-public class ObjectToPrimitiveValidatorTest extends TestCase {
-
- private ObjectToPrimitiveValidator objectToPrimitiveValidator;
-
- protected void setUp() throws Exception {
- this.objectToPrimitiveValidator = new ObjectToPrimitiveValidator(Integer.TYPE);
- }
-
- /**
- * Test method for {@link org.eclipse.jface.internal.databinding.provisional.validation.ObjectToPrimitiveValidator#isPartiallyValid(java.lang.Object)}.
- */
- public void testIsPartiallyValid() {
- ValidationError result = this.objectToPrimitiveValidator.isPartiallyValid(null);
- assertEquals("The wrong validation error was found.", result.message, this.objectToPrimitiveValidator.getNullHint());
-
- result = this.objectToPrimitiveValidator.isPartiallyValid(new Integer(1));
- assertNull("No validation error should be found.", result);
-
- result = this.objectToPrimitiveValidator.isPartiallyValid(new Object());
- assertEquals("The wrong validation error was found.", result.message, this.objectToPrimitiveValidator.getClassHint());
- }
-
- /**
- * Test method for {@link org.eclipse.jface.internal.databinding.provisional.validation.ObjectToPrimitiveValidator#isValid(java.lang.Object)}.
- */
- public void testIsValid() {
- ValidationError result = this.objectToPrimitiveValidator.isValid(null);
- assertEquals("The wrong validation error was found.", result.message, this.objectToPrimitiveValidator.getNullHint());
-
- result = this.objectToPrimitiveValidator.isValid(new Integer(1));
- assertNull("No validation error should be found.", result);
-
- result = this.objectToPrimitiveValidator.isValid(new Object());
- assertEquals("The wrong validation error was found.", result.message, this.objectToPrimitiveValidator.getClassHint());
- }
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindSpecTests.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindSpecTests.java
deleted file mode 100644
index 6e80e661..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindSpecTests.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Brad Reynolds.
- * 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:
- * Brad Reynolds - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.tests.databinding;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.internal.databinding.provisional.BindSpec;
-import org.eclipse.jface.internal.databinding.provisional.conversion.IConverter;
-import org.eclipse.jface.internal.databinding.provisional.validation.IDomainValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.IValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.ValidationError;
-
-/**
- * Unit tests for the BindSpec class.
- *
- * @since 3.2
- */
-public class BindSpecTests extends TestCase {
- /**
- * Asserts the BindSpec state when using the default constructor.
- */
- public void testDefaultConstructor() {
- BindSpec spec = new BindSpec();
- assertNull(spec.getDomainValidator());
- assertNull(spec.getModelToTargetConverter());
- assertNull(spec.getModelUpdatePolicy());
- assertNull(spec.getTargetToModelConverter());
- assertNull(spec.getTargetUpdatePolicy());
- assertNull(spec.getTypeConversionValidator());
- assertNull(spec.getValidatePolicy());
- assertTrue(spec.updateModel());
- assertTrue(spec.updateTarget());
- }
-
- /**
- * Asesrts the BindSpec state when using the constructor that accepts
- * individual objects and not arrays.
- */
- public void testSingleObjectConstructor() {
- Converter toTarget = new Converter();
- Converter toModel = new Converter();
- Validator validator = new Validator();
- DomainValidator domainValidator = new DomainValidator();
- Integer modelPolicy = new Integer(0);
- Integer targetPolicy = new Integer(1);
- Integer validatePolicy = new Integer(2);
-
- BindSpec spec = new BindSpec(toTarget, toModel, validator,
- domainValidator, modelPolicy, validatePolicy, targetPolicy);
-
- assertEquals(toTarget, spec.getModelToTargetConverter());
- assertEquals(toModel, spec.getTargetToModelConverter());
- assertEquals(validator, spec.getTypeConversionValidator());
- assertEquals(domainValidator, spec.getDomainValidator());
- assertEquals(modelPolicy, spec.getModelUpdatePolicy());
- assertEquals(targetPolicy, spec.getTargetUpdatePolicy());
- assertEquals(validatePolicy, spec.getValidatePolicy());
- assertTrue(spec.updateModel());
- assertTrue(spec.updateTarget());
- }
-
- /**
- * Asserts the BindSpec state when using the constructor that accepts
- * arrays.
- */
- public void testArrayConstructor() {
- Converter[] toTarget = new Converter[] { new Converter() };
- Converter[] toModel = new Converter[] { new Converter() };
- Validator[] validator = new Validator[] { new Validator() };
- DomainValidator domainValidator = new DomainValidator();
- Integer modelPolicy = new Integer(0);
- Integer targetPolicy = new Integer(1);
- Integer validatePolicy = new Integer(2);
-
- BindSpec spec = new BindSpec(toTarget, toModel, validator,
- domainValidator, modelPolicy, validatePolicy, targetPolicy);
- assertEquals(toTarget, spec.getModelToTargetConverters());
- assertEquals(toModel, spec.getTargetToModelConverters());
- assertEquals(validator, spec.getTypeConversionValidators());
- assertEquals(domainValidator, spec.getDomainValidator());
- assertEquals(modelPolicy, spec.getModelUpdatePolicy());
- assertEquals(targetPolicy, spec.getTargetUpdatePolicy());
- assertEquals(validatePolicy, spec.getValidatePolicy());
- assertTrue(spec.updateModel());
- assertTrue(spec.updateTarget());
- }
-
- /**
- * Asserts that when a validator is set it will always be the sole validator
- * and will remove any existing validators.
- */
- public void testSetValidator() {
- BindSpec spec = new BindSpec();
-
- IValidator v1 = new Validator();
- IValidator v2 = new Validator();
-
- spec.setValidators(new IValidator[] { v1, v2 });
- assertEquals(2, spec.getTypeConversionValidators().length);
-
- IValidator v3 = new Validator();
- spec.setValidator(v3);
- assertEquals(1, spec.getTypeConversionValidators().length);
- assertSame(v3, spec.getTypeConversionValidator());
- assertSame(v3, spec.getTypeConversionValidators()[0]);
- }
-
- /**
- * Asserts that when <code>null</code> getTypeConverstionValidator() will
- * return <code>null</code> and getTypeConversionValidators returns an
- * empty array.
- */
- public void testGetNullValidator() {
- BindSpec spec = new BindSpec();
- spec.setValidator(null);
- assertNull(spec.getTypeConversionValidator());
- assertEquals(0, spec.getTypeConversionValidators().length);
- }
-
- /**
- * Asserts that when a model to target converter is set it will always be
- * the sole converter and will remove any existing converters.
- */
- public void testSetModelToTargetConverter() {
- BindSpec spec = new BindSpec();
-
- IConverter c1 = new Converter();
- IConverter c2 = new Converter();
-
- spec.setModelToTargetConverters(new IConverter[] { c1, c2 });
- assertEquals(2, spec.getModelToTargetConverters().length);
-
- IConverter c3 = new Converter();
- spec.setModelToTargetConverter(c3);
- assertEquals(1, spec.getModelToTargetConverters().length);
- assertSame(c3, spec.getModelToTargetConverter());
- assertSame(c3, spec.getModelToTargetConverters()[0]);
- }
-
- /**
- * Asserts that when <code>null</code> getModelToTargetConverter() will
- * return <code>null</code> and getModelToTargetConverters() returns an
- * empty array.
- */
- public void testGetNullModelToTargetConverter() {
- BindSpec spec = new BindSpec();
-
- spec.setModelToTargetConverter(null);
- assertNull(spec.getModelToTargetConverter());
- assertEquals(0, spec.getModelToTargetConverters().length);
- }
-
- /**
- * Asserts that when a target to model converter is set it will always be
- * the sole converter and will remove any existing converters.
- */
- public void testSetTargetToModelConverter() {
- BindSpec spec = new BindSpec();
-
- IConverter c1 = new Converter();
- IConverter c2 = new Converter();
-
- spec.setTargetToModelConverters(new IConverter[] { c1, c2 });
- assertEquals(2, spec.getTargetToModelConverters().length);
-
- IConverter c3 = new Converter();
- spec.setTargetToModelConverter(c3);
- assertEquals(1, spec.getTargetToModelConverters().length);
- assertSame(c3, spec.getTargetToModelConverter());
- assertSame(c3, spec.getTargetToModelConverters()[0]);
- }
-
- /**
- * Asserts that when <code>null</code> getTargetToModelConverter() will
- * return <code>null</code> and getTargetToModelConverters() returns an
- * empty array.
- *
- */
- public void testGetNullTargetToModelConverter() {
- BindSpec spec = new BindSpec();
- spec.setTargetToModelConverter(null);
- assertNull(spec.getTargetToModelConverter());
- assertEquals(0, spec.getTargetToModelConverters().length);
- }
-
- private class Converter implements IConverter {
- public Object convert(Object fromObject) {
- return null;
- }
-
- public Object getFromType() {
- return null;
- }
-
- public Object getToType() {
- return null;
- }
- }
-
- private class Validator implements IValidator {
- public ValidationError isPartiallyValid(Object value) {
- return null;
- }
-
- public ValidationError isValid(Object value) {
- return null;
- }
- }
-
- private class DomainValidator implements IDomainValidator {
- public ValidationError isValid(Object value) {
- return null;
- }
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindingTestSuite.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindingTestSuite.java
deleted file mode 100644
index 93d6f11b..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindingTestSuite.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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
- * Brad Reynolds - bugs 137877, 152543, 152540
- *******************************************************************************/
-package org.eclipse.jface.tests.databinding;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.jface.internal.databinding.provisional.conversion.IdentityConverterTest;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultBindSupportFactoryBooleanPrimitiveTest;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultBindSupportFactoryBytePrimitiveTest;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultBindSupportFactoryDoublePrimitiveTest;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultBindSupportFactoryFloatPrimitiveTest;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultBindSupportFactoryIntTest;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultBindSupportFactoryLongPrimitiveTest;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultBindSupportFactoryShortPrimitiveTest;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultBindSupportFactoryTest;
-import org.eclipse.jface.internal.databinding.provisional.validation.ObjectToPrimitiveValidatorTest;
-import org.eclipse.jface.tests.databinding.mask.EditMaskLexerAndTokenTest;
-import org.eclipse.jface.tests.databinding.observable.value.WritableValueTest;
-import org.eclipse.jface.tests.databinding.scenarios.BindingScenariosTestSuite;
-import org.eclipse.jface.tests.databinding.util.MocksTest;
-import org.eclipse.jface.tests.examples.model.PersonTests;
-import org.eclipse.jface.tests.internal.databinding.internal.ValueBindingTest;
-import org.eclipse.jface.tests.internal.databinding.internal.observable.UnmodifiableObservableListTest;
-import org.eclipse.jface.tests.internal.databinding.internal.viewers.SVOCWLTest;
-import org.eclipse.jface.tests.internal.databinding.internal.viewers.SelectionProviderSingleSelectionObservableValueTest;
-import org.eclipse.jface.tests.internal.databinding.provisional.observable.AbstractObservableTest;
-import org.eclipse.jface.tests.internal.databinding.provisional.observable.ObservablesTest;
-import org.eclipse.jface.tests.internal.databinding.provisional.viewers.ViewersObservableFactoryTest;
-
-public class BindingTestSuite extends TestSuite {
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- public static Test suite() {
- return new BindingTestSuite();
- }
-
- public BindingTestSuite() {
- addTestSuite(ObservableTest.class);
- addTestSuite(JavaBeansScalarObservableValueFactoryTest.class);
- addTestSuite(DatabindingContextTest.class);
- addTestSuite(DefaultBindSupportFactoryTest.class);
- addTestSuite(IDiffsTest.class);
- addTestSuite(BindSpecTests.class);
- // addTestSuite(ObservableCollectionTest.class);
- addTestSuite(SelectionAwareObservableCollectionTest.class);
- addTest(BindingScenariosTestSuite.suite());
- addTestSuite(DefaultBindSupportFactoryIntTest.class);
- addTestSuite(DefaultBindSupportFactoryDoublePrimitiveTest.class);
- addTestSuite(DefaultBindSupportFactoryBytePrimitiveTest.class);
- addTestSuite(DefaultBindSupportFactoryLongPrimitiveTest.class);
- addTestSuite(DefaultBindSupportFactoryShortPrimitiveTest.class);
- addTestSuite(DefaultBindSupportFactoryBooleanPrimitiveTest.class);
- addTestSuite(DefaultBindSupportFactoryFloatPrimitiveTest.class);
- addTestSuite(ObjectToPrimitiveValidatorTest.class);
- addTestSuite(IdentityConverterTest.class);
- addTestSuite(LazyListBindingTest.class);
- addTestSuite(EventEditorObservableLazyDataRequestorTest.class);
- addTestSuite(EditMaskLexerAndTokenTest.class);
- addTestSuite(SelectionProviderSingleSelectionObservableValueTest.class);
- addTestSuite(SVOCWLTest.class);
- addTestSuite(ViewersObservableFactoryTest.class);
- addTestSuite(AbstractObservableTest.class);
- addTestSuite(MocksTest.class);
- addTestSuite(PersonTests.class);
- addTestSuite(WritableValueTest.class);
- addTestSuite(ValueBindingTest.class);
- addTestSuite(UnmodifiableObservableListTest.class);
- addTestSuite(ObservablesTest.class);
- }
-
- /**
- * @param testCase
- * TODO
- * @return true if the given test is temporarily disabled
- */
- public static boolean failingTestsDisabled(TestCase testCase) {
- System.out.println("Ignoring disabled test: "
- + testCase.getClass().getName() + "." + testCase.getName());
- return true;
- }
-
- /**
- * @param testSuite
- * TODO
- * @return true if the given test is temporarily disabled
- */
- public static boolean failingTestsDisabled(TestSuite testSuite) {
- System.out.println("Ignoring disabled test: "
- + testSuite.getClass().getName() + "." + testSuite.getName());
- return true;
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/CalculatedValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/CalculatedValueTest.java
deleted file mode 100644
index e40e9d6e..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/CalculatedValueTest.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * 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.databinding;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.databinding.observable.value.ComputedValue;
-import org.eclipse.jface.databinding.observable.value.WritableValue;
-import org.eclipse.jface.examples.databinding.ModelObject;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.beans.BeanObservableFactory;
-
-/**
- * @since 1.0
- *
- */
-public class CalculatedValueTest extends TestCase {
- public void test_ctor() throws Exception {
- ComputedValue cv = new ComputedValue() {
- protected Object calculate() {
- return new Integer(42);
- }
- };
- assertEquals("value type should be Integer.TYPE", Integer.TYPE, cv
- .getValueType());
- }
-
- public void test_getValue() throws Exception {
- ComputedValue cv = new ComputedValue() {
- protected Object calculate() {
- return new Integer(42);
- }
- };
- assertEquals("Calculated value should be 42", new Integer(42), cv
- .getValue());
- }
-
- public void test_handleChange() throws Exception {
- final int[] seed = new int[] { 42 };
- ComputedValue cv = new ComputedValue() {
- protected Object calculate() {
- return calcNewValue(seed);
- }
- };
- assertEquals("CalculatedValue should be " + calcNewValue(seed),
- calcNewValue(seed), cv.getValue());
- seed[0]++;
- // cv.getObservableChangeListener().handleChange(new ChangeEvent(this,
- // ChangeEvent.CHANGE, null, null));
- assertEquals("CalculatedValue should be " + calcNewValue(seed),
- calcNewValue(seed), cv.getValue());
- }
-
- private Object calcNewValue(int[] seed) {
- return new Integer(seed[0] + 2);
- }
-
- public void test_hookAndUnhookDependantObservableValues() throws Exception {
- final int[] seed = new int[] { 42 };
- ComputedValue cv = new ComputedValue() {
- protected Object calculate() {
- return calcNewValue(seed);
- }
- };
- WritableValue test1 = new WritableValue(Integer.TYPE);
- WritableValue test2 = new WritableValue(Integer.TYPE);
-
- // Hook observables...
- // cv.setDependencies(new IObservableValue[] {test1, test2});
- assertEquals("CalculatedValue should be " + calcNewValue(seed),
- calcNewValue(seed), cv.getValue());
-
- seed[0]++;
- test1.setValue(new Integer(0));
- assertEquals("CalculatedValue should be " + calcNewValue(seed),
- calcNewValue(seed), cv.getValue());
-
- seed[0]++;
- test2.setValue(new Integer(0));
- assertEquals("CalculatedValue should be " + calcNewValue(seed),
- calcNewValue(seed), cv.getValue());
-
- // Unhook observables...
- WritableValue test3 = new WritableValue(Integer.TYPE);
- WritableValue test4 = new WritableValue(Integer.TYPE);
- // cv.setDependencies(new IObservableValue[] {test3, test4});
-
- Integer oldValue = (Integer) cv.getValue();
-
- seed[0]++; // Calculation has changed
- test2.setValue(new Integer(0)); // should not update yet
- assertEquals("CalculatedValue should be " + oldValue, oldValue, cv
- .getValue());
- test3.setValue(new Integer(0)); // This should update
- assertEquals("CalculatedValue should be " + calcNewValue(seed),
- calcNewValue(seed), cv.getValue());
-
- seed[0]++;
- test4.setValue(new Integer(0));
- assertEquals("CalculatedValue should be " + calcNewValue(seed),
- calcNewValue(seed), cv.getValue());
- }
-
- private static class TestModel extends ModelObject {
- private int a = 0;
-
- /**
- * @return Returns the a.
- */
- public int getA() {
- return a;
- }
-
- /**
- * @param a
- * The a to set.
- */
- public void setA(int a) {
- int oldValue = this.a;
- this.a = a;
- firePropertyChange("a", oldValue, a);
- }
- }
-
- public void test_convertToObservables() throws Exception {
- final int[] seed = new int[] { 42 };
- ComputedValue cv = new ComputedValue() {
- protected Object calculate() {
- return calcNewValue(seed);
- }
- };
- TestModel test1 = new TestModel();
- TestModel test2 = new TestModel();
-
- // Hook beans...
- DataBindingContext dbc = new DataBindingContext();
- dbc.addObservableFactory(new BeanObservableFactory(dbc, null, null));
-
- // cv.setDependencies(dbc, new Object[] {new Property(test1, "a"), new
- // Property(test2, "a")});
- assertEquals("CalculatedValue should be " + calcNewValue(seed),
- calcNewValue(seed), cv.getValue());
-
- seed[0]++;
- test1.setA(1);
- assertEquals("CalculatedValue should be " + calcNewValue(seed),
- calcNewValue(seed), cv.getValue());
-
- seed[0]++;
- test2.setA(2);
- assertEquals("CalculatedValue should be " + calcNewValue(seed),
- calcNewValue(seed), cv.getValue());
-
- // Unhook beans...
- TestModel test3 = new TestModel();
- TestModel test4 = new TestModel();
- // cv.setDependencies(dbc, new Object[] {new Property(test3, "a"), new
- // Property(test4, "a")});
-
- Integer oldValue = (Integer) cv.getValue();
-
- seed[0]++;
- test2.setA(3);
- assertEquals("CalculatedValue should be " + oldValue, oldValue, cv
- .getValue());
- test3.setA(4);
- assertEquals("CalculatedValue should be " + calcNewValue(seed),
- calcNewValue(seed), cv.getValue());
-
- seed[0]++;
- test4.setA(5);
- assertEquals("CalculatedValue should be " + calcNewValue(seed),
- calcNewValue(seed), cv.getValue());
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/DatabindingContextTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/DatabindingContextTest.java
deleted file mode 100644
index 4449df78..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/DatabindingContextTest.java
+++ /dev/null
@@ -1,662 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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
- * Brad Reynolds - bug 159539
- * Brad Reynolds - bug 140644
- * Brad Reynolds - bug 159940
- *******************************************************************************/
-package org.eclipse.jface.tests.databinding;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.databinding.observable.list.IListChangeListener;
-import org.eclipse.jface.databinding.observable.list.IObservableList;
-import org.eclipse.jface.databinding.observable.list.ListDiff;
-import org.eclipse.jface.databinding.observable.list.WritableList;
-import org.eclipse.jface.databinding.observable.value.AbstractObservableValue;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.databinding.observable.value.IValueChangeListener;
-import org.eclipse.jface.databinding.observable.value.ValueDiff;
-import org.eclipse.jface.databinding.observable.value.WritableValue;
-import org.eclipse.jface.internal.databinding.provisional.BindSpec;
-import org.eclipse.jface.internal.databinding.provisional.Binding;
-import org.eclipse.jface.internal.databinding.provisional.BindingAdapter;
-import org.eclipse.jface.internal.databinding.provisional.BindingEvent;
-import org.eclipse.jface.internal.databinding.provisional.BindingException;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.conversion.ConvertString2Byte;
-import org.eclipse.jface.internal.databinding.provisional.conversion.IConverter;
-import org.eclipse.jface.internal.databinding.provisional.conversion.IdentityConverter;
-import org.eclipse.jface.internal.databinding.provisional.conversion.ToStringConverter;
-import org.eclipse.jface.internal.databinding.provisional.description.NestedProperty;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultBindSupportFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.IObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.NestedObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.validation.IValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.ValidationError;
-import org.eclipse.jface.tests.databinding.util.Mocks;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-public class DatabindingContextTest extends TestCase {
-
- boolean failed = false;
-
- DataBindingContext dbc;
-
- IObservableValue observableValueRMock;
-
- IValidator validatorMock;
-
- WritableValue settableValue1;
-
- WritableValue settableValue2;
-
- Object o1 = new Object();
-
- Object o2 = new Object();
-
- private static IConverter identityConverter = new IdentityConverter(
- Object.class);
-
- protected void setUp() throws Exception {
- super.setUp();
- dbc = DataBindingContext.createContext(new IObservableFactory[0]);
- observableValueRMock = (IObservableValue) Mocks
- .createRelaxedMock(IObservableValue.class);
- validatorMock = (IValidator) Mocks.createMock(IValidator.class);
- settableValue1 = new WritableValue(Object.class);
- settableValue2 = new WritableValue(Object.class);
- }
-
- protected void tearDown() throws Exception {
- if (!failed) {
- Mocks.verify(observableValueRMock);
- Mocks.verify(validatorMock);
- }
- super.tearDown();
- }
-
- protected void runTest() throws Throwable {
- try {
- super.runTest();
- } catch (Throwable th) {
- failed = true;
- throw th;
- }
- }
-
- public void testRegisterForDispose() {
- final boolean[] disposeCalled = new boolean[] { false };
- IObservableValue target = new WritableValue(Integer.TYPE) {
- public void dispose() {
- super.dispose();
- disposeCalled[0] = true;
- }
- };
- WritableValue model = new WritableValue(Integer.TYPE);
- model.setValue(new Integer(12));
- Display display = new Display();
- Shell shell = new Shell(display);
- final DataBindingContext dbc = DataBindingContext
- .createContext(new IObservableFactory[] {});
- registerContextToDispose(shell, dbc);
- dbc.registerForDispose(target);
- dbc.registerForDispose(model);
- dbc.bind(target, model, null);
- assertEquals("target should now have model's value", 12,
- ((Integer) target.getValue()).intValue());
- target.setValue(new Integer(9));
- assertEquals("model should now have target's value", 9,
- ((Integer) model.getValue()).intValue());
- shell.dispose();
- display.dispose();
- assertTrue("dispose should have been called", disposeCalled[0]);
- }
-
- private class DisposableObservable extends AbstractObservableValue {
- protected Object computeValue() {
- return null;
- }
-
- public void setValue(Object value) {
- }
-
- public Object getValueType() {
- return Object.class;
- }
-
- protected Object doGetValue() {
- return null;
- }
-
- boolean isDisposed = false;
-
- public void dispose() {
- super.dispose();
- isDisposed = true;
- }
-
- public boolean isDisposed() {
- return isDisposed;
- }
- }
-
- private class DisposableObservableFactory implements IObservableFactory {
- public IObservable createObservable(Object description) {
- return new DisposableObservable();
- }
- }
-
- public void testDisposeCalled() {
- Display display = new Display();
- Shell shell = new Shell(display);
- DataBindingContext dbc = DataBindingContext
- .createContext(new IObservableFactory[] { new DisposableObservableFactory() });
- registerContextToDispose(shell, dbc);
- DisposableObservable u = (DisposableObservable) dbc
- .createObservable(null);
- assertFalse("is not disposed", u.isDisposed());
- shell.dispose();
- display.dispose();
- assertTrue("is disposed", u.isDisposed());
- }
-
- private void registerContextToDispose(Shell shell,
- final DataBindingContext dbc) {
- shell.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- dbc.dispose();
- }
- });
- }
-
- public void testBindValueModel() {
- Mocks.reset(observableValueRMock);
- observableValueRMock.addValueChangeListener(null);
- observableValueRMock.getValue();
- observableValueRMock.getValueType();
- Mocks.setLastReturnValue(observableValueRMock, Object.class);
- validatorMock.isValid(null);
- Mocks.startChecking(observableValueRMock);
- Mocks.startChecking(validatorMock);
- dbc.bind(settableValue1, observableValueRMock, new BindSpec(
- identityConverter, identityConverter, validatorMock, null));
- Mocks.verify(observableValueRMock);
- }
-
- public void testBindValueTarget() {
- observableValueRMock.addValueChangeListener(null);
- observableValueRMock.setValue(null);
- observableValueRMock.getValue();
- observableValueRMock.getValueType();
- Mocks.setLastReturnValue(observableValueRMock, Object.class);
- validatorMock.isValid(null);
- Mocks.startChecking(observableValueRMock);
- Mocks.startChecking(validatorMock);
- dbc.bind(observableValueRMock, settableValue2, new BindSpec(
- identityConverter, identityConverter, validatorMock, null));
- }
-
- public void testBindValuePropagation() {
- settableValue1.setValue(o1);
- settableValue2.setValue(o2);
- dbc.bind(settableValue1, settableValue2, null);
- assertEquals(o2, settableValue1.getValue());
- settableValue1.setValue(o1);
- assertEquals(o1, settableValue2.getValue());
- settableValue2.setValue(o2);
- assertEquals(o2, settableValue1.getValue());
- }
-
- public void testBindingListeners() {
- final int[] calls = new int[] { 0, 0 };
- // this exact sequence of positions are not API and may change from
- // release to release.
- // This is just here to check that we got a sane sequence of pipeline
- // positions
- // and to catch when the sequence changes when we don't expect it to
- // change.
- //
- // See BindingEvent#pipelinePosition for details.
- final int[] pipelinePositions = new int[] { 0, 1, 2, 3, 4, 0, 2, 4, 1,
- 0, 1, 2, 0, 2, 4, 1 };
- settableValue1.setValue(o1);
- settableValue2.setValue(o2);
- Binding binding = dbc.bind(settableValue1, settableValue2, null);
- binding.addBindingEventListener(new BindingAdapter() {
- public ValidationError bindingEvent(BindingEvent e) {
- // Make sure we get the right sequence of pipeline positions
- assertEquals("Unexpected pipeline position at call #"
- + calls[0], pipelinePositions[calls[0]],
- e.pipelinePosition);
- calls[0]++;
- return null;
- }
- });
- binding.addBindingEventListener(new BindingAdapter() {
- public ValidationError bindingEvent(BindingEvent e) {
- calls[1]++;
- return null;
- }
- });
- assertEquals(o2, settableValue1.getValue());
- assertEquals(
- "Both binding events should be called the same number of times",
- calls[0], calls[1]);
- settableValue1.setValue(o1);
- assertEquals(o1, settableValue2.getValue());
- assertEquals(
- "Both binding events should be called the same number of times",
- calls[0], calls[1]);
- settableValue2.setValue(o2);
- assertEquals(
- "Both binding events should be called the same number of times",
- calls[0], calls[1]);
- assertEquals(o2, settableValue1.getValue());
-
- // Now test forcing an error from the event handler...
- binding.addBindingEventListener(new BindingAdapter() {
- public ValidationError bindingEvent(BindingEvent e) {
- if (e.pipelinePosition == org.eclipse.jface.databinding.BindingEvent.PIPELINE_AFTER_CONVERT) {
- return ValidationError.error("error");
- }
- return null;
- }
- });
- settableValue1.setValue(o1);
- settableValue2.setValue(o2);
- assertEquals(
- "Both binding events should be called the same number of times",
- calls[0], calls[1]);
- assertEquals("binding events should be called at least once", true,
- calls[0] > 0);
- }
-
- public void testCollectionBindingListeners() {
-
- WritableList v1 = new WritableList();
- WritableList v2 = new WritableList();
-
- Binding binding = dbc.bind(v1, v2, null);
- final int[] calls = new int[] { 0 };
- binding.addBindingEventListener(new BindingAdapter() {
- public ValidationError bindingEvent(BindingEvent e) {
- calls[0]++;
- return null;
- }
- });
-
- v2.add(0, "test");
- assertBindingCalls(calls);
- v2.remove(0);
- assertBindingCalls(calls);
- v2.add(0, "test2");
- assertBindingCalls(calls);
- v2.set(0, "test3");
- assertBindingCalls(calls);
- }
-
- private void assertBindingCalls(final int[] calls) {
- assertTrue("Should have seen some binding event calls", calls[0] > 0);
- calls[0] = 0;
- }
-
- public void testCreateNestedObservableWithArrays() {
- // String parentObject = "";
- // NestedProperty nestedProperty = new NestedProperty(parentObject, new
- // String[] {"nestedChild1", "nestedChild2", "foo"}, new Class[]
- // {Integer.class, String.class, Float.class});
- // DataBindingContext ctx = DataBinding.createContext(new
- // IObservableFactory[] {new MockObservableFactory(), new
- // NestedObservableFactory()});
- // INestedObservableValue observableValue = (INestedObservableValue)
- // ctx.createObservable(nestedProperty);
- // assertEquals("The child IObservable does not have the right type.",
- // Float.class, observableValue.getValueType());
- //
- // observableValue = ((INestedObservableValue)
- // observableValue.getOuterObservableValue());
- // assertEquals("The child IObservable does not have the right type.",
- // String.class, observableValue.getValueType());
- //
- // MockObservableValue v = ((MockObservableValue)
- // observableValue.getOuterObservableValue());
- // assertEquals("The child IObservable does not have the right getter.",
- // "nestedChild1", v.getDescription());
- // assertSame("The child IObservable does not have a correct parent
- // target object.", parentObject, v.getOuterObservableValue());
- // assertEquals("The child IObservable does not have the right type.",
- // Integer.class, v.getType());
- }
-
- public void testCreateNestedObservableWithPrototypeClass() {
- // String parentObject = "";
- // NestedProperty nestedProperty = new NestedProperty(parentObject,
- // "nestedChild1.nestedChild2.foo", NestedParent.class);
- // DataBindingContext ctx = DataBinding.createContext(new
- // IObservableFactory[] {new MockObservableFactory(), new
- // NestedObservableFactory()});
- // INestedObservableValue observableValue = (INestedObservableValue)
- // ctx.createObservable(nestedProperty);
- // assertEquals("The child IObservable does not have the right type.",
- // String.class, observableValue.getValueType());
- //
- // observableValue = ((INestedObservableValue)
- // observableValue.getOuterObservableValue());
- // assertEquals("The child IObservable does not have the right type.",
- // NestedChild2.class, observableValue.getValueType());
- //
- // MockObservableValue v = ((MockObservableValue)
- // observableValue.getOuterObservableValue());
- // assertEquals("The child IObservable does not have the right getter.",
- // "nestedChild1", v.getDescription());
- // assertSame("The child IObservable does not have a correct parent
- // target object.", parentObject, v.getOuterObservableValue());
- // assertEquals("The child IObservable does not have the right type.",
- // NestedChild1.class, v.getType());
- }
-
- public void testCreateNestedObservableWithPrototypeClassAndInvalidPath() {
- String parentObject = "";
- NestedProperty nestedProperty = new NestedProperty(parentObject,
- "nestedChild1.nestedChild3.foo", NestedParent.class);
- try {
- DataBindingContext ctx = new DataBindingContext();
- ctx.addObservableFactory(new MockObservableFactory());
- ctx.addObservableFactory(new NestedObservableFactory(ctx));
- ctx.createObservable(nestedProperty);
- fail("Expected binding exception.");
- } catch (BindingException be) {
- }
- }
-
- public void testFillBindSpecDefaultsMultipleConvertersAndValidators() throws Exception {
- DataBindingContext dbc = new DataBindingContext();
- dbc.addBindSupportFactory(new DefaultBindSupportFactory());
-
- BindSpec bs = new BindSpec();
- bs.setModelToTargetConverters(new IConverter[] {
- null, new ToStringConverter(), null
- });
- bs.setTargetToModelConverters(new IConverter[] {
- null, new ConvertString2Byte(), null
- });
-
- dbc.fillBindSpecDefaults(dbc, bs, Object.class, Object.class);
-
- assertConverterType(bs, 0, IdentityConverter.class, bs.getModelToTargetConverters());
- assertConverterType(bs, 1, ToStringConverter.class, bs.getModelToTargetConverters());
- assertConverterType(bs, 2, IdentityConverter.class, bs.getModelToTargetConverters());
-
- assertConverterType(bs, 0, IdentityConverter.class, bs.getTargetToModelConverters());
- assertConverterType(bs, 1, ConvertString2Byte.class, bs.getTargetToModelConverters());
- assertConverterType(bs, 2, IdentityConverter.class, bs.getTargetToModelConverters());
- }
-
- public void testWithDefaults() throws Exception {
- org.eclipse.jface.databinding.DataBindingContext dbc = new org.eclipse.jface.databinding.DataBindingContext();
- assertNull("converter should not exist by default", dbc.createConverter(String.class, String.class));
-
- dbc = org.eclipse.jface.databinding.DataBindingContext.withDefaults();
- assertNotNull(dbc);
- assertNotNull("converter was not initialized with defaults", dbc.createConverter(String.class, String.class));
- }
-
- private void assertConverterType(BindSpec bs, int element, Class clazz, IConverter[] converters) {
- assertEquals("model2target[" + element + "] = identity", clazz, converters[element].getClass());
- }
-
- /**
- * Asserts that ValidationError is populated and change events are fired
- * when a Binding that is associated with a context is in error.
- *
- * @throws Exception
- */
- public void testValidationError() throws Exception {
- WritableValue targetObservable = new WritableValue(String.class);
- WritableValue modelObservable = new WritableValue(String.class);
-
- final String errorMessage = "error";
- org.eclipse.jface.databinding.DataBindingContext dbc = org.eclipse.jface.databinding.DataBindingContext.withDefaults();
- ValueChangeCounter errorCounter = new ValueChangeCounter();
- ListChangeCounter errorsCounter = new ListChangeCounter();
-
- IObservableValue error = dbc.getValidationError();
- error.addValueChangeListener(errorCounter);
- assertNull(error.getValue());
-
- IObservableList errors = dbc.getValidationErrors();
- errors.addListChangeListener(errorsCounter);
- assertEquals(0, errors.size());
-
- IValidator validator = new IValidator() {
- public ValidationError isPartiallyValid(Object value) {
- return null;
- }
-
- public ValidationError isValid(Object value) {
- return ValidationError.error(errorMessage);
- }
- };
-
- dbc.bindValue(targetObservable,
- modelObservable,
- new org.eclipse.jface.databinding.BindSpec().setValidator(validator));
-
- targetObservable.setValue("");
- assertNotNull(error.getValue());
- assertEquals(errorMessage, error.getValue().toString());
- assertEquals(1, errors.size());
- assertEquals(1, errorsCounter.count);
- assertEquals(1, errorCounter.count);
- }
-
- /**
- * Asserts that then
- * {@link DataBindingContext#bindValue(IObservableValue, IObservableValue, org.eclipse.jface.databinding.BindSpec)}
- * if invoked the created binding is added to the internal list of bindings.
- *
- * @throws Exception
- */
- public void testBindValueAddBinding() throws Exception {
- WritableValue targetValue = new WritableValue(String.class);
- WritableValue modelValue = new WritableValue(String.class);
-
- org.eclipse.jface.databinding.DataBindingContext dbc = org.eclipse.jface.databinding.DataBindingContext.withDefaults();
- assertNotNull(dbc.getBindings());
- assertEquals(0, dbc.getBindings().size());
-
- org.eclipse.jface.databinding.Binding binding = dbc.bindValue(targetValue, modelValue, null);
- assertNotNull(binding);
- assertNotNull(dbc.getBindings());
- assertEquals(1, dbc.getBindings().size());
- assertEquals(binding, dbc.getBindings().get(0));
- }
-
- /**
- * Asserts that when
- * {@link DataBindingContext#bindList(IObservableList, IObservableList, org.eclipse.jface.databinding.BindSpec)}
- * is invoked the created binding is added to the intenal list of bindings.
- *
- * @throws Exception
- */
- public void testBindListAddBinding() throws Exception {
- WritableList targetList = new WritableList(Object.class);
- WritableList modelList = new WritableList(Object.class);
-
- org.eclipse.jface.databinding.DataBindingContext dbc = org.eclipse.jface.databinding.DataBindingContext.withDefaults();
- assertNotNull(dbc.getBindings());
- assertEquals(0, dbc.getBindings().size());
-
- org.eclipse.jface.databinding.Binding binding = dbc.bindList(targetList, modelList, null);
- assertNotNull(binding);
- assertNotNull(dbc.getBindings());
- assertEquals(1, dbc.getBindings().size());
- assertEquals(binding, dbc.getBindings().get(0));
- }
-
- public void testGetBindingsImmutability() throws Exception {
- org.eclipse.jface.databinding.DataBindingContext dbc = org.eclipse.jface.databinding.DataBindingContext.withDefaults();
- BindingStub binding = new BindingStub(null);
- dbc.addBinding(binding);
-
- try {
- dbc.getBindings().remove(0);
- fail("exception should have been thrown");
- } catch (UnsupportedOperationException e) {
- }
- }
-
- public void testRemoveBinding() throws Exception {
- BindingStub binding = new BindingStub(null);
- org.eclipse.jface.databinding.DataBindingContext dbc = org.eclipse.jface.databinding.DataBindingContext.withDefaults();
- dbc.addBinding(binding);
-
- assertTrue("context should contain the binding", dbc.getBindings().contains(binding));
- assertEquals("context should have been set on the binding", dbc, binding.context);
- assertTrue("removing the factory should return true", dbc.removeBinding(binding));
- assertNull("context should have been removed", binding.context);
- assertFalse("binding should have been removed", dbc.getBindings().contains(binding));
- assertFalse("when not found false should be returned", dbc.removeBinding(binding));
- }
-
- /**
- * {@link IValueChangeListener} implementation that counts the times
- * handleValueChange(...) is invoked.
- *
- * @since 3.2
- */
- private static class ValueChangeCounter implements IValueChangeListener {
- int count;
-
- public void handleValueChange(IObservableValue source, ValueDiff diff) {
- count++;
- }
- }
-
- /**
- * {@link IListChangeListener} implementation that counts the times
- * handleListChange(...) is invoked.
- *
- */
- private static class ListChangeCounter implements IListChangeListener {
- int count;
-
- public void handleListChange(IObservableList source, ListDiff diff) {
- count++;
- }
- }
-
- private static class BindingStub extends org.eclipse.jface.databinding.Binding {
- org.eclipse.jface.databinding.DataBindingContext context;
-
- public BindingStub(org.eclipse.jface.databinding.DataBindingContext context) {
- super(context);
- }
-
- public IObservableValue getPartialValidationError() {
- return null;
- }
-
- public IObservableValue getValidationError() {
- return null;
- }
-
- public void updateModelFromTarget() {
- }
-
- public void updateTargetFromModel() {
- }
-
- public void setDataBindingContext(org.eclipse.jface.databinding.DataBindingContext context) {
- this.context = context;
- }
- }
-
- //-------------------------------------------------------------------------
- // Fixture classes
- //-------------------------------------------------------------------------
-
- public class MockObservableFactory implements IObservableFactory {
- public IObservable createObservable(Object description) {
- Property property = (Property) description;
- return new MockObservableValue(property.getObject(), property
- .getPropertyID(), property.getPropertyType());
- }
- }
-
- public class MockObservableValue extends AbstractObservableValue {
- public Object targetObject;
-
- public Object description;
-
- private Class type;
-
- public MockObservableValue(Object targetObject, Object description,
- Class type) {
- super();
- this.targetObject = targetObject;
- this.description = description;
- this.type = type;
- }
-
- public Object getDescription() {
- return description;
- }
-
- public Class getType() {
- return type;
- }
-
- public Object getOuterObservableValue() {
- return targetObject;
- }
-
- public Object computeValue() {
- return null;
- }
-
- public Object getValueType() {
- return null;
- }
-
- public void setValue(Object value) {
- }
-
- protected Object doGetValue() {
- return null;
- }
-
- }
-
- private class NestedParent {
- public NestedChild1 getNestedChild1() {
- return new NestedChild1();
- }
- }
-
- private class NestedChild1 {
- public NestedChild2 getNestedChild2() {
- return new NestedChild2();
- }
- }
-
- private class NestedChild2 {
- public String getFoo() {
- return "foo";
- }
- }
-
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/EventEditor.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/EventEditor.java
deleted file mode 100644
index d888335d..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/EventEditor.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.tests.databinding;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.examples.databinding.compositetable.day.CalendarableItemEvent;
-import org.eclipse.jface.examples.databinding.compositetable.day.CalendarableItemEventHandler;
-import org.eclipse.jface.examples.databinding.compositetable.day.CalendarableSelectionChangeListener;
-import org.eclipse.jface.examples.databinding.compositetable.day.NewEvent;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableModel;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventContentProvider;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventCountProvider;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor;
-
-/**
- * A concrete class that implements IEventEditor for testing purposes.
- * <p>
- * Eventually, this could become an abstract parent class for creating
- * arbitrary new IEventEditor implementations.
- *
- * @since 3.3
- */
-public class EventEditor implements IEventEditor {
-
- protected CalendarableModel model = new CalendarableModel();
-
- // Utilities --------------------------------------------------------------
-
- private void fireEvent(CalendarableItemEvent e, List handlers) {
- for (Iterator i = handlers.iterator(); i.hasNext();) {
- CalendarableItemEventHandler h = (CalendarableItemEventHandler) i.next();
- h.handleRequest(e);
- if (!e.doit) {
- break;
- }
- }
- }
-
- private CalendarableItemEvent calendarableItemEvent(CalendarableItem item) {
- CalendarableItemEvent e = new CalendarableItemEvent();
- e.calendarableItem = item;
- return e;
- }
-
- // Events ----------------------------------------------------------------
-
- private List insertHandlers = new ArrayList();
-
- public NewEvent fireInsert(Date date, boolean allDayEvent) {
- CalendarableItem item = new CalendarableItem(date);
- CalendarableItemEvent e = calendarableItemEvent(item);
- fireEvent(e, insertHandlers);
- if (e.doit) {
- // TODO: Only refresh days that need refreshing
- refresh();
- return (NewEvent) e.result;
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#addItemInsertHandler(org.eclipse.jface.examples.databinding.compositetable.day.CalendarableItemEventHandler)
- */
- public void addItemInsertHandler(CalendarableItemEventHandler insertHandler) {
- insertHandlers.add(insertHandler);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#removeItemInsertHandler(org.eclipse.jface.examples.databinding.compositetable.day.CalendarableItemEventHandler)
- */
- public void removeItemInsertHandler(
- CalendarableItemEventHandler insertHandler) {
- insertHandlers.remove(insertHandler);
- }
-
- private List deleteHandlers = new ArrayList();
-
- public boolean fireDelete(CalendarableItem toDelete) {
- CalendarableItemEvent e = calendarableItemEvent(toDelete);
- fireEvent(e, deleteHandlers);
- if (e.doit) {
- // TODO: only refresh affected days
- refresh();
- }
- return e.doit;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#addItemDeleteHandler(org.eclipse.jface.examples.databinding.compositetable.day.CalendarableItemEventHandler)
- */
- public void addItemDeleteHandler(CalendarableItemEventHandler deleteHandler) {
- deleteHandlers.add(deleteHandler);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#removeItemDeleteHandler(org.eclipse.jface.examples.databinding.compositetable.day.CalendarableItemEventHandler)
- */
- public void removeItemDeleteHandler(CalendarableItemEventHandler deleteHandler) {
- deleteHandlers.remove(deleteHandler);
- }
-
- private List editHandlers = new ArrayList();
-
- public void fireEdit(CalendarableItem toEdit) {
- fireEvent(calendarableItemEvent(toEdit), editHandlers);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#addItemEditHandler(org.eclipse.jface.examples.databinding.compositetable.day.CalendarableItemEventHandler)
- */
- public void addItemEditHandler(CalendarableItemEventHandler handler) {
- editHandlers.add(handler);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#removeItemEditHandler(org.eclipse.jface.examples.databinding.compositetable.day.CalendarableItemEventHandler)
- */
- public void removeItemEditHandler(CalendarableItemEventHandler handler) {
- editHandlers.remove(handler);
- }
-
- private List disposeHandlers = new ArrayList();
-
- public void fireDispose(CalendarableItem disposed) {
- fireEvent(calendarableItemEvent(disposed), disposeHandlers);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#addItemDisposeHandler(org.eclipse.jface.examples.databinding.compositetable.day.CalendarableItemEventHandler)
- */
- public void addItemDisposeHandler(CalendarableItemEventHandler itemDisposeHandler) {
- disposeHandlers.add(itemDisposeHandler);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#removeItemDisposeHandler(org.eclipse.jface.examples.databinding.compositetable.day.CalendarableItemEventHandler)
- */
- public void removeItemDisposeHandler(CalendarableItemEventHandler itemDisposeHandler) {
- disposeHandlers.remove(itemDisposeHandler);
- }
-
- // Model stuff ------------------------------------------------------------
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#getNumberOfDays()
- */
- public int getNumberOfDays() {
- return model.getNumberOfDays();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#getNumberOfDivisionsInHour()
- */
- public int getNumberOfDivisionsInHour() {
- return model.getNumberOfDivisionsInHour();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#setTimeBreakdown(int, int)
- */
- public void setTimeBreakdown(int numberOfDays, int numberOfDivisionsInHour) {
- model.setTimeBreakdown(numberOfDays, numberOfDivisionsInHour);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#setEventContentProvider(org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventContentProvider)
- */
- public void setEventContentProvider(EventContentProvider eventContentProvider) {
- model.setEventContentProvider(eventContentProvider);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#setEventCountProvider(org.eclipse.jface.examples.databinding.compositetable.timeeditor.EventCountProvider)
- */
- public void setEventCountProvider(EventCountProvider eventCountProvider) {
- model.setEventCountProvider(eventCountProvider);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#setStartDate(java.util.Date)
- */
- public void setStartDate(Date startDate) {
- List disposedCalendarables = model.setStartDate(startDate);
- for (Iterator i = disposedCalendarables.iterator(); i.hasNext();) {
- CalendarableItem element = (CalendarableItem) i.next();
- fireDispose(element);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#getStartDate()
- */
- public Date getStartDate() {
- return model.getStartDate();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#refresh(java.util.Date)
- */
- public void refresh(Date date) {
- model.refresh(date);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#refresh()
- */
- public void refresh() {
- Date dateToRefresh = getStartDate();
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(dateToRefresh);
- for (int i=0; i < getNumberOfDays(); ++i) {
- refresh(gc.getTime());
- gc.add(Calendar.DATE, 1);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#addSelectionChangeListener(org.eclipse.jface.examples.databinding.compositetable.day.CalendarableSelectionChangeListener)
- */
- public void addSelectionChangeListener(CalendarableSelectionChangeListener l) {
- // no op
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.examples.databinding.compositetable.timeeditor.IEventEditor#removeSelectionChangeListener(org.eclipse.jface.examples.databinding.compositetable.day.CalendarableSelectionChangeListener)
- */
- public void removeSelectionChangeListener(CalendarableSelectionChangeListener l) {
- // no op
- }
-
-}
-
-
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/EventEditorObservableLazyDataRequestorTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/EventEditorObservableLazyDataRequestorTest.java
deleted file mode 100644
index aa320dbd..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/EventEditorObservableLazyDataRequestorTest.java
+++ /dev/null
@@ -1,592 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.tests.databinding;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.databinding.observable.list.WritableList;
-import org.eclipse.jface.examples.databinding.ModelObject;
-import org.eclipse.jface.examples.databinding.compositetable.day.NewEvent;
-import org.eclipse.jface.examples.databinding.compositetable.day.binding.EventEditorBindingDescription;
-import org.eclipse.jface.examples.databinding.compositetable.day.binding.EventEditorObservableLazyDataRequestorFactory;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableItem;
-import org.eclipse.jface.examples.databinding.compositetable.timeeditor.CalendarableModel;
-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.beans.BeanObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultBindSupportFactory;
-import org.eclipse.jface.internal.databinding.provisional.factories.DefaultBindingFactory;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyDeleteEvent;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertDeleteProvider;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertEvent;
-import org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor.NewObject;
-
-/**
- * This is basically two tests in one. It's an integration test that makes
- * sure that we can successfully bind EventEditors to JavaBean-style List
- * objects. However, since all of the other layers in this binding are also
- * unit-tested, it is also a unit test of the
- * EventEditorObservableLazyDataRequestor.
- *
- * @since 3.2
- */
-public class EventEditorObservableLazyDataRequestorTest extends TestCase {
-
- private EventEditorStub editor;
- private DataBindingContext dbc;
-
- private DataBindingContext getDBC() {
- DataBindingContext dbc = new DataBindingContext();
- dbc.addBindingFactory(new DefaultBindingFactory());
- dbc.addObservableFactory(new EventEditorObservableLazyDataRequestorFactory());
- dbc.addObservableFactory(new BeanObservableFactory(dbc, null, null));
- dbc.addBindSupportFactory(new DefaultBindSupportFactory());
- return dbc;
- }
-
- private static class EventEditorStub extends EventEditor {
- public CalendarableModel model() {
- return model;
- }
- }
-
- protected static class Event extends ModelObject {
- public boolean allDay = false;
- public Date startTime;
- public Date endTime;
- public String description;
-
- public Event(Date startTime, Date endTime, String description) {
- this(startTime, endTime, description, false);
- }
-
- public Event(Date startTime, Date endTime, String description, boolean isAllDay) {
- this.startTime = startTime;
- this.endTime = endTime;
- this.description = description;
- this.allDay = isAllDay;
- }
-
- public void setDescription(String string) {
- String oldValue = this.description;
- description = string;
- firePropertyChange("description", oldValue, string);
- }
-
- public boolean isAllDay() {
- return allDay;
- }
-
- public void setAllDay(boolean allDay) {
- this.allDay = allDay;
- }
-
- public Date getEndTime() {
- return endTime;
- }
-
- public void setEndTime(Date endTime) {
- this.endTime = endTime;
- }
-
- public Date getStartTime() {
- return startTime;
- }
-
- public void setStartTime(Date startTime) {
- this.startTime = startTime;
- }
-
- public String getDescription() {
- return description;
- }
-
- }
-
- protected Date time(int month, int day, int hour, int minutes) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(new Date());
- gc.set(Calendar.MONTH, month);
- gc.set(Calendar.DATE, day);
- gc.set(Calendar.HOUR_OF_DAY, hour);
- gc.set(Calendar.MINUTE, minutes);
- gc.set(Calendar.SECOND, 0);
- gc.set(Calendar.MILLISECOND, 0);
- return gc.getTime();
- }
-
-
- protected Date time(int hour, int minutes) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(new Date());
- gc.set(Calendar.HOUR_OF_DAY, hour);
- gc.set(Calendar.MINUTE, minutes);
- gc.set(Calendar.SECOND, 0);
- gc.set(Calendar.MILLISECOND, 0);
- return gc.getTime();
- }
-
- protected Date date(int month, int day) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(new Date());
- gc.set(Calendar.MONTH, month);
- gc.set(Calendar.DATE, day);
- gc.set(Calendar.HOUR_OF_DAY, 0);
- gc.set(Calendar.MINUTE, 0);
- gc.set(Calendar.SECOND, 0);
- gc.set(Calendar.MILLISECOND, 0);
- return gc.getTime();
- }
-
- protected Date nextDay(Date date) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(date);
- gc.add(Calendar.DATE, 1);
- return gc.getTime();
- }
-
- private WritableList loadTestDataIntoList(Event[] testData) {
- WritableList testDataList = new WritableList();
- for (int event = 0; event < testData.length; event++) {
- testDataList.add(testData[event]);
- }
- return testDataList;
- }
-
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- editor = new EventEditorStub();
- dbc = getDBC();
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- dbc.dispose();
- }
-
- private CalendarableItem ci(Date startDate, Date startTime, Date endTime, String description) {
- return ci(startDate, startTime, endTime, description, false);
- }
-
- private CalendarableItem ci(Date startDate, String description) {
- return ci(startDate, startDate, startDate, description, true);
- }
-
- private CalendarableItem ci(Date startDate, Date startTime, Date endTime, String description, boolean isAllDay) {
- CalendarableItem result = new CalendarableItem(startDate);
- result.setStartTime(startTime);
- result.setEndTime(endTime);
- result.setText(description);
- result.setAllDayEvent(isAllDay);
- return result;
- }
-
- protected Date setToStartOfDay(Date rawDate) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(rawDate);
- gc.set(Calendar.HOUR_OF_DAY, 0);
- gc.set(Calendar.MINUTE, 0);
- gc.set(Calendar.SECOND, 0);
- gc.set(Calendar.MILLISECOND, 0);
- return gc.getTime();
- }
-
- protected Date setToEndOfDay(Date date) {
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(date);
- gc.set(Calendar.HOUR_OF_DAY, 23);
- gc.set(Calendar.MINUTE, 59);
- gc.set(Calendar.SECOND, 59);
- gc.set(Calendar.MILLISECOND, 999);
- Date time = gc.getTime();
- return time;
- }
-
- private WritableList makeModel(final Event[] testData) {
- return loadTestDataIntoList(testData);
- }
-
- static class TestModel extends ModelObject {
- List testDataList;
- TestModel(List testData) {
- this.testDataList = testData;
- }
-
- public List getTestDataList() {
- return testDataList;
- }
-
- public void setTestDataList(List testDataList) {
- Object oldValue = this.testDataList;
- this.testDataList = testDataList;
- firePropertyChange("testDataList", oldValue, testDataList);
- }
- };
-
- private Property makeModel(List testData) {
- Object model = new TestModel(testData);
- return new Property(model, "testDataList");
- }
-
- private void assertEditorState(
- EventEditorStub editor,
- CalendarableItem[][] itemsInDay) {
- CalendarableModel cm = editor.model();
- for (int day=0; day < cm.getNumberOfDays(); ++day) {
- List calendarables = cm.getCalendarableItems(day);
- int itemInDay=0;
- assertEquals("Day " + day + ": list sizes same", itemsInDay[day].length, calendarables.size());
- for (Iterator calIter = calendarables.iterator(); calIter.hasNext();) {
- CalendarableItem item = (CalendarableItem) calIter.next();
- assertEquals("All-day", itemsInDay[day][itemInDay].isAllDayEvent(), item.isAllDayEvent());
- assertEquals("Text", itemsInDay[day][itemInDay].getText(), item.getText());
- if (item.isAllDayEvent()) {
- assertTrue("same day", isSameDay(itemsInDay[day][itemInDay].getStartTime(), item.getStartTime()));
- } else {
- assertEquals("Start time", itemsInDay[day][itemInDay].getStartTime(), item.getStartTime());
- assertEquals("End time", itemsInDay[day][itemInDay].getEndTime(), item.getEndTime());
- }
- ++itemInDay;
- }
- }
- }
-
- private boolean isSameDay(Date time1, Date time2) {
- GregorianCalendar gc1 = new GregorianCalendar();
- GregorianCalendar gc2 = new GregorianCalendar();
- gc1.setTime(time1);
- gc2.setTime(time2);
- if (gc1.get(Calendar.YEAR) != gc2.get(Calendar.YEAR)) {
- return false;
- }
- if (gc1.get(Calendar.MONTH) != gc2.get(Calendar.MONTH)) {
- return false;
- }
- if (gc1.get(Calendar.DATE) != gc2.get(Calendar.DATE)) {
- return false;
- }
- return true;
- }
-
- private EventEditorBindingDescription makeBindingDescription() {
- return new EventEditorBindingDescription(
- editor, dbc, "startTime", "endTime", "allDay", "description", null, null);
- }
-
-
- // Tests here -------------------------------------------------------------
-
- public void test_oneDayEvent_onEditorStartDate() throws Exception {
- editor.setTimeBreakdown(7, 4);
- editor.setStartDate(date(5, 15));
-
- EventEditorBindingDescription editorBindDesc = makeBindingDescription();
- Event[] testData = new Event[] {
- new Event (time(5, 15, 5, 45), time(5, 15, 9, 45), "Stand-up mtg")};
- dbc.bind(editorBindDesc, makeModel(testData), null);
- assertEditorState(editor, new CalendarableItem[][] {
- {ci(date(5, 15), time(5, 45), time(9, 45), "Stand-up mtg")},
- {},
- {},
- {},
- {},
- {},
- {}
- });
- }
-
- public void test_addingAndRemovingFromModel() throws Exception {
- editor.setTimeBreakdown(7, 4);
- editor.setStartDate(date(5, 15));
-
- EventEditorBindingDescription editorBindDesc = makeBindingDescription();
- Event[] testData = new Event[] {
- new Event (time(5, 15, 5, 45), time(5, 15, 9, 45), "Stand-up mtg")};
- WritableList model = makeModel(testData);
- dbc.bind(editorBindDesc, model, null);
- Event event = new Event (time(5, 16, 5, 45), time(5, 16, 9, 45), "Stand-up mtg 2");
- model.add(event);
- assertEditorState(editor, new CalendarableItem[][] {
- {ci(date(5, 15), time(5, 45), time(9, 45), "Stand-up mtg")},
- {ci(date(5, 16), time(5, 45), time(9, 45), "Stand-up mtg 2")},
- {},
- {},
- {},
- {},
- {}
- });
- model.remove(event);
- assertEditorState(editor, new CalendarableItem[][] {
- {ci(date(5, 15), time(5, 45), time(9, 45), "Stand-up mtg")},
- {},
- {},
- {},
- {},
- {},
- {}
- });
- }
-
- public void test_oneDayOneEvent_notOnEditorStartDate() throws Exception {
- editor.setTimeBreakdown(7, 4);
- editor.setStartDate(date(5, 15));
-
- EventEditorBindingDescription editorBindDesc = makeBindingDescription();
- Event[] testData = new Event[] {
- new Event (time(5, 16, 5, 45), time(5, 16, 9, 45), "Stand-up mtg")};
- dbc.bind(editorBindDesc, makeModel(testData), null);
- assertEditorState(editor, new CalendarableItem[][] {
- {},
- {ci(date(5, 16), time(5, 45), time(9, 45), "Stand-up mtg")},
- {},
- {},
- {},
- {},
- {}
- });
- }
-
- public void test_threeDayOneEvent() throws Exception {
- editor.setTimeBreakdown(7, 4);
- editor.setStartDate(date(5, 15));
-
- EventEditorBindingDescription editorBindDesc = makeBindingDescription();
- Event[] testData = new Event[] {
- new Event (time(5, 15, 5, 45), time(5, 17, 9, 45), "Stand-up mtg")};
- dbc.bind(editorBindDesc, makeModel(testData), null);
- assertEditorState(editor, new CalendarableItem[][] {
- {ci(date(5, 15), time(5, 45), setToEndOfDay(date(5, 15)), "Stand-up mtg")},
- {ci(date(5, 16), setToStartOfDay(date(5, 16)), setToEndOfDay(date(5, 16)), "Stand-up mtg")},
- {ci(date(5, 17), setToStartOfDay(date(5, 17)), time(9, 45), "Stand-up mtg")},
- {},
- {},
- {},
- {}
- });
- }
-
- public void test_threeDayOneEvent_notOnEditorStartDate() throws Exception {
- editor.setTimeBreakdown(7, 4);
- editor.setStartDate(date(5, 14));
-
- EventEditorBindingDescription editorBindDesc = makeBindingDescription();
- Event[] testData = new Event[] {
- new Event (time(5, 15, 5, 45), time(5, 17, 9, 45), "Stand-up mtg")};
- dbc.bind(editorBindDesc, makeModel(testData), null);
- assertEditorState(editor, new CalendarableItem[][] {
- {},
- {ci(date(5, 15), time(5, 45), setToEndOfDay(date(5, 15)), "Stand-up mtg")},
- {ci(date(5, 16), setToStartOfDay(date(5, 16)), setToEndOfDay(date(5, 16)), "Stand-up mtg")},
- {ci(date(5, 17), setToStartOfDay(date(5, 17)), time(9, 45), "Stand-up mtg")},
- {},
- {},
- {}
- });
- }
-
-
- public void test_oneDayOneAllDayEvent() throws Exception {
- editor.setTimeBreakdown(7, 4);
- editor.setStartDate(date(5, 15));
- Event[] testData = new Event[] {
- new Event (time(5, 15, 5, 45), time(5, 15, 9, 45), "Stand-up mtg", true)};
- EventEditorBindingDescription editorBindDesc = makeBindingDescription();
- dbc.bind(editorBindDesc, makeModel(testData), null);
- assertEditorState(editor, new CalendarableItem[][] {
- {ci(date(5, 15), "Stand-up mtg")},
- {},
- {},
- {},
- {},
- {},
- {}
- });
- }
-
- public void test_multiDayAllDayEvent() throws Exception {
- editor.setTimeBreakdown(7, 4);
- editor.setStartDate(date(5, 15));
- Event[] testData = new Event[] {
- new Event (time(5, 15, 5, 45), time(5, 17, 9, 45), "three day mtg", true)};
- EventEditorBindingDescription editorBindDesc = makeBindingDescription();
- dbc.bind(editorBindDesc, makeModel(testData), null);
- assertEditorState(editor, new CalendarableItem[][] {
- {ci(date(5, 15), "three day mtg")},
- {ci(date(5, 16), "three day mtg")},
- {ci(date(5, 17), "three day mtg")},
- {},
- {},
- {},
- {}
- });
- }
-
- public void test_bindCalendarableDescription() throws Exception {
- editor.setTimeBreakdown(7, 4);
- editor.setStartDate(date(5, 15));
- Event[] testData = new Event[] {
- new Event (time(5, 15, 5, 45), time(5, 15, 9, 45), "Stand-up mtg")};
- List testDataList = loadTestDataIntoList(testData);
- EventEditorBindingDescription editorBindDesc = makeBindingDescription();
- dbc.bind(editorBindDesc, makeModel(testDataList), null);
- assertEditorState(editor, new CalendarableItem[][] {
- {ci(date(5, 15), time(5, 45), time(9, 45), "Stand-up mtg")},
- {},
- {},
- {},
- {},
- {},
- {}
- });
- Event event = (Event) testDataList.get(0);
- event.setDescription("The quick brown fox jumped over the lazy dog.");
-
- List calendarableEvents = editor.model.getCalendarableItems((0));
- CalendarableItem item = (CalendarableItem) calendarableEvents.get(0);
- assertEquals("item Text was changed", event.description, item.getText());
- }
-
- /**
- * Test method for {@link org.eclipse.jface.examples.databinding.compositetable.day.binding.EventEditorObservableLazyDataRequestor#dispose()}.
- */
- public void testDispose() {
- editor.setTimeBreakdown(7, 4);
- editor.setStartDate(date(5, 14));
-
- EventEditorBindingDescription editorBindDesc = makeBindingDescription();
- Event[] testData = new Event[] {
- new Event (time(5, 15, 5, 45), time(5, 17, 9, 45), "Stand-up mtg")};
- dbc.bind(editorBindDesc, makeModel(testData), null);
-
- List daysToDispose = new LinkedList();
- for (int day=0; day < 7; ++day) {
- List calendarables = editor.model().getCalendarableItems(day);
- if (calendarables != null) {
- daysToDispose.addAll(calendarables);
- }
- }
-
- editor.setStartDate(date(5, 1));
-
- for (Iterator disposedDaysIter = daysToDispose.iterator(); disposedDaysIter.hasNext();) {
- CalendarableItem item = (CalendarableItem) disposedDaysIter.next();
- List bindingList = (List) item.getData("BindingBinding");
- for (Iterator bindingListIter = bindingList.iterator(); bindingListIter.hasNext();) {
- Binding binding = (Binding) bindingListIter.next();
- assertTrue("should be disposed", binding.isDisposed());
- }
- }
- }
-
- /**
- * Test method for {@link org.eclipse.jface.examples.databinding.compositetable.day.binding.EventEditorObservableLazyDataRequestor#add(int, java.lang.Object)}.
- */
- public void testInsert() {
- Event[] testData = new Event[] {
- new Event (time(5, 15, 5, 45), time(5, 15, 9, 45), "Stand-up mtg")};
- final WritableList model = makeModel(testData);
-
- LazyInsertDeleteProvider insertDeleteProvider = new LazyInsertDeleteProvider() {
- public NewObject insertElementAt(LazyInsertEvent e) {
- Event event = new Event(time(5, 17, 5, 45), time(5, 17, 9, 45), "Stand-up mtg 3");
- model.add(e.positionHint, event);
- return new NewObject(e.positionHint, event);
- }
-
- public void deleteElementAt(LazyDeleteEvent e) {
- }
- };
-
- editor.setTimeBreakdown(7, 4);
- editor.setStartDate(date(5, 15));
-
- EventEditorBindingDescription editorBindDesc = makeBindingDescription();
- dbc.bind(editorBindDesc, model, new BindSpec().setLazyInsertDeleteProvider(insertDeleteProvider));
- Event event = new Event (time(5, 16, 5, 45), time(5, 16, 9, 45), "Stand-up mtg 2");
- model.add(event);
-
- // Add the third event (to the target via the insertDeleteProvider)
- NewEvent results = editorBindDesc.editor.fireInsert(date(5, 17), false);
-
- assertEquals("start date", time(5, 17, 5, 45), results.startTimeEndTime[0]);
- assertEquals("end date", time(5, 17, 9, 45), results.startTimeEndTime[1]);
-
- assertEditorState(editor, new CalendarableItem[][] {
- {ci(date(5, 15), time(5, 45), time(9, 45), "Stand-up mtg")},
- {ci(date(5, 16), time(5, 45), time(9, 45), "Stand-up mtg 2")},
- {ci(date(5, 17), time(5, 45), time(9, 45), "Stand-up mtg 3")},
- {},
- {},
- {},
- {}
- });
- }
-
- /**
- * Test method for {@link org.eclipse.jface.examples.databinding.compositetable.day.binding.EventEditorObservableLazyDataRequestor#remove(int)}.
- */
- public void testRemove() {
- Event[] testData = new Event[] {
- new Event (time(5, 15, 5, 45), time(5, 15, 9, 45), "Stand-up mtg")};
- final WritableList model = makeModel(testData);
-
- LazyInsertDeleteProvider insertDeleteProvider = new LazyInsertDeleteProvider() {
- public NewObject insertElementAt(LazyInsertEvent e) {
- return null;
- }
-
- public boolean canDeleteElementAt(LazyDeleteEvent e) {
- return true;
- }
-
- public void deleteElementAt(LazyDeleteEvent e) {
- model.remove(e.position);
- }
- };
-
- editor.setTimeBreakdown(7, 4);
- editor.setStartDate(date(5, 15));
-
- EventEditorBindingDescription editorBindDesc = makeBindingDescription();
- dbc.bind(editorBindDesc, model, new BindSpec().setLazyInsertDeleteProvider(insertDeleteProvider));
- Event event = new Event (time(5, 16, 5, 45), time(5, 16, 9, 45), "Stand-up mtg 2");
- model.add(event);
-
- boolean result = editorBindDesc.editor.fireDelete((CalendarableItem) editor.model.getCalendarableItems(0).get(0));
-
- assertTrue("Could delete", result);
-
- assertEditorState(editor, new CalendarableItem[][] {
- {},
- {ci(date(5, 16), time(5, 45), time(9, 45), "Stand-up mtg 2")},
- {},
- {},
- {},
- {},
- {}
- });
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/IDiffsTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/IDiffsTest.java
deleted file mode 100644
index 99124174..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/IDiffsTest.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * 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.databinding;
-
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.databinding.observable.list.ListDiff;
-import org.eclipse.jface.databinding.observable.list.ListDiffEntry;
-import org.eclipse.jface.databinding.observable.set.SetDiff;
-import org.eclipse.jface.databinding.observable.value.ValueDiff;
-
-/**
- * @since 3.2
- *
- */
-public class IDiffsTest extends TestCase {
- /**
- * Asserts that the {@link SetDiff#toString()} implementation doesn't throw a NPE if any of its properties are <code>null</code>.
- */
- public void test_SetDiff() {
- SetDiff diff = new SetDiff() {
- public Set getAdditions() {
- return null;
- }
-
- public Set getRemovals() {
- return null;
- }
- };
-
- try {
- diff.toString();
- assertTrue(true);
- } catch (NullPointerException e) {
- fail("NPE was thrown.");
- }
- }
-
- /**
- * Asserts that the {@link LinkDiffEntry#toString()} implementation doesn't throw a NPE if any of its properties are <code>null</code>.
- */
- public void test_ListDiffEntry() {
- ListDiffEntry entry = new ListDiffEntry() {
- public Object getElement() {
- return null;
- }
-
- public int getPosition() {
- return 0;
- }
-
- public boolean isAddition() {
- return false;
- }
- };
-
- try {
- entry.toString();
- assertTrue(true);
- } catch (NullPointerException e) {
- fail("NPE was thrown.");
- }
- }
-
- /**
- * Asserts that the {@link ListDiff#toString()} implementation doesn't throw a NPE if any of its properties are <code>null</code>.
- *
- */
- public void test_ListDiff() {
- ListDiff diff = new ListDiff() {
- public ListDiffEntry[] getDifferences() {
- return null;
- }
- };
-
- try {
- diff.toString();
- assertTrue(true);
- } catch (NullPointerException e) {
- fail("NPE was thrown.");
- }
- }
-
- /**
- * Asserts that if the {@link ListDiff#toString()} implementation doesn't throw a NEP if the differences contains a <code>null</code> item.
- */
- public void test_ListDiff2() {
- ListDiff diff = new ListDiff() {
- public ListDiffEntry[] getDifferences() {
- return new ListDiffEntry[1];
- }
- };
-
- try {
- diff.toString();
- assertTrue(true);
- } catch (NullPointerException e) {
- fail("NPE was thrown.");
- }
- }
-
- /**
- * Asserts that if the {@link ValueDiff#toString()} implementation doesn't throw a NPE if any of its properties are <code>null</code>.
- *
- */
- public void test_ValueDiff() {
- ValueDiff diff = new ValueDiff() {
- public Object getNewValue() {
- return null;
- }
-
- public Object getOldValue() {
- return null;
- }
- };
-
- try {
- diff.toString();
- assertTrue(true);
- } catch (NullPointerException e) {
- fail("NPE was thrown.");
- }
- }
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/JavaBeansScalarObservableValueFactoryTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/JavaBeansScalarObservableValueFactoryTest.java
deleted file mode 100644
index 5729ab6f..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/JavaBeansScalarObservableValueFactoryTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.beans.JavaBeansScalarObservableValueFactory;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.factories.IObservableFactory;
-
-public class JavaBeansScalarObservableValueFactoryTest extends TestCase {
-
- public static class TestBean {
- private String field = "Hello, world";
-
- public String getField() {
- return field;
- }
-
- public void setField(String field) {
- this.field = field;
- }
- }
-
- public void test_getObservableValue() throws Exception {
- TestBean test = new TestBean();
-
- DataBindingContext dbc = DataBindingContext.createContext(new IObservableFactory[] {
- new JavaBeansScalarObservableValueFactory()
- });
- IObservableValue observable = (IObservableValue) dbc.createObservable(new Property(test, "field"));
- assertEquals("Hello, world", observable.getValue());
- }
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/LazyDataRequestor.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/LazyDataRequestor.java
deleted file mode 100644
index 8df3a35f..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/LazyDataRequestor.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 The Pampered Chef 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:
- * The Pampered Chef - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.tests.databinding;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.databinding.observable.AbstractObservable;
-import org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor;
-import org.eclipse.jface.internal.databinding.provisional.observable.ILazyListElementProvider;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyDeleteEvent;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertDeleteProvider;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertEvent;
-
-/**
- * @since 3.3
- *
- */
-public class LazyDataRequestor extends AbstractObservable implements ILazyDataRequestor {
-
- List elementProviders = new ArrayList();
- List insertDeleteProviders = new ArrayList();
- List listChangeListeners = new ArrayList();
- List changeListeners = new ArrayList();
- List staleListeners = new ArrayList();
- List windowData = new ArrayList();
- int size;
-
- int windowSize;
- int topRow = 0;
-
- public LazyDataRequestor (int windowSize) {
- this.windowSize = windowSize;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor#add(int, java.lang.Object)
- */
- public void add(int position, Object element) {
- size++;
- if (position < windowSize) {
- windowData.add(position, element);
- windowData.remove(windowData.size()-1);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor#remove(int)
- */
- public void remove(int position) {
- size--;
- if (position < windowSize) {
- windowData.remove(position);
- Object refreshed = fireElementProviders(windowData.size());
- windowData.add(refreshed);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor#addElementProvider(org.eclipse.jface.internal.databinding.provisional.observable.ILazyListElementProvider)
- */
- public void addElementProvider(ILazyListElementProvider p) {
- elementProviders.add(p);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor#addInsertDeleteProvider(org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertDeleteProvider)
- */
- public void addInsertDeleteProvider(LazyInsertDeleteProvider p) {
- insertDeleteProviders.add(p);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor#removeElementProvider(org.eclipse.jface.internal.databinding.provisional.observable.ILazyListElementProvider)
- */
- public void removeElementProvider(ILazyListElementProvider p) {
- elementProviders.remove(p);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor#removeInsertDeleteProvider(org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertDeleteProvider)
- */
- public void removeInsertDeleteProvider(LazyInsertDeleteProvider p) {
- insertDeleteProviders.remove(p);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor#setSize(int)
- */
- public void setSize(int size) {
- this.size = size;
- refresh();
- }
-
- private void refresh() {
- windowData = new ArrayList();
- for (int i = topRow; i <= windowSize - 1; ++i) {
- windowData.add(fireElementProviders(i));
- }
- }
-
- private Object fireElementProviders(int index) {
- for (Iterator epIter = elementProviders.iterator(); epIter.hasNext();) {
- ILazyListElementProvider p = (ILazyListElementProvider) epIter.next();
- Object result = p.get(index);
- if (result != null) {
- return result;
- }
- }
- throw new IndexOutOfBoundsException("Request for a nonexistent element");
- }
-
- private NewObject fireInsert(Object initializationData) {
- for (Iterator iter = insertDeleteProviders.iterator(); iter.hasNext();) {
- LazyInsertDeleteProvider p = (LazyInsertDeleteProvider) iter.next();
- NewObject result = p.insertElementAt(new LazyInsertEvent(0, initializationData));
- if (result != null) {
- return result;
- }
- }
- return null;
- }
-
- private boolean fireDelete(int position) {
- for (Iterator iter = insertDeleteProviders.iterator(); iter.hasNext();) {
- LazyInsertDeleteProvider p = (LazyInsertDeleteProvider) iter.next();
- boolean result = p.canDeleteElementAt(new LazyDeleteEvent(position));
- if (result) {
- p.deleteElementAt(new LazyDeleteEvent(position));
- return true;
- }
- }
- return false;
- }
-
- public void requestInsert(Object initializationData) {
- NewObject result = fireInsert(initializationData);
- if (result.position < windowSize) {
- refresh();
- }
- }
-
- public void requestDelete(int position) {
- if (fireDelete(position) && position < windowSize) {
- refresh();
- }
- }
-
- /**
- * @return Returns the windowData.
- */
- public List getWindowData() {
- return windowData;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.IObservable#isStale()
- */
- public boolean isStale() {
- return false;
- }
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/LazyListBindingTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/LazyListBindingTest.java
deleted file mode 100644
index 83391fa1..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/LazyListBindingTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * 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.databinding;
-
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.databinding.observable.list.WritableList;
-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.factories.DefaultBindingFactory;
-import org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyDeleteEvent;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertDeleteProvider;
-import org.eclipse.jface.internal.databinding.provisional.observable.LazyInsertEvent;
-import org.eclipse.jface.internal.databinding.provisional.observable.ILazyDataRequestor.NewObject;
-
-/**
- * @since 3.2
- *
- */
-public class LazyListBindingTest extends TestCase {
-
- /*
- * Concerns:
- *
- * 1) When the ILazyDataRequestor requests rows, the binding correctly
- * delegates to the ILazyDataProvider and returns the requested
- * rows.
- *
- * 2) When an insert or delete request occurs from the ILazyDataRequestor,
- * the binding correctly delegates to its insert/delete handler and
- * does whatever is necessary to avoid CoModificationException after
- * performing the insert or delete.
- *
- * 3) When the ILazyDataProvider (normally an IObservableList implementation)
- * sends a change event, the delta is properly processed and the correct
- * rows are added or removed to/from the ILazyDataRequestor.
- */
-
- private WritableList model;
- private LazyDataRequestor target;
- private Binding binding;
-
- private DataBindingContext getDBC() {
- DataBindingContext dbc = new DataBindingContext();
- dbc.addBindingFactory(new DefaultBindingFactory());
- return dbc;
- }
-
- private void compareList(List windowData, String[] strings) {
- int i = 0;
- for (Iterator iter = windowData.iterator(); iter.hasNext();) {
- String element = (String) iter.next();
- assertTrue("Element not equal: " + element + " <equals> " + strings[i], element.equals(strings[i]));
- ++i;
- }
- }
-
- private LazyInsertDeleteProvider insertDeleteProvider = new LazyInsertDeleteProvider() {
- private static final String TWO = "Two";
-
- public NewObject insertElementAt(LazyInsertEvent e) {
- model.add(1, TWO);
- return new ILazyDataRequestor.NewObject(1, TWO);
- }
-
- public boolean canDeleteElementAt(LazyDeleteEvent e) {
- return true;
- }
-
- public void deleteElementAt(LazyDeleteEvent e) {
- model.remove(e.position);
- }
- };
-
- protected void setUp() throws Exception {
- model = new WritableList(String.class);
- model.add("Un");
- model.add("Deux");
- model.add("Trois");
- model.add("Quatre");
- model.add("Cinq");
- target = new LazyDataRequestor(3);
-
- DataBindingContext dbc = getDBC();
-
- binding = dbc.bind(target, model, new BindSpec().setLazyInsertDeleteProvider(insertDeleteProvider));
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- binding.dispose();
- }
-
- public void testSetSize_ElementProviderHasTheRightStuff() throws Exception {
- compareList(target.getWindowData(), new String[] {"Un", "Deux", "Trois"});
- }
-
- public void testInsertAndDeleteFromTarget() throws Exception {
- target.requestInsert(null);
- compareList(target.getWindowData(), new String[] {"Un", "Two", "Deux"});
- compareList(model, new String[] {"Un", "Two", "Deux", "Trois", "Quatre", "Cinq"});
- target.requestDelete(1);
- compareList(target.getWindowData(), new String[] {"Un", "Deux", "Trois"});
- compareList(model, new String[] {"Un", "Deux", "Trois", "Quatre", "Cinq"});
- target.requestDelete(1);
- compareList(target.getWindowData(), new String[] {"Un", "Trois", "Quatre"});
- compareList(model, new String[] {"Un", "Trois", "Quatre", "Cinq"});
- }
-
- public void testInsertAndDeleteFromModel() throws Exception {
- model.add(1, "Two");
- compareList(target.getWindowData(), new String[] {"Un", "Two", "Deux"});
- compareList(model, new String[] {"Un", "Two", "Deux", "Trois", "Quatre", "Cinq"});
- model.remove(1);
- compareList(target.getWindowData(), new String[] {"Un", "Deux", "Trois"});
- compareList(model, new String[] {"Un", "Deux", "Trois", "Quatre", "Cinq"});
- model.remove(1);
- compareList(target.getWindowData(), new String[] {"Un", "Trois", "Quatre"});
- compareList(model, new String[] {"Un", "Trois", "Quatre", "Cinq"});
- }
-}
-
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/ObservableTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/ObservableTest.java
deleted file mode 100644
index ee73dde9..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/ObservableTest.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.databinding.observable.Diffs;
-import org.eclipse.jface.databinding.observable.IChangeListener;
-import org.eclipse.jface.databinding.observable.value.WritableValue;
-import org.eclipse.jface.tests.databinding.util.Mocks;
-
-public class ObservableTest extends TestCase {
-
- private static class MyObservable extends WritableValue {
- /**
- * @param initialValue
- */
- public MyObservable(Object initialValue) {
- super(initialValue);
- }
-
- public void fireChange(Object oldValue, Object newValue) {
- fireValueChange(Diffs.createValueDiff(oldValue, newValue));
- }
-
- }
-
- private MyObservable observable;
-
- protected void setUp() throws Exception {
- super.setUp();
- observable = new MyObservable(null);
- }
-
- protected void tearDown() throws Exception {
- if (observable != null) {
- try {
- observable.dispose();
- } catch (Exception ex) {
- // ignore
- }
- }
- observable = null;
- super.tearDown();
- }
-
- /*
- * Test method for
- * 'org.eclipse.jface.databinding.Observable.addChangeListener(IChangeListener)'
- */
- public void testAddChangeListener() {
- IChangeListener changeListenerMock = (IChangeListener) Mocks
- .createOrderedMock(IChangeListener.class);
-
- // testing that no methods on the observable are called when adding the
- // change listener
- Mocks.startChecking(changeListenerMock);
- observable.addChangeListener(changeListenerMock);
-
- // testing that handleChange is actually called
- Mocks.reset(changeListenerMock);
- changeListenerMock.handleChange(null);
- changeListenerMock.handleChange(null);
- Mocks.startChecking(changeListenerMock);
- observable.fireChange(null, null);
- observable.fireChange(null, null);
- Mocks.verify(changeListenerMock);
-
- // testing that handleChange is called just once
- Mocks.reset(changeListenerMock);
- changeListenerMock.handleChange(null);
- Mocks.startChecking(changeListenerMock);
- observable.fireChange(null, null);
- Mocks.verify(changeListenerMock);
-
- // dispose() will call another handleChange. Prevent this from causing a
- // test failure
- Mocks.reset(changeListenerMock);
- changeListenerMock.handleChange(null);
- Mocks.startChecking(changeListenerMock);
- }
-
- /*
- * Test method for
- * 'org.eclipse.jface.databinding.Observable.removeChangeListener(IChangeListener)'
- */
- public void testRemoveChangeListener() {
- IChangeListener changeListenerMock = (IChangeListener) Mocks
- .createOrderedMock(IChangeListener.class);
-
- // testing that no methods on the observable are called when removing
- // the
- // change listener
- Mocks.startChecking(changeListenerMock);
- observable.removeChangeListener(changeListenerMock);
-
- // testing that no methods on the observable are called after adding and
- // removing the change listener
- observable.addChangeListener(changeListenerMock);
- observable.removeChangeListener(changeListenerMock);
-
- observable.fireChange(null, null);
- }
-
- /*
- * Test method for
- * 'org.eclipse.jface.databinding.Observable.fireChangeEvent(int, Object,
- * Object)'
- */
- public void testFireChangeEvent() {
- // IChangeListener changeListenerMock = (IChangeListener) Mocks
- // .createMock(IChangeListener.class,
- // new Mocks.EqualityComparator() {
- // public boolean equals(Object o1, Object o2) {
- // ChangeEvent changeEvent1 = (ChangeEvent) o1;
- // ChangeEvent changeEvent2 = (ChangeEvent) o2;
- // return changeEvent1.getChangeType() == changeEvent2
- // .getChangeType()
- // && changeEvent1.getPosition() == changeEvent2
- // .getPosition()
- // && changeEvent1.getOldValue() == changeEvent2
- // .getOldValue()
- // && changeEvent1.getNewValue() == changeEvent2
- // .getNewValue();
- // }
- // });
- // observable.addChangeListener(changeListenerMock);
- //
- // Object o1 = new Object();
- // Object o2 = new Object();
- //
- // changeListenerMock.handleChange(new ChangeEvent(observable, 0, null,
- // null, ChangeEvent.POSITION_UNKNOWN));
- // changeListenerMock.handleChange(new ChangeEvent(observable, 0, null,
- // null, 1));
- // changeListenerMock.handleChange(new ChangeEvent(observable,
- // ChangeEvent.CHANGE, o1, o2, ChangeEvent.POSITION_UNKNOWN));
- // changeListenerMock.handleChange(new ChangeEvent(observable,
- // ChangeEvent.CHANGE, o1, o2, 42));
- // Mocks.startChecking(changeListenerMock);
- // observable.fireChange(0, null, null);
- // observable.fireChange(0, null, null, 1);
- // observable.fireChange(ChangeEvent.CHANGE, o1, o2);
- // observable.fireChange(ChangeEvent.CHANGE, o1, o2, 42);
- // Mocks.verify(changeListenerMock);
- //
- // // dispose() will call another handleChange. Prevent this from
- // causing a test failure
- // Mocks.reset(changeListenerMock);
- // changeListenerMock.handleChange(null);
- // Mocks.startChecking(changeListenerMock);
- }
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/RandomAccessListIteratorTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/RandomAccessListIteratorTest.java
deleted file mode 100644
index 4fecfe24..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/RandomAccessListIteratorTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package org.eclipse.jface.tests.databinding;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.jface.internal.databinding.internal.RandomAccessListIterator;
-
-import junit.framework.TestCase;
-
-public class RandomAccessListIteratorTest extends TestCase {
-
- private List emptyList = new LinkedList();
- private RandomAccessListIterator rali0 = new RandomAccessListIterator(emptyList);
- private List listWithOne;
- private RandomAccessListIterator rali1;
- private List list;
- private RandomAccessListIterator raliN;
-
- protected void setUp() throws Exception {
- listWithOne = new LinkedList();
- listWithOne.add("Uno");
- rali1 = new RandomAccessListIterator(listWithOne);
- list = new LinkedList();
- list.add("One");
- list.add("Two");
- list.add("three");
- list.add("four");
- raliN = new RandomAccessListIterator(list);
- }
-
- public void testGet_emptyList() {
- try {
- rali0.get(0);
- fail("Should have thrown exception");
- } catch (IndexOutOfBoundsException e) {
- // success
- }
- }
-
- public void testGet_withOne() {
- try {
- assertEquals("Uno", "Uno", rali1.get(0));
-
- rali1.get(1);
- fail("Should have thrown IndexOutOfBoundsException");
- } catch (Exception e) {
- // success
- }
- }
-
- public void testGet_alreadyAtItem() {
- assertEquals("one", "One", raliN.get(0));
- }
-
- public void testGet_moveForward() throws Exception {
- assertEquals("three", "three", raliN.get(2));
- }
-
- public void testGet_moveBackward() throws Exception {
- raliN.next();
- raliN.next();
- assertEquals("one", "One", raliN.get(0));
- }
-
- public void testGet_getLast() throws Exception {
- assertEquals("four", "four", raliN.get(3));
- }
-
- public void testGet_indexTooHigh() throws Exception {
- try {
- raliN.get(4);
- fail("Should have thrown exception");
- } catch (IndexOutOfBoundsException e) {
- // success
- }
- }
-
- public void testGet_indexTooLow() throws Exception {
- try {
- raliN.get(-100);
- fail("Should have thrown exception");
- } catch (IndexOutOfBoundsException e) {
- // success
- }
- }
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/SelectionAwareObservableCollectionTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/SelectionAwareObservableCollectionTest.java
deleted file mode 100644
index a6b8247a..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/SelectionAwareObservableCollectionTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding;
-
-import junit.framework.TestCase;
-
-public class SelectionAwareObservableCollectionTest extends TestCase {
-
- /*
- * FIXME: Rewrite to the new java.util.List API
- */
- public void testGetElementsAndSetElements() {
-// TestSelectionObservableCollection collection = new TestSelectionObservableCollection();
-// String string1 = "string1";
-// String string2 = "string2";
-// String string3 = "string3";
-// String string4 = "string4";
-// String string5 = "string5";
-//
-// collection.addElement(string1, 0);
-// collection.addElement(string2, 1);
-// collection.setSelectedObject(string1);
-//
-// List elementsToUpdate = new ArrayList();
-// elementsToUpdate.add(string3);
-// elementsToUpdate.add(string4);
-// elementsToUpdate.add(string5);
-//
-// collection.setElements(elementsToUpdate);
-//
-// assertEquals("The collection was not updated to the right size.", 3, collection.getSize());
-// assertEquals("The wrong element was found in position 0", string3, collection.getElement(0));
-// assertEquals("The wrong element was found in position 1", string4, collection.getElement(1));
-// assertEquals("The wrong element was found in position 2", string5, collection.getElement(2));
-// assertNull("The selected object was not reset as expected", collection.getSelectedObject());
-//
-// assertNotSame("The all elements list instance should not be the one provided in the set.", elementsToUpdate, collection.getElements());
-//
-// List returnedList = collection.getElements();
-// assertEquals("The wrong element was found in position 0 of the returned list", string3, returnedList.get(0));
-// assertEquals("The wrong element was found in position 1 of the returned list", string4, returnedList.get(1));
-// assertEquals("The wrong element was found in position 2 of the returned list", string5, returnedList.get(2));
-//
-// collection.setSelectedObject(string3);
-//
-// elementsToUpdate = new ArrayList();
-// elementsToUpdate.add(string1);
-// elementsToUpdate.add(string2);
-// elementsToUpdate.add(string3);
-//
-// collection.setElements(elementsToUpdate);
-//
-// assertSame("The selected element was not retained.", string3, collection.getSelectedObject());
- }
-
-// private class TestSelectionObservableCollection extends SelectionAwareObservableCollection {
-// private List elements = new ArrayList();
-// private Object selected;
-//
-// public int addElement(Object value, int index) {
-// elements.add(index, value);
-// return index;
-// }
-//
-// public Object computeElement(int index) {
-// return elements.get(index);
-// }
-//
-// public Class getElementType() {
-// return Object.class;
-// }
-//
-// public int computeSize() {
-// return elements.size();
-// }
-//
-// public void removeElement(int index) {
-// elements.remove(index);
-// }
-//
-// public void setElement(int index, Object value) {
-// elements.set(index, value);
-// }
-//
-// public Object getSelectedObject() {
-// return selected;
-// }
-//
-// public void setSelectedObject(Object object) {
-// this.selected = object;
-// }
-//
-//
-// }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/mask/EditMaskLexerAndTokenTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/mask/EditMaskLexerAndTokenTest.java
deleted file mode 100644
index af12f2b4..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/mask/EditMaskLexerAndTokenTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.eclipse.jface.tests.databinding.mask;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.examples.databinding.mask.internal.EditMaskLexerAndToken;
-
-public class EditMaskLexerAndTokenTest extends TestCase {
-
- private EditMaskLexerAndToken token;
-
- protected void setUp() throws Exception {
- token = new EditMaskLexerAndToken();
- }
-
- public void testInitWithNumeric() throws Exception {
- token.initializeEditMask("#", 0);
- assertTrue("Should accept a digit", token.accept("0"));
- token.clear();
- assertTrue("Should accept a digit", token.accept("1"));
- token.clear();
- assertTrue("Should accept a digit", token.accept("2"));
- token.clear();
- assertTrue("Should accept a digit", token.accept("3"));
- token.clear();
- assertTrue("Should accept a digit", token.accept("4"));
- token.clear();
- assertTrue("Should accept a digit", token.accept("5"));
- token.clear();
- assertTrue("Should accept a digit", token.accept("6"));
- token.clear();
- assertTrue("Should accept a digit", token.accept("7"));
- token.clear();
- assertTrue("Should accept a digit", token.accept("8"));
- token.clear();
- assertTrue("Should accept a digit", token.accept("9"));
- token.clear();
- assertFalse("Should not accept an alpha", token.accept("A"));
- token.clear();
- assertFalse("Should not accept an alpha", token.accept("z"));
- assertFalse("Placeholders are not read-only", token.isReadOnly());
- }
-
- public void testInitWithLiteral() throws Exception {
- token.initializeEditMask("(", 0);
- assertEquals("Literals automatically set their input", "(", token.getInput());
- assertFalse("Literals don't accept anything", token.accept("("));
- assertTrue("literals are read-only", token.isReadOnly());
- assertTrue("Literals are complete", token.isComplete());
- assertFalse("Literals cannot accept characters", token.canAcceptMoreCharacters());
- }
-
- public void testInitWithBackslashLiteral() throws Exception {
- token.initializeEditMask("\\#", 0);
- assertEquals("Should get backslash literal", "#", token.getInput());
- }
-
- public void testAcceptWithValidInputAndEmpty() throws Exception {
- token.initializeEditMask("#", 0);
- assertTrue("Should accept a 0", token.accept("0"));
- }
-
- public void testAcceptWhenParserCannotAcceptMoreCharacters() throws Exception {
- token.initializeEditMask("#", 0);
- assertTrue("Should accept a 0", token.accept("0"));
- assertFalse("Should not accept a 0 -- input full", token.accept("0"));
- }
-
- public void testGetInput() throws Exception {
- token.initializeEditMask("#", 0);
- assertTrue("Should accept a #", token.accept("0"));
- assertEquals(token.getInput(), "0");
- }
-
- public void testClear_withNonLiteral() throws Exception {
- token.initializeEditMask("#", 0);
- assertTrue("Should accept a 0", token.accept("0"));
- assertNotNull("Input should not be null", token.getInput());
- token.clear();
- assertNull("Input should be null after clear", token.getInput());
- }
-
- public void testClear_withLiteral() throws Exception {
- token.initializeEditMask("(", 0);
- assertNotNull("Input should not be null", token.getInput());
- token.clear();
- assertNotNull("Input should still not be null after clear of read-only literal", token.getInput());
- }
-
- public void testIsComplete_withNonLiteral() throws Exception {
- token.initializeEditMask("#", 0);
- assertFalse("should not be complete", token.isComplete());
- token.accept("1");
- assertTrue("should be complete", token.isComplete());
- token.clear();
- assertFalse("should not be complete", token.isComplete());
- }
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/mask/EditMaskParserTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/mask/EditMaskParserTest.java
deleted file mode 100644
index 3382a235..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/mask/EditMaskParserTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * 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.databinding.mask;
-
-import org.eclipse.jface.examples.databinding.mask.EditMaskParseException;
-import org.eclipse.jface.examples.databinding.mask.internal.EditMaskParser;
-
-import junit.framework.TestCase;
-
-/**
- * @since 3.2
- *
- */
-public class EditMaskParserTest extends TestCase {
-
- private EditMaskParser parser;
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- parser = new EditMaskParser("(###) ###-####");
- }
-
- /**
- * Test method for {@link org.eclipse.jface.examples.databinding.mask.internal.EditMaskParser#EditMaskParser(java.lang.String)}.
- */
- public void testEditMaskParser_validMask() {
- new EditMaskParser("(###) ###-####");
- }
-
- /**
- * Test method for {@link org.eclipse.jface.examples.databinding.mask.internal.EditMaskParser#EditMaskParser(java.lang.String)}.
- */
- public void testEditMaskParser_invalidMask() {
- try {
- new EditMaskParser("(###) ###-####\\");
- fail("Should have thrown exception");
- } catch (EditMaskParseException e) {
- // success
- }
- }
-
- /**
- * Test method for {@link org.eclipse.jface.examples.databinding.mask.internal.EditMaskParser#setInput(java.lang.String)}.
- */
- public void testSetInput() {
- parser.setInput("63a0) 5*55-1\\212abc9");
- assertEquals("Unformatted input", "6305551212", parser.getRawResult());
- assertEquals("Formatted input", "(630) 555-1212", parser.getFormattedResult());
- }
-
- /**
- * Test method for {@link org.eclipse.jface.examples.databinding.mask.internal.EditMaskParser#setInput(java.lang.String)}.
- */
- public void testSetInput_incomplete() {
- parser.setInput("6a0) 5*5-1\\12");
- assertEquals("Unformatted input", "6055112", parser.getRawResult());
- assertEquals("Formatted input", "(605) 511-2 ", parser.getFormattedResult());
- }
-
- /**
- * Test method for {@link org.eclipse.jface.examples.databinding.mask.internal.EditMaskParser#isComplete()}.
- */
- public void testIsComplete() {
- parser.setInput("63a0) 5*55-1\\212");
- assertTrue("complete", parser.isComplete());
- parser.setInput("6a0) 5*5-1\\12");
- assertFalse("incomplete", parser.isComplete());
- }
-
- public void testSetPlaceholder() throws Exception {
- parser.setInput("6a0) 5*5-1\\12");
- assertEquals("Formatted input", "(605) 511-2 ", parser.getFormattedResult());
- parser.setPlaceholder('_');
- assertEquals("Formatted input", "(605) 511-2___", parser.getFormattedResult());
- }
-
- /**
- * Test method for {@link org.eclipse.jface.examples.databinding.mask.internal.EditMaskParser#getNextInputPosition(int)}.
- */
- public void testGetNextInputPosition() {
- assertEquals("Skip leading (", 1, parser.getNextInputPosition(0));
- assertEquals("Position 1 is good", 1, parser.getNextInputPosition(1));
- assertEquals("Skip )<space>", 6, parser.getNextInputPosition(4));
- }
-
- public void testGetFirstIncompleteInputPosition() throws Exception {
- assertEquals("1st position incomplete", 1, parser.getFirstIncompleteInputPosition());
- parser.setInput("6a0) 5*5-1\\12");
- assertEquals("11th position incomplete", 11, parser.getFirstIncompleteInputPosition());
- parser.setInput("63a0) 5*55-1\\212");
- assertEquals("all complete", -1, parser.getFirstIncompleteInputPosition());
- }
-}
-
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/observable/value/WritableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/observable/value/WritableValueTest.java
deleted file mode 100644
index 220bd0a4..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/observable/value/WritableValueTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Brad Reynolds
- * 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:
- * Brad Reynolds - bug 158687
- ******************************************************************************/
-
-package org.eclipse.jface.tests.databinding.observable.value;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.databinding.observable.value.IValueChangeListener;
-import org.eclipse.jface.databinding.observable.value.ValueDiff;
-import org.eclipse.jface.databinding.observable.value.WritableValue;
-
-/**
- * @since 3.2
- */
-public class WritableValueTest extends TestCase {
- /**
- * Asserts that ValueChange events are only fired when the value changes.
- *
- * @throws Exception
- */
- public void testValueChangeOnlyFiresOnChange() throws Exception {
- WritableValue writableValue = new WritableValue(null);
- ValueChangeCounter counter = new ValueChangeCounter();
- writableValue.addValueChangeListener(counter);
-
- assertEquals(0, counter.count);
- //set same
- writableValue.setValue(null);
- assertEquals(0, counter.count);
-
- //set different
- writableValue.setValue("value");
- assertEquals(1, counter.count);
-
- //set same
- writableValue.setValue("value");
- assertEquals(1, counter.count);
-
- //set different
- writableValue.setValue(null);
- assertEquals(2, counter.count);
- }
-
- private static class ValueChangeCounter implements IValueChangeListener {
- int count;
-
- public void handleValueChange(IObservableValue source, ValueDiff diff) {
- count++;
- }
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/AutomationUtil.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/AutomationUtil.java
deleted file mode 100644
index 9e881ae6..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/AutomationUtil.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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.databinding.scenarios;
-
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-
-/**
- * COPIED FROM org.eclipse.ui.tests
- * <code>AutomationUtil</code> contains utility methods to mimic key events.
- * Mouse event methods can be added if needed to complete this class.
- */
-
-public class AutomationUtil {
-
- /**
- * Method to mimic a key code event on a display.
- *
- * @param display
- * The display.
- * @param eventType
- * The event type.
- * @param keyCode
- * The key code.
- */
- public static void performKeyCodeEvent(Display display, int eventType,
- int keyCode) {
- Event event = new Event();
- event.type = eventType;
- event.keyCode = keyCode;
- display.post(event);
- }
-
- /**
- * Method to mimic a character event on a display.
- *
- * @param display
- * The display.
- * @param eventType
- * The event type.
- * @param character
- * The character to mimic.
- */
- public static void performCharacterEvent(Display display, int eventType,
- char character) {
- Event event = new Event();
- event.type = eventType;
- event.character = character;
- display.post(event);
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/BindingScenariosTestSuite.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/BindingScenariosTestSuite.java
deleted file mode 100644
index 4650895f..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/BindingScenariosTestSuite.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.scenarios;
-
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.jface.tests.databinding.BindingTestSuite;
-import org.eclipse.jface.tests.databinding.swt.AutoSelectTableViewerCollectionExtendedTest;
-import org.eclipse.jface.tests.databinding.swt.AutoSelectTableViewerCollectionTest;
-import org.eclipse.jface.tests.databinding.swt.CComboObservableCollectionTest;
-import org.eclipse.jface.tests.databinding.swt.ComboObservableCollectionTest;
-import org.eclipse.jface.tests.databinding.swt.ListObservableCollectionTest;
-import org.eclipse.jface.tests.databinding.swt.ObservableCollectionViewerTest;
-import org.eclipse.jface.tests.databinding.swt.TableViewerObservableCollectionTest;
-import org.eclipse.jface.tests.databinding.swt.TextObservableValueTests;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * To run this test suite, right-click and select "Run As JUnit Plug-in Test".
- * This will also start an Eclipse instance. To clean up the launch
- * configuration, open up its "Main" tab and select "[No Application] - Headless
- * Mode" as the application to run. You can also run this class as an SWT
- * application.
- */
-public class BindingScenariosTestSuite extends TestSuite {
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- private static Display display;
-
- private static Shell shell;
-
- public static Test suite() {
- return new TestSetup(new BindingScenariosTestSuite()) {
- protected void setUp() throws Exception {
- Display d = Display.getDefault();
- if (d == null) {
- display = new Display();
- d = display;
- }
- shell = new Shell(d, SWT.SHELL_TRIM);
- shell.setLayout(new FillLayout());
- }
-
- protected void tearDown() throws Exception {
- shell.close();
- shell.dispose();
- if (display != null) {
- display.dispose();
- }
- }
- };
- }
-
- public BindingScenariosTestSuite() {
- addTestSuite(ObservableFactoriesTest.class);
- addTestSuite(PropertyScenarios.class);
- addTestSuite(CustomScenarios.class);
- addTestSuite(CustomConverterScenarios.class);
- addTestSuite(MasterDetailScenarios.class);
- addTestSuite(ComboScenarios.class);
- addTestSuite(TableScenarios.class);
- addTestSuite(NewTableScenarios.class);
- addTestSuite(NPETestScenario.class);
-
- // Test each of the basic SWT controls
- addTestSuite(TextControlScenario.class);
- addTestSuite(SpinnerControlScenario.class);
- addTestSuite(ButtonControlScenario.class);
- // Test each of the basic JFace controls
- addTestSuite(ComboViewerScenario.class);
- addTestSuite(ComboUpdatingTest.class);
- addTestSuite(ListViewerScenario.class);
- addTestSuite(TextObservableValueTests.class);
- if (BindingTestSuite.failingTestsDisabled(this))
- return;
- addTestSuite(CComboObservableCollectionTest.class);
- addTestSuite(ComboObservableCollectionTest.class);
- addTestSuite(TableViewerObservableCollectionTest.class);
- addTestSuite(ListObservableCollectionTest.class);
- addTestSuite(ObservableCollectionViewerTest.class);
- addTestSuite(AutoSelectTableViewerCollectionTest.class);
- addTestSuite(AutoSelectTableViewerCollectionExtendedTest.class);
- }
-
- public static Shell getShell() {
- return shell;
- }
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ButtonControlScenario.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ButtonControlScenario.java
deleted file mode 100644
index b6732623..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ButtonControlScenario.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.scenarios;
-
-import org.eclipse.jface.examples.databinding.model.Adventure;
-import org.eclipse.jface.examples.databinding.model.SampleData;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Button;
-
-/**
- * To run the tests in this class, right-click and select "Run As JUnit Plug-in
- * Test". This will also start an Eclipse instance. To clean up the launch
- * configuration, open up its "Main" tab and select "[No Application] - Headless
- * Mode" as the application to run.
- */
-
-public class ButtonControlScenario extends ScenariosTestCase {
-
- private Adventure adventure;
- private Button button;
-
- protected void setUp() throws Exception {
- super.setUp();
- // do any setup work here
- button = new Button(getComposite(), SWT.CHECK);
- adventure = SampleData.WINTER_HOLIDAY;
- }
-
- protected void tearDown() throws Exception {
- button.dispose();
- super.tearDown();
- }
-
- public void testScenario01() {
- // Bind the button's selection to the adventure "isPetsAllowed"
- getDbc().bind(button, new Property(adventure, "petsAllowed"),null);
- // Check the model and GUI are in the same state
- assertEquals(button.getSelection(),adventure.isPetsAllowed());
- // Change the model and check the GUI is updated
- boolean newBoolean = !adventure.isPetsAllowed();
- adventure.setPetsAllowed(newBoolean);
- assertEquals(newBoolean,adventure.isPetsAllowed());
- assertEquals(button.getSelection(),newBoolean);
- // Change the GUI and check the model
- newBoolean = !newBoolean;
- button.setSelection(newBoolean);
- button.notifyListeners(SWT.Selection,null);
- assertEquals(newBoolean,adventure.isPetsAllowed());
- newBoolean = !newBoolean;
- final boolean finalNewBoolean = newBoolean;
- adventure.setPetsAllowed(finalNewBoolean);
- spinEventLoop(0);
- assertEquals(newBoolean,button.getSelection());
-
- }
-
- public void testScenario02() {
- // Test with an SWT.Toggle button
- button.dispose();
- button = new Button(getComposite(), SWT.TOGGLE);
- // Bind the button's selection to the adventure "isPetsAllowed"
- getDbc().bind(button, new Property(adventure, "petsAllowed"),null);
- // Check the model and GUI are in the same state
- assertEquals(button.getSelection(),adventure.isPetsAllowed());
- // Change the model and check the GUI is updated
- boolean newBoolean = !adventure.isPetsAllowed();
- adventure.setPetsAllowed(newBoolean);
- assertEquals(newBoolean,adventure.isPetsAllowed());
- assertEquals(button.getSelection(),newBoolean);
- // Change the GUI and check the model
- newBoolean = !newBoolean;
- button.setSelection(newBoolean);
- button.notifyListeners(SWT.Selection,null);
- assertEquals(newBoolean,adventure.isPetsAllowed());
- }
-
- public void testScenario03() {
- // Test with an SWT.Radio button
- button.dispose();
- button = new Button(getComposite(), SWT.RADIO);
- // Bind the button's selection to the adventure "isPetsAllowed"
- getDbc().bind(button, new Property(adventure, "petsAllowed"),null);
- // Check the model and GUI are in the same state
- assertEquals(button.getSelection(),adventure.isPetsAllowed());
- // Change the model and check the GUI is updated
- boolean newBoolean = !adventure.isPetsAllowed();
- adventure.setPetsAllowed(newBoolean);
- assertEquals(newBoolean,adventure.isPetsAllowed());
- assertEquals(button.getSelection(),newBoolean);
- // Change the GUI and check the model
- newBoolean = !newBoolean;
- button.setSelection(newBoolean);
- button.notifyListeners(SWT.Selection,null);
- assertEquals(newBoolean,adventure.isPetsAllowed());
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboScenarios.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboScenarios.java
deleted file mode 100644
index c9dcd3d6..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboScenarios.java
+++ /dev/null
@@ -1,528 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.scenarios;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Locale;
-
-import org.eclipse.jface.databinding.observable.list.IObservableList;
-import org.eclipse.jface.databinding.observable.list.WritableList;
-import org.eclipse.jface.examples.databinding.model.Account;
-import org.eclipse.jface.examples.databinding.model.Adventure;
-import org.eclipse.jface.examples.databinding.model.Catalog;
-import org.eclipse.jface.examples.databinding.model.Lodging;
-import org.eclipse.jface.examples.databinding.model.SampleData;
-import org.eclipse.jface.internal.databinding.provisional.description.ListModelDescription;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.swt.SWTProperties;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersProperties;
-import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Combo;
-
-public class ComboScenarios extends ScenariosTestCase {
-
- protected ComboViewer cviewer = null;
-
- protected Combo combo = null;
-
- protected Catalog catalog = null;
-
- ILabelProvider lodgingLabelProvider = new LabelProvider() {
- public String getText(Object element) {
- return ((Lodging) element).getName();
- }
- };
-
- ILabelProvider accountLabelProvider = new LabelProvider() {
- public String getText(Object element) {
- return ((Account) element).getCountry();
- }
- };
-
- protected void setUp() throws Exception {
- super.setUp();
- getComposite().setLayout(new FillLayout());
-
- combo = new Combo(getComposite(), SWT.READ_ONLY | SWT.DROP_DOWN);
- cviewer = new ComboViewer(combo);
-
- catalog = SampleData.CATALOG_2005; // Lodging source
- }
-
- protected void tearDown() throws Exception {
- combo.dispose();
- combo = null;
- cviewer = null;
- super.tearDown();
- }
-
- protected Object getViewerSelection() {
- return ((IStructuredSelection) cviewer.getSelection())
- .getFirstElement();
- }
-
- /**
- * @return the ComboViewer's domain object list
- */
- protected List getViewerContent(ComboViewer cviewer) {
- Object[] elements = ((IStructuredContentProvider) cviewer
- .getContentProvider()).getElements(null);
- if (elements != null)
- return Arrays.asList(elements);
- return null;
- }
-
- /**
- *
- * @return the combo's items (String[]), which is the same thing as the
- * Viewer's labels
- *
- */
- protected List getComboContent() {
- String[] elements = combo.getItems();
- if (elements != null)
- return Arrays.asList(elements);
- return null;
- }
-
- protected List getColumn(Object[] list, String feature) {
- List result = new ArrayList();
- if (list == null || list.length == 0)
- return result;
- String getterName = "get"
- + feature.substring(0, 1).toUpperCase(Locale.ENGLISH)
- + feature.substring(1);
- try {
- Method getter = list[0].getClass().getMethod(getterName,
- new Class[0]);
- try {
- for (int i = 0; i < list.length; i++) {
- result.add(getter.invoke(list[i], new Object[0]));
- }
- } catch (IllegalArgumentException e) {
- } catch (IllegalAccessException e) {
- } catch (InvocationTargetException e) {
- }
- } catch (SecurityException e) {
- } catch (NoSuchMethodException e) {
- }
- return result;
- }
-
- /**
- * This test case deal with the 3rd scenario, using vanilla bindings: Ensure
- * a valid content and selection are bounded correctly Bind a collection of
- * Lodgings to a ComboViewer Bind the ComboViewer's selection to the
- * defaultLodging of an Adventure
- *
- * This test does not deal with null values, empty content, changed content,
- * property change of content elements, etc.
- *
- */
- public void test_ROCombo_Scenario03_vanilla() {
- Adventure skiAdventure = SampleData.WINTER_HOLIDAY; // selection will
- // change its defaultLodging
-
- cviewer.setLabelProvider(lodgingLabelProvider);
- // Bind the ComboViewer's content to the available lodging
- getDbc().bind(
- cviewer,
- new ListModelDescription(new Property(catalog, "lodgings"),
- "name"), null);
-
- // Ensure that cv's content now has the catalog's lodgings
- assertArrayEquals(catalog.getLodgings(), getViewerContent(cviewer)
- .toArray());
-
- // Ensure that the cv's labels are the same as the lodging descriptions
- assertEquals(getColumn(catalog.getLodgings(), "name"),
- getComboContent());
-
- // Bind the ComboViewer's selection to the Adventure's default lodging.
- getDbc().bind(
- new Property(cviewer, ViewersProperties.SINGLE_SELECTION),
- new Property(skiAdventure, "defaultLodging"), null);
-
- // Check to see that the initial selection is the currentDefault Lodging
- assertEquals(getViewerSelection(), skiAdventure.getDefaultLodging());
-
- // Change the selection of the ComboViewer to all possible lodgings, and
- // verify that skiAdventure's default lodging was changed accordingly
- for (int i = 0; i < catalog.getLodgings().length; i++) {
- Object selection = catalog.getLodgings()[i];
- cviewer.setSelection(new StructuredSelection(selection));
- assertEquals(selection, skiAdventure.getDefaultLodging());
- assertEquals(getViewerSelection(), skiAdventure.getDefaultLodging());
- }
-
- }
-
- /**
- * This test case deal with the 3rd scenario, and focuses on the collection
- * binding to the combo. It will bind a collection, add/remove/change
- * elements in the collection, and change element's properties to ensure
- * that the combo's labels were updated appropriatly.
- *
- * it also induce null values in properties, and elments.
- *
- * This test does not deal with the combo's selection.
- */
- public void test_ROCombo_Scenario03_collectionBindings() {
-
- cviewer.setLabelProvider(lodgingLabelProvider); // TODO: need to resolve
- // column binding
- // Bind the ComboViewer's content to the available lodging
- getDbc().bind(
- cviewer,
- new ListModelDescription(new Property(catalog, "lodgings"),
- "name"), null);
-
- // Ensure that cv's content now has the catalog's lodgings
- assertArrayEquals(catalog.getLodgings(), getViewerContent(cviewer)
- .toArray());
-
- // Ensure that the cv's labels are the same as the lodging descriptions
- assertEquals(getColumn(catalog.getLodgings(), "name"),
- getComboContent());
-
- // Add a lodging in the middle (not supported by the model right now)
- // Lodging lodging = SampleData.FACTORY.createLodging();
- // lodging.setName("Middle Lodging");
- // catalog.addLodging(lodging);
- // assertEquals(getViewerContent(cviewer).get(2), lodging);
-
- // Add a lodging at the end
- Lodging lodging = SampleData.FACTORY.createLodging();
- lodging.setName("End Lodging");
- catalog.addLodging(lodging);
- int index = getComboContent().size() - 1;
- assertEquals(getViewerContent(cviewer).get(index), lodging);
-
- // Delete the first Lodging
- catalog.removeLodging(catalog.getLodgings()[0]);
- // Ensure that the cv's labels are the same as the lodging descriptions
- assertEquals(getColumn(catalog.getLodgings(), "name"),
- getComboContent());
-
- // Delete middle Lodging
- catalog.removeLodging(catalog.getLodgings()[2]);
- // Ensure that the cv's labels are the same as the lodging descriptions
- assertEquals(getColumn(catalog.getLodgings(), "name"),
- getComboContent());
-
- // Change the names of all Lodging
- for (int i = 0; i < catalog.getLodgings().length; i++) {
- Lodging l = catalog.getLodgings()[i];
- l.setName("Changed: " + l.getName());
- }
- spinEventLoop(0); // force Async. efforts
- assertEquals(getColumn(catalog.getLodgings(), "name"),
- getComboContent());
-
- // Set to null value
- Lodging l = catalog.getLodgings()[0];
- l.setName(null);
- assertEquals(combo.getItem(0), "");
-
- // set to empty list
- while (catalog.getLodgings().length > 0)
- catalog.removeLodging(catalog.getLodgings()[0]);
- assertEquals(getColumn(catalog.getLodgings(), "name"),
- getComboContent());
-
- }
-
- /**
- * This scenario tests a simple SWT combo with a set item list where the
- * selection is bouded to a String property
- */
-// public void test_ROCombo_Scenario01() {
-//
-// // Read-Only Combo will not change its text property on a call to
-// // setText()
-//
-// String[] items = new String[] { "FairyLand", "TuneLand", "NoWereLand",
-// "TinkerLand", "DreamLand" };
-// combo.setItems(items);
-// Account account = catalog.getAccounts()[0];
-//
-// // simple Combo's selection bound to the Account's country property
-// getDbc().bind(new Property(combo, SWTProperties.SELECTION),
-// new Property(account, "country"), null);
-//
-// // Drive the combo selection
-// int index = 3;
-// combo.setText(items[index]); // this should drive the selection
-// assertEquals(account.getCountry(), items[index]);
-//
-// // Set the country, and ensure selection is set property
-// index = 1;
-// account.setCountry(items[index]);
-// assertEquals(index, combo.getSelectionIndex());
-// assertEquals(combo.getText(), items[index]);
-//
-// index = combo.getSelectionIndex();
-// String txt = combo.getText();
-// // Set the country to something that is not in the Combo's list
-// account.setCountry("FooBar");
-// // Combo's selection will not Change
-// assertEquals(combo.getSelectionIndex(), index);
-// assertEquals(combo.getText(), txt);
-//
-// }
-
- /**
- * This scenario tests a simple SWT combo that is bound to a list of Country
- * objects. The Country object's name property is listed in the Combo.
- *
- * The Combo's selection is bounded to the Country property of an Account.
- */
-// public void test_ROCombo_Scenario02_SWTCombo() {
-//
-// // Create a list of Strings for the countries
-// IObservableList list = new WritableList();
-// for (int i = 0; i < catalog.getAccounts().length; i++)
-// list.add(catalog.getAccounts()[i].getCountry());
-//
-// // Bind the combo's content to that of the String based list
-// getDbc().bind(combo, list, null);
-// assertEquals(Arrays.asList(combo.getItems()), list);
-//
-// Account account = catalog.getAccounts()[0];
-//
-// // simple Combo's selection bound to the Account's country property
-// getDbc().bind(new Property(combo, SWTProperties.SELECTION),
-// new Property(account, "country"), null);
-//
-// // Drive the combo selection
-// String selection = (String) list.get(2);
-// combo.setText(selection); // this should drive the selection
-// assertEquals(account.getCountry(), selection);
-//
-// }
-
- /**
- * This scenario tests a simple SWT combo that is bound to a list of Country
- * objects. The Country object's name property is listed in the Combo.
- *
- * The Combo's selection is bounded to the Country property of an Account.
- */
-// public void test_ROCombo_Scenario02_ComboViewer() {
-//
-// // Account label provider will fill the combo with the country
-// cviewer.setLabelProvider(accountLabelProvider);
-// // Bind the ComboViewer's content to the available accounts
-// getDbc().bind(
-// cviewer,
-// new ListModelDescription(new Property(catalog, "accounts"),
-// "country"), null);
-//
-// // Ensure that cv's content now has the catalog's accounts
-// assertArrayEquals(catalog.getAccounts(), getViewerContent(cviewer)
-// .toArray());
-// // Ensure that the cv's labels are the same as the account countries
-// assertEquals(getColumn(catalog.getAccounts(), "country"),
-// getComboContent());
-//
-// Account account = SampleData.FACTORY.createAccount();
-//
-// // Use the Viewers visual Combo (Strings) to set the account's country
-// getDbc().bind(new Property(combo, SWTProperties.SELECTION),
-// new Property(account, "country"), null);
-//
-// // Change the selection of the ComboViewer to all possible accounts, and
-// // verify that the account's Country is being changed correctly.
-// for (int i = 0; i < catalog.getAccounts().length; i++) {
-// Account selection = catalog.getAccounts()[i];
-// cviewer.setSelection(new StructuredSelection(selection));
-// assertEquals(selection.getCountry(), account.getCountry());
-// }
-//
-// }
-
- /**
- * This test ensure that multiple combos can be bound to the same deomain
- * model
- */
- public void test_ROCombo_multipleBindings() {
-
- Adventure skiAdventure = SampleData.WINTER_HOLIDAY; // for selection
-
- cviewer.setLabelProvider(lodgingLabelProvider); // TODO: need to resolve
- // column binding
- // Bind the ComboViewer's content to the available lodging
- getDbc().bind(
- cviewer,
- new ListModelDescription(new Property(catalog, "lodgings"),
- "name"), null);
-
- // Ensure that cv's content now has the catalog's lodgings
- assertArrayEquals(catalog.getLodgings(), getViewerContent(cviewer)
- .toArray());
-
- // Ensure that the cv's labels are the same as the lodging descriptions
- assertEquals(getColumn(catalog.getLodgings(), "name"),
- getComboContent());
-
- ComboViewer otherViewer = new ComboViewer(getComposite(), SWT.NONE);
- otherViewer.setLabelProvider(lodgingLabelProvider);
- getDbc().bind(otherViewer, new ListModelDescription(new Property(catalog, "lodgings"),"name"), null);
- // Ensure that cv's content now has the catalog's lodgings
- assertArrayEquals(catalog.getLodgings(), getViewerContent(otherViewer)
- .toArray());
-
- // Bind both selections to the same thing
- getDbc().bind(
- new Property(cviewer, ViewersProperties.SINGLE_SELECTION),
- new Property(skiAdventure, "defaultLodging"), null);
- getDbc().bind(
- new Property(otherViewer, ViewersProperties.SINGLE_SELECTION),
- new Property(skiAdventure, "defaultLodging"), null);
-
- Lodging lodging = catalog.getLodgings()[0];
-
- // Ensure that setting the selection is driven forward to the other
- // combo
- cviewer.setSelection(new StructuredSelection(lodging));
- assertEquals(((IStructuredSelection) cviewer.getSelection())
- .getFirstElement(), ((IStructuredSelection) otherViewer
- .getSelection()).getFirstElement());
-
- // Change the list of one combo, and ensure it updates the other combo
- catalog.removeLodging(lodging);
- assertEquals(getViewerContent(cviewer), getViewerContent(otherViewer));
-
- }
-
- /**
- * This scenario tests a simple SWT CCombo that is bound to a list of
- * Country objects. The Country object's name property is listed in the
- * Combo.
- *
- * The Combo's selection is bounded to the Country property of an Account.
- */
- public void test_ROCombo_SWTCCombo() {
-
- // Create a list of Strings for the countries
- IObservableList list = new WritableList();
- for (int i = 0; i < catalog.getAccounts().length; i++)
- list.add(catalog.getAccounts()[i].getCountry());
-
- CCombo ccombo = new CCombo(getComposite(), SWT.READ_ONLY
- | SWT.DROP_DOWN);
-
- // Bind the combo's content to that of the String based list
- getDbc().bind(ccombo, list, null);
- assertEquals(Arrays.asList(ccombo.getItems()), list);
-
- Account account = catalog.getAccounts()[0];
-
- // simple Combo's selection bound to the Account's country property
- getDbc().bind(new Property(ccombo, SWTProperties.SELECTION),
- new Property(account, "country"), null);
-
- // Drive the combo selection
- String selection = (String) list.get(2);
- ccombo.setText(selection); // this should drive the selection
- assertEquals(account.getCountry(), selection);
-
- }
-
- /**
- * This scenario tests a simple SWT CCombo that is bound to a list of
- * Country objects. The Country object's name property is listed in the
- * Combo.
- *
- * The Combo's selection is bounded to the Country property of an Account.
- */
- public void test_WCombo_SWTCCombo() {
-
- // Create a list of Strings for the countries
- IObservableList list = new WritableList();
- for (int i = 0; i < catalog.getAccounts().length; i++)
- list.add(catalog.getAccounts()[i].getCountry());
-
- CCombo ccombo = new CCombo(getComposite(), SWT.READ_ONLY
- | SWT.DROP_DOWN);
-
- // Bind the combo's content to that of the String based list
- getDbc().bind(ccombo, list, null);
- assertEquals(Arrays.asList(ccombo.getItems()), list);
-
- Account account = catalog.getAccounts()[0];
-
- // simple Combo's selection bound to the Account's country property
- getDbc().bind(new Property(ccombo, SWTProperties.SELECTION),
- new Property(account, "country"), null);
-
- // Drive the combo selection
- String selection = (String) list.get(2);
- ccombo.setText(selection); // this should drive the selection
- assertEquals(account.getCountry(), selection);
-
- selection = (String) list.get(1);
- account.setCountry(selection);
- assertEquals(selection, ccombo.getItem(ccombo.getSelectionIndex()));
- assertEquals(selection, ccombo.getText());
-
- selection = "country not in list";
- account.setCountry(selection);
- assertEquals(-1, ccombo.getSelectionIndex());
- assertEquals(selection, ccombo.getText());
- }
-
- /**
- * This scenario tests a simple SWT CCombo that is bound to a list of
- * Country objects. The Country object's name property is listed in the
- * Combo.
- *
- * The Combo's selection is bounded to the Country property of an Account.
- */
- public void test_ROCombo_SWTList() {
-
- // Create a list of Strings for the countries
- IObservableList list = new WritableList();
- for (int i = 0; i < catalog.getAccounts().length; i++)
- list.add(catalog.getAccounts()[i].getCountry());
-
- org.eclipse.swt.widgets.List swtlist = new org.eclipse.swt.widgets.List(
- getComposite(), SWT.READ_ONLY | SWT.SINGLE);
-
- // Bind the combo's content to that of the String based list
- getDbc().bind(swtlist, list, null);
- assertEquals(Arrays.asList(swtlist.getItems()), list);
-
- Account account = catalog.getAccounts()[0];
-
- // simple Combo's selection bound to the Account's country property
- getDbc().bind(new Property(swtlist, SWTProperties.SELECTION),
- new Property(account, "country"), null);
-
- String selection = (String) list.get(2);
- swtlist.select(2); // this should drive the selection
- swtlist.notifyListeners(SWT.Selection, null); // Force notification
- assertEquals(account.getCountry(), selection);
-
- }
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboUpdatingTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboUpdatingTest.java
deleted file mode 100644
index 1999efb1..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboUpdatingTest.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * 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.databinding.scenarios;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.internal.databinding.internal.swt.ComboObservableValue;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.tests.databinding.BindingTestSuite;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Combo;
-
-/**
- * @since 3.2
- */
-public class ComboUpdatingTest extends ScenariosTestCase {
-
- private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(
- this);
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- propertyChangeSupport.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String propertyName,
- PropertyChangeListener listener) {
- propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- propertyChangeSupport.removePropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(String propertyName,
- PropertyChangeListener listener) {
- propertyChangeSupport.removePropertyChangeListener(propertyName,
- listener);
- }
-
- protected void firePropertyChange(String propertyName, Object oldValue,
- Object newValue) {
- propertyChangeSupport.firePropertyChange(propertyName, oldValue,
- newValue);
- }
-
-
- private Combo comboEditable;
- //private Combo comboReadOnly;
-
- private static final String PROP_TEXT = "text";
- private String text = "Hello, world";
-
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
- private static final String PROP_CHOICES = "choices";
- private List choices = new ArrayList();
- {
- choices.add("Banana");
- choices.add("Apple");
- choices.add("Mango");
- }
-
- public List getChoices() {
- return choices;
- }
-
- public void setChoices(List choices) {
- this.choices = choices;
- firePropertyChange(PROP_CHOICES, null, null);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- getComposite().setLayout(new FillLayout());
- comboEditable = new Combo(getComposite(), SWT.DROP_DOWN);
-// comboReadOnly = new Combo(getComposite(), SWT.DROP_DOWN | SWT.READ_ONLY);
- }
-
- //-------------------------------------------------------------------------
-
- private static final String NEXT = "Next";
- public void testBindText() throws Exception {
- getDbc().bind(new Property(comboEditable, PROP_TEXT), new Property(this, PROP_TEXT), null);
- spinEventLoop(0);
- assertEquals("Should find value of text", text, comboEditable.getText());
- comboEditable.setText(NEXT);
- spinEventLoop(0);
- assertEquals("Should find new value in text", NEXT, text);
- }
-
- public void testBindItems_listHasSameItems_editable() throws Exception {
- if (BindingTestSuite.failingTestsDisabled(this)) {
- return;
- }
- text = "Apple";
- ComboObservableValue value = (ComboObservableValue) getDbc().createObservable(new Property(comboEditable, PROP_TEXT));
- getDbc().bind(value, new Property(this, PROP_TEXT), null);
- spinEventLoop(0);
- assertEquals("Should find value of text", text, comboEditable.getText());
- getDbc().bind(value.getItems(), new Property(this, PROP_CHOICES), null);
-// getDbc().bind(combo, new Property(this, PROP_CHOICES, String.class, Boolean.TRUE), null);
- spinEventLoop(0);
- int position = 0;
- for (Iterator choicesIter = choices.iterator(); choicesIter.hasNext();) {
- String element = (String) choicesIter.next();
- assertEquals(element, comboEditable.getItem(position));
- ++position;
- }
-// assertEquals("Should find value of text", "Apple", text);
- assertEquals("Should find value of combo.getText()", "", comboEditable.getText());
- comboEditable.setText("Banana");
- spinEventLoop(0);
- assertEquals("Should find value of text", "Banana", text);
- }
-
-// public void testBindItems_listHasSameItems_readOnly() throws Exception {
-// text = "Apple";
-// ComboObservableValue value = (ComboObservableValue) getDbc().createObservable(new Property(comboReadOnly, PROP_TEXT));
-// getDbc().bind(value.getItems(), new Property(this, PROP_CHOICES), null);
-//// getDbc().bind(combo, new Property(this, PROP_CHOICES, String.class, Boolean.TRUE), null);
-// spinEventLoop(0);
-// assertEquals("Should find value of text", "Apple", text);
-// getDbc().bind(value, new Property(this, PROP_TEXT), null);
-// spinEventLoop(0);
-// assertEquals("Should find value of text", "Apple", text);
-// assertEquals("Should find value of combo.getText()", "Apple", comboReadOnly.getText());
-// int position = 0;
-// for (Iterator choicesIter = choices.iterator(); choicesIter.hasNext();) {
-// String element = (String) choicesIter.next();
-// assertEquals(element, comboReadOnly.getItem(position));
-// ++position;
-// }
-// assertEquals("Should find value of text", "Apple", text);
-// assertEquals("Should find value of combo.getText()", "Apple", comboReadOnly.getText());
-// comboReadOnly.setText("Banana");
-// spinEventLoop(0);
-// assertEquals("Should find value of text", "Banana", text);
-// }
-
- public void testBindItems_listHasDifferentItems_editable() throws Exception {
- if (BindingTestSuite.failingTestsDisabled(this)) {
- return;
- }
- ComboObservableValue value = (ComboObservableValue) getDbc().createObservable(new Property(comboEditable, PROP_TEXT));
- getDbc().bind(value, new Property(this, PROP_TEXT), null);
- spinEventLoop(0);
- assertEquals("Should find value of text", text, comboEditable.getText());
- getDbc().bind(value.getItems(), new Property(this, PROP_CHOICES), null);
-// getDbc().bind(combo, new Property(this, PROP_CHOICES, String.class, Boolean.TRUE), null);
- spinEventLoop(0);
- int position = 0;
- for (Iterator choicesIter = choices.iterator(); choicesIter.hasNext();) {
- String element = (String) choicesIter.next();
- assertEquals(element, comboEditable.getItem(position));
- ++position;
- }
-// assertEquals("Should find value of text", "Hello, world", text);
- assertEquals("Should find value of combo.getText()", "", comboEditable.getText());
- comboEditable.setText("Banana");
- spinEventLoop(0);
- assertEquals("Should find value of text", "Banana", text);
- }
-
-// public void testBindItems_listHasDifferentItems_readOnly() throws Exception {
-// ComboObservableValue value = (ComboObservableValue) getDbc().createObservable(new Property(comboReadOnly, PROP_TEXT));
-// getDbc().bind(value, new Property(this, PROP_TEXT), null);
-// spinEventLoop(0);
-// getDbc().bind(value.getItems(), new Property(this, PROP_CHOICES), null);
-//// getDbc().bind(combo, new Property(this, PROP_CHOICES, String.class, Boolean.TRUE), null);
-// spinEventLoop(0);
-// int position = 0;
-// for (Iterator choicesIter = choices.iterator(); choicesIter.hasNext();) {
-// String element = (String) choicesIter.next();
-// assertEquals(element, comboReadOnly.getItem(position));
-// ++position;
-// }
-//// assertEquals("Should find value of text", "Hello, world", text);
-// assertEquals("Should find value of combo.getText()", "", comboReadOnly.getText());
-// comboReadOnly.setText("Banana");
-// spinEventLoop(0);
-// assertEquals("Should find value of text", "Banana", text);
-// }
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboViewerScenario.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboViewerScenario.java
deleted file mode 100644
index 53f9d3c4..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboViewerScenario.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.scenarios;
-
-import org.eclipse.jface.examples.databinding.model.Adventure;
-import org.eclipse.jface.examples.databinding.model.Catalog;
-import org.eclipse.jface.examples.databinding.model.SampleData;
-import org.eclipse.jface.internal.databinding.provisional.description.ListModelDescription;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersProperties;
-import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Combo;
-
-/**
- * To run the tests in this class, right-click and select "Run As JUnit Plug-in
- * Test". This will also start an Eclipse instance. To clean up the launch
- * configuration, open up its "Main" tab and select "[No Application] - Headless
- * Mode" as the application to run.
- */
-
-public class ComboViewerScenario extends ScenariosTestCase {
-
- private Catalog catalog;
-
- private Combo combo;
-
- private ComboViewer comboViewer;
-
- protected void setUp() throws Exception {
- super.setUp();
- // do any setup work here
- combo = new Combo(getComposite(), SWT.READ_ONLY | SWT.DROP_DOWN);
- comboViewer = new ComboViewer(combo);
- catalog = SampleData.CATALOG_2005; // Lodging source
- }
-
- protected void tearDown() throws Exception {
- combo.dispose();
- combo = null;
- comboViewer = null;
- super.tearDown();
- }
-
- public void testScenario01() {
-
- // Bind the catalog's lodgings to the combo
- getDbc().bind(
- comboViewer,
- new ListModelDescription(new Property(catalog, "lodgings"),
- "name"), null);
- // Verify that the combo's items are the lodgings
- for (int i = 0; i < catalog.getLodgings().length; i++) {
- assertEquals(catalog.getLodgings()[i], comboViewer.getElementAt(i));
- }
- // Verify that the String being shown in the combo viewer is the
- // "toString" of the combo viewer
- String[] lodgingStrings = new String[catalog.getLodgings().length];
- for (int i = 0; i < catalog.getLodgings().length; i++) {
- lodgingStrings[i] = catalog.getLodgings()[i].getName();
- }
- assertArrayEquals(lodgingStrings, combo.getItems());
-
- // Verify that the combo has no selected item
- assertEquals(null, ((IStructuredSelection) comboViewer.getSelection())
- .getFirstElement());
-
- // Now bind the selection of the combo to the "defaultLodging" property
- // of an adventure
- final Adventure adventure = SampleData.WINTER_HOLIDAY;
- getDbc().bind(
- new Property(comboViewer, ViewersProperties.SINGLE_SELECTION),
- new Property(adventure, "defaultLodging"), null);
-
- // Verify that the combo selection is the default lodging
- assertEquals(((IStructuredSelection) comboViewer.getSelection())
- .getFirstElement(), adventure.getDefaultLodging());
-
- // Change the model and verify that the combo selection changes
- adventure.setDefaultLodging(SampleData.CAMP_GROUND);
- assertEquals(adventure.getDefaultLodging(), SampleData.CAMP_GROUND);
- assertEquals(((IStructuredSelection) comboViewer.getSelection())
- .getFirstElement(), adventure.getDefaultLodging());
-
- // Change the combo selection and verify that the model changes
- comboViewer.getCombo().select(3);
- assertEquals(((IStructuredSelection) comboViewer.getSelection())
- .getFirstElement(), adventure.getDefaultLodging());
-
- adventure.setDefaultLodging(SampleData.YOUTH_HOSTEL);
- spinEventLoop(0);
- assertEquals(((IStructuredSelection) comboViewer.getSelection())
- .getFirstElement(), adventure.getDefaultLodging());
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomBeanBindSupportFactory.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomBeanBindSupportFactory.java
deleted file mode 100644
index 30c2f51d..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomBeanBindSupportFactory.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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
- *******************************************************************************/
-// TODO djo: copyright
-package org.eclipse.jface.tests.databinding.scenarios;
-
-import java.lang.reflect.Method;
-
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.conversion.IConverter;
-import org.eclipse.jface.internal.databinding.provisional.factories.BindSupportFactory;
-import org.eclipse.jface.internal.databinding.provisional.validation.IDomainValidator;
-
-/**
- * A BindSupportFactory that will automatically grab validators from an object's
- * properties, if a get&lt;PropertyName>Validator method is defined. Makes it
- * easy to associate validators with the properties that they are responsible
- * for validating.
- *
- * <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.
- *
- * @since 3.2
- */
-public class CustomBeanBindSupportFactory extends BindSupportFactory {
-
- private final DataBindingContext parentContext;
-
- public CustomBeanBindSupportFactory(DataBindingContext parentContext) {
- this.parentContext = parentContext;
- }
-
- public IConverter createConverter(Object fromType, Object toType) {
- if (fromType instanceof CustomBeanModelType) {
- CustomBeanModelType customBeanModelType = (CustomBeanModelType) fromType;
- fromType = customBeanModelType.getType();
- }
- if (toType instanceof CustomBeanModelType) {
- CustomBeanModelType customBeanModelType = (CustomBeanModelType) toType;
- toType = customBeanModelType.getType();
- }
- return parentContext.createConverter(fromType, toType);
- }
-
- public IDomainValidator createDomainValidator(Object modelType) {
- if (modelType instanceof CustomBeanModelType) {
- CustomBeanModelType property = (CustomBeanModelType) modelType;
- String propertyName = property.getPropertyName();
- String getValidatorMethodName = "get" + upperCaseFirstLetter(propertyName) + "Validator"; //$NON-NLS-1$ //$NON-NLS-2$
-
- Class objectClass = property.getObject().getClass();
-
- Method getValidator;
- try {
- getValidator = objectClass.getMethod(getValidatorMethodName,
- new Class[] { Class.class });
- } catch (Exception e) {
- return null;
- }
-
- try {
- IDomainValidator result = (IDomainValidator) getValidator
- .invoke(property.getObject(), new Object[0]);
- return result;
- } catch (Exception e) {
- return null;
- }
- }
- return null;
- }
-
- private String upperCaseFirstLetter(String name) {
- String result = name.substring(0, 1).toUpperCase() + name.substring(1);
- return result;
- }
-
- public Boolean isAssignableFromTo(Object fromType, Object toType) {
- if (fromType instanceof CustomBeanModelType) {
- fromType = ((CustomBeanModelType) fromType).getType();
- }
- if (toType instanceof CustomBeanModelType) {
- toType = ((CustomBeanModelType) toType).getType();
- }
- return new Boolean(parentContext.isAssignableFromTo(fromType, toType));
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomBeanModelType.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomBeanModelType.java
deleted file mode 100644
index f8af8534..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomBeanModelType.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * 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.databinding.scenarios;
-
-/**
- * @since 3.2
- *
- */
-public class CustomBeanModelType {
-
- private String propertyName;
-
- private Object object;
-
- private Class type;
-
- /**
- * @param object
- * @param propertyName
- * @param type
- */
- public CustomBeanModelType(Object object, String propertyName, Class type) {
- this.object = object;
- this.propertyName = propertyName;
- this.type = type;
- }
-
- /**
- * @return
- */
- public String getPropertyName() {
- return propertyName;
- }
-
- /**
- * @return
- */
- public Object getObject() {
- return object;
- }
-
- /**
- * @return
- */
- public Class getType() {
- return type;
- }
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomBeanObservableFactory.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomBeanObservableFactory.java
deleted file mode 100644
index e08075d4..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomBeanObservableFactory.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * 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.databinding.scenarios;
-
-import org.eclipse.jface.databinding.observable.IChangeListener;
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.databinding.observable.IStaleListener;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.databinding.observable.value.IValueChangeListener;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.factories.IObservableFactory;
-
-/**
- * @since 3.2
- *
- */
-public class CustomBeanObservableFactory implements IObservableFactory {
-
- private final DataBindingContext parentDataBindingContext;
-
- public CustomBeanObservableFactory(
- DataBindingContext parentDataBindingContext) {
- this.parentDataBindingContext = parentDataBindingContext;
- }
-
- public IObservable createObservable(Object description) {
- IObservable result = parentDataBindingContext
- .createObservable(description);
- if (description instanceof Property) {
- final Property property = (Property) description;
- if (result instanceof IObservableValue) {
- final IObservableValue wrapped = (IObservableValue) result;
- if (wrapped.getValueType() instanceof Class
- && property.getPropertyID() instanceof String) {
- return new IObservableValue() {
-
- public Object getValueType() {
- return new CustomBeanModelType(
- property.getObject(), (String) property
- .getPropertyID(), (Class) wrapped
- .getValueType());
- }
-
- public Object getValue() {
- return wrapped.getValue();
- }
-
- public void setValue(Object value) {
- wrapped.setValue(value);
- }
-
- public void addValueChangeListener(
- IValueChangeListener listener) {
- wrapped.addValueChangeListener(listener);
- }
-
- public void removeValueChangeListener(
- IValueChangeListener listener) {
- wrapped.removeValueChangeListener(listener);
- }
-
- public void addChangeListener(IChangeListener listener) {
- wrapped.addChangeListener(listener);
- }
-
- public void removeChangeListener(
- IChangeListener listener) {
- wrapped.removeChangeListener(listener);
- }
-
- public void addStaleListener(IStaleListener listener) {
- wrapped.addStaleListener(listener);
- }
-
- public void removeStaleListener(IStaleListener listener) {
- wrapped.removeStaleListener(listener);
- }
-
- public boolean isStale() {
- return wrapped.isStale();
- }
-
- public void dispose() {
- wrapped.dispose();
- }
- };
- }
- }
- }
- return result;
- }
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomConverterScenarios.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomConverterScenarios.java
deleted file mode 100644
index 7da8ecba..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomConverterScenarios.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.scenarios;
-
-import org.eclipse.jface.examples.databinding.model.Adventure;
-import org.eclipse.jface.examples.databinding.model.PriceModelObject;
-import org.eclipse.jface.examples.databinding.model.SampleData;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.swt.SWTProperties;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Spinner;
-
-/**
- * To run the tests in this class, right-click and select "Run As JUnit Plug-in
- * Test". This will also start an Eclipse instance. To clean up the launch
- * configuration, open up its "Main" tab and select "[No Application] - Headless
- * Mode" as the application to run.
- */
-
-public class CustomConverterScenarios extends ScenariosTestCase {
-
- private Adventure skiTrip;
-
- protected void setUp() throws Exception {
- super.setUp();
- skiTrip = SampleData.WINTER_HOLIDAY;
- }
-
- protected void tearDown() throws Exception {
- // do any teardown work here
- super.tearDown();
- }
-
- public void testScenario01() {
-
- Spinner spinner_dollars = new Spinner(getComposite(), SWT.NONE);
- spinner_dollars.setMaximum(10000);
- Spinner spinner_cents = new Spinner(getComposite(), SWT.NONE);
-
- // The price object is a double which contains both the dollars and cents
- // To allow this to be worked on with two separate spinner controls (which get and set int values)
- // an intermediate object is used
- PriceModelObject priceModel = new PriceModelObject();
- getDbc().bind(
- new Property(priceModel,"price"),
- new Property(skiTrip,"price"),null);
-
- getDbc().bind(
- new Property(spinner_dollars,
- SWTProperties.SELECTION),
- new Property(priceModel, "dollars"),null);
-
- getDbc().bind(
- new Property(spinner_cents,
- SWTProperties.SELECTION),
- new Property(priceModel, "cents"),null);
- // spinEventLoop(1);
- // Make sure that the selection on the spinner_dollars matches the
- // dollars of the price
- assertEquals(spinner_dollars.getSelection(), new Double(skiTrip
- .getPrice()).intValue());
- // Make sure that the selection on the spinner_cents matches the dollars
- // of the price
- Double doublePrice = new Double(skiTrip.getPrice());
- double cents = 100*doublePrice.doubleValue() - 100*doublePrice
- .intValue();
- assertEquals(spinner_cents.getSelection(), (int) cents);
-
- // Change the selection on the spinner_dollars to be $50 and make sure
- // the model is updated with the cents included
- spinner_dollars.setSelection(50);
- double expectedPrice = 50 + cents / 100;
- assertEquals(expectedPrice, skiTrip.getPrice(),0.01);
-
- // Change the selection on the spinner_cents to be 27 and make sure the
- // model is updated with the dollars included
- spinner_cents.setSelection(27);
- assertEquals(50.27, skiTrip.getPrice(),0.01);
-
- // Change the model to be $60.99 dollars and make sure the
- // spinner_dollars is 60 and spinner_cents is 99
- skiTrip.setPrice(60.99);
- assertEquals(60, spinner_dollars.getSelection());
- assertEquals(99, spinner_cents.getSelection());
-
- }
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomScenarios.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomScenarios.java
deleted file mode 100644
index 4e399002..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomScenarios.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.scenarios;
-
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.examples.databinding.model.Adventure;
-import org.eclipse.jface.examples.databinding.model.AggregateObservableValue;
-import org.eclipse.jface.examples.databinding.model.SampleData;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * To run the tests in this class, right-click and select "Run As JUnit Plug-in
- * Test". This will also start an Eclipse instance. To clean up the launch
- * configuration, open up its "Main" tab and select "[No Application] - Headless
- * Mode" as the application to run.
- */
-
-public class CustomScenarios extends ScenariosTestCase {
-
- protected void setUp() throws Exception {
- super.setUp();
- // do any setup work here
- }
-
- protected void tearDown() throws Exception {
- // do any teardown work here
- super.tearDown();
- }
-
- public void testScenario01() {
-
- // Binding the name property of an Adventure object to the contents of
- // Text controls, no conversion, no validation.
-
- Adventure adventure = SampleData.WINTER_HOLIDAY;
- Text text = new Text(getComposite(), SWT.BORDER);
-
- IObservableValue descriptionObservable = (IObservableValue) getDbc()
- .createObservable(new Property(adventure, "description"));
- IObservableValue nameObservable = (IObservableValue) getDbc()
- .createObservable(new Property(adventure, "name"));
-
- AggregateObservableValue customObservable_comma = new AggregateObservableValue(
- new IObservableValue[] { descriptionObservable, nameObservable },
- ",");
-
- getDbc().bind(getDbc().createObservable(new Property(text, "text")),
- customObservable_comma, null);
- // spinEventLoop(1);
- // Make sure that the description on the model match the widget
- assertEquals(adventure.getDescription() + "," + adventure.getName(),
- text.getText());
-
- // Change the widget to newDescription,newName and ensure the model is
- // updated
- text.setText("newDescription,newName");
- assertEquals("newDescription", adventure.getDescription());
- assertEquals("newName", adventure.getName());
-
- // Change the model to newDescription_0 and newName_0 and ensure the GUI
- // is updated
- adventure.setDescription("newDescription_0");
- adventure.setName("newName_0");
- assertEquals("newDescription_0,newName_0", text.getText());
-
- // Change text to newDescription_1 with no comma and ensure the model is
- // updated correctly with no name
- text.setText("newDescription_1");
- assertEquals("newDescription_1", adventure.getDescription());
- assertEquals(null, adventure.getName());
-
- // Change text to newName with a preceeding comma and ensure the model
- // is updated correctly with no description
- // TODO - Get this test working + Add the one where we have two aggregates and update one and
- // check that the other is updated - currently this fails on the GUI - JRW
-// text.setText(",newName_1");
-// assertEquals(null, adventure.getDescription());
-// assertEquals("newName_1", adventure.getName());
-
- }
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/LabelControlScenario.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/LabelControlScenario.java
deleted file mode 100644
index a28e5593..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/LabelControlScenario.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.scenarios;
-
-import org.eclipse.jface.examples.databinding.model.Adventure;
-import org.eclipse.jface.examples.databinding.model.SampleData;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Label;
-
-/**
- * To run the tests in this class, right-click and select "Run As JUnit Plug-in
- * Test". This will also start an Eclipse instance. To clean up the launch
- * configuration, open up its "Main" tab and select "[No Application] - Headless
- * Mode" as the application to run.
- */
-
-public class LabelControlScenario extends ScenariosTestCase {
-
- private Adventure adventure;
- private Label label;
-
- protected void setUp() throws Exception {
- super.setUp();
- // do any setup work here
- label = new Label(getComposite(), SWT.NONE);
- adventure = SampleData.WINTER_HOLIDAY;
- }
-
- protected void tearDown() throws Exception {
- // do any teardown work here
- super.tearDown();
- label.dispose();
- label = null;
- }
-
- public void testScenario01() {
- // Bind the adventure "name" property to a label control
- // Change the UI and verify the model and UI are the same value
- // Change the model and verify the UI changes
- getDbc().bind(label, new Property(adventure, "name"), null);
- assertEquals(adventure.getName(), label.getText());
- adventure.setName("France");
- assertEquals("France", label.getText());
- adventure.setName("Climb Everest");
- spinEventLoop(0);
- assertEquals("Climb Everest",label.getText());
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ListViewerScenario.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ListViewerScenario.java
deleted file mode 100644
index d631e7c6..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ListViewerScenario.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.scenarios;
-
-import org.eclipse.jface.examples.databinding.model.Adventure;
-import org.eclipse.jface.examples.databinding.model.Catalog;
-import org.eclipse.jface.examples.databinding.model.SampleData;
-import org.eclipse.jface.internal.databinding.provisional.description.ListModelDescription;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersProperties;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ListViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.List;
-
-/**
- * To run the tests in this class, right-click and select "Run As JUnit Plug-in
- * Test". This will also start an Eclipse instance. To clean up the launch
- * configuration, open up its "Main" tab and select "[No Application] - Headless
- * Mode" as the application to run.
- */
-
-public class ListViewerScenario extends ScenariosTestCase {
-
- private Catalog catalog;
-
- private List list;
-
- private ListViewer listViewer;
-
- protected void setUp() throws Exception {
- super.setUp();
- // do any setup work here
- list = new List(getComposite(), SWT.READ_ONLY | SWT.SINGLE);
- listViewer = new ListViewer(list);
- catalog = SampleData.CATALOG_2005; // Lodging source
- }
-
- protected void tearDown() throws Exception {
- list.dispose();
- list = null;
- listViewer = null;
- super.tearDown();
- }
-
- public void testScenario01() {
-
- // Bind the catalog's lodgings to the combo
- getDbc().bind(
- listViewer,
- new ListModelDescription(new Property(catalog, "lodgings"),
- "name"), null);
- // Verify that the combo's items are the lodgings
- for (int i = 0; i < catalog.getLodgings().length; i++) {
- assertEquals(catalog.getLodgings()[i], listViewer.getElementAt(i));
- }
- // Verify that the String being shown in the list viewer is the
- // "toString" of the combo viewer
- String[] lodgingStrings = new String[catalog.getLodgings().length];
- for (int i = 0; i < catalog.getLodgings().length; i++) {
- lodgingStrings[i] = catalog.getLodgings()[i].getName();
- }
- assertArrayEquals(lodgingStrings, list.getItems());
-
- // Verify that the list has no selected item
- assertEquals(null, ((IStructuredSelection) listViewer.getSelection())
- .getFirstElement());
-
- // Now bind the selection of the combo to the "defaultLodging" property
- // of an adventure
- final Adventure adventure = SampleData.WINTER_HOLIDAY;
- getDbc().bind(
- new Property(listViewer, ViewersProperties.SINGLE_SELECTION),
- new Property(adventure, "defaultLodging"), null);
-
- // Verify that the list selection is the default lodging
- assertEquals(((IStructuredSelection) listViewer.getSelection())
- .getFirstElement(), adventure.getDefaultLodging());
-
- // Change the model and verify that the list selection changes
- adventure.setDefaultLodging(SampleData.CAMP_GROUND);
- assertEquals(adventure.getDefaultLodging(), SampleData.CAMP_GROUND);
- assertEquals(((IStructuredSelection) listViewer.getSelection())
- .getFirstElement(), adventure.getDefaultLodging());
-
- // Change the list selection and verify that the model changes
- listViewer.getList().select(3);
- assertEquals(((IStructuredSelection) listViewer.getSelection())
- .getFirstElement(), adventure.getDefaultLodging());
-
- adventure.setDefaultLodging(SampleData.YOUTH_HOSTEL);
- spinEventLoop(0);
- assertEquals(((IStructuredSelection) listViewer.getSelection())
- .getFirstElement(), adventure.getDefaultLodging());
-
- }
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/MasterDetailScenarios.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/MasterDetailScenarios.java
deleted file mode 100644
index 288c7f68..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/MasterDetailScenarios.java
+++ /dev/null
@@ -1,378 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.scenarios;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.jface.databinding.observable.value.ComputedValue;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.examples.databinding.model.Adventure;
-import org.eclipse.jface.examples.databinding.model.Catalog;
-import org.eclipse.jface.examples.databinding.model.Category;
-import org.eclipse.jface.examples.databinding.model.Lodging;
-import org.eclipse.jface.examples.databinding.model.SampleData;
-import org.eclipse.jface.internal.databinding.provisional.description.ListModelDescription;
-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.swt.SWTProperties;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersProperties;
-import org.eclipse.jface.viewers.ContentViewer;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.ListViewer;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * To run the tests in this class, right-click and select "Run As JUnit Plug-in
- * Test". This will also start an Eclipse instance. To clean up the launch
- * configuration, open up its "Main" tab and select "[No Application] - Headless
- * Mode" as the application to run.
- */
-
-public class MasterDetailScenarios extends ScenariosTestCase {
-
- protected void setUp() throws Exception {
- super.setUp();
- // do any setup work here
- }
-
- protected void tearDown() throws Exception {
- // do any teardown work here
- super.tearDown();
- }
-
- protected Object getViewerSelection(ContentViewer contentViewer) {
- return ((IStructuredSelection) contentViewer.getSelection())
- .getFirstElement();
- }
-
- /**
- * @return the ComboViewer's domain object list
- */
- protected List getViewerContent(ContentViewer contentViewer) {
- Object[] elements = ((IStructuredContentProvider) contentViewer
- .getContentProvider()).getElements(null);
- if (elements != null)
- return Arrays.asList(elements);
- return null;
- }
-
- public void testScenario01() {
-
- // Displaying the catalog's list of Lodging objects in a list viewer,
- // using their names. The name of the currently selected Lodging can
- // be edited in a text widget. There is always a selected Lodging
- // object.
- ListViewer listViewer = new ListViewer(getComposite(), SWT.BORDER);
- listViewer.getList().setLayoutData(
- new GridData(SWT.FILL, SWT.FILL, false, false));
- Catalog catalog = SampleData.CATALOG_2005;
-
- listViewer.setLabelProvider(new LabelProvider() {
- public String getText(Object element) {
- return ((Lodging) element).getName();
- }
- });
- getDbc().bind(
- listViewer,
- new TableModelDescription(new Property(catalog, "lodgings"),
- new String[] { "name" }), null);
-
- assertArrayEquals(catalog.getLodgings(), getViewerContent(listViewer)
- .toArray());
-
- IObservableValue selectedLodging = (IObservableValue) getDbc()
- .createObservable(
- new Property(listViewer,
- ViewersProperties.SINGLE_SELECTION));
-
- selectedLodging.setValue(SampleData.CAMP_GROUND);
-
- assertEquals(SampleData.CAMP_GROUND, getViewerSelection(listViewer));
- Text txtName = new Text(getComposite(), SWT.BORDER);
-
- getDbc().bind(
- txtName,
- new Property(selectedLodging, "name", String.class,
- Boolean.FALSE), null);
-
- assertEquals(txtName.getText(), SampleData.CAMP_GROUND.getName());
- enterText(txtName, "foobar");
- assertEquals("foobar", SampleData.CAMP_GROUND.getName());
- listViewer.setSelection(new StructuredSelection(
- SampleData.FIVE_STAR_HOTEL));
- assertEquals(SampleData.FIVE_STAR_HOTEL, selectedLodging.getValue());
- assertEquals(SampleData.FIVE_STAR_HOTEL.getName(), txtName.getText());
- SampleData.FIVE_STAR_HOTEL.setName("barfoo");
- assertEquals("barfoo", txtName.getText());
-
- // Now make sure that the event listeners get removed on dispose()
- // Values should no longer be updated
- selectedLodging.dispose();
-
- // selectedLodging.setValue(SampleData.CAMP_GROUND);
- // assertNotSame(SampleData.CAMP_GROUND,
- // getViewerSelection(listViewer));
- // assertNotSame(txtName.getText(), SampleData.CAMP_GROUND.getName());
- // enterText(txtName, "foobar");
- // assertNotSame("foobar", SampleData.CAMP_GROUND.getName());
- // listViewer.setSelection(new StructuredSelection(
- // SampleData.FIVE_STAR_HOTEL));
- // assertNotSame(SampleData.FIVE_STAR_HOTEL,
- // selectedLodging.getValue());
- // assertNotSame(SampleData.FIVE_STAR_HOTEL.getName(),
- // txtName.getText());
- // SampleData.FIVE_STAR_HOTEL.setName("barfoo");
- // assertNotSame("barfoo", txtName.getText());
- }
-
- public void testScenario02() {
-
- // Selecting from the list of lodgings for an adventure and editing the
- // properties of the selected lodging in text widgets. If no lodging is
- // selected the input controls for name and adventure are disabled.
- // There are two buttons "Add" and "Remove"; clicking on "Add" creates a
- // new lodging and selects it so it can be edited, clicking on "Remove"
- // removes the currently selected lodging from the list.
- final ListViewer listViewer = new ListViewer(getComposite(), SWT.BORDER);
- listViewer.getList().setLayoutData(
- new GridData(SWT.FILL, SWT.FILL, false, false));
- final Catalog catalog = SampleData.CATALOG_2005;
-
- listViewer.setLabelProvider(new LabelProvider() {
- public String getText(Object element) {
- return ((Lodging) element).getName();
- }
- });
- getDbc().bind(
- listViewer,
- new TableModelDescription(new Property(catalog, "lodgings"),
- new String[] { "name" }), null);
-
- assertArrayEquals(catalog.getLodgings(), getViewerContent(listViewer)
- .toArray());
-
- final IObservableValue selectedLodgingObservable = (IObservableValue) getDbc()
- .createObservable(
- new Property(listViewer,
- ViewersProperties.SINGLE_SELECTION));
-
- selectedLodgingObservable.setValue(null);
- assertTrue(listViewer.getSelection().isEmpty());
-
- ComputedValue selectionExistsObservable = new ComputedValue(
- boolean.class) {
- protected Object calculate() {
- return new Boolean(selectedLodgingObservable.getValue() != null);
- }
- };
-
- assertFalse(((Boolean) selectionExistsObservable.getValue())
- .booleanValue());
-
- final Text txtName = new Text(getComposite(), SWT.BORDER);
-
- getDbc().bind(new Property(txtName, SWTProperties.ENABLED),
- selectionExistsObservable, null);
- getDbc().bind(
- new Property(txtName, SWTProperties.TEXT),
- new Property(selectedLodgingObservable, "name", String.class,
- Boolean.FALSE), null);
-
- assertEquals(txtName.getText(), "");
- assertFalse(txtName.getEnabled());
-
- final Text txtDescription = new Text(getComposite(), SWT.BORDER);
-
- getDbc().bind(new Property(txtDescription, SWTProperties.ENABLED),
- selectionExistsObservable, null);
- getDbc().bind(
- new Property(txtDescription, SWTProperties.TEXT),
- new Property(selectedLodgingObservable, "description",
- String.class, Boolean.FALSE), null);
-
- assertEquals(txtDescription.getText(), "");
- assertFalse(txtDescription.getEnabled());
-
- Button addButton = new Button(getComposite(), SWT.PUSH);
- addButton.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- Lodging selectedLodging = (Lodging) selectedLodgingObservable
- .getValue();
- int insertionIndex = 0;
- if (selectedLodging != null) {
- insertionIndex = Arrays.asList(catalog.getLodgings())
- .indexOf(selectedLodging);
- assertTrue(insertionIndex >= 0);
- }
- Lodging newLodging = SampleData.FACTORY.createLodging();
- int itemCount = listViewer.getList().getItemCount();
- newLodging.setName("new lodging name " + itemCount);
- newLodging.setDescription("new lodging description "
- + itemCount);
- catalog.addLodging(newLodging);
- assertEquals(itemCount + 1, listViewer.getList().getItemCount());
- listViewer.setSelection(new StructuredSelection(newLodging));
- assertSame(newLodging, selectedLodgingObservable.getValue());
- assertTrue(txtName.getEnabled());
- assertTrue(txtDescription.getEnabled());
- assertEquals(newLodging.getName(), txtName.getText());
- assertEquals(newLodging.getDescription(), txtDescription
- .getText());
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
- });
-
- Button removeButton = new Button(getComposite(), SWT.PUSH);
- removeButton.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- Lodging selectedLodging = (Lodging) selectedLodgingObservable
- .getValue();
- assertNotNull(selectedLodging);
- int deletionIndex = Arrays.asList(catalog.getLodgings())
- .indexOf(selectedLodging);
- assertTrue(deletionIndex >= 0);
- int itemCount = listViewer.getList().getItemCount();
- catalog.removeLodging(selectedLodging);
- assertEquals(itemCount - 1, listViewer.getList().getItemCount());
- assertNull(selectedLodgingObservable.getValue());
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
- });
-
- pushButtonWithEvents(addButton);
- pushButtonWithEvents(removeButton);
- pushButtonWithEvents(addButton);
- pushButtonWithEvents(addButton);
- pushButtonWithEvents(removeButton);
- }
-
- public void testScenario03() {
-
- // List adventures and for the selected adventure allow its default
- // lodging�s name and description to be changed in text controls. If
- // there is no selected adventure or the default lodging is null the
- // text controls are disabled. This is a nested property. The default
- // lodging can be changed elsewhere, and the list
- final Catalog catalog = SampleData.CATALOG_2005;
-
- final ListViewer categoryListViewer = new ListViewer(getComposite(),
- SWT.BORDER);
- categoryListViewer.getList().setLayoutData(
- new GridData(SWT.FILL, SWT.FILL, false, false));
- categoryListViewer.setLabelProvider(new LabelProvider() {
- public String getText(Object element) {
- return ((Category) element).getName();
- }
- });
- getDbc().bind(
- categoryListViewer,
- new ListModelDescription(new Property(catalog, "categories"),
- "name"), null);
-
- assertArrayEquals(catalog.getCategories(), getViewerContent(
- categoryListViewer).toArray());
-
- final IObservableValue selectedCategoryObservable = (IObservableValue) getDbc()
- .createObservable(
- new Property(categoryListViewer,
- ViewersProperties.SINGLE_SELECTION));
-
- final ListViewer adventureListViewer = new ListViewer(getComposite(),
- SWT.BORDER);
- adventureListViewer.getList().setLayoutData(
- new GridData(SWT.FILL, SWT.FILL, false, false));
- adventureListViewer.setLabelProvider(new LabelProvider() {
- public String getText(Object element) {
- return ((Adventure) element).getName();
- }
- });
-
- getDbc().bind(
- adventureListViewer,
- new ListModelDescription(new Property(
- selectedCategoryObservable, "adventures",
- Adventure.class, Boolean.TRUE), "name"), null);
-
- ComputedValue categorySelectionExistsObservable = new ComputedValue() {
- protected Object calculate() {
- return new Boolean(
- selectedCategoryObservable.getValue() != null);
- }
- };
-
- getDbc().bind(
- new Property(adventureListViewer.getList(),
- SWTProperties.ENABLED),
- categorySelectionExistsObservable, null);
-
- final IObservableValue selectedAdventureObservable = (IObservableValue) getDbc()
- .createObservable(
- new Property(adventureListViewer,
- ViewersProperties.SINGLE_SELECTION));
-
- ComputedValue adventureSelectionExistsObservable = new ComputedValue() {
- protected Object calculate() {
- return new Boolean(
- selectedAdventureObservable.getValue() != null);
- }
- };
-
- final Text txtName = new Text(getComposite(), SWT.BORDER);
-
- getDbc().bind(new Property(txtName, SWTProperties.ENABLED),
- adventureSelectionExistsObservable, null);
- getDbc().bind(
- new Property(txtName, SWTProperties.TEXT),
- new Property(selectedAdventureObservable, "name", String.class,
- Boolean.FALSE), null);
-
- assertEquals(txtName.getText(), "");
- assertFalse(txtName.getEnabled());
-
- final Text txtDescription = new Text(getComposite(), SWT.BORDER);
-
- getDbc().bind(new Property(txtDescription, SWTProperties.ENABLED),
- adventureSelectionExistsObservable, null);
- getDbc().bind(
- new Property(txtDescription, SWTProperties.TEXT),
- new Property(selectedAdventureObservable, "description",
- String.class, Boolean.FALSE), null);
-
- assertFalse(adventureListViewer.getList().isEnabled());
- categoryListViewer.setSelection(new StructuredSelection(
- SampleData.SUMMER_CATEGORY));
- assertTrue(adventureListViewer.getList().isEnabled());
- assertFalse(txtName.getEnabled());
- adventureListViewer.setSelection(new StructuredSelection(
- SampleData.RAFTING_HOLIDAY));
- assertTrue(txtName.getEnabled());
- assertEquals(SampleData.RAFTING_HOLIDAY.getName(), txtName.getText());
- categoryListViewer.setSelection(new StructuredSelection(
- SampleData.WINTER_CATEGORY));
- assertTrue(adventureListViewer.getList().isEnabled());
- assertFalse(txtName.getEnabled());
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/NPETestScenario.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/NPETestScenario.java
deleted file mode 100644
index 001d191c..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/NPETestScenario.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * 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.databinding.scenarios;
-
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * @since 3.2
- *
- */
-public class NPETestScenario extends ScenariosTestCase {
- private Text text;
-
- Person person;
-
- protected void setUp() throws Exception {
- super.setUp();
- person = new Person();
- text = new Text(getComposite(), SWT.BORDER);
- }
-
- /**
- * Asserts the ability to have an initial value of <code>null</code> on
- * the model and to update the value by changing the value of the view.
- */
- public void test_InitialNullValue() {
- Person person = new Person();
- assertNull(person.getName());
-
- getDbc().bind(text, new Property(person, "name"), null);
-
- text.setText("Brad");
- text.notifyListeners(SWT.FocusOut, null);
- assertEquals("Brad", person.getName());
- }
-
- private static class Person {
- private String name;
-
- /**
- * @return Returns the name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name
- * The name to set.
- */
- public void setName(String name) {
- this.name = name;
- }
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/NewTableScenarios.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/NewTableScenarios.java
deleted file mode 100644
index f3d7c6e2..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/NewTableScenarios.java
+++ /dev/null
@@ -1,445 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.scenarios;
-
-import java.beans.IntrospectionException;
-
-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.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.TableColumn;
-
-/**
- * To run the tests in this class, right-click and select "Run As JUnit Plug-in
- * Test". This will also start an Eclipse instance. To clean up the launch
- * configuration, open up its "Main" tab and select "[No Application] - Headless
- * Mode" as the application to run.
- */
-
-public class NewTableScenarios extends ScenariosTestCase {
-
- private TableViewer tableViewer;
-
- Catalog catalog;
-
- Category category;
-
- private TableColumn firstNameColumn;
-
- private TableColumn lastNameColumn;
-
- private TableColumn stateColumn;
-
- Image[] images;
-
- private TableColumn fancyColumn;
-
- protected void setUp() throws Exception {
- super.setUp();
- getComposite().setLayout(new FillLayout());
- tableViewer = new TableViewer(getComposite());
- tableViewer.getTable().setLinesVisible(true);
- tableViewer.getTable().setHeaderVisible(true);
- firstNameColumn = new TableColumn(tableViewer.getTable(), SWT.NONE);
- firstNameColumn.setWidth(50);
- lastNameColumn = new TableColumn(tableViewer.getTable(), SWT.NONE);
- lastNameColumn.setWidth(50);
- stateColumn = new TableColumn(tableViewer.getTable(), SWT.NONE);
- stateColumn.setWidth(50);
- fancyColumn = new TableColumn(tableViewer.getTable(), SWT.NONE);
- fancyColumn.setWidth(250);
-
- catalog = SampleData.CATALOG_2005; // Lodging source
- category = SampleData.WINTER_CATEGORY;
-
- images = new Image[] {
- getShell().getDisplay().getSystemImage(SWT.ICON_ERROR),
- getShell().getDisplay().getSystemImage(SWT.ICON_WARNING),
- getShell().getDisplay().getSystemImage(SWT.ICON_INFORMATION), };
- }
-
- protected void tearDown() throws Exception {
- // do any teardown work here
- super.tearDown();
- tableViewer.getTable().dispose();
- tableViewer = null;
- firstNameColumn = null;
- lastNameColumn = null;
- stateColumn = null;
- }
-
- String getValue(String text) {
- if (text == null)
- return "";
- return text;
- }
-
- public void testScenario01() throws IntrospectionException {
-// // Factory for directly creating IObservables for beans
-// JavaBeans javaBeans = new JavaBeans();
-//
-// // Wrap the TableViewer in an IObservableCollectionWithLabels
-// IObservableCollectionWithLabels accountTable = new TableViewerObservableTable(
-// tableViewer);
-//
-// // Create a readable set to track the catalog's accounts
-// IReadableSet accountSet = javaBeans.createReadableSet(catalog,
-// new PropertyDescriptor("accounts", Catalog.class, "getAccounts", null),
-// Account.class);
-//
-// // Create an observable cell provider to track the given accounts' properties.
-// IObservableCellProvider accountCellProvider = javaBeans.createObservableCellProvider(
-// accountSet, new String[] { "firstName", "lastName", "state" });
-//
-// // bind
-// getDbc().bind(accountTable, accountCellProvider, null);
-//
-// // uncomment next line to see result interactively
-// // interact();
-//
-// // Verify the data in the table columns matches the accounts
-// Account[] accounts = catalog.getAccounts();
-// for (int i = 0; i < accounts.length; i++) {
-// Account account = accounts[i];
-// String col_0 = ((ITableLabelProvider) tableViewer
-// .getLabelProvider()).getColumnText(account, 0);
-// assertEquals(getValue(account.getFirstName()), col_0);
-// String col_1 = ((ITableLabelProvider) tableViewer
-// .getLabelProvider()).getColumnText(account, 1);
-// assertEquals(getValue(account.getLastName()), col_1);
-// String col_2 = ((ITableLabelProvider) tableViewer
-// .getLabelProvider()).getColumnText(account, 2);
-// assertEquals(getValue(account.getState()), col_2);
-//
-// }
- }
-
- public void testScenario02() throws SecurityException,
- IllegalArgumentException {
-// // Show that a TableViewer with three columns can be used to update
-// // columns
-// Account[] accounts = catalog.getAccounts();
-//
-// TableViewerDescription tableViewerDescription = new TableViewerDescription(
-// tableViewer);
-// tableViewerDescription.addEditableColumn("firstName");
-// tableViewerDescription.addEditableColumn("lastName", null, null,
-// new PhoneConverter());
-// tableViewerDescription.addEditableColumn("state", null, null,
-// new StateConverter());
-// getDbc().bind(tableViewerDescription,
-// new Property(catalog, "accounts"), 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);
-//
- }
-
- 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);
-// }
- }
-
- 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"); }
- */
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ObservableFactoriesTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ObservableFactoriesTest.java
deleted file mode 100644
index 7817074f..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ObservableFactoriesTest.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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
- *******************************************************************************/
-/*
- * Created Oct 21, 2005 by Gili Mendel
- *
- * $RCSfile: ObservableFactoriesTest.java,v $
- * $Revision: 1.3 $ $Date: 2006/08/28 17:33:58 $
- */
-package org.eclipse.jface.tests.databinding.scenarios;
-
-import org.eclipse.jface.databinding.observable.IChangeListener;
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.databinding.observable.IStaleListener;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.factories.IObservableFactory;
-
-public class ObservableFactoriesTest extends ScenariosTestCase {
-
- interface Root {
- };
-
- interface None extends Root {
- };
-
- interface Middle extends None {
- };
-
- interface StandAlone {
- };
-
- class RootClass implements Root {
- };
-
- class NoneClass implements None {
- };
-
- class MiddleClass implements Middle {
- };
-
- class AllClass implements StandAlone, Middle, Root {
- };
-
- class MiddleChild extends MiddleClass {
- };
-
- interface TestIObservable extends IObservable {
- public Class getType();
- }
-
- class Factory implements IObservableFactory {
- Class c;
-
- public Factory(Class c) {
- this.c = c;
- }
-
- public IObservable createObservable(Object description) {
- if (c.isInstance(description)) {
- return new TestIObservable() {
- public void dispose() {
- }
-
- public boolean isStale() {
- return false;
- }
-
- public void removeChangeListener(
- IChangeListener changeListener) {
- }
-
- public void addChangeListener(IChangeListener changeListener) {
- }
-
- public Class getType() {
- return c;
- }
-
- public void addStaleListener(IStaleListener listener) {
- }
-
- public void removeStaleListener(IStaleListener listener) {
- }
- };
- }
- return null;
- }
- }
-
- IObservableFactory root = new Factory(Root.class);
-
- IObservableFactory middle = new Factory(Middle.class);
-
- IObservableFactory sa = new Factory(StandAlone.class);
-
- IObservableFactory factory = new Factory(Object.class);
-
- private DataBindingContext myDbc = null;
-
- protected DataBindingContext getDbc() {
- if (myDbc == null) {
- myDbc = DataBindingContext.createContext(new IObservableFactory[0]);
- }
- return myDbc;
- }
-
- protected Class getFactoryType(Object src) {
- TestIObservable u = (TestIObservable) getDbc().createObservable(src);
- return u.getType();
- }
-
- public void test_factoryRegistration() {
-
- getDbc().addObservableFactory(root);
- getDbc().addObservableFactory(middle);
-
- // Direct mapping
- assertEquals(Root.class, getFactoryType(new RootClass()));
- assertEquals(Middle.class, getFactoryType(new MiddleClass()));
-
- // Inherent interface
- assertEquals(Root.class, getFactoryType(new NoneClass()));
-
- // AllClass inherent interface
- assertEquals(Middle.class, getFactoryType(new AllClass()));
-
- // class inheretence
- assertEquals(Middle.class, getFactoryType(new MiddleChild()));
-
- // Direct, first interface
- getDbc().addObservableFactory(sa);
- assertEquals(StandAlone.class, getFactoryType(new AllClass()));
-
- // Class based contribution.
- getDbc().addObservableFactory(factory);
- assertEquals(Object.class, getFactoryType(new AllClass()));
-
- }
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/PropertyScenarios.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/PropertyScenarios.java
deleted file mode 100644
index da7ffa22..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/PropertyScenarios.java
+++ /dev/null
@@ -1,570 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.scenarios;
-
-import java.text.NumberFormat;
-import java.text.ParseException;
-import java.util.Date;
-import java.util.Locale;
-
-import org.eclipse.jface.databinding.observable.IChangeListener;
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.examples.databinding.model.Account;
-import org.eclipse.jface.examples.databinding.model.Adventure;
-import org.eclipse.jface.examples.databinding.model.Cart;
-import org.eclipse.jface.examples.databinding.model.SampleData;
-import org.eclipse.jface.internal.databinding.provisional.BindSpec;
-import org.eclipse.jface.internal.databinding.provisional.Binding;
-import org.eclipse.jface.internal.databinding.provisional.conversion.Converter;
-import org.eclipse.jface.internal.databinding.provisional.conversion.IConverter;
-import org.eclipse.jface.internal.databinding.provisional.conversion.IdentityConverter;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.swt.SWTProperties;
-import org.eclipse.jface.internal.databinding.provisional.validation.IValidator;
-import org.eclipse.jface.internal.databinding.provisional.validation.ValidationError;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Spinner;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * To run the tests in this class, right-click and select "Run As JUnit Plug-in
- * Test". This will also start an Eclipse instance. To clean up the launch
- * configuration, open up its "Main" tab and select "[No Application] - Headless
- * Mode" as the application to run.
- */
-
-public class PropertyScenarios extends ScenariosTestCase {
-
- private Adventure adventure;
-
- protected void setUp() throws Exception {
- super.setUp();
- // do any setup work here
- adventure = SampleData.WINTER_HOLIDAY;
- }
-
- protected void tearDown() throws Exception {
- // do any teardown work here
- super.tearDown();
- }
-
- public void testEnterText() {
- // just to make sure enterText() generates a FocusOut event.
- Text text = new Text(getComposite(), SWT.BORDER);
- final boolean[] focusLostHolder = { false };
- text.addFocusListener(new FocusListener() {
-
- public void focusGained(FocusEvent e) {
- // only interested in focus lost events
- }
-
- public void focusLost(FocusEvent e) {
- focusLostHolder[0] = true;
- }
- });
- enterText(text, "hallo");
- assertTrue(focusLostHolder[0]);
- }
-
- public void testScenario01() {
- Text text = new Text(getComposite(), SWT.BORDER);
- getDbc().bind(text, new Property(adventure, "name"), null);
- // uncomment the following line to see what's happening
- // spinEventLoop(1);
- assertEquals(adventure.getName(), text.getText());
- enterText(text, "foobar");
- // uncomment the following line to see what's happening
- // spinEventLoop(1);
- assertEquals("foobar", adventure.getName());
- adventure.setName("barfoo");
- // uncomment the following line to see what's happening
- // spinEventLoop(1);
- assertEquals("barfoo", text.getText());
- }
-
- public void testScenario02() {
- // Binding the name property of an Adventure object to the contents of
- // Text controls, no conversion, no validation. The Text widget editable
- // is set to false.by the developer (can not change the name)
- Text text = new Text(getComposite(), SWT.READ_ONLY);
- getDbc().bind(text, new Property(adventure, "name"), null);
- assertEquals(adventure.getName(), text.getText());
- }
-
- public void testScenario03() {
- // Binding of a read-only property of an Adventure object to the
- // contents of Text controls, no conversion, no validation. Text control
- // is not editable as a side effect of binding to a read-only property..
- Cart cart = SampleData.CART;
- cart.setAdventureDays(42);
- // bind to the lodgingDays feature, which is read-only and always one
- // less than the number of adventure days.
- Text text = new Text(getComposite(), SWT.BORDER);
- getDbc().bind(text, new Property(cart, "lodgingDays"),
- new BindSpec(new IConverter() {
- public Object getFromType() {
- return int.class;
- }
-
- public Object getToType() {
- return String.class;
- }
-
- public Object convert(Object object) {
- return object.toString();
- }
- }, new IConverter() {
- public Object getFromType() {
- return String.class;
- }
-
- public Object getToType() {
- return int.class;
- }
-
- public Object convert(Object object) {
- return new Integer((String) object);
- }
- }, null, null));
- assertEquals(new Integer(cart.getLodgingDays()).toString(), text
- .getText());
- // TODO API extension needed: getChangeable() and setChangeable() on
- // IObservableValue or IObservable
- // assertEquals(
- // "Needs API extension: getChangeable() and setChangeable() on
- // IObservableValue or IObservable.",
- // false, text.getEditable());
- }
-
- public void testScenario04() {
- // Binding a nested property of an Adventure object to the content of a
- // Text control, no conversion, no validation.
- Text text = new Text(getComposite(), SWT.BORDER);
- // TODO Scenario needs to be more specific - I'm binding to the default
- // lodging's description of an adventure. What do we expect to happen
- // when the default lodging changes? If we expect no change, then this
- // scenario does not introduce anything new. If we expect the binding to
- // be to the new default lodging's description, shouldn't we move this
- // scenario to the master/detail section? I'm assuming the latter for
- // now.
- IObservableValue defaultLodging = (IObservableValue) getDbc()
- .createObservable(new Property(adventure, "defaultLodging"));
- getDbc().bind(
- text,
- new Property(defaultLodging, "description", String.class,
- Boolean.FALSE), null);
-
- // test changing the description
- assertEquals(adventure.getDefaultLodging().getDescription(), text
- .getText());
- enterText(text, "foobar");
- assertEquals("foobar", adventure.getDefaultLodging().getDescription());
- adventure.getDefaultLodging().setDescription("barfoo");
- assertEquals(adventure.getDefaultLodging().getDescription(), text
- .getText());
-
- // test changing the default lodging
- adventure.setDefaultLodging(SampleData.CAMP_GROUND);
- assertEquals(adventure.getDefaultLodging().getDescription(), text
- .getText());
- adventure.getDefaultLodging().setDescription("barfo");
- assertEquals(adventure.getDefaultLodging().getDescription(), text
- .getText());
-
- adventure.setDefaultLodging(null);
- assertEquals("", text.getText());
-
- adventure.setDefaultLodging(SampleData.FIVE_STAR_HOTEL);
- assertEquals(adventure.getDefaultLodging().getDescription(), text
- .getText());
- adventure.getDefaultLodging().setDescription("barf");
- assertEquals(adventure.getDefaultLodging().getDescription(), text
- .getText());
-
- }
-
- public void testScenario05() {
- // Binding the name property of an Adventure object to the contents of
- // Text controls where conversion occurs � the model data is held all
- // in
- // uppercase and displayed in lowercase with the first letter
- // capitalized.
- Text text = new Text(getComposite(), SWT.BORDER);
- adventure.setName("UPPERCASE");
- getDbc().bind(text, new Property(adventure, "name"),
- new BindSpec(new IConverter() {
- public Object getFromType() {
- return String.class;
- }
-
- public Object getToType() {
- return String.class;
- }
-
- public Object convert(Object toObject) {
- String modelValue = (String) toObject;
- if (modelValue == null || modelValue.equals("")) {
- return modelValue;
- }
- String firstChar = modelValue.substring(0, 1);
- String remainingChars = modelValue.substring(1);
- return firstChar.toUpperCase()
- + remainingChars.toLowerCase();
- }
- }, new IConverter() {
- public Object getFromType() {
- return String.class;
- }
-
- public Object getToType() {
- return String.class;
- }
-
- public Object convert(Object fromObject) {
- return ((String) fromObject).toUpperCase();
- }
- }, null, null));
- // spinEventLoop(1);
- assertEquals("Uppercase", text.getText());
- enterText(text, "lowercase");
- // spinEventLoop(1);
- // TODO If we wanted to "canonicalize" the value in the text field, how
- // could we do that?
- assertEquals("LOWERCASE", adventure.getName());
- }
-
- public void testScenario06() {
- // Binding the name property of an Adventure object to the contents of
- // Text controls where validation occurs and the name cannot be longer
- // than 15 characters and cannot contain spaces
- Text text = new Text(getComposite(), SWT.BORDER);
- final String noSpacesMessage = "Name must not contain spaces.";
- final String max15CharactersMessage = "Maximum length for name is 15 characters.";
- adventure.setName("ValidValue");
- getDbc().bind(
- text,
- new Property(adventure, "name"),
- new BindSpec(new IdentityConverter(String.class),
- new IdentityConverter(String.class), new IValidator() {
- public ValidationError isPartiallyValid(Object value) {
- return isValid(value);
- }
-
- public ValidationError isValid(Object value) {
- String stringValue = (String) value;
- if (stringValue.length() > 15) {
- return ValidationError
- .error(max15CharactersMessage);
- } else if (stringValue.indexOf(' ') != -1) {
- return ValidationError
- .error(noSpacesMessage);
- } else {
- return null;
- }
- }
- }, null));
- // no validation message
- assertEquals(null, getDbc().getPartialValidationError().getValue());
- enterText(text, "Invalid Value");
- assertEquals(noSpacesMessage, ((ValidationError) getDbc()
- .getPartialValidationError().getValue()).message);
- assertEquals("ValidValue", text.getText());
- text.setText("InvalidValueBecauseTooLong");
- assertEquals(max15CharactersMessage, ((ValidationError) getDbc()
- .getPartialValidationError().getValue()).message);
- assertEquals("ValidValue", text.getText());
- enterText(text, "anothervalid");
- assertEquals(null, getDbc().getPartialValidationError().getValue());
- assertEquals("anothervalid", text.getText());
- assertEquals("anothervalid", adventure.getName());
- }
-
- public void testScenario07() {
- // Binding the price property of an Adventure to a Text control. Price
- // is a double and Text accepts String so conversion will have to occur.
- // Validation ensure that the value is positive
- Text text = new Text(getComposite(), SWT.BORDER);
- adventure.setPrice(5.0);
- final String cannotBeNegativeMessage = "Price cannot be negative.";
- final String mustBeCurrencyMessage = "Price must be a currency.";
- getDbc().bind(text, new Property(adventure, "price"),
- new BindSpec(new Converter(double.class, String.class) {
- public Object convert(Object toObject) {
- return ((Double) toObject).toString();
- }
- }, new Converter(String.class, double.class) {
-
- public Object convert(Object fromObject) {
- return new Double((String) fromObject);
- }
- }, new IValidator() {
- public ValidationError isPartiallyValid(Object value) {
- return null;
- }
-
- public ValidationError isValid(Object value) {
- String stringValue = (String) value;
- try {
- double doubleValue = new Double(stringValue)
- .doubleValue();
- if (doubleValue < 0.0) {
- return ValidationError
- .error(cannotBeNegativeMessage);
- }
- return null;
- } catch (NumberFormatException ex) {
- return ValidationError.error(mustBeCurrencyMessage);
- }
- }
- }, null));
- assertEquals("5.0", text.getText());
- assertEquals(null, getDbc().getValidationError().getValue());
- enterText(text, "0.65");
- assertEquals(null, getDbc().getValidationError().getValue());
- assertEquals(0.65, adventure.getPrice(), 0.0001);
- adventure.setPrice(42.24);
- assertEquals("42.24", text.getText());
- assertEquals(null, getDbc().getValidationError().getValue());
- enterText(text, "jygt");
- assertEquals(mustBeCurrencyMessage, ((ValidationError) getDbc()
- .getValidationError().getValue()).message);
- enterText(text, "-23.9");
- assertEquals(cannotBeNegativeMessage, ((ValidationError) getDbc()
- .getValidationError().getValue()).message);
- assertEquals(42.24, adventure.getPrice(), 0.0001);
- adventure.setPrice(0.0);
- assertEquals(null, getDbc().getValidationError().getValue());
- }
-
- public void testScenario08() {
- // Binding the price property of an Adventure to a Text control but with
- // custom conversion � the double will be validated to only have two
- // decimal places and displayed with a leading currency symbol, and can
- // be entered with or without the currency symbol.
- Text text = new Text(getComposite(), SWT.BORDER);
- adventure.setPrice(5.0);
- final String cannotBeNegativeMessage = "Price cannot be negative.";
- final String mustBeCurrencyMessage = "Price must be a currency.";
- final NumberFormat currencyFormat = NumberFormat
- .getCurrencyInstance(Locale.CANADA);
- getDbc().bind(text, new Property(adventure, "price"),
- new BindSpec(new Converter(double.class, String.class) {
- public Object convert(Object toObject) {
- return currencyFormat.format(((Double) toObject)
- .doubleValue());
- }
- }, new Converter(String.class, double.class) {
-
- public Object convert(Object fromObject) {
- try {
- return currencyFormat.parse((String) fromObject);
- } catch (ParseException e) {
- // TODO throw something like
- // IllegalConversionException?
- return new Double(0);
- }
- }
- }, new IValidator() {
- public ValidationError isPartiallyValid(Object value) {
- return null;
- }
-
- public ValidationError isValid(Object value) {
- String stringValue = (String) value;
- try {
- double doubleValue = currencyFormat.parse(
- stringValue).doubleValue();
- if (doubleValue < 0.0) {
- return ValidationError
- .error(cannotBeNegativeMessage);
- }
- return null;
- } catch (ParseException e) {
- return ValidationError.error(mustBeCurrencyMessage);
- }
- }
- }, null));
- assertEquals("$5.00", text.getText());
- assertEquals(null, getDbc().getValidationError().getValue());
- enterText(text, "$0.65");
- assertEquals(null, getDbc().getValidationError().getValue());
- assertEquals(0.65, adventure.getPrice(), 0.0001);
- adventure.setPrice(42.24);
- assertEquals("$42.24", text.getText());
- assertEquals(null, getDbc().getValidationError().getValue());
- enterText(text, "jygt");
- assertEquals(mustBeCurrencyMessage, ((ValidationError) getDbc()
- .getValidationError().getValue()).message);
- enterText(text, "-$23.9");
- assertEquals(cannotBeNegativeMessage, ((ValidationError) getDbc()
- .getValidationError().getValue()).message);
- assertEquals(42.24, adventure.getPrice(), 0.0001);
- adventure.setPrice(0.0);
- assertEquals(null, getDbc().getValidationError().getValue());
- }
-
- public void testScenario09() {
- // Binding a boolean property to a CheckBox. Adventure will have a
- // Boolean property �petsAllowed�
- Button checkbox = new Button(getComposite(), SWT.CHECK);
- // checkbox.setText("Pets allowed");
- // checkbox.setLayoutData(new GridData(SWT.LEFT,SWT.TOP, false,false));
- adventure.setPetsAllowed(true);
- getDbc().bind(checkbox, new Property(adventure, "petsAllowed"), null);
- assertEquals(true, checkbox.getSelection());
- setButtonSelectionWithEvents(checkbox, false);
- assertEquals(false, adventure.isPetsAllowed());
- adventure.setPetsAllowed(true);
- assertEquals(true, checkbox.getSelection());
- }
-
- public void testScenario10() {
- // Binding a Transportation departure time to a Text control that
- // formats and validates the time to and from a String. There are
- // property bindings that bind elements of the GUI to elements to GUI
- // and also elements of the domain to elements of the domain
- // TODO fail("not implemented");
- }
-
- public void testScenario11() {
- // Binding the max value of a spinner to another spinner.
- Spinner spinner1 = new Spinner(getComposite(), SWT.NONE);
- spinner1.setSelection(10);
- spinner1.setMinimum(1);
- spinner1.setMaximum(100);
- Spinner spinner2 = new Spinner(getComposite(), SWT.NONE);
- spinner2.setMaximum(1);
- getDbc()
- .bind(spinner1, new Property(spinner2, SWTProperties.MAX), null);
- assertEquals(1, spinner1.getSelection());
- spinner1.setSelection(10);
- spinner1.notifyListeners(SWT.Modify, new Event());
- assertEquals(10, spinner2.getMaximum());
- }
-
- public void testScenario12() {
- // Binding the enabled state of several Text controls to a check box.
- // There will be two check boxes, so as each is enabled/disabled the
- // other one follows as do the states of the Text controls.
- Button checkbox1 = new Button(getComposite(), SWT.CHECK);
- checkbox1.setSelection(false);
- Button checkbox2 = new Button(getComposite(), SWT.CHECK);
- checkbox2.setSelection(false);
- Text text1 = new Text(getComposite(), SWT.NONE);
- Text text2 = new Text(getComposite(), SWT.NONE);
- IObservableValue checkbox1Selected = (IObservableValue) getDbc()
- .createObservable(checkbox1);
- IObservableValue checkbox2Selected = (IObservableValue) getDbc()
- .createObservable(checkbox2);
- // bind the two checkboxes so that if one is checked, the other is not
- // and vice versa.
- Converter negatingConverter = new Converter(boolean.class,
- boolean.class) {
- private Boolean negated(Boolean booleanObject) {
- return new Boolean(!booleanObject.booleanValue());
- }
-
- public Object convert(Object targetObject) {
- return negated((Boolean) targetObject);
- }
- };
- getDbc().bind(checkbox1Selected, checkbox2Selected,
- new BindSpec(negatingConverter, negatingConverter, null, null));
- // bind the enabled state of the two text widgets to one of the
- // checkboxes each.
- getDbc().bind(new Property(text1, SWTProperties.ENABLED),
- checkbox1Selected, null);
- getDbc().bind(new Property(text2, SWTProperties.ENABLED),
- checkbox2Selected, null);
- assertEquals(true, text1.getEnabled());
- assertEquals(false, text2.getEnabled());
- assertEquals(true, checkbox1.getSelection());
- setButtonSelectionWithEvents(checkbox1, false);
- assertEquals(false, text1.getEnabled());
- assertEquals(true, text2.getEnabled());
- assertEquals(true, checkbox2.getSelection());
- setButtonSelectionWithEvents(checkbox2, false);
- assertEquals(true, text1.getEnabled());
- assertEquals(false, text2.getEnabled());
- assertEquals(true, checkbox1.getSelection());
- }
-
- public void testScenario13() {
- // Changing the update policy to be not automatic, but on explicit
- // method call (e.g. triggered by a button click).
- getSWTObservableFactory().setUpdateTime(org.eclipse.jface.databinding.DataBindingContext.TIME_LATE);
- Text text = new Text(getComposite(), SWT.BORDER);
- getDbc().bind(text, new Property(adventure, "name"), null);
- // uncomment the following line to see what's happening
- // happening
- // spinEventLoop(1);
- String adventureName = adventure.getName();
- assertEquals(adventureName, text.getText());
- enterText(text, "foobar");
- // uncomment the following line to see what's happening
- // spinEventLoop(1);
- assertEquals("foobar", adventure.getName());
- adventure.setName("barfoo");
- // uncomment the following line to see what's happening
- // spinEventLoop(1);
- assertEquals("barfoo", text.getText());
- }
-
- public void testScenario14() {
- Text t1 = new Text(getComposite(), SWT.BORDER);
- Text t2 = new Text(getComposite(), SWT.BORDER);
-
- getSWTObservableFactory().setUpdateTime(org.eclipse.jface.databinding.DataBindingContext.TIME_EARLY);
- getDbc().bind(t1, new Property(adventure, "name"), null);
- getDbc().bind(t2, new Property(adventure, "name"), null);
-
- final int[] counter = { 0 };
- IObservableValue uv = (IObservableValue) getDbc().createObservable(
- new Property(adventure, "name"));
- uv.addChangeListener(new IChangeListener() {
- public void handleChange(IObservable source) {
- // Count how many times adventure has changed
- counter[0]++;
- }
- });
-
- String name = adventure.getName() + "Foo";
- enterText(t1, name);
- assertEquals(name, adventure.getName());
- assertEquals(name, t2.getText());
- assertTrue(counter[0] == 1);
-
- name = name + "Bar";
- uv.setValue(name);
- assertEquals(t1.getText(), adventure.getName());
- assertEquals(2, counter[0]);
-
- }
-
- public void testScenario15() {
- Text text = new Text(getComposite(), SWT.NONE);
- Account account = new Account();
- account.setExpiryDate(new Date());
- Binding b = getDbc().bind(text, new Property(account, "expiryDate"),
- null);
- Text errorText = new Text(getComposite(), SWT.NONE);
- getDbc().bind(errorText, b.getValidationError(),
- new BindSpec().setUpdateModel(false));
- assertEquals(null, b.getValidationError().getValue());
- enterText(text, "foo");
- assertNotNull(b.getValidationError().getValue());
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ScenariosTestCase.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ScenariosTestCase.java
deleted file mode 100644
index 9800b0e4..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ScenariosTestCase.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.scenarios;
-
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.examples.databinding.model.SampleData;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.swt.SWTObservableFactory;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Abstract base class of the JFace binding scenario test classes.
- */
-abstract public class ScenariosTestCase extends TestCase {
-
- private Composite composite;
- private DataBindingContext dbc;
- protected Display display;
- private boolean disposeDisplay = false;
- protected Shell shell;
- protected Text dummyText;
-
- private SWTObservableFactory swtObservableFactory;
-
- protected Composite getComposite() {
- return composite;
- }
-
- protected DataBindingContext getDbc() {
- return dbc;
- }
-
- protected SWTObservableFactory getSWTObservableFactory() {
- return swtObservableFactory;
- }
-
- public Shell getShell() {
- if (shell != null) {
- return shell;
- }
- Shell result = BindingScenariosTestSuite.getShell();
- if (result == null) {
- display = Display.getDefault();
- if (Display.getDefault() == null) {
- display = new Display();
- disposeDisplay = true;
- }
- shell = new Shell(display, SWT.SHELL_TRIM);
- shell.setLayout(new FillLayout());
- result = shell;
- }
- result.setText(getName()); // In the case that the shell() becomes
- // visible.
- return result;
- }
-
- protected void spinEventLoop(int secondsToWaitWithNoEvents) {
- if (!composite.isVisible() && secondsToWaitWithNoEvents > 0) {
- composite.getShell().open();
- }
- while (composite.getDisplay().readAndDispatch()) {
- // do nothing, just process events
- }
- try {
- Thread.sleep(secondsToWaitWithNoEvents * 1000);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- }
-
- protected void interact() {
- if (!getShell().isVisible()) {
- getShell().open();
- }
- while (!getShell().isDisposed()) {
- if (!getShell().getDisplay().readAndDispatch()) {
- getShell().getDisplay().sleep();
- }
- }
- }
-
- protected void setButtonSelectionWithEvents(Button button, boolean value) {
- if (button.getSelection() == value) {
- return;
- }
- button.setSelection(value);
- pushButtonWithEvents(button);
- }
-
- protected void pushButtonWithEvents(Button button) {
- button.notifyListeners(SWT.Selection, null);
- }
-
- protected void setUp() throws Exception {
- composite = new Composite(getShell(), SWT.NONE);
- composite.setLayout(new FillLayout());
- SampleData.initializeData(); // test may manipulate the data... let
- // all start from fresh
- dbc = SampleData.getDatabindingContext(composite);
- swtObservableFactory = SampleData.getSWTObservableFactory();
- dummyText = new Text(getComposite(), SWT.NONE);
- dummyText.setText("dummy");
- }
-
- protected void tearDown() throws Exception {
- getShell().setVisible(false); // same Shell may be reUsed across tests
- composite.dispose();
- composite = null;
- if (shell != null) {
- shell.close();
- shell.dispose();
- } else
- dbc.dispose();
- if (display != null && disposeDisplay) {
- display.dispose();
- }
- }
-
- protected void enterText(Text text, String string) {
- text.notifyListeners(SWT.FocusIn, null);
- text.setText(string);
- text.notifyListeners(SWT.FocusOut, null);
- }
-
- protected void assertArrayEquals(Object[] expected, Object[] actual) {
- assertEquals(Arrays.asList(expected), Arrays.asList(actual));
- }
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/SpinnerControlScenario.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/SpinnerControlScenario.java
deleted file mode 100644
index f790859e..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/SpinnerControlScenario.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.scenarios;
-
-import org.eclipse.jface.examples.databinding.model.Adventure;
-import org.eclipse.jface.examples.databinding.model.SampleData;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Spinner;
-
-/**
- * To run the tests in this class, right-click and select "Run As JUnit Plug-in
- * Test". This will also start an Eclipse instance. To clean up the launch
- * configuration, open up its "Main" tab and select "[No Application] - Headless
- * Mode" as the application to run.
- */
-
-public class SpinnerControlScenario extends ScenariosTestCase {
-
- private Adventure adventure;
-
- protected void setUp() throws Exception {
- super.setUp();
- // do any setup work here
- adventure = SampleData.WINTER_HOLIDAY;
- }
-
- protected void tearDown() throws Exception {
- // do any teardown work here
- super.tearDown();
- }
-
- public void testScenario01() {
-
- // Bind the adventure "maxNumberOfPeople" property to a spinner
- // Change the UI and verify the model changes
- // Change the model and verify the UI changes
- Spinner spinner = new Spinner(getComposite(), SWT.BORDER);
- getDbc().bind(spinner, new Property(adventure, "maxNumberOfPeople"),
- null);
- assertEquals(adventure.getMaxNumberOfPeople(), spinner.getSelection());
- // Verify the model is updated when the GUI is changed
- spinner.setSelection(5);
- assertEquals(5, adventure.getMaxNumberOfPeople());
- // Verify the GUI is updated when the model changes
- adventure.setMaxNumberOfPeople(7);
- assertEquals(7, spinner.getSelection());
- adventure.setMaxNumberOfPeople(11);
- spinEventLoop(0);
- assertEquals(11, spinner.getSelection());
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/TableScenarios.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/TableScenarios.java
deleted file mode 100644
index 4f12e773..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/TableScenarios.java
+++ /dev/null
@@ -1,412 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.scenarios;
-
-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.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.TableColumn;
-
-/**
- * To run the tests in this class, right-click and select "Run As JUnit Plug-in
- * Test". This will also start an Eclipse instance. To clean up the launch
- * configuration, open up its "Main" tab and select "[No Application] - Headless
- * Mode" as the application to run.
- */
-
-public class TableScenarios extends ScenariosTestCase {
-
- private TableViewer tableViewer;
-
- private Catalog catalog;
-
- Category category;
-
- private TableColumn firstNameColumn;
-
- private TableColumn lastNameColumn;
-
- private TableColumn stateColumn;
-
- Image[] images;
-
- private TableColumn fancyColumn;
-
- protected void setUp() throws Exception {
- super.setUp();
- getComposite().setLayout(new FillLayout());
- tableViewer = new TableViewer(getComposite());
- tableViewer.getTable().setLinesVisible(true);
- tableViewer.getTable().setHeaderVisible(true);
- firstNameColumn = new TableColumn(tableViewer.getTable(), SWT.NONE);
- firstNameColumn.setWidth(50);
- lastNameColumn = new TableColumn(tableViewer.getTable(), SWT.NONE);
- lastNameColumn.setWidth(50);
- stateColumn = new TableColumn(tableViewer.getTable(), SWT.NONE);
- stateColumn.setWidth(50);
- fancyColumn = new TableColumn(tableViewer.getTable(), SWT.NONE);
- fancyColumn.setWidth(250);
-
- catalog = SampleData.CATALOG_2005; // Lodging source
- category = SampleData.WINTER_CATEGORY;
-
- images = new Image[] {
- getShell().getDisplay().getSystemImage(SWT.ICON_ERROR),
- getShell().getDisplay().getSystemImage(SWT.ICON_WARNING),
- getShell().getDisplay().getSystemImage(SWT.ICON_INFORMATION), };
- }
-
- protected void tearDown() throws Exception {
- // do any teardown work here
- super.tearDown();
- tableViewer.getTable().dispose();
- tableViewer = null;
- firstNameColumn = null;
- lastNameColumn = null;
- stateColumn = null;
- }
-
- private String getValue(String text) {
- 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);
-
- // 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);
- assertEquals(getValue(account.getFirstName()), col_0);
- String col_1 = ((ITableLabelProvider) tableViewer
- .getLabelProvider()).getColumnText(account, 1);
- assertEquals(getValue(account.getLastName()), col_1);
- String col_2 = ((ITableLabelProvider) tableViewer
- .getLabelProvider()).getColumnText(account, 2);
- assertEquals(getValue(account.getState()), col_2);
-
- }
- }
-
- 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());
- }
-
- 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);
-//
- }
-
- 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);
-// }
- }
-
- 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");
-
- }
- **/
-}
-
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/TextControlScenario.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/TextControlScenario.java
deleted file mode 100644
index 0e671624..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/TextControlScenario.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.databinding.scenarios;
-
-import org.eclipse.jface.examples.databinding.model.Account;
-import org.eclipse.jface.examples.databinding.model.Adventure;
-import org.eclipse.jface.examples.databinding.model.SampleData;
-import org.eclipse.jface.examples.databinding.model.Transportation;
-import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.tests.databinding.BindingTestSuite;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * To run the tests in this class, right-click and select "Run As JUnit Plug-in
- * Test". This will also start an Eclipse instance. To clean up the launch
- * configuration, open up its "Main" tab and select "[No Application] - Headless
- * Mode" as the application to run.
- */
-
-public class TextControlScenario extends ScenariosTestCase {
-
- private Text text;
-
- private Adventure adventure;
-
- private Transportation transportation;
-
- Account account;
-
- protected void setUp() throws Exception {
- super.setUp();
- // do any setup work here
- adventure = SampleData.WINTER_HOLIDAY;
- transportation = SampleData.EXECUTIVE_JET;
- account = SampleData.PRESIDENT;
- text = new Text(getComposite(), SWT.BORDER);
- }
-
- protected void tearDown() throws Exception {
- text.dispose();
- text = null;
- super.tearDown();
- }
-
- public void testScenario01() {
- // Bind the adventure "name" property to a text field
- // Change the UI and verify the model changes
- // Change the model and verify the UI changes
- getDbc().bind(text, new Property(adventure, "name"), null);
- assertEquals(adventure.getName(), text.getText());
- text.setText("England");
- text.notifyListeners(SWT.FocusOut, null);
- assertEquals("England", adventure.getName());
- adventure.setName("France");
- assertEquals("France", text.getText());
- adventure.setName("Germany");
- spinEventLoop(0);
- assertEquals("Germany", text.getText());
- }
-
- public void testScenario02() {
-
- // Bind the transportation "price" property to a text field
- // This is a Double.TYPE so we check that conversion and validation
- // occurs
- // Change the UI and verify the model changes
- // Change the model and verify the UI changes
- getDbc().bind(text, new Property(transportation, "price"), null);
- assertEquals(Double.toString(transportation.getPrice()), text.getText());
- text.setText("9876.54");
- text.notifyListeners(SWT.FocusOut, null);
- assertEquals(9876.54, transportation.getPrice(), 0);
- transportation.setPrice(1234.56);
- assertEquals("1234.56", text.getText());
- }
-
- public void testScenario03() {
- // Show that the Escape key can be pressed in the middle of editing and
- // the value will revert
- // the updatePolicy for this test is TIME_LATE so it occurs when focus
- // is lost from the Text control
- getSWTObservableFactory().setUpdateTime(org.eclipse.jface.databinding.DataBindingContext.TIME_LATE);
- getDbc().bind(text, new Property(adventure, "name"), null);
- String currentText = text.getText();
- text.setText("Switzerland");
- // We do not notify FocusOut
- // Verify that the model hasn't changed
- assertEquals(currentText, adventure.getName());
- Event event = new Event();
- event.character = SWT.ESC;
- event.keyCode = 27;
- text.notifyListeners(SWT.KeyDown, event);
- // Verify that the text has reverted
- assertEquals(currentText, text.getText());
- // And that the model didn't change
- assertEquals(adventure.getName(), currentText);
- // Now change the GUI and commit this change
- currentText = "Austria";
- text.setText(currentText);
- text.notifyListeners(SWT.FocusOut, null);
- assertEquals(text.getText(), adventure.getName());
- // Now change the text again and press escape a second time
- text.setText("Turkey");
- // Send escape
- text.notifyListeners(SWT.KeyDown, event);
- // Verify it has reverted to "Austria" and not any other value, i.e. the
- // last value it displayed
- assertEquals(currentText, text.getText());
-
- }
-
- public void testScenario04() {
- // Show that the Escape key can be pressed in the middle of editing and
- // the value will revert
- // the updatePolicy for this test is TIME_EARLY so it occurs when each
- // keystroke occurs
- getSWTObservableFactory().setUpdateTime(org.eclipse.jface.databinding.DataBindingContext.TIME_EARLY);
- getDbc().bind(text, new Property(adventure, "name"), null);
- String originalName = adventure.getName();
- // Change the text field character by character and ensure that the
- // model changes
- String newName = "Switzerland";
- for (int i = 0; i < newName.length(); i++) {
- text.setText(newName.substring(0, i + 1));
- // Verify the model has changed
- assertEquals(newName.substring(0, i + 1), adventure.getName());
- }
- // Now send an escape key and verify that the model reverts
- Event event = new Event();
- event.character = SWT.ESC;
- event.keyCode = 27;
- text.notifyListeners(SWT.KeyDown, event);
- assertEquals(adventure.getName(), originalName);
- // Now send "Austria" key by key
- newName = "Austria";
- for (int i = 0; i < newName.length(); i++) {
- text.setText(newName.substring(0, i + 1));
- // Verify the model has changed
- assertEquals(newName.substring(0, i + 1), adventure.getName());
- }
- // Send a focus lost event to commit the change
- text.notifyListeners(SWT.FocusOut, null);
- // Send an escape key
- text.notifyListeners(SWT.KeyDown, event);
- // Verify that the model has changed and has not reverted
- assertEquals(newName, adventure.getName());
- }
-
- /**
- * public void testScenario05(){ // Show that nesting of properties works.
- * Adventure has defaultLodging and Lodging has name getDbc().bind(text,new
- * Property(adventure,"defaultLodging.name"),null); // Verify the GUI is
- * showing the model value
- * assertEquals(text.getText(),adventure.getDefaultLodging().getName());
- * }
- */
- public void testScenario06() {
- // // Show that partial validation works for TIME_EARLY
- // // We are using TIME_EARLY to verify that invalid states are not sent
- // to the model
- // getSWTObservableFactory().setUpdateTime(DataBindingContext.TIME_EARLY);
- // getDbc().bind(text, new Property(account, "phone"), new BindSpec(new
- // PhoneConverter(),new PhoneValidator()));
- // // Verify we have no error message for partial validation or full
- // validation yet
- // assertTrue(((String)getDbc().getPartialValidationMessage().getValue()).length()
- // == 0);
- // assertTrue(((String)getDbc().getValidationMessage().getValue()).length()
- // == 0);
- // // Update some of the phone number
- // String originalPhoneNumber = account.getPhone();
- // text.setText("999");
- // // Verify that the phone number is partially invalid and there is no
- // validation message
- // assertTrue(((String)getDbc().getPartialValidationMessage().getValue()).length()
- // > 0);
- // assertTrue(((String)getDbc().getValidationMessage().getValue()).length()
- // == 0);
- // // And that the model has not changed
- // assertEquals(account.getPhone(),originalPhoneNumber);
- // // Verify that fixing the phone removes the error and the model is
- // updated too
- // text.setText("999-888-7777");
- // assertTrue(((String)getDbc().getPartialValidationMessage().getValue()).length()
- // == 0);
- // assertEquals(account.getPhone(),"9998887777");
- }
-
- public void testScenario07() {
- // // Show that partial validation works for TIME_LATE
- // getSWTObservableFactory().setUpdateTime(DataBindingContext.TIME_LATE);
- // getDbc().bind(text, new Property(account, "phone"), new BindSpec(new
- // PhoneConverter(),new PhoneValidator()));
- // // Update some of the phone number
- // String originalPhoneNumber = account.getPhone();
- // text.setText("222");
- // // Verify that we have no completion validation message and a partial
- // one
- // assertTrue(((String)getDbc().getPartialValidationMessage().getValue()).length()
- // > 0);
- // assertTrue(((String)getDbc().getValidationMessage().getValue()).length()
- // == 0);
- // // Fix the error
- // text.setText("222-333-4444");
- // // Verify that the errors are both fixed
- // assertTrue(((String)getDbc().getPartialValidationMessage().getValue()).length()
- // == 0);
- // assertTrue(((String)getDbc().getValidationMessage().getValue()).length()
- // == 0);
- // // The model should not be changed
- // assertEquals(originalPhoneNumber,account.getPhone());
- // // Lose focus and verify that the complete validation message is
- // fixed
- // text.notifyListeners(SWT.FocusOut,null);
- // assertTrue(((String)getDbc().getValidationMessage().getValue()).length()
- // == 0);
- // // The model should be changed
- // assertEquals("2223334444",account.getPhone());
- }
-
- public void testScenario08() {
-
- if(BindingTestSuite.failingTestsDisabled(this)) {
- return;
- }
-
- // Show that the CustomBeanBindSupportFactory will automatically pick up
- // the
- // validator on the MaxNumberOfPeople property
-
- getSWTObservableFactory().setUpdateTime(org.eclipse.jface.databinding.DataBindingContext.TIME_EARLY);
- DataBindingContext parentDbc = getDbc();
- DataBindingContext childDbc = new DataBindingContext(parentDbc);
- childDbc.addBindSupportFactory(new CustomBeanBindSupportFactory(
- parentDbc));
- childDbc
- .addObservableFactory(new CustomBeanObservableFactory(parentDbc));
- childDbc.bind(text, new Property(adventure, "maxNumberOfPeople"), null);
- // make sure we can set a value inside the validator's range
- text.setText("4");
- assertEquals(4, adventure.getMaxNumberOfPeople());
- // Now try to set a value outside the validator's range
- text.setText("999");
- assertEquals(4, adventure.getMaxNumberOfPeople());
- childDbc.dispose();
- }
-
- public void testScenario09() {
-
- // Verify direct binding between a Text and Label following bugzilla
- // 118696
- getSWTObservableFactory().setUpdateTime(org.eclipse.jface.databinding.DataBindingContext.TIME_LATE);
- Label label = new Label(getComposite(), SWT.NONE);
- getDbc().bind(text, label, null);
- // Change the text
- text.setText("Frog");
- // Verify the label does not change
- assertTrue(label.getText().length() == 0);
- // Lose focus from the text field
- text.notifyListeners(SWT.FocusOut, null);
- assertEquals(label.getText(), "Frog");
-
- }
-
- public void testScenario10() {
-
- // Verify direct binding between a Text and Label following bugzilla
- // 118696 with TIME_EARLY
- getSWTObservableFactory().setUpdateTime(org.eclipse.jface.databinding.DataBindingContext.TIME_EARLY);
- Label label = new Label(getComposite(), SWT.NONE);
- getDbc().bind(text, label, null);
- // Change the text
- String newTextValue = "Frog";
- for (int i = 0; i < newTextValue.length(); i++) {
- text.setText(newTextValue.substring(0, i + 1));
- // Verify the label has changed key by key
- assertEquals(text.getText(), label.getText());
- }
- // Lose focus
- text.notifyListeners(SWT.FocusOut, null);
- // Verify the text and label are the same following a lose focus
- assertEquals(text.getText(), label.getText());
- }
-
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/smoketest/swt.xswt b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/smoketest/swt.xswt
deleted file mode 100644
index 0097d63e..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/smoketest/swt.xswt
+++ /dev/null
@@ -1,301 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xswt xmlns:x="http://sweet_swt.sf.net/xswt">
- <import xmlns="http://sweet_swt.sf.net/xswt">
- <package name="java.lang"/>
- <package name="org.eclipse.swt.widgets"/>
- <package name="org.eclipse.swt.custom"/>
- <package name="org.eclipse.swt.layout"/>
- </import>
-
- <!-- An XSWT example that uses nearly every SWT control and uses the new
- syntax wherever possible.
-
- Get XSWT at:
-
- http://xswt.sourceforge.net/updates
-
- then choose Window | Show View | Other... | XSWT Views | XSWT Preview -->
-
- <layout x:class="gridLayout"/>
-
- <label text="SWT Controls:"/>
- <tabFolder>
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" grabExcessVerticalSpace="true" horizontalAlignment="GridData.FILL" verticalAlignment="GridData.FILL"/>
-
- <composite x:id="Text">
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" horizontalAlignment="GridData.FILL"/>
- <layout x:class="gridLayout" numColumns="2"/>
-
- <composite x:style="BORDER">
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" verticalAlignment="GridData.FILL" horizontalAlignment="GridData.FILL"/>
- <layout x:class="gridLayout" numColumns="2"/>
-
- <label text="Integer:"/><text x:style="BORDER" x:id="intText" text="1"/>
- <label text="Float:"/><text x:style="BORDER" x:id="floatText" text="1.0"/>
- <label text="String:"/><text x:style="BORDER" x:id="stringText" text="The quick brown fox jumped over the lazy dog."/>
- <label text="RegexValidated String:"/><text x:style="BORDER" x:id="regexStringText" text="The quick brown fox jumped over the lazy dog."/>
- <label text="Masked String:"/><text x:style="BORDER" x:id="maskedStringText" background="208 128 128"/>
- </composite>
- <slider x:style="VERTICAL" x:id="buttonScroller">
- <layoutData x:class="gridData" verticalAlignment="GridData.FILL"/>
- </slider>
- </composite>
- <tabItem text="Text" control="Text"/>
-
- <composite x:id="Labels">
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" horizontalAlignment="GridData.FILL"/>
- <layout x:class="gridLayout" numColumns="2"/>
-
- <composite x:style="BORDER">
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" verticalAlignment="GridData.FILL" horizontalAlignment="GridData.FILL"/>
- <layout x:class="gridLayout" numColumns="1"/>
-
- <label text="Label with text"/>
- <label text="Label with image"/>
- <label text="Label with text and image"/>
- <label x:style="SEPARATOR | HORIZONTAL"><layoutData x:class="gridData" grabExcessHorizontalSpace="true" horizontalAlignment="GridData.FILL"/></label>
- <cLabel text="CLabel with text"/>
- <cLabel text="CLabel with image"/>
- <cLabel text="CLabel with text and image"/>
- </composite>
- <slider x:style="VERTICAL" x:id="textScroller"/>
- </composite>
- <tabItem text="Label / CLabel" control="Labels"/>
-
- <composite x:id="Button">
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" horizontalAlignment="GridData.FILL"/>
- <layout x:class="gridLayout" numColumns="2"/>
-
- <composite x:style="BORDER">
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" verticalAlignment="GridData.FILL" horizontalAlignment="GridData.FILL"/>
- <layout x:class="gridLayout" numColumns="2"/>
-
- <label text="Push:"/><button x:id="pushButton" text="PushButton"/>
- <label text="Arrow:"/><button x:id="arrowButton" x:style="ARROW" text="ArrowButton"/>
- <label text="Toggle:"/><button x:id="toggleButton" x:style="TOGGLE" text="ToggleButton"/>
- <label text="Check:"/><button x:style="CHECK" x:id="checkButton" text="CheckBox"/>
- <label text="Radio Group 1:"/>
- <composite x:style="BORDER" x:id="radioGroup1">
- <layoutData x:class="gridData" horizontalAlignment="GridData.FILL"/>
- <layout x:class="gridLayout" numColumns="1"/>
-
- <button x:style="RADIO" x:id="radioButton0.1" text="Radio"/>
- <button x:style="RADIO" x:id="radioButton0.2" text="Radio2" selection="true"/>
- <button x:style="RADIO" x:id="radioButton0.3" text="Radio3"/>
- </composite>
- <label text="Radio Group 2:"/>
- <composite x:style="BORDER" x:id="radioGroup2">
- <layoutData x:class="gridData" horizontalAlignment="GridData.FILL"/>
- <layout x:class="gridLayout" numColumns="1"/>
-
- <button x:style="RADIO" x:id="radioButton1.1" text="Radio"/>
- <button x:style="RADIO" x:id="radioButton1.2" text="Radio2"/>
- <button x:style="RADIO" x:id="radioButton1.3" text="Radio3"/>
- </composite>
- </composite>
- <slider x:style="VERTICAL" x:id="1buttonScroller">
- <layoutData x:class="gridData" verticalAlignment="GridData.FILL"/>
- </slider>
- </composite>
- <tabItem text="Button" control="Button"/>
-
- <composite x:id="List">
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" horizontalAlignment="GridData.FILL"/>
- <layout x:class="gridLayout" numColumns="1"/>
-
- <composite>
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" horizontalAlignment="GridData.FILL" grabExcessVerticalSpace="true" verticalAlignment="GridData.FILL"/>
- <layout x:class="fillLayout" type="VERTICAL"/>
-
- <list x:style="BORDER | V_SCROLL | MULTI"/>
- <list x:style="BORDER | V_SCROLL"/>
- </composite>
- </composite>
- <tabItem text="List" control="List"/>
-
- <composite x:id="Combos">
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" horizontalAlignment="GridData.FILL"/>
- <layout x:class="gridLayout" numColumns="2"/>
-
- <composite x:style="BORDER">
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" verticalAlignment="GridData.FILL" horizontalAlignment="GridData.FILL"/>
- <layout x:class="gridLayout" numColumns="1"/>
-
- <combo>
- <add x:p0="item1"/>
- <add x:p0="item2"/>
- <add x:p0="item3"/>
- </combo>
- <combo x:style="SIMPLE">
- <add x:p0="item1"/>
- <add x:p0="item2"/>
- <add x:p0="item3"/>
- </combo>
- <combo x:style="READ_ONLY">
- <add x:p0="item1"/>
- <add x:p0="item2"/>
- <add x:p0="item3"/>
- </combo>
- <label x:style="SEPARATOR | HORIZONTAL"><layoutData x:class="gridData" grabExcessHorizontalSpace="true" horizontalAlignment="GridData.FILL"/></label>
- <cCombo>
- <add x:p0="item1"/>
- <add x:p0="item2"/>
- <add x:p0="item3"/>
- </cCombo>
- <cCombo x:style="READ_ONLY" background="255 255 255">
- <add x:p0="item1"/>
- <add x:p0="item2"/>
- <add x:p0="item3"/>
- </cCombo>
- </composite>
- <slider x:style="VERTICAL" x:id="2buttonScroller">
- <layoutData x:class="gridData" verticalAlignment="GridData.FILL"/>
- </slider>
- </composite>
- <tabItem text="Combo / CCombo" control="Combos"/>
-
- <composite x:id="Table">
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" horizontalAlignment="GridData.FILL"/>
- <layout x:class="gridLayout" numColumns="1"/>
-
- <composite x:style="BORDER">
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" grabExcessVerticalSpace="true" horizontalAlignment="GridData.FILL" verticalAlignment="GridData.FILL"/>
- <layout x:class="gridLayout" numColumns="2"/>
-
- <table x:style="BORDER" linesVisible="true" headerVisible="true">
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" grabExcessVerticalSpace="true" horizontalAlignment="GridData.FILL" verticalAlignment="GridData.FILL"/>
-
- <tableColumn width="50" text="Done"/>
- <tableColumn width="200" text="Description"/>
- <tableColumn width="60" text="Planned"/>
- <tableColumn width="60" text="Revised"/>
- <tableColumn width="60" text="Actual"/>
- <!--<tableItem/>-->
- </table>
- </composite>
- </composite>
- <tabItem text="Table" control="Table"/>
-
- <composite x:id="Tree">
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" horizontalAlignment="GridData.FILL"/>
- <layout x:class="gridLayout" numColumns="1"/>
-
- <composite x:style="BORDER">
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" grabExcessVerticalSpace="true" horizontalAlignment="GridData.FILL" verticalAlignment="GridData.FILL"/>
- <layout x:class="gridLayout" numColumns="2"/>
-
- <tree x:style="BORDER">
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" grabExcessVerticalSpace="true" horizontalAlignment="GridData.FILL" verticalAlignment="GridData.FILL"/>
-
- <treeItem text="item">
- <x:children>
- <treeItem text="item"/>
- <treeItem text="item"/>
- <treeItem text="item">
- <x:children>
- <treeItem text="item"/>
- <treeItem text="item"/>
- <treeItem text="item"/>
- <treeItem text="item"/>
- <treeItem text="item"/>
- </x:children>
- </treeItem>
- <treeItem text="item"/>
- </x:children>
- </treeItem>
- <treeItem text="item with Image (or at least needs one)">
- <x:children>
- <treeItem text="item"/>
- <treeItem text="item"/>
- </x:children>
- </treeItem>
- <treeItem text="Another item">
- <x:children>
- <treeItem text="item"/>
- <treeItem text="item"/>
- <treeItem text="item"/>
- <treeItem text="item"/>
- <treeItem text="item"/>
- </x:children>
- </treeItem>
- </tree>
- </composite>
- </composite>
- <tabItem text="Tree" control="Tree"/>
-
- <composite x:id="TableTree">
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" horizontalAlignment="GridData.FILL"/>
- <layout x:class="gridLayout" numColumns="1"/>
-
- <composite x:style="BORDER">
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" grabExcessVerticalSpace="true" horizontalAlignment="GridData.FILL" verticalAlignment="GridData.FILL"/>
- <layout x:class="gridLayout" numColumns="2"/>
-
- <tableTree x:style="BORDER">
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" grabExcessVerticalSpace="true" horizontalAlignment="GridData.FILL" verticalAlignment="GridData.FILL"/>
-
- <tableTreeItem text="item">
- <x:children>
- <tableTreeItem text="subitem"/>
- <tableTreeItem text="subitem"/>
- </x:children>
- </tableTreeItem>
- <tableTreeItem text="item">
- <x:children>
- <tableTreeItem text="subitem"/>
- <tableTreeItem text="subitem"/>
- <tableTreeItem text="subitem"/>
- <tableTreeItem text="subitem"/>
- <tableTreeItem text="subitem"/>
- </x:children>
- </tableTreeItem>
- <tableTreeItem text="item">
- <x:children>
- <tableTreeItem text="item">
- <x:children>
- <tableTreeItem text="subitem"/>
- </x:children>
- </tableTreeItem>
- <tableTreeItem text="item">
- <x:children>
- <tableTreeItem text="subitem"/>
- <tableTreeItem text="subitem"/>
- <tableTreeItem text="subitem"/>
- <tableTreeItem text="subitem"/>
- <tableTreeItem text="subitem"/>
- </x:children>
- </tableTreeItem>
- <tableTreeItem text="item">
- <x:children>
- <tableTreeItem text="subitem"/>
- <tableTreeItem text="subitem"/>
- <tableTreeItem text="subitem"/>
- </x:children>
- </tableTreeItem>
- </x:children>
- </tableTreeItem>
- </tableTree>
- </composite>
- </composite>
- <tabItem text="TableTree" control="TableTree"/>
-
- <composite x:id="Progress">
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" horizontalAlignment="GridData.FILL"/>
- <layout x:class="gridLayout" numColumns="2"/>
-
- <composite x:style="BORDER">
- <layoutData x:class="gridData" grabExcessHorizontalSpace="true" verticalAlignment="GridData.FILL" horizontalAlignment="GridData.FILL"/>
- <layout x:class="gridLayout" numColumns="1"/>
-
- <progressBar x:style="INDETERMINATE"/>
- <progressBar x:style="INDETERMINATE | SMOOTH"/>
- <progressBar x:style="SMOOTH" minimum="0" maximum="100" selection="40"/>
- <progressBar minimum="0" maximum="100" selection="60"/>
- </composite>
- <slider x:style="VERTICAL" x:id="3textScroller"/>
- </composite>
- <tabItem text="ProgressBar" control="Progress"/>
-
- </tabFolder>
-</xswt>
-
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/AbstractGetAndSetSelectionObservableCollectionTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/AbstractGetAndSetSelectionObservableCollectionTest.java
deleted file mode 100644
index acac2de6..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/AbstractGetAndSetSelectionObservableCollectionTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * 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.databinding.swt;
-
-import junit.framework.TestCase;
-
-/**
- * @since 1.0
- *
- */
-public abstract class AbstractGetAndSetSelectionObservableCollectionTest extends TestCase {
-//
-// public void testGetSelectedObject() {
-// SelectionAwareObservableCollection observable = getSelectionAwareObservable(new String[] {"foo", "bar"});
-// assertEquals("No initial selection should be found.", null, observable.getSelectedObject());
-// setSelectedValueOfControl("bar");
-// assertEquals("bar", observable.getSelectedObject());
-// }
-//
-// /*
-// * Test method for 'org.eclipse.jface.internal.databinding.swt.CComboObservableCollection.setSelectedObject(Object)'
-// */
-// public void testSetSelectedObject() {
-// SelectionAwareObservableCollection observable = getSelectionAwareObservable(new String[] {"foo", "bar"});
-// observable.setSelectedObject("bar");
-// assertEquals("bar", getSelectedObjectOfControl());
-// observable.setSelectedObject("bar1");
-// assertEquals("bar", getSelectedObjectOfControl());
-// observable.setSelectedObject("foo");
-// assertEquals("foo", getSelectedObjectOfControl());
-// observable.setSelectedObject(null);
-// assertEquals(null, getSelectedObjectOfControl());
-// }
-//
-// protected abstract SelectionAwareObservableCollection getSelectionAwareObservable(String[] values);
-//
-// protected abstract Object getSelectedObjectOfControl();
-//
-// protected abstract void setSelectedValueOfControl(String value);
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/AutoSelectTableViewerCollectionExtendedTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/AutoSelectTableViewerCollectionExtendedTest.java
deleted file mode 100644
index 7ae318b6..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/AutoSelectTableViewerCollectionExtendedTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * 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.databinding.swt;
-
-import junit.framework.TestCase;
-
-/**
- * @since 1.0
- *
- */
-public class AutoSelectTableViewerCollectionExtendedTest extends TestCase {
-//
-// /*
-// * Test method for 'org.eclipse.jface.internal.databinding.swt.CComboObservableCollection.getSelectedObject()'
-// */
-// private TableViewer viewer;
-//
-// protected SelectionAwareObservableCollection getSelectionAwareObservable(String[] values) {
-// Shell shell = BindingScenariosTestSuite.getShell();
-// this.viewer = new TableViewer(shell, SWT.NONE);
-// TableViewerDescription description = new TableViewerDescription(viewer);
-// DataBindingContext ctx = DataBinding.createContext(new IObservableFactory[] {new AutoSelectTableViewerFactory()});
-// SelectionAwareObservableCollection observableCollection = (SelectionAwareObservableCollection) ctx.createObservable(description);
-// observableCollection.setElements(Arrays.asList(values));
-// return observableCollection;
-// }
-//
-// protected Object getSelectedObjectOfControl() {
-// StructuredSelection selection = (StructuredSelection) this.viewer.getSelection();
-// if (selection.isEmpty()) {
-// return null;
-// }
-// return selection.getFirstElement();
-// }
-//
-// protected void setSelectedValueOfControl(String value) {
-// this.viewer.setSelection(new StructuredSelection(new String[]{value}));
-// }
-//
-// /*
-// * Test method for 'org.eclipse.jface.internal.databinding.swt.CComboObservableCollection.setSelectedObject(Object)'
-// */
-// public void testAutoSelect() {
-// SelectionAwareObservableCollection observable = getSelectionAwareObservable(new String[] {"foo", "bar"});
-// assertEquals("foo", getSelectedObjectOfControl());
-// }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/AutoSelectTableViewerCollectionTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/AutoSelectTableViewerCollectionTest.java
deleted file mode 100644
index 923b7f2d..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/AutoSelectTableViewerCollectionTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * 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.databinding.swt;
-
-import junit.framework.TestCase;
-
-/**
- * @since 1.0
- *
- */
-public class AutoSelectTableViewerCollectionTest extends TestCase {
-//
-// /*
-// * Test method for 'org.eclipse.jface.internal.databinding.swt.CComboObservableCollection.getSelectedObject()'
-// */
-// private TableViewer viewer;
-//
-// protected SelectionAwareObservableCollection getSelectionAwareObservable(String[] values) {
-// Shell shell = BindingScenariosTestSuite.getShell();
-// this.viewer = new TableViewer(shell, SWT.NONE);
-// DataBindingContext ctx = DataBinding.createContext(new IObservableFactory[] {new AutoSelectTableViewerFactory()});
-// SelectionAwareObservableCollection observableCollection = (SelectionAwareObservableCollection) ctx.createObservable(new Property(viewer, ViewersProperties.CONTENT, String.class, new Boolean(true)));
-// observableCollection.setElements(Arrays.asList(values));
-// return observableCollection;
-// }
-//
-// protected Object getSelectedObjectOfControl() {
-// StructuredSelection selection = (StructuredSelection) this.viewer.getSelection();
-// if (selection.isEmpty()) {
-// return null;
-// }
-// return selection.getFirstElement();
-// }
-//
-// protected void setSelectedValueOfControl(String value) {
-// this.viewer.setSelection(new StructuredSelection(new String[]{value}));
-// }
-//
-// /*
-// * Test method for 'org.eclipse.jface.internal.databinding.swt.CComboObservableCollection.setSelectedObject(Object)'
-// */
-// public void testAutoSelect() {
-// SelectionAwareObservableCollection observable = getSelectionAwareObservable(new String[] {"foo", "bar"});
-// assertEquals("foo", getSelectedObjectOfControl());
-// }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/CComboObservableCollectionTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/CComboObservableCollectionTest.java
deleted file mode 100644
index 9e0f583e..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/CComboObservableCollectionTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * 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.databinding.swt;
-
-
-/**
- * @since 1.0
- *
- */
-public class CComboObservableCollectionTest extends AbstractGetAndSetSelectionObservableCollectionTest {
-
-// /*
-// * Test method for 'org.eclipse.jface.internal.databinding.swt.CComboObservableCollection.getSelectedObject()'
-// */
-// private CCombo ccombo;
-//
-// protected SelectionAwareObservableCollection getSelectionAwareObservable(String[] values) {
-// Shell shell = BindingScenariosTestSuite.getShell();
-// this.ccombo = new CCombo(shell, SWT.NONE);
-// for (int i = 0; i < values.length; i++) {
-// this.ccombo.add(values[i]);
-// }
-// DataBindingContext ctx = DataBinding.createContext(new IObservableFactory[] {new SWTObservableFactory()});
-// return (SelectionAwareObservableCollection) ctx.createObservable(new Property(ccombo, SWTProperties.ITEMS, String.class, new Boolean(true)));
-// }
-//
-// protected Object getSelectedObjectOfControl() {
-// int selectionIndex = this.ccombo.getSelectionIndex();
-// if (selectionIndex != -1) {
-// return this.ccombo.getItem(selectionIndex);
-// }
-// return null;
-// }
-//
-// protected void setSelectedValueOfControl(String value) {
-// this.ccombo.setText(value);
-// }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/ComboObservableCollectionTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/ComboObservableCollectionTest.java
deleted file mode 100644
index 0bf4f77b..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/ComboObservableCollectionTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * 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.databinding.swt;
-
-
-/**
- * @since 1.0
- *
- */
-public class ComboObservableCollectionTest extends AbstractGetAndSetSelectionObservableCollectionTest {
-//
-// /*
-// * Test method for 'org.eclipse.jface.internal.databinding.swt.CComboObservableCollection.getSelectedObject()'
-// */
-// private Combo combo;
-//
-// protected SelectionAwareObservableCollection getSelectionAwareObservable(String[] values) {
-// Shell shell = BindingScenariosTestSuite.getShell();
-// this.combo = new Combo(shell, SWT.NONE);
-// for (int i = 0; i < values.length; i++) {
-// this.combo.add(values[i]);
-// }
-// DataBindingContext ctx = DataBinding.createContext(new IObservableFactory[] {new SWTObservableFactory()});
-// return (SelectionAwareObservableCollection) ctx.createObservable(new Property(combo, SWTProperties.ITEMS, String.class, new Boolean(true)));
-// }
-//
-// protected Object getSelectedObjectOfControl() {
-// int selectionIndex = this.combo.getSelectionIndex();
-// if (selectionIndex != -1) {
-// return this.combo.getItem(selectionIndex);
-// }
-// return null;
-// }
-//
-// protected void setSelectedValueOfControl(String value) {
-// this.combo.select(this.combo.indexOf(value));
-// }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/CopyOfAutoSelectTableViewerCollectionExtendedTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/CopyOfAutoSelectTableViewerCollectionExtendedTest.java
deleted file mode 100644
index bc36fa7c..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/CopyOfAutoSelectTableViewerCollectionExtendedTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * 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.databinding.swt;
-
-import junit.framework.TestCase;
-
-/**
- * @since 1.0
- *
- */
-public class CopyOfAutoSelectTableViewerCollectionExtendedTest extends TestCase {
-//
-// /*
-// * Test method for 'org.eclipse.jface.internal.databinding.swt.CComboObservableCollection.getSelectedObject()'
-// */
-// private TableViewer viewer;
-//
-// protected SelectionAwareObservableCollection getSelectionAwareObservable(String[] values) {
-// Shell shell = BindingScenariosTestSuite.getShell();
-// this.viewer = new TableViewer(shell, SWT.NONE);
-// DataBindingContext ctx = DataBinding.createContext(new IObservableFactory[] {new AutoSelectTableViewerFactory()});
-// SelectionAwareObservableCollection observableCollection = (SelectionAwareObservableCollection) ctx.createObservable(new Property(viewer, ViewersProperties.CONTENT, String.class, new Boolean(true)));
-// observableCollection.setElements(Arrays.asList(values));
-// return observableCollection;
-// }
-//
-// protected Object getSelectedObjectOfControl() {
-// StructuredSelection selection = (StructuredSelection) this.viewer.getSelection();
-// if (selection.isEmpty()) {
-// return null;
-// }
-// return selection.getFirstElement();
-// }
-//
-// protected void setSelectedValueOfControl(String value) {
-// this.viewer.setSelection(new StructuredSelection(new String[]{value}));
-// }
-//
-// /*
-// * Test method for 'org.eclipse.jface.internal.databinding.swt.CComboObservableCollection.setSelectedObject(Object)'
-// */
-// public void testAutoSelect() {
-// SelectionAwareObservableCollection observable = getSelectionAwareObservable(new String[] {"foo", "bar"});
-// assertEquals("foo", getSelectedObjectOfControl());
-// }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/ListObservableCollectionTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/ListObservableCollectionTest.java
deleted file mode 100644
index ba034734..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/ListObservableCollectionTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * 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.databinding.swt;
-
-
-/**
- * @since 1.0
- *
- */
-public class ListObservableCollectionTest extends AbstractGetAndSetSelectionObservableCollectionTest {
-//
-// /*
-// * Test method for 'org.eclipse.jface.internal.databinding.swt.CComboObservableCollection.getSelectedObject()'
-// */
-// private List listControl;
-//
-// protected SelectionAwareObservableCollection getSelectionAwareObservable(String[] values) {
-// Shell shell = BindingScenariosTestSuite.getShell();
-// this.listControl = new List(shell, SWT.NONE);
-// for (int i = 0; i < values.length; i++) {
-// this.listControl.add(values[i]);
-// }
-// DataBindingContext ctx = DataBinding.createContext(new IObservableFactory[] {new SWTObservableFactory()});
-// return (SelectionAwareObservableCollection) ctx.createObservable(new Property(listControl, SWTProperties.ITEMS, String.class, new Boolean(true)));
-// }
-//
-// protected Object getSelectedObjectOfControl() {
-// int selectionIndex = this.listControl.getSelectionIndex();
-// if (selectionIndex != -1) {
-// return this.listControl.getItem(selectionIndex);
-// }
-// return null;
-// }
-//
-// protected void setSelectedValueOfControl(String value) {
-// this.listControl.setSelection(new String[] {value});
-// }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/ObservableCollectionViewerTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/ObservableCollectionViewerTest.java
deleted file mode 100644
index 8d1a584a..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/ObservableCollectionViewerTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * 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.databinding.swt;
-
-
-/**
- * @since 1.0
- *
- */
-public class ObservableCollectionViewerTest extends AbstractGetAndSetSelectionObservableCollectionTest {
-//
-// /*
-// * Test method for 'org.eclipse.jface.internal.databinding.swt.CComboObservableCollection.getSelectedObject()'
-// */
-// private AbstractListViewer viewer;
-//
-// protected SelectionAwareObservableCollection getSelectionAwareObservable(String[] values) {
-// Shell shell = BindingScenariosTestSuite.getShell();
-// this.viewer = new ListViewer(shell, SWT.NONE);
-// DataBindingContext ctx = DataBinding.createContext(new IObservableFactory[] {new SWTObservableFactory()});
-// SelectionAwareObservableCollection observableCollection = (SelectionAwareObservableCollection) ctx.createObservable(new Property(viewer, ViewersProperties.CONTENT, String.class, new Boolean(true)));
-// observableCollection.setElements(Arrays.asList(values));
-// return observableCollection;
-// }
-//
-// protected Object getSelectedObjectOfControl() {
-// StructuredSelection selection = (StructuredSelection) this.viewer.getSelection();
-// if (selection.isEmpty()) {
-// return null;
-// }
-// return selection.getFirstElement();
-// }
-//
-// protected void setSelectedValueOfControl(String value) {
-// this.viewer.setSelection(new StructuredSelection(new String[]{value}));
-// }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/TableViewerObservableCollectionTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/TableViewerObservableCollectionTest.java
deleted file mode 100644
index 309bd6ee..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/TableViewerObservableCollectionTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * 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.databinding.swt;
-
-
-/**
- * @since 1.0
- *
- */
-public class TableViewerObservableCollectionTest extends AbstractGetAndSetSelectionObservableCollectionTest {
-//
-// /*
-// * Test method for 'org.eclipse.jface.internal.databinding.swt.CComboObservableCollection.getSelectedObject()'
-// */
-// private TableViewer viewer;
-//
-// protected SelectionAwareObservableCollection getSelectionAwareObservable(String[] values) {
-// Shell shell = BindingScenariosTestSuite.getShell();
-// this.viewer = new TableViewer(shell, SWT.NONE);
-// DataBindingContext ctx = DataBinding.createContext(new IObservableFactory[] {new SWTObservableFactory()});
-// SelectionAwareObservableCollection observableCollection = (SelectionAwareObservableCollection) ctx.createObservable(new Property(viewer, ViewersProperties.CONTENT, String.class, new Boolean(true)));
-// observableCollection.setElements(Arrays.asList(values));
-// return observableCollection;
-// }
-//
-// protected Object getSelectedObjectOfControl() {
-// StructuredSelection selection = (StructuredSelection) this.viewer.getSelection();
-// if (selection.isEmpty()) {
-// return null;
-// }
-// return selection.getFirstElement();
-// }
-//
-// protected void setSelectedValueOfControl(String value) {
-// this.viewer.setSelection(new StructuredSelection(new String[]{value}));
-// }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/TextObservableValueTests.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/TextObservableValueTests.java
deleted file mode 100644
index cca96a9e..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/TextObservableValueTests.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.eclipse.jface.tests.databinding.swt;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.internal.databinding.internal.swt.TextObservableValue;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Tests to assert the inputs of the TextObservableValue constructor.
- *
- * @since 3.2
- */
-public class TextObservableValueTests extends TestCase {
- private Text text;
-
- protected void setUp() throws Exception {
- super.setUp();
-
- Shell shell = new Shell();
- text = new Text(shell, SWT.NONE);
- }
-
- /**
- * Asserts that if the a <code>null</code> Text is passed TextObservableValue throws a IAE.
- */
- public void testConstructor() {
- try {
- new TextObservableValue(null, SWT.NONE);
- fail();
- } catch (IllegalArgumentException 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);
- }
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/util/Mocks.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/util/Mocks.java
deleted file mode 100644
index cb3a7594..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/util/Mocks.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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
- * Brad Reynolds (bug 146435)
- *******************************************************************************/
-package org.eclipse.jface.tests.databinding.util;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.AssertionFailedError;
-
-public class Mocks {
-
- public static interface EqualityComparator {
- public boolean equals(Object o1, Object o2);
- }
-
- private static EqualityComparator defaultEqualityComparator = new EqualityComparator() {
- public boolean equals(Object o1, Object o2) {
- return o1 == null ? o2 == null : o1.equals(o2);
- }
- };
-
- private static EqualityComparator indifferentEqualityComparator = new EqualityComparator() {
- public boolean equals(Object o1, Object o2) {
- return true;
- }
- };
-
- private static interface Mock {
- public MockInvocationHandler getMockInvocationHandler();
- }
-
- private static Method getMockInvocationHandlerMethod;
-
- private static Method equalsMethod;
-
- static {
- try {
- getMockInvocationHandlerMethod = Mock.class.getMethod(
- "getMockInvocationHandler", new Class[0]);
- equalsMethod = Object.class.getMethod("equals",
- new Class[] { Object.class });
- } catch (Exception e) {
- // ignore, will lead to NullPointerExceptions later on
- }
- }
-
- private static final class MockInvocationHandler implements
- InvocationHandler {
-
- private class MethodCall {
- private final Method method;
-
- private final Object[] args;
-
- private Object returnValue = null;
-
- public MethodCall(Method method, Object[] args) {
- this.method = method;
- this.args = args;
- }
-
- public boolean equals(Object obj) {
- if (!(obj instanceof MethodCall)) {
- return false;
- }
- MethodCall other = (MethodCall) obj;
- if (other.method != method
- || (other.args == null && args != null)
- || (other.args != null && args == null)
- || (args != null && other.args.length != args.length)) {
- return false;
- }
- if (args != null) {
- for (int i = 0; i < args.length; i++) {
- if (!equalityComparator.equals(args[i], other.args[i])) {
- return false;
- }
- }
- }
- return true;
- }
-
- public void setReturnValue(Object object) {
- returnValue = object;
- }
-
- public Object getReturnValue() {
- return returnValue;
- }
- }
-
- List previousCallHistory = null;
-
- List currentCallHistory = new ArrayList();
-
- private final boolean ordered;
-
- private final EqualityComparator equalityComparator;
-
- public MockInvocationHandler(boolean ordered,
- EqualityComparator equalityComparator) {
- this.ordered = ordered;
- this.equalityComparator = equalityComparator;
- }
-
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
- if (getMockInvocationHandlerMethod.equals(method)) {
- return this;
- }
- if (equalsMethod.equals(method)) {
- return new Boolean(proxy == args[0]);
- }
- MethodCall methodCall = new MethodCall(method, args);
- if (previousCallHistory != null) {
- // we are in replay mode
- int indexOfMethodCall = previousCallHistory.indexOf(methodCall);
- if (indexOfMethodCall != -1) {
- // copy return value over to this method call
- methodCall.setReturnValue(((MethodCall) previousCallHistory
- .get(indexOfMethodCall)).getReturnValue());
- } else {
- throw new AssertionFailedError("unexpected method call: "
- + method.getName());
- }
- if (ordered) {
- if (previousCallHistory.size() <= currentCallHistory.size()) {
- throw new AssertionFailedError("extra method call: "
- + method.getName());
- }
- MethodCall previousCall = (MethodCall) previousCallHistory
- .get(currentCallHistory.size());
- if (!methodCall.equals(previousCall)) {
- throw new AssertionFailedError(
- "different method call (expected:"
- + previousCall.method.getName()
- + ", actual:" + method.getName() + ")");
- }
- }
- }
- currentCallHistory.add(methodCall);
- Class returnType = method.getReturnType();
- if (returnType.isPrimitive() && void.class != returnType) {
- Object result = null;
- Object returnValue = methodCall.getReturnValue();
-
- if (returnType == boolean.class) {
- result = (returnValue != null) ? (Boolean) returnValue
- : Boolean.FALSE;
- } else if (returnType == byte.class) {
- result = (returnValue != null) ? (Byte) returnValue
- : new Byte((byte) 0);
- } else if (returnType == char.class) {
- result = (returnValue != null) ? (Character) returnValue
- : new Character((char) 0);
- } else if (returnType == short.class) {
- result = (returnValue != null) ? (Short) returnValue
- : new Short((short) 0);
- } else if (returnType == int.class) {
- result = (returnValue != null) ? (Integer) returnValue
- : new Integer(0);
- } else if (returnType == long.class) {
- result = (returnValue != null) ? (Long) returnValue
- : new Long(0);
- } else if (returnType == float.class) {
- result = (returnValue != null) ? (Float) returnValue
- : new Float(0);
- } else if (returnType == double.class) {
- result = (returnValue != null) ? (Double) returnValue
- : new Double(0);
- }
-
- return result;
- }
- return methodCall.getReturnValue();
- }
-
- public void replay() {
- previousCallHistory = currentCallHistory;
- currentCallHistory = new ArrayList();
- }
-
- public void verify() {
- if (previousCallHistory == null) {
- if (currentCallHistory.size() == 0) {
- // mock object was not used at all
- return;
- }
- throw new AssertionFailedError("unexpected");
- }
- if (ordered) {
- int numMissingCalls = previousCallHistory.size()
- - currentCallHistory.size();
- if (numMissingCalls > 0) {
- throw new AssertionFailedError("missing method calls ("
- + numMissingCalls + ")");
- }
- for (int i = 0; i < previousCallHistory.size(); i++) {
- if (!previousCallHistory.get(i).equals(
- currentCallHistory.get(i))) {
- throw new AssertionFailedError(
- "method call did not match (" + i + " of "
- + currentCallHistory.size() + ")");
- }
- }
- } else {
- for (Iterator it = previousCallHistory.iterator(); it.hasNext();) {
- MethodCall methodCall = (MethodCall) it.next();
- if (!currentCallHistory.contains(methodCall)) {
- throw new AssertionFailedError("missing method call:"
- + methodCall.method.getName());
- }
- }
- }
- }
-
- public void reset() {
- previousCallHistory = null;
- currentCallHistory = new ArrayList();
- }
-
- public void setLastReturnValue(Object object) {
- MethodCall methodCall = (MethodCall) currentCallHistory
- .get(currentCallHistory.size() - 1);
- methodCall.setReturnValue(object);
- }
- }
-
- /**
- * Creates a mock object that neither looks at the order of method calls nor
- * at the arguments.
- *
- * @param interfaceType
- * @return a mock object that checks for the order of method invocations but
- * not for equality of method arguments
- */
- public static Object createRelaxedMock(Class interfaceType) {
- return createMock(interfaceType, false, indifferentEqualityComparator);
- }
-
- /**
- * Creates a mock object that does not look at the arguments, but checks
- * that the order of calls is as expected.
- *
- * @param interfaceType
- * @return a mock object that checks for the order of method invocations but
- * not for equality of method arguments
- */
- public static Object createOrderedMock(Class interfaceType) {
- return createMock(interfaceType, true, indifferentEqualityComparator);
- }
-
- /**
- * creates a fussy mock object
- *
- * @param interfaceType
- * @return a mock object that checks for the order of method invocations and
- * for equality of method arguments
- */
- public static Object createMock(Class interfaceType) {
- return createMock(interfaceType, true, defaultEqualityComparator);
- }
-
- /**
- * creates a fussy mock object with a comparator
- *
- * @param interfaceType
- * @return a mock object that checks for the order of method invocations and
- * uses the given comparator to compare method arguments
- */
- public static Object createMock(Class interfaceType,
- EqualityComparator equalityComparator) {
- return createMock(interfaceType, true, equalityComparator);
- }
-
- private static Object createMock(Class interfaceType, boolean ordered,
- EqualityComparator equalityComparator) {
- if (!interfaceType.isInterface()) {
- throw new IllegalArgumentException();
- }
- MockInvocationHandler mockInvocationHandler = new MockInvocationHandler(
- ordered, equalityComparator);
- Object newProxyInstance = Proxy.newProxyInstance(Mocks.class
- .getClassLoader(), new Class[] { interfaceType, Mock.class },
- mockInvocationHandler);
- return newProxyInstance;
- }
-
- public static void startChecking(Object mock) {
- getMockInvocationHandler(mock).replay();
- }
-
- public static void verify(Object mock) {
- getMockInvocationHandler(mock).verify();
- }
-
- public static void reset(Object mock) {
- getMockInvocationHandler(mock).reset();
- }
-
- private static MockInvocationHandler getMockInvocationHandler(Object mock) {
- return ((Mock) mock).getMockInvocationHandler();
- }
-
- public static void setLastReturnValue(Object mock, Object object) {
- getMockInvocationHandler(mock).setLastReturnValue(object);
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/util/MocksTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/util/MocksTest.java
deleted file mode 100644
index affa6fcf..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/util/MocksTest.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Brad Reynolds.
- * 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:
- * Brad Reynolds - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.tests.databinding.util;
-
-import java.lang.reflect.UndeclaredThrowableException;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for the Mocks class.
- *
- * @since 1.1
- */
-public class MocksTest extends TestCase {
- private IPrimitive primitiveMock;
-
- private static boolean uninitializedBoolean;
- private static byte unitializedByte;
- private static char unitializedChar;
- private static short unitializedShort;
- private static int unitializedInt;
- private static long unitializedLong;
- private static float unitializedFloat;
- private static double unitializedDouble;
-
- protected void setUp() throws Exception {
- primitiveMock = (IPrimitive) Mocks.createRelaxedMock(IPrimitive.class);
- }
-
- public void testPrimitiveBooleanReturnType() throws Exception {
- try {
- boolean value = primitiveMock.getBoolean();
- assertEquals(uninitializedBoolean, value);
- } catch (UndeclaredThrowableException e) {
- fail("exception should not have been thrown");
- }
- }
-
- public void testPrimitiveBooleanSetLastReturnValue() throws Exception {
- Boolean value = Boolean.TRUE;
- primitiveMock.getBoolean();
- Mocks.setLastReturnValue(primitiveMock, value);
- Mocks.startChecking(primitiveMock);
-
- assertEquals(value.booleanValue(), primitiveMock.getBoolean());
- }
-
- public void testPrimitiveByteReturnType() throws Exception {
- try {
- byte value = primitiveMock.getByte();
- assertEquals(unitializedByte, value);
- } catch (UndeclaredThrowableException e) {
- fail("exception should not have been thrown");
- }
- }
-
- public void testPrimitiveByteSetLastReturnValue() throws Exception {
- Byte value = new Byte((byte) 1);
- primitiveMock.getByte();
- Mocks.setLastReturnValue(primitiveMock, value);
- Mocks.startChecking(primitiveMock);
-
- assertEquals(value.byteValue(), primitiveMock.getByte());
- }
-
- public void testPrimitiveCharReturnType() throws Exception {
- try {
- char value = primitiveMock.getChar();
- assertEquals(unitializedChar, value);
- } catch (UndeclaredThrowableException e) {
- fail("exception should not have been thrown");
- }
- }
-
- public void testPrimitiveCharSetLastReturnValue() throws Exception {
- Character value = new Character('a');
- primitiveMock.getChar();
- Mocks.setLastReturnValue(primitiveMock, value);
- Mocks.startChecking(primitiveMock);
-
- assertEquals(value.charValue(), primitiveMock.getChar());
- }
-
- public void testPrimitiveShortReturnType() throws Exception {
- try {
- short value = primitiveMock.getShort();
- assertEquals(unitializedShort, value);
- } catch (UndeclaredThrowableException e) {
- fail("exception should not have been thrown");
- }
- }
-
- public void testPrimitiveShortSetLastReturnValue() throws Exception {
- Short value = new Short((short) 1);
- primitiveMock.getShort();
- Mocks.setLastReturnValue(primitiveMock, value);
- Mocks.startChecking(primitiveMock);
-
- assertEquals(value.shortValue(), primitiveMock.getShort());
- }
-
- public void testPrimitiveIntReturnType() throws Exception {
- try {
- int value = primitiveMock.getInt();
- assertEquals(unitializedInt, value);
- } catch (UndeclaredThrowableException e) {
- fail("exception should not have been thrown");
- }
- }
-
- public void testPrimitiveIntSetLastReturnValue() throws Exception {
- Integer value = new Integer(1);
- primitiveMock.getInt();
- Mocks.setLastReturnValue(primitiveMock, value);
- Mocks.startChecking(primitiveMock);
-
- assertEquals(value.intValue(), primitiveMock.getInt());
- }
-
- public void testPrimitiveLongReturnType() throws Exception {
- try {
- long value = primitiveMock.getLong();
- assertEquals(unitializedLong, value);
- } catch (UndeclaredThrowableException e) {
- fail("exception should not have been thrown");
- }
- }
-
- public void testPrimitiveLongSetLastReturnValue() throws Exception {
- Long value = new Long(1);
- primitiveMock.getLong();
- Mocks.setLastReturnValue(primitiveMock, value);
- Mocks.startChecking(primitiveMock);
-
- assertEquals(value.longValue(), primitiveMock.getLong());
- }
-
- public void testPrimitiveFloatReturnType() throws Exception {
- try {
- float value = primitiveMock.getFloat();
- assertEquals(unitializedFloat, value, 0);
- } catch (UndeclaredThrowableException e) {
- fail("exception should not have been thrown");
- }
- }
-
- public void testPrimitiveFloatSetLastReturnValue() throws Exception {
- Float value = new Float(1);
- primitiveMock.getFloat();
- Mocks.setLastReturnValue(primitiveMock, value);
- Mocks.startChecking(primitiveMock);
-
- assertEquals(value.floatValue(), primitiveMock.getFloat(), 0);
- }
-
- public void testPrimitiveDoubleReturnType() throws Exception {
- try {
- double value = primitiveMock.getDouble();
- assertEquals(unitializedDouble, value, 0);
- } catch (UndeclaredThrowableException e) {
- fail("exception should not have been thrown");
- }
- }
-
- public void testPrimitiveDoubleSetLastReturnValue() throws Exception {
- Double value = new Double(1);
- primitiveMock.getDouble();
- Mocks.setLastReturnValue(primitiveMock, value);
- Mocks.startChecking(primitiveMock);
-
- assertEquals(value.doubleValue(), primitiveMock.getDouble(), 0);
- }
-
- private interface IPrimitive {
- public boolean getBoolean();
-
- public byte getByte();
-
- public char getChar();
-
- public short getShort();
-
- public int getInt();
-
- public long getLong();
-
- public float getFloat();
-
- public double getDouble();
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/examples/model/PersonTests.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/examples/model/PersonTests.java
deleted file mode 100644
index 1c9b9c1a..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/examples/model/PersonTests.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Brad Reynolds.
- * 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:
- * Brad Reynolds - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.tests.examples.model;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.examples.databinding.model.SimplePerson;
-
-/**
- * @since 3.2
- *
- */
-public class PersonTests extends TestCase {
- public void testSetName() {
- SimplePerson person = new SimplePerson();
- Listener listener = new Listener();
-
- person.addPropertyChangeListener(listener);
- assertEquals(0, listener.count);
- assertNull(listener.lastEvent);
- person.setState("new state"); //$NON-NLS-1$
-
- assertEquals(1, listener.count);
- assertNotNull(listener.lastEvent);
- assertEquals("state", listener.lastEvent.getPropertyName()); //$NON-NLS-1$
- assertEquals("", listener.lastEvent.getOldValue());
- assertEquals("new state", listener.lastEvent.getNewValue()); //$NON-NLS-1$
- assertEquals("new state", person.getState());
- }
-
- private class Listener implements PropertyChangeListener {
- private int count;
- private PropertyChangeEvent lastEvent;
-
- public void propertyChange(PropertyChangeEvent evt) {
- count++;
- this.lastEvent = evt;
- }
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/internal/ValueBindingTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/internal/ValueBindingTest.java
deleted file mode 100644
index ddc7be3c..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/internal/ValueBindingTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Brad Reynolds 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:
- * Brad Reynolds - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.tests.internal.databinding.internal;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.databinding.BindSpec;
-import org.eclipse.jface.databinding.DataBindingContext;
-import org.eclipse.jface.databinding.observable.value.AbstractObservableValue;
-import org.eclipse.jface.internal.databinding.internal.ValueBinding;
-
-/**
- * @since 3.2
- *
- */
-public class ValueBindingTest extends TestCase {
- /**
- * Bug 152543.
- *
- * @throws Exception
- */
- public void testNoUpdateTargetFromModel() throws Exception {
- BindSpec spec = new BindSpec();
- spec.setUpdateModel(false);
- spec.setUpdateTarget(false);
-
- try {
- new ValueBinding(new DataBindingContext(),
- new ObservableValueStub(), new ObservableValueStub(), spec);
- } catch (Exception e) {
- fail();
- }
- }
-
- private static class ObservableValueStub extends AbstractObservableValue {
- protected Object doGetValue() {
- // do nothing
- return null;
- }
-
- public Object getValueType() {
- // do nothing
- return null;
- }
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/internal/observable/UnmodifiableObservableListTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/internal/observable/UnmodifiableObservableListTest.java
deleted file mode 100644
index ac23b382..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/internal/observable/UnmodifiableObservableListTest.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Cerner 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:
- * Brad Reynolds - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.tests.internal.databinding.internal.observable;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.databinding.observable.Diffs;
-import org.eclipse.jface.databinding.observable.IChangeListener;
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.databinding.observable.IStaleListener;
-import org.eclipse.jface.databinding.observable.Observables;
-import org.eclipse.jface.databinding.observable.list.IListChangeListener;
-import org.eclipse.jface.databinding.observable.list.IObservableList;
-import org.eclipse.jface.databinding.observable.list.ListDiff;
-import org.eclipse.jface.databinding.observable.list.ListDiffEntry;
-import org.eclipse.jface.databinding.observable.list.ObservableList;
-
-public class UnmodifiableObservableListTest extends TestCase {
- ObservableList unmodifiable;
- ObservableList mutable;
-
- protected void setUp() throws Exception {
- List list = new ArrayList();
- list.add("1");
- list.add("2");
-
- mutable = new MutableObservableList(list, String.class);
- unmodifiable = (ObservableList) Observables.unmodifiableObservableList(mutable);
- }
-
- public void testFiresChangeEvents() throws Exception {
- ChangeCounter mutableListener = new ChangeCounter();
- ChangeCounter unmodifiableListener = new ChangeCounter();
-
- mutable.addChangeListener(mutableListener);
- unmodifiable.addChangeListener(unmodifiableListener);
-
- assertEquals(0, mutableListener.count);
- assertEquals(0, unmodifiableListener.count);
- mutable.add("3");
- assertEquals(1, mutableListener.count);
- assertEquals(1, unmodifiableListener.count);
- }
-
- public void testFiresListChangeEvents() throws Exception {
- ListChangeCounter mutableListener = new ListChangeCounter();
- ListChangeCounter unmodifiableListener = new ListChangeCounter();
-
- mutable.addListChangeListener(mutableListener);
- unmodifiable.addListChangeListener(unmodifiableListener);
-
- assertEquals(0, mutableListener.count);
- assertEquals(0, unmodifiableListener.count);
-
- String element = "3";
- mutable.add(element);
- assertEquals(1, mutableListener.count);
- assertEquals(mutable, mutableListener.source);
- assertEquals(1, mutableListener.diff.getDifferences().length);
-
- ListDiffEntry difference = mutableListener.diff.getDifferences()[0];
- assertEquals(element, difference.getElement());
- assertTrue(difference.isAddition());
- assertEquals(3, mutable.size());
-
- assertEquals(1, unmodifiableListener.count);
- assertEquals(unmodifiable, unmodifiableListener.source);
- assertEquals(1, unmodifiableListener.diff.getDifferences().length);
-
- difference = unmodifiableListener.diff.getDifferences()[0];
- assertEquals(element, difference.getElement());
- assertTrue(difference.isAddition());
- assertEquals(3, unmodifiable.size());
- }
-
- public void testFiresStaleEvents() throws Exception {
- StaleCounter mutableListener = new StaleCounter();
- StaleCounter unmodifiableListener = new StaleCounter();
-
- mutable.addStaleListener(mutableListener);
- unmodifiable.addStaleListener(unmodifiableListener);
-
- assertEquals(0, mutableListener.count);
- assertEquals(0, unmodifiableListener.count);
- mutable.setStale(true);
- assertEquals(1, mutableListener.count);
- assertEquals(mutable, mutableListener.source);
- assertTrue(mutable.isStale());
- assertEquals(1, unmodifiableListener.count);
- assertEquals(unmodifiable, unmodifiableListener.source);
- assertTrue(unmodifiable.isStale());
- }
-
- public void testIsStale() throws Exception {
- assertFalse(mutable.isStale());
- assertFalse(unmodifiable.isStale());
- mutable.setStale(true);
- assertTrue(mutable.isStale());
- assertTrue(unmodifiable.isStale());
- }
-
- public void testSetStaleOnUnmodifiableList() throws Exception {
- try {
- unmodifiable.setStale(true);
- fail("UnsupportedOperationException should have been thrown");
- } catch (UnsupportedOperationException e) {
- }
- }
-
- private static class StaleCounter implements IStaleListener {
- int count;
- IObservable source;
-
- public void handleStale(IObservable source) {
- count++;
- this.source = source;
- }
- }
-
- private static class ChangeCounter implements IChangeListener {
- int count;
- IObservable source;
- public void handleChange(IObservable source) {
- count++;
- this.source = source;
- }
- }
-
- private static class ListChangeCounter implements IListChangeListener {
- int count;
- IObservableList source;
- ListDiff diff;
-
- public void handleListChange(IObservableList source, ListDiff diff) {
- count++;
- this.source = source;
- this.diff = diff;
- }
- }
-
- private static class MutableObservableList extends ObservableList {
- /**
- * @param wrappedList
- * @param elementType
- */
- public MutableObservableList(List wrappedList, Object elementType) {
- super(wrappedList, elementType);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.internal.databinding.provisional.observable.list.ObservableList#add(java.lang.Object)
- */
- public boolean add(Object o) {
- boolean result = wrappedList.add(o);
- fireListChange(Diffs.createListDiff(Diffs.createListDiffEntry(wrappedList.size() - 1, true, o)));
-
- return result;
- }
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/internal/viewers/SVOCWLTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/internal/viewers/SVOCWLTest.java
deleted file mode 100644
index 37a44740..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/internal/viewers/SVOCWLTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Brad Reynolds.
- * 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:
- * Brad Reynolds - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.tests.internal.databinding.internal.viewers;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.internal.databinding.internal.viewers.StructuredViewerObservableCollectionWithLabels;
-import org.eclipse.jface.internal.databinding.provisional.conversion.IConverter;
-import org.eclipse.jface.internal.databinding.provisional.observable.mapping.IMultiMapping;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @since 3.2
- *
- */
-public class SVOCWLTest extends TestCase {
- private Shell shell;
-
- private TableViewer viewer;
-
- /**
- * {@inheritDoc}
- */
- protected void setUp() throws Exception {
- super.setUp();
- shell = new Shell();
- shell.setLayout(new FillLayout());
- viewer = new TableViewer(shell);
- }
-
- private static class SVOCWL extends
- StructuredViewerObservableCollectionWithLabels {
- Object[] addedElements = null;
-
- public SVOCWL(StructuredViewer structuredViewer) {
- super(structuredViewer);
- }
-
- protected void addToViewer(Object element) {
- }
-
- protected void addToViewer(Object[] elements) {
- addedElements = elements;
- }
-
- protected void addToViewer(int index, Object element) {
- }
-
- public void init(IMultiMapping labelMapping) {
- }
-
- protected void removeFromViewer(Object element) {
- }
-
- protected void removeFromViewer(Object[] elements) {
- }
-
- public void updateElements(Object[] elements) {
- }
-
- public void setModelToTargetConverters(IConverter[] converters) {
- }
- };
-
- /**
- * Asserts the order that items are added to the viewer is maintained in
- * {@link StructuredViewerObservableCollectionWithLabels#addAll(java.util.Collection)}.
- */
- public void test_addAllOrder() {
- SVOCWL svocwl = new SVOCWL(viewer);
-
- List list = new ArrayList();
- for (int i = 0; i < 10; i++) {
- list.add(Integer.toString(i));
- }
-
- svocwl.addAll(list);
- assertNotNull(svocwl.addedElements);
- assertEquals(list.size(), svocwl.size());
- for (int i = 0; i < list.size(); i++) {
- assertEquals(list.get(i), svocwl.addedElements[i]);
- }
- }
-
- /**
- * Asserts that if <code>null</code> is passed to addAll() a NPE is
- * thrown.
- */
- public void test_checkNull() {
- SVOCWL sv = new SVOCWL(viewer);
-
- try {
- sv.addAll(null);
- fail();
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/internal/viewers/SelectionProviderSingleSelectionObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/internal/viewers/SelectionProviderSingleSelectionObservableValueTest.java
deleted file mode 100644
index 9353bb9b..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/internal/viewers/SelectionProviderSingleSelectionObservableValueTest.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Brad Reynolds.
- * 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:
- * Brad Reynolds - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.tests.internal.databinding.internal.viewers;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.databinding.observable.value.IValueChangeListener;
-import org.eclipse.jface.databinding.observable.value.ValueDiff;
-import org.eclipse.jface.internal.databinding.internal.viewers.SelectionProviderSingleSelectionObservableValue;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Tests for SelectionProviderSingleSelectionObservableValue.
- *
- * @since 1.1
- */
-public class SelectionProviderSingleSelectionObservableValueTest extends TestCase {
- private ISelectionProvider selectionProvider;
- private TableViewer viewer;
- private static String[] model = new String[] { "0", "1" };
-
- /*
- * (non-Javadoc)
- *
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- Shell shell = new Shell();
- viewer = new TableViewer(shell, SWT.NONE);
- viewer.setContentProvider(new ContentProvider());
- viewer.setInput(model);
- selectionProvider = viewer;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- Shell shell = viewer.getTable().getShell();
- if (!shell.isDisposed())
- shell.dispose();
- }
-
- public void testConstructorIllegalArgumentException() {
- try {
- new SelectionProviderSingleSelectionObservableValue(null);
- fail();
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * Asserts that when a selection is set on the viewer:
- * <ul>
- * <li>the selection is available in the observable</li>
- * <li>Value change events are fired with appropriate diff values</li>
- * </ul>
- */
- public void testGetSetValue() {
- SelectionProviderSingleSelectionObservableValue observable = new SelectionProviderSingleSelectionObservableValue(
- selectionProvider);
- ChangeListener listener = new ChangeListener();
- observable.addValueChangeListener(listener);
- assertNull(observable.getValue());
-
- selectionProvider.setSelection(new StructuredSelection(model[0]));
- assertEquals(1, listener.count);
- assertNull(listener.diff.getOldValue());
- assertEquals(model[0], listener.diff.getNewValue());
- assertEquals(observable, listener.source);
- assertEquals(model[0], observable.getValue());
-
- selectionProvider.setSelection(new StructuredSelection(model[1]));
- assertEquals(2, listener.count);
- assertEquals(model[0], listener.diff.getOldValue());
- assertEquals(model[1], listener.diff.getNewValue());
- assertEquals(observable, listener.source);
- assertEquals(model[1], observable.getValue());
-
- selectionProvider.setSelection(StructuredSelection.EMPTY);
- assertEquals(3, listener.count);
- assertEquals(model[1], listener.diff.getOldValue());
- assertNull(listener.diff.getNewValue());
- assertEquals(observable, listener.source);
- assertEquals(null, observable.getValue());
- }
-
- private class ChangeListener implements IValueChangeListener {
- int count = 0;
-
- IObservable source;
-
- ValueDiff diff;
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.databinding.observable.value.IValueChangeListener#handleValueChange(org.eclipse.jface.databinding.observable.value.IObservableValue,
- * org.eclipse.jface.databinding.observable.value.ValueDiff)
- */
- public void handleValueChange(IObservableValue source, ValueDiff diff) {
- count++;
- this.source = source;
- this.diff = diff;
- }
- }
-
- private class ContentProvider implements IStructuredContentProvider {
- public void dispose() {
- // TODO Auto-generated method stub
-
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // TODO Auto-generated method stub
-
- }
-
- public Object[] getElements(Object inputElement) {
- return (String[]) inputElement;
- }
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/provisional/observable/AbstractObservableTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/provisional/observable/AbstractObservableTest.java
deleted file mode 100644
index f521f64a..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/provisional/observable/AbstractObservableTest.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Brad Reynolds.
- * 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:
- * Brad Reynolds - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.tests.internal.databinding.provisional.observable;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.databinding.observable.AbstractObservable;
-import org.eclipse.jface.databinding.observable.IChangeListener;
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.databinding.observable.IStaleListener;
-
-/**
- * Tests for AbstractObservable.
- *
- * @since 1.1
- */
-public class AbstractObservableTest extends TestCase {
- private ObservableStub stub;
-
- protected void setUp() throws Exception {
- stub = new ObservableStub();
- }
-
- public void testStaleListener() throws Exception {
- assertFalse(stub.hasListeners());
-
- StaleListener listener1 = new StaleListener();
-
- assertFalse(stub.firstListenerAdded);
- stub.addStaleListener(listener1);
- assertTrue(stub.firstListenerAdded);
- stub.firstListenerAdded = false; //reset
-
- assertTrue(stub.hasListeners());
- assertEquals(0, listener1.count);
-
- stub.fireStale();
-
- assertEquals(1, listener1.count);
- assertSame(stub, listener1.source);
-
- //Add a second stale listener as 1 vs. 2 listener code is different.
- StaleListener listener2 = new StaleListener();
- assertEquals(0, listener2.count);
- stub.addStaleListener(listener2);
- stub.fireStale();
-
- assertEquals(2, listener1.count);
- assertEquals(1, listener2.count);
-
- //Add a third stale listener as 2 vs. 3 or greater code is different.
- StaleListener listener3 = new StaleListener();
- stub.addStaleListener(listener3);
- assertEquals(0, listener3.count);
-
- stub.fireStale();
-
- assertEquals(3, listener1.count);
- assertEquals(2, listener2.count);
- assertEquals(1, listener3.count);
-
- assertFalse(stub.lastListenerRemoved);
- stub.removeStaleListener(listener1);
- stub.removeStaleListener(listener2);
- stub.removeStaleListener(listener3);
- assertTrue(stub.lastListenerRemoved);
-
- assertFalse(stub.hasListeners());
- }
-
- public void testChangeListener() throws Exception {
- assertFalse(stub.hasListeners());
-
- ChangeListener listener1 = new ChangeListener();
-
- assertFalse(stub.firstListenerAdded);
- stub.addChangeListener(listener1);
- assertTrue(stub.firstListenerAdded);
- stub.firstListenerAdded = false;
-
- assertTrue(stub.hasListeners());
- assertEquals(0, listener1.count);
-
- stub.fireChange();
-
- assertEquals(1, listener1.count);
- assertSame(stub, listener1.source);
-
- //Add a second listener as the 1 vs. 2 listener code is different.
- ChangeListener listener2 = new ChangeListener();
- stub.addChangeListener(listener2);
- assertEquals(0, listener2.count);
-
- stub.fireChange();
- assertEquals(2, listener1.count);
- assertEquals(1, listener2.count);
-
- //Add a third listener as the 2 vs. 3 or greater code is different.
- ChangeListener listener3 = new ChangeListener();
- stub.addChangeListener(listener3);
- assertEquals(0, listener3.count);
-
- stub.fireChange();
-
- assertEquals(3, listener1.count);
- assertEquals(2, listener2.count);
- assertEquals(1, listener3.count);
-
- assertFalse(stub.lastListenerRemoved);
- stub.removeChangeListener(listener1);
- stub.removeChangeListener(listener2);
- stub.removeChangeListener(listener3);
- assertTrue(stub.lastListenerRemoved);
-
- assertFalse(stub.hasListeners());
- }
-
- public void testHasListenersWithChangeAndStaleListeners() throws Exception {
- ChangeListener changeListener = new ChangeListener();
- StaleListener staleListener = new StaleListener();
-
- assertFalse(stub.hasListeners());
- assertFalse(stub.firstListenerAdded);
- assertFalse(stub.lastListenerRemoved);
-
- stub.addChangeListener(changeListener);
- assertTrue(stub.hasListeners());
- assertTrue(stub.firstListenerAdded);
- assertFalse(stub.lastListenerRemoved);
-
- //reset
- stub.firstListenerAdded = false;
- stub.lastListenerRemoved = false;
-
- stub.addStaleListener(staleListener);
- assertTrue(stub.hasListeners());
- assertFalse(stub.firstListenerAdded);
- assertFalse(stub.lastListenerRemoved);
-
- stub.removeChangeListener(changeListener);
- assertTrue(stub.hasListeners());
- assertFalse(stub.firstListenerAdded);
- assertFalse(stub.lastListenerRemoved);
-
- stub.removeStaleListener(staleListener);
- assertFalse(stub.hasListeners());
- assertFalse(stub.firstListenerAdded);
- assertTrue(stub.lastListenerRemoved);
- }
-
- private class ChangeListener implements IChangeListener {
- int count;
- IObservable source;
-
- public void handleChange(IObservable source) {
- count++;
- this.source = source;
- }
- }
-
- private class StaleListener implements IStaleListener {
- int count;
- IObservable source;
-
- public void handleStale(IObservable source) {
- count++;
- this.source = source;
- }
- }
-
- private static class ObservableStub extends AbstractObservable {
- private boolean firstListenerAdded;
- private boolean lastListenerRemoved;
-
- protected Object doGetValue() {
- return null;
- }
-
- public Object getValueType() {
- return null;
- }
-
- protected void fireStale() {
- super.fireStale();
- }
-
- protected void fireChange() {
- super.fireChange();
- }
-
- public boolean isStale() {
- return false;
- }
-
- protected boolean hasListeners() {
- return super.hasListeners();
- }
-
- protected void firstListenerAdded() {
- firstListenerAdded = true;
- }
-
- protected void lastListenerRemoved() {
- lastListenerRemoved = true;
- }
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/provisional/observable/ObservablesTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/provisional/observable/ObservablesTest.java
deleted file mode 100644
index b2f13cc7..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/provisional/observable/ObservablesTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Cerner 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:
- * Brad Reynolds - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.tests.internal.databinding.provisional.observable;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.databinding.observable.Observables;
-import org.eclipse.jface.databinding.observable.list.IObservableList;
-import org.eclipse.jface.databinding.observable.list.ObservableList;
-import org.eclipse.jface.internal.databinding.internal.observable.UnmodifiableObservableList;
-
-public class ObservablesTest extends TestCase {
- public void testUnmodifableObservableListExceptions() throws Exception {
- try {
- Observables.unmodifiableObservableList(null);
- fail("IllegalArgumentException should have been thrown.");
- } catch (IllegalArgumentException e) {
- }
- }
-
- public void testUnmodifiableObservableList() throws Exception {
- IObservableList unmodifiable = Observables.unmodifiableObservableList(new ObservableListStub(new ArrayList(0), String.class));
- assertTrue(unmodifiable instanceof UnmodifiableObservableList);
- }
-
- private static class ObservableListStub extends ObservableList {
- /**
- * @param wrappedList
- * @param elementType
- */
- protected ObservableListStub(List wrappedList, Object elementType) {
- super(wrappedList, elementType);
- }
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/provisional/viewers/ViewersObservableFactoryTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/provisional/viewers/ViewersObservableFactoryTest.java
deleted file mode 100644
index 74ca0f05..00000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/provisional/viewers/ViewersObservableFactoryTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Brad Reynolds.
- * 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:
- * Brad Reynolds - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jface.tests.internal.databinding.provisional.viewers;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.databinding.observable.IObservable;
-import org.eclipse.jface.internal.databinding.internal.viewers.SelectionProviderSingleSelectionObservableValue;
-import org.eclipse.jface.internal.databinding.provisional.description.Property;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersObservableFactory;
-import org.eclipse.jface.internal.databinding.provisional.viewers.ViewersProperties;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.ListViewer;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Tests for ViewerObservableFactory.
- *
- * @since 1.1
- */
-public class ViewersObservableFactoryTest extends TestCase {
- private Shell shell;
- private ViewersObservableFactory factory;
-
- protected void setUp() throws Exception {
- shell = new Shell();
- factory = new ViewersObservableFactory();
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- if (shell != null && !shell.isDisposed()) {
- shell.dispose();
- }
- }
-
- public void testGetObservableForSelectionProvider() throws Exception {
- ISelectionProvider selectionProvider = new SelectionProviderStub();
- IObservable observable = factory.createObservable(new Property(selectionProvider, ViewersProperties.SINGLE_SELECTION));
-
- assertNotNull(observable);
- assertTrue(observable instanceof SelectionProviderSingleSelectionObservableValue);
- }
-
- public void testGetObservableForTableViewer() throws Exception {
- TableViewer viewer = new TableViewer(shell);
- IObservable observable = factory.createObservable(new Property(viewer, ViewersProperties.SINGLE_SELECTION));
-
- assertNotNull(observable);
- assertTrue(observable instanceof SelectionProviderSingleSelectionObservableValue);
- }
-
- public void testGetObservableForListViewer() throws Exception {
- ListViewer viewer = new ListViewer(shell);
- IObservable observable = factory.createObservable(new Property(viewer, ViewersProperties.SINGLE_SELECTION));
-
- assertNotNull(observable);
- assertTrue(observable instanceof SelectionProviderSingleSelectionObservableValue);
- }
-
- /**
- * Empty stub to satisfy the requirement that we have a type of ISelectionProvider that is not a viewer.
- */
- private class SelectionProviderStub implements ISelectionProvider {
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- }
-
- public ISelection getSelection() {
- return null;
- }
-
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- }
-
- public void setSelection(ISelection selection) {
- }
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/test.xml b/tests/org.eclipse.jface.tests.databinding/test.xml
deleted file mode 100644
index 73284d59..00000000
--- a/tests/org.eclipse.jface.tests.databinding/test.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0"?>
-
-<project name="testsuite" default="run" basedir=".">
- <!-- The property ${eclipse-home} should be passed into this script -->
- <!-- Set a meaningful default value for when it is not. -->
- <property name="eclipse-home" value="${basedir}\..\.."/>
-
- <!-- sets the properties eclipse-home, and library-file -->
- <property name="plugin-name" value="org.eclipse.jface.tests.databinding"/>
- <property name="library-file"
- value="${eclipse-home}/plugins/org.eclipse.test/library.xml"/>
-
- <!-- This target holds all initialization code that needs to be done for -->
- <!-- all tests that are to be run. Initialization for individual tests -->
- <!-- should be done within the body of the suite target. -->
- <target name="init">
- <tstamp/>
- <delete>
- <fileset dir="${eclipse-home}" includes="org*.xml"/>
- </delete>
- </target>
-
- <!-- This target defines the tests that need to be run. -->
- <target name="suite">
- <property name="sniff-folder"
- value="${eclipse-home}/databinding_sniff_folder"/>
- <delete dir="${sniff-folder}" quiet="true"/>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${sniff-folder}"/>
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname"
- value="org.eclipse.jface.tests.databinding.BindingTestSuite"/>
- </ant>
- </target>
-
- <!-- This target holds code to cleanup the testing environment after -->
- <!-- after all of the tests have been run. You can use this target to -->
- <!-- delete temporary files that have been created. -->
- <target name="cleanup">
- </target>
-
- <!-- This target runs the test suite. Any actions that need to happen -->
- <!-- after all the tests have been run should go here. -->
- <target name="run" depends="init,suite,cleanup">
- <ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
- <property name="includes" value="org*.xml"/>
- <property name="output-file" value="${plugin-name}.xml"/>
- </ant>
- </target>
-</project>

Back to the top