Skip to content

Commit 051f063

Browse files
committed
Apply Eclipse formatter on jface databinding examples
This make reading and modifiy the examples easier and that is the main purpose of these examples
1 parent dee1e64 commit 051f063

35 files changed

+516
-497
lines changed

examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/AsynchronousTestSet.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ public AsynchronousTestSet() {
6868
super(new HashSet<>(), Object.class);
6969
display = Display.getCurrent();
7070
if (display == null) {
71-
throw new IllegalStateException(
72-
"This object can only be created in the UI thread"); //$NON-NLS-1$
71+
throw new IllegalStateException("This object can only be created in the UI thread"); //$NON-NLS-1$
7372
}
7473
recompute();
7574
}

examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/LabelProviderTest.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,24 +125,21 @@ protected void removeListenerFrom(RenamableItem next) {
125125
renameButton.addSelectionListener(buttonSelectionListener);
126126
renameButton.setText("Rename"); //$NON-NLS-1$
127127

128-
selectedRenamable
129-
.addValueChangeListener(event -> {
130-
boolean shouldEnable = selectedRenamable.getValue() != null;
131-
removeButton.setEnabled(shouldEnable);
132-
renameButton.setEnabled(shouldEnable);
133-
});
128+
selectedRenamable.addValueChangeListener(event -> {
129+
boolean shouldEnable = selectedRenamable.getValue() != null;
130+
removeButton.setEnabled(shouldEnable);
131+
renameButton.setEnabled(shouldEnable);
132+
});
134133
removeButton.setEnabled(false);
135134
renameButton.setEnabled(false);
136135

137136
GridLayoutFactory.fillDefaults().generateLayout(buttonBar);
138-
GridLayoutFactory.fillDefaults().numColumns(2).margins(
139-
LayoutConstants.getMargins()).generateLayout(shell);
137+
GridLayoutFactory.fillDefaults().numColumns(2).margins(LayoutConstants.getMargins()).generateLayout(shell);
140138
}
141139

142140
protected void rename(final RenamableItem currentSelection) {
143-
InputDialog inputDialog = new InputDialog(
144-
shell,
145-
"Edit name", "Enter the new item name", currentSelection.getName(), null); //$NON-NLS-1$ //$NON-NLS-2$
141+
InputDialog inputDialog = new InputDialog(shell, "Edit name", "Enter the new item name", //$NON-NLS-1$ //$NON-NLS-2$
142+
currentSelection.getName(), null);
146143
if (Window.OK == inputDialog.open()) {
147144
currentSelection.setName(inputDialog.getValue());
148145
}

examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/LabelProviderTest2.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,12 @@ protected void removeListenerFrom(RenamableItem next) {
134134
renameButton.setEnabled(false);
135135

136136
GridLayoutFactory.fillDefaults().generateLayout(buttonBar);
137-
GridLayoutFactory.fillDefaults().numColumns(2).margins(
138-
LayoutConstants.getMargins()).generateLayout(shell);
137+
GridLayoutFactory.fillDefaults().numColumns(2).margins(LayoutConstants.getMargins()).generateLayout(shell);
139138
}
140139

141140
protected void rename(final RenamableItem currentSelection) {
142-
InputDialog inputDialog = new InputDialog(
143-
shell,
144-
"Edit name", "Enter the new item name", currentSelection.getName(), null); //$NON-NLS-1$ //$NON-NLS-2$
141+
InputDialog inputDialog = new InputDialog(shell, "Edit name", "Enter the new item name", //$NON-NLS-1$ //$NON-NLS-2$
142+
currentSelection.getName(), null);
145143
if (Window.OK == inputDialog.open()) {
146144
currentSelection.setName(inputDialog.getValue());
147145
}

examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/SimpleNode.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import org.eclipse.core.databinding.observable.set.IObservableSet;
1717

18-
1918
/**
2019
* This object will be given randomly-generated children
2120
*

examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/StructuredContentProviderTest.java

Lines changed: 24 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,13 @@ public class StructuredContentProviderTest {
9191
private WritableValue<Integer> currentFunction;
9292

9393
/**
94-
* mathFunction is the transformation. It can multiply by 2, round down to
95-
* the nearest integer, or do nothing (identity)
94+
* mathFunction is the transformation. It can multiply by 2, round down to the
95+
* nearest integer, or do nothing (identity)
9696
*/
9797
private SomeMathFunction<Double> mathFunction;
9898

9999
/**
100-
* Set of Doubles. Holds the result of applying mathFunction to the
101-
* inputSet.
100+
* Set of Doubles. Holds the result of applying mathFunction to the inputSet.
102101
*/
103102
private MappedSet outputSet;
104103

@@ -120,9 +119,7 @@ public StructuredContentProviderTest() {
120119
// Initialize shell
121120
final Label someDoubles = new Label(shell, SWT.NONE);
122121
someDoubles.setText("A list of random Doubles"); //$NON-NLS-1$
123-
someDoubles.setLayoutData(new GridData(
124-
GridData.HORIZONTAL_ALIGN_FILL
125-
| GridData.VERTICAL_ALIGN_FILL));
122+
someDoubles.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
126123

127124
Control addRemoveComposite = createInputControl(shell, inputSet);
128125

@@ -146,8 +143,7 @@ public StructuredContentProviderTest() {
146143
GridLayout layout = new GridLayout();
147144
layout.numColumns = 1;
148145
operation.setLayout(layout);
149-
operation.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
150-
| GridData.VERTICAL_ALIGN_FILL));
146+
operation.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
151147

152148
Control outputControl = createOutputComposite(shell);
153149
GridData outputData = new GridData(GridData.FILL_BOTH);
@@ -169,8 +165,7 @@ protected void updateControl() {
169165
+ " doubles is " + sum); //$NON-NLS-1$
170166
}
171167
};
172-
sumLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
173-
| GridData.VERTICAL_ALIGN_FILL));
168+
sumLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
174169

175170
GridLayout shellLayout = new GridLayout();
176171
layout.numColumns = 1;
@@ -227,16 +222,12 @@ protected Double calculate() {
227222
* Creates a radio button in the given parent composite. When selected, the
228223
* button will change the given SettableValue to the given value.
229224
*
230-
* @param parent
231-
* parent composite
232-
* @param model
233-
* SettableValue that will hold the value of the
234-
* currently-selected radio button
235-
* @param string
236-
* text to appear in the radio button
237-
* @param value
238-
* value of this radio button (SettableValue will hold this value
239-
* when the radio button is selected)
225+
* @param parent parent composite
226+
* @param model SettableValue that will hold the value of the
227+
* currently-selected radio button
228+
* @param string text to appear in the radio button
229+
* @param value value of this radio button (SettableValue will hold this value
230+
* when the radio button is selected)
240231
*/
241232
private void createRadioButton(Composite parent, final WritableValue<Integer> model, String string,
242233
final int value) {
@@ -255,13 +246,11 @@ protected void updateControl() {
255246
button.setSelection(model.getValue().equals(value));
256247
}
257248
};
258-
button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
259-
| GridData.VERTICAL_ALIGN_FILL));
249+
button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
260250
}
261251

262252
private Control createOutputComposite(Composite parent) {
263-
ListViewer listOfInts = new ListViewer(parent, SWT.BORDER
264-
| SWT.V_SCROLL | SWT.H_SCROLL);
253+
ListViewer listOfInts = new ListViewer(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
265254

266255
listOfInts.setContentProvider(new ObservableSetContentProvider<>());
267256
listOfInts.setLabelProvider(new ViewerLabelProvider());
@@ -273,25 +262,20 @@ private Control createOutputComposite(Composite parent) {
273262
* Creates and returns a control that will allow the user to add and remove
274263
* Doubles from the given input set.
275264
*
276-
* @param parent
277-
* parent control
278-
* @param inputSet
279-
* input set
280-
* @return a newly created SWT control that displays Doubles from the input
281-
* set and allows the user to add and remove entries
265+
* @param parent parent control
266+
* @param inputSet input set
267+
* @return a newly created SWT control that displays Doubles from the input set
268+
* and allows the user to add and remove entries
282269
*/
283-
private Control createInputControl(Composite parent,
284-
final WritableSet<Double> inputSet) {
270+
private Control createInputControl(Composite parent, final WritableSet<Double> inputSet) {
285271
Composite addRemoveComposite = new Composite(parent, SWT.NONE);
286-
ListViewer listOfInts = new ListViewer(addRemoveComposite,
287-
SWT.BORDER);
272+
ListViewer listOfInts = new ListViewer(addRemoveComposite, SWT.BORDER);
288273

289274
listOfInts.setContentProvider(new ObservableSetContentProvider<>());
290275
listOfInts.setLabelProvider(new ViewerLabelProvider());
291276
listOfInts.setInput(inputSet);
292277

293-
final IObservableValue<Double> selectedInt = ViewerProperties.singleSelection(Double.class)
294-
.observe(listOfInts);
278+
final IObservableValue<Double> selectedInt = ViewerProperties.singleSelection(Double.class).observe(listOfInts);
295279

296280
GridData listData = new GridData(GridData.FILL_BOTH);
297281
listData.minimumHeight = 1;
@@ -310,8 +294,7 @@ public void widgetSelected(SelectionEvent e) {
310294
super.widgetSelected(e);
311295
}
312296
});
313-
add.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
314-
| GridData.VERTICAL_ALIGN_FILL));
297+
add.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
315298

316299
final Button remove = new Button(buttonBar, SWT.PUSH);
317300
remove.setText("Remove"); //$NON-NLS-1$
@@ -347,15 +330,12 @@ public void widgetSelected(SelectionEvent e) {
347330
super.widgetSelected(e);
348331
}
349332
});
350-
remove.setLayoutData(new GridData(
351-
GridData.HORIZONTAL_ALIGN_FILL
352-
| GridData.VERTICAL_ALIGN_FILL));
333+
remove.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
353334

354335
GridLayout buttonLayout = new GridLayout();
355336
buttonLayout.numColumns = 1;
356337
buttonBar.setLayout(buttonLayout); // End button bar
357-
buttonBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
358-
| GridData.VERTICAL_ALIGN_BEGINNING));
338+
buttonBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING));
359339

360340
GridLayout addRemoveLayout = new GridLayout();
361341
addRemoveLayout.numColumns = 2;

examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/contentprovider/test/TreeContentProviderTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ public void widgetSelected(SelectionEvent e) {
9292
GridLayoutFactory.fillDefaults().generateLayout(buttonBar);
9393
}
9494

95-
GridLayoutFactory.fillDefaults().margins(LayoutConstants.getMargins())
96-
.generateLayout(shell);
95+
GridLayoutFactory.fillDefaults().margins(LayoutConstants.getMargins()).generateLayout(shell);
9796

9897
shell.addDisposeListener(e -> dispose());
9998
}

examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ducks/DuckType.java

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,57 +19,59 @@
1919
import java.lang.reflect.Proxy;
2020

2121
/**
22-
* DuckType. Implements Duck Typing for Java. ("If it walks like a duck,
23-
* quacks like a duck, it..."). Essentially allows programs to treat
24-
* objects from separate hierarchies as if they were designed with common
25-
* interfaces as long as they adhere to common naming conventions.
22+
* DuckType. Implements Duck Typing for Java. ("If it walks like a duck, quacks
23+
* like a duck, it..."). Essentially allows programs to treat objects from
24+
* separate hierarchies as if they were designed with common interfaces as long
25+
* as they adhere to common naming conventions.
2626
* <p>
27-
* This version is the strict DuckType. All methods present in
27+
* This version is the strict DuckType. All methods present in
2828
* interfaceToImplement must be present on the target object.
2929
*
3030
* @author djo
3131
*/
3232
public class DuckType implements InvocationHandler {
3333

3434
/**
35-
* Interface DuckType#Wrapper. An interface for DuckType proxies that
36-
* allows clients to access the proxied value. The value returned by
37-
* calling DuckType#implement always implements this interface.
35+
* Interface DuckType#Wrapper. An interface for DuckType proxies that allows
36+
* clients to access the proxied value. The value returned by calling
37+
* DuckType#implement always implements this interface.
3838
*/
3939
public static interface Wrapper {
4040
/**
41-
* Method duckType_GetWrappedValue. Returns the proxied value.
41+
* Method duckType_GetWrappedValue. Returns the proxied value.
4242
*
4343
* @return The proxied value.
4444
*/
4545
public Object duckType_GetWrappedValue();
4646
}
4747

4848
/**
49-
* Causes object to implement the interfaceToImplement and returns
50-
* an instance of the object implementing interfaceToImplement even
51-
* if interfaceToImplement was not declared in object.getClass()'s
52-
* implements declaration.<p>
49+
* Causes object to implement the interfaceToImplement and returns an instance
50+
* of the object implementing interfaceToImplement even if interfaceToImplement
51+
* was not declared in object.getClass()'s implements declaration.
52+
* <p>
5353
*
54-
* This works as long as all methods declared in interfaceToImplement
55-
* are present on object.
54+
* This works as long as all methods declared in interfaceToImplement are
55+
* present on object.
5656
*
5757
* @param interfaceToImplement The Java class of the interface to implement
58-
* @param object The object to force to implement interfaceToImplement
58+
* @param object The object to force to implement
59+
* interfaceToImplement
5960
* @return object, but now implementing interfaceToImplement
6061
*/
6162
public static Object implement(Class<?> interfaceToImplement, Object object) {
6263
return Proxy.newProxyInstance(interfaceToImplement.getClassLoader(),
63-
new Class[] {interfaceToImplement, Wrapper.class}, new DuckType(object));
64+
new Class[] { interfaceToImplement, Wrapper.class }, new DuckType(object));
6465
}
6566

6667
/**
67-
* Indicates if object is a (DuckType) instace of intrface. That is,
68-
* is every method in intrface present on object.
68+
* Indicates if object is a (DuckType) instace of intrface. That is, is every
69+
* method in intrface present on object.
6970
*
7071
* @param intrface The interface to implement
71-
* @param object The object to test
72-
* @return true if every method in intrface is present on object. false otherwise
72+
* @param object The object to test
73+
* @return true if every method in intrface is present on object. false
74+
* otherwise
7375
*/
7476
public static boolean instanceOf(Class<?> intrface, Object object) {
7577
final Method[] methods = intrface.getMethods();

examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ducks/ReflectedMethod.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
import java.lang.reflect.Method;
1818

1919
/**
20-
* ReflectedMethod. Encapsulates a method that may or may not exist on
21-
* some receiver. Invocation policy is that if the method can be invoked,
22-
* it is. On failure, returns null.
20+
* ReflectedMethod. Encapsulates a method that may or may not exist on some
21+
* receiver. Invocation policy is that if the method can be invoked, it is. On
22+
* failure, returns null.
2323
*
2424
* @author djo
2525
*/
@@ -29,9 +29,9 @@ public class ReflectedMethod {
2929
private Method method;
3030

3131
/**
32-
* Constructor ReflectedMethod. Create a ReflectedMethod object.
32+
* Constructor ReflectedMethod. Create a ReflectedMethod object.
3333
*
34-
* @param subject The object on which the method lives.
34+
* @param subject The object on which the method lives.
3535
* @param methodName The name of the method.
3636
* @param paramTypes The method's parameter types.
3737
*/
@@ -46,8 +46,7 @@ public ReflectedMethod(Object subject, String methodName, Class<?>[] paramTypes)
4646
}
4747

4848
/**
49-
* Method exists. Returns true if the underlying method exists, false
50-
* otherwise.
49+
* Method exists. Returns true if the underlying method exists, false otherwise.
5150
*
5251
* @return true if the underlying method exists, false otherwise.
5352
*/
@@ -56,12 +55,12 @@ public boolean exists() {
5655
}
5756

5857
/**
59-
* Method invoke. If possible, invoke the encapsulated method with the
60-
* specified parameters.
58+
* Method invoke. If possible, invoke the encapsulated method with the specified
59+
* parameters.
6160
*
6261
* @param params An Object[] containing the parameters to pass.
63-
* @return any return value or null if there was no return value or an
64-
* error occured.
62+
* @return any return value or null if there was no return value or an error
63+
* occured.
6564
*/
6665
public Object invoke(Object[] params) {
6766
if (method == null)
@@ -77,13 +76,11 @@ public Object invoke(Object[] params) {
7776
}
7877

7978
/**
80-
* Method getType. Returns the return type of the method.
79+
* Method getType. Returns the return type of the method.
8180
*
8281
* @return The return type or null if none.
8382
*/
8483
public Class<?> getType() {
8584
return method.getReturnType();
8685
}
8786
}
88-
89-

0 commit comments

Comments
 (0)