@Override public void run() { if (isStartedUp() && !isShuttingDown()) { unexpectedShutdown = true; // fix BEAM-712 (nf 2007.11.02) logger.severe("Unexpectedly shutting down " + getAppName());/*I18N*/ handleImminentExit(); } else { logger.severe("Nominally shutting down " + getAppName());/*I18N*/ } } };
public final void savePreferences() { if (preferencesFile == null) { return; } setPreferences(); try { logger.info("Storing user preferences in '" + preferencesFile.getPath() + "'...");/*I18N*/ getPreferences().store(preferencesFile, getAppName() + " " + getAppVersion() + " - User preferences file"); logger.info("User preferences stored");/*I18N*/ } catch (IOException ignored) { logger.warning("Failed to store user preferences");/*I18N*/ } }
@Override public final void mouseEntered(MouseEvent evt) { if (evt.getSource() instanceof AbstractButton) { AbstractButton button = (AbstractButton) evt.getSource(); Action action = button.getAction(); if (action != null) { String message = (String) action.getValue(Action.SHORT_DESCRIPTION); if (message != null && message.length() > 0) { _oldMessage = getStatusBarMessage(); setStatusBarMessage(message); } } } }
protected String getMainFrameTitle() { return getAppName() + " " + getAppVersion(); }
public final void showOutOfMemoryErrorDialog(String message) { showErrorDialog("Out of Memory", String.format("%s is out of memory.\n%s\n\n" + "You can try to release memory by closing products or image views which\n" + "you currently not really need.\n" + "If this does not help, you can increase the amount of virtual memory\n" + "as described on the BEAM website at http://envisat.esa.int/services/beam/.", getAppName(), message ) ); }
pm.beginTask("Starting " + getAppName(), 6); initLogger(); initBeamUserDir(); initResources(); initPreferences(); logStartUpInfo(); pm.worked(1); initCommandManager(); initMainFrame(); initShutdownHook(); initLookAndFeel(); configureLayoutPersitence(); configureDockingManager(); pm.worked(1); initClient(SubProgressMonitor.create(pm, 1)); configureCommandsByResourceBundle(); initMainMenuBar(); initMainToolBar(); initMainPane(); initStatusBar(); initFrameIcon(); pm.worked(1); initClientUI(SubProgressMonitor.create(pm, 1));
boolean startingUp = !isStartedUp(); boolean mustUpdateComponentTreeUI = initLookAndFeel(); final boolean useSystemFontSettings = getPreferences().getPropertyBool( PROPERTY_KEY_APP_UI_USE_SYSTEM_FONT_SETTINGS, currentUseSystemFontSettings); if (currentUseSystemFontSettings != useSystemFontSettings) { final String fontName = getPreferences().getPropertyString(PROPERTY_KEY_APP_UI_FONT_NAME, currentMenuFont.getName()); final int fontSize = getPreferences().getPropertyInt(PROPERTY_KEY_APP_UI_FONT_SIZE, currentMenuFont.getSize()); if (!currentMenuFont.getName().equalsIgnoreCase(fontName) || currentMenuFont.getSize() != fontSize) { changeUIDefaultsFonts(uiDefaults, fontName, fontSize); mustUpdateComponentTreeUI = true; if (mustUpdateComponentTreeUI && getMainFrame().isVisible()) { updateComponentTreeUI();
public final void handleUnknownException(Throwable e) { Debug.trace(e); String message; if (e == null) { message = "An unknown error occurred."; /*I18N*/ } else if (e.getMessage() == null) { message = "An exception occurred:\n" + " Type: " + e.getClass().getName() + "\n" + " No message text available."; /*I18N*/ } else { message = "An exception occurred:\n" + " Type: " + e.getClass().getName() + "\n" + " Message: " + e.getMessage(); /*I18N*/ } getMainFrame().setCursor(Cursor.getDefaultCursor()); setStatusBarMessage("Error."); logger.log(Level.SEVERE, message, e); showErrorDialog("Error", message); clearStatusBarMessage(); }
Assert.argument(!lastDirPropertyKey.isEmpty(), "!lastDirPropertyKey.isEmpty()"); String lastDir = getPreferences().getPropertyString(lastDirPropertyKey, SystemUtils.getUserHomeDir().getPath()); File currentDir = new File(lastDir); fileChooser.setSelectedFile(new File(FileUtils.exchangeExtension(fileName, defaultExtension))); fileChooser.setDialogTitle(getAppName() + " - " + title); fileChooser.setFileSelectionMode(dirsOnly ? JFileChooser.DIRECTORIES_ONLY : JFileChooser.FILES_ONLY); int result = fileChooser.showSaveDialog(getMainFrame()); if (fileChooser.getCurrentDirectory() != null) { getPreferences().setPropertyString(lastDirPropertyKey, lastDirPath);
public final void showMessageDialog(String title, String message, int messageType, String preferencesKey) { if (suppressibleOptionPane != null && !StringUtils.isNullOrEmpty(preferencesKey)) { suppressibleOptionPane.showMessageDialog(preferencesKey, getMainFrame(), message, getAppName() + " - " + title, messageType); } else { JOptionPane.showMessageDialog(getMainFrame(), message, getAppName() + " - " + title, messageType); } }
private void initPreferences() { preferences = new PropertyMap(); preferences.setPropertyBool(PROPERTY_KEY_APP_DEBUG_ENABLED, false); preferences.setPropertyString(PROPERTY_KEY_APP_UI_FONT_NAME, "SansSerif"); preferences.setPropertyInt(PROPERTY_KEY_APP_UI_FONT_SIZE, 12); preferences.setPropertyBool(PROPERTY_KEY_APP_LOG_ENABLED, false); preferences.setPropertyString(PROPERTY_KEY_APP_LOG_PREFIX, getAppName()); preferences.setPropertyString(PROPERTY_KEY_APP_LOG_LEVEL, SystemUtils.LLS_INFO); preferences.setPropertyBool(PROPERTY_KEY_APP_LOG_ECHO, false); preferencesFile = new File(appUserDir, "preferences.properties"); loadPreferences(); suppressibleOptionPane = new SuppressibleOptionPane(getPreferences()); }
/** * Exits the application. <p>The base class implementation calls <code>setShuttingDown(true)</code>, calls * {@link #handleImminentExit()} and disposes the main frame. * <p/> * <p> When this method is overridden, this base class's implementation should always be called last. However, the * preferred way to change the shutdown behaviour is to override the {@link #handleImminentExit()} method. */ public void shutDown() { setShuttingDown(true); handleImminentExit(); getMainFrame().dispose(); System.exit(0); }
protected boolean initLookAndFeel() { try { UIManager.installLookAndFeel("Napkin", "net.sourceforge.napkinlaf.NapkinLookAndFeel"); } catch (Throwable e) { // ignored, because Napkin LAF is no important } String currentLafClassName = UIManager.getLookAndFeel().getClass().getName(); String defaultLafClassName = getDefaultLookAndFeelClassName(); String newLafClassName = getPreferences().getPropertyString(PROPERTY_KEY_APP_UI_LAF, defaultLafClassName); // This should fix a problem occurring in JIDE 3.3.5 with the GTKLookAndFeel (nf, 2012-03-02) if (newLafClassName.equals("com.sun.java.swing.plaf.gtk.GTKLookAndFeel")) { newLafClassName = defaultLafClassName; } if (!uiDefaultsInitialized || !currentLafClassName.equals(newLafClassName)) { try { UIManager.setLookAndFeel(newLafClassName); getPreferences().setPropertyString(PROPERTY_KEY_APP_UI_LAF, newLafClassName); } catch (Throwable ignored) { // ignore } try { loadJideExtension(); } catch (Throwable ignored) { // ignore } return true; } return false; }
@Override public void clearStatusBarMessage() { final ProductSceneView sceneView = getSelectedProductSceneView(); if (sceneView == null) { super.clearStatusBarMessage(); return; } final RasterDataNode raster = sceneView.getRaster(); super.setStatusBarMessage(raster.getDisplayName() + " - " + getCSName(raster)); }
private void initMainMenuBar() { CommandBar menuBar = createMainMenuBar(); if (menuBar != null) { menuBar.getContext().setInitSide(DockableBarContext.DOCK_SIDE_NORTH); menuBar.getContext().setInitIndex(1); getMainFrame().getDockableBarManager().addDockableBar(menuBar); insertCommandMenuItems(); } }
int x = getPreferences().getPropertyInt("frame.location.x", -1); int y = getPreferences().getPropertyInt("frame.location.y", -1); int width = getPreferences().getPropertyInt("frame.size.width", 0); int height = getPreferences().getPropertyInt("frame.size.height", 0); getMainFrame().setBounds(x, y, width, height); frameBoundsRestored = true; bV = getPreferences().getPropertyBool("view.showToolBar", Boolean.TRUE); command = commandManager.getExecCommand("showToolBar"); if (command != null) { bV = getPreferences().getPropertyBool("view.showStatusBar", Boolean.TRUE); command = commandManager.getExecCommand("showStatusBar"); if (command != null) { fileHistory.initBy(getPreferences()); bV = getPreferences().getPropertyBool(PROPERTY_KEY_APP_DEBUG_ENABLED, Boolean.FALSE); debugEnabled = bV; if (debugEnabled) { applyLookAndFeelPreferences();
/** * Called by the <code>exit</code> method. The default implementation first saves the user preferences. * You should not call this method directly. If you override this method, make sure to call the base * class version as well. * * @see #savePreferences() */ protected void handleImminentExit() { Debug.trace(getAppName() + ": handleImminentExit entered"); if (!unexpectedShutdown) { // fix BEAM-712 (nf 2007.11.02) Debug.trace("(1)"); LayoutPersistence layoutPersistence = getMainFrame().getLayoutPersistence(); if (layoutPersistence != null) { layoutPersistence.saveLayoutData(); // produces a dead lock, method is certainly not threadsafe! } } Debug.trace("(2)"); savePreferences(); Debug.trace("(3)"); HelpSys.dispose(); // todo - disposing the HelpSystem should be done in the BeamUiActivator.stop() method Debug.trace(getAppName() + ": handleImminentExit exited"); }
file = showFileSaveDialogImpl(title, dirsOnly, fileFilter, return null; // Cancel } else if (file.exists()) { int status = JOptionPane.showConfirmDialog(getMainFrame(), MessageFormat.format( "The file ''{0}'' already exists.\nOverwrite it?", file), MessageFormat.format("{0} - {1}", getAppName(), title), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE
protected final void setPreferences() { ////////////////////////////////////////////////////////////// // Store file history fileHistory.copyInto(getPreferences()); ////////////////////////////////////////////////////////////// // Store frame properties getPreferences().setPropertyInt("frame.location.x", getMainFrame().getLocation().x); getPreferences().setPropertyInt("frame.location.y", getMainFrame().getLocation().y); getPreferences().setPropertyInt("frame.size.width", getMainFrame().getSize().width); getPreferences().setPropertyInt("frame.size.height", getMainFrame().getSize().height); getPreferences().setPropertyBool("frame.ui.dblbuf", RepaintManager.currentManager(getMainFrame()).isDoubleBufferingEnabled()); ////////////////////////////////////////////////////////////// getPreferences().setPropertyBool(PROPERTY_KEY_APP_DEBUG_ENABLED, debugEnabled); }
private void initMainFrame() { mainFrame = new MainFrame(); mainFrame.setTitle(getMainFrameTitle()); mainFrame.setName("mainFrame" + getAppName()); mainFrame.setDefaultCloseOperation(MainFrame.DO_NOTHING_ON_CLOSE); mainFrame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { Debug.trace("BasicApp: application main frame is closing, calling exit handler..."); closeHandler.actionPerformed(new ActionEvent(e.getSource(), e.getID(), "close")); } }); }