001: /*
002: ** $Id: ConfigActionFactory.java,v 1.6 2000/10/26 14:35:18 mrw Exp $
003: **
004: ** Mike Wilson, September 2000, mrw@whisperingwind.co.uk
005: **
006: ** (C) Copyright 2000, Mike Wilson, Reading, Berkshire, UK
007: **
008: ** This program is free software; you can redistribute it and/or modify
009: ** it under the terms of the GNU General Public License as published by
010: ** the Free Software Foundation; either version 2 of the License, or
011: ** (at your option) any later version.
012: **
013: ** This program is distributed in the hope that it will be useful,
014: ** but WITHOUT ANY WARRANTY; without even the implied warranty of
015: ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016: ** GNU General Public License for more details.
017: **
018: ** You should have received a copy of the GNU Library General
019: ** Public License along with this library; if not, write to the
020: ** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
021: ** Boston, MA 02111-1307 USA.
022: */
023:
024: package uk.co.whisperingwind.vienna;
025:
026: import javax.swing.Action;
027: import uk.co.whisperingwind.framework.ActionFactory;
028:
029: /**
030: ** Creates Action instances for the configuration dialogs.
031: */
032:
033: public class ConfigActionFactory extends ActionFactory {
034: public ConfigActionFactory(String path) {
035: super (path);
036: }
037:
038: /**
039: ** Create the Action for the named command. Returns null if the
040: ** command is unknown.
041: */
042:
043: public DefaultAction createAction(String command) {
044: DefaultAction action = super .createAction(command);
045:
046: if (command.equals("new"))
047: action = new NewAction();
048: else if (command.equals("edit"))
049: action = new EditAction();
050: else if (command.equals("delete"))
051: action = new DeleteAction();
052: else if (command.equals("test"))
053: action = new TestAction();
054:
055: return action;
056: }
057:
058: /**
059: ** The "New" action.
060: */
061:
062: private class NewAction extends ActionFactory.DefaultAction {
063: public NewAction() {
064: super ("New");
065: putValue(Action.NAME, "New connection");
066: putValue(Action.SMALL_ICON, getIcon("New16.gif"));
067: putValue(DefaultAction.LARGE_ICON, getIcon("New24.gif"));
068: putValue(DefaultAction.TOOL_TIP, "New connection");
069: putValue(DefaultAction.MNEMONIC_KEY, new Integer('N'));
070: putValue(DefaultAction.ACTION_COMMAND_KEY, "new");
071: }
072: }
073:
074: /**
075: ** The "Edit" action.
076: */
077:
078: private class EditAction extends DefaultAction {
079: public EditAction() {
080: super ("Edit");
081: putValue(Action.NAME, "Edit");
082: putValue(Action.SMALL_ICON, getIcon("Edit16.gif"));
083: putValue(LARGE_ICON, getIcon("Edit24.gif"));
084: putValue(TOOL_TIP, "Edit connection");
085: putValue(MNEMONIC_KEY, new Integer('O'));
086: putValue(ACTION_COMMAND_KEY, "edit");
087: }
088: }
089:
090: /**
091: ** The "Delete" action.
092: */
093:
094: private class DeleteAction extends DefaultAction {
095: public DeleteAction() {
096: super ("Delete");
097: putValue(Action.NAME, "Delete");
098: putValue(Action.SMALL_ICON, getIcon("Delete16.gif"));
099: putValue(LARGE_ICON, getIcon("Delete24.gif"));
100: putValue(TOOL_TIP, "Delete connection");
101: putValue(MNEMONIC_KEY, new Integer('D'));
102: putValue(ACTION_COMMAND_KEY, "delete");
103: }
104: }
105:
106: /**
107: ** The "Test" action.
108: */
109:
110: private class TestAction extends DefaultAction {
111: public TestAction() {
112: super ("Test");
113: putValue(Action.NAME, "Test");
114: putValue(TOOL_TIP, "Test the connection");
115: putValue(ACTION_COMMAND_KEY, "test");
116: }
117: }
118: }
|