Skip to content

Commit 4af83af

Browse files
authored
Merge branch 'eclipse-platform:master' into master
2 parents ac6426a + 84f02de commit 4af83af

2 files changed

Lines changed: 44 additions & 60 deletions

File tree

examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/SnippetExplorer.java

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -37,38 +37,39 @@
3737
*/
3838
public class SnippetExplorer {
3939

40-
private static final String USAGE_EXPLANATION = "Welcome to the SnippetExplorer!\n"
41-
+ "\n"
42-
+ "This tool will help you to explore and test the large collection of SWT example Snippets. "
43-
+ "You can use the text field on top to filter the Snippets by there description or Snippet number. "
44-
+ "To start a Snippet you can either double click its entry, press enter or use the button below. "
45-
+ "It is also possible to start multiple Snippets at once. (exact behavior depends on selected Snippet-Runner)\n"
46-
+ "\n"
47-
+ "It is recommended to start the Snippet Explorer connected to a console since some of the Snippets "
48-
+ "print useful informations to the console or do not open a window at all.\n"
49-
+ "\n"
50-
+ "The Explorer supports (dependent on your OS and environment) different modes to start Snippets. Those runners are:\n"
51-
+ "\n"
52-
+ " \u2022 Thread Runner: Snippets are executed as threads of the Explorer.\n"
53-
+ "\t- This runner is only available if the environment supports multiple Displays at the same time. (only Windows at the moment)\n"
54-
+ "\t- Multiple Snippets can be run parallel using this runner.\n"
55-
+ "\t- All running Snippets are closed when the explorer exits.\n"
56-
+ "\t- If to many Snippets are run in parallel SWT may run out of handles.\n"
57-
+ "\t- If a Snippet calls System.exit it will also force the explorer itself and all other running Snippets to exit as well.\n"
58-
+ "\n"
59-
+ " \u2022 Process Runner: Snippets are executed as separate processes.\n"
60-
+ "\t- This runner is only available if a JRE was found which can be used to start the Snippets.\n"
61-
+ "\t- Multiple Snippets can be run parallel using this runner.\n"
62-
+ "\t- This runner is more likely to fail Snippet launch due to incomplete classpath or other launch problems.\n"
63-
+ "\t- When the explorer exits it try to close all running Snippets but has less control over it as the Thread runner.\n"
64-
+ "\t- Unlike the Thread runner the Process runner is resisted to faulty Snippets. (e.g. Snippets calling System.exit)\n"
65-
+ "\n"
66-
+ " \u2022 Serial Runner: Snippets are executed one after another instead of the explorer.\n"
67-
+ "\t- This runner is always available.\n"
68-
+ "\t- Cannot run Snippets parallel.\n"
69-
+ "\t- To run Snippets the explorer gets closed, executes the selected Snippets one after another in the same JVM "
70-
+ "and after the last Snippet has finished restarts the Snippet Explorer.\n"
71-
+ "\t- A Snippet calling System.exit will stop the Snippet chain and the explorer itself can not restart.";
40+
private static final String USAGE_EXPLANATION = """
41+
Welcome to the SnippetExplorer!
42+
43+
This tool will help you to explore and test the large collection of SWT example Snippets. \
44+
You can use the text field on top to filter the Snippets by there description or Snippet number. \
45+
To start a Snippet you can either double click its entry, press enter or use the button below. \
46+
It is also possible to start multiple Snippets at once. (exact behavior depends on selected Snippet-Runner)
47+
48+
It is recommended to start the Snippet Explorer connected to a console since some of the Snippets \
49+
print useful informations to the console or do not open a window at all.
50+
51+
The Explorer supports (dependent on your OS and environment) different modes to start Snippets. Those runners are:
52+
53+
\u2022 Thread Runner: Snippets are executed as threads of the Explorer.
54+
- This runner is only available if the environment supports multiple Displays at the same time. (only Windows at the moment)
55+
- Multiple Snippets can be run parallel using this runner.
56+
- All running Snippets are closed when the explorer exits.
57+
- If to many Snippets are run in parallel SWT may run out of handles.
58+
- If a Snippet calls System.exit it will also force the explorer itself and all other running Snippets to exit as well.
59+
60+
\u2022 Process Runner: Snippets are executed as separate processes.
61+
- This runner is only available if a JRE was found which can be used to start the Snippets.
62+
- Multiple Snippets can be run parallel using this runner.
63+
- This runner is more likely to fail Snippet launch due to incomplete classpath or other launch problems.
64+
- When the explorer exits it try to close all running Snippets but has less control over it as the Thread runner.
65+
- Unlike the Thread runner the Process runner is resisted to faulty Snippets. (e.g. Snippets calling System.exit)
66+
67+
\u2022 Serial Runner: Snippets are executed one after another instead of the explorer.
68+
- This runner is always available.
69+
- Cannot run Snippets parallel.
70+
- To run Snippets the explorer gets closed, executes the selected Snippets one after another in the same JVM \
71+
and after the last Snippet has finished restarts the Snippet Explorer.
72+
- A Snippet calling System.exit will stop the Snippet chain and the explorer itself can not restart.""";
7273

7374
/** Max length for Snippet description in the main table. */
7475
private static final int MAX_DESCRIPTION_LENGTH_IN_TABLE = 80;
@@ -235,7 +236,7 @@ private void initialize() {
235236

236237
createControls(shell);
237238

238-
final String[] columns = new String[] { "Name", "Description" };
239+
final String[] columns = { "Name", "Description" };
239240
for (String col : columns) {
240241
final TableColumn tableCol = new TableColumn(snippetTable, SWT.NONE);
241242
tableCol.setText(col);

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Spinner.java

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2016 Red Hat, Inc. and others.
2+
* Copyright (c) 2000, 2025 Red Hat, Inc. and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -15,7 +15,7 @@
1515
package org.eclipse.swt.tests.junit;
1616

1717
import static org.junit.Assert.assertEquals;
18-
import static org.junit.Assert.fail;
18+
import static org.junit.Assert.assertThrows;
1919

2020
import org.eclipse.swt.SWT;
2121
import org.eclipse.swt.widgets.Spinner;
@@ -37,23 +37,13 @@ public void setUp() {
3737
@Override
3838
@Test
3939
public void test_ConstructorLorg_eclipse_swt_widgets_CompositeI() {
40-
try {
41-
spinner = new Spinner(null, 0);
42-
fail("No exception thrown for parent == null");
43-
}
44-
catch (IllegalArgumentException e) {
45-
}
46-
int[] cases = {0, SWT.READ_ONLY, SWT.WRAP};
40+
assertThrows("No exception thrown for parent == null", IllegalArgumentException.class,
41+
() -> new Spinner(null, 0));
42+
int[] cases = { 0, SWT.READ_ONLY, SWT.WRAP };
4743
for (int style : cases)
4844
spinner = new Spinner(shell, style);
4945
}
5046

51-
@Override
52-
@Test
53-
public void test_computeSizeIIZ() {
54-
// super class test is sufficient
55-
}
56-
5747
@Test
5848
public void test_getIncrement() {
5949
int [] cases = {5,100,1000,1};
@@ -72,13 +62,9 @@ public void test_getDigits() {
7262
spinner.setDigits(digits);
7363
assertEquals(digits, spinner.getDigits());
7464
}
75-
try{
76-
spinner.setDigits(-1);
77-
fail("setDigits should have failed with illegal Argument");
78-
}
79-
catch(IllegalArgumentException e){
80-
assertEquals(cases[cases.length-1], spinner.getDigits());
81-
}
65+
assertThrows("setDigits should have failed with illegal Argument", IllegalArgumentException.class,
66+
() -> spinner.setDigits(-1));
67+
assertEquals(cases[cases.length-1], spinner.getDigits());
8268
}
8369

8470
@Test
@@ -132,11 +118,8 @@ public void test_getTextLimit() {
132118
spinner.setTextLimit(value);
133119
assertEquals(value, spinner.getTextLimit());
134120
}
135-
try {
136-
spinner.setTextLimit(0);
137-
fail("setTextLimit should have caused an expection with value 0");
138-
} catch (Exception e) {
139-
}
121+
assertThrows("setTextLimit should have caused an expection with value 0", IllegalArgumentException.class,
122+
() -> spinner.setTextLimit(0));
140123
}
141124

142125
@Test

0 commit comments

Comments
 (0)