Esempio n. 1
0
 private void startPluginHost() {
   try {
     mainContext.startBundleHost(BundleFromResources.SPECIFIC_BEHAVIOUR_BUNDLES);
     pluginFramework = mainContext.getPluginHost();
     pluginFramework
         .getHostBundleContext()
         .registerService(org.orbisgis.viewapi.workspace.ViewWorkspace.class, viewWorkspace, null);
   } catch (Exception ex) {
     LOGGER.error(I18N.tr("Loading of plugins is aborted"), ex);
   }
 }
Esempio n. 2
0
 /**
  * Stops this application, closes the {@link MainFrame} and saves all properties. This method is
  * called through the MainFrame.MAIN_FRAME_CLOSING event listener.
  */
 public boolean shutdown(boolean stopVM) {
   if (!isShutdownVetoed()) {
     try {
       mainFrame.setVisible(false); // Hide the main panel
       mainContext.saveStatus(); // Save the services status
       // Save dialogs status
       saveSIFState();
       // Save layout
       dockManager.saveLayout();
       this.dispose();
     } finally {
       // While public Plugins are not implemented do not close the VM in finally clause
       if (stopVM) {
         SwingUtilities.invokeLater(
             new Runnable() {
               /**
                * If an error occur while unload resources, java machine may continue to run. In
                * this case, the following command would terminate the application.
                */
               public void run() {
                 System.exit(0);
               }
             });
       }
     }
     return true;
   } else {
     return false;
   }
 }
Esempio n. 3
0
 /** Create the GeoCatalog view */
 private void makeGeoCatalogPanel() {
   // The geo-catalog view content is read from the SourceContext
   geoCatalog = new Catalog(mainContext.getDataManager(), editors);
   // Catalog extensions
   geoCatalog.registeTrackers(pluginFramework.getHostBundleContext());
   // Add the view as a new Docking Panel
   dockManager.addDockingPanel(geoCatalog);
 }
Esempio n. 4
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);
 }
Esempio n. 5
0
 /** A method to save the workspace : documents and layout */
 public void onMenuSaveApplication() {
   if (!isShutdownVetoed()) {
     mainContext.saveStatus(); // Save the services status
     // Save dialogs status
     saveSIFState();
     // Save layout
     dockManager.saveLayout();
     LOGGER.info(I18N.tr("The workspace has been saved."));
   } else {
     LOGGER.info(I18N.tr("The workspace hasn't been saved."));
   }
 }
Esempio n. 6
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);
  }
Esempio n. 7
0
 /** Load the built-ins editors factories */
 private void loadEditorFactories() {
   TableEditorFactory tableEditorFactory = new TableEditorFactory();
   tableEditorFactory.setDataManager(mainContext.getDataManager());
   editors.addEditorFactory(tableEditorFactory);
 }
Esempio n. 8
0
 /** Create the logging panels All,Info,Warning,Error */
 private void makeLoggingPanels() {
   loggerCollection = new OutputManager(mainContext.isDebugMode());
   // Show Panel
   dockManager.addDockingPanel(loggerCollection.getPanel());
 }