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,v 1.3 2007/04/01 18:49:31 taqua Exp $
027 * ------------
028 * (C) Copyright 2000-2005, by Object Refinery Limited.
029 * (C) Copyright 2005-2007, by Pentaho Corporation.
030 */
031
032 package org.jfree.report.modules.gui.swing.preview;
033
034 import org.jfree.report.modules.gui.swing.common.SwingGuiContext;
035 import org.jfree.util.ResourceBundleSupport;
036
037 /**
038 * Creation-Date: 01.12.2006, 18:49:32
039 *
040 * @author Thomas Morgner
041 */
042 public class ActionCategory implements Comparable
043 {
044 private String resourceBase;
045 private String resourcePrefix;
046 private int position;
047 private ResourceBundleSupport resources;
048 private String name;
049
050 public ActionCategory()
051 {
052 name = "";
053 }
054
055 public void initialize(SwingGuiContext context)
056 {
057 resources = new ResourceBundleSupport
058 (context.getLocale(), resourceBase);
059 }
060
061 public String getResourceBase()
062 {
063 return resourceBase;
064 }
065
066 public void setResourceBase(final String resourceBase)
067 {
068 this.resourceBase = resourceBase;
069 }
070
071 public String getResourcePrefix()
072 {
073 return resourcePrefix;
074 }
075
076 public void setResourcePrefix(final String resourcePrefix)
077 {
078 this.resourcePrefix = resourcePrefix;
079 }
080
081 public int getPosition()
082 {
083 return position;
084 }
085
086 public void setPosition(final int position)
087 {
088 this.position = position;
089 }
090
091 public String getName()
092 {
093 return name;
094 }
095
096 public void setName(final String name)
097 {
098 if (name == null)
099 {
100 throw new NullPointerException();
101 }
102 this.name = name;
103 }
104
105 /**
106 * Returns the display name for the export action.
107 *
108 * @return The display name.
109 */
110 public String getDisplayName()
111 {
112 return resources.getString(resourcePrefix + "name");
113 }
114
115 /**
116 * Returns the short description for the export action.
117 *
118 * @return The short description.
119 */
120 public String getShortDescription()
121 {
122 return resources.getString(resourcePrefix + "description");
123 }
124
125 /**
126 * Returns the mnemonic key code.
127 *
128 * @return The code.
129 */
130 public Integer getMnemonicKey()
131 {
132 return resources.getOptionalMnemonic(resourcePrefix + "mnemonic");
133 }
134
135 public boolean equals(final Object o)
136 {
137 if (this == o)
138 {
139 return true;
140 }
141 if (o == null || getClass() != o.getClass())
142 {
143 return false;
144 }
145
146 final ActionCategory that = (ActionCategory) o;
147
148 if (position != that.position)
149 {
150 return false;
151 }
152 if (!name.equals(that.name))
153 {
154 return false;
155 }
156
157 return true;
158 }
159
160 public int hashCode()
161 {
162 int result;
163 result = position;
164 result = 29 * result + name.hashCode();
165 return result;
166 }
167
168 /**
169 * Compares this object with the specified object for order. Returns a
170 * negative integer, zero, or a positive integer as this object is less than,
171 * equal to, or greater than the specified object.<p>
172 * <p/>
173 *
174 * @param o the Object to be compared.
175 * @return a negative integer, zero, or a positive integer as this object is
176 * less than, equal to, or greater than the specified object.
177 * @throws ClassCastException if the specified object's type prevents it from
178 * being compared to this Object.
179 */
180 public int compareTo(final Object o)
181 {
182 ActionCategory other = (ActionCategory) o;
183 if (position < other.position)
184 {
185 return -1;
186 }
187 if (position > other.position)
188 {
189 return 1;
190 }
191 return name.compareTo(other.name);
192 }
193
194 public String toString()
195 {
196 return "ActionCategory{" +
197 "name='" + name + '\'' +
198 ", position=" + position +
199 ", resourceBase='" + resourceBase + '\'' +
200 ", resourcePrefix='" + resourcePrefix + '\'' +
201 ", resources=" + resources +
202 '}';
203 }
204 }