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: package com.sun.rave.designtime;
043:
044: import java.awt.Image;
045:
046: /**
047: * <p>A ResultMessage object represents a single message to a user about an operation that was just
048: * completed (or failed). ResultMessage objects are created and added to Result objects when
049: * returning from an operation.</p>
050: *
051: * @author Joe Nuxoll
052: * @version 1.0
053: * @see Result
054: */
055: public class ResultMessage implements DisplayItem {
056:
057: /**
058: * Used for type property - this message is informational, and may be displayed on the status
059: * bar to the user.
060: */
061: public static final int TYPE_INFORMATION = 0;
062:
063: /**
064: * Used for type property - this message is a warning, and may be displayed on the status bar
065: * or in a dialog to the user.
066: */
067: public static final int TYPE_WARNING = 1;
068:
069: /**
070: * Used for 'type' property - this message is critical, and will be displayed in a dialog to the
071: * user.
072: */
073: public static final int TYPE_CRITICAL = 2;
074:
075: /**
076: * Creates a new ResultMessage object with the specified type, displayName, and description.
077: *
078: * @param type The desired type of the message: TYPE_INFORMATION, TYPE_WARNING, or TYPE_CRITICAL.
079: * @param displayName The desired display name of the message
080: * @param description The desired description of the message
081: * @return A newly created ResultMessage object
082: */
083: public static ResultMessage create(int type, String displayName,
084: String description) {
085: return new ResultMessage(type, displayName, description);
086: }
087:
088: /**
089: * Creates a new ResultMessage object with the specified type, displayName, description, and icon.
090: *
091: * @param type The desired type of the message: TYPE_INFORMATION, TYPE_WARNING, or TYPE_CRITICAL.
092: * @param displayName The desired display name of the message
093: * @param description The desired description of the message
094: * @param smallIcon The desired image icon for the message
095: * @return A newly created ResultMessage object
096: */
097: public static ResultMessage create(int type, String displayName,
098: String description, Image smallIcon) {
099: return new ResultMessage(type, displayName, description,
100: smallIcon);
101: }
102:
103: protected int type;
104: protected String displayName;
105: protected String description;
106: protected Image smallIcon;
107: protected Image largeIcon;
108: protected String helpKey;
109:
110: public ResultMessage(int type, String displayName,
111: String description) {
112: if (type == TYPE_INFORMATION || type == TYPE_WARNING
113: || type == TYPE_CRITICAL) {
114: this .type = type;
115: } else {
116: throw new IllegalArgumentException(
117: "Message type must be TYPE_INFORMATION (0), TYPE_WARNING (1), or TYPE_CRITICAL (2)"); // NOI18N
118: }
119: this .type = type;
120: this .displayName = displayName;
121: this .description = description;
122: }
123:
124: public ResultMessage(int type, String displayName,
125: String description, Image smallIcon) {
126: this (type, displayName, description);
127: this .smallIcon = smallIcon;
128: }
129:
130: public void setMessageType(int type) {
131: if (type == TYPE_INFORMATION || type == TYPE_WARNING
132: || type == TYPE_CRITICAL) {
133: this .type = type;
134: } else {
135: throw new IllegalArgumentException(
136: "Message type must be TYPE_INFORMATION (0), TYPE_WARNING (1), or TYPE_CRITICAL (2)"); // NOI18N
137: }
138: }
139:
140: public int getMessageType() {
141: return type;
142: }
143:
144: public void setDisplayName(String displayName) {
145: this .displayName = displayName;
146: }
147:
148: public String getDisplayName() {
149: return displayName;
150: }
151:
152: public void setDescription(String description) {
153: this .description = description;
154: }
155:
156: public String getDescription() {
157: return description;
158: }
159:
160: public void setSmallIcon(Image smallIcon) {
161: this .smallIcon = smallIcon;
162: }
163:
164: public Image getSmallIcon() {
165: return smallIcon;
166: }
167:
168: public void setLargeIcon(Image largeIcon) {
169: this .largeIcon = largeIcon;
170: }
171:
172: public Image getLargeIcon() {
173: return largeIcon;
174: }
175:
176: public void setHelpKey(String helpKey) {
177: this .helpKey = helpKey;
178: }
179:
180: public String getHelpKey() {
181: return helpKey;
182: }
183: }
|