com.japisoft.xmlpad.toolkit.SingleDocumentEditor.showEditor(
"c:/conf.xml", true );
package demo;
import com.japisoft.xmlpad.XMLContainer;
import java.awt.*;
import javax.swing.*;
/** Simple component usage */
public class Demo extends JFrame {
public Demo() {
getContentPane().add( new XMLContainer()
);
setSize( new Dimension( 550, 400
) );
setTitle( "XMLPad simple demo"
);
setVisible( true );
}
public static void main( String[] args ) {
new Demo();
}
}
package demo;
import com.japisoft.xmlpad.*;
import com.japisoft.xmlpad.action.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/** Simple usage of the <code>XMLContainer</code>
toolbar action model
@version 1.1
*/
public class Demo extends JFrame {
public Demo() {
XMLContainer
mContainer = new XMLContainer();
getContentPane().add( mContainer
);
setSize( new Dimension( 550, 400
) );
setTitle( "JXMLPad application
demo" );
resetMenu( mContainer.getToolBarModel()
);
setVisible( true );
}
private void resetMenu( ToolBarModel model ) {
JMenuBar menuBar = new JMenuBar();
JMenu file = new JMenu( "File"
);
menuBar.add( file );
setJMenuBar( menuBar );
// I retreive all Action instances
from the
// current ActionModel
Action[] fileAction = new Action[]
{
ActionModel.getActionByName(
ActionModel.NEW_ACTION ),
ActionModel.getActionByName(
ActionModel.LOAD_ACTION ),
ActionModel.getActionByName(
ActionModel.SAVE_ACTION ),
ActionModel.getActionByName(
ActionModel.SAVEAS_ACTION )
};
buildMenu( fileAction, file );
}
private void buildMenu( Action[] actions, JMenu menu )
{
for ( int i = 0; i < actions.length;
i++ ) {
JMenuItem
item = ( JMenuItem )menu.add( actions[ i ] );
item.setText(
"" + actions[ i ].getValue( "ACTION.NAME" ) );
}
}
}
package demo;
import javax.swing.*;
import com.japisoft.xmlpad.XMLContainer;
/** Here an applet demonstration usage with JXMLPAD */
public class AppletDemo extends JApplet
{
public AppletDemo() {
super();
initUI();
}
private void initUI() {
getContentPane().add( new XMLContainer() );
}
}
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<!-- @(#)SwingApplet.html 1.1 97/07/02
-->
<html>
<body>
<!-- HTML CONVERTER -->
<OBJECT
classid="clsid:CAFEEFAC-0014-0000-0001-ABCDEFFEDCBA"
WIDTH = "600" HEIGHT = "400"
codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4_0_01-win.c
ab#Version=1,4,0,10">
<PARAM NAME = "CODE" VALUE = "demo.AppletDemo" >
<PARAM NAME = "ARCHIVE" VALUE = "../lib/xerces.jar,../lib/tool.jar,../lib/xm
lpad.jar" >
<PARAM NAME = "JAVA_CODEBASE" VALUE = "classes">
<PARAM NAME="type" VALUE="application/x-java-applet;jpi-version=1.4.0_01">
<PARAM NAME="scriptable" VALUE="false">
<COMMENT>
<EMBED
type="application/x-java-applet;jpi-version=1.4.0_01"
CODE =
"demo.AppletDemo"
ARCHIVE
= "../lib/xerces.jar,../lib/tool.jar,../lib/xmlpad.jar"
JAVA_CODEBASE
= "classes"
WIDTH
= "600"
HEIGHT
= "400"
scriptable="false"
pluginspage="http://java.sun.com/products/plugin/index.html#download">
<NOEMBED>
</NOEMBED>
</EMBED>
</COMMENT>
</OBJECT>
<!--
<APPLET CODE = "demo.AppletDemo" CODEBASE="res" ARCHIVE = "../lib/xerces.jar,../lib/tool.jar"
WIDTH = "600" HEI
GHT = "400">
</APPLET>
-->
<!--"END_CONVERTED_APPLET"-->
</body>
</html>
ActionModel.replaceActionByName(ActionModel.NEW_ACTION,
new NewAction() );
// Here my New action that write a default JSP page
class NewAction extends XMLAction
{
public NewAction() {
// Get
the same icon than the default New action
super(
ActionModel.NEW_ACTION );
}
public void notifyAction() {
editor.setText(
"<%@page language=\"java\"%>\n" +
"<html>\n" +
"<body>\n" +
"</body>\n" +
"</html>" );
}
public String getName() {
return
ActionModel.NEW_ACTION;
}
}
// Disable the parse and format action
ActionModel.setEnabledAction( ActionModel.REFRESH_ACTION, false );
ActionModel.setEnabledAction( ActionModel.FORMAT_ACTION, false );
// run the new action
ActionModel.activeActionByName(ActionModel.NEW_ACTION);
factory=com.japisoft.xmlpad.ComponentFactory
look=com.japisoft.xmlpad.look.MozillaLook
tree=true
location=true
fontname=Dialog
fontsize=12
action.file.1=com.japisoft.xmlpad.action.NewAction
action.file.2=com.japisoft.xmlpad.action.LoadAction
action.file.3=com.japisoft.xmlpad.action.SaveAsAction
action.edit.1=com.japisoft.xmlpad.action.CutAction
action.edit.2=com.japisoft.xmlpad.action.CopyAction
action.edit.3=com.japisoft.xmlpad.action.PasteAction
groupOrder=file,edit
Name |
Role |
New |
Build a new XML document. This action uses the XMLTemplate
class for building a new page. |
Load |
Load an XML document |
SaveAs |
Save an XML document |
Copy |
Copy a text |
Cut |
Cut a text |
Paste |
Paste a text |
Undo |
Undo the last action but this is a new document action |
Redo |
Redo the last action but to undo action has been
called |
Refresh |
Parse the current document and show any error in
red |
Search |
Parse the current document and show a tree for easily
navigating |
Split |
Split the current editor in two ones |
Format |
Ident the current XML text. |
addTagDescriptor
method on the
SyntaxHelper.
<!-- Here a minimal DTD for JSP page -->
<!ELEMENT html (head,body)>
<!ELEMENT head (title)>
<!ELEMENT title #PCDATA>
<!ELEMENT body (jsp:include|jsp:getProperty|jsp:setProperty|jsp:useBean)>
<!ELEMENT jsp:include EMPTY>
<!ATTLIST jsp:include
page CDATA #REQUIRED>
<!ELEMENT jsp:getProperty EMPTY>
<!ATTLIST jsp:getProperty
name CDATA #REQUIRED
property CDATA #REQUIRED>
<!ELEMENT jsp:setProperty EMPTY>
<!ATTLIST jsp:setProperty
property CDATA #REQUIRED
value CDATA #REQUIRED>
<!ELEMENT jsp:useBean EMPTY>
<!ATTLIST jsp:useBean
id CDATA #REQUIRED
scope CDATA #REQUIRED>
<!DOCTYPE Module SYSTEM "file:///home/japisoft/test/project/myDTD.dtd">
package com.japisoft.xmleditor.look;
import java.awt.*;
import com.japisoft.xmleditor.bean.XMLEditor;
import com.japisoft.xmleditor.bean.XMLTemplate;
/**
* Default look for the <code>XMLEditor</code>
*
* @author (c) 2002 JAPISoft
* @version 1.0
* @see Look
* @see LookManager */
public class DefaultLook implements Look
{
public DefaultLook() {
super();
}
public void install( XMLEditor
editor ) {
editor.setErrorLineColor( new
Color( 200, 0, 0 ) );
// Syntax Colorization
editor.setCommentColor( new Color(
255, 0, 0 ) );
// <? and <!
editor.setDeclarationColor( Color.gray.darker()
);
editor.setDocTypeColor( Color.gray.darker()
);
editor.setTagColor( Color.green.darker().darker()
);
editor.setLiteralColor( Color.blue
);
// Tag delimiter
editor.setTagDelimiterHighlight(
true );
editor.setTagDelimiterHighlightColor(
editor.getTagColor().brighter() );
// Att delimiter
editor.setAttDelimiterHighlight(
true );
editor.setAttDelimiterHighlightColor(
new Color( 100, 100, 150 ) );
editor.setCaretColor( Color.black
);
editor.setEntityColor(
Color.blue );
editor.setSelectionLineColor(
new Color( 150, 150, 230 ) );
editor.setBackground( Color.lightGray
);
editor.setForeground( Color.black
);
editor.setDeclarationFont( new
Font( null, Font.BOLD, 10 ) );
editor.setDocTypeFont( new Font(
null, Font.BOLD, 10 ) );
editor.getCaret().setBlinkRate(
500 );
// Template
XMLTemplate
template = new XMLTemplate();
template.setComment( " Version
: 1.0, Date : " + new java.util.Date() );
editor.setTemplate( template
);
}
public void uninstall( XMLEditor
editor ) {
}
}
Property name |
Property role |
Default value |
factory |
Components for the XMLContainer like the toolbar,
the editor... |
com.japisoft.xmlpad.ComponentFactory |
look |
The Default lookAndFeel |
com.japisoft.xmlpad.look.MozillaLook |
tree |
Show the real time tree |
true |
location |
Localize the current cursor in the tree |
true |
fontname |
Font name |
Dialog |
fontsize |
Font size |
12 |