001: /*
002: ** $Id: MainActionFactory.java,v 1.8 2000/11/01 08:43:37 mrw Exp $
003: **
004: ** Action factory to create actions for the main view.
005: **
006: ** Mike Wilson, September 2000, mrw@whisperingwind.co.uk
007: **
008: ** (C) Copyright 2000, Mike Wilson, Reading, Berkshire, UK
009: **
010: ** This program is free software; you can redistribute it and/or modify
011: ** it under the terms of the GNU General Public License as published by
012: ** the Free Software Foundation; either version 2 of the License, or
013: ** (at your option) any later version.
014: **
015: ** This program is distributed in the hope that it will be useful,
016: ** but WITHOUT ANY WARRANTY; without even the implied warranty of
017: ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
018: ** GNU General Public License for more details.
019: **
020: ** You should have received a copy of the GNU Library General
021: ** Public License along with this library; if not, write to the
022: ** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
023: ** Boston, MA 02111-1307 USA.
024: */
025:
026: package uk.co.whisperingwind.vienna;
027:
028: import uk.co.whisperingwind.framework.ActionFactory;
029: import java.awt.Event;
030: import javax.swing.KeyStroke;
031: import javax.swing.Action;
032:
033: public class MainActionFactory extends ActionFactory {
034: public MainActionFactory(String path) {
035: super (path);
036: }
037:
038: public DefaultAction createAction(String command) {
039: DefaultAction action = super .createAction(command);
040:
041: if (command.equals("new"))
042: action = new NewAction();
043: if (command.equals("open"))
044: action = new OpenAction();
045: else if (command.equals("save"))
046: action = new SaveAction();
047: else if (command.equals("saveAs"))
048: action = new SaveAsAction();
049: else if (command.equals("saveAll"))
050: action = new SaveAllAction();
051: else if (command.equals("close"))
052: action = new CloseAction();
053: else if (command.equals("closeAll"))
054: action = new CloseAllAction();
055: else if (command.equals("config"))
056: action = new ConfigAction();
057: else if (command.equals("quit"))
058: action = new QuitAction();
059: else if (command.equals("execute"))
060: action = new ExecuteAction();
061: else if (command.equals("cancel"))
062: action = new CancelAction();
063: else if (command.equals("commit"))
064: action = new CommitAction();
065: else if (command.equals("rollback"))
066: action = new RollbackAction();
067: else if (command.equals("schema"))
068: action = new SchemaAction();
069: else if (command.equals("export"))
070: action = new ExportAction();
071: else if (command.equals("about"))
072: action = new AboutAction();
073: else if (command.equals("undo"))
074: action = new UndoAction();
075: else if (command.equals("redo"))
076: action = new RedoAction();
077:
078: return action;
079: }
080:
081: private class NewAction extends ActionFactory.DefaultAction {
082: public NewAction() {
083: super ("New");
084: putValue(Action.NAME, "New");
085: putValue(Action.SMALL_ICON, getIcon("New16.gif"));
086: putValue(DefaultAction.LARGE_ICON, getIcon("New24.gif"));
087: putValue(DefaultAction.TOOL_TIP, "New document");
088: putValue(DefaultAction.MNEMONIC_KEY, new Integer('N'));
089: putValue(DefaultAction.ACTION_COMMAND_KEY, "new");
090: putValue(DefaultAction.ACCELERATOR_KEY, KeyStroke
091: .getKeyStroke('N', Event.CTRL_MASK, false));
092: }
093: }
094:
095: private class OpenAction extends DefaultAction {
096: public OpenAction() {
097: super ("Open");
098: putValue(Action.NAME, "Open...");
099: putValue(Action.SMALL_ICON, getIcon("Open16.gif"));
100: putValue(LARGE_ICON, getIcon("Open24.gif"));
101: putValue(TOOL_TIP, "Open document");
102: putValue(MNEMONIC_KEY, new Integer('O'));
103: putValue(ACTION_COMMAND_KEY, "open");
104: putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('O',
105: Event.CTRL_MASK, false));
106: }
107: }
108:
109: private class SaveAction extends DefaultAction {
110: public SaveAction() {
111: super ("Save");
112: putValue(Action.NAME, "Save");
113: putValue(Action.SMALL_ICON, getIcon("Save16.gif"));
114: putValue(LARGE_ICON, getIcon("Save24.gif"));
115: putValue(TOOL_TIP, "Save document");
116: putValue(MNEMONIC_KEY, new Integer('S'));
117: putValue(ACTION_COMMAND_KEY, "save");
118: putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('S',
119: Event.CTRL_MASK, false));
120: }
121: }
122:
123: private class SaveAsAction extends DefaultAction {
124: public SaveAsAction() {
125: super ("SaveAs");
126: putValue(Action.NAME, "Save as...");
127: putValue(Action.SMALL_ICON, getIcon("SaveAs16.gif"));
128: putValue(LARGE_ICON, getIcon("SaveAs24.gif"));
129: putValue(TOOL_TIP, "Save document with a new file name");
130: putValue(ACTION_COMMAND_KEY, "saveAs");
131: putValue(ACCELERATOR_KEY, null);
132: }
133: }
134:
135: private class SaveAllAction extends DefaultAction {
136: public SaveAllAction() {
137: super ("SaveAll");
138: putValue(Action.NAME, "Save all");
139: putValue(Action.SMALL_ICON, getIcon("SaveAll16.gif"));
140: putValue(LARGE_ICON, getIcon("SaveAll24.gif"));
141: putValue(TOOL_TIP, "Save all documents");
142: putValue(ACTION_COMMAND_KEY, "saveAll");
143: putValue(ACCELERATOR_KEY, null);
144: }
145: }
146:
147: private class CloseAction extends DefaultAction {
148: public CloseAction() {
149: super ("Close");
150: putValue(Action.NAME, "Close");
151: putValue(Action.SMALL_ICON, null);
152: putValue(LARGE_ICON, null);
153: putValue(TOOL_TIP, "Close document");
154: putValue(ACTION_COMMAND_KEY, "close");
155: putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('W',
156: Event.CTRL_MASK, false));
157: }
158: }
159:
160: private class CloseAllAction extends DefaultAction {
161: public CloseAllAction() {
162: super ("CloseAll");
163: putValue(Action.NAME, "Close all");
164: putValue(Action.SMALL_ICON, null);
165: putValue(LARGE_ICON, null);
166: putValue(TOOL_TIP, "Close all documents");
167: putValue(ACTION_COMMAND_KEY, "closeAll");
168: putValue(ACCELERATOR_KEY, null);
169: }
170: }
171:
172: private class ConfigAction extends DefaultAction {
173: public ConfigAction() {
174: super ("Config");
175: putValue(Action.NAME, "Configure...");
176: putValue(Action.SMALL_ICON, null);
177: putValue(LARGE_ICON, null);
178: putValue(TOOL_TIP, "Configure");
179: putValue(ACTION_COMMAND_KEY, "config");
180: }
181: }
182:
183: private class QuitAction extends DefaultAction {
184: public QuitAction() {
185: super ("Quit");
186: putValue(Action.NAME, "Quit");
187: putValue(Action.SMALL_ICON, null);
188: putValue(LARGE_ICON, null);
189: putValue(TOOL_TIP, "Quit application");
190: putValue(ACTION_COMMAND_KEY, "quit");
191: putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('Q',
192: Event.CTRL_MASK, false));
193: }
194: }
195:
196: private class ExecuteAction extends DefaultAction {
197: public ExecuteAction() {
198: super ("Execute");
199: putValue(Action.NAME, "Execute");
200: putValue(Action.SMALL_ICON, getIcon("Play16.gif"));
201: putValue(LARGE_ICON, getIcon("Play24.gif"));
202: putValue(TOOL_TIP, "Execute query");
203: putValue(ACTION_COMMAND_KEY, "execute");
204: putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('E',
205: Event.CTRL_MASK, false));
206: }
207: }
208:
209: private class CancelAction extends DefaultAction {
210: public CancelAction() {
211: super ("Cancel");
212: putValue(Action.NAME, "Cancel");
213: putValue(Action.SMALL_ICON, getIcon("Stop16.gif"));
214: putValue(LARGE_ICON, getIcon("Stop24.gif"));
215: putValue(TOOL_TIP, "Cancel query");
216: putValue(ACTION_COMMAND_KEY, "cancel");
217: putValue(ACCELERATOR_KEY, null);
218: }
219: }
220:
221: private class CommitAction extends DefaultAction {
222: public CommitAction() {
223: super ("Commit");
224: putValue(Action.NAME, "Commit");
225: putValue(Action.SMALL_ICON, getIcon("Redo16.gif"));
226: putValue(LARGE_ICON, getIcon("Redo24.gif"));
227: putValue(TOOL_TIP, "Commit changes");
228: putValue(ACTION_COMMAND_KEY, "commit");
229: putValue(ACCELERATOR_KEY, null);
230: }
231: }
232:
233: private class RollbackAction extends DefaultAction {
234: public RollbackAction() {
235: super ("Rollback");
236: putValue(Action.NAME, "Rollback");
237: putValue(Action.SMALL_ICON, getIcon("Undo16.gif"));
238: putValue(LARGE_ICON, getIcon("Undo24.gif"));
239: putValue(TOOL_TIP, "Rollback changes");
240: putValue(ACTION_COMMAND_KEY, "rollback");
241: putValue(ACCELERATOR_KEY, null);
242: }
243: }
244:
245: private class SchemaAction extends DefaultAction {
246: public SchemaAction() {
247: super ("Schema");
248: putValue(Action.NAME, "Schema");
249: putValue(Action.SMALL_ICON, null);
250: putValue(LARGE_ICON, null);
251: putValue(TOOL_TIP, "Query database schema");
252: putValue(ACTION_COMMAND_KEY, "schema");
253: putValue(ACCELERATOR_KEY, null);
254: }
255: }
256:
257: private class ExportAction extends DefaultAction {
258: public ExportAction() {
259: super ("Export");
260: putValue(Action.NAME, "Export...");
261: putValue(Action.SMALL_ICON, null);
262: putValue(LARGE_ICON, null);
263: putValue(TOOL_TIP, "Export results to a file");
264: putValue(ACTION_COMMAND_KEY, "export");
265: putValue(ACCELERATOR_KEY, null);
266: }
267: }
268:
269: private class AboutAction extends DefaultAction {
270: public AboutAction() {
271: super ("About");
272: putValue(Action.NAME, "About...");
273: putValue(Action.SMALL_ICON, null);
274: putValue(LARGE_ICON, null);
275: putValue(TOOL_TIP, "About ViennaSQL");
276: putValue(ACTION_COMMAND_KEY, "about");
277: putValue(ACCELERATOR_KEY, null);
278: }
279: }
280:
281: private class UndoAction extends DefaultAction {
282: public UndoAction() {
283: super ("Undo");
284: putValue(Action.NAME, "Undo");
285: putValue(Action.SMALL_ICON, null);
286: putValue(LARGE_ICON, null);
287: putValue(TOOL_TIP, "Undo edit action");
288: putValue(ACTION_COMMAND_KEY, "undo");
289: putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('Z',
290: Event.CTRL_MASK, false));
291: }
292: }
293:
294: private class RedoAction extends DefaultAction {
295: public RedoAction() {
296: super ("Redo");
297: putValue(Action.NAME, "Redo");
298: putValue(Action.SMALL_ICON, null);
299: putValue(LARGE_ICON, null);
300: putValue(TOOL_TIP, "Redo edit action");
301: putValue(ACTION_COMMAND_KEY, "redo");
302: putValue(ACCELERATOR_KEY, null);
303: }
304: }
305: }
|