API for XML all-purpose editor
The requirement is to be able to plug an XML editor into a Java
application. The application can launch an editor on a whole document
or
a sub-tree.
I implemented the interface :
Send comments to Jean-Marc Vanel
package jmvanel.xml;
import
javax.xml.transform.dom.DOMSource;
import org.w3c.dom.Node;
/** A robust XML
all-purpose editor and displayer.
* It is a view whose model is an XML
sub-tree.
* It is just a view, and doesn't manager
the application aspects:
* save as, user, session, history, etc.
* It can process documents with or
without XML Schema.
* In the presence of a Schema, it will
enforce validaty constraints at each
user input.
* The application can use DOM Events to
communicate with the XMLEditor.
* When the app. receives an Event from
the DOM implementation indicating a
change, it can send a popup to display a message.
* The application can also veto a
document modification entered by the user
by using the information in the interface MutationEvent.
* PENDING: how to manage an editor that
displays in real-time each update in the DOM (and more generally MVC
design patterns)
*/
public interface XMLEditor {
/** loads specified XML document in the
editor */
void setDOMSource(DOMSource s);
/** accessor to the editor Graphical User
Interface */
java.awt.Component getPanel();
/** use given XML Schema to assist and
validate user input */
void setSchema(DOMSource s);
/** indicates wether this implementation
allows to modify current document */
boolean isEditImplemented();
/** indicates wether the application allows
to modify current document */
boolean isEditAllowed();
/** indicates wether the document has been
modified by user (read-only property) */
boolean isDocumentModified(); // not really
necessary, because the application can subscribe to DOM events
/** loads specified XML configuration in the editor;
the XMLEditor must look all children of the document element for a
suitable configuration
* (so the application can have one
configuration for several XMLEditor implementations) */
void setConfiguration(DOMSource s);
DOMSource getDOMSource();
/** If the implementation has no XML Schema
capability, this method should return null */
DOMSource getSchema();
/** called by the application to allow or
forbid editing */
void setEditAllowed(boolean allowed);
/** If the implementation has no XML Configuration
capability, this method should return null */
DOMSource getConfiguration();
/** Accessor to the XML Schema of the Configuration
document (read-only property);
* if the implementation has no XML
Configuration capability, this method should return null */
DOMSource getConfigurationSchema();
}
package jmvanel.xml;
/** When the app. receives an
Event
from the DOM implementation indicating a change,
* it can use the
getUIContext() to get a reference to a GUI object where it
can add() a Component object to
provide a feedback.
* This object represents a
mapping between an XML Node and a zone in the GUI
where the application can send
messages concerning this Node.
*/
public interface
XMLEditorWithFeedback extends XMLEditor {
java.awt.Container
getUIContext(Node n);
}
package jmvanel.xml;
/** Multi-document XML
Editor. Is able
to manage several XML documents, eg by putting them in
* tabbed panes or in more sophisticated ways (eg a Graph editor).
* It is essentially a Collection and a factory for XML Editors.
* The individual XMLEditor's getPanel() accessors can return the same Component or
different
* Components.
*/
public interface XMLEditorMulti {
XMLEditor
newEditor();
void
removeEditor(XMLEditor editor);
XMLEditor[]
getEditors();
}