Skip to content

Commit 303cbe4

Browse files
committed
Adding Configuration to RUPS. RES-691
1 parent 7456070 commit 303cbe4

19 files changed

+727
-83
lines changed

pom.xml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@
7171
<artifactId>logback-core</artifactId>
7272
<version>${logback.version}</version>
7373
</dependency>
74+
<dependency>
75+
<groupId>com.ibm.icu</groupId>
76+
<artifactId>icu4j</artifactId>
77+
<version>69.1</version>
78+
</dependency>
7479
<dependency>
7580
<groupId>com.itextpdf</groupId>
7681
<artifactId>io</artifactId>
@@ -87,10 +92,11 @@
8792
<version>${dom4j.version}</version>
8893
</dependency>
8994
<dependency>
90-
<groupId>com.ibm.icu</groupId>
91-
<artifactId>icu4j</artifactId>
92-
<version>69.1</version>
95+
<groupId>com.formdev</groupId>
96+
<artifactId>flatlaf</artifactId>
97+
<version>2.2</version>
9398
</dependency>
99+
94100
<dependency>
95101
<groupId>com.itextpdf</groupId>
96102
<artifactId>pdftest</artifactId>
@@ -127,6 +133,11 @@
127133
<build>
128134
<finalName>${project.artifactId}-${project.version}</finalName>
129135
<plugins>
136+
<plugin>
137+
<groupId>org.apache.felix</groupId>
138+
<artifactId>maven-bundle-plugin</artifactId>
139+
<version>5.1.4</version>
140+
</plugin>
130141
<plugin>
131142
<artifactId>maven-assembly-plugin</artifactId>
132143
<version>${assembly-plugin.version}</version>
@@ -169,11 +180,6 @@
169180
</manifest>
170181
</archive>
171182
</configuration>
172-
</plugin>
173-
<plugin>
174-
<groupId>org.apache.felix</groupId>
175-
<artifactId>maven-bundle-plugin</artifactId>
176-
<version>5.1.4</version>
177183
</plugin>
178184
</plugins>
179185
</build>
@@ -328,4 +334,4 @@
328334
</build>
329335
</profile>
330336
</profiles>
331-
</project>
337+
</project>

src/main/java/com/itextpdf/rups/Rups.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,33 +45,35 @@ This file is part of the iText (R) project.
4545
import com.itextpdf.kernel.actions.data.ITextCoreProductData;
4646
import com.itextpdf.rups.controller.IRupsController;
4747
import com.itextpdf.rups.controller.RupsController;
48+
import com.itextpdf.rups.model.LoggerHelper;
4849
import com.itextpdf.rups.view.Language;
4950
import com.itextpdf.rups.view.RupsDropTarget;
5051
import com.itextpdf.rups.view.RupsMenuBar;
5152
import com.itextpdf.rups.view.RupsTabbedPane;
5253
import com.itextpdf.rups.view.icons.FrameIconUtil;
5354

55+
import com.formdev.flatlaf.FlatLightLaf;
5456
import java.awt.BorderLayout;
5557
import java.awt.Dimension;
5658
import java.awt.Toolkit;
5759
import java.io.File;
5860
import javax.swing.JFrame;
5961
import javax.swing.SwingUtilities;
6062
import javax.swing.UIManager;
63+
import javax.swing.UnsupportedLookAndFeelException;
6164

6265
public class Rups {
6366

6467
/**
6568
* Initializes the main components of the Rups application.
6669
*
67-
* @param f a file that should be opened on launch
68-
* @param onCloseOperation the close operation
70+
* @param f a file that should be opened on launch
6971
*/
70-
public static void startNewApplication(final File f, final int onCloseOperation) {
72+
public static void startNewApplication(final File f) {
7173
SwingUtilities.invokeLater(() -> {
7274
setLookandFeel();
73-
IRupsController rupsController = initApplication(new JFrame(), onCloseOperation);
74-
if ( f != null ) {
75+
final IRupsController rupsController = initApplication(new JFrame());
76+
if (f != null) {
7577
loadDocumentFromFile(rupsController, f);
7678
}
7779
});
@@ -83,17 +85,17 @@ static void loadDocumentFromFile(IRupsController rupsController, File f) {
8385

8486
static void setLookandFeel() {
8587
try {
86-
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
87-
} catch (Exception e) {
88-
try {
89-
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
90-
} catch (Exception ex) {
91-
// WELP IDK
88+
if ( !FlatLightLaf.setup()) {
89+
UIManager.setLookAndFeel(RupsConfiguration.INSTANCE.getLookAndFeel());
9290
}
91+
} catch (
92+
ClassNotFoundException | InstantiationException |
93+
IllegalAccessException | UnsupportedLookAndFeelException e) {
94+
LoggerHelper.error(Language.ERROR_LOOK_AND_FEEL.getString(), e, Rups.class);
9395
}
9496
}
9597

96-
static IRupsController initApplication(JFrame frame, final int onCloseOperation) {
98+
static IRupsController initApplication(JFrame frame) {
9799
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
98100
frame.setSize((int) (screen.getWidth() * .90), (int) (screen.getHeight() * .90));
99101
frame.setLocation((int) (screen.getWidth() * .05), (int) (screen.getHeight() * .05));
@@ -103,7 +105,7 @@ static IRupsController initApplication(JFrame frame, final int onCloseOperation)
103105
frame.setTitle(
104106
String.format(Language.TITLE.getString(), ITextCoreProductData.getInstance().getVersion()));
105107
frame.setIconImages(FrameIconUtil.loadFrameIcons());
106-
frame.setDefaultCloseOperation(onCloseOperation);
108+
frame.setDefaultCloseOperation(RupsConfiguration.INSTANCE.getCloseOperation());
107109

108110
final RupsTabbedPane rupsTabbedPane = new RupsTabbedPane();
109111
final RupsController rupsController = new RupsController(screen, rupsTabbedPane);

0 commit comments

Comments
 (0)