📄 systemutilities.java
字号:
history = (Vector)object; } } } catch (IOException ioExc) { GUIUtilities.displayErrorMessage( "An IO error occurred reading previously " + "executed history:\n" + ioExc.getMessage()); history = new Vector(); } return history; } /** * Clears the SQL command history. */ public static final void clearSqlCommandHistory() { try { FileUtils.writeObject(new Vector(), historyFile); } catch (IOException ioExc) {} } /** * Adds the specified query to the SQL command list and * saves this to file. */ public static final void addSqlCommand(String query) { final Vector history = getSqlCommandHistory(); int size = history.size(); if (size == QueryEditorSettings.getHistoryMax()) { history.removeElementAt(size - 1); } history.add(0, query); GUIUtils.startWorker(new Runnable() { public void run() { try { FileUtils.writeObject(history, historyFile); } catch (IOException ioExc) { GUIUtilities.displayErrorMessage( "An IO error occurred adding the previously " + "executed query to history:\n" + ioExc.getMessage()); } } }); } /** * Returns whether database resources are available on * any connection within any pool. * * @return whether a connection to a database exists */ public static boolean isConnected() { return ConnectionManager.getActiveConnectionPoolCount() > 0; } /** * Disconnects the specified connection. * * @param dc - the connection to be disconnected */ public static final void disconnect(DatabaseConnection dc) throws DataSourceException { ConnectionManager.closeConnection(dc); EventMediator.fireEvent( new ConnectionEvent(dc), ConnectionListener.DISCONNECTED); updateStatusActiveConnections(); } /** * Updates the first status bar label with the active connection pool * data source count. */ public static void updateStatusActiveConnections() { GUIUtilities.getStatusBar().setFirstLabelText( " Active Data Sources: " + ConnectionManager.getActiveConnectionPoolCount()); } /** * Returns the open connection count for the specified connection. * * @param dc - the connection to be polled */ public static int getOpenConnectionCount(DatabaseConnection dc) { return ConnectionManager.getOpenConnectionCount(dc); } public static final boolean connect(DatabaseConnection dc) throws DataSourceException { ConnectionBuilder builder = null; try { builder = new ConnectionBuilder(); builder.establishConnection(dc); if (builder.isCancelled()) { return false; } boolean connected = builder.isConnected(); if (!connected) { DataSourceException e = builder.getException(); if (e != null) { throw e; } else { throw new RuntimeException( "Unknown error establishing connection."); } } EventMediator.fireEvent(new ConnectionEvent(dc), ConnectionListener.CONNECTED); GUIUtils.scheduleGC(); return true; } finally { if (builder != null) { builder.finished(); } updateStatusActiveConnections(); } } public static final DatabaseConnection[] getSavedConnections() { if (connections == null) { connections = ConnectionProperties.getConnectionsArray(); setSavedConnections(connections); } return connections; } public static void setSavedConnections(DatabaseConnection[] _savedConns) { connections = _savedConns; } /** * Returns the running Java VM version in full format using * <code>System.getProperty("java.version")</code>. * * @return the Java VM version */ public static final String getVMVersionFull() { return System.getProperty("java.version"); } /** * Returns the running Java VM version in short format (major versio only) * using <code>System.getProperty("java.version")</code>. * * @return the Java VM version */ public static final double getVMVersion() { return Double.parseDouble(System.getProperty("java.version").substring(0,3)); } /** * Returns the user defined setting for prompt to save open * documents/files etc before closing. * * @return true | false */ public static boolean isPromptingToSave() { return SystemProperties.getBooleanProperty("user", "general.save.prompt"); } /** * Program shutdown method. * Does some logging and closes connections cleanly. */ public static void exitProgram() { if (SystemProperties.getBooleanProperty("user", "general.save.prompt") && GUIUtilities.hasValidSaveFunction()) { if (GUIUtilities.getOpenSaveFunctionCount() > 0) { SaveOnExitDialog exitDialog = new SaveOnExitDialog(); int result = exitDialog.getResult(); if (result != SaveFunction.SAVE_COMPLETE || result != SaveOnExitDialog.DISCARD_OPTION) { exitDialog = null; return; } } } // close open connection pools Log.info("Releasing database resources..."); try { ConnectionManager.close(); } catch (DataSourceException e) {} Log.info("Connection pools destroyed"); GUIUtilities.shuttingDown(); GUIUtilities.getParentFrame().dispose(); System.exit(0); } /** * Returns the page format for printing. * * @return the page format */ public static PageFormat getPageFormat() { if (pageFormat == null) { pageFormat = PrintUtilities.getPageFormat(); } return pageFormat; } /** * Sets the page format to that specified. * * @param _pageFormat - the page format */ public static void setPageFormat(PageFormat _pageFormat) { pageFormat = _pageFormat; } /** * Returns whether user-defined locale settings have been set. */ public static boolean hasLocaleSettings() { String language = SystemProperties.getStringProperty("user", "locale.language"); String country = SystemProperties.getStringProperty("user", "locale.country"); String timezone = SystemProperties.getStringProperty("user", "locale.timezone"); // Log.debug("language: " + language + " country: " + country + // " timezone: " + timezone); return !(MiscUtils.isNull(language)) && !(MiscUtils.isNull(country)) && !(MiscUtils.isNull(timezone)); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -