|
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-2002 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.javahelp; import java.util.*; import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.help.HelpSet; import org.openide.ErrorManager; import org.openide.util.*; import org.netbeans.api.javahelp.Help; /** An implementation of the JavaHelp system (a little more concrete). * @author Jesse Glick */ public abstract class AbstractHelp extends Help implements HelpConstants { /** constructor for subclasses */ protected AbstractHelp() {} /** the results of the search for helpsets */ private Lookup.Result helpsets = null; /** Get all available help sets. * Pay attention to {@link #helpSetsChanged} to see * when this set will change. * @return a collection of HelpSet */ protected final Collection getHelpSets() { if (helpsets == null) { Installer.err.log("searching for instances of HelpSet..."); helpsets = Lookup.getDefault().lookup(new Lookup.Template(HelpSet.class)); helpsets.addLookupListener(new LookupListener() { public void resultChanged(LookupEvent ev) { helpSetsChanged(); } }); fireChangeEvent(); // since someone may be listening to whether they are ready } Collection c = helpsets.allInstances(); if (Installer.err.isLoggable(ErrorManager.INFORMATIONAL)) { List l = new ArrayList(Math.min(1, c.size())); Iterator it = c.iterator(); while (it.hasNext()) { l.add(((HelpSet)it.next()).getTitle()); } Installer.err.log("listing helpsets: " + l); } return c; } /** Are the help sets ready? * @return true if they have been loaded */ protected final boolean helpSetsReady() { return helpsets != null; } /** Whether a given help set is supposed to be merged * into the master set. * @param hs the help set * @return true if so */ protected final boolean shouldMerge(HelpSet hs) { Boolean b = (Boolean)hs.getKeyData(HELPSET_MERGE_CONTEXT, HELPSET_MERGE_ATTR); return (b == null) || b.booleanValue(); } /** Called when the set of available help sets changes. * Fires a change event to listeners; subclasses may * do extra cleanup. */ protected void helpSetsChanged() { Installer.err.log("helpSetsChanged"); fireChangeEvent(); } public final void addChangeListener(ChangeListener l) { synchronized (listeners) { listeners.add(l); } } public final void removeChangeListener(ChangeListener l) { synchronized (listeners) { listeners.remove(l); } } /** all change listeners */ private final Set listeners = new HashSet(1); // Set |
... 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.