KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > multiview > Error


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.multiview;
21
22  /** Error.java
23  *
24  * Created on November 20, 2004, 12:27 PM
25  * @author mkuchtiak
26  */

27 public class Error {
28
29     public static final int TYPE_FATAL=0;
30     public static final int TYPE_WARNING=1;
31
32     public static final int ERROR_MESSAGE=0;
33     public static final int WARNING_MESSAGE=1;
34     public static final int MISSING_VALUE_MESSAGE=2;
35     public static final int DUPLICATE_VALUE_MESSAGE=3;
36
37     private int errorType;
38     private int severityLevel;
39     private String JavaDoc errorMessage;
40     private javax.swing.JComponent JavaDoc focusableComponent;
41     private ErrorLocation errorLocation;
42     
43     /*
44     public Error(int errorType, String errorMessage, javax.swing.JComponent focusableComponent) {
45         this(TYPE_WARNING, errorType, errorMessage, focusableComponent);
46     }
47
48     public Error(int severityLevel, int errorType, String errorMessage, javax.swing.JComponent focusableComponent) {
49         this.severityLevel=severityLevel;
50         this.errorType=errorType;
51         this.errorMessage=errorMessage;
52         this.focusableComponent=focusableComponent;
53     }
54     */

55     public Error(int errorType, String JavaDoc errorMessage, javax.swing.JComponent JavaDoc focusableComponent) {
56         this(TYPE_WARNING ,errorType, errorMessage, focusableComponent);
57     }
58         
59     public Error(int severityLevel, int errorType, String JavaDoc errorMessage, javax.swing.JComponent JavaDoc focusableComponent) {
60         this.severityLevel=severityLevel;
61         this.errorType=errorType;
62         this.errorMessage=errorMessage;
63         this.focusableComponent=focusableComponent;
64     }
65     
66     public Error(int errorType, String JavaDoc errorMessage, ErrorLocation errorLocation) {
67         this(TYPE_WARNING,errorType, errorMessage, errorLocation);
68     }
69     
70     public Error(int severityLevel, int errorType, String JavaDoc errorMessage, ErrorLocation errorLocation) {
71         this.severityLevel=severityLevel;
72         this.errorType=errorType;
73         this.errorMessage=errorMessage;
74         this.errorLocation=errorLocation;
75     }
76
77     public int getSeverityLevel() {
78         return severityLevel;
79     }
80     
81     public int getErrorType() {
82         return errorType;
83     }
84
85     public String JavaDoc getErrorMessage() {
86         return errorMessage;
87     }
88
89     public javax.swing.JComponent JavaDoc getFocusableComponent() {
90         return focusableComponent;
91     }
92
93     public ErrorLocation getErrorLocation() {
94         return errorLocation;
95     }
96     
97     public boolean isEditError() {
98         return (focusableComponent!=null);
99     }
100     
101     /** Object that will enable to identify the place in section view where the error
102      * should be fixed. This is intended to use in SectionView:validateView() method.
103      */

104     public static class ErrorLocation {
105         private Object JavaDoc key;
106         private String JavaDoc componentId;
107         
108         public ErrorLocation (Object JavaDoc key, String JavaDoc componentId) {
109             this.key=key;
110             this.componentId=componentId;
111         }
112         
113         public Object JavaDoc getKey() {
114             return key;
115         }
116         public String JavaDoc getComponentId() {
117             return componentId;
118         }
119     }
120     
121 }
122
Popular Tags