# HG changeset patch # User Frank Benoit # Date 1240437758 -7200 # Node ID e884642ad36e2299231150d91749a2340cd3be7d # Parent 5d5bd660917fdee0667047d043f06e797e10433f more work on examples diff -r 5d5bd660917f -r e884642ad36e org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet007ColorLabelProvider.d --- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet007ColorLabelProvider.d Wed Apr 22 18:59:26 2009 +0200 +++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet007ColorLabelProvider.d Thu Apr 23 00:02:38 2009 +0200 @@ -61,124 +61,119 @@ persons.add(new Person("David Gilmour", Person.MALE)); final Display display = new Display(); - Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() { - public void run() { - Shell shell = new Shell(display); - shell.setText("Gender Bender"); - shell.setLayout(new GridLayout()); + Realm.runWithDefault(SWTObservables.getRealm(display), dgRunnable(() { + Shell shell = new Shell(display); + shell.setText("Gender Bender"); + shell.setLayout(new GridLayout()); + + Table table = new Table(shell, SWT.SINGLE | SWT.H_SCROLL + | SWT.V_SCROLL | SWT.BORDER); + GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); + table.setLayoutData(gridData); + table.setHeaderVisible(true); + table.setLinesVisible(true); + TableColumn column = new TableColumn(table, SWT.NONE); + column.setText("No"); + column.setWidth(20); + column = new TableColumn(table, SWT.NONE); + column.setText("Name"); + column.setWidth(100); + final TableViewer viewer = new TableViewer(table); - Table table = new Table(shell, SWT.SINGLE | SWT.H_SCROLL - | SWT.V_SCROLL | SWT.BORDER); - GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); - table.setLayoutData(gridData); - table.setHeaderVisible(true); - table.setLinesVisible(true); - TableColumn column = new TableColumn(table, SWT.NONE); - column.setText("No"); - column.setWidth(20); - column = new TableColumn(table, SWT.NONE); - column.setText("Name"); - column.setWidth(100); - final TableViewer viewer = new TableViewer(table); + IObservableList observableList = Observables + .staticObservableList(persons); + ObservableListContentProvider contentProvider = new ObservableListContentProvider(); + + viewer.setContentProvider(contentProvider); - IObservableList observableList = Observables - .staticObservableList(persons); - ObservableListContentProvider contentProvider = new ObservableListContentProvider(); - - viewer.setContentProvider(contentProvider); + // this does not have to correspond to the columns in the table, + // we just list all attributes that affect the table content. + IObservableMap[] attributes = BeansObservables.observeMaps( + contentProvider.getKnownElements(), Class.fromType!(Person), + [ "name", "gender" ]); - // this does not have to correspond to the columns in the table, - // we just list all attributes that affect the table content. - IObservableMap[] attributes = BeansObservables.observeMaps( - contentProvider.getKnownElements(), Person.class, - new String[] { "name", "gender" }); + class ColorLabelProvider : ObservableMapLabelProvider + , ITableColorProvider { + Color male; + Color female; + + this(IObservableMap[] attributes) { + super(attributes); + male = display.getSystemColor(SWT.COLOR_BLUE); + female = new Color(display, 255, 192, 203); + } - class ColorLabelProvider extends ObservableMapLabelProvider - implements ITableColorProvider { - Color male = display.getSystemColor(SWT.COLOR_BLUE); + // to drive home the point that attributes does not have to + // match + // the columns + // in the table, we change the column text as follows: + public String getColumnText(Object element, int index) { + if (index is 0) { + return Integer + .toString(persons.indexOf(element) + 1); + } + return (cast(Person) element).getName(); + } - Color female = new Color(display, 255, 192, 203); + public Color getBackground(Object element, int index) { + return null; + } - ColorLabelProvider(IObservableMap[] attributes) { - super(attributes); - } + public Color getForeground(Object element, int index) { + if (index is 0) + return null; + Person person = cast(Person) element; + return (person.getGender() is Person.MALE) ? male + : female; + } - // to drive home the point that attributes does not have to - // match - // the columns - // in the table, we change the column text as follows: - public String getColumnText(Object element, int index) { - if (index == 0) { - return Integer - .toString(persons.indexOf(element) + 1); - } - return ((Person) element).getName(); - } + public void dispose() { + super.dispose(); + female.dispose(); + } + } + viewer.setLabelProvider(new ColorLabelProvider(attributes)); + + viewer.setInput(cast(Object)observableList); + + table.getColumn(0).pack(); - public Color getBackground(Object element, int index) { - return null; - } - - public Color getForeground(Object element, int index) { - if (index == 0) - return null; - Person person = (Person) element; - return (person.getGender() == Person.MALE) ? male - : female; - } - - public void dispose() { - super.dispose(); - female.dispose(); + Button button = new Button(shell, SWT.PUSH); + button.setText("Toggle Gender"); + button.addSelectionListener(new class() SelectionAdapter { + public void widgetSelected(SelectionEvent arg0) { + StructuredSelection selection = cast(StructuredSelection) viewer + .getSelection(); + if (selection !is null && !selection.isEmpty()) { + Person person = cast(Person) selection + .getFirstElement(); + person + .setGender((person.getGender() is Person.MALE) ? Person.FEMALE + : Person.MALE); } } - viewer.setLabelProvider(new ColorLabelProvider(attributes)); + }); - viewer.setInput(observableList); - - table.getColumn(0).pack(); + shell.setSize(300, 400); + shell.open(); - Button button = new Button(shell, SWT.PUSH); - button.setText("Toggle Gender"); - button.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent arg0) { - StructuredSelection selection = (StructuredSelection) viewer - .getSelection(); - if (selection != null && !selection.isEmpty()) { - Person person = (Person) selection - .getFirstElement(); - person - .setGender((person.getGender() == Person.MALE) ? Person.FEMALE - : Person.MALE); - } - } - }); - - shell.setSize(300, 400); - shell.open(); - - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) - display.sleep(); - } + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); } - }); + })); display.dispose(); } static class Person { static final int MALE = 0; - static final int FEMALE = 1; - private String name; - private int gender; + private PropertyChangeSupport changeSupport; - private PropertyChangeSupport changeSupport = new PropertyChangeSupport( - this); - - Person(String name, int gender) { + this(String name, int gender) { + changeSupport = new PropertyChangeSupport(this); this.name = name; this.gender = gender; } diff -r 5d5bd660917f -r e884642ad36e org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet008ComputedValue.d --- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet008ComputedValue.d Wed Apr 22 18:59:26 2009 +0200 +++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet008ComputedValue.d Thu Apr 23 00:02:38 2009 +0200 @@ -44,38 +44,36 @@ */ public static void main(String[] args) { final Display display = new Display(); - Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() { - public void run() { - Shell shell = new Shell(display); - shell.setLayout(new FillLayout()); + Realm.runWithDefault(SWTObservables.getRealm(display), dgRunnable(() { + Shell shell = new Shell(display); + shell.setLayout(new FillLayout()); + + final UI ui = new UI(shell); + final Data data = new Data(); - final UI ui = new UI(shell); - final Data data = new Data(); - - // Bind the UI to the Data. - DataBindingContext dbc = new DataBindingContext(); - dbc.bindValue(SWTObservables.observeText(ui.firstName, - SWT.Modify), data.firstName); - dbc.bindValue(SWTObservables.observeText(ui.lastName, - SWT.Modify), data.lastName); + // Bind the UI to the Data. + DataBindingContext dbc = new DataBindingContext(); + dbc.bindValue(SWTObservables.observeText(ui.firstName, + SWT.Modify), data.firstName, null, null); + dbc.bindValue(SWTObservables.observeText(ui.lastName, + SWT.Modify), data.lastName, null, null); - // Construct the formatted name observable. - FormattedName formattedName = new FormattedName(data.firstName, - data.lastName); - - // Bind the formatted name Text to the formatted name - // observable. - dbc.bindValue(SWTObservables.observeText(ui.formattedName, - SWT.None), formattedName, new UpdateValueStrategy(false, UpdateValueStrategy.POLICY_NEVER), null); + // Construct the formatted name observable. + FormattedName formattedName = new FormattedName(data.firstName, + data.lastName); - shell.pack(); - shell.open(); - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) - display.sleep(); - } + // Bind the formatted name Text to the formatted name + // observable. + dbc.bindValue(SWTObservables.observeText(ui.formattedName, + SWT.None), formattedName, new UpdateValueStrategy(false, UpdateValueStrategy.POLICY_NEVER), null); + + shell.pack(); + shell.open(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); } - }); + })); display.dispose(); } @@ -93,39 +91,39 @@ * * @since 3.2 */ - static class FormattedName extends ComputedValue { + static class FormattedName : ComputedValue { private IObservableValue firstName; private IObservableValue lastName; - FormattedName(IObservableValue firstName, IObservableValue lastName) { + this(IObservableValue firstName, IObservableValue lastName) { this.firstName = firstName; this.lastName = lastName; } protected Object calculate() { - String lastName = (String) this.lastName.getValue(); - String firstName = (String) this.firstName.getValue(); - lastName = (lastName != null && lastName.length() > 0) ? lastName + String lastName = stringcast( this.lastName.getValue()); + String firstName = stringcast( this.firstName.getValue()); + lastName = (lastName !is null && lastName.length() > 0) ? lastName : "[Last Name]"; - firstName = (firstName != null && firstName.length() > 0) ? firstName + firstName = (firstName !is null && firstName.length() > 0) ? firstName : "[First Name]"; StringBuffer buffer = new StringBuffer(); buffer.append(lastName).append(", ").append(firstName); - return buffer.toString(); + return stringcast(buffer.toString()); } } static class Data { - final WritableValue firstName; + const WritableValue firstName; - final WritableValue lastName; + const WritableValue lastName; - Data() { - firstName = new WritableValue("", String.class); - lastName = new WritableValue("", String.class); + this() { + firstName = new WritableValue(stringcast(""), Class.fromType!(String)); + lastName = new WritableValue(stringcast(""), Class.fromType!(String)); } } @@ -134,22 +132,22 @@ * * @since 3.2 */ - static class UI extends Composite { - final Text firstName; + static class UI : Composite { + const Text firstName; - final Text lastName; + const Text lastName; - final Text formattedName; + const Text formattedName; - UI(Composite parent) { + this(Composite parent) { super(parent, SWT.NONE); GridLayoutFactory.swtDefaults().numColumns(2).applyTo(this); - new Label(this, SWT.NONE).setText("First Name:"); - new Label(this, SWT.NONE).setText("Last Name"); + (new Label(this, SWT.NONE)).setText("First Name:"); + (new Label(this, SWT.NONE)).setText("Last Name"); - GridDataFactory gdf = GridDataFactory.swtDefaults().align(SWT.FILL, + GridDataFactory gdf = GridDataFactory.swtDefaults().align_(SWT.FILL, SWT.FILL).grab(true, false); firstName = new Text(this, SWT.BORDER); gdf.applyTo(firstName); @@ -158,7 +156,7 @@ gdf.applyTo(lastName); gdf = GridDataFactory.swtDefaults().span(2, 1).grab(true, false) - .align(SWT.FILL, SWT.BEGINNING); + .align_(SWT.FILL, SWT.BEGINNING); Label label = new Label(this, SWT.NONE); label.setText("Formatted Name:"); gdf.applyTo(label); diff -r 5d5bd660917f -r e884642ad36e org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet009TableViewer.d --- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet009TableViewer.d Wed Apr 22 18:59:26 2009 +0200 +++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet009TableViewer.d Thu Apr 23 00:02:38 2009 +0200 @@ -19,11 +19,16 @@ import java.util.LinkedList; import java.util.List; -import org.eclipse.core.databinding.beans.BeanProperties; +//import org.eclipse.core.databinding.beans.BeanProperties; +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.beans.BeansObservables; import org.eclipse.core.databinding.observable.Realm; import org.eclipse.core.databinding.observable.list.WritableList; +import org.eclipse.core.databinding.observable.map.IObservableMap; import org.eclipse.jface.databinding.swt.SWTObservables; -import org.eclipse.jface.databinding.viewers.ViewerSupport; +//import org.eclipse.jface.databinding.viewers.ViewerSupport; +import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; +import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; @@ -42,26 +47,27 @@ // In an RCP application, the threading Realm will be set for you // automatically by the Workbench. In an SWT application, you can do // this once, wrpping your binding method call. - Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() { - public void run() { + Realm.runWithDefault(SWTObservables.getRealm(display), dgRunnable(() { - ViewModel viewModel = new ViewModel(); - Shell shell = new View(viewModel).createShell(); + ViewModel viewModel = new ViewModel(); + Shell shell = (new View(viewModel)).createShell(); - // The SWT event loop - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) { - display.sleep(); - } + // The SWT event loop + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) { + display.sleep(); } } - }); + })); } // Minimal JavaBeans support public static abstract class AbstractModelObject { - private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport( + private PropertyChangeSupport propertyChangeSupport; + this(){ + propertyChangeSupport = new PropertyChangeSupport( this); + } public void addPropertyChangeListener(PropertyChangeListener listener) { propertyChangeSupport.addPropertyChangeListener(listener); @@ -91,11 +97,11 @@ } // The data model class. This is normally a persistent class of some sort. - static class Person extends AbstractModelObject { + static class Person : AbstractModelObject { // A property... String name = "John Smith"; - public Person(String name) { + public this(String name) { this.name = name; } @@ -106,7 +112,7 @@ public void setName(String name) { String oldValue = this.name; this.name = name; - firePropertyChange("name", oldValue, name); + firePropertyChange("name", stringcast(oldValue), stringcast(name)); } } @@ -118,8 +124,9 @@ // ro retrieve, this ViewModel just instantiates a model object to edit. static class ViewModel { // The model to bind - private List people = new LinkedList(); - { + private List people; + this(){ + people = new LinkedList(); people.add(new Person("Steve Northover")); people.add(new Person("Grant Gayed")); people.add(new Person("Veronika Irvine")); @@ -139,7 +146,7 @@ private ViewModel viewModel; private Table committers; - public View(ViewModel viewModel) { + public this(ViewModel viewModel) { this.viewModel = viewModel; } @@ -154,9 +161,24 @@ // Set up data binding. TableViewer peopleViewer = new TableViewer(committers); - ViewerSupport.bind(peopleViewer, new WritableList(viewModel - .getPeople(), Person.class), BeanProperties.value( - Person.class, "name")); + + ///ViewerSupport.bind(peopleViewer, new WritableList(viewModel + /// .getPeople(), Class.fromType!(Person)), BeanProperties.value( + /// Class.fromType!(Person), "name")); + + // Create a standard content provider + ObservableListContentProvider peopleViewerContentProvider = + new ObservableListContentProvider(); + peopleViewer.setContentProvider(peopleViewerContentProvider); + + // And a standard label provider that maps columns + IObservableMap[] attributeMaps = BeansObservables.observeMaps( + peopleViewerContentProvider.getKnownElements(), Class.fromType!(Person), + [ "name" ]); + peopleViewer.setLabelProvider(new ObservableMapLabelProvider(attributeMaps)); + + // Now set the Viewer's input + peopleViewer.setInput(new WritableList(viewModel.getPeople(), Class.fromType!(Person))); column.pack(); diff -r 5d5bd660917f -r e884642ad36e org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet010MasterDetail.d --- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet010MasterDetail.d Wed Apr 22 18:59:26 2009 +0200 +++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet010MasterDetail.d Thu Apr 23 00:02:38 2009 +0200 @@ -26,6 +26,7 @@ import org.eclipse.jface.databinding.viewers.ViewersObservables; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ListViewer; +import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Display; @@ -40,50 +41,49 @@ public class Snippet010MasterDetail { public static void main(String[] args) { final Display display = new Display(); - Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() { - public void run() { - Shell shell = new Shell(display); - shell.setLayout(new GridLayout()); + Realm.runWithDefault(SWTObservables.getRealm(display), dgRunnable(() { + Shell shell = new Shell(display); + shell.setLayout(new GridLayout()); - Person[] persons = new Person[] { new Person("Me"), - new Person("Myself"), new Person("I") }; + Person[] persons = [ new Person("Me"), + new Person("Myself"), new Person("I") ]; - ListViewer viewer = new ListViewer(shell); - viewer.setContentProvider(new ArrayContentProvider()); - viewer.setInput(persons); + ListViewer viewer = new ListViewer(shell); + viewer.setContentProvider(new ArrayContentProvider!(Object)()); + viewer.setInput(new ArrayWrapperObject(persons)); - Text name = new Text(shell, SWT.BORDER | SWT.READ_ONLY); + Text name = new Text(shell, SWT.BORDER | SWT.READ_ONLY); - // 1. Observe changes in selection. - IObservableValue selection = ViewersObservables - .observeSingleSelection(viewer); + // 1. Observe changes in selection. + IObservableValue selection = ViewersObservables + .observeSingleSelection(cast(Viewer)viewer); - // 2. Observe the name property of the current selection. - IObservableValue detailObservable = BeansObservables - .observeDetailValue(selection, "name", String.class); + // 2. Observe the name property of the current selection. + IObservableValue detailObservable = BeansObservables + .observeDetailValue(SWTObservables.getRealm(display), selection, "name", Class.fromType!(String)); - // 3. Bind the Text widget to the name detail (selection's - // name). - new DataBindingContext().bindValue(SWTObservables.observeText( - name, SWT.None), detailObservable, - new UpdateValueStrategy(false, - UpdateValueStrategy.POLICY_NEVER), null); + // 3. Bind the Text widget to the name detail (selection's + // name). + (new DataBindingContext()).bindValue(SWTObservables.observeText( + name, SWT.None), detailObservable, + new UpdateValueStrategy(false, + UpdateValueStrategy.POLICY_NEVER), null); - shell.open(); - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) - display.sleep(); - } + shell.open(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); } - }); + })); display.dispose(); } public static class Person { private String name; - private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this); + private PropertyChangeSupport changeSupport; - Person(String name) { + this(String name) { + changeSupport = new PropertyChangeSupport(this); this.name = name; } diff -r 5d5bd660917f -r e884642ad36e org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet011ValidateMultipleBindingsSnippet.d --- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet011ValidateMultipleBindingsSnippet.d Wed Apr 22 18:59:26 2009 +0200 +++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet011ValidateMultipleBindingsSnippet.d Thu Apr 23 00:02:38 2009 +0200 @@ -12,6 +12,7 @@ module org.eclipse.jface.examples.databinding.snippets.Snippet011ValidateMultipleBindingsSnippet; import java.lang.all; +import tango.io.Stdout; import org.eclipse.core.databinding.DataBindingContext; import org.eclipse.core.databinding.UpdateValueStrategy; @@ -41,7 +42,7 @@ public class Snippet011ValidateMultipleBindingsSnippet { public static void main(String[] args) { Realm.runWithDefault(SWTObservables.getRealm(Display.getDefault()), - new Runnable() { + new class() Runnable { public void run() { Snippet011ValidateMultipleBindingsSnippet.run(); } @@ -56,25 +57,25 @@ DataBindingContext dbc = new DataBindingContext(); dbc.bindValue(SWTObservables.observeText(view.text1, SWT.Modify), - model.value1, new UpdateValueStrategy() + model.value1, (new UpdateValueStrategy()) .setAfterConvertValidator(new CrossFieldValidator( model.value2)), null); dbc.bindValue(SWTObservables.observeText(view.text2, SWT.Modify), - model.value2, new UpdateValueStrategy() + model.value2, (new UpdateValueStrategy()) .setAfterConvertValidator(new CrossFieldValidator( model.value1)), null); // DEBUG - print to show value change - model.value1.addValueChangeListener(new IValueChangeListener() { + model.value1.addValueChangeListener(new class() IValueChangeListener { public void handleValueChange(ValueChangeEvent event) { - System.out.println("Value 1: " + model.value1.getValue()); + Stdout.formatln("Value 1: {}", model.value1.getValue()); } }); // DEBUG - print to show value change - model.value2.addValueChangeListener(new IValueChangeListener() { + model.value2.addValueChangeListener(new class() IValueChangeListener { public void handleValueChange(ValueChangeEvent event) { - System.out.println("Value 2: " + model.value2.getValue()); + Stdout.formatln("Value 2: {}", model.value2.getValue()); } }); @@ -92,7 +93,7 @@ * @since 3.2 * */ - private static final class CrossFieldValidator implements IValidator { + private static final class CrossFieldValidator : IValidator { /** * */ @@ -101,12 +102,12 @@ /** * @param model */ - private CrossFieldValidator(IObservableValue other) { + private this(IObservableValue other) { this.other = other; } public IStatus validate(Object value) { - if (!value.equals(other.getValue())) { + if (!value.opEquals(other.getValue())) { return ValidationStatus.ok(); } return ValidationStatus.error("values cannot be the same"); @@ -114,15 +115,19 @@ } static class Model { - WritableValue value1 = new WritableValue(); - WritableValue value2 = new WritableValue(); + WritableValue value1; + WritableValue value2; + this(){ + value1 = new WritableValue(); + value2 = new WritableValue(); + } } static class View { Text text1; Text text2; - View(Composite composite) { + this(Composite composite) { composite.setLayout(new GridLayout(2, true)); text1 = new Text(composite, SWT.BORDER); text2 = new Text(composite, SWT.BORDER); diff -r 5d5bd660917f -r e884642ad36e org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet012CompositeUpdater.d --- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet012CompositeUpdater.d Wed Apr 22 18:59:26 2009 +0200 +++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet012CompositeUpdater.d Thu Apr 23 00:02:38 2009 +0200 @@ -89,7 +89,7 @@ static Timer timer = new Timer(true); - static class Counter extends WritableValue { + static class Counter : WritableValue { Counter() { super(new Integer(0), Integer.class); scheduleIncrementTask(); diff -r 5d5bd660917f -r e884642ad36e org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet013TableViewerEditing.d --- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet013TableViewerEditing.d Wed Apr 22 18:59:26 2009 +0200 +++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet013TableViewerEditing.d Thu Apr 23 00:02:38 2009 +0200 @@ -98,7 +98,7 @@ } // The data model class. This is normally a persistent class of some sort. - static class Person extends AbstractModelObject { + static class Person : AbstractModelObject { // A property... String name = "John Smith"; @@ -148,7 +148,7 @@ * * @since 3.3 */ - private static class InlineEditingSupport extends + private static class InlineEditingSupport : ObservableValueEditingSupport { private CellEditor cellEditor; diff -r 5d5bd660917f -r e884642ad36e org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet014WizardDialog.d --- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet014WizardDialog.d Wed Apr 22 18:59:26 2009 +0200 +++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet014WizardDialog.d Thu Apr 23 00:02:38 2009 +0200 @@ -44,11 +44,11 @@ */ public class Snippet014WizardDialog { - static class FirstWizardPage extends WizardPage { - private final class SingleDigitValidator implements IValidator { + static class FirstWizardPage : WizardPage { + private final class SingleDigitValidator : IValidator { public IStatus validate(Object value) { Integer i = (Integer) value; - if (i == null) { + if (i is null) { return ValidationStatus .info("Please enter a value."); } @@ -85,7 +85,7 @@ } } - static class SecondWizardPage extends WizardPage { + static class SecondWizardPage : WizardPage { protected SecondWizardPage() { super("Second", "Second Page", ImageDescriptor .createFromImage(new Image(Display.getDefault(), 16, 16))); @@ -114,7 +114,7 @@ IObservableValue dateValue = new WritableValue(null, Date.class); } - static class SampleWizard extends Wizard { + static class SampleWizard : Wizard { private SampleWizardModel model = new SampleWizardModel(); @@ -150,7 +150,7 @@ dialog.open(); // The SWT event loop Display display = Display.getCurrent(); - while (dialog.getShell() != null + while (dialog.getShell() !is null && !dialog.getShell().isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); diff -r 5d5bd660917f -r e884642ad36e org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet017TableViewerWithDerivedColumns.d --- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet017TableViewerWithDerivedColumns.d Wed Apr 22 18:59:26 2009 +0200 +++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet017TableViewerWithDerivedColumns.d Thu Apr 23 00:02:38 2009 +0200 @@ -103,7 +103,7 @@ private static Person UNKNOWN = new Person("unknown", null, null); // The data model class. This is normally a persistent class of some sort. - static class Person extends AbstractModelObject { + static class Person : AbstractModelObject { // A property... String name = "Donald Duck"; Person mother; @@ -245,7 +245,7 @@ peopleViewer.addFilter(new ViewerFilter() { public bool select(Viewer viewer, Object parentElement, Object element) { - return element != UNKNOWN; + return element !is UNKNOWN; } }); diff -r 5d5bd660917f -r e884642ad36e org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet018CheckboxTableViewerCheckedSelection.d --- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet018CheckboxTableViewerCheckedSelection.d Wed Apr 22 18:59:26 2009 +0200 +++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet018CheckboxTableViewerCheckedSelection.d Thu Apr 23 00:02:38 2009 +0200 @@ -144,7 +144,7 @@ } // The data model class. - static class Person extends AbstractModelObject { + static class Person : AbstractModelObject { private String name; private Set friends = new HashSet(); @@ -177,7 +177,7 @@ // The ViewModel is responsible for getting the objects to edit from the // data access tier. Since this snippet doesn't have any persistent objects // to retrieve, this ViewModel just instantiates a model object to edit. - static class ViewModel extends AbstractModelObject { + static class ViewModel : AbstractModelObject { private List people = new ArrayList(); public List getPeople() { @@ -304,13 +304,13 @@ InputDialog dlg = new InputDialog(shell, "Add Person", "Enter name:", "", new IInputValidator() { public String isValid(String newText) { - if (newText == null - || newText.length() == 0) + if (newText is null + || newText.length() is 0) return "Name cannot be empty"; return null; } }); - if (dlg.open() == Window.OK) { + if (dlg.open() is Window.OK) { Person person = new Person(); person.setName(dlg.getValue()); people.add(person); @@ -341,7 +341,7 @@ IObservableValue personSelected = new ComputedValue(bool.TYPE) { protected Object calculate() { - return bool.valueOf(selectedPerson.getValue() != null); + return bool.valueOf(selectedPerson.getValue() !is null); } }; dbc.bindValue(SWTObservables.observeEnabled(removePersonButton), diff -r 5d5bd660917f -r e884642ad36e org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet019TreeViewerWithListFactory.d --- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet019TreeViewerWithListFactory.d Wed Apr 22 18:59:26 2009 +0200 +++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet019TreeViewerWithListFactory.d Thu Apr 23 00:02:38 2009 +0200 @@ -155,7 +155,7 @@ TreeItem parentItem = selectedItem.getParentItem(); Bean parent; int index; - if (parentItem == null) { + if (parentItem is null) { parent = input; index = beanViewer.getTree().indexOf(selectedItem); } else { @@ -182,10 +182,10 @@ pasteButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(final SelectionEvent e) { Bean copy = (Bean) clipboard.getValue(); - if (copy == null) + if (copy is null) return; Bean parent = getSelectedBean(); - if (parent == null) + if (parent is null) parent = input; List list = new ArrayList(parent.getList()); @@ -259,7 +259,7 @@ .observeSingleSelection(beanViewer); IObservableValue beanSelected = new ComputedValue(bool.TYPE) { protected Object calculate() { - return bool.valueOf(beanViewerSelection.getValue() != null); + return bool.valueOf(beanViewerSelection.getValue() !is null); } }; dbc.bindValue(SWTObservables.observeEnabled(addChildBeanButton), @@ -272,7 +272,7 @@ dbc.bindValue(SWTObservables.observeEnabled(pasteButton), new ComputedValue(bool.TYPE) { protected Object calculate() { - return bool.valueOf(clipboard.getValue() != null); + return bool.valueOf(clipboard.getValue() !is null); } }); @@ -309,13 +309,13 @@ } public List getList() { - if (list == null) + if (list is null) return null; return new ArrayList(list); } public void setList(List list) { - if (list != null) + if (list !is null) list = new ArrayList(list); changeSupport.firePropertyChange("list", this.list, this.list = list); diff -r 5d5bd660917f -r e884642ad36e org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet020TreeViewerWithSetFactory.d --- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet020TreeViewerWithSetFactory.d Wed Apr 22 18:59:26 2009 +0200 +++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet020TreeViewerWithSetFactory.d Thu Apr 23 00:02:38 2009 +0200 @@ -157,7 +157,7 @@ Bean bean = (Bean) selectedItem.getData(); TreeItem parentItem = selectedItem.getParentItem(); Bean parent; - if (parentItem == null) + if (parentItem is null) parent = input; else parent = (Bean) parentItem.getData(); @@ -181,10 +181,10 @@ pasteButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(final SelectionEvent e) { Bean copy = (Bean) clipboard.getValue(); - if (copy == null) + if (copy is null) return; Bean parent = getSelectedBean(); - if (parent == null) + if (parent is null) parent = input; Set set = new HashSet(parent.getSet()); @@ -259,7 +259,7 @@ .observeSingleSelection(beanViewer); IObservableValue beanSelected = new ComputedValue(bool.TYPE) { protected Object calculate() { - return bool.valueOf(beanViewerSelection.getValue() != null); + return bool.valueOf(beanViewerSelection.getValue() !is null); } }; dbc.bindValue(SWTObservables.observeEnabled(addChildBeanButton), @@ -272,7 +272,7 @@ dbc.bindValue(SWTObservables.observeEnabled(pasteButton), new ComputedValue(bool.TYPE) { protected Object calculate() { - return bool.valueOf(clipboard.getValue() != null); + return bool.valueOf(clipboard.getValue() !is null); } }); @@ -309,13 +309,13 @@ } public Set getSet() { - if (set == null) + if (set is null) return null; return new HashSet(set); } public void setSet(Set set) { - if (set != null) + if (set !is null) set = new HashSet(set); changeSupport.firePropertyChange("set", this.set, this.set = set); } diff -r 5d5bd660917f -r e884642ad36e org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet021MultiFieldValidation.d --- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet021MultiFieldValidation.d Wed Apr 22 18:59:26 2009 +0200 +++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet021MultiFieldValidation.d Thu Apr 23 00:02:38 2009 +0200 @@ -55,7 +55,7 @@ * @since 3.2 * */ -public class Snippet021MultiFieldValidation extends WizardPage { +public class Snippet021MultiFieldValidation : WizardPage { private List list_1; private List list; @@ -221,7 +221,7 @@ protected IStatus validate() { Integer field1 = (Integer) middleField1.getValue(); Integer field2 = (Integer) middleField2.getValue(); - if (Math.abs(field1.intValue()) % 2 != Math.abs(field2 + if (Math.abs(field1.intValue()) % 2 !is Math.abs(field2 .intValue()) % 2) return ValidationStatus .error("Fields 1 and 2 must be both even or both odd"); @@ -272,7 +272,7 @@ } } }); - if (dialog.open() == Window.OK) { + if (dialog.open() is Window.OK) { targetAddends.add(Integer.valueOf(dialog.getValue())); } } @@ -303,7 +303,7 @@ .hasNext();) { actualSum += ((Integer) iterator.next()).intValue(); } - if (sum.intValue() != actualSum) + if (sum.intValue() !is actualSum) return ValidationStatus.error("Sum of addends is " + actualSum + ", expecting " + sum); return ValidationStatus.ok(); @@ -320,7 +320,7 @@ modelAddends); } - static class MultiFieldValidationWizard extends Wizard { + static class MultiFieldValidationWizard : Wizard { public void addPages() { addPage(new Snippet021MultiFieldValidation()); } @@ -345,7 +345,7 @@ // The SWT event loop Display display = Display.getCurrent(); - while (dialog.getShell() != null + while (dialog.getShell() !is null && !dialog.getShell().isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); diff -r 5d5bd660917f -r e884642ad36e org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet025TableViewerWithPropertyDerivedColumns.d --- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet025TableViewerWithPropertyDerivedColumns.d Wed Apr 22 18:59:26 2009 +0200 +++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet025TableViewerWithPropertyDerivedColumns.d Thu Apr 23 00:02:38 2009 +0200 @@ -103,7 +103,7 @@ private static Person UNKNOWN = new Person("unknown", null, null); // The data model class. This is normally a persistent class of some sort. - static class Person extends AbstractModelObject { + static class Person : AbstractModelObject { // A property... String name = "Donald Duck"; Person mother; @@ -237,7 +237,7 @@ peopleViewer.addFilter(new ViewerFilter() { public bool select(Viewer viewer, Object parentElement, Object element) { - return element != UNKNOWN; + return element !is UNKNOWN; } }); diff -r 5d5bd660917f -r e884642ad36e org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet026AnonymousBeanProperties.d --- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet026AnonymousBeanProperties.d Wed Apr 22 18:59:26 2009 +0200 +++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet026AnonymousBeanProperties.d Thu Apr 23 00:02:38 2009 +0200 @@ -113,7 +113,7 @@ } } - public static class ContactGroup extends AbstractModelObject implements + public static class ContactGroup : AbstractModelObject , Comparable { private String name; private Set contacts = new TreeSet(); @@ -123,7 +123,7 @@ } private String checkNull(String string) { - if (string == null) + if (string is null) throw new NullPointerException(); return string; } @@ -160,13 +160,13 @@ } } - public static class Contact extends AbstractModelObject implements + public static class Contact : AbstractModelObject , Comparable { private String name; private String status; private String checkNull(String string) { - if (string == null) + if (string is null) throw new NullPointerException(); return string; } @@ -196,13 +196,13 @@ public int compareTo(Object o) { Contact that = (Contact) o; int result = this.name.compareTo(that.name); - if (result == 0) + if (result is 0) result = this.status.compareTo(that.status); return result; } } - public static class ApplicationModel extends AbstractModelObject { + public static class ApplicationModel : AbstractModelObject { private Set groups = new TreeSet(); public Set getGroups() { @@ -223,13 +223,13 @@ * own property to apply set changes incrementally through the addContact * and removeContact methods. */ - public static class ContactGroupContactsProperty extends SimpleSetProperty { + public static class ContactGroupContactsProperty : SimpleSetProperty { public Object getElementType() { return Contact.class; } protected Set doGetSet(Object source) { - if (source == null) + if (source is null) return Collections.EMPTY_SET; return ((ContactGroup) source).getContacts(); } @@ -251,7 +251,7 @@ return new Listener(this, listener); } - private class Listener extends NativePropertyListener implements + private class Listener : NativePropertyListener , PropertyChangeListener { Listener(IProperty property, ISimplePropertyListener listener) { super(property, listener); diff -r 5d5bd660917f -r e884642ad36e org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet027ExternalValidator.d --- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet027ExternalValidator.d Wed Apr 22 18:59:26 2009 +0200 +++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet027ExternalValidator.d Thu Apr 23 00:02:38 2009 +0200 @@ -44,7 +44,7 @@ * * @since 3.5 */ -public class Snippet027ExternalValidator extends WizardPage { +public class Snippet027ExternalValidator : WizardPage { private Text nameValue; private Text emailValue; @@ -84,7 +84,7 @@ } } - static class Contact extends AbstractModelObject { + static class Contact : AbstractModelObject { String name; String email; String phoneNumber; @@ -126,11 +126,11 @@ } public IStatus validate() { - if (name.indexOf(' ') == -1) { + if (name.indexOf(' ') is -1) { return ValidationStatus .error("Please enter both first and last name separated by a space."); } - if (email.indexOf('@') == -1) { + if (email.indexOf('@') is -1) { return ValidationStatus .error("Please enter a valid email address containing '@'."); } @@ -225,7 +225,7 @@ WizardPageSupport.create(this, dbc); } - static class ExternalValidationWizard extends Wizard { + static class ExternalValidationWizard : Wizard { public void addPages() { addPage(new Snippet027ExternalValidator()); } @@ -250,7 +250,7 @@ // The SWT event loop Display display = Display.getCurrent(); - while (dialog.getShell() != null + while (dialog.getShell() !is null && !dialog.getShell().isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); diff -r 5d5bd660917f -r e884642ad36e org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet028DuplexingObservableValue.d --- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet028DuplexingObservableValue.d Wed Apr 22 18:59:26 2009 +0200 +++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet028DuplexingObservableValue.d Thu Apr 23 00:02:38 2009 +0200 @@ -189,7 +189,7 @@ } } - public static class MovieInfo extends AbstractModelObject { + public static class MovieInfo : AbstractModelObject { private String title; private String releaseDate; private String director; diff -r 5d5bd660917f -r e884642ad36e org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet029TreeViewerMultiListProperty.d --- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet029TreeViewerMultiListProperty.d Wed Apr 22 18:59:26 2009 +0200 +++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet029TreeViewerMultiListProperty.d Thu Apr 23 00:02:38 2009 +0200 @@ -122,7 +122,7 @@ } } - public static class Catalog extends AbstractModelObject { + public static class Catalog : AbstractModelObject { private String name; private List catalogs = new ArrayList(); private List items = new ArrayList(); @@ -157,7 +157,7 @@ } } - public static class CatalogItem extends AbstractModelObject { + public static class CatalogItem : AbstractModelObject { private String name; public CatalogItem(String name) { diff -r 5d5bd660917f -r e884642ad36e org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet031JFaceObservable.d --- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet031JFaceObservable.d Wed Apr 22 18:59:26 2009 +0200 +++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet031JFaceObservable.d Thu Apr 23 00:02:38 2009 +0200 @@ -58,7 +58,7 @@ // In this example, we extend the EventManager class // to manage our listeners and we fire a property change // event when the object state changes. - public static class Person extends EventManager { + public static class Person : EventManager { // A property... String name = "HelloWorld"; diff -r 5d5bd660917f -r e884642ad36e org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet032TableViewerColumnEditing.d --- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet032TableViewerColumnEditing.d Wed Apr 22 18:59:26 2009 +0200 +++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet032TableViewerColumnEditing.d Thu Apr 23 00:02:38 2009 +0200 @@ -103,7 +103,7 @@ } // The data model class. This is normally a persistent class of some sort. - static class Person extends AbstractModelObject { + static class Person : AbstractModelObject { // A property... String name; String firstName; diff -r 5d5bd660917f -r e884642ad36e org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet033CrossValidationControlDecoration.d --- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet033CrossValidationControlDecoration.d Wed Apr 22 18:59:26 2009 +0200 +++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet033CrossValidationControlDecoration.d Thu Apr 23 00:02:38 2009 +0200 @@ -130,7 +130,7 @@ (Composite) null, decorationUpdater); } - private static class DateRangeValidator extends MultiValidator { + private static class DateRangeValidator : MultiValidator { private final IObservableValue start; private final IObservableValue end; private final String errorMessage;