| 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 | * Main class of the application and called from the .jar. | |
| 16 | * This class set the general environment of execution and start the software. | |
| 17 | */ | |
| 18 | public class MainApp { | |
| 19 | | |
| 20 | private static final Logger LOGGER = LogManager.getRootLogger(); | |
| 21 | private static final InjectionModel INJECTION_MODEL; // required to load preferences first | |
| 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); // required init but not enough, reapplied next | |
| 37 | MainApp.apply4K(); | |
| 38 | } | |
| 39 | ||
| 40 | private MainApp() { | |
| 41 | // nothing | |
| 42 | } | |
| 43 | | |
| 44 | /** | |
| 45 | * Application starting point. | |
| 46 | * @param args CLI parameters (not used) | |
| 47 | */ | |
| 48 | public static void main(String[] args) { | |
| 49 |
1
1. main : removed call to com/jsql/view/swing/util/MediatorHelper::register → NO_COVERAGE |
MediatorHelper.register(MainApp.INJECTION_MODEL); |
| 50 | ||
| 51 |
1
1. main : removed call to com/jsql/util/ExceptionUtil::setUncaughtExceptionHandler → NO_COVERAGE |
MainApp.INJECTION_MODEL.getMediatorUtils().getExceptionUtil().setUncaughtExceptionHandler(); |
| 52 |
1
1. main : removed call to com/jsql/util/ProxyUtil::initProxy → NO_COVERAGE |
MainApp.INJECTION_MODEL.getMediatorUtils().getProxyUtil().initProxy(); |
| 53 |
1
1. main : removed call to com/jsql/util/AuthenticationUtil::setKerberosCifs → NO_COVERAGE |
MainApp.INJECTION_MODEL.getMediatorUtils().getAuthenticationUtil().setKerberosCifs(); |
| 54 | ||
| 55 | try { | |
| 56 | var view = new JFrameView(MainApp.INJECTION_MODEL); | |
| 57 |
1
1. main : removed call to com/jsql/view/swing/util/MediatorHelper::register → NO_COVERAGE |
MediatorHelper.register(view); |
| 58 |
1
1. main : removed call to com/jsql/model/InjectionModel::subscribe → NO_COVERAGE |
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 | // Fix #22668: Assistive Technology not found | |
| 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() { // required not in UiUtil before frame is set | |
| 71 | if (MainApp.INJECTION_MODEL.getMediatorUtils().getPreferencesUtil().is4K()) { | |
| 72 | System.setProperty("sun.java2d.uiScale", "2.5"); // jdk >= 9 | |
| 73 | } | |
| 74 | } | |
| 75 | } | |
Mutations | ||
| 49 |
1.1 |
|
| 51 |
1.1 |
|
| 52 |
1.1 |
|
| 53 |
1.1 |
|
| 57 |
1.1 |
|
| 58 |
1.1 |