Skip to content

Commit d7f6b38

Browse files
committed
Cleanup o.e.swt.tests.gtk
* Convert to JUnit 5 * Convert listeners/adapters to lambdas * Reformat in some places as it was simply non readable * Enable save actions to help with cleaning up
1 parent 9412173 commit d7f6b38

File tree

125 files changed

+1577
-2637
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+1577
-2637
lines changed

examples/.settings_shared/org.eclipse.jdt.core.prefs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
1313
org.eclipse.jdt.core.compiler.annotation.owning=org.eclipse.jdt.annotation.Owning
1414
org.eclipse.jdt.core.compiler.annotation.resourceanalysis=disabled
1515
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
16+
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
1617
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
1718
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
1819
org.eclipse.jdt.core.compiler.compliance=17
Lines changed: 95 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
eclipse.preferences.version=1
22
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
3+
sp_cleanup.add_all=false
34
sp_cleanup.add_default_serial_version_id=true
45
sp_cleanup.add_generated_serial_version_id=false
56
sp_cleanup.add_missing_annotations=true
@@ -9,52 +10,143 @@ sp_cleanup.add_missing_nls_tags=false
910
sp_cleanup.add_missing_override_annotations=true
1011
sp_cleanup.add_missing_override_annotations_interface_methods=true
1112
sp_cleanup.add_serial_version_id=false
13+
sp_cleanup.also_simplify_lambda=true
1214
sp_cleanup.always_use_blocks=true
1315
sp_cleanup.always_use_parentheses_in_expressions=false
1416
sp_cleanup.always_use_this_for_non_static_field_access=false
1517
sp_cleanup.always_use_this_for_non_static_method_access=false
18+
sp_cleanup.array_with_curly=true
19+
sp_cleanup.arrays_fill=false
20+
sp_cleanup.bitwise_conditional_expression=false
21+
sp_cleanup.boolean_literal=false
22+
sp_cleanup.boolean_value_rather_than_comparison=false
23+
sp_cleanup.break_loop=false
24+
sp_cleanup.collection_cloning=false
25+
sp_cleanup.comparing_on_criteria=false
26+
sp_cleanup.comparison_statement=false
27+
sp_cleanup.controlflow_merge=false
1628
sp_cleanup.convert_functional_interfaces=true
17-
sp_cleanup.convert_to_enhanced_for_loop=false
29+
sp_cleanup.convert_to_enhanced_for_loop=true
30+
sp_cleanup.convert_to_enhanced_for_loop_if_loop_var_used=false
31+
sp_cleanup.convert_to_switch_expressions=false
1832
sp_cleanup.correct_indentation=false
19-
sp_cleanup.format_source_code=false
20-
sp_cleanup.format_source_code_changes_only=false
33+
sp_cleanup.do_while_rather_than_while=false
34+
sp_cleanup.double_negation=false
35+
sp_cleanup.else_if=false
36+
sp_cleanup.embedded_if=false
37+
sp_cleanup.evaluate_nullable=false
38+
sp_cleanup.extract_increment=false
39+
sp_cleanup.format_source_code=true
40+
sp_cleanup.format_source_code_changes_only=true
41+
sp_cleanup.hash=false
42+
sp_cleanup.if_condition=false
2143
sp_cleanup.insert_inferred_type_arguments=false
44+
sp_cleanup.instanceof=true
45+
sp_cleanup.instanceof_keyword=false
46+
sp_cleanup.invert_equals=false
47+
sp_cleanup.join=false
48+
sp_cleanup.lazy_logical_operator=false
2249
sp_cleanup.make_local_variable_final=true
2350
sp_cleanup.make_parameters_final=false
2451
sp_cleanup.make_private_fields_final=true
2552
sp_cleanup.make_type_abstract_if_missing_method=false
2653
sp_cleanup.make_variable_declarations_final=false
54+
sp_cleanup.map_cloning=false
55+
sp_cleanup.merge_conditional_blocks=false
56+
sp_cleanup.multi_catch=true
2757
sp_cleanup.never_use_blocks=false
2858
sp_cleanup.never_use_parentheses_in_expressions=true
59+
sp_cleanup.no_string_creation=false
60+
sp_cleanup.no_super=false
61+
sp_cleanup.number_suffix=false
62+
sp_cleanup.objects_equals=false
2963
sp_cleanup.on_save_use_additional_actions=true
64+
sp_cleanup.one_if_rather_than_duplicate_blocks_that_fall_through=false
65+
sp_cleanup.operand_factorization=false
3066
sp_cleanup.organize_imports=true
67+
sp_cleanup.overridden_assignment=false
68+
sp_cleanup.overridden_assignment_move_decl=false
69+
sp_cleanup.plain_replacement=false
70+
sp_cleanup.precompile_regex=false
71+
sp_cleanup.primitive_comparison=false
72+
sp_cleanup.primitive_parsing=false
73+
sp_cleanup.primitive_rather_than_wrapper=false
74+
sp_cleanup.primitive_serialization=false
75+
sp_cleanup.pull_out_if_from_if_else=false
76+
sp_cleanup.pull_up_assignment=false
77+
sp_cleanup.push_down_negation=false
3178
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
3279
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
3380
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
3481
sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
3582
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
83+
sp_cleanup.reduce_indentation=false
84+
sp_cleanup.redundant_comparator=false
85+
sp_cleanup.redundant_falling_through_block_end=false
3686
sp_cleanup.remove_private_constructors=true
87+
sp_cleanup.remove_redundant_modifiers=false
88+
sp_cleanup.remove_redundant_semicolons=true
3789
sp_cleanup.remove_redundant_type_arguments=true
3890
sp_cleanup.remove_trailing_whitespaces=true
3991
sp_cleanup.remove_trailing_whitespaces_all=true
4092
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
93+
sp_cleanup.remove_unnecessary_array_creation=true
4194
sp_cleanup.remove_unnecessary_casts=true
4295
sp_cleanup.remove_unnecessary_nls_tags=false
96+
sp_cleanup.remove_unnecessary_suppress_warnings=false
4397
sp_cleanup.remove_unused_imports=false
4498
sp_cleanup.remove_unused_local_variables=false
99+
sp_cleanup.remove_unused_method_parameters=false
45100
sp_cleanup.remove_unused_private_fields=true
46101
sp_cleanup.remove_unused_private_members=false
47102
sp_cleanup.remove_unused_private_methods=true
48103
sp_cleanup.remove_unused_private_types=true
104+
sp_cleanup.replace_deprecated_calls=false
105+
sp_cleanup.replace_deprecated_fields=false
106+
sp_cleanup.return_expression=false
107+
sp_cleanup.simplify_boolean_if_else=false
108+
sp_cleanup.simplify_lambda_expression_and_method_ref=false
109+
sp_cleanup.single_used_field=false
49110
sp_cleanup.sort_members=false
50111
sp_cleanup.sort_members_all=false
112+
sp_cleanup.standard_comparison=false
113+
sp_cleanup.static_inner_class=false
114+
sp_cleanup.strictly_equal_or_different=false
115+
sp_cleanup.stringbuffer_to_stringbuilder=false
116+
sp_cleanup.stringbuilder=false
117+
sp_cleanup.stringbuilder_for_local_vars=false
118+
sp_cleanup.stringconcat_stringbuffer_stringbuilder=false
119+
sp_cleanup.stringconcat_to_textblock=false
120+
sp_cleanup.substring=true
121+
sp_cleanup.switch=false
122+
sp_cleanup.switch_for_instanceof_pattern=false
123+
sp_cleanup.system_property=false
124+
sp_cleanup.system_property_boolean=false
125+
sp_cleanup.system_property_file_encoding=false
126+
sp_cleanup.system_property_file_separator=false
127+
sp_cleanup.system_property_javaspecversion=false
128+
sp_cleanup.system_property_javaversion=false
129+
sp_cleanup.system_property_line_separator=false
130+
sp_cleanup.system_property_path_separator=false
131+
sp_cleanup.ternary_operator=false
132+
sp_cleanup.try_with_resource=true
133+
sp_cleanup.unlooped_while=false
134+
sp_cleanup.unreachable_block=false
51135
sp_cleanup.use_anonymous_class_creation=false
136+
sp_cleanup.use_autoboxing=false
52137
sp_cleanup.use_blocks=false
53138
sp_cleanup.use_blocks_only_for_return_and_throw=false
139+
sp_cleanup.use_directly_map_method=false
54140
sp_cleanup.use_lambda=true
55141
sp_cleanup.use_parentheses_in_expressions=false
142+
sp_cleanup.use_string_is_blank=false
56143
sp_cleanup.use_this_for_non_static_field_access=false
57144
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
58145
sp_cleanup.use_this_for_non_static_method_access=false
59146
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
60147
sp_cleanup.use_type_arguments=false
148+
sp_cleanup.use_unboxing=false
149+
sp_cleanup.use_var=false
150+
sp_cleanup.useless_continue=false
151+
sp_cleanup.useless_return=false
152+
sp_cleanup.valueof_rather_than_instantiation=false

tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug106798_TreeCheckBoxTest.java

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
import org.eclipse.swt.layout.GridData;
1919
import org.eclipse.swt.layout.GridLayout;
2020
import org.eclipse.swt.widgets.Display;
21-
import org.eclipse.swt.widgets.Event;
22-
import org.eclipse.swt.widgets.Listener;
2321
import org.eclipse.swt.widgets.Shell;
2422
import org.eclipse.swt.widgets.Table;
2523
import org.eclipse.swt.widgets.TableColumn;
@@ -43,16 +41,12 @@ public static void main(String[] args) {
4341
| SWT.FULL_SELECTION);
4442
table.setHeaderVisible(true);
4543
table.setLayoutData(new GridData(GridData.FILL_BOTH));
46-
table.addListener(SWT.SetData, new Listener() {
47-
48-
@Override
49-
public void handleEvent(Event event) {
50-
TableItem item = (TableItem) event.item;
51-
int index = table.indexOf(item);
52-
boolean checked = myModel[index];
53-
item.setChecked(checked);
54-
item.setText(0, "Row " + index + ": " + checked);
55-
}
44+
table.addListener(SWT.SetData, event -> {
45+
TableItem item = (TableItem) event.item;
46+
int index = table.indexOf(item);
47+
boolean checked = myModel[index];
48+
item.setChecked(checked);
49+
item.setText(0, "Row " + index + ": " + checked);
5650
});
5751

5852
TableColumn tableColumn = new TableColumn(table, SWT.LEFT);
@@ -62,17 +56,14 @@ public void handleEvent(Event event) {
6256
table.setItemCount(myModel.length);
6357
table.clearAll();
6458

65-
table.addListener(SWT.Selection, new Listener() {
66-
@Override
67-
public void handleEvent(Event e) {
68-
if (e.detail == SWT.CHECK) {
69-
TableItem item = (TableItem) e.item;
70-
int index = table.indexOf(item);
71-
boolean isChecked = item.getChecked();
72-
myModel[index] = isChecked;
73-
myModel[index / 2] = isChecked;
74-
table.clear(new int[] { index, index / 2 });
75-
}
59+
table.addListener(SWT.Selection, e -> {
60+
if (e.detail == SWT.CHECK) {
61+
TableItem item = (TableItem) e.item;
62+
int index = table.indexOf(item);
63+
boolean isChecked = item.getChecked();
64+
myModel[index] = isChecked;
65+
myModel[index / 2] = isChecked;
66+
table.clear(new int[] { index, index / 2 });
7667
}
7768
});
7869

tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug113798_ComboSelectionEvent.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515

1616

1717
import org.eclipse.swt.SWT;
18-
import org.eclipse.swt.events.SelectionAdapter;
19-
import org.eclipse.swt.events.SelectionEvent;
18+
import org.eclipse.swt.events.SelectionListener;
2019
import org.eclipse.swt.widgets.Combo;
2120
import org.eclipse.swt.widgets.Display;
2221
import org.eclipse.swt.widgets.Shell;
@@ -34,12 +33,7 @@ public static void main(String[] args) {
3433
Combo combo = new Combo(shell, SWT.READ_ONLY);
3534
combo.setItems(new String[] { "A", "A", "B", "C" });
3635
combo.setSize(200, 200);
37-
combo.addSelectionListener(new SelectionAdapter() {
38-
@Override
39-
public void widgetSelected(SelectionEvent e) {
40-
System.out.println("Widget selected");
41-
}
42-
});
36+
combo.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> System.out.println("Widget selected")));
4337
shell.pack();
4438
shell.open();
4539
while (!shell.isDisposed()) {

tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug114003_MaximizedShellLocation.java

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515

1616

1717
import org.eclipse.swt.SWT;
18-
import org.eclipse.swt.events.SelectionAdapter;
19-
import org.eclipse.swt.events.SelectionEvent;
18+
import org.eclipse.swt.events.SelectionListener;
2019
import org.eclipse.swt.layout.RowData;
2120
import org.eclipse.swt.layout.RowLayout;
2221
import org.eclipse.swt.widgets.Button;
@@ -35,39 +34,21 @@ public static void main(String[] args)
3534
b.setLayoutData (new RowData (100, SWT.DEFAULT));
3635

3736
b.setText("hide");
38-
b.addSelectionListener(new SelectionAdapter()
39-
{
40-
41-
@Override
42-
public void widgetSelected(SelectionEvent arg0)
43-
{
44-
shell.setVisible(false);
45-
new Thread()
46-
{
47-
@Override
48-
public void run()
49-
{
50-
try
51-
{
52-
Thread.sleep(4000);
53-
}
54-
catch (InterruptedException e)
55-
{
56-
}
57-
58-
Display.getDefault().asyncExec(new Runnable()
59-
{
60-
@Override
61-
public void run()
62-
{
63-
shell.setVisible(true);
64-
}
65-
});
66-
37+
b.addSelectionListener(SelectionListener.widgetSelectedAdapter(arg0 -> {
38+
shell.setVisible(false);
39+
new Thread() {
40+
@Override
41+
public void run() {
42+
try {
43+
Thread.sleep(4000);
44+
} catch (InterruptedException e) {
6745
}
68-
}.start();
69-
}
70-
});
46+
47+
Display.getDefault().asyncExec(() -> shell.setVisible(true));
48+
49+
}
50+
}.start();
51+
}));
7152

7253
shell.open();
7354
while (!shell.isDisposed())

tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug119157_ShellWithoutFocus.java

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
import org.eclipse.swt.layout.FillLayout;
2020
import org.eclipse.swt.widgets.Button;
2121
import org.eclipse.swt.widgets.Display;
22-
import org.eclipse.swt.widgets.Event;
2322
import org.eclipse.swt.widgets.List;
24-
import org.eclipse.swt.widgets.Listener;
2523
import org.eclipse.swt.widgets.Shell;
2624
import org.eclipse.swt.widgets.Text;
2725

@@ -35,30 +33,22 @@ public static void main(String[] args) {
3533
main.setLayout(new FillLayout());
3634
Button button = new Button(main, SWT.PUSH);
3735
button.setText("Press me");
38-
button.addListener(SWT.Selection, new Listener() {
39-
@Override
40-
public void handleEvent(Event event) {
41-
if (dialog == null) {
42-
dialog = new Shell(main);
43-
dialog.setLayout(new FillLayout());
44-
Text text = new Text(dialog, SWT.MULTI);
45-
text.setText("No focus");
46-
List list = new List(dialog, SWT.MULTI);
47-
list.add("Multi-select will");
48-
list.add("not work");
49-
list.add("the second time.");
50-
Button button = new Button(dialog, SWT.PUSH);
51-
button.setText("OK");
52-
button.addListener(SWT.Selection, new Listener() {
53-
@Override
54-
public void handleEvent(Event event) {
55-
dialog.setVisible(false);
56-
}
57-
});
58-
dialog.setSize(400, 200);
59-
}
60-
dialog.setVisible(true);
36+
button.addListener(SWT.Selection, event -> {
37+
if (dialog == null) {
38+
dialog = new Shell(main);
39+
dialog.setLayout(new FillLayout());
40+
Text text = new Text(dialog, SWT.MULTI);
41+
text.setText("No focus");
42+
List list = new List(dialog, SWT.MULTI);
43+
list.add("Multi-select will");
44+
list.add("not work");
45+
list.add("the second time.");
46+
Button button1 = new Button(dialog, SWT.PUSH);
47+
button1.setText("OK");
48+
button1.addListener(SWT.Selection, event1 -> dialog.setVisible(false));
49+
dialog.setSize(400, 200);
6150
}
51+
dialog.setVisible(true);
6252
});
6353
main.setSize(200, 200);
6454
main.open();

0 commit comments

Comments
 (0)