Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 844 → Rev 845

/sun/xmleditor/trunk/src/control/DocumentManager.java
4,10 → 4,10
* Coded by: Group 5, software practice summer 2003
* University of Bielefeld, Germany
*
* @version $Revision: 1.128 $
* @version $Revision: 1.129 $
*
* Last modification: $Date: 2003/07/26 11:48:41 $
* $Id: DocumentManager.java,v 1.128 2003/07/26 11:48:41 smcsporr Exp $
* Last modification: $Date: 2003/07/26 11:58:33 $
* $Id: DocumentManager.java,v 1.129 2003/07/26 11:58:33 smcsporr Exp $
*/
 
package src.control;
50,7 → 50,7
*
* @author Group 5
*
* @version $Revision: 1.128 $ Last modification: $Date: 2003/07/26 11:48:41 $
* @version $Revision: 1.129 $ Last modification: $Date: 2003/07/26 11:58:33 $
*/
public class DocumentManager implements ActionListener,DocumentManagerInterface,ChangeListener {
 
150,7 → 150,8
}
/**
* The <code>actionPerformed</code> method is needed by an <code>ActionListener</code>.
* The <code>actionPerformed</code> method handles events related to documents.
*
* It takes <code>ActionEvent</code>s and starts the appropiate actions.
* The current implementation handles events with the following <code>ActionCommand</code>s:
*
165,7 → 166,7
* 'Set DTD'
* 'Set XML schema'
*
* @param event: The <code>ActionEvent</code> that occured.
* @param event The <code>ActionEvent</code> that occured.
*
* @see java.awt.event.ActionEvent
* @see java.awt.event.ActionListener
172,12 → 173,13
*
* author Group 5
*
* Last revision: 16-Jul-2003 by S. McSporran
* Last revision: 26-Jul-2003 by S. McSporran
*/
public void actionPerformed(ActionEvent event) {
/* Actions to perform if the user choosed the 'Open XML file' option. */
if (event.getActionCommand() == "Open XML file") {
/* Check if the user really choosed a file. */
if (! loadDocument()) {
} else {
193,6 → 195,7
/* Actions to perform if the user choosed the 'New document' option. */
if (event.getActionCommand() == "New document") {
/* Labels for the available choice buttons. */
String strDTD = "DTD";
String strSchema = "XML schema";
208,12 → 211,12
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE, null, options, strSchema);
/* Launch method createNewFileWithDTD if user chooses 'DTD'. */
/* User chooses 'DTD'. */
if (answer == JOptionPane.YES_OPTION) {
createNewFileWithDTD();
}
/* Launch method createNewFileWithSchema if user chooses 'XML schema'. */
/* User chooses 'XML schema'. */
if (answer == JOptionPane.NO_OPTION) {
createNewFileWithSchema();
}
248,8 → 251,8
/* If no filename has been specified, ask the user where to save. */
if (actualDocument.getFileName() == null) {
saveActiveDocumentAs();
}
else {
} else {
/* If the filename of the active document is known, save. */
saveActiveDocument();
}
261,6 → 264,7
 
/* Check, if a document is available. */
if (! openDocumentList.isEmpty()) {
/* Ask the user where to save the document. */
saveActiveDocumentAs();
}
269,16 → 273,32
/* Actions to perform if the user choosed the 'Validate document' option. */
if (event.getActionCommand() == "Validate document") {
/* Check, if a document exists. */
if (! openDocumentList.isEmpty()) {
/* Check if the document is valid. */
if (validator.validateDocument(actualDocument.getDomDoc(), actualDocument.getFileName())) {
log(LogInterface.TYPE_INFO, "The document is valid");
}
/* Check, if a grammar has been specified. */
if ((actualDocument.getDomDoc().getDocumentElement().hasAttribute("xsi:schemaLocation")) ||
(actualDocument.getDomDoc().getDoctype() != null)) {
/* Check, if the document is valid. */
if (validator.validateDocument(actualDocument.getDomDoc(),
actualDocument.getFileName())) {
log(LogInterface.TYPE_INFO, "The document is valid");
}
/* If not, print an error message. */
else {
log(LogInterface.TYPE_ERROR, "The document does not fit to the specified grammar");
/* Not valid -> Print an error message. */
else {
log(LogInterface.TYPE_ERROR, "The document does not fit to the specified grammar");
}
/* No grammar -> Print an error message. */
} else {
log(LogInterface.TYPE_ERROR, "No grammar specified.");
}
/* No document -> Print an error message. */
} else {
log(LogInterface.TYPE_ERROR, "No document available.");
}
}
956,7 → 976,6
}
}
 
/**
* <code>setNoDTD</code> deletes the DOCTYPE entry from an XML document's header.
*
966,7 → 985,8
public void setNoDTD() {
/* Check, if a DOCTYPE entry exists. */
if (actualDocument.getDomDoc() != null) {
if ((actualDocument.getDomDoc().getDoctype() != null) &&
(actualDocument.getDomDoc().getDoctype().getInternalSubset() == null)) {
actualDocument.changeDTDGrammar(actualDocument.getDomDoc(), null);
updateView.update();
} else {
1015,11 → 1035,9
if (saveWithValidationDialog(actualDocument.getTitle())){
actualDocument.saveDocument(actualDocument.getDomDoc(),actualDocument.getFileName());
actualDocument.setSaved();
}
}
}
}
}
}
 
/**