ConfigActionFactory.java :  » Database-Client » ViennaSQL » uk » co » whisperingwind » vienna » Java Open Source

Java Open Source » Database Client » ViennaSQL 
ViennaSQL » uk » co » whisperingwind » vienna » ConfigActionFactory.java
/*
** $Id: ConfigActionFactory.java,v 1.6 2000/10/26 14:35:18 mrw Exp $
**
** Mike Wilson, September 2000, mrw@whisperingwind.co.uk
**
** (C) Copyright 2000, Mike Wilson, Reading, Berkshire, UK
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
** 
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
** 
** You should have received a copy of the GNU Library General
** Public License along with this library; if not, write to the
** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
** Boston, MA  02111-1307  USA.
*/

package uk.co.whisperingwind.vienna;

import javax.swing.Action;
import uk.co.whisperingwind.framework.ActionFactory;

/**
** Creates Action instances for the configuration dialogs.
*/

public class ConfigActionFactory extends ActionFactory
{
    public ConfigActionFactory (String path)
    {
  super (path);
    }

    /**
    ** Create the Action for the named command. Returns null if the
    ** command is unknown.
    */

    public DefaultAction createAction (String command)
    {
  DefaultAction action = super.createAction (command);

  if (command.equals ("new"))
      action = new NewAction ();
  else if (command.equals ("edit"))
      action = new EditAction ();
  else if (command.equals ("delete"))
      action = new DeleteAction ();
  else if (command.equals ("test"))
      action = new TestAction ();

  return action;
    }

    /**
    ** The "New" action.
    */

    private class NewAction extends ActionFactory.DefaultAction
    {
  public NewAction ()
  {
      super ("New");
      putValue (Action.NAME, "New connection");
      putValue (Action.SMALL_ICON, getIcon ("New16.gif"));
      putValue (DefaultAction.LARGE_ICON, getIcon ("New24.gif"));
      putValue (DefaultAction.TOOL_TIP, "New connection");
      putValue (DefaultAction.MNEMONIC_KEY, new Integer ('N'));
      putValue (DefaultAction.ACTION_COMMAND_KEY, "new");
  }
    }

    /**
    ** The "Edit" action.
    */

    private class EditAction extends DefaultAction
    {
  public EditAction ()
  {
      super ("Edit");
      putValue (Action.NAME, "Edit");
      putValue (Action.SMALL_ICON, getIcon ("Edit16.gif"));
      putValue (LARGE_ICON, getIcon ("Edit24.gif"));
      putValue (TOOL_TIP, "Edit connection");
      putValue (MNEMONIC_KEY, new Integer ('O'));
      putValue (ACTION_COMMAND_KEY, "edit");
  }
    }

    /**
    ** The "Delete" action.
    */

    private class DeleteAction extends DefaultAction
    {
  public DeleteAction ()
  {
      super ("Delete");
      putValue (Action.NAME, "Delete");
      putValue (Action.SMALL_ICON, getIcon ("Delete16.gif"));
      putValue (LARGE_ICON, getIcon ("Delete24.gif"));
      putValue (TOOL_TIP, "Delete connection");
      putValue (MNEMONIC_KEY, new Integer ('D'));
      putValue (ACTION_COMMAND_KEY, "delete");
  }
    }

    /**
    ** The "Test" action.
    */

    private class TestAction extends DefaultAction
    {
  public TestAction ()
  {
      super ("Test");
      putValue (Action.NAME, "Test");
      putValue (TOOL_TIP, "Test the connection");
      putValue (ACTION_COMMAND_KEY, "test");
  }
    }
}

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.