Exemplo n.º 1
0
 /**
  * Core constructor, init Model instances
  *
  * @param debugMode Show additional information for debugging purposes
  * @note Call startup() to init Swing
  */
 public Core(CoreWorkspaceImpl coreWorkspace, boolean debugMode, LoadingFrame splashScreen)
     throws InvocationTargetException, InterruptedException {
   ProgressMonitor parentProgress = splashScreen.getProgressMonitor();
   ProgressMonitor progressInfo = parentProgress.startTask(I18N.tr("Loading Workspace.."), 100);
   MainContext.initConsoleLogger(debugMode);
   // Declare empty main frame
   mainFrame = new MainFrame();
   // Set the main frame position and size
   mainFrame.setSize(MAIN_VIEW_SIZE);
   // Try to set the frame at the center of the default screen
   try {
     GraphicsDevice device =
         GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
     Rectangle screenBounds = device.getDefaultConfiguration().getBounds();
     mainFrame.setLocation(
         screenBounds.x + screenBounds.width / 2 - MAIN_VIEW_SIZE.width / 2,
         screenBounds.y + screenBounds.height / 2 - MAIN_VIEW_SIZE.height / 2);
   } catch (Throwable ex) {
     LOGGER.error(ex.getLocalizedMessage(), ex);
   }
   UIFactory.setMainFrame(mainFrame);
   initMainContext(debugMode, coreWorkspace, splashScreen);
   progressInfo.progressTo(10);
   this.viewWorkspace = new ViewWorkspace(this.mainContext.getCoreWorkspace());
   Services.registerService(
       ViewWorkspace.class, I18N.tr("Contains view folders path"), viewWorkspace);
   progressInfo.setTaskName(I18N.tr("Register GUI Sql functions.."));
   addSQLFunctions();
   progressInfo.progressTo(11);
   // Load plugin host
   progressInfo.setTaskName(I18N.tr("Load the plugin framework.."));
   startPluginHost();
   progressInfo.progressTo(18);
   progressInfo.setTaskName(I18N.tr("Connecting to the database.."));
   // Init database
   try {
     mainContext.initDataBase(
         coreWorkspace.getDataBaseUser(), coreWorkspace.getDataBasePassword());
   } catch (SQLException ex) {
     throw new RuntimeException(ex.getLocalizedMessage(), ex);
   }
   initSIF();
   progressInfo.progressTo(20);
 }
Exemplo n.º 2
0
  /** Free all resources allocated by this object */
  public void dispose() {
    // Close all running jobs
    final AppContext appContext = AppContext.getAppContext();
    ExecutorService executorService = (ExecutorService) appContext.get(SwingWorker.class);
    if (executorService != null) {
      executorService.shutdown();
    }

    // Free UI resources
    if (editors != null) {
      editors.dispose();
    }
    if (geoCatalog != null) {
      geoCatalog.dispose();
    }
    if (mainFrame != null) {
      mainFrame.dispose();
    }
    if (singleFrameTracker != null) {
      singleFrameTracker.close();
    }
    if (editorFactoryTracker != null) {
      editorFactoryTracker.close();
    }
    if (editorTracker != null) {
      editorTracker.close();
    }
    if (toolBarTracker != null) {
      toolBarTracker.close();
    }
    dockManager.dispose();
    loggerCollection.dispose();

    // Free libraries resources
    mainContext.dispose();

    UIFactory.setMainFrame(null);
  }