View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  
20  package org.xnap.gui.action;
21  
22  import java.awt.event.ActionEvent;
23  
24  import javax.help.HelpBroker;
25  import javax.help.HelpSet;
26  import javax.help.Map;
27  import javax.swing.AbstractAction;
28  import javax.swing.Action;
29  
30  import org.xnap.XNap;
31  import org.xnap.gui.StatusBar;
32  import org.xnap.gui.util.HelpManager;
33  import org.xnap.gui.util.IconHelper;
34  
35  /***
36   * Provides an action that shows the about dialog.
37   */
38  public class HelpDialogAction extends AbstractAction 
39  {
40      
41      //--- Constant(s) ---
42      
43      //--- Data field(s) ---
44      
45      private String name;
46      private HelpSet hs;
47  
48      //--- Constructor(s) ---
49      
50      /***
51       * Constructs a new HelpDialogAction.
52       * 
53       * @param name name of the manual, e.g "XNap Handbook"
54       * @param helpset the corresponding helpset
55       */
56      public HelpDialogAction(String name, HelpSet helpset)
57      {
58  		this.name = name;
59  		this.hs = helpset;
60  
61  		putValue(Action.NAME, name + "...");
62  		putValue(IconHelper.XNAP_ICON, "contents.png");
63  		putValue(Action.SHORT_DESCRIPTION, XNap.tr("Shows the help dialog."));
64  
65  		setEnabled(HelpManager.getMainHelpSet() != null);
66      }
67  
68      //--- Method(s) ---
69          
70      public void actionPerformed(ActionEvent event) 
71      {
72  		StatusBar.setText(XNap.tr("Opening {0}", name));
73  		HelpBroker hb = HelpManager.getMainHelpBroker();
74  		try {
75  			Map.ID id = Map.ID.create(null, hs);
76  			hb.setCurrentID(id);
77  			hb.setDisplayed(true);		
78  		}
79  		catch (Exception e) {
80  		}
81      }
82  }
83  
84  
85  
86