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

📄 advancedoptions.java

📁 JAVA开源LDAP浏览器jxplorer的源码!
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        getOwner().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

        // Force a refresh of the attribute display...so that the fields don't disappear (bug 367)...
		(jx.getAttributeDisplay()).refreshEditors();
    }

    /**
     * Sets the look and feel and registers it in the property file.
     * @param lf the look and feel (package name).
     * @param pos the position of the lf in the radio buttons.
     * @return the selected radio button.
     * @throws ClassNotFoundException
     * @throws InstantiationException
     * @throws IllegalAccessException
     * @throws UnsupportedLookAndFeelException
     */
    private JRadioButton setNewLookAndFeel(String lf, int pos)
            throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException
    {
        // If this fails we know which L&F made it fail...
        JRadioButton rb = lookAndFeel[pos];
        UIManager.setLookAndFeel(lf);

        // Updates the 'gui.lookandfeel' value in the dxconfig property file with the windows L&F...
        JXplorer.setProperty("gui.lookandfeel", lf);
        return rb;
    }

    /**
     * There must be a better way of doing this but here it is anyway...
     * This method tries to make sure that the whole of JXplorer actually gets
     * the new Look and Feel.  It should work by just using...
     * <br>'SwingUtilities.updateComponentTreeUI(getOwner());',<br>
     * but some components are forgotten about - such as this window, the search
     * gui and the popup tree tool.  So this method manually tells them to update.
     * But thats not all - each tree has its own copy of the search gui & the popup
     * tree tool...so each tree needs to be told to update these components.
     * In all there are eight calls to the updateComponentTreeUI...phew.
     */
    private void updateLookAndFeel()
    {
        if ((getOwner() instanceof JXplorer) == false)
        {
            SwingUtilities.updateComponentTreeUI(getOwner());
            return;
        }

        JXplorer jx = (JXplorer) getOwner();

//TE XXXXXXXXXX this produces bug 2578..........
        // Update the bulk of JXplorer with the new L&F...
        SwingUtilities.updateComponentTreeUI(jx);

        // Make sure this window gets the new L&F too...
        SwingUtilities.updateComponentTreeUI(this);

        // Get the trees...
        SmartTree explore = jx.getTree();
        SmartTree search = jx.getSearchTree();
        SmartTree schema = jx.getSchemaTree();

        // To stop the truncation of tree nodes esp in Java L&F...what a joke....
        SwingUtilities.updateComponentTreeUI(explore);
        SwingUtilities.updateComponentTreeUI(search);
        SwingUtilities.updateComponentTreeUI(schema);

        // Make sure each tree's popup menu gets the new L&F...
        SwingUtilities.updateComponentTreeUI(explore.getPopupTool());
        SwingUtilities.updateComponentTreeUI(search.getPopupTool());
        SwingUtilities.updateComponentTreeUI(schema.getPopupTool());

        // Make sure each tree's search dialog gets the new L&F...
        SearchGUI sExplore = explore.getSearchGUI();
        SearchGUI sSearch = search.getSearchGUI();
        SearchGUI sSchema = schema.getSearchGUI();

        if (sExplore != null)
            SwingUtilities.updateComponentTreeUI(sExplore);
        if (sSearch != null)
            SwingUtilities.updateComponentTreeUI(sSearch);
        if (sSchema != null)
            SwingUtilities.updateComponentTreeUI(sSchema);
    }

    /**
     * Checks if the log method has been changed.
     * If so updates the property file and sets
     * the log method as requested.
     */
    private void checkLogMethod()
    {
        try
        {
            int logMethod = logMethodCombo.getSelectedIndex();

            String original = JXplorer.getProperty("handlers");

            switch (logMethod)
            {
                case 0:
                    JXplorer.setProperty("handlers", "");
                    break;
                case 1:
                    JXplorer.setProperty("handlers", "java.util.logging.ConsoleHandler");
                    break;
                case 2:
                    JXplorer.setProperty("handlers", "java.util.logging.FileHandler");
                    break;
                case 3:
                    JXplorer.setProperty("handlers", "java.util.logging.ConsoleHandler,java.util.logging.FileHandler");
                    break;
                default:
                    JXplorer.setProperty("handlers", "java.util.logging.ConsoleHandler,java.util.logging.FileHandler");
            }

            if (original.equals(JXplorer.getProperty("handlers")) == false)
            {
                JXplorer.writePropertyFile();
                JXplorer.setupLogger();
            }


            //TODO implement Full GUI for java logging of JX packages - may have to wait for Sun to fix the broken logging system :-)
        }
        catch (Exception e)
        {
            return;  // Should never happen. TODO: log properly
        }

    }

    /**
     * Checks if the log level has been changed.
     * If so updates the property file and sets
     * the log level as requested.
     */
    private void checkLogLevel()
    {
        String original = JXplorer.getProperty(".level");

        switch (logLevelCombo.getSelectedIndex())
        {
            case 0:
                {
                    JXplorer.setProperty(".level", "SEVERE");
                    JXplorer.setProperty("com.ca.level", "SEVERE");
                    break;
                }     //TE: Errors Only option.
            case 1:
                {
                    JXplorer.setProperty(".level", "WARNING");
                    JXplorer.setProperty("com.ca.level", "WARNING");
                    break;
                }    //TE: Basic option.
            case 2:
                {
                    JXplorer.setProperty(".level", "INFO");
                    JXplorer.setProperty("com.ca.level", "INFO");
                    break;
                }       //TE: Tree Operations option.
            case 3:
                {
                    JXplorer.setProperty(".level", "FINE");
                    JXplorer.setProperty("com.ca.level", "FINE");
                    break;
                }       //TE: Extensive option.
            case 4:
                {
                    JXplorer.setProperty(".level", "FINEST");
                    JXplorer.setProperty("com.ca.level", "FINEST");
                    break;
                }     //TE: All option.
            case 5:
                {
                    JXplorer.setProperty(".level", "ALL");
                    JXplorer.setProperty("com.ca.level", "ALL");
                    break;
                }        //TE: All + BER Trace option.
            default:
                {
                    JXplorer.setProperty(".level", "WARNING");
                    JXplorer.setProperty("com.ca.level", "WARNING");
                    break;
                }   //TE: Errors Only option.
        }

        if (original.equals(JXplorer.getProperty(".handlers")) == false)
        {
            JXplorer.writePropertyFile();
            JXplorer.setupLogger();
        }

        // Set the values for immediate use...
        jx.checkSpecialLoggingActions();
    }

    /**
     * Checks if the ldap levels have been changed by getting the values from the text areas.
     * Sets the changes in the property file and in searchBroker.
     */
    private void checkLdapLevels()
    {
        String limit = ldapLimit.getText();
        String timeout = ldapTimeout.getText();

        try
        {
            // Make sure the values are of integer type...
            Integer.valueOf(limit);
            Integer.valueOf(timeout);
        }
        catch (NumberFormatException e)
        {
            CBUtility.error("Both Ldap Limit & Ldap timeout must be of Integer type.\n" + e);
            getLdapLevels();
        }

        // Set the values in the property file...
        JXplorer.setProperty("option.ldap.limit", limit);
        JXplorer.setProperty("option.ldap.timeout", timeout);

        // Sets the values in searchBroker for immediate use...
        jx.searchBroker.setTimeout(Integer.parseInt(timeout));
        jx.searchBroker.setLimit(Integer.parseInt(limit));
    }

    /**
     * Checks what the URL handling is and sets it in the property file.
     * Does this by getting the user selected index...if 0 then
     * 'JXplorer' if 1 then 'Launch'.
     */
    private void checkUrlHandling()
    {
        int index = urlCombo.getSelectedIndex();

        if (index == 1)
            JXplorer.setProperty("option.url.handling", "Launch");
        else
            JXplorer.setProperty("option.url.handling", "JXplorer");
    }

   /**
    * Checks what the URL handling is and sets it in the property file.
    * Does this by getting the user selected index...if 0 then
    * 'JXplorer' if 1 then 'Launch'.
    */
    private void checkCachePwds()
    {
        int index = cachePwdCombo.getSelectedIndex();

        if(index == 1)
            JXplorer.setProperty("jxplorer.cache.passwords", "false");
        else
            JXplorer.setProperty("jxplorer.cache.passwords", "true");
    }

   /**
     * Resets all values in the advanced options window back to the values in the property file.
     */
    private void reset()
    {
        getLookAndFeel();
        getLogLevel();
        getLogMethod();
        getLdapLevels();
        getURLHandling();
        getPasswordCachingOption();
    }

    /**
     * Shuts the advanced options dialog.
     */
    private void quit()
    {
        setVisible(false);
        dispose();
    }
}

⌨️ 快捷键说明

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