KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > ui > validation > ValidationAnnotation


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * Created on Mar 22, 2005
22  *
23  * To change the template for this generated file go to
24  * Window - Preferences - Java - Code Generation - Code and Comments
25  */

26 package org.netbeans.modules.xml.wsdl.ui.validation;
27
28 import java.beans.PropertyChangeEvent JavaDoc;
29 import java.beans.PropertyChangeListener JavaDoc;
30 import java.util.ArrayList JavaDoc;
31 import java.util.Iterator JavaDoc;
32 import java.util.List JavaDoc;
33
34 import org.openide.text.Annotation;
35 import org.openide.text.Line;
36
37 /**
38  * @author radval
39  *
40  * To change the template for this generated type comment go to
41  * Window - Preferences - Java - Code Generation - Code and Comments
42  */

43 public class ValidationAnnotation extends Annotation implements PropertyChangeListener JavaDoc {
44     
45     /** The error message shown on mouseover on the pmd icon */
46     private String JavaDoc errormessage = null;
47     
48     /** The annotations currently existing. */
49     private static List JavaDoc annotations = new ArrayList JavaDoc();
50     
51     private ValidationAnnotation() {}
52     
53     public static final ValidationAnnotation getNewInstance() {
54         ValidationAnnotation va = new ValidationAnnotation();
55         annotations.add( va );
56         return va;
57     }
58     
59     public static final void clearAll() {
60         Iterator JavaDoc iterator = annotations.iterator();
61         while( iterator.hasNext() ) {
62             ((Annotation)iterator.next()).detach();
63         }
64         annotations.clear();
65     }
66     
67     /**
68      * The annotation type.
69      *
70      * @return the string "wsdl-validation-annotation"
71      */

72     @Override JavaDoc
73     public String JavaDoc getAnnotationType() {
74         return "org-netbeans-modules-xml-core-error"; //NOI18N
75
}
76     
77     
78     /**
79      * Sets the current errormessage
80      *
81      * @param message the errormessage
82      */

83     public void setErrorMessage( String JavaDoc message ) {
84         errormessage = message;
85     }
86     
87     
88     /**
89      * A short description of this annotation
90      *
91      * @return the short description
92      */

93     @Override JavaDoc
94     public String JavaDoc getShortDescription() {
95         return errormessage;
96     }
97     
98     
99     /**
100      * Invoked when the user change the content on the line where the annotation is
101      * attached
102      *
103      * @param propertyChangeEvent the event fired
104      */

105     public void propertyChange( PropertyChangeEvent JavaDoc propertyChangeEvent ) {
106         Line line = ( Line )propertyChangeEvent.getSource();
107         line.removePropertyChangeListener( this );
108         detach();
109     }
110     
111 }
112
113
Popular Tags