@Override public void close(ProgressMonitor pm) { checkIsOpen(); // Backup Consistent data jaxbMapContext = getJAXBObject(); // Close the layers if (pm == null) { pm = new NullProgressMonitor(); } ILayer[] layers = layerModel.getLayersRecursively(); for (int i = 0; i < layers.length; i++) { pm.progressTo(i * 100 / layers.length); if (!layers[i].acceptsChilds()) { try { layers[i].close(); } catch (LayerException e) { LOGGER.error(I18N.tr("Cannot close layer {0}", layers[i].getName())); } } } layerModel.removeLayerListenerRecursively(openerListener); this.open = false; }
/** * 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); }
/** Change the state of the main frame in the swing thread */ @Override public void run() { try { mainFrame.setVisible(true); } catch (Exception ex) { LOGGER.error(ex.getLocalizedMessage(), ex); dispose(); } finally { progress.setCancelled(true); } }
private void initialize(ProgressMonitor parentProgress) { ProgressMonitor progress = parentProgress.startTask(I18N.tr("Loading the main window"), 100); makeMainFrame(); progress.endTask(); progress.setTaskName(I18N.tr("Loading docking system and frames")); // Initiate the docking management system DockingManagerImpl dockManagerImpl = new DockingManagerImpl(mainFrame); dockManager = dockManagerImpl; mainFrame.setDockingManager(dockManager); // Initiate the docking panel tracker singleFrameTracker = new DockingPanelTracker(pluginFramework.getHostBundleContext(), dockManager); singleFrameTracker.open(); toolBarTracker = new MenuItemServiceTracker<MainWindow, ToolBarAction>( pluginFramework.getHostBundleContext(), ToolBarAction.class, dockManagerImpl, mainFrame); toolBarTracker.open(); progress.endTask(); // Load the log panels makeLoggingPanels(); progress.endTask(); // Load the editor factories manager makeEditorManager(dockManager); progress.endTask(); // Load the GeoCatalog makeGeoCatalogPanel(); progress.endTask(); // Load Built-ins Editors loadEditorFactories(); progress.endTask(); progress.setTaskName(I18N.tr("Restore the former layout..")); // Load the docking layout and editors opened in last OrbisGis instance File savedDockingLayout = new File(viewWorkspace.getDockingLayoutPath()); if (!savedDockingLayout.exists()) { // Copy the default docking layout // First OrbisGIS start copyDefaultDockingLayout(savedDockingLayout); } dockManager.setDockingLayoutPersistanceFilePath(viewWorkspace.getDockingLayoutPath()); progress.endTask(); addCoreMenu(); }