@Override public void actionPerformed(ActionEvent e) { // Initialize helpSet String helpHS = "/resources/javahelp/TetradHelp.hs"; try { URL url = this.getClass().getResource(helpHS); HelpSet helpSet = new HelpSet(null, url); helpSet.setHomeID("graph_edge_types"); HelpBroker broker = helpSet.createHelpBroker(); ActionListener listener = new CSH.DisplayHelpFromSource(broker); listener.actionPerformed(e); } catch (Exception ee) { System.out.println("HelpSet " + ee.getMessage()); System.out.println("HelpSet " + helpHS + " not found"); throw new IllegalArgumentException(); } } });
/** * Find the helpset file and create a HelpSet object. */ private HelpSet getHelpSet(String helpsetfile) throws HelpSetException { HelpSet hs = null; ClassLoader cl = this.getClass().getClassLoader(); URL hsURL = HelpSet.findHelpSet(cl, helpsetfile); hs = new HelpSet(null, hsURL); return hs; }
/** * @return true if we successfully added the help set, else false */ public static boolean addHelpSet(final HelpSet newHelpSet) { try { masterHelpSet.add(newHelpSet); return true; } catch (final Exception e) { return false; } }
public HelpBroker getHelpBroker() throws HelpSetException, MalformedURLException { if (broker == null) { HelpSet helpSet = new HelpSet(Application.class.getClassLoader(), new URL(helpBrokerUrl)); broker = helpSet.createHelpBroker(); } return broker; } }
protected JaxxHelpBroker(String helpsetName, String helpKey, String defaultID) { if (helpsetName == null) { throw new NullPointerException("parameter helpsetName can not be null!"); } this.helpsetName = helpsetName; this.helpKey = helpKey; this.defaultID = defaultID; cache = new HashMap<Component, String>(); try { ClassLoader cl = getClass().getClassLoader(); URL url = HelpSet.findHelpSet(cl, helpsetName); helpset = new HelpSet(cl, url); helpBroker = helpset.createHelpBroker(); } catch (Exception ee) { throw new IllegalStateException("could not find help set " + helpsetName + " for reason " + ee.getMessage(), ee); } }
JHelp helpViewer = null; try { // Get the classloader of this class. ClassLoader cl = JavaHelpTest.class.getClassLoader(); // Use the findHelpSet method of HelpSet to create a URL referencing the helpset file. // Note that in this example the location of the helpset is implied as being in the same // directory as the program by specifying "jhelpset.hs" without any directory prefix, // this should be adjusted to suit the implementation. URL url = HelpSet.findHelpSet(cl, "jhelpset.hs"); // Create a new JHelp object with a new HelpSet. helpViewer = new JHelp(new HelpSet(cl, url)); }
/** * Creates a presentation object for this HelpSet. * Consults the <tt>implRegistry</tt> of <tt>KeyData</tt> for * the class name (as helpBrokerClass) and for the ClassLoader * instance (as helpBrokerLoader) and then tries to instantiate * that class. It then invokes <tt>setHelpSet()</tt> with * this instance of HelpSet as the argument. The resulting object is * returned. * @see createHelpBroker(String) */ public HelpBroker createHelpBroker() { return createHelpBroker(null); }
URL base = hs.getHelpSetURL(); subHS = new HelpSet(hs.getLoader(), u); if (subHS != null) { hs.addSubHelpSet(subHS);
readExternalHelpSet(); if (hs == null) { hs = new HelpSet(); hs.setLocalMap(new TryMap()); } else { logger.info("EmptyHelp set to false"); for (Object idAsObject : Collections.list(hs.getLocalMap().getAllIDs())) { final ID id = (ID) idAsObject; String stringId = id.getIDString();
connection.setConnectTimeout(TIMEOUT); connection.connect(); hs = new HelpSet(null, new URL(externalHelpSetURL)); if (hs.getLocalMap() == null) { hs = null; logger.error("Helpset from " + externalHelpSetURL + " local map was null");
/** * This methods creates a HelpSet based upon, in priority, the external * HelpSet, the backup HelpSet a newly created empty HelpSet. */ public static void initialize() { if (!initialized) { prb = (PropertyResourceBundle) ResourceBundle .getBundle("helpcollator"); readExternalHelpSet(); if (hs == null) { readBackupHelpSet(); } if (hs == null) { hs = new HelpSet(); hs.setLocalMap(new TryMap()); } else { logger.info("EmptyHelp set to false"); emptyHelp = false; } idMap = new HashMap<Component, String>(); nonAlphanumeric = Pattern.compile("[^a-z0-9\\.]"); initialized = true; } }
/** * As above but default on locale to Locale.getDefault() * * @param cl The ClassLoader to use. If cl is null the default * ClassLoader is used. * @param name The name of the resource. * @return Null if not found. */ public static URL findHelpSet(ClassLoader cl, String name) { return findHelpSet(cl, name, Locale.getDefault()); }
/** * Returns the content of the secondary viewer */ public String getContent() { // return the URL of the ident if set if (ident != null) { Map map = hs.getCombinedMap(); try { URL url = map.getURLFromID(ident); return (url.toExternalForm()); } catch (Exception ex) { } } // just return the content even if "" return content; }
Hashtable attributes) { String spec = (String) attributes.get("location"); URL hsURL = hs.getHelpSetURL(); try { Map map = new FlatMap(new URL(hsURL, spec), hs); Map omap = hs.getLocalMap(); if (omap == null) { debug("map is null"); hs.setLocalMap(map); } else { hs.setLocalMap(omap); } else { debug("map is not TryMap"); tmap.add(omap); tmap.add(map); hs.setLocalMap(tmap);
ident = helpset.getHomeID(); HelpSet hs = ident.hs; if (! helpset.contains(hs)) { Map map = helpset.getCombinedMap(); currentID = ident; try { url = map.getURLFromID(ident); } else { Map hsmap = hs.getLocalMap(); url = hsmap.getURLFromID(ident);
/** * retuns a helpset title for a given url */ private String getHelpSetTitle(HelpSet hs, URL url) { URL baseURL = hs.getHelpSetURL(); String urlExternal = url.toExternalForm(); String baseURLExternal = baseURL.toExternalForm(); if (urlExternal.startsWith(baseURLExternal)) { return hs.getTitle(); } Enumeration helpsets = hs.getHelpSets(); String title = null; while (helpsets.hasMoreElements()) { HelpSet testHS = (HelpSet) helpsets.nextElement(); title = getHelpSetTitle(testHS, url); if (title != null) { break; } } return title; }
private static void unloadHelpSet(Extension ext) { HelpBroker hb = ExtensionHelp.getHelpBroker(); if (hb == null) { return; } URL helpSetUrl = getExtensionHelpSetUrl(ext); if (helpSetUrl != null) { HelpSet baseHelpSet = hb.getHelpSet(); Enumeration<?> helpSets = baseHelpSet.getHelpSets(); while (helpSets.hasMoreElements()) { HelpSet extensionHelpSet = (HelpSet) helpSets.nextElement(); if (helpSetUrl.equals(extensionHelpSet.getHelpSetURL())) { baseHelpSet.remove(extensionHelpSet); break; } } } }
/** * Gets a DefaultMutableTreeNode representing the * information in this view instance. * * The default implementation parses the data in the URL, but a subclass may * override this method and provide a different implemenation. For example, * it may create the tree programatically. */ public DefaultMutableTreeNode getDataAsTree() { HelpSet hs = getHelpSet(); debug("helpSet in "+this+hs.toString()); Hashtable params = getParameters(); URL url; if (params == null || (params != null && !params.containsKey("data"))) { DefaultMutableTreeNode node = new DefaultMutableTreeNode(); return node; } try { url = new URL(hs.getHelpSetURL(), (String) params.get("data")); } catch (Exception ex) { throw new Error("Trouble getting URL to Index data; "+ex); } debug("url,hs: "+url.toString()+";"+hs.toString()); return parse(url, hs, hs.getLocale(), new DefaultIndexFactory()); }