001: /**
002: * ===========================================
003: * JFreeReport : a free Java reporting library
004: * ===========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
009: *
010: * This library is free software; you can redistribute it and/or modify it under the terms
011: * of the GNU Lesser General Public License as published by the Free Software Foundation;
012: * either version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
015: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: * See the GNU Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public License along with this
019: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020: * Boston, MA 02111-1307, USA.
021: *
022: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023: * in the United States and other countries.]
024: *
025: * ------------
026: * ActionCategory.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.modules.gui.base.internal;
030:
031: import org.jfree.report.modules.gui.commonswing.SwingGuiContext;
032: import org.jfree.util.ResourceBundleSupport;
033:
034: /**
035: * Creation-Date: 01.12.2006, 18:49:32
036: *
037: * @author Thomas Morgner
038: */
039: public class ActionCategory implements Comparable {
040: private String resourceBase;
041: private String resourcePrefix;
042: private int position;
043: private ResourceBundleSupport resources;
044: private String name;
045: private boolean userDefined;
046:
047: public ActionCategory() {
048: name = ""; //$NON-NLS-1$
049: }
050:
051: public void initialize(final SwingGuiContext context) {
052: resources = new ResourceBundleSupport(context.getLocale(),
053: resourceBase);
054: }
055:
056: public String getResourceBase() {
057: return resourceBase;
058: }
059:
060: public void setResourceBase(final String resourceBase) {
061: this .resourceBase = resourceBase;
062: }
063:
064: public String getResourcePrefix() {
065: return resourcePrefix;
066: }
067:
068: public void setResourcePrefix(final String resourcePrefix) {
069: this .resourcePrefix = resourcePrefix;
070: }
071:
072: public int getPosition() {
073: return position;
074: }
075:
076: public void setPosition(final int position) {
077: this .position = position;
078: }
079:
080: public String getName() {
081: return name;
082: }
083:
084: public void setName(final String name) {
085: if (name == null) {
086: throw new NullPointerException();
087: }
088: this .name = name;
089: }
090:
091: /**
092: * Returns the display name for the export action.
093: *
094: * @return The display name.
095: */
096: public String getDisplayName() {
097: return resources.getString(resourcePrefix + "name"); //$NON-NLS-1$
098: }
099:
100: /**
101: * Returns the short description for the export action.
102: *
103: * @return The short description.
104: */
105: public String getShortDescription() {
106: return resources.getString(resourcePrefix + "description"); //$NON-NLS-1$
107: }
108:
109: /**
110: * Returns the mnemonic key code.
111: *
112: * @return The code.
113: */
114: public Integer getMnemonicKey() {
115: return resources.getOptionalMnemonic(resourcePrefix
116: + "mnemonic"); //$NON-NLS-1$
117: }
118:
119: public boolean equals(final Object o) {
120: if (this == o) {
121: return true;
122: }
123: if (o == null || getClass() != o.getClass()) {
124: return false;
125: }
126:
127: final ActionCategory that = (ActionCategory) o;
128:
129: if (position != that.position) {
130: return false;
131: }
132: if (!name.equals(that.name)) {
133: return false;
134: }
135:
136: return true;
137: }
138:
139: public int hashCode() {
140: int result = position;
141: result = 29 * result + name.hashCode();
142: return result;
143: }
144:
145: /**
146: * Compares this object with the specified object for order. Returns a
147: * negative integer, zero, or a positive integer as this object is less than,
148: * equal to, or greater than the specified object.<p>
149: * <p/>
150: *
151: * @param o the Object to be compared.
152: * @return a negative integer, zero, or a positive integer as this object is
153: * less than, equal to, or greater than the specified object.
154: * @throws ClassCastException if the specified object's type prevents it from
155: * being compared to this Object.
156: */
157: public int compareTo(final Object o) {
158: final ActionCategory other = (ActionCategory) o;
159: if (position < other.position) {
160: return -1;
161: }
162: if (position > other.position) {
163: return 1;
164: }
165: return name.compareTo(other.name);
166: }
167:
168: public String toString() {
169: return "ActionCategory{" + //$NON-NLS-1$
170: "name='" + name + '\'' + //$NON-NLS-1$
171: ", position=" + position + //$NON-NLS-1$
172: ", resourceBase='" + resourceBase + '\'' + //$NON-NLS-1$
173: ", resourcePrefix='" + resourcePrefix + '\'' + //$NON-NLS-1$
174: ", resources=" + resources + //$NON-NLS-1$
175: '}';
176: }
177:
178: public void setUserDefined(final boolean userDefined) {
179: this .userDefined = userDefined;
180: }
181:
182: public boolean isUserDefined() {
183: return userDefined;
184: }
185: }
|