01: /*
02: * $Id: JGraphpadBrowserAction.java,v 1.1.1.1 2005/08/04 11:21:58 gaudenz Exp $
03: * Copyright (c) 2001-2005, Gaudenz Alder
04: *
05: * All rights reserved.
06: *
07: * See LICENSE file for license details. If you are unable to locate
08: * this file please contact info (at) jgraph (dot) com.
09: */
10: package com.jgraph.browserplugin;
11:
12: import java.awt.event.ActionEvent;
13: import java.io.IOException;
14:
15: import com.jgraph.editor.JGraphEditorAction;
16: import com.jgraph.pad.dialog.JGraphpadDialogs;
17:
18: /**
19: * Implements all actions that require the browser launcher.
20: */
21: public class JGraphpadBrowserAction extends JGraphEditorAction {
22:
23: /**
24: * Shortcut to the shared JGraphpad dialogs.
25: */
26: protected static JGraphpadDialogs dlgs = JGraphpadDialogs
27: .getSharedInstance();
28:
29: /**
30: * Specifies the name for the <code>homepage</code> action.
31: */
32: public static final String NAME_HOMEPAGE = "homepage";
33:
34: /**
35: * Constructs a new Batik action for the specified name.
36: */
37: public JGraphpadBrowserAction(String name) {
38: super (name);
39: }
40:
41: /**
42: * Executes the action based on the action name.
43: *
44: * @param e
45: * The object that describes the event.
46: */
47: public void actionPerformed(ActionEvent e) {
48: try {
49: if (getName().equals(NAME_HOMEPAGE))
50: JGraphpadBrowserLauncher
51: .openURL("http://www.jgraph.com/");
52: } catch (IOException e1) {
53: dlgs.errorDialog(getPermanentFocusOwner(), e1
54: .getLocalizedMessage());
55: }
56: }
57:
58: /**
59: * Bundle of all actions in this class.
60: */
61: public static class AllActions implements Bundle {
62:
63: /**
64: * Holds the actions. The actions are constructed in the constructor as
65: * they require an editor instance.
66: */
67: public JGraphEditorAction actionHomepage = new JGraphpadBrowserAction(
68: NAME_HOMEPAGE);
69:
70: /*
71: * (non-Javadoc)
72: */
73: public JGraphEditorAction[] getActions() {
74: return new JGraphEditorAction[] { actionHomepage };
75: }
76:
77: /*
78: * (non-Javadoc)
79: */
80: public void update() {
81: // always enabled
82: }
83:
84: }
85:
86: }
|