1 /* 2 * @(#)JHelpFavoritesNavigator.java 1.4 06/10/30 3 * 4 * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. 5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 * 7 * This code is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License version 2 only, as 9 * published by the Free Software Foundation. Sun designates this 10 * particular file as subject to the "Classpath" exception as provided 11 * by Sun in the LICENSE file that accompanied this code. 12 * 13 * This code is distributed in the hope that it will be useful, but WITHOUT 14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 * version 2 for more details (a copy is included in the LICENSE file that 17 * accompanied this code). 18 * 19 * You should have received a copy of the GNU General Public License version 20 * 2 along with this work; if not, write to the Free Software Foundation, 21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 * 23 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 24 * CA 95054 USA or visit www.sun.com if you need additional information or 25 * have any questions. 26 */ 27 28 package javax.help; 29 30 import java.net.URL; 31 import javax.swing.event.ChangeListener; 32 import javax.swing.event.ChangeEvent; 33 import javax.swing.Action; 34 35 /** 36 * JHelpFavoritesNavigator is a JHelpNavigator for Favorites. 37 * 38 * All the tree navigation and selection has been delegated to the UI 39 * where the JTree is created. 40 * 41 * @author Richard Gregor 42 * @version 1.4 10/30/06 43 */ 44 public class JHelpFavoritesNavigator extends JHelpNavigator { 45 46 /** 47 * Creates an Index navigator. 48 * 49 * @param view The NavigatorView 50 */ JHelpFavoritesNavigator(NavigatorView view)51 public JHelpFavoritesNavigator(NavigatorView view) { 52 super(view, null); 53 } 54 55 /** 56 * Creates a Index navigator. 57 * 58 * @param view The NavigatorView. 59 * @param model The model for the Navigator. 60 */ JHelpFavoritesNavigator(NavigatorView view, HelpModel model)61 public JHelpFavoritesNavigator(NavigatorView view, HelpModel model) { 62 super(view, model); 63 } 64 65 // HERE - label & Locale? 66 // HERE - URL data vs Hashtable? 67 /** 68 * Creates an Index navigator with explicit arguments. Note that this should not throw 69 * an InvalidNavigatorViewException since we are implicitly passing the type. 70 * 71 * @param hs HelpSet 72 * @param name The name identifying this HelpSet. 73 * @param label The label to use (for this locale). 74 * @param data The "data" part of the parameters, a URL location of the TOC data. 75 */ JHelpFavoritesNavigator(HelpSet hs, String name, String label, URL data)76 public JHelpFavoritesNavigator(HelpSet hs, 77 String name, String label, URL data) 78 throws InvalidNavigatorViewException { 79 super(new FavoritesView(hs, name, label, createParams(data))); 80 } 81 82 /** 83 * Gets the UID for this JComponent. 84 */ getUIClassID()85 public String getUIClassID() { 86 return "HelpFavoritesNavigatorUI"; 87 } 88 89 /** 90 * Determines if this instance of a JHelpNavigator can merge its data with another one. 91 * 92 * @param view The data to merge 93 * @return Whether it can be merged 94 * 95 * @see merge(NavigatorView) 96 * @see remove(NavigatorView) 97 */ canMerge(NavigatorView view)98 public boolean canMerge(NavigatorView view) { 99 return false; 100 } 101 102 /** 103 * Sets state of navigation entry for given target to expanded. Non-empty entry is expanded. Empty entry is visible. 104 * 105 * @param target The target to expand 106 */ expandID(String target)107 public void expandID(String target){ 108 firePropertyChange("expand"," ",target); 109 } 110 111 /** 112 * Sets state of navigation entry for given target to collapsed if entry is visible. Parent is collapsed if entry is empty. 113 * 114 * @param target The target to collapse 115 */ collapseID(String target)116 public void collapseID(String target){ 117 firePropertyChange("collapse"," ",target); 118 } 119 120 /** 121 * Returns an AddAction object for this navigator 122 * 123 */ getAddAction()124 public Action getAddAction(){ 125 return this.getUI().getAddAction(); 126 } 127 128 private static final boolean debug = false; debug(String msg)129 private static void debug(String msg) { 130 if (debug) { 131 System.err.println("JHelpIndexNavigator: "+msg); 132 } 133 } 134 } 135 136 137 138