private static void showError(BasicApp app, final String message) { JOptionPane.showMessageDialog(null, message, app.getAppName(), JOptionPane.ERROR_MESSAGE); } }
private void initShutdownHook() { Thread shutdownHook = new Thread(getAppName() + " shut-down hook") { @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*/ } } }; Runtime.getRuntime().addShutdownHook(shutdownHook); }
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 ) ); }
protected String getMainFrameTitle() { return getAppName() + " " + getAppVersion(); }
@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 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); } }
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*/ } }
public final int showQuestionDialog(String title, String message, boolean allowCancel, String preferencesKey) { if (suppressibleOptionPane != null && !StringUtils.isNullOrEmpty(preferencesKey)) { return suppressibleOptionPane.showConfirmDialog(preferencesKey, getMainFrame(), message, getAppName() + " - " + title, allowCancel ? JOptionPane.YES_NO_CANCEL_OPTION : JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE ); } else { return JOptionPane.showConfirmDialog(getMainFrame(), message, getAppName() + " - " + title, allowCancel ? JOptionPane.YES_NO_CANCEL_OPTION : JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE ); } }
fileChooser.setSelectedFile(new File(FileUtils.exchangeExtension(fileName, defaultExtension))); fileChooser.setDialogTitle(getAppName() + " - " + title); fileChooser.setFileSelectionMode(dirsOnly ? JFileChooser.DIRECTORIES_ONLY : JFileChooser.FILES_ONLY);
private void configureLayoutPersitence() { getMainFrame().getLayoutPersistence().setProfileKey(getAppName()); getMainFrame().getLayoutPersistence().setUsePref(false); getMainFrame().getLayoutPersistence().setLayoutDirectory(appUserDir.getPath()); getMainFrame().getLayoutPersistence().beginLoadLayoutData(); getMainFrame().getDockableBarManager().setProfileKey(getAppName()); }
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")); } }); }
/** * 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"); }
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()); }
fileChooser.setFileFilter(fileFilter); fileChooser.setDialogTitle(getAppName() + " - " + title); fileChooser.setFileSelectionMode(dirsOnly ? JFileChooser.DIRECTORIES_ONLY : JFileChooser.FILES_ONLY); int result = fileChooser.showOpenDialog(getMainFrame());
"The file ''{0}'' already exists.\nOverwrite it?", file), MessageFormat.format("{0} - {1}", getAppName(), title), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE
private void configureDockingManager() { getMainFrame().getDockingManager().setProfileKey(getAppName()); getMainFrame().getDockingManager().setInitBounds(new Rectangle(0, 0, 960, 800)); getMainFrame().getDockingManager().setInitSplitPriority(DefaultDockingManager.SPLIT_SOUTH_NORTH_EAST_WEST); getMainFrame().getDockingManager().setInitDelay(100); getMainFrame().getDockingManager().setSteps(1); getMainFrame().getDockingManager().setStepDelay(0); getMainFrame().getDockingManager().setUndoLimit(0); getMainFrame().getDockingManager().setFloatable(true); getMainFrame().getDockingManager().setShowGripper(false); getMainFrame().getDockingManager().setDragGripperOnly(false); getMainFrame().getDockingManager().setContinuousLayout(true); getMainFrame().getDockingManager().setAutoDockingAsDefault(false); getMainFrame().getDockingManager().setHideFloatingFramesWhenDeactivate(true); getMainFrame().getDockingManager().setHideFloatingFramesOnSwitchOutOfApplication(true); // getMainFrame().getDockingManager().setOutlineMode(DockingManager.PARTIAL_OUTLINE_MODE); // getMainFrame().getDockingManager().setOutlineMode(DockingManager.MIX_OUTLINE_MODE); getMainFrame().getDockingManager().setOutlineMode(DockingManager.FULL_OUTLINE_MODE); }
pm.beginTask("Starting " + getAppName(), 6);