Skip to content

Commit 7b2086f

Browse files
committed
Allow DesignerStarter to be invoked directly
- The JCommander usage is deprecated - We update debug params for compatibility with all PMD commands - We allow to call startGui directly
1 parent 437bcff commit 7b2086f

File tree

6 files changed

+31
-19
lines changed

6 files changed

+31
-19
lines changed

src/main/java/net/sourceforge/pmd/util/fxdesigner/Designer.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
import java.util.logging.Logger;
1313
import java.util.stream.Collectors;
1414

15+
import net.sourceforge.pmd.lang.ast.xpath.Attribute;
16+
import net.sourceforge.pmd.util.fxdesigner.app.DesignerParams;
17+
import net.sourceforge.pmd.util.fxdesigner.app.DesignerRoot;
18+
import net.sourceforge.pmd.util.fxdesigner.app.DesignerRootImpl;
19+
import net.sourceforge.pmd.util.fxdesigner.util.DesignerUtil;
20+
1521
import javafx.application.Application;
1622
import javafx.application.Platform;
1723
import javafx.collections.ObservableList;
@@ -20,11 +26,6 @@
2026
import javafx.scene.Scene;
2127
import javafx.scene.image.Image;
2228
import javafx.stage.Stage;
23-
import net.sourceforge.pmd.lang.ast.xpath.Attribute;
24-
import net.sourceforge.pmd.util.fxdesigner.app.DesignerParams;
25-
import net.sourceforge.pmd.util.fxdesigner.app.DesignerRoot;
26-
import net.sourceforge.pmd.util.fxdesigner.app.DesignerRootImpl;
27-
import net.sourceforge.pmd.util.fxdesigner.util.DesignerUtil;
2829

2930

3031
/**

src/main/java/net/sourceforge/pmd/util/fxdesigner/DesignerStarter.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import org.apache.commons.lang3.SystemUtils;
1313

14+
import net.sourceforge.pmd.annotation.InternalApi;
15+
1416
import com.beust.jcommander.JCommander;
1517
import com.beust.jcommander.ParameterException;
1618
import javafx.application.Application;
@@ -47,7 +49,7 @@ private static boolean isJavaFxAvailable() {
4749
}
4850
}
4951

50-
52+
@Deprecated
5153
private static MainCliArgs readParameters(String[] argv) {
5254

5355
MainCliArgs argsObj = new MainCliArgs();
@@ -75,7 +77,12 @@ private static MainCliArgs readParameters(String[] argv) {
7577

7678
}
7779

78-
80+
/**
81+
* Starting from PMD 7.0.0 this method usage will be limited for development.
82+
* CLI support will be provided by pmd-cli
83+
*/
84+
@Deprecated
85+
@InternalApi
7986
public static void main(String[] args) {
8087

8188
readParameters(args);
@@ -118,6 +125,7 @@ private static String getJavaFxVersion() {
118125
return null;
119126
}
120127

128+
@Deprecated
121129
private static String getHelpText(JCommander jCommander) {
122130

123131
StringBuilder sb = new StringBuilder();
@@ -139,7 +147,7 @@ private static String getHelpText(JCommander jCommander) {
139147
}
140148

141149
@SuppressWarnings("PMD.AvoidCatchingThrowable")
142-
private static void launchGui(String[] args) {
150+
public static int launchGui(String[] args) {
143151
setSystemProperties();
144152

145153
String message = null;
@@ -152,14 +160,16 @@ private static void launchGui(String[] args) {
152160
if (message != null) {
153161
System.err.println(message);
154162
JOptionPane.showMessageDialog(null, message);
155-
System.exit(ERROR_EXIT);
163+
return ERROR_EXIT;
156164
}
157165

158166
try {
159167
Application.launch(Designer.class, args);
160168
} catch (Throwable unrecoverable) {
161169
unrecoverable.printStackTrace();
162-
System.exit(ERROR_EXIT);
170+
return ERROR_EXIT;
163171
}
172+
173+
return OK;
164174
}
165175
}

src/main/java/net/sourceforge/pmd/util/fxdesigner/DesignerVersion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/**
1616
* Stores the current Designer and PMD version and provides utility methods around them.
1717
*/
18-
public class DesignerVersion {
18+
public final class DesignerVersion {
1919

2020
/**
2121
* Constant that contains always the current version of the designer.

src/main/java/net/sourceforge/pmd/util/fxdesigner/MainCliArgs.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66

77
import com.beust.jcommander.Parameter;
88

9+
@Deprecated
910
final class MainCliArgs {
1011

1112

12-
@Parameter(names = {"--verbose", "-v"},
13+
@Parameter(names = {"--verbose", "-v", "-D", "--debug"},
1314
arity = 0,
1415
description = "Whether to launch the app in verbose mode. "
1516
+ "This enables logging of exception stack traces and "

src/main/java/net/sourceforge/pmd/util/fxdesigner/app/DesignerParams.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import java.util.List;
1010

1111
import com.sun.javafx.application.ParametersImpl;
12-
1312
import javafx.application.Application.Parameters;
1413

1514

src/main/java/net/sourceforge/pmd/util/fxdesigner/popups/SimplePopups.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
import org.reactfx.EventSource;
2020
import org.reactfx.EventStream;
2121

22+
import net.sourceforge.pmd.PMDVersion;
23+
import net.sourceforge.pmd.lang.Language;
24+
import net.sourceforge.pmd.util.fxdesigner.DesignerVersion;
25+
import net.sourceforge.pmd.util.fxdesigner.app.DesignerRoot;
26+
import net.sourceforge.pmd.util.fxdesigner.util.AuxLanguageRegistry;
27+
import net.sourceforge.pmd.util.fxdesigner.util.DesignerUtil;
28+
2229
import javafx.animation.Animation;
2330
import javafx.animation.Interpolator;
2431
import javafx.animation.Transition;
@@ -32,12 +39,6 @@
3239
import javafx.scene.layout.StackPane;
3340
import javafx.stage.Popup;
3441
import javafx.util.Duration;
35-
import net.sourceforge.pmd.PMDVersion;
36-
import net.sourceforge.pmd.lang.Language;
37-
import net.sourceforge.pmd.util.fxdesigner.DesignerVersion;
38-
import net.sourceforge.pmd.util.fxdesigner.app.DesignerRoot;
39-
import net.sourceforge.pmd.util.fxdesigner.util.AuxLanguageRegistry;
40-
import net.sourceforge.pmd.util.fxdesigner.util.DesignerUtil;
4142

4243

4344
/**

0 commit comments

Comments
 (0)