KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > rice > cs > drjava > ui > JavadocErrorPanel


1 /*BEGIN_COPYRIGHT_BLOCK
2  *
3  * This file is part of DrJava. Download the current version of this project from http://www.drjava.org/
4  * or http://sourceforge.net/projects/drjava/
5  *
6  * DrJava Open Source License
7  *
8  * Copyright (C) 2001-2005 JavaPLT group at Rice University (javaplt@rice.edu). All rights reserved.
9  *
10  * Developed by: Java Programming Languages Team, Rice University, http://www.cs.rice.edu/~javaplt/
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13  * documentation files (the "Software"), to deal with the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
15  * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
16  *
17  * - Redistributions of source code must retain the above copyright notice, this list of conditions and the
18  * following disclaimers.
19  * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
20  * following disclaimers in the documentation and/or other materials provided with the distribution.
21  * - Neither the names of DrJava, the JavaPLT, Rice University, nor the names of its contributors may be used to
22  * endorse or promote products derived from this Software without specific prior written permission.
23  * - Products derived from this software may not be called "DrJava" nor use the term "DrJava" as part of their
24  * names without prior written permission from the JavaPLT group. For permission, write to javaplt@rice.edu.
25  *
26  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
27  * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28  * CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
29  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30  * WITH THE SOFTWARE.
31  *
32  *END_COPYRIGHT_BLOCK*/

33
34 package edu.rice.cs.drjava.ui;
35
36 import edu.rice.cs.drjava.model.SingleDisplayModel;
37 import edu.rice.cs.drjava.model.compiler.CompilerErrorModel;
38 import edu.rice.cs.util.text.SwingDocument;
39
40 import javax.swing.text.*;
41
42 /**
43  * The panel which displays all the Javadoc parsing errors.
44  *
45  * @version $Id: JavadocErrorPanel.java 4026 2006-10-31 15:50:16Z rcartwright $
46  */

47 public class JavadocErrorPanel extends ErrorPanel {
48
49   protected JavadocErrorListPane _errorListPane;
50   // TODO: Is this field necessary?
51
// private boolean _successful;
52

53   /**
54    * Constructor.
55    * @param model SingleDisplayModel in which we are running
56    * @param frame MainFrame in which we are displayed
57    */

58   public JavadocErrorPanel(SingleDisplayModel model, MainFrame frame) {
59     super(model, frame, "Javadoc Output", "Javadoc");
60 // _successful = true;
61
_errorListPane = new JavadocErrorListPane();
62     setErrorListPane(_errorListPane);
63   }
64
65   /**
66    * Returns the JavadocErrorListPane that this panel manages.
67    */

68   public JavadocErrorListPane getErrorListPane() {
69     return _errorListPane;
70   }
71
72   protected CompilerErrorModel getErrorModel() {
73     return getModel().getJavadocModel().getJavadocErrorModel();
74   }
75
76   /** Called when work begins. */
77   public void setJavadocInProgress() {
78     _errorListPane.setJavadocInProgress();
79   }
80
81   /**
82    * Clean up when the tab is closed.
83    */

84   protected void _close() {
85     super._close();
86     getModel().getJavadocModel().resetJavadocErrors();
87     reset();
88   }
89
90   /** Reset the errors to the current error information. */
91   public void reset() {
92     CompilerErrorModel model = getModel().getJavadocModel().getJavadocErrorModel();
93     if (model != null) _numErrors = model.getNumErrors();
94     else _numErrors = 0;
95
96     _errorListPane.updateListPane(true);
97   }
98
99   /**
100    * A pane to show Javadoc errors. It acts a bit like a listbox (clicking
101    * selects an item) but items can each wrap, etc.
102    */

103   public class JavadocErrorListPane extends ErrorPanel.ErrorListPane {
104 // private final JLabel _errorLabel = new JLabel();
105
// private final JLabel _testLabel = new JLabel();
106
// private final JLabel _fileLabel = new JLabel();
107

108     /** Puts the error pane into "compilation in progress" state. */
109     public void setJavadocInProgress() {
110       _errorListPositions = new Position[0];
111
112       SwingDocument doc = new SwingDocument();
113       doc.append("Generating Javadoc. Please wait...\n", NORMAL_ATTRIBUTES);
114       setDocument(doc);
115       selectNothing();
116     }
117
118     /** Used to show that the last javadoc command was unsuccessful. */
119     protected void _updateWithErrors() throws BadLocationException {
120       SwingDocument doc = new SwingDocument();
121       String JavaDoc failureName = "error";
122       if (getErrorModel().hasOnlyWarnings()) failureName = "warning";
123       _updateWithErrors(failureName, "found", doc);
124     }
125
126     /** Used to show that the last compile was successful. */
127     protected void _updateNoErrors(boolean done) throws BadLocationException {
128       SwingDocument doc = new SwingDocument();
129       String JavaDoc msg = (done) ? "Javadoc generated successfully." : "";
130       doc.append(msg, NORMAL_ATTRIBUTES);
131       setDocument(doc);
132       selectNothing();
133     }
134
135 // public JavadocError getError() {
136
// return _error;
137
// }
138

139   }
140
141 }
142
Popular Tags