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-2006 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: package org.netbeans.modules.vmd.api.model;
042:
043: import java.awt.*;
044:
045: /**
046: * This immutable class represents a palette descriptor used in component descriptor.
047: * <p>
048: * It holds information about the category id, display name, small icon, and large icon.
049: *
050: * @author David Kaspar
051: */
052: public final class PaletteDescriptor {
053:
054: private final String categoryID;
055: private final String displayName;
056: private final String toolTip;
057: private final String smallIcon;
058: private final String largeIcon;
059:
060: /**
061: * Creates a new palette descriptor for describing always visible component descriptor by specifying category id, display name, small and large icon.
062: * @param categoryID the category id
063: * @param displayName the display name
064: * @param smallIcon the small icon
065: * @param largeIcon the large icon
066: */
067: public PaletteDescriptor(String categoryID, String displayName,
068: String toolTip, String smallIcon, String largeIcon) {
069: this .categoryID = categoryID;
070: this .displayName = displayName;
071: this .toolTip = toolTip;
072: this .smallIcon = smallIcon;
073: this .largeIcon = largeIcon;
074: }
075:
076: /**
077: * Return a palette category id.
078: * @return the palette category
079: */
080: public String getCategoryID() {
081: return categoryID;
082: }
083:
084: /**
085: * Return a display name.
086: * @return the display name
087: */
088: public String getDisplayName() {
089: return displayName;
090: }
091:
092: /**
093: * Return a tool tip.
094: * @return the tool tip
095: */
096: public String getToolTip() {
097: return toolTip;
098: }
099:
100: /**
101: * Returns a small icon.
102: * @return the small icon
103: */
104: public String getSmallIcon() {
105: return smallIcon;
106: }
107:
108: /**
109: * Returns a large icon.
110: * @return the large icon
111: */
112: public String getLargeIcon() {
113: return largeIcon;
114: }
115:
116: @Override
117: public boolean equals(Object o) {
118: if (this == o)
119: return true;
120: if (o == null || getClass() != o.getClass())
121: return false;
122:
123: final PaletteDescriptor descriptor = (PaletteDescriptor) o;
124:
125: if (displayName != null ? !displayName
126: .equals(descriptor.displayName)
127: : descriptor.displayName != null)
128: return false;
129: if (largeIcon != null ? !largeIcon.equals(descriptor.largeIcon)
130: : descriptor.largeIcon != null)
131: return false;
132: if (smallIcon != null ? !smallIcon.equals(descriptor.smallIcon)
133: : descriptor.smallIcon != null)
134: return false;
135:
136: return true;
137: }
138:
139: @Override
140: public int hashCode() {
141: int result;
142: result = displayName != null ? displayName.hashCode() : 0;
143: result = 29 * result
144: + (toolTip != null ? toolTip.hashCode() : 0);
145: result = 29 * result
146: + (smallIcon != null ? smallIcon.hashCode() : 0);
147: result = 29 * result
148: + (largeIcon != null ? largeIcon.hashCode() : 0);
149: return result;
150: }
151:
152: }
|