01: /*
02: * $Id: JGraphpadL2FAction.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.l2fplugin;
11:
12: import java.awt.Component;
13: import java.awt.Font;
14:
15: import org.jgraph.JGraph;
16:
17: import com.jgraph.editor.JGraphEditorAction;
18: import com.jgraph.pad.action.JGraphpadFormatAction;
19: import com.l2fprod.common.swing.JFontChooser;
20:
21: /**
22: * Implements all actions that require L2FProd in the classpath.
23: */
24: public class JGraphpadL2FAction extends JGraphpadFormatAction {
25:
26: /**
27: * Constructs a new L2F action for the specified name.
28: */
29: public JGraphpadL2FAction(String name) {
30: super (name);
31: }
32:
33: /**
34: * Overrides the parent implementation to use
35: * {@link JFontChooser#showDialog(java.awt.Component, java.lang.String, java.awt.Font)}.
36: *
37: * @param component
38: * The parent component for the dialog to be displayed.
39: * @param title
40: * The title of the dialog to be displayed.
41: * @param font
42: * The default font to use in the dialog.
43: * @return Returns the selected font.
44: */
45: public Font fontDialog(Component component, String title, Font font) {
46: return JFontChooser.showDialog(component, title, font);
47: }
48:
49: /**
50: * Bundle of all actions in this class.
51: */
52: public static class AllActions implements Bundle {
53:
54: /**
55: * Holds the actions.
56: */
57: public JGraphEditorAction actionFont = new JGraphpadL2FAction(
58: NAME_FONT);
59:
60: /*
61: * (non-Javadoc)
62: */
63: public JGraphEditorAction[] getActions() {
64: return new JGraphEditorAction[] { actionFont };
65: }
66:
67: /*
68: * (non-Javadoc)
69: */
70: public void update() {
71: JGraph graph = getPermanentFocusOwnerGraph();
72: boolean isCellsSelected = graph != null
73: && !graph.isSelectionEmpty();
74:
75: actionFont.setEnabled(isCellsSelected);
76: }
77:
78: }
79:
80: }
|