Source code: com/virtuosotechnologies/asaph/maingui/CommandManager.java
1 /*
2 ================================================================================
3
4 FILE: CommandManager.java
5
6 PROJECT:
7
8 Asaph
9
10 CONTENTS:
11
12 The command manager API exported by the maingui plugin
13
14 PROGRAMMERS:
15
16 Daniel Azuma (DA) <dazuma@kagi.com>
17
18 COPYRIGHT:
19
20 Copyright (C) 2003 Daniel Azuma (dazuma@kagi.com)
21
22 This program is free software; you can redistribute it and/or
23 modify it under the terms of the GNU General Public License as
24 published by the Free Software Foundation; either version 2
25 of the License, or (at your option) any later version.
26
27 This program is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 GNU General Public License for more details.
31
32 You should have received a copy of the GNU General Public
33 License along with this program; if not, write to
34 Free Software Foundation, Inc.
35 59 Temple Place, Suite 330
36 Boston, MA 02111-1307 USA
37
38 ================================================================================
39 */
40
41
42 package com.virtuosotechnologies.asaph.maingui;
43
44
45 import com.virtuosotechnologies.lib.base.BasicEnumeratedType;
46 import com.virtuosotechnologies.lib.command.CommandNode;
47
48
49 /**
50 * The command manager API exported by the maingui plugin
51 */
52 public interface CommandManager
53 {
54 /**
55 * The name of this API.
56 */
57 public static final String API_NAME =
58 "com.virtuosotechnologies.asaph.maingui.CommandManager";
59
60
61 /**
62 * A category for commands, specifying where in the menus the command will
63 * appear, as well as additional behaviors involving appearance and enabling.
64 */
65 public static final class CommandCategory
66 extends BasicEnumeratedType
67 {
68 CommandCategory(String str)
69 {
70 super(str);
71 }
72 }
73
74
75 /**
76 * Denotes commands for database creating and opening. Commands registered
77 * in this category will show up towards the top of the File menu. The
78 * plugin has complete control over the enable/disable state of these
79 * commands, and it may change the state at any time.
80 */
81 public static final CommandCategory OPEN_COMMANDS =
82 new CommandCategory("open_database");
83
84 /**
85 * Denotes commands for database saving. Commands registered in this
86 * category will show up towards the middle and bottom of the File menu,
87 * and will be located in a group that is enabled only when a database is
88 * selected. Additionally, the plugin may further disable this node or its
89 * subnodes if it chooses, in response to the type of database selected.
90 */
91 public static final CommandCategory SAVE_COMMANDS =
92 new CommandCategory("save_database");
93
94 /**
95 * Denotes commands for song manipulation. Commands registered in this
96 * category will show up in the Song menu, and will be located in a group
97 * that is enabled only when at least one song is selected. Additionally,
98 * the plugin may further disable this node or its subnodes if it chooses,
99 * in response to selection changes or other state changes.
100 */
101 public static final CommandCategory SONG_COMMANDS =
102 new CommandCategory("song");
103
104 /**
105 * Denotes commands for publishing, report generation, and other features
106 * provided by the plugin. Commands registered under this node will show
107 * up in the Tools menu. The plugin has complete control over the
108 * enable/disable state of these commands, and it may change the state
109 * in response to selection changes or other state changes.
110 */
111 public static final CommandCategory TOOL_COMMANDS =
112 new CommandCategory("tool");
113
114
115 /**
116 * Returns a group-flavored CommandNode that can be filled with commands
117 * which a plugin wants to submit to the menu system.
118 * Commands are separated into categories, identified by the constants
119 * OPEN_COMMANDS, SAVE_COMMANDS, SONG_COMMANDS and TOOL_COMMANDS.
120 * See the comments for the various key constants for more information
121 * about command categories.
122 *
123 * @param category a category for the command
124 * @return a group-flavored CommandNode, or null if category not recognized
125 */
126 public CommandNode createCommandGroup(
127 CommandCategory category);
128
129
130 /**
131 * Sets the default song command. If a command is already present, the one with
132 * the higher priority will be taken.
133 * Returns true if the command was set, or false if not.
134 *
135 * @param node a CommandNode for the default song command
136 * @param priority priority of this command
137 * @return true if successful
138 */
139 public boolean setDefaultSongCommand(
140 CommandNode node,
141 int priority);
142 }