001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: /*
043: * BaseActionWrapper.java
044: *
045: * Created on April 16, 2005, 7:01 AM
046: */
047:
048: package org.netbeans.modules.uml.designpattern;
049:
050: import org.netbeans.modules.uml.ui.products.ad.application.action.BaseAction;
051: import java.awt.event.ActionEvent;
052: import javax.swing.Action;
053: import javax.swing.Icon;
054:
055: /**
056: *
057: * @author Administrator
058: */
059: public class BaseActionWrapper extends BaseAction {
060: Action mWrappedAction = null;
061:
062: /** Creates a new instance of BaseActionWrapper */
063: public BaseActionWrapper(Action action) {
064: mWrappedAction = action;
065: putValue(Action.NAME, removeAMPS((String) action
066: .getValue(Action.NAME)));
067: putValue(Action.ACCELERATOR_KEY, action
068: .getValue(Action.ACCELERATOR_KEY));
069: putValue(Action.ACTION_COMMAND_KEY, action
070: .getValue(Action.ACTION_COMMAND_KEY));
071: putValue(Action.LONG_DESCRIPTION, action
072: .getValue(Action.LONG_DESCRIPTION));
073: putValue(Action.MNEMONIC_KEY, action
074: .getValue(Action.MNEMONIC_KEY));
075: putValue(Action.SHORT_DESCRIPTION, action
076: .getValue(Action.SHORT_DESCRIPTION));
077: // putValue(Action.SMALL_ICON, action.getValue(Action.SMALL_ICON));
078: }
079:
080: protected String removeAMPS(String value) {
081: String retVal = value;
082: int index = value.indexOf('&');
083: if (index > -1) {
084: retVal = value.substring(0, index);
085: retVal += value.substring(index + 1);
086: }
087:
088: return retVal;
089: }
090:
091: public void actionPerformed(ActionEvent e) {
092: mWrappedAction.actionPerformed(e);
093: }
094:
095: // public boolean isChecked()
096: // {
097: //
098: // boolean retValue;
099: //
100: // retValue = super.isChecked();
101: // return retValue;
102: // }
103:
104: // public String getToolTipText()
105: // {
106: //
107: // String retValue;
108: //
109: // retValue = super.getToolTipText();
110: // return (String)mWrappedAction.getValue(Action.SHORT_DESCRIPTION);
111: // }
112:
113: public javax.swing.Icon getSmallImage() {
114:
115: Icon retVal = null;
116:
117: // Object obj = getValue(Action.SMALL_ICON);
118: // if (obj instanceof Icon)
119: // {
120: // retVal = (Icon)obj;
121: //
122: // }
123: return retVal;
124: }
125:
126: // public javax.swing.JComponent getCustomComponent()
127: // {
128: //
129: // javax.swing.JComponent retValue;
130: //
131: // retValue = super.getCustomComponent();
132: // return retValue;
133: // }
134: //
135: // public int getStyle()
136: // {
137: //
138: // int retValue;
139: //
140: // retValue = super.getStyle();
141: // return retValue;
142: // }
143: //
144: // public String getText()
145: // {
146: // return (String)getValue(Action.NAME);
147: // }
148: //
149: // public String getLabel()
150: // {
151: // String retValue;
152: //
153: // retValue = super.getLabel();
154: // return retValue;
155: // }
156:
157: public String getId() {
158: String retValue = "BaseActionWrapper";
159:
160: Class clazz = mWrappedAction.getClass();
161: retValue = clazz.getName();
162:
163: return retValue;
164: }
165:
166: }
|