|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| JavadocErrorPanel.java | 37.5% | 55.6% | 54.5% | 52.7% |
|
||||||||||||||
| 1 | /*BEGIN_COPYRIGHT_BLOCK | |
| 2 | * | |
| 3 | * Copyright (c) 2001-2010, JavaPLT group at Rice University (drjava@rice.edu) | |
| 4 | * All rights reserved. | |
| 5 | * | |
| 6 | * Redistribution and use in source and binary forms, with or without | |
| 7 | * modification, are permitted provided that the following conditions are met: | |
| 8 | * * Redistributions of source code must retain the above copyright | |
| 9 | * notice, this list of conditions and the following disclaimer. | |
| 10 | * * Redistributions in binary form must reproduce the above copyright | |
| 11 | * notice, this list of conditions and the following disclaimer in the | |
| 12 | * documentation and/or other materials provided with the distribution. | |
| 13 | * * Neither the names of DrJava, the JavaPLT group, Rice University, nor the | |
| 14 | * names of its contributors may be used to endorse or promote products | |
| 15 | * derived from this software without specific prior written permission. | |
| 16 | * | |
| 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 18 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 20 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
| 21 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 23 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 24 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
| 25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
| 26 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 28 | * | |
| 29 | * This software is Open Source Initiative approved Open Source Software. | |
| 30 | * Open Source Initative Approved is a trademark of the Open Source Initiative. | |
| 31 | * | |
| 32 | * This file is part of DrJava. Download the current version of this project | |
| 33 | * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/ | |
| 34 | * | |
| 35 | * END_COPYRIGHT_BLOCK*/ | |
| 36 | ||
| 37 | package edu.rice.cs.drjava.ui; | |
| 38 | ||
| 39 | import edu.rice.cs.drjava.model.SingleDisplayModel; | |
| 40 | import edu.rice.cs.drjava.model.compiler.CompilerErrorModel; | |
| 41 | ||
| 42 | import javax.swing.text.*; | |
| 43 | ||
| 44 | /** | |
| 45 | * The panel which displays all the Javadoc parsing errors. | |
| 46 | * | |
| 47 | * @version $Id: JavadocErrorPanel.java 5404 2010-10-25 22:22:48Z mgricken $ | |
| 48 | */ | |
| 49 | public class JavadocErrorPanel extends ErrorPanel { | |
| 50 | ||
| 51 | protected JavadocErrorListPane _errorListPane; | |
| 52 | ||
| 53 | /** Constructor. | |
| 54 | * @param model SingleDisplayModel in which we are running | |
| 55 | * @param frame MainFrame in which we are displayed | |
| 56 | */ | |
| 57 | 38 | public JavadocErrorPanel(SingleDisplayModel model, MainFrame frame) { |
| 58 | 38 | super(model, frame, "Javadoc Output", "Javadoc"); |
| 59 | // _successful = true; | |
| 60 | 38 | _errorListPane = new JavadocErrorListPane(); |
| 61 | 38 | setErrorListPane(_errorListPane); |
| 62 | } | |
| 63 | ||
| 64 | /** Returns the JavadocErrorListPane that this panel manages. | |
| 65 | */ | |
| 66 | 76 | public JavadocErrorListPane getErrorListPane() { |
| 67 | 76 | return _errorListPane; |
| 68 | } | |
| 69 | ||
| 70 | 0 | protected CompilerErrorModel getErrorModel() { |
| 71 | 0 | return getModel().getJavadocModel().getJavadocErrorModel(); |
| 72 | } | |
| 73 | ||
| 74 | /** Called when work begins. */ | |
| 75 | 0 | public void setJavadocInProgress() { |
| 76 | 0 | _errorListPane.setJavadocInProgress(); |
| 77 | } | |
| 78 | ||
| 79 | /** Closes this panel and resets the corresponding model. */ | |
| 80 | 4 | @Override |
| 81 | protected void _close() { | |
| 82 | 4 | super._close(); |
| 83 | 4 | getModel().getJavadocModel().resetJavadocErrors(); |
| 84 | 4 | reset(); |
| 85 | } | |
| 86 | ||
| 87 | /** Reset the errors to the current error information. */ | |
| 88 | 42 | public void reset() { |
| 89 | 42 | CompilerErrorModel model = getModel().getJavadocModel().getJavadocErrorModel(); |
| 90 | 42 | if (model != null) _numErrors = model.getNumErrors(); |
| 91 | 0 | else _numErrors = 0; |
| 92 | ||
| 93 | 42 | _errorListPane.updateListPane(true); |
| 94 | } | |
| 95 | ||
| 96 | /** A pane to show Javadoc errors. It acts a bit like a listbox (clicking | |
| 97 | * selects an item) but items can each wrap, etc. | |
| 98 | */ | |
| 99 | public class JavadocErrorListPane extends ErrorPanel.ErrorListPane { | |
| 100 | protected boolean _wasSuccessful = false; | |
| 101 | ||
| 102 | // private final JLabel _errorLabel = new JLabel(); | |
| 103 | // private final JLabel _testLabel = new JLabel(); | |
| 104 | // private final JLabel _fileLabel = new JLabel(); | |
| 105 | ||
| 106 | /** Puts the error pane into "compilation in progress" state. */ | |
| 107 | 0 | public void setJavadocInProgress() { |
| 108 | 0 | _errorListPositions = new Position[0]; |
| 109 | ||
| 110 | 0 | ErrorDocument doc = new ErrorDocument(getErrorDocumentTitle()); |
| 111 | 0 | doc.append("Generating Javadoc. Please wait...\n", NORMAL_ATTRIBUTES); |
| 112 | 0 | setDocument(doc); |
| 113 | 0 | selectNothing(); |
| 114 | 0 | _wasSuccessful = false; |
| 115 | } | |
| 116 | ||
| 117 | 0 | public void setJavadocEnded(boolean success) { _wasSuccessful = success; } |
| 118 | ||
| 119 | /** Used to show that the last javadoc command was unsuccessful. */ | |
| 120 | 0 | protected void _updateWithErrors() throws BadLocationException { |
| 121 | 0 | ErrorDocument doc = new ErrorDocument(getErrorDocumentTitle()); |
| 122 | 0 | String failureName = "error"; |
| 123 | 0 | if (getErrorModel().hasOnlyWarnings()) failureName = "warning"; |
| 124 | 0 | _updateWithErrors(failureName, "found", doc); |
| 125 | } | |
| 126 | ||
| 127 | /** Used to show that the last compile was successful. */ | |
| 128 | 42 | protected void _updateNoErrors(boolean done) throws BadLocationException { |
| 129 | 42 | ErrorDocument doc = new ErrorDocument(getErrorDocumentTitle()); |
| 130 | 42 | String msg = ""; |
| 131 | 42 | if (done) { |
| 132 | 0 | if (_wasSuccessful) msg = "Javadoc generated successfully."; |
| 133 | 42 | else msg = "Javadoc generation failed."; |
| 134 | } | |
| 135 | 42 | doc.append(msg, NORMAL_ATTRIBUTES); |
| 136 | 42 | setDocument(doc); |
| 137 | 42 | selectNothing(); |
| 138 | } | |
| 139 | ||
| 140 | // public JavadocError getError() { | |
| 141 | // return _error; | |
| 142 | // } | |
| 143 | 80 | public String getErrorDocumentTitle() { return "Javadoc Errors"; } |
| 144 | } | |
| 145 | } |
|
||||||||||