checkPlatform();
if (DcSettings.getString(DcRepository.Settings.stLanguage) == null ||
DcSettings.getString(DcRepository.Settings.stLanguage).trim().equals("")) {
SelectLanguageDialog dlg = new SelectLanguageDialog();
DcSwingUtilities.openDialogNativeModal(dlg);
}
showSplashScreen();
// check if the web module has been installed
isWebModuleInstalled = new File(DataCrow.webDir, "WEB-INF").exists();
// initialize plugins
Plugins.getInstance();
// initialize services
Servers.getInstance();
// Initialize the Component factory
new ComponentFactory();
Enumeration en = Logger.getRootLogger().getAllAppenders();
while (en.hasMoreElements()) {
Appender appender = (Appender) en.nextElement();
if (appender instanceof TextPaneAppender)
((TextPaneAppender) appender).addListener(LogPanel.getInstance());
}
logger.info(DcResources.getText("msgApplicationStarts"));
// Initialize all modules
showSplashMsg(DcResources.getText("msgLoadingModules"));
long start = logger.isDebugEnabled() ? new Date().getTime() : 0;
new ModuleUpgrade().upgrade();
if (logger.isDebugEnabled()) {
long end = new Date().getTime();
logger.debug("Upgrading the modules took " + (end - start) + "ms");
}
start = logger.isDebugEnabled() ? new Date().getTime() : 0;
DcModules.load();
if (logger.isDebugEnabled()) {
long end = new Date().getTime();
logger.debug("Loading the modules took " + (end - start) + "ms");
}
logger.info(DcResources.getText("msgModulesLoaded"));
ValueEnhancers.initialize();
// delete lock file
Directory directory = new Directory(dataDir, false, new String[] {"lck"});
for (String file : directory.read())
new File(file).delete();
// set the database name
DcSettings.set(DcRepository.Settings.stConnectionString, "dc");
if (db != null && db.length() > 0)
DcSettings.set(DcRepository.Settings.stConnectionString, db);
initDbProperties();
start = logger.isDebugEnabled() ? new Date().getTime() : 0;
SecurityCentre.getInstance().initialize();
if (logger.isDebugEnabled()) {
long end = new Date().getTime();
logger.debug("Initilization of the security center took " + (end - start) + "ms");
}
// log in
login(username, password);
// Establish a connection to the database / server
showSplashMsg(DcResources.getText("msgInitializingDB"));
DatabaseManager.initialize();
// Start the UI
if (splashScreen == null)
showSplashScreen();
showSplashMsg(DcResources.getText("msgLoadingItems"));
DcModules.loadData();
checkTabs();
loadDefaultData();
if (!webserverMode)
showSplashMsg(DcResources.getText("msgLoadingUI"));
// load the filters & patterns
DataFilters.load();
FilePatterns.load();
ComponentFactory.setLookAndFeel();
if (!webserverMode) {
mainFrame = new MainFrame();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
long start = logger.isDebugEnabled() ? new Date().getTime() : 0;
DataCrow.mainFrame.initialize();
DataCrow.mainFrame.setVisible(true);
mainFrame.setViews();
if (logger.isDebugEnabled()) {
long end = new Date().getTime();
logger.debug("Initilization of the UI took " + (end - start) + "ms");
}
}
});
} else {
if (!SecurityCentre.getInstance().getUser().isAuthorized("WebServer")) {
DcSwingUtilities.displayWarningMessage("msgWebServerStartUnauthorized");
new ShutdownThread().run();
System.exit(0);
} else {
Runtime.getRuntime().addShutdownHook(new ShutdownThread());
showSplashMsg(DcResources.getText("msgStartingWebServer"));
DcWebServer.getInstance().start();
if (DcWebServer.getInstance().isRunning())
showSplashMsg(DcResources.getText("msgWebServerStarted"));
System.out.println(DcResources.getText("msgCloseWebServerConsole"));
}
}
SystemMonitor monitor = new SystemMonitor();
monitor.start();
Thread splashCloser = new Thread(new SplashScreenCloser());
splashCloser.start();
if (DcSettings.getBoolean(DcRepository.Settings.stCheckForNewVersion))
new VersionChecker().start();
if (!webserverMode) {
DataFilter df = new DataFilter(DcModules._LOAN);
df.addEntry(new DataFilterEntry(DataFilterEntry._AND, DcModules._LOAN, Loan._B_ENDDATE, Operator.IS_EMPTY, null));
df.addEntry(new DataFilterEntry(DataFilterEntry._AND, DcModules._LOAN, Loan._E_DUEDATE, Operator.IS_FILLED, null));
for (DcObject loan : DataManager.get(df)) {
Long overdue = ((Loan) loan).getDaysTillOverdue();
if (overdue != null && overdue.longValue() < 0) {
DcSwingUtilities.displayWarningMessage("msgThereAreOverdueItems");
new LoanInformationForm().setVisible(true);
break;
}
}
}
DcSettings.set(DcRepository.Settings.stGracefulShutdown, Boolean.FALSE);
DcSettings.save();
if (DcSettings.getBoolean(DcRepository.Settings.stDriveScannerRunOnStartup)) {
DriveManagerDialog.getInstance();
DriveManager.getInstance().startScanners();
}
if (DcSettings.getBoolean(DcRepository.Settings.stDrivePollerRunOnStartup)) {
DriveManagerDialog.getInstance();
DriveManager.getInstance().startDrivePoller();
}
initialized = true;
} catch (Exception e) {
if (logger != null) logger.fatal("Severe error occurred while starting Data Crow. The application cannot continue.", e);
e.printStackTrace();
new NativeMessageBox("Error", e.toString());
System.exit(0);
}
int xp = DcSettings.getInt(DcRepository.Settings.stXpMode);
if (!webserverMode && xp == -1) {
SelectExpienceLevelDialog dlg = new SelectExpienceLevelDialog();
dlg.setVisible(true);
}
if (!webserverMode && DcSettings.getBoolean(DcRepository.Settings.stShowTipsOnStartup)) {
TipOfTheDayDialog dlg = new TipOfTheDayDialog();
dlg.setVisible(true);
}
if (!webserverMode && DcSettings.getBoolean(DcRepository.Settings.stShowToolSelectorOnStartup)) {
ToolSelectWizard wizard = new ToolSelectWizard();
wizard.setVisible(true);