UIAction.java
资源名称:swingx.zip [点击查看]
上传用户:zhengdagz
上传日期:2014-03-06
资源大小:1956k
文件大小:3k
源码类别:
xml/soap/webservice
开发平台:
Java
- /*
- * $Id: UIAction.java,v 1.2 2005/10/10 18:01:51 rbair Exp $
- *
- * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
- * Santa Clara, California 95054, U.S.A. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
- /*
- * @(#)UIAction.java 1.2 03/04/24
- *
- * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
- * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
- */
- package org.jdesktop.swingx;
- import java.beans.PropertyChangeListener;
- import javax.swing.Action;
- /**
- * UIAction is the basis of all of basic's action classes that are used in
- * an ActionMap. Subclasses need to override <code>actionPerformed</code>.
- * <p>
- * A typical subclass will look like:
- * <pre>
- * private static class Actions extends UIAction {
- * Actions(String name) {
- * super(name);
- * }
- *
- * public void actionPerformed(ActionEvent ae) {
- * if (getName() == "selectAll") {
- * selectAll();
- * }
- * else if (getName() == "cancelEditing") {
- * cancelEditing();
- * }
- * }
- * }
- * </pre>
- * <p>
- * Subclasses that wish to conditionalize the enabled state should override
- * <code>isEnabled(Component)</code>, and be aware that the passed in
- * <code>Component</code> may be null.
- * <p>
- * This is based on sun.swing.UIAction in J2SE 1.5
- *
- * @see javax.swing.Action
- * @author Scott Violet
- */
- public abstract class UIAction implements Action {
- private String name;
- public UIAction(String name) {
- this.name = name;
- }
- public final String getName() {
- return name;
- }
- public Object getValue(String key) {
- if (key == NAME) {
- return name;
- }
- return null;
- }
- // UIAction is not mutable, this does nothing.
- public void putValue(String key, Object value) {
- }
- // UIAction is not mutable, this does nothing.
- public void setEnabled(boolean b) {
- }
- /**
- * Cover method for <code>isEnabled(null)</code>.
- */
- public final boolean isEnabled() {
- return isEnabled(null);
- }
- /**
- * Subclasses that need to conditionalize the enabled state should
- * override this. Be aware that <code>sender</code> may be null.
- *
- * @param sender Widget enabled state is being asked for, may be null.
- */
- public boolean isEnabled(Object sender) {
- return true;
- }
- // UIAction is not mutable, this does nothing.
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- }
- // UIAction is not mutable, this does nothing.
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- }
- }