1 package com.jsql;
2
3 import com.jsql.model.InjectionModel;
4 import com.jsql.util.LogLevelUtil;
5 import com.jsql.view.swing.JFrameView;
6 import com.jsql.view.swing.util.MediatorHelper;
7 import com.jsql.view.swing.util.UiUtil;
8 import org.apache.logging.log4j.Level;
9 import org.apache.logging.log4j.LogManager;
10 import org.apache.logging.log4j.Logger;
11
12 import java.awt.*;
13
14
15
16
17
18 public class MainApp {
19
20 private static final Logger LOGGER = LogManager.getRootLogger();
21 private static final InjectionModel INJECTION_MODEL;
22
23 static {
24 System.setProperty("jdk.httpclient.allowRestrictedHeaders", "connection,content-length,expect,host,upgrade");
25 System.setProperty("log4j2.formatMsgNoLookups", "true");
26
27 if (GraphicsEnvironment.isHeadless()) {
28 LOGGER.log(Level.ERROR, "Headless runtime not supported, use default Java runtime instead");
29 System.exit(1);
30 }
31
32 INJECTION_MODEL = new InjectionModel();
33 MainApp.INJECTION_MODEL.getMediatorUtils().getPreferencesUtil().loadSavedPreferences();
34
35 var nameTheme = MainApp.INJECTION_MODEL.getMediatorUtils().getPreferencesUtil().getThemeFlatLafName();
36 UiUtil.applyTheme(nameTheme);
37 MainApp.apply4K();
38 }
39
40 private MainApp() {
41
42 }
43
44
45
46
47
48 public static void main(String[] args) {
49 MediatorHelper.register(MainApp.INJECTION_MODEL);
50
51 MainApp.INJECTION_MODEL.getMediatorUtils().getExceptionUtil().setUncaughtExceptionHandler();
52 MainApp.INJECTION_MODEL.getMediatorUtils().getProxyUtil().initProxy();
53 MainApp.INJECTION_MODEL.getMediatorUtils().getAuthenticationUtil().setKerberosCifs();
54
55 try {
56 var view = new JFrameView(MainApp.INJECTION_MODEL);
57 MediatorHelper.register(view);
58 MainApp.INJECTION_MODEL.subscribe(view.getSubscriber());
59 } catch (HeadlessException e) {
60 LOGGER.log(LogLevelUtil.CONSOLE_JAVA, "HeadlessException, command line execution not supported: %s", e);
61 } catch (AWTError e) {
62
63 LOGGER.log(LogLevelUtil.CONSOLE_JAVA, String.format(
64 "Java Access Bridge missing or corrupt, check your access bridge definition in JDK_HOME/jre/lib/accessibility.properties: %s",
65 e.getMessage()
66 ), e);
67 }
68 }
69
70 private static void apply4K() {
71 if (MainApp.INJECTION_MODEL.getMediatorUtils().getPreferencesUtil().is4K()) {
72 System.setProperty("sun.java2d.uiScale", "2.5");
73 }
74 }
75 }