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

📄 mainmenu.java

📁 JAVA开源LDAP浏览器jxplorer的源码!
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                        }
                    }
                    else
                    {
                        JXplorer.setProperty("option.ldap.browseAliasBehaviour", "never");
                        if (jxplorer.jndiBroker.getDirContext() != null)
                        {
                            jxplorer.jndiBroker.getDirContext().addToEnvironment("java.naming.ldap.derefAliases", "never");
                            //System.out.println("set to: " + jxplorer.jndiBroker.getDirContext().getEnvironment().get("java.naming.ldap.derefAliases"));
                        }
                    }
                }
                catch (Exception e2) {}   // XXX probably never happen :-)
            }
        });
    }



   /**
    *    Sets up the advanced options dialog (written so that it is set up when the user clicks on the menu item
    *    instead of being set up when JX starts.  The problem with advanced options being set up when JX starts
    *    (or really when MainMenu is set up) is that it forces CBHelpSystem to over ride the Thread priority so that
    *    a Help Set is supplied.
    */

    protected void setUpAdvancedOptions()
    {
        AdvancedOptions adOpt = new AdvancedOptions(jxplorer, this);
        CBUtility.center(adOpt, jxplorer);
        adOpt.setVisible(true);
    }


    protected void setupSSLMenu(JMenu sslMenu)
    {
        ActionListener sslListener = new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                JMenuItem item = (JMenuItem)e.getSource();

                if (item == simpleSSL)
                {
                    KeystoreGUI win = new KeystoreGUI(jxplorer, JXplorer.getMyProperties(),
                                                     JXplorer.getProperty(JXplorer.CA_PATH_PROPERTY),
                                                     null,
                                                     JXplorer.getProperty(JXplorer.CA_TYPE_PROPERTY),
                                                     CBIntText.get("Manage Your Trusted Server Certificates."),
                                                     false, HelpIDs.SSL_CERTS);
                    win.setSize(450,320);
                    CBUtility.center(win, jxplorer);
                    win.setVisible(true);  // may modify jxplorer properties
                }
                else if (item == authSSL)
                {
                    KeystoreGUI win = new KeystoreGUI(jxplorer, JXplorer.getMyProperties(),
                                                     JXplorer.getProperty(JXplorer.CLIENT_PATH_PROPERTY),
                                                     null,
                                                     JXplorer.getProperty(JXplorer.CLIENT_TYPE_PROPERTY),
                                                     CBIntText.get("Manage Your Own Private Keys and Certificates."),
                                                     true, HelpIDs.SSL_CERTS);
                    win.setSize(450,440);
                    CBUtility.center(win, jxplorer);
                    win.setVisible(true);  // may modify jxplorer properties
                }

                /*
                 *     allow the user to select which keystore files and keystore types to use.
                 */

                else if (item == keystoreOptions)
                {
                    KeystoreOptions options = new KeystoreOptions(jxplorer, JXplorer.getMyProperties());
                    options.setSize(530,260);
                    CBUtility.center(options, jxplorer);
                    options.setVisible(true);
                }
                jxplorer.repaint();
            }
        };

        simpleSSL = setMenuItem(sslMenu, sslListener,
            new String[] {CBIntText.get("Trusted Servers and CAs"),"u",
                          CBIntText.get("Setup which servers you trust for SSL."),
                          "E", dirImages+"sslcert.gif"} );	//TE: changed mnemonic from 'S' to 'u'.

        authSSL = setMenuItem(sslMenu, sslListener,
            new String[] {CBIntText.get("Client Certificates"),"C",
                          CBIntText.get("Setup client authentication (if available)."),
                          ("none".equals(JXplorer.getProperty("authprovider"))?"D":"E"), dirImages+"sslkeycert.gif"} );

        keystoreOptions = setMenuItem(sslMenu, sslListener,
            new String[] {CBIntText.get("Advanced Keystore Options"),"K",
                          CBIntText.get("Select your keystore locations and the type of keystore to use."),
                          "E", dirImages+"blankRec.gif"} );

    }


    protected void setupToolsMenu(JMenu toolsMenu)
    {
        String [][] toolsMenuItems =
                { {CBIntText.get("Stop Action"),"A", CBIntText.get("Stop the currently executing browser action."), "E", dirImages+"stop.gif"} };

        setMenu(toolsMenu, toolsMenuItems, new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
				String cmd = ((JMenuItem)e.getSource()).getName();

                if (cmd.equals(CBIntText.get("Stop Action")))
                {
                    jxplorer.getStopMonitor().show();
                }
                jxplorer.repaint();
            }
        });

		//TE: only enables the stop menu item if there is a query to stop.  If the stop menu
		//	  item is repositioned up date the getItem(0) method to the appropriate index.
		jxplorer.getStopMonitor().addWatcher(toolsMenu.getItem(0));
    }


    protected void setupHelpMenu(JMenu helpMenu)
    {
        ActionListener helpListener = new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                JMenuItem item = (JMenuItem)e.getSource();

                if (jxplorer.helpSystem == null && item != helpAbout)               // reality check - the help system
                {                                                                   // seems a bit flaky
                    CBUtility.error(jxplorer, "Unable to open Help System", null);
                    return;
                }

                if (item == helpContents)
                    jxplorer.helpSystem.openTab(HelpIDs.TAB_TOC);     //TE: opens the help with the table of contents tab visible.
                else if (item == helpSearch)                //TE: opens the help with the search tab visible.
                    jxplorer.helpSystem.openTab(HelpIDs.TAB_SEARCH);
                else if (item == helpAbout)
                    showAboutMessage();

                jxplorer.repaint();
            }
        };

        helpContents = setMenuItem(helpMenu, helpListener,
            new String[] {CBIntText.get("Contents"), "C", CBIntText.get("Display the help index."), "E", dirImages+"content.gif" } );

        helpSearch = setMenuItem(helpMenu, helpListener,
            new String[] {CBIntText.get("Search"),   "r", CBIntText.get("Search help for a keyword."), "E", dirImages+"search.gif" } );

        setMenuItem(helpMenu, helpListener, new String[] {"-", "", "", "", ""  } );  // separator

        helpAbout = setMenuItem(helpMenu, helpListener,
            new String[] {CBIntText.get("About"),    "A", CBIntText.get("General information about JXplorer."), "E", dirImages+"about.gif" } );



    }

   /**
    * Displays an about dialog in the center of JXplorer.
    * Switch display depending on whether it is the open source version or the commercial version...
	*/
    public void showAboutMessage()
    {
        // Open source license...
        File licence = new File(System.getProperty("user.dir") + File.separator + "licence.txt");
        if (licence.exists())
        {
            String textBody = JXplorer.version+"\n\nCopyright \u00a9 2005 CA. All rights reserved.";

            try
            {
                textBody = CBUtility.readTextFile(licence);
                textBody = JXplorer.version + "\n" +
                           "\nWritten by: Chris Betts" +
                           "\n            Trudi Ersvaer\n" +
                           "\nThanks to:  Jason Paul" +
                           "\n            Lachlan O'Dea" +
                           "\n            Van Bui\n\n\n" +
                           textBody;

            }
            catch (IOException e) {} // should still be set to original CA text.

            CBAbout about = new CBAbout(jxplorer, textBody, new ImageIcon(dirTemplates + "JXAboutBottom.gif"),
                        new ImageIcon(dirTemplates + "JXAboutTop.gif"), CBIntText.get("OK"), CBIntText.get("Close this window"), CBIntText.get("About JXplorer"));

            about.setSize(477, 350);
            about.setResizable(true);
            CBUtility.center(about, jxplorer);
            about.setVisible(true);
        }
        else
        {
            /* I don't think we can ship with the CA tau code?? - CB
            // CA license...
            File ca_licence = new File(System.getProperty("user.dir") + File.separator + "ca_license.txt");
            String textBody = null;
            try
            {
                textBody = CBUtility.readTextFile(ca_licence);
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }

            AboutBox about = new AboutBox(jxplorer, "eTrust\u2122 Directory JXplorer", JXplorer.version, "", "", textBody, HelpIDs.CONTACT_SUPPORT);
            about.setVisible(true);
            */
        }
    }



   /**
    *    Utility function; sets up a menu with a bunch of menu items
    *    defined as strings, with tooltips and enabled/disabled state.<p>
    *
    *    ... assumes listeners will be created for them elsewhere, and registered
    *    here.
    *    @param menu the menu object to add this menu item to
    *    @param menuItems an array of string arrays defining the various menu items: <br>
    *           each string array should have 4 elements:
    *           {"item name", "mnemonic", "tool tip text", enabled/disabled state ("E"/"D")}
    *    @param listener - a thingumy to monitor the menu item, and do something if it's
    *           checked.
    */

    protected void setMenu(JMenu menu, String [][] menuItems, ActionListener listener)
    {
        for (int i=0;i<menuItems.length;i++)
        {
            JMenuItem item = setMenuItem(menu, listener, menuItems[i]);
        }
    }

    /**
     *  Sets up a menu item with a list of strings
     *  @param menu the menu to add this menu item to
     *  @param menuItems - an array of 4 strings; the name, the hot key, the tip, and a single letter 'E' or 'D' for enabled/disabled
     *  @param listener an action listener for this menu item.
     *  @return the created menu item
     */

    protected JMenuItem setMenuItem(JMenu menu, ActionListener listener, String[] menuItems)
    {
        if (menuItems[0].equals("-"))
        {
            menu.add(new JSeparator());
            return null;
        }
        else
        {
			JMenuItem item = new JMenuItem(CBIntText.get(menuItems[0]), new ImageIcon(menuItems[4]));
			item.setName(menuItems[0]);		//TE: gives the menu item a name...fixes bug 2447 re stop button (because stop button was not assigned with a name).
			return setMenuItem(menu, item, listener, menuItems);
        }
    }


   /**
	*  Sets up a menu item with a list of strings
	*  @param menu the menu to add this menu item to
	*  @param menuItems - an array of 4 strings; the name, the hot key, the tip, and a single letter 'E' or 'D' for enabled/disabled
	*  @param listener an action listener for this menu item.
	*  @return the created menu item
	*/

	protected JMenuItem setMenuItem(JMenu menu, JMenuItem item, ActionListener listener, String[] menuItems)
	{
        //item.setName(menuItems[0]);

        setMenuItemState(menu, item, menuItems[1], menuItems[2], (menuItems[3].charAt(0)=='E'));
        if (listener != null) item.addActionListener(listener);
        return item;
    }

   /**
    *    Similar to @setMenu, but for checkboxes.  Note arguments; the string array is an
    *    element longer (to allow setting of check box state).
    *    @param menu the menu object to add this menu item to
    *    @param menuItems an array of string arrays defining the various menu items: <br>
    *           each string array should have 5 elements:
    *           {"item name", "mnemonic", "tool tip text", enabled/disabled state ("E"/"D"), and
    *             checked/unchecked state ("C"/"U") }
    *    @param listener - a thingumy to monitor the menu item, and do something if it's
    *           checked.
    */

   protected void setCheckBoxMenu(JMenu menu, String [][] menuItems, ActionListener listener)
    {
        for (int i=0;i<menuItems.length;i++)
        {
            if (menuItems[i][0].equals("-"))
                menu.add(new JSeparator());
            else
            {
                JCheckBoxMenuItem tmp = new JCheckBoxMenuItem(menuItems[i][0], new ImageIcon(menuItems[i][5]), (menuItems[i][4].charAt(0)=='C'));
                setMenuItemState(menu, tmp, menuItems[i][1], menuItems[i][2], (menuItems[i][3].charAt(0)=='E'));
                if (listener != null) tmp.addActionListener(listener);
            }
        }
    }

    /**
     *    Takes a menu Item and sets up state information such as the mnemonic, the tool tip
     *    text and the enabled/disabled state.
     *    @param menu the parent menu.
     *    @param menuItem the menu item being modified
     *    @param mnemonic the hot key (alt-'key', or prefixed with "ctr"+'key')
     *    @param toolTipText text displayed when the mouse hovers over component
     *    @param enabled whether the menu item is active, or greyed out.
     */

    protected void setMenuItemState(JMenu menu, JMenuItem menuItem, String mnemonic, String toolTipText, boolean enabled)
    {
        if (mnemonic.length()==1)
        {
            menuItem.setMnemonic(mnemonic.charAt(0));
        }
        else if (mnemonic.startsWith("Cnt")||mnemonic.startsWith("cnt")||mnemonic.startsWith("Ctr")||mnemonic.startsWith("ctr"))
        {
            char C = mnemonic.charAt(mnemonic.length()-1);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(C, java.awt.Event.CTRL_MASK, false));
        }
        menuItem.setToolTipText(toolTipText);
        menuItem.setEnabled(enabled);
        menu.add(menuItem);
    }



   /**
    *	Sets the image & icon paths.
	*/

	public void setImageDirs()
	{
		dirImages = JXplorer.getProperty("dir.images");
	 	dirIcons = JXplorer.getProperty("dir.icons");
		dirTemplates = JXplorer.getProperty("dir.templates");
	}
}

⌨️ 快捷键说明

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