1 | package com.jsql; | |
2 | ||
3 | import com.jsql.model.InjectionModel; | |
4 | import com.jsql.util.GitUtil.ShowOnConsole; | |
5 | import com.jsql.util.I18nUtil; | |
6 | import com.jsql.util.LogLevelUtil; | |
7 | import com.jsql.view.swing.JFrameView; | |
8 | import com.jsql.view.swing.util.MediatorHelper; | |
9 | import org.apache.logging.log4j.Level; | |
10 | import org.apache.logging.log4j.LogManager; | |
11 | import org.apache.logging.log4j.Logger; | |
12 | ||
13 | import java.awt.*; | |
14 | ||
15 | /** | |
16 | * Main class of the application and called from the .jar. | |
17 | * This class set the general environment of execution and start the software. | |
18 | */ | |
19 | public class MainApplication { | |
20 | | |
21 | private static final Logger LOGGER = LogManager.getRootLogger(); | |
22 | | |
23 | private static final InjectionModel injectionModel; | |
24 | | |
25 | static { | |
26 | ||
27 | System.setProperty("jdk.httpclient.allowRestrictedHeaders", "connection,content-length,expect,host,upgrade"); | |
28 | ||
29 | if (GraphicsEnvironment.isHeadless()) { | |
30 | LOGGER.log( | |
31 | Level.ERROR, | |
32 | "Headless runtime detected, please install or use default Java runtime instead of headless runtime" | |
33 | ); | |
34 | System.exit(1); | |
35 | } | |
36 | | |
37 | injectionModel = new InjectionModel(); | |
38 | injectionModel.getMediatorUtils().getPreferencesUtil().loadSavedPreferences(); | |
39 | ||
40 | MainApplication.apply4K(); | |
41 | } | |
42 | | |
43 | private MainApplication() { | |
44 | // nothing | |
45 | } | |
46 | | |
47 | /** | |
48 | * Application starting point. | |
49 | * @param args CLI parameters (not used) | |
50 | */ | |
51 | public static void main(String[] args) { | |
52 | | |
53 | // Initialize MVC | |
54 |
1
1. main : removed call to com/jsql/view/swing/util/MediatorHelper::register → NO_COVERAGE |
MediatorHelper.register(injectionModel); |
55 | | |
56 | // Configure global environment settings | |
57 |
1
1. main : removed call to com/jsql/util/ExceptionUtil::setUncaughtExceptionHandler → NO_COVERAGE |
injectionModel.getMediatorUtils().getExceptionUtil().setUncaughtExceptionHandler(); |
58 |
1
1. main : removed call to com/jsql/util/ProxyUtil::initializeProxy → NO_COVERAGE |
injectionModel.getMediatorUtils().getProxyUtil().initializeProxy(); |
59 |
1
1. main : removed call to com/jsql/util/AuthenticationUtil::setKerberosCifs → NO_COVERAGE |
injectionModel.getMediatorUtils().getAuthenticationUtil().setKerberosCifs(); |
60 | | |
61 | try { | |
62 | var view = new JFrameView(); | |
63 |
1
1. main : removed call to com/jsql/view/swing/util/MediatorHelper::register → NO_COVERAGE |
MediatorHelper.register(view); |
64 | | |
65 |
1
1. main : removed call to com/jsql/model/InjectionModel::subscribe → NO_COVERAGE |
injectionModel.subscribe(view.getSubscriber()); |
66 | | |
67 | } catch (HeadlessException e) { | |
68 | | |
69 | LOGGER.log( | |
70 | LogLevelUtil.CONSOLE_JAVA, | |
71 | String.format( | |
72 | "HeadlessException, command line execution in jSQL not supported yet: %s", | |
73 | e.getMessage() | |
74 | ), | |
75 | e | |
76 | ); | |
77 | return; | |
78 | | |
79 | } catch (AWTError e) { | |
80 | | |
81 | // Fix #22668: Assistive Technology not found | |
82 | LOGGER.log( | |
83 | LogLevelUtil.CONSOLE_JAVA, | |
84 | String.format( | |
85 | "Java Access Bridge missing or corrupt, check your access bridge definition in JDK_HOME/jre/lib/accessibility.properties: %s", | |
86 | e.getMessage() | |
87 | ), | |
88 | e | |
89 | ); | |
90 | return; | |
91 | } | |
92 | | |
93 |
1
1. main : removed call to com/jsql/model/InjectionModel::displayVersion → NO_COVERAGE |
injectionModel.displayVersion(); |
94 | | |
95 |
1
1. main : negated conditional → NO_COVERAGE |
if (injectionModel.getMediatorUtils().getProxyUtil().isNotLive(ShowOnConsole.YES)) { |
96 | return; | |
97 | } | |
98 | | |
99 |
1
1. main : negated conditional → NO_COVERAGE |
if (injectionModel.getMediatorUtils().getPreferencesUtil().isCheckingUpdate()) { |
100 |
1
1. main : removed call to com/jsql/util/GitUtil::checkUpdate → NO_COVERAGE |
injectionModel.getMediatorUtils().getGitUtil().checkUpdate(ShowOnConsole.NO); |
101 | } | |
102 | | |
103 |
1
1. main : removed call to com/jsql/util/I18nUtil::checkCurrentLanguage → NO_COVERAGE |
I18nUtil.checkCurrentLanguage(); |
104 |
1
1. main : removed call to com/jsql/util/GitUtil::showNews → NO_COVERAGE |
injectionModel.getMediatorUtils().getGitUtil().showNews(); |
105 | | |
106 |
1
1. main : removed call to com/jsql/MainApplication::check4K → NO_COVERAGE |
MainApplication.check4K(); |
107 | } | |
108 | | |
109 | private static void apply4K() { | |
110 | | |
111 | if (injectionModel.getMediatorUtils().getPreferencesUtil().is4K()) { | |
112 | | |
113 | // jdk >= 9 | |
114 | System.setProperty("sun.java2d.uiScale", "2.5"); | |
115 | } | |
116 | } | |
117 | | |
118 | private static void check4K() { | |
119 | | |
120 | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); | |
121 | int width = (int) screenSize.getWidth(); | |
122 | | |
123 |
3
1. check4K : negated conditional → NO_COVERAGE 2. check4K : changed conditional boundary → NO_COVERAGE 3. check4K : negated conditional → NO_COVERAGE |
if (width >= 3840 && !injectionModel.getMediatorUtils().getPreferencesUtil().is4K()) { |
124 | | |
125 | LOGGER.log(LogLevelUtil.CONSOLE_ERROR, "Your screen seems compatible with 4K resolution, enable high-definition mode in Preferences"); | |
126 | } | |
127 | } | |
128 | } | |
Mutations | ||
54 |
1.1 |
|
57 |
1.1 |
|
58 |
1.1 |
|
59 |
1.1 |
|
63 |
1.1 |
|
65 |
1.1 |
|
93 |
1.1 |
|
95 |
1.1 |
|
99 |
1.1 |
|
100 |
1.1 |
|
103 |
1.1 |
|
104 |
1.1 |
|
106 |
1.1 |
|
123 |
1.1 2.2 3.3 |