001: /**
002: * ========================================
003: * JFreeReport : a free Java report library
004: * ========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2000-2007, by Object Refinery Limited, 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: * $Id: ActionCategory.java 3525 2007-10-16 11:43:48Z tmorgner $
027: * ------------
028: * (C) Copyright 2000-2005, by Object Refinery Limited.
029: * (C) Copyright 2005-2007, by Pentaho Corporation.
030: */package org.jfree.report.modules.gui.swing.preview;
031:
032: import org.jfree.report.modules.gui.swing.common.SwingGuiContext;
033: import org.jfree.util.ResourceBundleSupport;
034:
035: /**
036: * Creation-Date: 01.12.2006, 18:49:32
037: *
038: * @author Thomas Morgner
039: */
040: public class ActionCategory implements Comparable {
041: private String resourceBase;
042: private String resourcePrefix;
043: private int position;
044: private ResourceBundleSupport resources;
045: private String name;
046:
047: public ActionCategory() {
048: name = "";
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");
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");
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");
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{" + "name='" + name + '\''
170: + ", position=" + position + ", resourceBase='"
171: + resourceBase + '\'' + ", resourcePrefix='"
172: + resourcePrefix + '\'' + ", resources=" + resources
173: + '}';
174: }
175: }
|