001: /*
002: ** $Id: SchemaActionFactory.java,v 1.4 2000/10/21 16:24:03 mrw Exp $
003: **
004: ** Create Action instances for the schema 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 java.awt.Event;
029: import javax.swing.Action;
030: import javax.swing.KeyStroke;
031: import uk.co.whisperingwind.framework.ActionFactory;
032:
033: public class SchemaActionFactory extends ActionFactory {
034: public SchemaActionFactory(String path) {
035: super (path);
036: }
037:
038: public DefaultAction createAction(String command) {
039: DefaultAction action = null;
040:
041: if (command.equals("new"))
042: action = new NewAction();
043: else if (command.equals("close"))
044: action = new CloseAction();
045: else if (command.equals("table"))
046: action = new TableAction();
047: else if (command.equals("view"))
048: action = new ViewAction();
049: else if (command.equals("synonym"))
050: action = new SynonymAction();
051: else if (command.equals("sequence"))
052: action = new SequenceAction();
053:
054: return action;
055: }
056:
057: private class NewAction extends ActionFactory.DefaultAction {
058: public NewAction() {
059: super ("New");
060: putValue(Action.NAME, "New window");
061: putValue(Action.SMALL_ICON, getIcon("New16.gif"));
062: putValue(DefaultAction.LARGE_ICON, getIcon("New24.gif"));
063: putValue(DefaultAction.TOOL_TIP, "New window");
064: putValue(DefaultAction.MNEMONIC_KEY, new Integer('N'));
065: putValue(DefaultAction.ACTION_COMMAND_KEY, "new");
066: putValue(DefaultAction.ACCELERATOR_KEY, KeyStroke
067: .getKeyStroke('N', Event.CTRL_MASK, false));
068: }
069: }
070:
071: private class CloseAction extends DefaultAction {
072: public CloseAction() {
073: super ("Close");
074: putValue(Action.NAME, "Close window");
075: putValue(DefaultAction.TOOL_TIP, "Close window");
076: putValue(DefaultAction.MNEMONIC_KEY, new Integer('W'));
077: putValue(DefaultAction.ACTION_COMMAND_KEY, "close");
078: putValue(DefaultAction.ACCELERATOR_KEY, KeyStroke
079: .getKeyStroke('W', Event.CTRL_MASK, false));
080: }
081: }
082:
083: private class TableAction extends ToggleAction {
084: public TableAction() {
085: super ("Table");
086: putValue(Action.NAME, "Show tables");
087: putValue(DefaultAction.TOOL_TIP, "Show tables");
088: putValue(DefaultAction.ACTION_COMMAND_KEY, "viewtable");
089: }
090: }
091:
092: private class ViewAction extends ToggleAction {
093: public ViewAction() {
094: super ("View");
095: putValue(Action.NAME, "Show views");
096: putValue(DefaultAction.TOOL_TIP, "Show views");
097: putValue(DefaultAction.ACTION_COMMAND_KEY, "viewview");
098: }
099: }
100:
101: private class SynonymAction extends ToggleAction {
102: public SynonymAction() {
103: super ("Synonym");
104: putValue(Action.NAME, "Show synonyms");
105: putValue(DefaultAction.TOOL_TIP, "Show synonyms");
106: putValue(DefaultAction.ACTION_COMMAND_KEY, "viewsynonym");
107: }
108: }
109:
110: private class SequenceAction extends ToggleAction {
111: public SequenceAction() {
112: super ("Sequence");
113: putValue(Action.NAME, "Show sequences");
114: putValue(DefaultAction.TOOL_TIP, "Show sequences");
115: putValue(DefaultAction.ACTION_COMMAND_KEY, "viewsequence");
116: }
117: }
118: }
|