001: /*BEGIN_COPYRIGHT_BLOCK
002: *
003: * Copyright (c) 2001-2007, JavaPLT group at Rice University (javaplt@rice.edu)
004: * All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions are met:
008: * * Redistributions of source code must retain the above copyright
009: * notice, this list of conditions and the following disclaimer.
010: * * Redistributions in binary form must reproduce the above copyright
011: * notice, this list of conditions and the following disclaimer in the
012: * documentation and/or other materials provided with the distribution.
013: * * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
014: * names of its contributors may be used to endorse or promote products
015: * derived from this software without specific prior written permission.
016: *
017: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
018: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
019: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
020: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
021: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
022: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
023: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
024: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
025: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
026: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
027: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
028: *
029: * This software is Open Source Initiative approved Open Source Software.
030: * Open Source Initative Approved is a trademark of the Open Source Initiative.
031: *
032: * This file is part of DrJava. Download the current version of this project
033: * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
034: *
035: * END_COPYRIGHT_BLOCK*/
036:
037: package edu.rice.cs.drjava.ui;
038:
039: import edu.rice.cs.drjava.model.SingleDisplayModel;
040: import edu.rice.cs.drjava.model.compiler.CompilerErrorModel;
041: import edu.rice.cs.util.text.SwingDocument;
042:
043: import javax.swing.text.*;
044:
045: /**
046: * The panel which displays all the Javadoc parsing errors.
047: *
048: * @version $Id: JavadocErrorPanel.java 4255 2007-08-28 19:17:37Z mgricken $
049: */
050: public class JavadocErrorPanel extends ErrorPanel {
051:
052: protected JavadocErrorListPane _errorListPane;
053:
054: // TODO: Is this field necessary?
055: // private boolean _successful;
056:
057: /**
058: * Constructor.
059: * @param model SingleDisplayModel in which we are running
060: * @param frame MainFrame in which we are displayed
061: */
062: public JavadocErrorPanel(SingleDisplayModel model, MainFrame frame) {
063: super (model, frame, "Javadoc Output", "Javadoc");
064: // _successful = true;
065: _errorListPane = new JavadocErrorListPane();
066: setErrorListPane(_errorListPane);
067: }
068:
069: /**
070: * Returns the JavadocErrorListPane that this panel manages.
071: */
072: public JavadocErrorListPane getErrorListPane() {
073: return _errorListPane;
074: }
075:
076: protected CompilerErrorModel getErrorModel() {
077: return getModel().getJavadocModel().getJavadocErrorModel();
078: }
079:
080: /** Called when work begins. */
081: public void setJavadocInProgress() {
082: _errorListPane.setJavadocInProgress();
083: }
084:
085: /**
086: * Clean up when the tab is closed.
087: */
088: protected void _close() {
089: super ._close();
090: getModel().getJavadocModel().resetJavadocErrors();
091: reset();
092: }
093:
094: /** Reset the errors to the current error information. */
095: public void reset() {
096: CompilerErrorModel model = getModel().getJavadocModel()
097: .getJavadocErrorModel();
098: if (model != null)
099: _numErrors = model.getNumErrors();
100: else
101: _numErrors = 0;
102:
103: _errorListPane.updateListPane(true);
104: }
105:
106: /**
107: * A pane to show Javadoc errors. It acts a bit like a listbox (clicking
108: * selects an item) but items can each wrap, etc.
109: */
110: public class JavadocErrorListPane extends ErrorPanel.ErrorListPane {
111: // private final JLabel _errorLabel = new JLabel();
112: // private final JLabel _testLabel = new JLabel();
113: // private final JLabel _fileLabel = new JLabel();
114:
115: /** Puts the error pane into "compilation in progress" state. */
116: public void setJavadocInProgress() {
117: _errorListPositions = new Position[0];
118:
119: SwingDocument doc = new SwingDocument();
120: doc.append("Generating Javadoc. Please wait...\n",
121: NORMAL_ATTRIBUTES);
122: setDocument(doc);
123: selectNothing();
124: }
125:
126: /** Used to show that the last javadoc command was unsuccessful. */
127: protected void _updateWithErrors() throws BadLocationException {
128: SwingDocument doc = new SwingDocument();
129: String failureName = "error";
130: if (getErrorModel().hasOnlyWarnings())
131: failureName = "warning";
132: _updateWithErrors(failureName, "found", doc);
133: }
134:
135: /** Used to show that the last compile was successful. */
136: protected void _updateNoErrors(boolean done)
137: throws BadLocationException {
138: SwingDocument doc = new SwingDocument();
139: String msg = (done) ? "Javadoc generated successfully."
140: : "";
141: doc.append(msg, NORMAL_ATTRIBUTES);
142: setDocument(doc);
143: selectNothing();
144: }
145:
146: // public JavadocError getError() {
147: // return _error;
148: // }
149:
150: }
151:
152: }
|