Initialises the Model, View and Control.
()
| 129 | |
| 130 | /** Initialises the {@code Model}, {@code View} and {@code Control}. */ |
| 131 | private void init() { |
| 132 | try { |
| 133 | initModel(); |
| 134 | setupLookAndFeel(); |
| 135 | } catch (Exception e) { |
| 136 | setupLookAndFeel(); |
| 137 | if (e instanceof FileNotFoundException) { |
| 138 | JOptionPane.showMessageDialog( |
| 139 | null, |
| 140 | Constant.messages.getString("start.db.error"), |
| 141 | Constant.messages.getString("start.title.error"), |
| 142 | JOptionPane.ERROR_MESSAGE); |
| 143 | } |
| 144 | LOGGER.fatal("Failed to initialise: {}", e.getMessage(), e); |
| 145 | System.err.println(e.getMessage()); |
| 146 | System.exit(1); |
| 147 | } |
| 148 | |
| 149 | UIManager.put("PasswordField.showRevealButton", true); |
| 150 | |
| 151 | OptionsParam options = Model.getSingleton().getOptionsParam(); |
| 152 | OptionsParamView viewParam = options.getViewParam(); |
| 153 | |
| 154 | for (FontUtils.FontType fontType : FontUtils.FontType.values()) { |
| 155 | FontUtils.setDefaultFont( |
| 156 | fontType, viewParam.getFontName(fontType), viewParam.getFontSize(fontType)); |
| 157 | } |
| 158 | |
| 159 | setupLocale(options); |
| 160 | |
| 161 | if (viewParam.isUseSystemsLocaleForFormat()) { |
| 162 | Locale.setDefault(Locale.Category.FORMAT, Constant.getSystemsLocale()); |
| 163 | } |
| 164 | |
| 165 | View.getSingleton().showSplashScreen(); |
| 166 | |
| 167 | Thread bootstrap = |
| 168 | new Thread( |
| 169 | new Runnable() { |
| 170 | |
| 171 | @Override |
| 172 | public void run() { |
| 173 | try { |
| 174 | initControlAndPostViewInit(); |
| 175 | |
| 176 | } catch (IllegalStateException e) { |
| 177 | JOptionPane.showMessageDialog( |
| 178 | View.getSingleton().getSplashScreen(), |
| 179 | Constant.messages.getString( |
| 180 | "start.gui.dialog.fatal.error.init"), |
| 181 | Constant.PROGRAM_NAME, |
| 182 | JOptionPane.ERROR_MESSAGE); |
| 183 | System.exit(1); |
| 184 | } catch (Throwable e) { |
| 185 | if (!Constant.isDevMode()) { |
| 186 | ErrorInfo errorInfo = |
| 187 | new ErrorInfo( |
| 188 | Constant.messages.getString( |
no test coverage detected