|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.javadoc.search; import javax.swing.JPopupMenu; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.net.URL; import java.util.*; import java.lang.ref.Reference; import java.lang.ref.WeakReference; import javax.swing.JMenu; import javax.swing.JMenuItem; import org.openide.ErrorManager; import org.openide.awt.HtmlBrowser; import org.openide.awt.Mnemonics; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileSystem; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; import org.openide.util.actions.SystemAction; import org.openide.util.actions.Presenter; /** * Action which shows mounted Javadoc filesystems with known indexes as a submenu, * so you can choose a Javadoc set. * * @author Jesse Glick */ public final class IndexOverviewAction extends SystemAction implements Presenter.Menu { private static final ErrorManager err = ErrorManager.getDefault().getInstance("org.netbeans.modules.javadoc.search.IndexOverviewAction.IndexMenu"); // NOI18N public void actionPerformed(ActionEvent ev) { // do nothing -- should never be called } public String getName() { return NbBundle.getMessage(IndexOverviewAction.class, "CTL_INDICES_MenuItem"); } protected String iconResource() { return null; //"org/netbeans/modules/javadoc/resources/JavaDoc.gif"; // NOI18N } public HelpCtx getHelpCtx() { return new HelpCtx("javadoc.search"); // NOI18N } public JMenuItem getMenuPresenter() { return new IndexMenu(); } /** * Lazy menu which when added to its parent menu, will begin creating the * list of filesystems and finding their titles. When the popup for it * is created, it will create submenuitems for each available index. */ private final class IndexMenu extends JMenu implements HelpCtx.Provider { private int itemHash = 0; public IndexMenu() { Mnemonics.setLocalizedText(this, IndexOverviewAction.this.getName()); setIcon(IndexOverviewAction.this.getIcon()); } public HelpCtx getHelpCtx() { return IndexOverviewAction.this.getHelpCtx(); } public void addNotify() { if (err.isLoggable(ErrorManager.INFORMATIONAL)) { err.log("addNotify"); } super.addNotify(); IndexBuilder.getDefault(); } public JPopupMenu getPopupMenu() { List[] data = IndexBuilder.getDefault().getIndices(); int newHash = computeDataHash(data); if (newHash != itemHash) { if (err.isLoggable(ErrorManager.INFORMATIONAL)) { err.log("recreating popup menu (" + itemHash + " -> " + newHash + ")"); } itemHash = newHash; // Probably need to recreate the menu. removeAll(); List names = data[0]; // List |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.