|
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-2003 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.javahelp; import java.io.IOException; import java.net.URL; import javax.swing.BoundedRangeModel; import javax.swing.DefaultBoundedRangeModel; import javax.swing.SwingUtilities; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; import javax.help.HelpSet; import javax.help.HelpSetException; import org.openide.cookies.InstanceCookie; import org.openide.loaders.XMLDataObject; import org.openide.util.Lookup; /** An XML processor for help set references. * Provides an instance of javax.swing.HelpSet. * @author Jesse Glick */ public final class HelpSetProcessor implements XMLDataObject.Processor, InstanceCookie.Of { /** "context" for merge attribute on helpsets */ public static final String HELPSET_MERGE_CONTEXT = "OpenIDE"; // NOI18N /** attribute (type Boolean) on helpsets indicating * whether they should be merged into the master or * not; by default, true */ public static final String HELPSET_MERGE_ATTR = "mergeIntoMaster"; // NOI18N public static final BoundedRangeModel parseModel = new DefaultBoundedRangeModel(0, 0, 0, 0); /** the XML file being parsed */ private XMLDataObject xml; /** the cached help set */ private HelpSet hs; /** Bind to an XML file. * @param xml the file */ public void attachTo(XMLDataObject xml) { if (this.xml == xml) return; hs = null; // XXX this is called way too often, why? this.xml = xml; Installer.err.log("processing help set ref: " + xml.getPrimaryFile()); BPMChanger.invoke(BPMChanger.INC_MAXIMUM); } /** Decrement count of available help sets. */ protected void finalize() { BPMChanger.invoke(BPMChanger.DEC_VALUE_AND_MAXIMUM); } /** The class being produced. * @throws IOException doesn't * @throws ClassNotFoundException doesn't * @return the class of helpsets */ public Class instanceClass() throws IOException, ClassNotFoundException { return HelpSet.class; } /** Get the name of the produced class. * @return the class of helpsets */ public String instanceName() { return "javax.help.HelpSet"; // NOI18N } /** Test whether a given superclass will be produced. * @param type the superclass * @return true if it is HelpSet */ public boolean instanceOf(Class type) { return type == HelpSet.class; } /** Create the help set. * @throws IOException if there was a problem parsing the XML * of the helpset file or otherwise producing * the helpset from its resource * @throws ClassNotFoundException doesn't * @return the help set */ public synchronized Object instanceCreate() throws IOException, ClassNotFoundException { if (hs == null) { Installer.err.log("creating help set from ref: " + xml.getPrimaryFile()); try { Document doc = xml.getDocument(); Element el = doc.getDocumentElement(); if (! el.getNodeName().equals("helpsetref")) throw new IOException(); // NOI18N String url = el.getAttribute("url"); // NOI18N if (url == null || url.equals("")) throw new IOException("no url attr on |
... 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.