⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 guiutilities.java

📁 eq跨平台查询工具源码 eq跨平台查询工具源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     */    public static void dockedTabComponentClosed(String key) {        // save the change        //layoutProperties.setDockedPaneVisible(key, false);                // update the system properties visible key        SystemProperties.setBooleanProperty("user", key, false);                // update the view menu item        JPanel panel = getDockedTabComponent(key);        if (panel != null && panel instanceof DockedTabView) {            DockedTabView tab = (DockedTabView)panel;            menuBar.setViewOption(tab.getMenuItemKey(), false);        }                // update properties to file        updatePreferencesToFile();            }        /**     * Displays or hides the docked tab component of the specified type.     *     * @param the property key of the component     * @param show/hide the view     */    public static void displayDockedComponent(String key, boolean display) {                if (display) {            ensureDockedTabVisible(key);        }        else {            // retrieve the panel from the cache            JPanel panel = getDockedTabComponent(key);                        if (panel != null && panel instanceof DockedTabView) {                DockedTabView _panel = (DockedTabView)panel;                String title = _panel.getTitle();                int position = getDockedComponentPosition(key);                // remove it from the pane                closeDockedComponent(title, position);                // save the change                layoutProperties.setDockedPaneVisible(key, false);            }        }            }        /**      * Closes the dialog with the specified title.     */    public static void closeDialog(String title) {        if (register.getOpenDialogCount() > 0) {            List<JDialog> list = register.getOpenDialogs();            for (int i = 0, k = list.size(); i < k; i++) {                JDialog dialog = list.get(i);                if (dialog.getTitle().startsWith(title)) {                    dialog.dispose();                    return;                }            }        }    }    /**      * Closes the currently in-focus dialog.      */    public static void closeSelectedDialog() {        if (register.getOpenDialogCount() > 0) {            List<JDialog> list = register.getOpenDialogs();            for (int i = 0, k = list.size(); i < k; i++) {                JDialog dialog = list.get(i);                // check if this is focused                if (dialog.isFocused()) {                    // dialog dispose                    dialog.dispose();                    return;                }            }        }    }        /** <p>Displays or hides the specified tool bar.     *     *  @param the tool bar     *  @param <code>true</code> to display | <code>false</code> to hide     */    public static void displayToolBar(String name, boolean display) {        ToolBarProperties.setToolBarVisible(name, display);        resetToolBar(false);    }        public static void initialiseViewToolsMenuItems() {        menuBar.initialiseViewToolsMenuItems(                ToolBarProperties.isToolBarVisible(ToolBarManager.FILE_TOOLS),                ToolBarProperties.isToolBarVisible(ToolBarManager.EDIT_TOOLS),                ToolBarProperties.isToolBarVisible(ToolBarManager.SEARCH_TOOLS),                ToolBarProperties.isToolBarVisible(ToolBarManager.DATABASE_TOOLS),                ToolBarProperties.isToolBarVisible(ToolBarManager.BROWSER_TOOLS),                ToolBarProperties.isToolBarVisible(ToolBarManager.IMPORT_EXPORT_TOOLS),                ToolBarProperties.isToolBarVisible(ToolBarManager.SYSTEM_TOOLS)        );    }        /**      * Displays or hides the main application status bar.     *     * @param <code>true</code> to display | <code>false</code> to hide     */    public static void displayStatusBar(boolean display) {        statusBar.setVisible(display);        SystemProperties.setBooleanProperty("user",                             "system.display.statusbar", display);    }        /** <p>Registers the application status bar with this class.     *     *  @param the status bar     */    public static void registerStatusBar(StatusBarPanel status) {        statusBar = status;    }        /** <p>Retrieves the main frame's layered pane object.     *     *  @return the frame's <code>JLayeredPane</code>     */    public static JLayeredPane getFrameLayeredPane() {        return ((JFrame)getParentFrame()).getLayeredPane();    }        /** <p>Retrieves the application's status bar as     *  registered with this class.     *     *  @return the application status bar     */    public static final StatusBarPanel getStatusBar() {        return statusBar;    }        public static void refreshConnectionMenu(DatabaseConnection[] savedConns) {                if (menuBar != null) {            menuBar.setConnectionsMenu(savedConns);        }    }        public static void addNewConnToMenu(DatabaseConnection c) {        menuBar.addNewConnectionMenu(c);    }    public static void addNewRecentFileToMenu(File file) {        String path = file.getAbsolutePath();        SystemUtilities.addRecentOpenFile(path);        menuBar.reloadRecentFileMenu();        /*        if (SystemUtilities.addRecentOpenFile(path)) {            menuBar.addNewRecentFileMenu(file.getName(), path);        }*/    }        public static void setLookAndFeel(int _lookAndFeel) {        lookAndFeel = _lookAndFeel;    }    /**     * Returns the current look and feel value.     */    public static final int getLookAndFeel() {        return lookAndFeel;    }        /**     * Saves the user preferences to file.     */    protected static void updatePreferencesToFile() {        GUIUtils.startWorker(new Runnable() {            public void run() {                SystemResources.setUserPreferences(                                    SystemProperties.getProperties("user"));            }        });    }        /**     * Sets the docked tab views according to user preference.     */    private static void setDockedTabViews(boolean reload) {        List<UserLayoutObject> list = layoutProperties.getLayoutObjectsSorted();        for (int i = 0, n = list.size(); i < n; i++) {            UserLayoutObject object = list.get(i);            String key = object.getKey();            if (object.isVisible()) {                initDockedTabView(key);                JPanel panel = getDockedTabComponent(key);                DockedTabView tab = (DockedTabView)panel;                String title = tab.getTitle();                int position = object.getPosition();                // first check if its already displayed                if (desktopMediator.getTabComponent(position, title) == null) {                    // add the component to the view                    addDockedTab(title, panel, position, false);                    //Log.debug("Adding docked tab: " + title);                                        // check if its minimised                    if (object.isMinimised()) {                        desktopMediator.minimiseDockedTab(position, title);                    }                                    }            }            else {                if (reload) {                    displayDockedComponent(key, false);                }            }        }    }    /**     * Notifies that user preferences have changed.<br>     * This will update relevant components and settings     * and save the new preferences to file.     */    public static void preferencesChanged() {        SwingUtilities.invokeLater(new Runnable() {            public void run() {                try {                    // save to file                    updatePreferencesToFile();                    // update the logger level                    Log.setLevel(SystemProperties.getProperty(                                            "user", "system.log.level"));                    // set misc display options                    setDisplayOptions(false);                    // update any open editors                    updateOpenEditors(false);                    // update the docked tab view options                    String[] keys = {ConnectionsTreePanel.PROPERTY_KEY,                                     DriversTreePanel.PROPERTY_KEY,                                     KeywordsDockedPanel.PROPERTY_KEY,                                     SQLStateCodesDockedPanel.PROPERTY_KEY,                                     SystemPropertiesDockedTab.PROPERTY_KEY,                                     SystemOutputPanel.PROPERTY_KEY};                    for (int i = 0; i < keys.length; i++) {                        layoutProperties.setDockedPaneVisible(                                keys[i],                                 SystemProperties.getBooleanProperty("user", keys[i]),                                 false);                    }                    layoutProperties.persist(); // save after looping all                    // update the docked tab view display                    setDockedTabViews(true);                    //setBrowserDisplayOptions(false);                    JDialog.setDefaultLookAndFeelDecorated(                        SystemProperties.getBooleanProperty("user", "decorate.dialog.look"));                    JFrame.setDefaultLookAndFeelDecorated(                        SystemProperties.getBooleanProperty("user", "decorate.frame.look"));                    // todo: conn options                    /*                    if (SystemUtilities.isConnected()) {                        DBConnection dbConn = new DBConnection();                        dbConn.updateConnectionProperties();                    }                                    */                    Log.info("System properties modified.");                }                finally {                    showNormalCursor();                }            }        });    }        /**     * Updates open editors with the user preferences.     * This will usually only be called following a user      * preference change.     */    public static void updateOpenEditors(boolean writeFile) {        QueryEditorSettings.initialise();        if (register.getOpenPanelCount() > 0) {            List<PanelCacheObject> list = register.getOpenPanels();            for (int i = 0, k = list.size(); i < k; i++) {                Component component = list.get(i).getComponent();                if (component instanceof QueryEditor) {                    QueryEditor editor = (QueryEditor)component;                    editor.setEditorPreferences();                }            }        }        menuBar.setEditorViewOptions();                if (writeFile) {            updatePreferencesToFile();        }            }        /**     * Retrieves a list of the open central panels that implement     * SaveFunction.     *     * @return the open SaveFunction panels     */    public static List<SaveFunction> getOpenSaveFunctionPanels() {        List<SaveFunction> saveFunctions = new ArrayList<SaveFunction>();        List<PanelCacheObject> panels = register.getOpenPanels();        for (int i = 0, k = panels.size(); i < k; i++) {            Component c = panels.get(i).getComponent();            if (c instanceof SaveFunction) {                SaveFunction saveFunction = (SaveFunction)c;                if (saveFunction.promptToSave()) {                    saveFunctions.add(saveFunction);                }            }        }        return saveFunctions;    }    /**     * Retrieves the number of open central panels that implement     * SaveFunction.     *     * @return the open SaveFunction panels count     */    public static int getOpenSaveFunctionCount() {        int count = 0;        List<PanelCacheObject> panels = register.getOpenPanels();        for (int i = 0, k = panels.size(); i < k; i++) {            if (panels.get(i).getComponent() instanceof SaveFunction) {                count++;            }        }        return count;    }        public static void closeConnection() {        // grab the selected connection from the         // connections tree docked panel and close it        JPanel panel = getDockedTabComponent(ConnectionsTreePanel.PROPERTY_KEY);        if (panel != null) {            DatabaseConnection dc = ((ConnectionsTreePanel)panel).                                        getSelectedDatabaseConnection();            if (dc != null && dc.isConnected()) {                try {                    SystemUtilities.disconnect(dc);                } catch (DataSourceException e) {                    displayErrorMessage(                            "Error disconnecting selected data source:\n"+                            e.getMessage());

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -