tentative merge of EKIT_0_9H and custom patches
authorJeremy Laine <jeremy.laine@m4x.org>
Thu, 19 Aug 2004 02:06:45 +0000 (02:06 +0000)
committerJeremy Laine <jeremy.laine@m4x.org>
Thu, 19 Aug 2004 02:06:45 +0000 (02:06 +0000)
21 files changed:
ekit/MakeEkit.ant
ekit/MakeEkitApplet.ant
ekit/RunEkitApplet.csh [deleted file]
ekit/com/hexidec/ekit/Ekit.java
ekit/com/hexidec/ekit/EkitApplet.java
ekit/com/hexidec/ekit/EkitCore.java
ekit/com/hexidec/ekit/EkitCore_Basic.java [deleted file]
ekit/com/hexidec/ekit/EkitCore_Spell.java [deleted file]
ekit/com/hexidec/ekit/component/ExtendedHTMLEditorKit.java
ekit/com/hexidec/ekit/component/RelativeImageView.java
ekit/com/hexidec/util/CMUS.proposal.txt [deleted file]
ekit/com/hexidec/util/CMUScodec.java [deleted file]
ekit/com/hexidec/util/Cartesian.java [deleted file]
ekit/com/hexidec/util/DMCScodec.java [deleted file]
ekit/com/hexidec/util/MutableFilter.java [deleted file]
ekit/com/hexidec/util/PatternReplacer.java [deleted file]
ekit/com/hexidec/util/TreeSpider$FileTreeComparator.class [deleted file]
ekit/com/hexidec/util/TreeSpider.class [deleted file]
ekit/com/hexidec/util/TreeSpider.java [deleted file]
ekit/ekit.jar
ekit/ekitapplet.jar

index aa9a739..56a656a 100644 (file)
@@ -5,11 +5,13 @@
                <delete>\r
                        <fileset dir="${packagedir}/ekit/" includes="**/*.class"/>\r
                </delete>\r
+               <delete file="${packagedir}/util/Base64Codec.class"/>\r
                <delete file="${packagedir}/util/Translatrix.class"/>\r
        </target>\r
        <target name="compile" description="Compile code">\r
                <javac compiler="modern">\r
                        <src path="${packagedir}"/>\r
+                       <include name="util/Base64Codec.java"/>\r
                        <include name="util/Translatrix.java"/>\r
                        <include name="ekit/action/*.java"/>\r
                        <include name="ekit/component/*.java"/>\r
                        destfile="ekit.jar"\r
                        basedir="."\r
                        manifest="com/hexidec/ekit/ekit.manifest"\r
-                       includes="com/hexidec/ekit/*.class,com/hexidec/ekit/action/*.class,com/hexidec/ekit/component/*.class,com/hexidec/ekit/icons/*.gif,com/hexidec/ekit/*.properties,com/hexidec/util/Translatrix.class"/>\r
+                       includes="com/hexidec/ekit/*.class,com/hexidec/ekit/action/*.class,com/hexidec/ekit/component/*.class,com/hexidec/ekit/icons/*.gif,com/hexidec/ekit/*.properties,com/hexidec/util/Base64Codec.class,com/hexidec/util/Translatrix.class"/>\r
                <chmod file="ekit.jar" perm="755"/>\r
        </target>\r
        <target name="cleanup" description="Delete classes">\r
                <delete>\r
                        <fileset dir="${packagedir}/ekit/" includes="**/*.class"/>\r
                </delete>\r
+               <delete file="${packagedir}/util/Base64Codec.class"/>\r
                <delete file="${packagedir}/util/Translatrix.class"/>\r
        </target>\r
        <target name="fullbuild" depends="initialise,compile,distribute,cleanup">\r
index 6eadb11..cb485a2 100644 (file)
@@ -5,6 +5,7 @@
                <delete>\r
                        <fileset dir="${packagedir}/ekit/" includes="**/*.class"/>\r
                </delete>\r
+               <delete file="${packagedir}/util/Base64Codec.class"/>\r
                <delete file="${packagedir}/util/Translatrix.class"/>\r
        </target>\r
        <target name="compile" description="Compile code">\r
diff --git a/ekit/RunEkitApplet.csh b/ekit/RunEkitApplet.csh
deleted file mode 100644 (file)
index dd3bb47..0000000
+++ /dev/null
@@ -1 +0,0 @@
-appletviewer EkitAppletDemo.html\r
index 15c7c6d..33f1e94 100644 (file)
@@ -38,7 +38,7 @@ import javax.swing.JPanel;
 import javax.swing.JToolBar;
 
 import com.hexidec.ekit.EkitCore;
-import com.hexidec.ekit.EkitCoreSpell;
+//import com.hexidec.ekit.EkitCoreSpell;
 
 /** Ekit
   * App for editing and saving HTML in a Java text component
@@ -77,7 +77,7 @@ public class Ekit extends JFrame implements WindowListener
        {
                if(useSpellChecker)
                {
-                       ekitCore = new EkitCoreSpell(sDocument, sStyleSheet, sRawDocument, urlStyleSheet, includeToolBar, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, debugMode, true, multiBar);
+//                     ekitCore = new EkitCoreSpell(sDocument, sStyleSheet, sRawDocument, urlStyleSheet, includeToolBar, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, debugMode, true, multiBar);
                }
                else
                {
@@ -265,4 +265,4 @@ public class Ekit extends JFrame implements WindowListener
                }
        }
 
-}
\ No newline at end of file
+}
index e7e9201..b67aa53 100644 (file)
@@ -2,7 +2,7 @@
 GNU Lesser General Public License
 
 EkitApplet - Java Swing HTML Editor & Viewer Applet
-Copyright (C) 2000-2003 Howard Kistler
+Copyright (C) 2000 Howard Kistler
 
 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
@@ -22,6 +22,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 package com.hexidec.ekit;
 
 import java.awt.BorderLayout;
+import java.awt.GridBagLayout;
+import java.awt.GridBagConstraints;
 import java.awt.Toolkit;
 import java.awt.event.KeyEvent;
 import java.net.MalformedURLException;
@@ -48,8 +50,6 @@ public class EkitApplet extends JApplet
        /* Components */
        EkitCore ekitCore;
 
-       private JLabel jlblStatus;
-
        /** Constructor
          */
        public EkitApplet()
@@ -77,7 +77,9 @@ public class EkitApplet extends JApplet
                        murle.printStackTrace(System.err);
                }
                boolean showToolBar = true;
+               boolean showToolBarMulti = false;
                if(this.getParameter("TOOLBAR") != null) { showToolBar = this.getParameter("TOOLBAR").equalsIgnoreCase("true"); }
+               if(this.getParameter("TOOLBARMULTI") != null) { showToolBar = this.getParameter("TOOLBARMULTI").equalsIgnoreCase("true"); showToolBarMulti = this.getParameter("TOOLBARMULTI").equalsIgnoreCase("true"); }
                boolean showViewSource = ((this.getParameter("SOURCEVIEW") != null && this.getParameter("SOURCEVIEW").equalsIgnoreCase("true")));
                String sLanguage = this.getParameter("LANGCODE");
                String sCountry = this.getParameter("LANGCOUNTRY");
@@ -85,8 +87,17 @@ public class EkitApplet extends JApplet
                if(this.getParameter("EXCLUSIVE") != null) { editModeExclusive = this.getParameter("EXCLUSIVE").equalsIgnoreCase("true"); }
                boolean showMenuIcons = true;
                if(this.getParameter("MENUICONS") != null) { showMenuIcons = this.getParameter("MENUICONS").equalsIgnoreCase("true"); }
+               boolean spellChecker = false;
+               if(this.getParameter("SPELLCHECK") != null) { spellChecker = this.getParameter("SPELLCHECK").equalsIgnoreCase("true"); }
 
-               ekitCore = new EkitCore(sRawDocument, urlCSS, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, this.getParameter("BASEURL"));
+               if(spellChecker)
+               {
+                       //ekitCore = new EkitCoreSpell(sRawDocument, urlCSS, showToolBar, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, showToolBarMulti, this.getParameter("BASEURL"));
+               }
+               else
+               {
+                       ekitCore = new EkitCore(sRawDocument, urlCSS, showToolBar, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false, showToolBarMulti, this.getParameter("BASEURL"));
+               }
 
                /* Obtain image servlet information */
                ekitCore.setServletURL(this.getParameter("SERVLETURL"));
@@ -107,38 +118,78 @@ public class EkitApplet extends JApplet
                if(this.getParameter("MENU_HELP")   != null) { if(this.getParameter("MENU_HELP").equalsIgnoreCase("true"))   { vcMenus.add(EkitCore.KEY_MENU_HELP); } }   else { vcMenus.add(EkitCore.KEY_MENU_HELP); }
                this.setJMenuBar(ekitCore.getCustomMenuBar(vcMenus));
 
-               jlblStatus = new JLabel();
-               
                /* Add the components to the app */
-               this.getContentPane().setLayout(new BorderLayout());
-               this.getContentPane().add(ekitCore, BorderLayout.CENTER);
-               this.getContentPane().add(jlblStatus, BorderLayout.SOUTH);
                if(showToolBar)
                {
-                       Vector vcTools = new Vector();
-                       vcTools.add(EkitCore.KEY_TOOL_NEW);
-                       vcTools.add(EkitCore.KEY_TOOL_SEP);
-                       vcTools.add(EkitCore.KEY_TOOL_CUT);
-                       vcTools.add(EkitCore.KEY_TOOL_COPY);
-                       vcTools.add(EkitCore.KEY_TOOL_PASTE);
-                       vcTools.add(EkitCore.KEY_TOOL_SEP);
-                       vcTools.add(EkitCore.KEY_TOOL_BOLD);
-                       vcTools.add(EkitCore.KEY_TOOL_ITALIC);
-                       vcTools.add(EkitCore.KEY_TOOL_UNDERLINE);
-                       vcTools.add(EkitCore.KEY_TOOL_STRIKE);
-                       vcTools.add(EkitCore.KEY_TOOL_SUPER);
-                       vcTools.add(EkitCore.KEY_TOOL_SUB);
-                       vcTools.add(EkitCore.KEY_TOOL_ULIST);
-                       vcTools.add(EkitCore.KEY_TOOL_OLIST);
-                       vcTools.add(EkitCore.KEY_TOOL_SEP);
-                       vcTools.add(EkitCore.KEY_TOOL_CLEAR);
-                       vcTools.add(EkitCore.KEY_TOOL_SEP);
-                       vcTools.add(EkitCore.KEY_TOOL_ANCHOR);
-                       vcTools.add(EkitCore.KEY_TOOL_SEP);
-                       vcTools.add(EkitCore.KEY_TOOL_SOURCE);
-                       vcTools.add(EkitCore.KEY_TOOL_SEP);
-                       vcTools.add(EkitCore.KEY_TOOL_STYLES);
-                       this.getContentPane().add(ekitCore.getCustomToolBar(vcTools, showToolBar), BorderLayout.NORTH);
+                       if(showToolBarMulti)
+                       {
+                               this.getContentPane().setLayout(new GridBagLayout());
+                               GridBagConstraints gbc = new GridBagConstraints();
+                               gbc.fill       = GridBagConstraints.HORIZONTAL;
+                               gbc.anchor     = GridBagConstraints.NORTH;
+                               gbc.gridheight = 1;
+                               gbc.gridwidth  = 1;
+                               gbc.weightx    = 1.0;
+                               gbc.weighty    = 0.0;
+                               gbc.gridx      = 1;
+
+                               gbc.gridy      = 1;
+                               Vector vcTools = new Vector();
+                               vcTools.add(EkitCore.KEY_TOOL_NEW);
+                               vcTools.add(EkitCore.KEY_TOOL_SEP);
+                               vcTools.add(EkitCore.KEY_TOOL_CUT);
+                               vcTools.add(EkitCore.KEY_TOOL_COPY);
+                               vcTools.add(EkitCore.KEY_TOOL_PASTE);
+                               vcTools.add(EkitCore.KEY_TOOL_SEP);
+                               vcTools.add(EkitCore.KEY_TOOL_CLEAR);
+                               vcTools.add(EkitCore.KEY_TOOL_SEP);
+                               vcTools.add(EkitCore.KEY_TOOL_ANCHOR);
+                               vcTools.add(EkitCore.KEY_TOOL_SEP);
+                               vcTools.add(EkitCore.KEY_TOOL_SOURCE);
+                               this.getContentPane().add(ekitCore.customizeToolBar(EkitCore.TOOLBAR_MAIN, vcTools, showToolBar), gbc);
+
+                               gbc.gridy      = 2;
+                               this.getContentPane().add(ekitCore.getToolBarFormat(showToolBar), gbc);
+
+                               gbc.gridy      = 3;
+                               this.getContentPane().add(ekitCore.getToolBarStyles(showToolBar), gbc);
+
+                               gbc.anchor     = GridBagConstraints.CENTER;
+                               gbc.fill       = GridBagConstraints.BOTH;
+                               gbc.weighty    = 1.0;
+                               gbc.gridy      = 4;
+                               this.getContentPane().add(ekitCore, gbc);
+                       }
+                       else
+                       {
+                               Vector vcTools = new Vector();
+                               vcTools.add(EkitCore.KEY_TOOL_NEW);
+                               vcTools.add(EkitCore.KEY_TOOL_SEP);
+                               vcTools.add(EkitCore.KEY_TOOL_CUT);
+                               vcTools.add(EkitCore.KEY_TOOL_COPY);
+                               vcTools.add(EkitCore.KEY_TOOL_PASTE);
+                               vcTools.add(EkitCore.KEY_TOOL_SEP);
+                               vcTools.add(EkitCore.KEY_TOOL_BOLD);
+                               vcTools.add(EkitCore.KEY_TOOL_ITALIC);
+                               vcTools.add(EkitCore.KEY_TOOL_UNDERLINE);
+                               vcTools.add(EkitCore.KEY_TOOL_STRIKE);
+                               vcTools.add(EkitCore.KEY_TOOL_SUPER);
+                               vcTools.add(EkitCore.KEY_TOOL_SUB);
+                               vcTools.add(EkitCore.KEY_TOOL_ULIST);
+                               vcTools.add(EkitCore.KEY_TOOL_OLIST);
+                               vcTools.add(EkitCore.KEY_TOOL_SEP);
+                               vcTools.add(EkitCore.KEY_TOOL_CLEAR);
+                               vcTools.add(EkitCore.KEY_TOOL_SEP);
+                               vcTools.add(EkitCore.KEY_TOOL_ANCHOR);
+                               vcTools.add(EkitCore.KEY_TOOL_SEP);
+                               vcTools.add(EkitCore.KEY_TOOL_SOURCE);
+                               vcTools.add(EkitCore.KEY_TOOL_SEP);
+                               vcTools.add(EkitCore.KEY_TOOL_STYLES);
+
+                               this.getContentPane().setLayout(new BorderLayout());
+                               this.getContentPane().add(ekitCore, BorderLayout.CENTER);
+                               this.getContentPane().add(ekitCore.customizeToolBar(EkitCore.TOOLBAR_MAIN, vcTools, showToolBar), BorderLayout.NORTH);
+                       }
                }
        }
 
index 07df9cb..87aef09 100644 (file)
@@ -2,7 +2,7 @@
 GNU Lesser General Public License
 
 EkitCore - Base Java Swing HTML Editor & Viewer Class (Basic Version)
-Copyright (C) 2000-2003 Howard Kistler
+Copyright (C) 2000 Howard Kistler
 
 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
@@ -57,6 +57,7 @@ import java.util.ResourceBundle;
 import java.util.Vector;
 import javax.swing.AbstractAction;
 import javax.swing.Action;
+import javax.swing.BorderFactory;
 import javax.swing.Icon;
 import javax.swing.ImageIcon;
 import javax.swing.JButton;
@@ -68,6 +69,7 @@ import javax.swing.JDialog;
 import javax.swing.JEditorPane;
 import javax.swing.JFileChooser;
 import javax.swing.JFrame;
+import javax.swing.JLabel;
 import javax.swing.JMenu;
 import javax.swing.JMenuBar;
 import javax.swing.JMenuItem;
@@ -75,11 +77,13 @@ import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JSplitPane;
+import javax.swing.JTextArea;
 import javax.swing.JTextField;
 import javax.swing.JTextPane;
 import javax.swing.JToggleButton;
 import javax.swing.JToolBar;
 import javax.swing.KeyStroke;
+import javax.swing.border.*;
 import javax.swing.event.CaretEvent;
 import javax.swing.event.CaretListener;
 import javax.swing.event.DocumentEvent;
@@ -94,6 +98,7 @@ import javax.swing.text.DefaultEditorKit;
 import javax.swing.text.DefaultStyledDocument;
 import javax.swing.text.Document;
 import javax.swing.text.Element;
+import javax.swing.text.JTextComponent;
 import javax.swing.text.PlainDocument;
 import javax.swing.text.Position;
 import javax.swing.text.Style;
@@ -118,7 +123,7 @@ import com.hexidec.util.Translatrix;
   * Main application class for editing and saving HTML in a Java text component
   *
   * @author Howard Kistler
-  * @version 0.9g
+  * @version 0.9h
   *
   * REQUIREMENTS
   * Java 2 (JDK 1.3 or 1.4)
@@ -133,12 +138,13 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
        private ExtendedHTMLEditorKit htmlKit;
        private ExtendedHTMLDocument htmlDoc;
        private StyleSheet styleSheet;
-       private JTextPane jtpSource;
+       private JTextArea jtpSource;
        private JScrollPane jspSource;
        private JToolBar jToolBar;
 
-       private JCheckBoxMenuItem jcbmiViewToolbar;
-       private JCheckBoxMenuItem jcbmiViewSource;
+       private JToolBar jToolBarMain;
+       private JToolBar jToolBarFormat;
+       private JToolBar jToolBarStyles;
 
        private JButtonNoFocus jbtnNewHTML;
        private JButtonNoFocus jbtnOpenHTML;
@@ -191,9 +197,17 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
        private JMenu jMenuTable;
        private JMenu jMenuForms;
        private JMenu jMenuSearch;
+       private JMenu jMenuTools;
        private JMenu jMenuHelp;
        private JMenu jMenuDebug;
 
+       private JMenu jMenuToolbars;
+       private JCheckBoxMenuItem jcbmiViewToolbar;
+       private JCheckBoxMenuItem jcbmiViewToolbarMain;
+       private JCheckBoxMenuItem jcbmiViewToolbarFormat;
+       private JCheckBoxMenuItem jcbmiViewToolbarStyles;
+       private JCheckBoxMenuItem jcbmiViewSource;
+
        /* Constants */
        // Menu Keys
        public static final String KEY_MENU_FILE   = "file";
@@ -230,6 +244,10 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
        public static final String KEY_TOOL_SOURCE    = "viewsource";
        public static final String KEY_TOOL_STYLES    = "styleselect";
 
+       public static final int TOOLBAR_MAIN   = 0;
+       public static final int TOOLBAR_FORMAT = 1;
+       public static final int TOOLBAR_STYLES = 2;
+
        // Menu & Tool Key Arrays
        private static Hashtable htMenus = new Hashtable();
        private static Hashtable htTools = new Hashtable();
@@ -255,6 +273,7 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
        private boolean lastSearchTopSetting  = false;
 
        private File currentFile = null;
+       private String imageChooserStartDir = ".";
 
        private int indent = 0;
        private final int indentStep = 4;
@@ -277,7 +296,9 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
          * @param sDocument         [String]  A text or HTML document to load in the editor upon startup.
          * @param sStyleSheet       [String]  A CSS stylesheet to load in the editor upon startup.
          * @param sRawDocument      [String]  A document encoded as a String to load in the editor upon startup.
+         * @param sdocSource        [StyledDocument] Optional document specification, using javax.swing.text.StyledDocument.
          * @param urlStyleSheet     [URL]     A URL reference to the CSS style sheet.
+         * @param includeToolBar    [boolean] Specifies whether the app should include the toolbar(s).
          * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
          * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
          * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
@@ -285,8 +306,10 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
          * @param sCountry          [String]  The country portion of the Internationalization Locale to run Ekit in.
          * @param base64            [boolean] Specifies whether the raw document is Base64 encoded or not.
          * @param debugMode         [boolean] Specifies whether to show the Debug menu or not.
+         * @param hasSpellChecker   [boolean] Specifies whether or not this uses the SpellChecker module
+         * @param multiBar          [boolean] Specifies whether to use multiple toolbars or one big toolbar.
          */
-       public EkitCore(String sDocument, String sStyleSheet, String sRawDocument, URL urlStyleSheet, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64, boolean debugMode, String baseurl)
+       public EkitCore(String sDocument, String sStyleSheet, String sRawDocument, StyledDocument sdocSource, URL urlStyleSheet, boolean includeToolBar, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64, boolean debugMode, boolean hasSpellChecker, boolean multiBar, String baseurl)
        {
                super();
 
@@ -342,10 +365,19 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
                jtpMain.addKeyListener(this);
 
                /* Create the source text area */
-               jtpSource = new JTextPane();
+               if(sdocSource == null)
+               {
+                       jtpSource = new JTextArea();
+                       jtpSource.setText(jtpMain.getText());
+               }
+               else
+               {
+                       jtpSource = new JTextArea(sdocSource);
+                       jtpMain.setText(jtpSource.getText());
+               }
                jtpSource.setBackground(new Color(212, 212, 212));
                jtpSource.setSelectionColor(new Color(255, 192, 192));
-               jtpSource.setText(jtpMain.getText());
+               jtpSource.setMargin(new Insets(4, 4, 4, 4));
                jtpSource.getDocument().addDocumentListener(this);
 
                /* Add CaretListener for tracking caret location events */
@@ -505,10 +537,41 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
                JMenuItem jmiSelWord = new JMenuItem((Action)actions.get(DefaultEditorKit.selectWordAction));      jmiSelWord.setText(Translatrix.getTranslationString("SelectWord"));      jMenuEdit.add(jmiSelWord);
 
                /* VIEW Menu */
-               jMenuView        = new JMenu(Translatrix.getTranslationString("View"));
+               jMenuView = new JMenu(Translatrix.getTranslationString("View"));
                htMenus.put(KEY_MENU_VIEW, jMenuView);
-               jcbmiViewToolbar = new JCheckBoxMenuItem(Translatrix.getTranslationString("ViewToolbar"), false); jcbmiViewToolbar.setActionCommand("toggletoolbar"); jcbmiViewToolbar.addActionListener(this); jMenuView.add(jcbmiViewToolbar);
-               jcbmiViewSource  = new JCheckBoxMenuItem(Translatrix.getTranslationString("ViewSource"), false);  jcbmiViewSource.setActionCommand("viewsource");     jcbmiViewSource.addActionListener(this);  jMenuView.add(jcbmiViewSource);
+               if(includeToolBar)
+               {
+                       if(multiBar)
+                       {
+                               jMenuToolbars = new JMenu(Translatrix.getTranslationString("ViewToolbars"));
+
+                               jcbmiViewToolbarMain = new JCheckBoxMenuItem(Translatrix.getTranslationString("ViewToolbarMain"), false);
+                                       jcbmiViewToolbarMain.setActionCommand("toggletoolbarmain");
+                                       jcbmiViewToolbarMain.addActionListener(this);
+                                       jMenuToolbars.add(jcbmiViewToolbarMain);
+
+                               jcbmiViewToolbarFormat = new JCheckBoxMenuItem(Translatrix.getTranslationString("ViewToolbarFormat"), false);
+                                       jcbmiViewToolbarFormat.setActionCommand("toggletoolbarformat");
+                                       jcbmiViewToolbarFormat.addActionListener(this);
+                                       jMenuToolbars.add(jcbmiViewToolbarFormat);
+
+                               jcbmiViewToolbarStyles = new JCheckBoxMenuItem(Translatrix.getTranslationString("ViewToolbarStyles"), false);
+                                       jcbmiViewToolbarStyles.setActionCommand("toggletoolbarstyles");
+                                       jcbmiViewToolbarStyles.addActionListener(this);
+                                       jMenuToolbars.add(jcbmiViewToolbarStyles);
+
+                               jMenuView.add(jMenuToolbars);
+                       }
+                       else
+                       {
+                               jcbmiViewToolbar = new JCheckBoxMenuItem(Translatrix.getTranslationString("ViewToolbar"), false);
+                                       jcbmiViewToolbar.setActionCommand("toggletoolbar");
+                                       jcbmiViewToolbar.addActionListener(this);
+
+                               jMenuView.add(jcbmiViewToolbar);
+                       }
+               }
+               jcbmiViewSource = new JCheckBoxMenuItem(Translatrix.getTranslationString("ViewSource"), false);  jcbmiViewSource.setActionCommand("viewsource");     jcbmiViewSource.addActionListener(this);  jMenuView.add(jcbmiViewSource);
 
                /* FONT Menu */
                jMenuFont              = new JMenu(Translatrix.getTranslationString("Font"));
@@ -603,9 +666,10 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
                jMenuInsert              = new JMenu(Translatrix.getTranslationString("Insert"));
                htMenus.put(KEY_MENU_INSERT, jMenuInsert);
                jMenuInsert.add(new JMenuItem(actionInsertAnchor));
-               JMenuItem jmiBreak       = new JMenuItem(Translatrix.getTranslationString("InsertBreak"));                    jmiBreak.setActionCommand("insertbreak"); jmiBreak.addActionListener(this); jmiBreak.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, java.awt.Event.SHIFT_MASK, false)); jMenuInsert.add(jmiBreak);
-               JMenuItem jmiNBSP        = new JMenuItem(Translatrix.getTranslationString("InsertNBSP"));                     jmiNBSP.setActionCommand("insertnbsp");   jmiNBSP.addActionListener(this);  jMenuInsert.add(jmiNBSP);
-               JMenuItem jmiHRule       = new JMenuItem((Action)actions.get("InsertHR"));                                    jmiHRule.setText(Translatrix.getTranslationString("InsertHorizontalRule")); jMenuInsert.add(jmiHRule);
+               JMenuItem jmiSymbol      = new JMenuItem(Translatrix.getTranslationString("InsertSymbol")); jmiSymbol.setActionCommand("insertsymbol"); jmiSymbol.addActionListener(this);  jMenuInsert.add(jmiSymbol);
+               JMenuItem jmiBreak       = new JMenuItem(Translatrix.getTranslationString("InsertBreak"));  jmiBreak.setActionCommand("insertbreak");   jmiBreak.addActionListener(this);   jmiBreak.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, java.awt.Event.SHIFT_MASK, false)); jMenuInsert.add(jmiBreak);
+               JMenuItem jmiNBSP        = new JMenuItem(Translatrix.getTranslationString("InsertNBSP"));   jmiNBSP.setActionCommand("insertnbsp");     jmiNBSP.addActionListener(this);    jMenuInsert.add(jmiNBSP);
+               JMenuItem jmiHRule       = new JMenuItem((Action)actions.get("InsertHR"));                  jmiHRule.setText(Translatrix.getTranslationString("InsertHorizontalRule")); jMenuInsert.add(jmiHRule);
                jMenuInsert.addSeparator();
                JMenuItem jmiImageLocal  = new JMenuItem(Translatrix.getTranslationString("InsertLocalImage") + menuDialog);  jmiImageLocal.setActionCommand("insertlocalimage"); jmiImageLocal.addActionListener(this); jMenuInsert.add(jmiImageLocal);
                JMenuItem jmiImageServer = new JMenuItem(Translatrix.getTranslationString("InsertServerImage") + menuDialog); jmiImageServer.setActionCommand("insertserverimage"); jmiImageServer.addActionListener(this); jMenuInsert.add(jmiImageServer);
@@ -636,6 +700,14 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
                JMenuItem jmiFormButtonSubmit = new JMenuItem(Translatrix.getTranslationString("FormButtonSubmit")); jmiFormButtonSubmit.setActionCommand("insertbuttonsubmit"); jmiFormButtonSubmit.addActionListener(this); jMenuForms.add(jmiFormButtonSubmit);
                JMenuItem jmiFormButtonReset  = new JMenuItem(Translatrix.getTranslationString("FormButtonReset"));  jmiFormButtonReset.setActionCommand("insertbuttonreset");   jmiFormButtonReset.addActionListener(this);  jMenuForms.add(jmiFormButtonReset);
 
+               /* TOOLS Menu */
+               if(hasSpellChecker)
+               {
+                       jMenuTools = new JMenu(Translatrix.getTranslationString("Tools"));
+                       htMenus.put(KEY_MENU_TOOLS, jMenuTools);
+                       JMenuItem jmiSpellcheck = new JMenuItem(Translatrix.getTranslationString("ToolSpellcheck")); jmiSpellcheck.setActionCommand("spellcheck"); jmiSpellcheck.addActionListener(this); jMenuTools.add(jmiSpellcheck);
+               }
+
                /* SEARCH Menu */
                jMenuSearch            = new JMenu(Translatrix.getTranslationString("Search"));
                htMenus.put(KEY_MENU_SEARCH, jMenuSearch);
@@ -666,38 +738,183 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
                jMenuBar.add(jMenuInsert);
                jMenuBar.add(jMenuTable);
                jMenuBar.add(jMenuForms);
+               if(jMenuTools != null) { jMenuBar.add(jMenuTools); }
                jMenuBar.add(jMenuHelp);
                if(debugMode)
                {
                        jMenuBar.add(jMenuDebug);
                }
 
+               /* Create toolbar tool objects */
+               jbtnNewHTML = new JButtonNoFocus(getEkitIcon("New"));
+                       jbtnNewHTML.setToolTipText(Translatrix.getTranslationString("NewDocument"));
+                       jbtnNewHTML.setActionCommand("newdoc");
+                       jbtnNewHTML.addActionListener(this);
+                       htTools.put(KEY_TOOL_NEW, jbtnNewHTML);
+               jbtnOpenHTML = new JButtonNoFocus(getEkitIcon("Open"));
+                       jbtnOpenHTML.setToolTipText(Translatrix.getTranslationString("OpenDocument"));
+                       jbtnOpenHTML.setActionCommand("openhtml");
+                       jbtnOpenHTML.addActionListener(this);
+                       htTools.put(KEY_TOOL_OPEN, jbtnOpenHTML);
+               jbtnSaveHTML = new JButtonNoFocus(getEkitIcon("Save"));
+                       jbtnSaveHTML.setToolTipText(Translatrix.getTranslationString("SaveDocument"));
+                       jbtnSaveHTML.setActionCommand("saveas");
+                       jbtnSaveHTML.addActionListener(this);
+                       htTools.put(KEY_TOOL_SAVE, jbtnSaveHTML);
+               jbtnCut = new JButtonNoFocus(new DefaultEditorKit.CutAction());
+                       jbtnCut.setIcon(getEkitIcon("Cut"));
+                       jbtnCut.setText(null);
+                       jbtnCut.setToolTipText(Translatrix.getTranslationString("Cut"));
+                       htTools.put(KEY_TOOL_CUT, jbtnCut);
+               jbtnCopy = new JButtonNoFocus(new DefaultEditorKit.CopyAction());
+                       jbtnCopy.setIcon(getEkitIcon("Copy"));
+                       jbtnCopy.setText(null);
+                       jbtnCopy.setToolTipText(Translatrix.getTranslationString("Copy"));
+                       htTools.put(KEY_TOOL_COPY, jbtnCopy);
+               jbtnPaste = new JButtonNoFocus(new DefaultEditorKit.PasteAction());
+                       jbtnPaste.setIcon(getEkitIcon("Paste"));
+                       jbtnPaste.setText(null);
+                       jbtnPaste.setToolTipText(Translatrix.getTranslationString("Paste"));
+                       htTools.put(KEY_TOOL_PASTE, jbtnPaste);
+               jbtnBold = new JButtonNoFocus(actionFontBold);
+                       jbtnBold.setIcon(getEkitIcon("Bold"));
+                       jbtnBold.setText(null);
+                       jbtnBold.setToolTipText(Translatrix.getTranslationString("FontBold"));
+                       htTools.put(KEY_TOOL_BOLD, jbtnBold);
+               jbtnItalic = new JButtonNoFocus(actionFontItalic);
+                       jbtnItalic.setIcon(getEkitIcon("Italic"));
+                       jbtnItalic.setText(null);
+                       jbtnItalic.setToolTipText(Translatrix.getTranslationString("FontItalic"));
+                       htTools.put(KEY_TOOL_ITALIC, jbtnItalic);
+               jbtnUnderline = new JButtonNoFocus(actionFontUnderline);
+                       jbtnUnderline.setIcon(getEkitIcon("Underline"));
+                       jbtnUnderline.setText(null);
+                       jbtnUnderline.setToolTipText(Translatrix.getTranslationString("FontUnderline"));
+                       htTools.put(KEY_TOOL_UNDERLINE, jbtnUnderline);
+               jbtnStrike = new JButtonNoFocus(actionFontStrike);
+                       jbtnStrike.setIcon(getEkitIcon("Strike"));
+                       jbtnStrike.setText(null);
+                       jbtnStrike.setToolTipText(Translatrix.getTranslationString("FontStrike"));
+                       htTools.put(KEY_TOOL_STRIKE, jbtnStrike);
+               jbtnSuperscript = new JButtonNoFocus(actionFontSuperscript);
+                       jbtnSuperscript.setIcon(getEkitIcon("Super"));
+                       jbtnSuperscript.setText(null);
+                       jbtnSuperscript.setToolTipText(Translatrix.getTranslationString("FontSuperscript"));
+                       htTools.put(KEY_TOOL_SUPER, jbtnSuperscript);
+               jbtnSubscript = new JButtonNoFocus(actionFontSubscript);
+                       jbtnSubscript.setIcon(getEkitIcon("Sub"));
+                       jbtnSubscript.setText(null);
+                       jbtnSubscript.setToolTipText(Translatrix.getTranslationString("FontSubscript"));
+                       htTools.put(KEY_TOOL_SUB, jbtnSubscript);
+               jbtnUList = new JButtonNoFocus(actionListUnordered);
+                       jbtnUList.setIcon(getEkitIcon("UList"));
+                       jbtnUList.setText(null);
+                       jbtnUList.setToolTipText(Translatrix.getTranslationString("ListUnordered"));
+                       htTools.put(KEY_TOOL_ULIST, jbtnUList);
+               jbtnOList = new JButtonNoFocus(actionListOrdered);
+                       jbtnOList.setIcon(getEkitIcon("OList"));
+                       jbtnOList.setText(null);
+                       jbtnOList.setToolTipText(Translatrix.getTranslationString("ListOrdered"));
+                       htTools.put(KEY_TOOL_OLIST, jbtnOList);
+               jbtnClearFormat = new JButtonNoFocus(actionClearFormat);
+                       jbtnClearFormat.setIcon(getEkitIcon("ClearFormat"));
+                       jbtnClearFormat.setText(null);
+                       jbtnClearFormat.setToolTipText(Translatrix.getTranslationString("FormatClear"));
+                       htTools.put(KEY_TOOL_CLEAR, jbtnClearFormat);
+               jbtnAnchor = new JButtonNoFocus(actionInsertAnchor);
+                       jbtnAnchor.setIcon(getEkitIcon("Anchor"));
+                       jbtnAnchor.setText(null);
+                       jbtnAnchor.setToolTipText(Translatrix.getTranslationString("ToolAnchor"));
+                       htTools.put(KEY_TOOL_ANCHOR, jbtnAnchor);
+               jtbtnViewSource = new JToggleButtonNoFocus(getEkitIcon("Source"));
+                       jtbtnViewSource.setText(null);
+                       jtbtnViewSource.setToolTipText(Translatrix.getTranslationString("ViewSource"));
+                       jtbtnViewSource.setActionCommand("viewsource");
+                       jtbtnViewSource.addActionListener(this);
+                       jtbtnViewSource.setPreferredSize(jbtnAnchor.getPreferredSize());
+                       jtbtnViewSource.setMinimumSize(jbtnAnchor.getMinimumSize());
+                       jtbtnViewSource.setMaximumSize(jbtnAnchor.getMaximumSize());
+                       htTools.put(KEY_TOOL_SOURCE, jtbtnViewSource);
+               jcmbStyleSelector = new JComboBoxNoFocus();
+                       jcmbStyleSelector.setToolTipText(Translatrix.getTranslationString("PickCSSStyle"));
+                       jcmbStyleSelector.setAction(new StylesAction(jcmbStyleSelector));
+                       htTools.put(KEY_TOOL_STYLES, jcmbStyleSelector);
+
                /* Create the toolbar */
-               jToolBar = new JToolBar(JToolBar.HORIZONTAL);
-               jToolBar.setFloatable(false);
-               jbtnNewHTML     = new JButtonNoFocus(getEkitIcon("New"));  jbtnNewHTML.setToolTipText(Translatrix.getTranslationString("NewDocument"));   jbtnNewHTML.setActionCommand("newdoc");    jbtnNewHTML.addActionListener(this);  jToolBar.add(jbtnNewHTML);  htTools.put(KEY_TOOL_NEW, jbtnNewHTML);
-               jbtnOpenHTML    = new JButtonNoFocus(getEkitIcon("Open")); jbtnOpenHTML.setToolTipText(Translatrix.getTranslationString("OpenDocument")); jbtnOpenHTML.setActionCommand("openhtml"); jbtnOpenHTML.addActionListener(this); jToolBar.add(jbtnOpenHTML); htTools.put(KEY_TOOL_OPEN, jbtnOpenHTML);
-               jbtnSaveHTML    = new JButtonNoFocus(getEkitIcon("Save")); jbtnSaveHTML.setToolTipText(Translatrix.getTranslationString("SaveDocument")); jbtnSaveHTML.setActionCommand("saveas");   jbtnSaveHTML.addActionListener(this); jToolBar.add(jbtnSaveHTML); htTools.put(KEY_TOOL_SAVE, jbtnSaveHTML);
-               jToolBar.add(new JToolBar.Separator());
-               jbtnCut         = new JButtonNoFocus(new DefaultEditorKit.CutAction());   jbtnCut.setIcon(getEkitIcon("Cut"));     jbtnCut.setText(null);   jbtnCut.setToolTipText(Translatrix.getTranslationString("Cut"));     jToolBar.add(jbtnCut);   htTools.put(KEY_TOOL_CUT, jbtnCut);
-               jbtnCopy        = new JButtonNoFocus(new DefaultEditorKit.CopyAction());  jbtnCopy.setIcon(getEkitIcon("Copy"));   jbtnCopy.setText(null);  jbtnCopy.setToolTipText(Translatrix.getTranslationString("Copy"));   jToolBar.add(jbtnCopy);  htTools.put(KEY_TOOL_COPY, jbtnCopy);
-               jbtnPaste       = new JButtonNoFocus(new DefaultEditorKit.PasteAction()); jbtnPaste.setIcon(getEkitIcon("Paste")); jbtnPaste.setText(null); jbtnPaste.setToolTipText(Translatrix.getTranslationString("Paste")); jToolBar.add(jbtnPaste); htTools.put(KEY_TOOL_PASTE, jbtnPaste);
-               jToolBar.add(new JToolBar.Separator());
-               jbtnBold        = new JButtonNoFocus(actionFontBold);        jbtnBold.setIcon(getEkitIcon("Bold"));               jbtnBold.setText(null);        jbtnBold.setToolTipText(Translatrix.getTranslationString("FontBold"));                 jToolBar.add(jbtnBold);        htTools.put(KEY_TOOL_BOLD, jbtnBold);
-               jbtnItalic      = new JButtonNoFocus(actionFontItalic);      jbtnItalic.setIcon(getEkitIcon("Italic"));           jbtnItalic.setText(null);      jbtnItalic.setToolTipText(Translatrix.getTranslationString("FontItalic"));             jToolBar.add(jbtnItalic);      htTools.put(KEY_TOOL_ITALIC, jbtnItalic);
-               jbtnUnderline   = new JButtonNoFocus(actionFontUnderline);   jbtnUnderline.setIcon(getEkitIcon("Underline"));     jbtnUnderline.setText(null);   jbtnUnderline.setToolTipText(Translatrix.getTranslationString("FontUnderline"));       jToolBar.add(jbtnUnderline);   htTools.put(KEY_TOOL_UNDERLINE, jbtnUnderline);
-               jbtnStrike      = new JButtonNoFocus(actionFontStrike);      jbtnStrike.setIcon(getEkitIcon("Strike"));           jbtnStrike.setText(null);      jbtnStrike.setToolTipText(Translatrix.getTranslationString("FontStrike"));             jToolBar.add(jbtnStrike);      htTools.put(KEY_TOOL_STRIKE, jbtnStrike);
-               jbtnSuperscript = new JButtonNoFocus(actionFontSuperscript); jbtnSuperscript.setIcon(getEkitIcon("Super"));       jbtnSuperscript.setText(null); jbtnSuperscript.setToolTipText(Translatrix.getTranslationString("FontSuperscript")); jToolBar.add(jbtnSuperscript);   htTools.put(KEY_TOOL_SUPER, jbtnSuperscript);
-               jbtnSubscript   = new JButtonNoFocus(actionFontSubscript);   jbtnSubscript.setIcon(getEkitIcon("Sub"));           jbtnSubscript.setText(null);   jbtnSubscript.setToolTipText(Translatrix.getTranslationString("FontSubscript"));     jToolBar.add(jbtnSubscript);     htTools.put(KEY_TOOL_SUB, jbtnSubscript);
-               jbtnUList       = new JButtonNoFocus(actionListUnordered);   jbtnUList.setIcon(getEkitIcon("UList"));             jbtnUList.setText(null);       jbtnUList.setToolTipText(Translatrix.getTranslationString("ListUnordered"));           jToolBar.add(jbtnUList);       htTools.put(KEY_TOOL_ULIST, jbtnUList);
-               jbtnOList       = new JButtonNoFocus(actionListOrdered);     jbtnOList.setIcon(getEkitIcon("OList"));             jbtnOList.setText(null);       jbtnOList.setToolTipText(Translatrix.getTranslationString("ListOrdered"));             jToolBar.add(jbtnOList);       htTools.put(KEY_TOOL_OLIST, jbtnOList);
-               jbtnClearFormat = new JButtonNoFocus(actionClearFormat);     jbtnClearFormat.setIcon(getEkitIcon("ClearFormat")); jbtnClearFormat.setText(null); jbtnClearFormat.setToolTipText(Translatrix.getTranslationString("FormatClear"));       jToolBar.add(jbtnClearFormat); htTools.put(KEY_TOOL_CLEAR, jbtnClearFormat);
-               jToolBar.add(new JToolBar.Separator());
-               jbtnAnchor      = new JButtonNoFocus(actionInsertAnchor); jbtnAnchor.setIcon(getEkitIcon("Anchor")); jbtnAnchor.setText(null); jbtnAnchor.setToolTipText(Translatrix.getTranslationString("ToolAnchor")); jToolBar.add(jbtnAnchor); htTools.put(KEY_TOOL_ANCHOR, jbtnAnchor);
-               jToolBar.add(new JToolBar.Separator());
-               jtbtnViewSource = new JToggleButtonNoFocus(getEkitIcon("Source")); jtbtnViewSource.setText(null); jtbtnViewSource.setToolTipText(Translatrix.getTranslationString("ViewSource")); jtbtnViewSource.setActionCommand("viewsource"); jtbtnViewSource.addActionListener(this); jtbtnViewSource.setPreferredSize(jbtnAnchor.getPreferredSize()); jtbtnViewSource.setMinimumSize(jbtnAnchor.getMinimumSize()); jtbtnViewSource.setMaximumSize(jbtnAnchor.getMaximumSize()); jToolBar.add(jtbtnViewSource); htTools.put(KEY_TOOL_SOURCE, jtbtnViewSource);
-               jToolBar.add(new JToolBar.Separator());
-               jcmbStyleSelector = new JComboBoxNoFocus(); jToolBar.add(jcmbStyleSelector); jcmbStyleSelector.setAction(new StylesAction(jcmbStyleSelector)); htTools.put(KEY_TOOL_STYLES, jcmbStyleSelector);
+               if(multiBar)
+               {
+                       jToolBarMain = new JToolBar(JToolBar.HORIZONTAL);
+                       jToolBarMain.setFloatable(false);
+                       jToolBarMain.add((JButtonNoFocus)(htTools.get(KEY_TOOL_NEW)));
+                       jToolBarMain.add((JButtonNoFocus)(htTools.get(KEY_TOOL_OPEN)));
+                       jToolBarMain.add((JButtonNoFocus)(htTools.get(KEY_TOOL_SAVE)));
+                       jToolBarMain.add(new JToolBar.Separator());
+                       jToolBarMain.add((JButtonNoFocus)(htTools.get(KEY_TOOL_CUT)));
+                       jToolBarMain.add((JButtonNoFocus)(htTools.get(KEY_TOOL_COPY)));
+                       jToolBarMain.add((JButtonNoFocus)(htTools.get(KEY_TOOL_PASTE)));
+                       jToolBarMain.add(new JToolBar.Separator());
+                       jToolBarMain.add((JButtonNoFocus)(htTools.get(KEY_TOOL_CLEAR)));
+                       jToolBarMain.add(new JToolBar.Separator());
+                       jToolBarMain.add((JButtonNoFocus)(htTools.get(KEY_TOOL_ANCHOR)));
+                       jToolBarMain.add(new JToolBar.Separator());
+                       jToolBarMain.add((JToggleButtonNoFocus)(htTools.get(KEY_TOOL_SOURCE)));
+
+                       jToolBarFormat = new JToolBar(JToolBar.HORIZONTAL);
+                       jToolBarFormat.setFloatable(false);
+                       jToolBarFormat.add((JButtonNoFocus)(htTools.get(KEY_TOOL_BOLD)));
+                       jToolBarFormat.add((JButtonNoFocus)(htTools.get(KEY_TOOL_ITALIC)));
+                       jToolBarFormat.add((JButtonNoFocus)(htTools.get(KEY_TOOL_UNDERLINE)));
+                       jToolBarFormat.add(new JToolBar.Separator());
+                       jToolBarFormat.add((JButtonNoFocus)(htTools.get(KEY_TOOL_STRIKE)));
+                       jToolBarFormat.add((JButtonNoFocus)(htTools.get(KEY_TOOL_SUPER)));
+                       jToolBarFormat.add((JButtonNoFocus)(htTools.get(KEY_TOOL_SUB)));
+                       jToolBarFormat.add(new JToolBar.Separator());
+                       jToolBarFormat.add((JButtonNoFocus)(htTools.get(KEY_TOOL_ULIST)));
+                       jToolBarFormat.add((JButtonNoFocus)(htTools.get(KEY_TOOL_OLIST)));
+
+                       jToolBarStyles = new JToolBar(JToolBar.HORIZONTAL);
+                       jToolBarStyles.setFloatable(false);
+                       jToolBarStyles.add(new JLabel(Translatrix.getTranslationString("SelectorToolCSSStyles")));
+                       jToolBarStyles.add((JComboBoxNoFocus)(htTools.get(KEY_TOOL_STYLES)));
+
+                       // fix the weird size preference of toggle buttons
+                       jtbtnViewSource.setPreferredSize(jbtnAnchor.getPreferredSize());
+                       jtbtnViewSource.setMinimumSize(jbtnAnchor.getMinimumSize());
+                       jtbtnViewSource.setMaximumSize(jbtnAnchor.getMaximumSize());
+               }
+               else
+               {
+                       jToolBar = new JToolBar(JToolBar.HORIZONTAL);
+                       jToolBar.setFloatable(false);
+                       jToolBar.add((JButtonNoFocus)(htTools.get(KEY_TOOL_NEW)));
+                       jToolBar.add((JButtonNoFocus)(htTools.get(KEY_TOOL_OPEN)));
+                       jToolBar.add((JButtonNoFocus)(htTools.get(KEY_TOOL_SAVE)));
+                       jToolBar.add(new JToolBar.Separator());
+                       jToolBar.add((JButtonNoFocus)(htTools.get(KEY_TOOL_CUT)));
+                       jToolBar.add((JButtonNoFocus)(htTools.get(KEY_TOOL_COPY)));
+                       jToolBar.add((JButtonNoFocus)(htTools.get(KEY_TOOL_PASTE)));
+                       jToolBar.add(new JToolBar.Separator());
+                       jToolBar.add((JButtonNoFocus)(htTools.get(KEY_TOOL_BOLD)));
+                       jToolBar.add((JButtonNoFocus)(htTools.get(KEY_TOOL_ITALIC)));
+                       jToolBar.add((JButtonNoFocus)(htTools.get(KEY_TOOL_UNDERLINE)));
+                       jToolBar.add((JButtonNoFocus)(htTools.get(KEY_TOOL_STRIKE)));
+                       jToolBar.add((JButtonNoFocus)(htTools.get(KEY_TOOL_SUPER)));
+                       jToolBar.add((JButtonNoFocus)(htTools.get(KEY_TOOL_SUB)));
+                       jToolBar.add((JButtonNoFocus)(htTools.get(KEY_TOOL_ULIST)));
+                       jToolBar.add((JButtonNoFocus)(htTools.get(KEY_TOOL_OLIST)));
+                       jToolBar.add((JButtonNoFocus)(htTools.get(KEY_TOOL_CLEAR)));
+                       jToolBar.add(new JToolBar.Separator());
+                       jToolBar.add((JButtonNoFocus)(htTools.get(KEY_TOOL_ANCHOR)));
+                       jToolBar.add(new JToolBar.Separator());
+                       jToolBar.add((JToggleButtonNoFocus)(htTools.get(KEY_TOOL_SOURCE)));
+                       jToolBar.add(new JToolBar.Separator());
+                       jToolBar.add((JComboBoxNoFocus)(htTools.get(KEY_TOOL_STYLES)));
+
+                       // fix the weird size preference of toggle buttons
+                       jtbtnViewSource.setPreferredSize(jbtnAnchor.getPreferredSize());
+                       jtbtnViewSource.setMinimumSize(jbtnAnchor.getMinimumSize());
+                       jtbtnViewSource.setMaximumSize(jbtnAnchor.getMaximumSize());
+               }
 
                /* Create the scroll area for the text pane */
                JScrollPane jspViewport = new JScrollPane(jtpMain);
@@ -730,90 +947,151 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
                this.add(jspltDisplay, BorderLayout.CENTER);
        }
 
+       public EkitCore(String sDocument, String sStyleSheet, String sRawDocument, URL urlStyleSheet, boolean includeToolBar, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64, boolean debugMode, boolean hasSpellChecker, boolean multiBar, String baseurl)
+       {
+               this(sDocument, sStyleSheet, sRawDocument, (StyledDocument)null, urlStyleSheet, includeToolBar, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, debugMode, hasSpellChecker, multiBar, baseurl);
+       }
+       
+       public EkitCore(String sDocument, String sStyleSheet, String sRawDocument, URL urlStyleSheet, boolean includeToolBar, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64, boolean debugMode, boolean hasSpellChecker, boolean multiBar)
+       {
+               this(sDocument, sStyleSheet, sRawDocument, (StyledDocument)null, urlStyleSheet, includeToolBar, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, debugMode, hasSpellChecker, multiBar, "");
+       }
+
+       public EkitCore(String sDocument, String sStyleSheet, String sRawDocument, URL urlStyleSheet, boolean includeToolBar, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64, boolean debugMode, String baseurl)
+       {
+               this(sDocument, sStyleSheet, sRawDocument, (StyledDocument)null, urlStyleSheet, includeToolBar, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, debugMode, false, false, baseurl);
+       }
+
+       public EkitCore(String sDocument, String sStyleSheet, String sRawDocument, URL urlStyleSheet, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64, boolean debugMode, boolean hasSpellChecker, String baseurl)
+       {
+               this(sDocument, sStyleSheet, sRawDocument, (StyledDocument)null, urlStyleSheet, true, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, debugMode, hasSpellChecker, false, baseurl);
+       }
+
+       public EkitCore(String sDocument, String sStyleSheet, String sRawDocument, URL urlStyleSheet, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64, boolean debugMode, String baseurl)
+       {
+               this(sDocument, sStyleSheet, sRawDocument, (StyledDocument)null, urlStyleSheet, true, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, debugMode, false, false, baseurl);
+       }
+
        /** Common Constructor
          * @param sDocument         [String]  A text or HTML document to load in the editor upon startup.
          * @param sStyleSheet       [String]  A CSS stylesheet to load in the editor upon startup.
+         * @param includeToolBar    [boolean] Specifies whether the app should include the toolbar(s).
          * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
          * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
          * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
          * @param sLanguage         [String]  The language portion of the Internationalization Locale to run Ekit in.
          * @param sCountry          [String]  The country portion of the Internationalization Locale to run Ekit in.
          */
-       public EkitCore(String sDocument, String sStyleSheet, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64)
+       public EkitCore(String sDocument, String sStyleSheet, boolean includeToolBar, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64, String baseurl)
        {
-               this(sDocument, sStyleSheet, null, null, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false,"");
+               this(sDocument, sStyleSheet, null, null, includeToolBar, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false, baseurl);
+       }
+
+       /** StyledDocument Constructor With Spellchecker Specifier
+         * @param sdocSource        [StyledDocument] The optional StyledDocument to use as the source Document.
+         * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
+         * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
+         * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
+         * @param sLanguage         [String]  The language portion of the Internationalization Locale to run Ekit in.
+         * @param sCountry          [String]  The country portion of the Internationalization Locale to run Ekit in.
+         * @param debugMode         [boolean] Specifies whether to show the Debug menu or not.
+         * @param hasSpellChecker   [boolean] Specifies whether or not this uses the SpellChecker module
+         */
+       public EkitCore(StyledDocument sdocSource, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean debugMode, boolean hasSpellChecker, String baseurl)
+       {
+               this(null, null, null, sdocSource, null, true, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, false, debugMode, hasSpellChecker, false, baseurl);
+       }
+
+       /** StyledDocument Constructor
+         * @param sdocSource        [StyledDocument] The optional StyledDocument to use as the source Document.
+         * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
+         * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
+         * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
+         * @param sLanguage         [String]  The language portion of the Internationalization Locale to run Ekit in.
+         * @param sCountry          [String]  The country portion of the Internationalization Locale to run Ekit in.
+         * @param debugMode         [boolean] Specifies whether to show the Debug menu or not.
+         */
+       public EkitCore(StyledDocument sdocSource, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean debugMode, String baseurl)
+       {
+               this(null, null, null, sdocSource, null, true, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, false, debugMode, false, false, baseurl);
        }
 
        /** Default Language Constructor
          * @param sDocument         [String]  A text or HTML document to load in the editor upon startup.
          * @param sStyleSheet       [String]  A CSS stylesheet to load in the editor upon startup.
+         * @param includeToolBar    [boolean] Specifies whether the app should include the toolbar(s).
          * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
          * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
          * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
          */
-       public EkitCore(String sDocument, String sStyleSheet, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, boolean base64)
+       public EkitCore(String sDocument, String sStyleSheet, boolean includeToolBar, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, boolean base64, String baseurl)
        {
-               this(sDocument, sStyleSheet, null, null, showViewSource, showMenuIcons, editModeExclusive, null, null, base64, false, "");
+               this(sDocument, sStyleSheet, null, null, includeToolBar, showViewSource, showMenuIcons, editModeExclusive, null, null, base64, false, baseurl);
        }
 
        /** Raw/Base64 Document & Style Sheet URL Constructor (Ideal for EkitApplet)
          * @param sRawDocument      [String]  A document encoded as a String to load in the editor upon startup.
          * @param sRawDocument      [String]  A document encoded as a String to load in the editor upon startup.
+         * @param includeToolBar    [boolean] Specifies whether the app should include the toolbar(s).
          * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
          * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
          * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
          * @param sLanguage         [String]  The language portion of the Internationalization Locale to run Ekit in.
          * @param sCountry          [String]  The country portion of the Internationalization Locale to run Ekit in.
          */
-       public EkitCore(String sRawDocument, URL urlStyleSheet, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64, String baseurl)
+       public EkitCore(String sRawDocument, URL urlStyleSheet, boolean includeToolBar, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64, boolean hasSpellChecker, boolean multiBar, String baseurl)
        {
-               this(null, null, sRawDocument, urlStyleSheet, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false, baseurl);
+               this(null, null, sRawDocument, urlStyleSheet, includeToolBar, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false, hasSpellChecker, multiBar, baseurl);
        }
 
        /** Document Constructor
          * @param sRawDocument      [String]  A document encoded as a String to load in the editor upon startup.
+         * @param includeToolBar    [boolean] Specifies whether the app should include the toolbar(s).
          * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
          * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
          * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
          * @param sLanguage         [String]  The language portion of the Internationalization Locale to run Ekit in.
          * @param sCountry          [String]  The country portion of the Internationalization Locale to run Ekit in.
          */
-       public EkitCore(String sRawDocument, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64)
+       public EkitCore(String sRawDocument, boolean includeToolBar, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64, String baseurl)
        {
-               this(null, null, sRawDocument, null, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false,"");
+               this(null, null, sRawDocument, null, includeToolBar, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false, baseurl);
        }
 
        /** Default Language & Document Constructor
          * @param sRawDocument      [String]  A document encoded as a String to load in the editor upon startup.
+         * @param includeToolBar    [boolean] Specifies whether the app should include the toolbar(s).
          * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
          * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
          * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
          */
-       public EkitCore(String sRawDocument, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, boolean base64)
+       public EkitCore(String sRawDocument, boolean includeToolBar, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, boolean base64, String baseurl)
        {
-               this(null, null, sRawDocument, null, showViewSource, showMenuIcons, editModeExclusive, null, null, base64, false,"");
+               this(null, null, sRawDocument, null, includeToolBar, showViewSource, showMenuIcons, editModeExclusive, null, null, base64, false, baseurl);
        }
 
        /** Flags & Language Constructor
+         * @param includeToolBar    [boolean] Specifies whether the app should include the toolbar(s).
          * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
          * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
          * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
          * @param sLanguage         [String]  The language portion of the Internationalization Locale to run Ekit in.
          * @param sCountry          [String]  The country portion of the Internationalization Locale to run Ekit in.
          */
-       public EkitCore(boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry)
+       public EkitCore(boolean includeToolBar, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry)
        {
-               this(null, null, null, null, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, false, false,"");
+               this(null, null, null, null, includeToolBar, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, false, false, "");
        }
 
        /** Flags Constructor
+         * @param includeToolBar    [boolean] Specifies whether the app should include the toolbar(s).
          * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
          * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
          * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
          */
-       public EkitCore(boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive)
+       public EkitCore(boolean includeToolBar, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive)
        {
-               this(null, null, null, null, showViewSource, showMenuIcons, editModeExclusive, null, null, false, false,"");
+               this(null, null, null, null, includeToolBar, showViewSource, showMenuIcons, editModeExclusive, null, null, false, false, "");
        }
 
        /** Language & Debug Constructor
@@ -823,7 +1101,7 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
          */
        public EkitCore(String sLanguage, String sCountry, boolean debugMode)
        {
-               this(null, null, null, null, false, true, true, sLanguage, sCountry, false, debugMode,"");
+               this(null, null, null, null, true, false, true, true, sLanguage, sCountry, false, debugMode, "");
        }
 
        /** Language Constructor
@@ -832,7 +1110,7 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
          */
        public EkitCore(String sLanguage, String sCountry)
        {
-               this(null, null, null, null, false, true, true, sLanguage, sCountry, false, false,"");
+               this(null, null, null, null, true, false, true, true, sLanguage, sCountry, false, false, "");
        }
 
        /** Debug Constructor
@@ -840,14 +1118,14 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
          */
        public EkitCore(boolean debugMode)
        {
-               this(null, null, null, null, false, true, true, null, null, false, debugMode,"");
+               this(null, null, null, null, true, false, true, true, null, null, false, debugMode, "");
        }
 
        /** Empty Constructor
          */
        public EkitCore()
        {
-               this(null, null, null, null, false, true, true, null, null, false, false,"");
+               this(null, null, null, null, true, false, true, true, null, null, false, false, "");
        }
 
        /* ActionListener method */
@@ -984,6 +1262,18 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
                        {
                                jToolBar.setVisible(jcbmiViewToolbar.isSelected());
                        }
+                       else if(command.equals("toggletoolbarmain"))
+                       {
+                               jToolBarMain.setVisible(jcbmiViewToolbarMain.isSelected());
+                       }
+                       else if(command.equals("toggletoolbarformat"))
+                       {
+                               jToolBarFormat.setVisible(jcbmiViewToolbarFormat.isSelected());
+                       }
+                       else if(command.equals("toggletoolbarstyles"))
+                       {
+                               jToolBarStyles.setVisible(jcbmiViewToolbarStyles.isSelected());
+                       }
                        else if(command.equals("viewsource"))
                        {
                                toggleSourceWindow();
@@ -1030,6 +1320,10 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
                        {
                                insertServerImage();
                        }
+                       else if(command.equals("insertsymbol"))
+                       {
+                               insertSymbol();
+                       }
                        else if(command.equals("insertnbsp"))
                        {
                                insertNonbreakingSpace();
@@ -1123,6 +1417,10 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
                        {
                                SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("About"), true, Translatrix.getTranslationString("AboutMessage"), SimpleInfoDialog.INFO);
                        }
+                       else if(command.equals("spellcheck"))
+                       {
+                               checkDocumentSpelling(jtpMain.getDocument());
+                       }
                }
                catch(IOException ioe)
                {
@@ -1334,7 +1632,7 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
        {
                if(!exclusiveEdit)
                {
-                       if(jspSource.isShowing())
+                       if(isSourceWindowActive())
                        {
                                if(de.getDocument() instanceof HTMLDocument || de.getDocument() instanceof ExtendedHTMLDocument)
                                {
@@ -1360,6 +1658,7 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
                jtpMain.setDocument(htmlDoc);
                jtpMain.getDocument().addUndoableEditListener(new CustomUndoableEditListener());
                jtpMain.getDocument().addDocumentListener(this);
+               jtpMain.setCaretPosition(0);
                purgeUndos();
                registerDocumentStyles();
        }
@@ -1674,6 +1973,22 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
                jtpMain.setCaretPosition(caretPos + 1);
        }
 
+       /** Method for inserting a symbol
+         */
+       private void insertSymbol()
+       throws IOException, BadLocationException, RuntimeException
+       {
+               int caretPos = jtpMain.getCaretPosition();
+               SymbolDialog symbolInput = new SymbolDialog(this, Translatrix.getTranslationString("SymbolDialogTitle"), true);
+               String symbol = symbolInput.getInputText();
+               symbolInput.dispose();
+               if(symbol != null)
+               {
+                       htmlDoc.insertString(caretPos, symbol, jtpMain.getInputAttributes());
+                       jtpMain.setCaretPosition(caretPos + 1);
+               }
+       }
+
        /** Method for inserting a non-breaking space (&nbsp;)
          */
        private void insertNonbreakingSpace()
@@ -1785,10 +2100,10 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
        private void doSearch(String searchFindTerm, String searchReplaceTerm, boolean bIsFindReplace, boolean bCaseSensitive, boolean bStartAtTop)
        {
                boolean bReplaceAll = false;
-               JTextPane searchPane = jtpMain;
+               JTextComponent searchPane = (JTextComponent)jtpMain;
                if(jspSource.isShowing() || jtpSource.hasFocus())
                {
-                       searchPane = jtpSource;
+                       searchPane = (JTextComponent)jtpSource;
                }
                if(searchFindTerm == null || (bIsFindReplace && searchReplaceTerm == null))
                {
@@ -1844,14 +2159,14 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
          */
        private int findText(String findTerm, String replaceTerm, boolean bCaseSenstive, int iOffset)
        {
-               JTextPane jtpFindSource;
-               if(jspSource.isShowing() || jtpSource.hasFocus())
+               JTextComponent jtpFindSource;
+               if(isSourceWindowActive() || jtpSource.hasFocus())
                {
-                       jtpFindSource = jtpSource;
+                       jtpFindSource = (JTextComponent)jtpSource;
                }
                else
                {
-                       jtpFindSource = jtpMain;
+                       jtpFindSource = (JTextComponent)jtpMain;
                }
                int searchPlace = -1;
                try
@@ -1901,10 +2216,11 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
        {
                if(whatImage == null)
                {
-                       whatImage = getImageFromChooser(".", extsIMG, Translatrix.getTranslationString("FiletypeIMG"));
+                       whatImage = getImageFromChooser(imageChooserStartDir, extsIMG, Translatrix.getTranslationString("FiletypeIMG"));
                }
                if(whatImage != null)
                {
+                       imageChooserStartDir = whatImage.getParent().toString();
                        int caretPos = jtpMain.getCaretPosition();
                        htmlKit.insertHTML(htmlDoc, caretPos, "<IMG SRC=\"" + whatImage + "\">", 0, 0, HTML.Tag.IMG);
                        jtpMain.setCaretPosition(caretPos + 1);
@@ -1986,6 +2302,10 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
                return selectedFile;
        }
 
+       /** Empty spell check method, overwritten by spell checker extension class
+         */
+       public void checkDocumentSpelling(Document doc) { ; }
+
        /** Method for saving text as a complete HTML document
          */
        private void writeOut(HTMLDocument doc, File whatFile)
@@ -2102,6 +2422,34 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
                refreshOnUpdate();
        }
 
+       /** Method for loading HTML document
+         */
+       public void loadDocument(File whatFile)
+       throws IOException, BadLocationException
+       {
+               try
+               {
+                       loadDocument(whatFile, null);
+               }
+               catch(ChangedCharSetException ccse)
+               {
+                       String charsetType = ccse.getCharSetSpec().toLowerCase();
+                       int pos = charsetType.indexOf("charset");
+                       if(pos == -1)
+                       {
+                               throw ccse;
+                       }
+                       while(pos < charsetType.length() && charsetType.charAt(pos) != '=')
+                       {
+                               pos++;
+                       }
+                       pos++; // Places file cursor past the equals sign (=)
+                       String whatEncoding = charsetType.substring(pos).trim();
+                       loadDocument(whatFile, whatEncoding);
+               }
+               refreshOnUpdate();
+       }
+
        /** Method for loading HTML document into the app, including document encoding setting
          */
        private void loadDocument(File whatFile, String whatEncoding)
@@ -2109,6 +2457,7 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
        {
                Reader r = null;
                htmlDoc = (ExtendedHTMLDocument)(htmlKit.createDefaultDocument());
+               htmlDoc.putProperty("com.hexidec.ekit.docsource", whatFile.toString());
                try
                {
                        if(whatEncoding == null)
@@ -2350,7 +2699,7 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
 
        /** Convenience method for obtaining the Source JTextPane
          */
-       public JTextPane getSourcePane()
+       public JTextArea getSourcePane()
        {
                return jtpSource;
        }
@@ -2396,45 +2745,116 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
          */
        public JToolBar getToolBar(boolean isShowing)
        {
-               jcbmiViewToolbar.setState(isShowing);
-               return jToolBar;
+               if(jToolBar != null)
+               {
+                       jcbmiViewToolbar.setState(isShowing);
+                       return jToolBar;
+               }
+               return (JToolBar)null;
        }
 
-       /** Convenience method for obtaining the pre-generated toolbar
+       /** Convenience method for obtaining the pre-generated main toolbar
+         */
+       public JToolBar getToolBarMain(boolean isShowing)
+       {
+               if(jToolBarMain != null)
+               {
+                       jcbmiViewToolbarMain.setState(isShowing);
+                       return jToolBarMain;
+               }
+               return (JToolBar)null;
+       }
+
+       /** Convenience method for obtaining the pre-generated main toolbar
          */
-       public JToolBar getCustomToolBar(Vector vcTools, boolean isShowing)
+       public JToolBar getToolBarFormat(boolean isShowing)
        {
-               jcbmiViewToolbar.setState(isShowing);
-               jToolBar = new JToolBar(JToolBar.HORIZONTAL);
-               jToolBar.setFloatable(false);
+               if(jToolBarFormat != null)
+               {
+                       jcbmiViewToolbarFormat.setState(isShowing);
+                       return jToolBarFormat;
+               }
+               return (JToolBar)null;
+       }
+
+       /** Convenience method for obtaining the pre-generated main toolbar
+         */
+       public JToolBar getToolBarStyles(boolean isShowing)
+       {
+               if(jToolBarStyles != null)
+               {
+                       jcbmiViewToolbarStyles.setState(isShowing);
+                       return jToolBarStyles;
+               }
+               return (JToolBar)null;
+       }
+
+       /** Convenience method for obtaining a custom toolbar
+         */
+       public JToolBar customizeToolBar(int whichToolBar, Vector vcTools, boolean isShowing)
+       {
+               JToolBar jToolBarX = new JToolBar(JToolBar.HORIZONTAL);
+               jToolBarX.setFloatable(false);
+/*
+               jToolBarX.setMargin(new Insets(2, 2, 2, 2));
+               jToolBarX.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
+               jToolBarX.setBorderPainted(true);
+*/
                for(int i = 0; i < vcTools.size(); i++)
                {
                        String toolToAdd = ((String)(vcTools.elementAt(i))).toLowerCase();
                        if(toolToAdd.equals(KEY_TOOL_SEP))
                        {
-                               jToolBar.add(new JToolBar.Separator());
+                               jToolBarX.add(new JToolBar.Separator());
                        }
                        else if(htTools.containsKey(toolToAdd))
                        {
                                if(htTools.get(toolToAdd) instanceof JButtonNoFocus)
                                {
-                                       jToolBar.add((JButtonNoFocus)(htTools.get(toolToAdd)));
+                                       jToolBarX.add((JButtonNoFocus)(htTools.get(toolToAdd)));
                                }
                                else if(htTools.get(toolToAdd) instanceof JToggleButtonNoFocus)
                                {
-                                       jToolBar.add((JToggleButtonNoFocus)(htTools.get(toolToAdd)));
+                                       jToolBarX.add((JToggleButtonNoFocus)(htTools.get(toolToAdd)));
                                }
                                else if(htTools.get(toolToAdd) instanceof JComboBoxNoFocus)
                                {
-                                       jToolBar.add((JComboBoxNoFocus)(htTools.get(toolToAdd)));
+                                       jToolBarX.add((JComboBoxNoFocus)(htTools.get(toolToAdd)));
                                }
                                else
                                {
-                                       jToolBar.add((JComponent)(htTools.get(toolToAdd)));
+                                       jToolBarX.add((JComponent)(htTools.get(toolToAdd)));
                                }
                        }
                }
-               return jToolBar;
+               if(whichToolBar == TOOLBAR_MAIN)
+               {
+                       jToolBarMain = jToolBarX;
+                       jToolBarMain.setVisible(isShowing);
+                       jcbmiViewToolbarMain.setSelected(isShowing);
+                       return jToolBarMain;
+               }
+               else if(whichToolBar == TOOLBAR_FORMAT)
+               {
+                       jToolBarFormat = jToolBarX;
+                       jToolBarFormat.setVisible(isShowing);
+                       jcbmiViewToolbarFormat.setSelected(isShowing);
+                       return jToolBarFormat;
+               }
+               else if(whichToolBar == TOOLBAR_STYLES)
+               {
+                       jToolBarStyles = jToolBarX;
+                       jToolBarStyles.setVisible(isShowing);
+                       jcbmiViewToolbarStyles.setSelected(isShowing);
+                       return jToolBarStyles;
+               }
+               else
+               {
+                       jToolBarMain = jToolBarX;
+                       jToolBarMain.setVisible(isShowing);
+                       jcbmiViewToolbarMain.setSelected(isShowing);
+                       return jToolBarMain;
+               }
        }
 
        /** Convenience method for obtaining the current file handle
@@ -2455,7 +2875,14 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
          */
        public String getDocumentText()
        {
-               return jtpMain.getText();
+               if(isSourceWindowActive())
+               {
+                       return jtpSource.getText();
+               }
+               else
+               {
+                       return jtpMain.getText();
+               }
        }
 
        /** Convenience method for obtaining the document text
@@ -2496,7 +2923,17 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
                jtpMain.setText(sText);
                ((HTMLEditorKit)(jtpMain.getEditorKit())).setDefaultCursor(new Cursor(Cursor.TEXT_CURSOR));
                jtpSource.setText(jtpMain.getText());
-               ((HTMLEditorKit)(jtpSource.getEditorKit())).setDefaultCursor(new Cursor(Cursor.TEXT_CURSOR));
+       }
+
+       /** Convenience method for setting the source document
+         */
+       public void setSourceDocument(StyledDocument sDoc)
+       {
+               jtpSource.getDocument().removeDocumentListener(this);
+               jtpSource.setDocument(sDoc);
+               jtpSource.getDocument().addDocumentListener(this);
+               jtpMain.setText(jtpSource.getText());
+               ((HTMLEditorKit)(jtpMain.getEditorKit())).setDefaultCursor(new Cursor(Cursor.TEXT_CURSOR));
        }
 
        /** Convenience method for obtaining the document text
@@ -2551,11 +2988,18 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
                e.printStackTrace(System.err);
        }
 
-       /** Convenience method for toggling source window visibility
+       /** Convenience method for determining if the source window is active
+         */
+       private boolean isSourceWindowActive()
+       {
+               return (jspSource == jspltDisplay.getRightComponent());
+       }
+
+       /** Method for toggling source window visibility
          */
        private void toggleSourceWindow()
        {
-               if(!(jspSource.isShowing()))
+               if(!(isSourceWindowActive()))
                {
                        jtpSource.setText(jtpMain.getText());
                        jspltDisplay.setRightComponent(jspSource);
@@ -2569,6 +3013,7 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
                                jspltDisplay.setDividerLocation(iSplitPos);
                                jspltDisplay.setEnabled(true);
                        }
+                       jtpSource.requestFocus();
                }
                else
                {
@@ -2578,8 +3023,8 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc
                        jtpMain.requestFocus();
                }
                this.validate();
-               jcbmiViewSource.setSelected(jspSource.isShowing());
-               jtbtnViewSource.setSelected(jspSource.isShowing());
+               jcbmiViewSource.setSelected(isSourceWindowActive());
+               jtbtnViewSource.setSelected(isSourceWindowActive());
        }
 
        /** Searches the specified element for CLASS attribute setting
diff --git a/ekit/com/hexidec/ekit/EkitCore_Basic.java b/ekit/com/hexidec/ekit/EkitCore_Basic.java
deleted file mode 100644 (file)
index ef23e15..0000000
+++ /dev/null
@@ -1,2836 +0,0 @@
-/*
-GNU Lesser General Public License
-
-EkitCore - Base Java Swing HTML Editor & Viewer Class (Basic Version)
-Copyright (C) 2000-2003 Howard Kistler
-
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public
-License along with this library; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
-package com.hexidec.ekit;
-
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Cursor;
-import java.awt.Dimension;
-import java.awt.Frame;
-import java.awt.Graphics;
-import java.awt.Image;
-import java.awt.Insets;
-import java.awt.Toolkit;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Reader;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.MalformedURLException;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.Vector;
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.Icon;
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JCheckBoxMenuItem;
-import javax.swing.JComboBox;
-import javax.swing.JComponent;
-import javax.swing.JDialog;
-import javax.swing.JEditorPane;
-import javax.swing.JFileChooser;
-import javax.swing.JFrame;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JSplitPane;
-import javax.swing.JTextField;
-import javax.swing.JTextPane;
-import javax.swing.JToggleButton;
-import javax.swing.JToolBar;
-import javax.swing.KeyStroke;
-import javax.swing.event.CaretEvent;
-import javax.swing.event.CaretListener;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-import javax.swing.event.UndoableEditEvent;
-import javax.swing.event.UndoableEditListener;
-import javax.swing.filechooser.FileFilter;
-import javax.swing.text.AttributeSet;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.ChangedCharSetException;
-import javax.swing.text.DefaultEditorKit;
-import javax.swing.text.DefaultStyledDocument;
-import javax.swing.text.Document;
-import javax.swing.text.Element;
-import javax.swing.text.PlainDocument;
-import javax.swing.text.Position;
-import javax.swing.text.Style;
-import javax.swing.text.StyleConstants;
-import javax.swing.text.StyledDocument;
-import javax.swing.text.StyledEditorKit;
-import javax.swing.text.StyledEditorKit.FontSizeAction;
-import javax.swing.text.html.HTML;
-import javax.swing.text.html.HTMLDocument;
-import javax.swing.text.html.HTMLEditorKit;
-import javax.swing.text.html.StyleSheet;
-import javax.swing.text.rtf.RTFEditorKit;
-import javax.swing.undo.UndoManager;
-import javax.swing.undo.CannotUndoException;
-
-import com.hexidec.ekit.action.*;
-import com.hexidec.ekit.component.*;
-import com.hexidec.util.Base64Codec;
-import com.hexidec.util.Translatrix;
-
-/** EkitCore
-  * Main application class for editing and saving HTML in a Java text component
-  *
-  * @author Howard Kistler
-  * @version 0.9g
-  *
-  * REQUIREMENTS
-  * Java 2 (JDK 1.3 or 1.4)
-  * Swing Library
-  */
-
-public class EkitCore extends JPanel implements ActionListener, KeyListener, DocumentListener
-{
-       /* Components */
-       private JSplitPane jspltDisplay;
-       private JTextPane jtpMain;
-       private ExtendedHTMLEditorKit htmlKit;
-       private ExtendedHTMLDocument htmlDoc;
-       private StyleSheet styleSheet;
-       private JTextPane jtpSource;
-       private JScrollPane jspSource;
-       private JToolBar jToolBar;
-
-       private JCheckBoxMenuItem jcbmiViewToolbar;
-       private JCheckBoxMenuItem jcbmiViewSource;
-
-       private JButtonNoFocus jbtnNewHTML;
-       private JButtonNoFocus jbtnOpenHTML;
-       private JButtonNoFocus jbtnSaveHTML;
-       private JButtonNoFocus jbtnCut;
-       private JButtonNoFocus jbtnCopy;
-       private JButtonNoFocus jbtnPaste;
-       private JButtonNoFocus jbtnBold;
-       private JButtonNoFocus jbtnItalic;
-       private JButtonNoFocus jbtnUnderline;
-       private JButtonNoFocus jbtnStrike;
-       private JButtonNoFocus jbtnSuperscript;
-       private JButtonNoFocus jbtnSubscript;
-       private JButtonNoFocus jbtnUList;
-       private JButtonNoFocus jbtnOList;
-       private JButtonNoFocus jbtnClearFormat;
-       private JButtonNoFocus jbtnAnchor;
-       private JToggleButtonNoFocus jtbtnViewSource;
-       private JComboBoxNoFocus jcmbStyleSelector;
-
-       private Frame frameHandler;
-
-       private HTMLUtilities htmlUtilities = new HTMLUtilities(this);
-
-       /* Actions */
-       private StyledEditorKit.BoldAction actionFontBold;
-       private StyledEditorKit.ItalicAction actionFontItalic;
-       private StyledEditorKit.UnderlineAction actionFontUnderline;
-       private FormatAction actionFontStrike;
-       private FormatAction actionFontSuperscript;
-       private FormatAction actionFontSubscript;
-       private ListAutomationAction actionListUnordered;
-       private ListAutomationAction actionListOrdered;
-       private CustomAction actionSelectFont;
-       private CustomAction actionClearFormat;
-       private CustomAction actionInsertAnchor;
-
-       protected UndoManager undoMngr;
-       protected UndoAction undoAction;
-       protected RedoAction redoAction;
-
-       /* Menus */
-       private JMenuBar jMenuBar;
-       private JMenu jMenuFile;
-       private JMenu jMenuEdit;
-       private JMenu jMenuView;
-       private JMenu jMenuFont;
-       private JMenu jMenuFormat;
-       private JMenu jMenuInsert;
-       private JMenu jMenuTable;
-       private JMenu jMenuForms;
-       private JMenu jMenuSearch;
-       private JMenu jMenuHelp;
-       private JMenu jMenuDebug;
-
-       /* Constants */
-       // Menu Keys
-       public static final String KEY_MENU_FILE   = "file";
-       public static final String KEY_MENU_EDIT   = "edit";
-       public static final String KEY_MENU_VIEW   = "view";
-       public static final String KEY_MENU_FONT   = "font";
-       public static final String KEY_MENU_FORMAT = "format";
-       public static final String KEY_MENU_INSERT = "insert";
-       public static final String KEY_MENU_TABLE  = "table";
-       public static final String KEY_MENU_FORMS  = "forms";
-       public static final String KEY_MENU_SEARCH = "search";
-       public static final String KEY_MENU_TOOLS  = "tools";
-       public static final String KEY_MENU_HELP   = "help";
-       public static final String KEY_MENU_DEBUG  = "debug";
-
-       // Tool Keys
-       public static final String KEY_TOOL_SEP       = "separator";
-       public static final String KEY_TOOL_NEW       = "new";
-       public static final String KEY_TOOL_OPEN      = "open";
-       public static final String KEY_TOOL_SAVE      = "save";
-       public static final String KEY_TOOL_CUT       = "cut";
-       public static final String KEY_TOOL_COPY      = "copy";
-       public static final String KEY_TOOL_PASTE     = "paste";
-       public static final String KEY_TOOL_BOLD      = "bold";
-       public static final String KEY_TOOL_ITALIC    = "italic";
-       public static final String KEY_TOOL_UNDERLINE = "underline";
-       public static final String KEY_TOOL_STRIKE    = "strike";
-       public static final String KEY_TOOL_SUPER     = "superscript";
-       public static final String KEY_TOOL_SUB       = "subscript";
-       public static final String KEY_TOOL_ULIST     = "ulist";
-       public static final String KEY_TOOL_OLIST     = "olist";
-       public static final String KEY_TOOL_CLEAR     = "clearformats";
-       public static final String KEY_TOOL_ANCHOR    = "anchor";
-       public static final String KEY_TOOL_SOURCE    = "viewsource";
-       public static final String KEY_TOOL_STYLES    = "styleselect";
-
-       // Menu & Tool Key Arrays
-       private static Hashtable htMenus = new Hashtable();
-       private static Hashtable htTools = new Hashtable();
-
-       private final String appName = "Ekit";
-       private final String menuDialog = "..."; /* text to append to a MenuItem label when menu item opens a dialog */
-
-       private final boolean useFormIndicator = true; /* Creates a highlighted background on a new FORM so that it may be more easily edited */
-       private final String clrFormIndicator = "#cccccc";
-
-       // System Clipboard Settings
-       private java.awt.datatransfer.Clipboard sysClipboard;
-       private SecurityManager secManager;
-
-       /* Variables */
-       private int iSplitPos = 0;
-
-       private boolean exclusiveEdit = true;
-
-       private String lastSearchFindTerm     = null;
-       private String lastSearchReplaceTerm  = null;
-       private boolean lastSearchCaseSetting = false;
-       private boolean lastSearchTopSetting  = false;
-
-       private File currentFile = null;
-
-       private int indent = 0;
-       private final int indentStep = 4;
-
-       // File extensions for MutableFilter
-       private final String[] extsHTML = { "html", "htm", "shtml" };
-       private final String[] extsCSS  = { "css" };
-       private final String[] extsIMG  = { "gif", "jpg", "jpeg", "png" };
-       private final String[] extsRTF  = { "rtf" };
-       private final String[] extsB64  = { "b64" };
-       private final String[] extsSer  = { "ser" };
-
-       /* Servlet Settings */
-       private String ServletURL = null;
-       private String TreePilotSystemID = "";
-       private String ImageDir = "";
-       private static ResourceBundle TreePilotProperties;
-
-       /** Master Constructor
-         * @param sDocument         [String]  A text or HTML document to load in the editor upon startup.
-         * @param sStyleSheet       [String]  A CSS stylesheet to load in the editor upon startup.
-         * @param sRawDocument      [String]  A document encoded as a String to load in the editor upon startup.
-         * @param urlStyleSheet     [URL]     A URL reference to the CSS style sheet.
-         * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
-         * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
-         * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
-         * @param sLanguage         [String]  The language portion of the Internationalization Locale to run Ekit in.
-         * @param sCountry          [String]  The country portion of the Internationalization Locale to run Ekit in.
-         * @param base64            [boolean] Specifies whether the raw document is Base64 encoded or not.
-         * @param debugMode         [boolean] Specifies whether to show the Debug menu or not.
-         */
-       public EkitCore(String sDocument, String sStyleSheet, String sRawDocument, URL urlStyleSheet, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64, boolean debugMode)
-       {
-               super();
-
-               exclusiveEdit = editModeExclusive;
-
-               frameHandler = new Frame();
-
-               // Determine if system clipboard is available
-               secManager = System.getSecurityManager();
-               if(secManager != null)
-               {
-                       try
-                       {
-                               secManager.checkSystemClipboardAccess();
-                               sysClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
-                       }
-                       catch (SecurityException se)
-                       {
-                               sysClipboard = null;
-                       }
-               }
-
-               /* Localize for language */
-               Translatrix.setBundleName("com.hexidec.ekit.LanguageResources");
-               Locale baseLocale = (Locale)null;
-               if(sLanguage != null && sCountry != null)
-               {
-                       baseLocale = new Locale(sLanguage, sCountry);
-               }
-               Translatrix.setLocale(baseLocale);
-
-               /* Load TreePilot properties */
-               try
-               {
-                       TreePilotProperties = ResourceBundle.getBundle("com.hexidec.ekit.TreePilot");
-               }
-               catch(MissingResourceException mre)
-               {
-                       logException("MissingResourceException while loading treepilot file", mre);
-               }
-
-               /* Create the editor kit, document, and stylesheet */
-               jtpMain = new JTextPane();
-               htmlKit = new ExtendedHTMLEditorKit();
-               htmlDoc = (ExtendedHTMLDocument)(htmlKit.createDefaultDocument());
-               styleSheet = htmlDoc.getStyleSheet();
-               htmlKit.setDefaultCursor(new Cursor(Cursor.TEXT_CURSOR));
-
-               /* Set up the text pane */
-               jtpMain.setEditorKit(htmlKit);
-               jtpMain.setDocument(htmlDoc);
-               jtpMain.setMargin(new Insets(4, 4, 4, 4));
-               jtpMain.addKeyListener(this);
-
-               /* Create the source text area */
-               jtpSource = new JTextPane();
-               jtpSource.setBackground(new Color(212, 212, 212));
-               jtpSource.setSelectionColor(new Color(255, 192, 192));
-               jtpSource.setText(jtpMain.getText());
-               jtpSource.getDocument().addDocumentListener(this);
-
-               /* Add CaretListener for tracking caret location events */
-               jtpMain.addCaretListener(new CaretListener()
-               {
-                       public void caretUpdate(CaretEvent ce)
-                       {
-                               handleCaretPositionChange(ce);
-                       }
-               });
-
-               /* Set up the undo features */
-               undoMngr = new UndoManager();
-               undoAction = new UndoAction();
-               redoAction = new RedoAction();
-               jtpMain.getDocument().addUndoableEditListener(new CustomUndoableEditListener());
-
-               /* Insert raw document, if exists */
-               if(sRawDocument != null && sRawDocument.length() > 0)
-               {
-                       if(base64)
-                       {
-                               jtpMain.setText(Base64Codec.decode(sRawDocument));
-                       }
-                       else
-                       {
-                               jtpMain.setText(sRawDocument);
-                       }
-               }
-               jtpMain.setCaretPosition(0);
-               jtpMain.getDocument().addDocumentListener(this);
-
-               /* Import CSS from reference, if exists */
-               if(urlStyleSheet != null)
-               {
-                       try
-                       {
-                               String currDocText = jtpMain.getText();
-                               htmlDoc = (ExtendedHTMLDocument)(htmlKit.createDefaultDocument());
-                               styleSheet = htmlDoc.getStyleSheet();
-                               BufferedReader br = new BufferedReader(new InputStreamReader(urlStyleSheet.openStream()));
-                               styleSheet.loadRules(br, urlStyleSheet);
-                               br.close();
-                               htmlDoc = new ExtendedHTMLDocument(styleSheet);
-                               registerDocument(htmlDoc);
-                               jtpMain.setText(currDocText);
-                               jtpSource.setText(jtpMain.getText());
-                       }
-                       catch(Exception e)
-                       {
-                               e.printStackTrace(System.out);
-                       }
-               }
-
-               /* Preload the specified HTML document, if exists */
-               if(sDocument != null)
-               {
-                       File defHTML = new File(sDocument);
-                       if(defHTML.exists())
-                       {
-                               try
-                               {
-                                       openDocument(defHTML);
-                               }
-                               catch(Exception e)
-                               {
-                                       logException("Exception in preloading HTML document", e);
-                               }
-                       }
-               }
-
-               /* Preload the specified CSS document, if exists */
-               if(sStyleSheet != null)
-               {
-                       File defCSS = new File(sStyleSheet);
-                       if(defCSS.exists())
-                       {
-                               try
-                               {
-                                       openStyleSheet(defCSS);
-                               }
-                               catch(Exception e)
-                               {
-                                       logException("Exception in preloading CSS stylesheet", e);
-                               }
-                       }
-               }
-
-               /* Collect the actions that the JTextPane is naturally aware of */
-               Hashtable actions = new Hashtable();
-               Action[] actionsArray = jtpMain.getActions();
-               for(int i = 0; i < actionsArray.length; i++)
-               {
-                       Action a = actionsArray[i];
-                       actions.put(a.getValue(Action.NAME), a);
-               }
-
-               /* Create shared actions */
-               actionFontBold        = new StyledEditorKit.BoldAction();
-               actionFontItalic      = new StyledEditorKit.ItalicAction();
-               actionFontUnderline   = new StyledEditorKit.UnderlineAction();
-               actionFontStrike      = new FormatAction(this, Translatrix.getTranslationString("FontStrike"), HTML.Tag.STRIKE);
-               actionFontSuperscript = new FormatAction(this, Translatrix.getTranslationString("FontSuperscript"), HTML.Tag.SUP);
-               actionFontSubscript   = new FormatAction(this, Translatrix.getTranslationString("FontSubscript"), HTML.Tag.SUB);
-               actionListUnordered   = new ListAutomationAction(this, Translatrix.getTranslationString("ListUnordered"), HTML.Tag.UL);
-               actionListOrdered     = new ListAutomationAction(this, Translatrix.getTranslationString("ListOrdered"), HTML.Tag.OL);
-               Hashtable customAttr = new Hashtable();
-               customAttr.put("face","");
-               actionSelectFont      = new CustomAction(this, Translatrix.getTranslationString("FontSelect") + menuDialog, HTML.Tag.FONT, customAttr);
-               actionClearFormat     = new CustomAction(this, Translatrix.getTranslationString("FormatClear"), new HTML.UnknownTag(""));
-               actionInsertAnchor    = new CustomAction(this, Translatrix.getTranslationString("InsertAnchor") + menuDialog, HTML.Tag.A);
-
-               /* Build the menus */
-               /* FILE Menu */
-               jMenuFile              = new JMenu(Translatrix.getTranslationString("File"));
-               htMenus.put(KEY_MENU_FILE, jMenuFile);
-               JMenuItem jmiNew       = new JMenuItem(Translatrix.getTranslationString("NewDocument"));                     jmiNew.setActionCommand("newdoc");        jmiNew.addActionListener(this);      jmiNew.setAccelerator(KeyStroke.getKeyStroke('N', java.awt.Event.CTRL_MASK, false));      if(showMenuIcons) { jmiNew.setIcon(getEkitIcon("New")); }; jMenuFile.add(jmiNew);
-               JMenuItem jmiOpenHTML  = new JMenuItem(Translatrix.getTranslationString("OpenDocument") + menuDialog);       jmiOpenHTML.setActionCommand("openhtml"); jmiOpenHTML.addActionListener(this); jmiOpenHTML.setAccelerator(KeyStroke.getKeyStroke('O', java.awt.Event.CTRL_MASK, false)); if(showMenuIcons) { jmiOpenHTML.setIcon(getEkitIcon("Open")); }; jMenuFile.add(jmiOpenHTML);
-               JMenuItem jmiOpenCSS   = new JMenuItem(Translatrix.getTranslationString("OpenStyle") + menuDialog);          jmiOpenCSS.setActionCommand("opencss");   jmiOpenCSS.addActionListener(this);  jMenuFile.add(jmiOpenCSS);
-               JMenuItem jmiOpenB64   = new JMenuItem(Translatrix.getTranslationString("OpenBase64Document") + menuDialog); jmiOpenB64.setActionCommand("openb64");   jmiOpenB64.addActionListener(this);  jMenuFile.add(jmiOpenB64);
-               jMenuFile.addSeparator();
-               JMenuItem jmiSave      = new JMenuItem(Translatrix.getTranslationString("Save"));                  jmiSave.setActionCommand("save");         jmiSave.addActionListener(this);     jmiSave.setAccelerator(KeyStroke.getKeyStroke('S', java.awt.Event.CTRL_MASK, false)); if(showMenuIcons) { jmiSave.setIcon(getEkitIcon("Save")); }; jMenuFile.add(jmiSave);
-               JMenuItem jmiSaveAs    = new JMenuItem(Translatrix.getTranslationString("SaveAs") + menuDialog);   jmiSaveAs.setActionCommand("saveas");     jmiSaveAs.addActionListener(this);   jMenuFile.add(jmiSaveAs);
-               JMenuItem jmiSaveBody  = new JMenuItem(Translatrix.getTranslationString("SaveBody") + menuDialog); jmiSaveBody.setActionCommand("savebody"); jmiSaveBody.addActionListener(this); jMenuFile.add(jmiSaveBody);
-               JMenuItem jmiSaveRTF   = new JMenuItem(Translatrix.getTranslationString("SaveRTF") + menuDialog);  jmiSaveRTF.setActionCommand("savertf");   jmiSaveRTF.addActionListener(this);  jMenuFile.add(jmiSaveRTF);
-               JMenuItem jmiSaveB64   = new JMenuItem(Translatrix.getTranslationString("SaveB64") + menuDialog);  jmiSaveB64.setActionCommand("saveb64");   jmiSaveB64.addActionListener(this);  jMenuFile.add(jmiSaveB64);
-               jMenuFile.addSeparator();
-               JMenuItem jmiSerialOut = new JMenuItem(Translatrix.getTranslationString("Serialize") + menuDialog);   jmiSerialOut.setActionCommand("serialize");  jmiSerialOut.addActionListener(this); jMenuFile.add(jmiSerialOut);
-               JMenuItem jmiSerialIn  = new JMenuItem(Translatrix.getTranslationString("ReadFromSer") + menuDialog); jmiSerialIn.setActionCommand("readfromser"); jmiSerialIn.addActionListener(this);  jMenuFile.add(jmiSerialIn);
-               jMenuFile.addSeparator();
-               JMenuItem jmiExit      = new JMenuItem(Translatrix.getTranslationString("Exit")); jmiExit.setActionCommand("exit"); jmiExit.addActionListener(this); jMenuFile.add(jmiExit);
-
-               /* EDIT Menu */
-               jMenuEdit            = new JMenu(Translatrix.getTranslationString("Edit"));
-               htMenus.put(KEY_MENU_EDIT, jMenuEdit);
-               if(sysClipboard != null)
-               {
-                       // System Clipboard versions of menu commands
-                       JMenuItem jmiCut     = new JMenuItem(Translatrix.getTranslationString("Cut"));   jmiCut.setActionCommand("textcut");     jmiCut.addActionListener(this);   jmiCut.setAccelerator(KeyStroke.getKeyStroke('X', java.awt.Event.CTRL_MASK, false));   if(showMenuIcons) { jmiCut.setIcon(getEkitIcon("Cut")); }     jMenuEdit.add(jmiCut);
-                       JMenuItem jmiCopy    = new JMenuItem(Translatrix.getTranslationString("Copy"));  jmiCopy.setActionCommand("textcopy");   jmiCopy.addActionListener(this);  jmiCopy.setAccelerator(KeyStroke.getKeyStroke('C', java.awt.Event.CTRL_MASK, false));  if(showMenuIcons) { jmiCopy.setIcon(getEkitIcon("Copy")); }   jMenuEdit.add(jmiCopy);
-                       JMenuItem jmiPaste   = new JMenuItem(Translatrix.getTranslationString("Paste")); jmiPaste.setActionCommand("textpaste"); jmiPaste.addActionListener(this); jmiPaste.setAccelerator(KeyStroke.getKeyStroke('V', java.awt.Event.CTRL_MASK, false)); if(showMenuIcons) { jmiPaste.setIcon(getEkitIcon("Paste")); } jMenuEdit.add(jmiPaste);
-               }
-               else
-               {
-                       // DefaultEditorKit versions of menu commands
-                       JMenuItem jmiCut     = new JMenuItem(new DefaultEditorKit.CutAction());   jmiCut.setText(Translatrix.getTranslationString("Cut"));     jmiCut.setAccelerator(KeyStroke.getKeyStroke('X', java.awt.Event.CTRL_MASK, false));   if(showMenuIcons) { jmiCut.setIcon(getEkitIcon("Cut")); }     jMenuEdit.add(jmiCut);
-                       JMenuItem jmiCopy    = new JMenuItem(new DefaultEditorKit.CopyAction());  jmiCopy.setText(Translatrix.getTranslationString("Copy"));   jmiCopy.setAccelerator(KeyStroke.getKeyStroke('C', java.awt.Event.CTRL_MASK, false));  if(showMenuIcons) { jmiCopy.setIcon(getEkitIcon("Copy")); }   jMenuEdit.add(jmiCopy);
-                       JMenuItem jmiPaste   = new JMenuItem(new DefaultEditorKit.PasteAction()); jmiPaste.setText(Translatrix.getTranslationString("Paste")); jmiPaste.setAccelerator(KeyStroke.getKeyStroke('V', java.awt.Event.CTRL_MASK, false)); if(showMenuIcons) { jmiPaste.setIcon(getEkitIcon("Paste")); } jMenuEdit.add(jmiPaste);
-               }
-               jMenuEdit.addSeparator();
-               JMenuItem jmiUndo    = new JMenuItem(undoAction); jmiUndo.setAccelerator(KeyStroke.getKeyStroke('Z', java.awt.Event.CTRL_MASK, false)); jMenuEdit.add(jmiUndo);
-               JMenuItem jmiRedo    = new JMenuItem(redoAction); jmiRedo.setAccelerator(KeyStroke.getKeyStroke('Y', java.awt.Event.CTRL_MASK, false)); jMenuEdit.add(jmiRedo);
-               jMenuEdit.addSeparator();
-               JMenuItem jmiSelAll  = new JMenuItem((Action)actions.get(DefaultEditorKit.selectAllAction));       jmiSelAll.setText(Translatrix.getTranslationString("SelectAll"));        jmiSelAll.setAccelerator(KeyStroke.getKeyStroke('A', java.awt.Event.CTRL_MASK, false)); jMenuEdit.add(jmiSelAll);
-               JMenuItem jmiSelPara = new JMenuItem((Action)actions.get(DefaultEditorKit.selectParagraphAction)); jmiSelPara.setText(Translatrix.getTranslationString("SelectParagraph")); jMenuEdit.add(jmiSelPara);
-               JMenuItem jmiSelLine = new JMenuItem((Action)actions.get(DefaultEditorKit.selectLineAction));      jmiSelLine.setText(Translatrix.getTranslationString("SelectLine"));      jMenuEdit.add(jmiSelLine);
-               JMenuItem jmiSelWord = new JMenuItem((Action)actions.get(DefaultEditorKit.selectWordAction));      jmiSelWord.setText(Translatrix.getTranslationString("SelectWord"));      jMenuEdit.add(jmiSelWord);
-
-               /* VIEW Menu */
-               jMenuView        = new JMenu(Translatrix.getTranslationString("View"));
-               htMenus.put(KEY_MENU_VIEW, jMenuView);
-               jcbmiViewToolbar = new JCheckBoxMenuItem(Translatrix.getTranslationString("ViewToolbar"), false); jcbmiViewToolbar.setActionCommand("toggletoolbar"); jcbmiViewToolbar.addActionListener(this); jMenuView.add(jcbmiViewToolbar);
-               jcbmiViewSource  = new JCheckBoxMenuItem(Translatrix.getTranslationString("ViewSource"), false);  jcbmiViewSource.setActionCommand("viewsource");     jcbmiViewSource.addActionListener(this);  jMenuView.add(jcbmiViewSource);
-
-               /* FONT Menu */
-               jMenuFont              = new JMenu(Translatrix.getTranslationString("Font"));
-               htMenus.put(KEY_MENU_FONT, jMenuFont);
-               JMenuItem jmiBold      = new JMenuItem(actionFontBold);      jmiBold.setText(Translatrix.getTranslationString("FontBold"));           jmiBold.setAccelerator(KeyStroke.getKeyStroke('B', java.awt.Event.CTRL_MASK, false));      if(showMenuIcons) { jmiBold.setIcon(getEkitIcon("Bold")); }           jMenuFont.add(jmiBold);
-               JMenuItem jmiItalic    = new JMenuItem(actionFontItalic);    jmiItalic.setText(Translatrix.getTranslationString("FontItalic"));       jmiItalic.setAccelerator(KeyStroke.getKeyStroke('I', java.awt.Event.CTRL_MASK, false));    if(showMenuIcons) { jmiItalic.setIcon(getEkitIcon("Italic")); }       jMenuFont.add(jmiItalic);
-               JMenuItem jmiUnderline = new JMenuItem(actionFontUnderline); jmiUnderline.setText(Translatrix.getTranslationString("FontUnderline")); jmiUnderline.setAccelerator(KeyStroke.getKeyStroke('U', java.awt.Event.CTRL_MASK, false)); if(showMenuIcons) { jmiUnderline.setIcon(getEkitIcon("Underline")); } jMenuFont.add(jmiUnderline);
-               JMenuItem jmiStrike    = new JMenuItem(actionFontStrike);    jmiStrike.setText(Translatrix.getTranslationString("FontStrike"));                                                                                                  if(showMenuIcons) { jmiStrike.setIcon(getEkitIcon("Strike")); }       jMenuFont.add(jmiStrike);
-               jMenuFont.addSeparator();
-               jMenuFont.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("FormatBig"), HTML.Tag.BIG)));
-               jMenuFont.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("FormatSmall"), HTML.Tag.SMALL)));
-               JMenu jMenuFontSize = new JMenu(Translatrix.getTranslationString("FontSize"));
-                       String fontSizeKey = "size";
-                       customAttr = new Hashtable(); customAttr.put(fontSizeKey,"1");
-                       jMenuFontSize.add(new JMenuItem(new CustomAction(this, Translatrix.getTranslationString("FontSize1"), HTML.Tag.FONT, customAttr)));
-                       customAttr = new Hashtable(); customAttr.put(fontSizeKey,"2");
-                       jMenuFontSize.add(new JMenuItem(new CustomAction(this, Translatrix.getTranslationString("FontSize2"), HTML.Tag.FONT, customAttr)));
-                       customAttr = new Hashtable(); customAttr.put(fontSizeKey,"3");
-                       jMenuFontSize.add(new JMenuItem(new CustomAction(this, Translatrix.getTranslationString("FontSize3"), HTML.Tag.FONT, customAttr)));
-                       customAttr = new Hashtable(); customAttr.put(fontSizeKey,"4");
-                       jMenuFontSize.add(new JMenuItem(new CustomAction(this, Translatrix.getTranslationString("FontSize4"), HTML.Tag.FONT, customAttr)));
-                       customAttr = new Hashtable(); customAttr.put(fontSizeKey,"5");
-                       jMenuFontSize.add(new JMenuItem(new CustomAction(this, Translatrix.getTranslationString("FontSize5"), HTML.Tag.FONT, customAttr)));
-                       customAttr = new Hashtable(); customAttr.put(fontSizeKey,"6");
-                       jMenuFontSize.add(new JMenuItem(new CustomAction(this, Translatrix.getTranslationString("FontSize6"), HTML.Tag.FONT, customAttr)));
-                       customAttr = new Hashtable(); customAttr.put(fontSizeKey,"7");
-                       jMenuFontSize.add(new JMenuItem(new CustomAction(this, Translatrix.getTranslationString("FontSize7"), HTML.Tag.FONT, customAttr)));
-               jMenuFont.add(jMenuFontSize);
-               jMenuFont.addSeparator();
-               JMenuItem jmiSupscript = new JMenuItem(actionFontSuperscript); if(showMenuIcons) { jmiSupscript.setIcon(getEkitIcon("Super")); } jMenuFont.add(jmiSupscript);
-               JMenuItem jmiSubscript = new JMenuItem(actionFontSubscript);   if(showMenuIcons) { jmiSubscript.setIcon(getEkitIcon("Sub")); }   jMenuFont.add(jmiSubscript);
-               jMenuFont.addSeparator();
-               JMenuItem jmiSerif      = new JMenuItem((Action)actions.get("font-family-Serif"));      jmiSerif.setText(Translatrix.getTranslationString("FontSerif"));           jMenuFont.add(jmiSerif);
-               JMenuItem jmiSansSerif  = new JMenuItem((Action)actions.get("font-family-SansSerif"));  jmiSansSerif.setText(Translatrix.getTranslationString("FontSansserif"));   jMenuFont.add(jmiSansSerif);
-               JMenuItem jmiMonospaced = new JMenuItem((Action)actions.get("font-family-Monospaced")); jmiMonospaced.setText(Translatrix.getTranslationString("FontMonospaced")); jMenuFont.add(jmiMonospaced);
-               JMenuItem jmiSelectFont = new JMenuItem(actionSelectFont);                                                                                                         jMenuFont.add(jmiSelectFont);
-               jMenuFont.addSeparator();
-               JMenu jMenuFontColor = new JMenu(Translatrix.getTranslationString("Color"));
-                       customAttr = new Hashtable(); customAttr.put("color","black");
-                       jMenuFontColor.add(new JMenuItem(new CustomAction(this, Translatrix.getTranslationString("CustomColor") + menuDialog, HTML.Tag.FONT, customAttr)));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorAqua"),    new Color(  0,255,255))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorBlack"),   new Color(  0,  0,  0))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorBlue"),    new Color(  0,  0,255))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorFuschia"), new Color(255,  0,255))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorGray"),    new Color(128,128,128))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorGreen"),   new Color(  0,128,  0))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorLime"),    new Color(  0,255,  0))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorMaroon"),  new Color(128,  0,  0))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorNavy"),    new Color(  0,  0,128))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorOlive"),   new Color(128,128,  0))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorPurple"),  new Color(128,  0,128))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorRed"),     new Color(255,  0,  0))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorSilver"),  new Color(192,192,192))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorTeal"),    new Color(  0,128,128))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorWhite"),   new Color(255,255,255))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorYellow"),  new Color(255,255,  0))));
-               jMenuFont.add(jMenuFontColor);
-
-               /* FORMAT Menu */
-               jMenuFormat            = new JMenu(Translatrix.getTranslationString("Format"));
-               htMenus.put(KEY_MENU_FORMAT, jMenuFormat);
-               JMenu jMenuFormatAlign = new JMenu(Translatrix.getTranslationString("Align"));
-                       jMenuFormatAlign.add(new JMenuItem(new StyledEditorKit.AlignmentAction(Translatrix.getTranslationString("AlignLeft"), StyleConstants.ALIGN_LEFT)));
-                       jMenuFormatAlign.add(new JMenuItem(new StyledEditorKit.AlignmentAction(Translatrix.getTranslationString("AlignCenter"), StyleConstants.ALIGN_CENTER)));
-                       jMenuFormatAlign.add(new JMenuItem(new StyledEditorKit.AlignmentAction(Translatrix.getTranslationString("AlignRight"), StyleConstants.ALIGN_RIGHT)));
-                       jMenuFormatAlign.add(new JMenuItem(new StyledEditorKit.AlignmentAction(Translatrix.getTranslationString("AlignJustified"), StyleConstants.ALIGN_JUSTIFIED)));
-               jMenuFormat.add(jMenuFormatAlign);
-               jMenuFormat.addSeparator();
-               JMenu jMenuFormatHeading = new JMenu(Translatrix.getTranslationString("Heading"));
-                       jMenuFormatHeading.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("Heading1"), HTML.Tag.H1)));
-                       jMenuFormatHeading.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("Heading2"), HTML.Tag.H2)));
-                       jMenuFormatHeading.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("Heading3"), HTML.Tag.H3)));
-                       jMenuFormatHeading.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("Heading4"), HTML.Tag.H4)));
-                       jMenuFormatHeading.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("Heading5"), HTML.Tag.H5)));
-                       jMenuFormatHeading.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("Heading6"), HTML.Tag.H6)));
-               jMenuFormat.add(jMenuFormatHeading);
-               jMenuFormat.addSeparator();
-               JMenuItem jmiUList = new JMenuItem(actionListUnordered); if(showMenuIcons) { jmiUList.setIcon(getEkitIcon("UList")); } jMenuFormat.add(jmiUList);
-               JMenuItem jmiOList = new JMenuItem(actionListOrdered);   if(showMenuIcons) { jmiOList.setIcon(getEkitIcon("OList")); } jMenuFormat.add(jmiOList);
-               jMenuFormat.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("ListItem"), HTML.Tag.LI)));
-               jMenuFormat.addSeparator();
-               jMenuFormat.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("FormatBlockquote"), HTML.Tag.BLOCKQUOTE)));
-               jMenuFormat.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("FormatPre"), HTML.Tag.PRE)));
-               jMenuFormat.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("FormatStrong"), HTML.Tag.STRONG)));
-               jMenuFormat.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("FormatEmphasis"), HTML.Tag.EM)));
-               jMenuFormat.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("FormatTT"), HTML.Tag.TT)));
-               jMenuFormat.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("FormatSpan"), HTML.Tag.SPAN)));
-               jMenuFormat.addSeparator();
-               JMenuItem jmiClearStyles = new JMenuItem(actionClearFormat); if(showMenuIcons) { jmiClearStyles.setIcon(getEkitIcon("ClearFormat")); }; jMenuFormat.add(jmiClearStyles);
-
-               /* INSERT Menu */
-               jMenuInsert              = new JMenu(Translatrix.getTranslationString("Insert"));
-               htMenus.put(KEY_MENU_INSERT, jMenuInsert);
-               jMenuInsert.add(new JMenuItem(actionInsertAnchor));
-               JMenuItem jmiBreak       = new JMenuItem(Translatrix.getTranslationString("InsertBreak"));                    jmiBreak.setActionCommand("insertbreak"); jmiBreak.addActionListener(this); jmiBreak.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, java.awt.Event.SHIFT_MASK, false)); jMenuInsert.add(jmiBreak);
-               JMenuItem jmiNBSP        = new JMenuItem(Translatrix.getTranslationString("InsertNBSP"));                     jmiNBSP.setActionCommand("insertnbsp");   jmiNBSP.addActionListener(this);  jMenuInsert.add(jmiNBSP);
-               JMenuItem jmiHRule       = new JMenuItem((Action)actions.get("InsertHR"));                                    jmiHRule.setText(Translatrix.getTranslationString("InsertHorizontalRule")); jMenuInsert.add(jmiHRule);
-               jMenuInsert.addSeparator();
-               JMenuItem jmiImageLocal  = new JMenuItem(Translatrix.getTranslationString("InsertLocalImage") + menuDialog);  jmiImageLocal.setActionCommand("insertlocalimage"); jmiImageLocal.addActionListener(this); jMenuInsert.add(jmiImageLocal);
-               JMenuItem jmiImageServer = new JMenuItem(Translatrix.getTranslationString("InsertServerImage") + menuDialog); jmiImageServer.setActionCommand("insertserverimage"); jmiImageServer.addActionListener(this); jMenuInsert.add(jmiImageServer);
-
-               /* TABLE Menu */
-               jMenuTable              = new JMenu(Translatrix.getTranslationString("Table"));
-               htMenus.put(KEY_MENU_TABLE, jMenuTable);
-               JMenuItem jmiTable       = new JMenuItem(Translatrix.getTranslationString("InsertTable") + menuDialog); jmiTable.setActionCommand("inserttable");             jmiTable.addActionListener(this);       jMenuTable.add(jmiTable);
-               jMenuTable.addSeparator();
-               JMenuItem jmiTableRow    = new JMenuItem(Translatrix.getTranslationString("InsertTableRow"));           jmiTableRow.setActionCommand("inserttablerow");       jmiTableRow.addActionListener(this);    jMenuTable.add(jmiTableRow);
-               JMenuItem jmiTableCol    = new JMenuItem(Translatrix.getTranslationString("InsertTableColumn"));        jmiTableCol.setActionCommand("inserttablecolumn");    jmiTableCol.addActionListener(this);    jMenuTable.add(jmiTableCol);
-               jMenuTable.addSeparator();
-               JMenuItem jmiTableRowDel = new JMenuItem(Translatrix.getTranslationString("DeleteTableRow"));           jmiTableRowDel.setActionCommand("deletetablerow");    jmiTableRowDel.addActionListener(this); jMenuTable.add(jmiTableRowDel);
-               JMenuItem jmiTableColDel = new JMenuItem(Translatrix.getTranslationString("DeleteTableColumn"));        jmiTableColDel.setActionCommand("deletetablecolumn"); jmiTableColDel.addActionListener(this); jMenuTable.add(jmiTableColDel);
-
-               /* FORMS Menu */
-               jMenuForms                    = new JMenu(Translatrix.getTranslationString("Forms"));
-               htMenus.put(KEY_MENU_FORMS, jMenuForms);
-               JMenuItem jmiFormInsertForm   = new JMenuItem(Translatrix.getTranslationString("FormInsertForm")); jmiFormInsertForm.setActionCommand("insertform");     jmiFormInsertForm.addActionListener(this); jMenuForms.add(jmiFormInsertForm);
-               jMenuForms.addSeparator();
-               JMenuItem jmiFormTextfield    = new JMenuItem(Translatrix.getTranslationString("FormTextfield"));  jmiFormTextfield.setActionCommand("inserttextfield"); jmiFormTextfield.addActionListener(this);  jMenuForms.add(jmiFormTextfield);
-               JMenuItem jmiFormTextarea     = new JMenuItem(Translatrix.getTranslationString("FormTextarea"));   jmiFormTextarea.setActionCommand("inserttextarea");   jmiFormTextarea.addActionListener(this);   jMenuForms.add(jmiFormTextarea);
-               JMenuItem jmiFormCheckbox     = new JMenuItem(Translatrix.getTranslationString("FormCheckbox"));   jmiFormCheckbox.setActionCommand("insertcheckbox");   jmiFormCheckbox.addActionListener(this);   jMenuForms.add(jmiFormCheckbox);
-               JMenuItem jmiFormRadio        = new JMenuItem(Translatrix.getTranslationString("FormRadio"));      jmiFormRadio.setActionCommand("insertradiobutton");   jmiFormRadio.addActionListener(this);      jMenuForms.add(jmiFormRadio);
-               JMenuItem jmiFormPassword     = new JMenuItem(Translatrix.getTranslationString("FormPassword"));   jmiFormPassword.setActionCommand("insertpassword");   jmiFormPassword.addActionListener(this);   jMenuForms.add(jmiFormPassword);
-               jMenuForms.addSeparator();
-               JMenuItem jmiFormButton       = new JMenuItem(Translatrix.getTranslationString("FormButton"));       jmiFormButton.setActionCommand("insertbutton");             jmiFormButton.addActionListener(this);       jMenuForms.add(jmiFormButton);
-               JMenuItem jmiFormButtonSubmit = new JMenuItem(Translatrix.getTranslationString("FormButtonSubmit")); jmiFormButtonSubmit.setActionCommand("insertbuttonsubmit"); jmiFormButtonSubmit.addActionListener(this); jMenuForms.add(jmiFormButtonSubmit);
-               JMenuItem jmiFormButtonReset  = new JMenuItem(Translatrix.getTranslationString("FormButtonReset"));  jmiFormButtonReset.setActionCommand("insertbuttonreset");   jmiFormButtonReset.addActionListener(this);  jMenuForms.add(jmiFormButtonReset);
-
-               /* SEARCH Menu */
-               jMenuSearch            = new JMenu(Translatrix.getTranslationString("Search"));
-               htMenus.put(KEY_MENU_SEARCH, jMenuSearch);
-               JMenuItem jmiFind      = new JMenuItem(Translatrix.getTranslationString("SearchFind"));      jmiFind.setActionCommand("find");           jmiFind.addActionListener(this);      jmiFind.setAccelerator(KeyStroke.getKeyStroke('F', java.awt.Event.CTRL_MASK, false));      jMenuSearch.add(jmiFind);
-               JMenuItem jmiFindAgain = new JMenuItem(Translatrix.getTranslationString("SearchFindAgain")); jmiFindAgain.setActionCommand("findagain"); jmiFindAgain.addActionListener(this); jmiFindAgain.setAccelerator(KeyStroke.getKeyStroke('G', java.awt.Event.CTRL_MASK, false)); jMenuSearch.add(jmiFindAgain);
-               JMenuItem jmiReplace   = new JMenuItem(Translatrix.getTranslationString("SearchReplace"));   jmiReplace.setActionCommand("replace");     jmiReplace.addActionListener(this);   jmiReplace.setAccelerator(KeyStroke.getKeyStroke('R', java.awt.Event.CTRL_MASK, false));   jMenuSearch.add(jmiReplace);
-
-               /* HELP Menu */
-               jMenuHelp = new JMenu(Translatrix.getTranslationString("Help"));
-               htMenus.put(KEY_MENU_HELP, jMenuHelp);
-               JMenuItem jmiAbout = new JMenuItem(Translatrix.getTranslationString("About")); jmiAbout.setActionCommand("helpabout"); jmiAbout.addActionListener(this); jMenuHelp.add(jmiAbout);
-
-               /* DEBUG Menu */
-               jMenuDebug           = new JMenu(Translatrix.getTranslationString("Debug"));
-               htMenus.put(KEY_MENU_DEBUG, jMenuDebug);
-               JMenuItem jmiDesc    = new JMenuItem(Translatrix.getTranslationString("DescribeDoc")); jmiDesc.setActionCommand("describe");       jmiDesc.addActionListener(this);    jMenuDebug.add(jmiDesc);
-               JMenuItem jmiDescCSS = new JMenuItem(Translatrix.getTranslationString("DescribeCSS")); jmiDescCSS.setActionCommand("describecss"); jmiDescCSS.addActionListener(this); jMenuDebug.add(jmiDescCSS);
-               JMenuItem jmiTag     = new JMenuItem(Translatrix.getTranslationString("WhatTags"));    jmiTag.setActionCommand("whattags");        jmiTag.addActionListener(this);     jMenuDebug.add(jmiTag);
-
-               /* Create menubar and add menus */
-               jMenuBar = new JMenuBar();
-               jMenuBar.add(jMenuFile);
-               jMenuBar.add(jMenuEdit);
-               jMenuBar.add(jMenuView);
-               jMenuBar.add(jMenuFont);
-               jMenuBar.add(jMenuFormat);
-               jMenuBar.add(jMenuSearch);
-               jMenuBar.add(jMenuInsert);
-               jMenuBar.add(jMenuTable);
-               jMenuBar.add(jMenuForms);
-               jMenuBar.add(jMenuHelp);
-               if(debugMode)
-               {
-                       jMenuBar.add(jMenuDebug);
-               }
-
-               /* Create the toolbar */
-               jToolBar = new JToolBar(JToolBar.HORIZONTAL);
-               jToolBar.setFloatable(false);
-               jbtnNewHTML     = new JButtonNoFocus(getEkitIcon("New"));  jbtnNewHTML.setToolTipText(Translatrix.getTranslationString("NewDocument"));   jbtnNewHTML.setActionCommand("newdoc");    jbtnNewHTML.addActionListener(this);  jToolBar.add(jbtnNewHTML);  htTools.put(KEY_TOOL_NEW, jbtnNewHTML);
-               jbtnOpenHTML    = new JButtonNoFocus(getEkitIcon("Open")); jbtnOpenHTML.setToolTipText(Translatrix.getTranslationString("OpenDocument")); jbtnOpenHTML.setActionCommand("openhtml"); jbtnOpenHTML.addActionListener(this); jToolBar.add(jbtnOpenHTML); htTools.put(KEY_TOOL_OPEN, jbtnOpenHTML);
-               jbtnSaveHTML    = new JButtonNoFocus(getEkitIcon("Save")); jbtnSaveHTML.setToolTipText(Translatrix.getTranslationString("SaveDocument")); jbtnSaveHTML.setActionCommand("saveas");   jbtnSaveHTML.addActionListener(this); jToolBar.add(jbtnSaveHTML); htTools.put(KEY_TOOL_SAVE, jbtnSaveHTML);
-               jToolBar.add(new JToolBar.Separator());
-               jbtnCut         = new JButtonNoFocus(new DefaultEditorKit.CutAction());   jbtnCut.setIcon(getEkitIcon("Cut"));     jbtnCut.setText(null);   jbtnCut.setToolTipText(Translatrix.getTranslationString("Cut"));     jToolBar.add(jbtnCut);   htTools.put(KEY_TOOL_CUT, jbtnCut);
-               jbtnCopy        = new JButtonNoFocus(new DefaultEditorKit.CopyAction());  jbtnCopy.setIcon(getEkitIcon("Copy"));   jbtnCopy.setText(null);  jbtnCopy.setToolTipText(Translatrix.getTranslationString("Copy"));   jToolBar.add(jbtnCopy);  htTools.put(KEY_TOOL_COPY, jbtnCopy);
-               jbtnPaste       = new JButtonNoFocus(new DefaultEditorKit.PasteAction()); jbtnPaste.setIcon(getEkitIcon("Paste")); jbtnPaste.setText(null); jbtnPaste.setToolTipText(Translatrix.getTranslationString("Paste")); jToolBar.add(jbtnPaste); htTools.put(KEY_TOOL_PASTE, jbtnPaste);
-               jToolBar.add(new JToolBar.Separator());
-               jbtnBold        = new JButtonNoFocus(actionFontBold);        jbtnBold.setIcon(getEkitIcon("Bold"));               jbtnBold.setText(null);        jbtnBold.setToolTipText(Translatrix.getTranslationString("FontBold"));                 jToolBar.add(jbtnBold);        htTools.put(KEY_TOOL_BOLD, jbtnBold);
-               jbtnItalic      = new JButtonNoFocus(actionFontItalic);      jbtnItalic.setIcon(getEkitIcon("Italic"));           jbtnItalic.setText(null);      jbtnItalic.setToolTipText(Translatrix.getTranslationString("FontItalic"));             jToolBar.add(jbtnItalic);      htTools.put(KEY_TOOL_ITALIC, jbtnItalic);
-               jbtnUnderline   = new JButtonNoFocus(actionFontUnderline);   jbtnUnderline.setIcon(getEkitIcon("Underline"));     jbtnUnderline.setText(null);   jbtnUnderline.setToolTipText(Translatrix.getTranslationString("FontUnderline"));       jToolBar.add(jbtnUnderline);   htTools.put(KEY_TOOL_UNDERLINE, jbtnUnderline);
-               jbtnStrike      = new JButtonNoFocus(actionFontStrike);      jbtnStrike.setIcon(getEkitIcon("Strike"));           jbtnStrike.setText(null);      jbtnStrike.setToolTipText(Translatrix.getTranslationString("FontStrike"));             jToolBar.add(jbtnStrike);      htTools.put(KEY_TOOL_STRIKE, jbtnStrike);
-               jbtnSuperscript = new JButtonNoFocus(actionFontSuperscript); jbtnSuperscript.setIcon(getEkitIcon("Super"));       jbtnSuperscript.setText(null); jbtnSuperscript.setToolTipText(Translatrix.getTranslationString("FontSuperscript")); jToolBar.add(jbtnSuperscript);   htTools.put(KEY_TOOL_SUPER, jbtnSuperscript);
-               jbtnSubscript   = new JButtonNoFocus(actionFontSubscript);   jbtnSubscript.setIcon(getEkitIcon("Sub"));           jbtnSubscript.setText(null);   jbtnSubscript.setToolTipText(Translatrix.getTranslationString("FontSubscript"));     jToolBar.add(jbtnSubscript);     htTools.put(KEY_TOOL_SUB, jbtnSubscript);
-               jbtnUList       = new JButtonNoFocus(actionListUnordered);   jbtnUList.setIcon(getEkitIcon("UList"));             jbtnUList.setText(null);       jbtnUList.setToolTipText(Translatrix.getTranslationString("ListUnordered"));           jToolBar.add(jbtnUList);       htTools.put(KEY_TOOL_ULIST, jbtnUList);
-               jbtnOList       = new JButtonNoFocus(actionListOrdered);     jbtnOList.setIcon(getEkitIcon("OList"));             jbtnOList.setText(null);       jbtnOList.setToolTipText(Translatrix.getTranslationString("ListOrdered"));             jToolBar.add(jbtnOList);       htTools.put(KEY_TOOL_OLIST, jbtnOList);
-               jbtnClearFormat = new JButtonNoFocus(actionClearFormat);     jbtnClearFormat.setIcon(getEkitIcon("ClearFormat")); jbtnClearFormat.setText(null); jbtnClearFormat.setToolTipText(Translatrix.getTranslationString("FormatClear"));       jToolBar.add(jbtnClearFormat); htTools.put(KEY_TOOL_CLEAR, jbtnClearFormat);
-               jToolBar.add(new JToolBar.Separator());
-               jbtnAnchor      = new JButtonNoFocus(actionInsertAnchor); jbtnAnchor.setIcon(getEkitIcon("Anchor")); jbtnAnchor.setText(null); jbtnAnchor.setToolTipText(Translatrix.getTranslationString("ToolAnchor")); jToolBar.add(jbtnAnchor); htTools.put(KEY_TOOL_ANCHOR, jbtnAnchor);
-               jToolBar.add(new JToolBar.Separator());
-               jtbtnViewSource = new JToggleButtonNoFocus(getEkitIcon("Source")); jtbtnViewSource.setText(null); jtbtnViewSource.setToolTipText(Translatrix.getTranslationString("ViewSource")); jtbtnViewSource.setActionCommand("viewsource"); jtbtnViewSource.addActionListener(this); jtbtnViewSource.setPreferredSize(jbtnAnchor.getPreferredSize()); jtbtnViewSource.setMinimumSize(jbtnAnchor.getMinimumSize()); jtbtnViewSource.setMaximumSize(jbtnAnchor.getMaximumSize()); jToolBar.add(jtbtnViewSource); htTools.put(KEY_TOOL_SOURCE, jtbtnViewSource);
-               jToolBar.add(new JToolBar.Separator());
-               jcmbStyleSelector = new JComboBoxNoFocus(); jToolBar.add(jcmbStyleSelector); jcmbStyleSelector.setAction(new StylesAction(jcmbStyleSelector)); htTools.put(KEY_TOOL_STYLES, jcmbStyleSelector);
-
-               /* Create the scroll area for the text pane */
-               JScrollPane jspViewport = new JScrollPane(jtpMain);
-               jspViewport.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
-               jspViewport.setPreferredSize(new Dimension(400, 400));
-               jspViewport.setMinimumSize(new Dimension(32, 32));
-
-               /* Create the scroll area for the source viewer */
-               jspSource = new JScrollPane(jtpSource);
-               jspSource.setPreferredSize(new Dimension(400, 100));
-               jspSource.setMinimumSize(new Dimension(32, 32));
-
-               jspltDisplay = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
-               jspltDisplay.setTopComponent(jspViewport);
-               if(showViewSource)
-               {
-                       jspltDisplay.setBottomComponent(jspSource);
-               }
-               else
-               {
-                       jspltDisplay.setBottomComponent(null);
-               }
-
-               iSplitPos = jspltDisplay.getDividerLocation();
-
-               registerDocumentStyles();
-
-               /* Add the components to the app */
-               this.setLayout(new BorderLayout());
-               this.add(jspltDisplay, BorderLayout.CENTER);
-       }
-
-       /** Common Constructor
-         * @param sDocument         [String]  A text or HTML document to load in the editor upon startup.
-         * @param sStyleSheet       [String]  A CSS stylesheet to load in the editor upon startup.
-         * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
-         * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
-         * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
-         * @param sLanguage         [String]  The language portion of the Internationalization Locale to run Ekit in.
-         * @param sCountry          [String]  The country portion of the Internationalization Locale to run Ekit in.
-         */
-       public EkitCore(String sDocument, String sStyleSheet, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64)
-       {
-               this(sDocument, sStyleSheet, null, null, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false);
-       }
-
-       /** Default Language Constructor
-         * @param sDocument         [String]  A text or HTML document to load in the editor upon startup.
-         * @param sStyleSheet       [String]  A CSS stylesheet to load in the editor upon startup.
-         * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
-         * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
-         * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
-         */
-       public EkitCore(String sDocument, String sStyleSheet, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, boolean base64)
-       {
-               this(sDocument, sStyleSheet, null, null, showViewSource, showMenuIcons, editModeExclusive, null, null, base64, false);
-       }
-
-       /** Raw/Base64 Document & Style Sheet URL Constructor (Ideal for EkitApplet)
-         * @param sRawDocument      [String]  A document encoded as a String to load in the editor upon startup.
-         * @param sRawDocument      [String]  A document encoded as a String to load in the editor upon startup.
-         * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
-         * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
-         * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
-         * @param sLanguage         [String]  The language portion of the Internationalization Locale to run Ekit in.
-         * @param sCountry          [String]  The country portion of the Internationalization Locale to run Ekit in.
-         */
-       public EkitCore(String sRawDocument, URL urlStyleSheet, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64)
-       {
-               this(null, null, sRawDocument, urlStyleSheet, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false);
-       }
-
-       /** Document Constructor
-         * @param sRawDocument      [String]  A document encoded as a String to load in the editor upon startup.
-         * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
-         * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
-         * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
-         * @param sLanguage         [String]  The language portion of the Internationalization Locale to run Ekit in.
-         * @param sCountry          [String]  The country portion of the Internationalization Locale to run Ekit in.
-         */
-       public EkitCore(String sRawDocument, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64)
-       {
-               this(null, null, sRawDocument, null, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false);
-       }
-
-       /** Default Language & Document Constructor
-         * @param sRawDocument      [String]  A document encoded as a String to load in the editor upon startup.
-         * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
-         * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
-         * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
-         */
-       public EkitCore(String sRawDocument, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, boolean base64)
-       {
-               this(null, null, sRawDocument, null, showViewSource, showMenuIcons, editModeExclusive, null, null, base64, false);
-       }
-
-       /** Flags & Language Constructor
-         * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
-         * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
-         * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
-         * @param sLanguage         [String]  The language portion of the Internationalization Locale to run Ekit in.
-         * @param sCountry          [String]  The country portion of the Internationalization Locale to run Ekit in.
-         */
-       public EkitCore(boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry)
-       {
-               this(null, null, null, null, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, false, false);
-       }
-
-       /** Flags Constructor
-         * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
-         * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
-         * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
-         */
-       public EkitCore(boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive)
-       {
-               this(null, null, null, null, showViewSource, showMenuIcons, editModeExclusive, null, null, false, false);
-       }
-
-       /** Language & Debug Constructor
-         * @param sLanguage [String]  The language portion of the Internationalization Locale to run Ekit in.
-         * @param sCountry  [String]  The country portion of the Internationalization Locale to run Ekit in.
-         * @param debugMode [boolean] Specifies whether to show the Debug menu or not.
-         */
-       public EkitCore(String sLanguage, String sCountry, boolean debugMode)
-       {
-               this(null, null, null, null, false, true, true, sLanguage, sCountry, false, debugMode);
-       }
-
-       /** Language Constructor
-         * @param sLanguage [String]  The language portion of the Internationalization Locale to run Ekit in.
-         * @param sCountry  [String]  The country portion of the Internationalization Locale to run Ekit in.
-         */
-       public EkitCore(String sLanguage, String sCountry)
-       {
-               this(null, null, null, null, false, true, true, sLanguage, sCountry, false, false);
-       }
-
-       /** Debug Constructor
-         * @param debugMode [boolean] Specifies whether to show the Debug menu or not.
-         */
-       public EkitCore(boolean debugMode)
-       {
-               this(null, null, null, null, false, true, true, null, null, false, debugMode);
-       }
-
-       /** Empty Constructor
-         */
-       public EkitCore()
-       {
-               this(null, null, null, null, false, true, true, null, null, false, false);
-       }
-
-       /* ActionListener method */
-       public void actionPerformed(ActionEvent ae)
-       {
-               try
-               {
-                       String command = ae.getActionCommand();
-                       if(command.equals("newdoc"))
-                       {
-                               SimpleInfoDialog sidAsk = new SimpleInfoDialog(this.getFrame(), "", true, Translatrix.getTranslationString("AskNewDocument"), SimpleInfoDialog.QUESTION);
-                               String decision = sidAsk.getDecisionValue();
-                               if(decision.equals(Translatrix.getTranslationString("DialogAccept")))
-                               {
-                                       if(styleSheet != null)
-                                       {
-                                               htmlDoc = new ExtendedHTMLDocument(styleSheet);
-                                       }
-                                       else
-                                       {
-                                               htmlDoc = (ExtendedHTMLDocument)(htmlKit.createDefaultDocument());
-                                       }
-                                       jtpMain.setText("<HTML><BODY></BODY></HTML>");
-                                       jtpSource.setText(jtpMain.getText());
-                                       registerDocument(htmlDoc);
-                                       currentFile = null;
-                                       updateTitle();
-                               }
-                       }
-                       else if(command.equals("openhtml"))
-                       {
-                               openDocument(null);
-                       }
-                       else if(command.equals("opencss"))
-                       {
-                               openStyleSheet(null);
-                       }
-                       else if(command.equals("openb64"))
-                       {
-                               openDocumentBase64(null);
-                       }
-                       else if(command.equals("save"))
-                       {
-                               writeOut((HTMLDocument)(jtpMain.getDocument()), currentFile);
-                               updateTitle();
-                       }
-                       else if(command.equals("saveas"))
-                       {
-                               writeOut((HTMLDocument)(jtpMain.getDocument()), null);
-                       }
-                       else if(command.equals("savebody"))
-                       {
-                               writeOutFragment((HTMLDocument)(jtpMain.getDocument()),"body");
-                       }
-                       else if(command.equals("savertf"))
-                       {
-                               writeOutRTF((StyledDocument)(jtpMain.getStyledDocument()));
-                       }
-                       else if(command.equals("saveb64"))
-                       {
-                               writeOutBase64(jtpSource.getText());
-                       }
-                       else if(command.equals("textcut"))
-                       {
-                               if(jspSource.isShowing() && jtpSource.hasFocus())
-                               {
-                                       jtpSource.cut();
-                               }
-                               else
-                               {
-                                       jtpMain.cut();
-                               }
-                       }
-                       else if(command.equals("textcopy"))
-                       {
-                               if(jspSource.isShowing() && jtpSource.hasFocus())
-                               {
-                                       jtpSource.copy();
-                               }
-                               else
-                               {
-                                       jtpMain.copy();
-                               }
-                       }
-                       else if(command.equals("textpaste"))
-                       {
-                               if(jspSource.isShowing() && jtpSource.hasFocus())
-                               {
-                                       jtpSource.paste();
-                               }
-                               else
-                               {
-                                       jtpMain.paste();
-                               }
-                       }
-                       else if(command.equals("describe"))
-                       {
-                               System.out.println("------------DOCUMENT------------");
-                               System.out.println("Content Type : " + jtpMain.getContentType());
-                               System.out.println("Editor Kit   : " + jtpMain.getEditorKit());
-                               System.out.println("Doc Tree     :");
-                               System.out.println("");
-                               describeDocument(jtpMain.getStyledDocument());
-                               System.out.println("--------------------------------");
-                               System.out.println("");
-                       }
-                       else if(command.equals("describecss"))
-                       {
-                               System.out.println("-----------STYLESHEET-----------");
-                               System.out.println("Stylesheet Rules");
-                               Enumeration rules = styleSheet.getStyleNames();
-                               while(rules.hasMoreElements())
-                               {
-                                       String ruleName = (String)(rules.nextElement());
-                                       Style styleRule = styleSheet.getStyle(ruleName);
-                                       System.out.println(styleRule.toString());
-                               }
-                               System.out.println("--------------------------------");
-                               System.out.println("");
-                       }
-                       else if(command.equals("whattags"))
-                       {
-                               System.out.println("Caret Position : " + jtpMain.getCaretPosition());
-                               AttributeSet attribSet = jtpMain.getCharacterAttributes();
-                               Enumeration attribs = attribSet.getAttributeNames();
-                               System.out.println("Attributes     : ");
-                               while(attribs.hasMoreElements())
-                               {
-                                       String attribName = attribs.nextElement().toString();
-                                       System.out.println("                 " + attribName + " | " + attribSet.getAttribute(attribName));
-                               }
-                       }
-                       else if(command.equals("toggletoolbar"))
-                       {
-                               jToolBar.setVisible(jcbmiViewToolbar.isSelected());
-                       }
-                       else if(command.equals("viewsource"))
-                       {
-                               toggleSourceWindow();
-                       }
-                       else if(command.equals("serialize"))
-                       {
-                               serializeOut((HTMLDocument)(jtpMain.getDocument()));
-                       }
-                       else if(command.equals("readfromser"))
-                       {
-                               serializeIn();
-                       }
-                       else if(command.equals("inserttable"))
-                       {
-                               String[] fieldNames = { "rows", "cols", "border", "cellspacing", "cellpadding", "width" };
-                               String[] fieldTypes = { "text", "text", "text",   "text",        "text",        "text" };
-                               insertTable((Hashtable)null, fieldNames, fieldTypes);
-                       }
-                       else if(command.equals("inserttablerow"))
-                       {
-                               insertTableRow();
-                       }
-                       else if(command.equals("inserttablecolumn"))
-                       {
-                               insertTableColumn();
-                       }
-                       else if(command.equals("deletetablerow"))
-                       {
-                               deleteTableRow();
-                       }
-                       else if(command.equals("deletetablecolumn"))
-                       {
-                               deleteTableColumn();
-                       }
-                       else if(command.equals("insertbreak"))
-                       {
-                               insertBreak();
-                       }
-                       else if(command.equals("insertlocalimage"))
-                       {
-                               insertLocalImage(null);
-                       }
-                       else if(command.equals("insertserverimage"))
-                       {
-                               insertServerImage();
-                       }
-                       else if(command.equals("insertnbsp"))
-                       {
-                               insertNonbreakingSpace();
-                       }
-                       else if(command.equals("insertform"))
-                       {
-                               String[] fieldNames  = { "name", "method",   "enctype" };
-                               String[] fieldTypes  = { "text", "combo",    "text" };
-                               String[] fieldValues = { "",     "POST,GET", "text" };
-                               insertFormElement(HTML.Tag.FORM, "form", (Hashtable)null, fieldNames, fieldTypes, fieldValues, true);
-                       }
-                       else if(command.equals("inserttextfield"))
-                       {
-                               Hashtable htAttribs = new Hashtable();
-                               htAttribs.put("type", "text");
-                               String[] fieldNames = { "name", "value", "size", "maxlength" };
-                               String[] fieldTypes = { "text", "text",  "text", "text" };
-                               insertFormElement(HTML.Tag.INPUT, "input", htAttribs, fieldNames, fieldTypes, false);
-                       }
-                       else if(command.equals("inserttextarea"))
-                       {
-                               String[] fieldNames = { "name", "rows", "cols" };
-                               String[] fieldTypes = { "text", "text", "text" };
-                               insertFormElement(HTML.Tag.TEXTAREA, "textarea", (Hashtable)null, fieldNames, fieldTypes, true);
-                       }
-                       else if(command.equals("insertcheckbox"))
-                       {
-                               Hashtable htAttribs = new Hashtable();
-                               htAttribs.put("type", "checkbox");
-                               String[] fieldNames = { "name", "checked" };
-                               String[] fieldTypes = { "text", "bool" };
-                               insertFormElement(HTML.Tag.INPUT, "input", htAttribs, fieldNames, fieldTypes, false);
-                       }
-                       else if(command.equals("insertradiobutton"))
-                       {
-                               Hashtable htAttribs = new Hashtable();
-                               htAttribs.put("type", "radio");
-                               String[] fieldNames = { "name", "checked" };
-                               String[] fieldTypes = { "text", "bool" };
-                               insertFormElement(HTML.Tag.INPUT, "input", htAttribs, fieldNames, fieldTypes, false);
-                       }
-                       else if(command.equals("insertpassword"))
-                       {
-                               Hashtable htAttribs = new Hashtable();
-                               htAttribs.put("type", "password");
-                               String[] fieldNames = { "name", "value", "size", "maxlength" };
-                               String[] fieldTypes = { "text", "text",  "text", "text" };
-                               insertFormElement(HTML.Tag.INPUT, "input", htAttribs, fieldNames, fieldTypes, false);
-                       }
-                       else if(command.equals("insertbutton"))
-                       {
-                               Hashtable htAttribs = new Hashtable();
-                               htAttribs.put("type", "button");
-                               String[] fieldNames = { "name", "value" };
-                               String[] fieldTypes = { "text", "text" };
-                               insertFormElement(HTML.Tag.INPUT, "input", htAttribs, fieldNames, fieldTypes, false);
-                       }
-                       else if(command.equals("insertbuttonsubmit"))
-                       {
-                               Hashtable htAttribs = new Hashtable();
-                               htAttribs.put("type", "submit");
-                               String[] fieldNames = { "name", "value" };
-                               String[] fieldTypes = { "text", "text" };
-                               insertFormElement(HTML.Tag.INPUT, "input", htAttribs, fieldNames, fieldTypes, false);
-                       }
-                       else if(command.equals("insertbuttonreset"))
-                       {
-                               Hashtable htAttribs = new Hashtable();
-                               htAttribs.put("type", "reset");
-                               String[] fieldNames = { "name", "value" };
-                               String[] fieldTypes = { "text", "text" };
-                               insertFormElement(HTML.Tag.INPUT, "input", htAttribs, fieldNames, fieldTypes, false);
-                       }
-                       else if(command.equals("find"))
-                       {
-                               doSearch((String)null, (String)null, false, lastSearchCaseSetting, lastSearchTopSetting);
-                       }
-                       else if(command.equals("findagain"))
-                       {
-                               doSearch(lastSearchFindTerm, (String)null, false, lastSearchCaseSetting, false);
-                       }
-                       else if(command.equals("replace"))
-                       {
-                               doSearch((String)null, (String)null, true, lastSearchCaseSetting, lastSearchTopSetting);
-                       }
-                       else if(command.equals("exit"))
-                       {
-                               this.dispose();
-                       }
-                       else if(command.equals("helpabout"))
-                       {
-                               SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("About"), true, Translatrix.getTranslationString("AboutMessage"), SimpleInfoDialog.INFO);
-                       }
-               }
-               catch(IOException ioe)
-               {
-                       logException("IOException in actionPerformed method", ioe);
-                       SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorIOException"), SimpleInfoDialog.ERROR);
-               }
-               catch(BadLocationException ble)
-               {
-                       logException("BadLocationException in actionPerformed method", ble);
-                       SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorBadLocationException"), SimpleInfoDialog.ERROR);
-               }
-               catch(NumberFormatException nfe)
-               {
-                       logException("NumberFormatException in actionPerformed method", nfe);
-                       SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorNumberFormatException"), SimpleInfoDialog.ERROR);
-               }
-               catch(ClassNotFoundException cnfe)
-               {
-                       logException("ClassNotFound Exception in actionPerformed method", cnfe);
-                       SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorClassNotFoundException "), SimpleInfoDialog.ERROR);
-               }
-               catch(RuntimeException re)
-               {
-                       logException("RuntimeException in actionPerformed method", re);
-                       SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorRuntimeException"), SimpleInfoDialog.ERROR);
-               }
-       }
-
-       /* KeyListener methods */
-       public void keyTyped(KeyEvent ke)
-       {
-               Element elem;
-               String selectedText;
-               int pos = this.getCaretPosition();
-               int repos = -1;
-               if(ke.getKeyChar() == KeyEvent.VK_BACK_SPACE)
-               {
-                       try
-                       {
-                               if(pos > 0)
-                               {
-                                       if((selectedText = jtpMain.getSelectedText()) != null)
-                                       {
-                                               htmlUtilities.delete();
-                                               return;
-                                       }
-                                       else
-                                       {
-                                               int sOffset = htmlDoc.getParagraphElement(pos).getStartOffset();
-                                               if(sOffset == jtpMain.getSelectionStart())
-                                               {
-                                                       boolean content = true;
-                                                       if(htmlUtilities.checkParentsTag(HTML.Tag.LI))
-                                                       {
-                                                               elem = htmlUtilities.getListItemParent();
-                                                               content = false;
-                                                               int so = elem.getStartOffset();
-                                                               int eo = elem.getEndOffset();
-                                                               if(so + 1 < eo)
-                                                               {
-                                                                       char[] temp = jtpMain.getText(so, eo - so).toCharArray();
-                                                                       for(int i=0; i < temp.length; i++)
-                                                                       {
-                                                                               if(!(new Character(temp[i])).isWhitespace(temp[i]))
-                                                                               {
-                                                                                       content = true;
-                                                                               }
-                                                                       }
-                                                               }
-                                                               if(!content)
-                                                               {
-                                                                       Element listElement = elem.getParentElement();
-                                                                       htmlUtilities.removeTag(elem, true);
-                                                                       this.setCaretPosition(sOffset - 1);
-                                                                       return;
-                                                               }
-                                                               else
-                                                               {
-                                                                       jtpMain.setCaretPosition(jtpMain.getCaretPosition() - 1);
-                                                                       jtpMain.moveCaretPosition(jtpMain.getCaretPosition() - 2);
-                                                                       jtpMain.replaceSelection("");
-                                                                       return;
-                                                               }
-                                                       }
-                                                       else if(htmlUtilities.checkParentsTag(HTML.Tag.TABLE))
-                                                       {
-                                                               jtpMain.setCaretPosition(jtpMain.getCaretPosition() - 1);
-                                                               ke.consume();
-                                                               return;
-                                                       }
-                                               }
-                                               jtpMain.replaceSelection("");
-                                               return;
-                                       }
-                               }
-                       }
-                       catch (BadLocationException ble)
-                       {
-                               logException("BadLocationException in keyTyped method", ble);
-                               SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorBadLocationException"), SimpleInfoDialog.ERROR);
-                       }
-                       catch (IOException ioe)
-                       {
-                               logException("IOException in keyTyped method", ioe);
-                               SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorIOException"), SimpleInfoDialog.ERROR);
-                       }
-               }
-               else if(ke.getKeyChar() == KeyEvent.VK_ENTER)
-               {
-                       try
-                       {
-                               if(htmlUtilities.checkParentsTag(HTML.Tag.UL) == true | htmlUtilities.checkParentsTag(HTML.Tag.OL) == true)
-                               {
-                                       elem = htmlUtilities.getListItemParent();
-                                       int so = elem.getStartOffset();
-                                       int eo = elem.getEndOffset();
-                                       char[] temp = this.getTextPane().getText(so,eo-so).toCharArray();
-                                       boolean content = false;
-                                       for(int i=0;i<temp.length;i++)
-                                       {
-                                               if(!(new Character(temp[i])).isWhitespace(temp[i]))
-                                               {
-                                                       content = true;
-                                               }
-                                       }
-                                       if(content)
-                                       {
-                                               int end = -1;
-                                               int j = temp.length;
-                                               do
-                                               {
-                                                       j--;
-                                                       if(new Character(temp[j]).isLetterOrDigit(temp[j]))
-                                                       {
-                                                               end = j;
-                                                       }
-                                               } while (end == -1 && j >= 0);
-                                               j = end;
-                                               do
-                                               {
-                                                       j++;
-                                                       if(!new Character(temp[j]).isSpaceChar(temp[j]))
-                                                       {
-                                                               repos = j - end -1;
-                                                       }
-                                               } while (repos == -1 && j < temp.length);
-                                               if(repos == -1)
-                                               {
-                                                       repos = 0;
-                                               }
-                                       }
-                                       if(elem.getStartOffset() == elem.getEndOffset() || !content)
-                                       {
-                                               manageListElement(elem);
-                                       }
-                                       else
-                                       {
-                                               if(this.getCaretPosition() + 1 == elem.getEndOffset())
-                                               {
-                                                       insertListStyle(elem);
-                                                       this.setCaretPosition(pos - repos);
-                                               }
-                                               else
-                                               {
-                                                       int caret = this.getCaretPosition();
-                                                       String tempString = this.getTextPane().getText(caret, eo - caret);
-                                                       this.getTextPane().select(caret, eo - 1);
-                                                       this.getTextPane().replaceSelection("");
-                                                       htmlUtilities.insertListElement(tempString);
-                                                       Element newLi = htmlUtilities.getListItemParent();
-                                                       this.setCaretPosition(newLi.getEndOffset() - 1);
-                                               }
-                                       }
-                               }
-                       }
-                       catch (BadLocationException ble)
-                       {
-                               logException("BadLocationException in keyTyped method", ble);
-                               SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorBadLocationException"), SimpleInfoDialog.ERROR);
-                       }
-                       catch (IOException ioe)
-                       {
-                               logException("IOException in keyTyped method", ioe);
-                               SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorIOException"), SimpleInfoDialog.ERROR);
-                       }
-               }
-       }
-       public void keyPressed(KeyEvent e) {}
-       public void keyReleased(KeyEvent e) {}
-
-       public void insertListStyle(Element element)
-       throws BadLocationException,IOException
-       {
-               if(element.getParentElement().getName() == "ol")
-               {
-                       actionListOrdered.actionPerformed(new ActionEvent(new Object(), 0, "newListPoint"));
-               }
-               else
-               {
-                       actionListUnordered.actionPerformed(new ActionEvent(new Object(), 0, "newListPoint"));
-               }
-       }
-
-       /* DocumentListener methods */
-       public void changedUpdate(DocumentEvent de)     { handleDocumentChange(de); }
-       public void insertUpdate(DocumentEvent de)      { handleDocumentChange(de); }
-       public void removeUpdate(DocumentEvent de)      { handleDocumentChange(de); }
-       public void handleDocumentChange(DocumentEvent de)
-       {
-               if(!exclusiveEdit)
-               {
-                       if(jspSource.isShowing())
-                       {
-                               if(de.getDocument() instanceof HTMLDocument || de.getDocument() instanceof ExtendedHTMLDocument)
-                               {
-                                       jtpSource.getDocument().removeDocumentListener(this);
-                                       jtpSource.setText(jtpMain.getText());
-                                       jtpSource.getDocument().addDocumentListener(this);
-                               }
-                               else if(de.getDocument() instanceof PlainDocument || de.getDocument() instanceof DefaultStyledDocument)
-                               {
-                                       jtpMain.getDocument().removeDocumentListener(this);
-                                       jtpMain.setText(jtpSource.getText());
-                                       jtpMain.getDocument().addDocumentListener(this);
-                               }
-                       }
-               }
-       }
-
-       /** Method for setting a document as the current document for the text pane
-         * and re-registering the controls and settings for it
-         */
-       public void registerDocument(ExtendedHTMLDocument htmlDoc)
-       {
-               jtpMain.setDocument(htmlDoc);
-               jtpMain.getDocument().addUndoableEditListener(new CustomUndoableEditListener());
-               jtpMain.getDocument().addDocumentListener(this);
-               purgeUndos();
-               registerDocumentStyles();
-       }
-
-       /** Method for locating the available CSS style for the document and adding
-         * them to the styles selector
-         */
-       public void registerDocumentStyles()
-       {
-               if(jcmbStyleSelector == null || htmlDoc == null)
-               {
-                       return;
-               }
-               jcmbStyleSelector.setEnabled(false);
-               jcmbStyleSelector.removeAllItems();
-               jcmbStyleSelector.addItem(Translatrix.getTranslationString("NoCSSStyle"));
-               for(Enumeration e = htmlDoc.getStyleNames(); e.hasMoreElements();)
-               {
-                       String name = (String) e.nextElement();
-                       if(name.length() > 0 && name.charAt(0) == '.')
-                       {
-                               jcmbStyleSelector.addItem(name.substring(1));
-                       }
-               }
-               jcmbStyleSelector.setEnabled(true);
-       }
-
-       /** Method for inserting an HTML Table
-         */
-       private void insertTable(Hashtable attribs, String[] fieldNames, String[] fieldTypes)
-       throws IOException, BadLocationException, RuntimeException, NumberFormatException
-       {
-               int caretPos = jtpMain.getCaretPosition();
-               StringBuffer compositeElement = new StringBuffer("<TABLE");
-               if(attribs != null && attribs.size() > 0)
-               {
-                       Enumeration attribEntries = attribs.keys();
-                       while(attribEntries.hasMoreElements())
-                       {
-                               Object entryKey   = attribEntries.nextElement();
-                               Object entryValue = attribs.get(entryKey);
-                               if(entryValue != null && entryValue != "")
-                               {
-                                       compositeElement.append(" " + entryKey + "=" + '"' + entryValue + '"');
-                               }
-                       }
-               }
-               int rows = 0;
-               int cols = 0;
-               if(fieldNames != null && fieldNames.length > 0)
-               {
-                       PropertiesDialog propertiesDialog = new PropertiesDialog(this.getFrame(), fieldNames, fieldTypes, Translatrix.getTranslationString("FormDialogTitle"), true);
-                       propertiesDialog.show();
-                       String decision = propertiesDialog.getDecisionValue();
-                       if(decision.equals(Translatrix.getTranslationString("DialogCancel")))
-                       {
-                               propertiesDialog.dispose();
-                               propertiesDialog = null;
-                               return;
-                       }
-                       else
-                       {
-                               for(int iter = 0; iter < fieldNames.length; iter++)
-                               {
-                                       String fieldName = fieldNames[iter];
-                                       String propValue = propertiesDialog.getFieldValue(fieldName);
-                                       if(propValue != null && propValue != "" && propValue.length() > 0)
-                                       {
-                                               if(fieldName.equals("rows"))
-                                               {
-                                                       rows = Integer.parseInt(propValue);
-                                               }
-                                               else if(fieldName.equals("cols"))
-                                               {
-                                                       cols = Integer.parseInt(propValue);
-                                               }
-                                               else
-                                               {
-                                                       compositeElement.append(" " + fieldName + "=" + '"' + propValue + '"');
-                                               }
-                                       }
-                               }
-                       }
-                       propertiesDialog.dispose();
-                       propertiesDialog = null;
-               }
-               compositeElement.append(">");
-               for(int i = 0; i < rows; i++)
-               {
-                       compositeElement.append("<TR>");
-                       for(int j = 0; j < cols; j++)
-                       {
-                               compositeElement.append("<TD></TD>");
-                       }
-                       compositeElement.append("</TR>");
-               }
-               compositeElement.append("</TABLE><P>&nbsp;<P>");
-               htmlKit.insertHTML(htmlDoc, caretPos, compositeElement.toString(), 0, 0, HTML.Tag.TABLE);
-               jtpMain.setCaretPosition(caretPos + 1);
-               refreshOnUpdate();
-       }
-
-       /** Method for inserting a row into an HTML Table
-         */
-       private void insertTableRow()
-       {
-               int caretPos = jtpMain.getCaretPosition();
-               Element element = htmlDoc.getCharacterElement(jtpMain.getCaretPosition());
-               Element elementParent = element.getParentElement();
-               int startPoint  = -1;
-               int columnCount = -1;
-               while(elementParent != null && !elementParent.getName().equals("body"))
-               {
-                       if(elementParent.getName().equals("tr"))
-                       {
-                               startPoint  = elementParent.getStartOffset();
-                               columnCount = elementParent.getElementCount();
-                               break;
-                       }
-                       else
-                       {
-                               elementParent = elementParent.getParentElement();
-                       }
-               }
-               if(startPoint > -1 && columnCount > -1)
-               {
-                       jtpMain.setCaretPosition(startPoint);
-                       StringBuffer sRow = new StringBuffer();
-                       sRow.append("<TR>");
-                       for(int i = 0; i < columnCount; i++)
-                       {
-                               sRow.append("<TD></TD>");
-                       }
-                       sRow.append("</TR>");
-                       ActionEvent actionEvent = new ActionEvent(jtpMain, 0, "insertTableRow");
-                       new HTMLEditorKit.InsertHTMLTextAction("insertTableRow", sRow.toString(), HTML.Tag.TABLE, HTML.Tag.TR).actionPerformed(actionEvent);
-                       refreshOnUpdate();
-                       jtpMain.setCaretPosition(caretPos);
-               }
-       }
-
-       /** Method for inserting a column into an HTML Table
-         */
-       private void insertTableColumn()
-       {
-               int caretPos = jtpMain.getCaretPosition();
-               Element element = htmlDoc.getCharacterElement(jtpMain.getCaretPosition());
-               Element elementParent = element.getParentElement();
-               int startPoint = -1;
-               int rowCount   = -1;
-               int cellOffset =  0;
-               while(elementParent != null && !elementParent.getName().equals("body"))
-               {
-                       if(elementParent.getName().equals("table"))
-                       {
-                               startPoint = elementParent.getStartOffset();
-                               rowCount   = elementParent.getElementCount();
-                               break;
-                       }
-                       else if(elementParent.getName().equals("tr"))
-                       {
-                               int rowStart = elementParent.getStartOffset();
-                               int rowCells = elementParent.getElementCount();
-                               for(int i = 0; i < rowCells; i++)
-                               {
-                                       Element currentCell = elementParent.getElement(i);
-                                       if(jtpMain.getCaretPosition() >= currentCell.getStartOffset() && jtpMain.getCaretPosition() <= currentCell.getEndOffset())
-                                       {
-                                               cellOffset = i;
-                                       }
-                               }
-                               elementParent = elementParent.getParentElement();
-                       }
-                       else
-                       {
-                               elementParent = elementParent.getParentElement();
-                       }
-               }
-               if(startPoint > -1 && rowCount > -1)
-               {
-                       jtpMain.setCaretPosition(startPoint);
-                       String sCell = "<TD></TD>";
-                       ActionEvent actionEvent = new ActionEvent(jtpMain, 0, "insertTableCell");
-                       for(int i = 0; i < rowCount; i++)
-                       {
-                               Element row = elementParent.getElement(i);
-                               Element whichCell = row.getElement(cellOffset);
-                               jtpMain.setCaretPosition(whichCell.getStartOffset());
-                               new HTMLEditorKit.InsertHTMLTextAction("insertTableCell", sCell, HTML.Tag.TR, HTML.Tag.TD, HTML.Tag.TH, HTML.Tag.TD).actionPerformed(actionEvent);
-                       }
-                       refreshOnUpdate();
-                       jtpMain.setCaretPosition(caretPos);
-               }
-       }
-
-       /** Method for inserting a cell into an HTML Table
-         */
-       private void insertTableCell()
-       {
-               String sCell = "<TD></TD>";
-               ActionEvent actionEvent = new ActionEvent(jtpMain, 0, "insertTableCell");
-               new HTMLEditorKit.InsertHTMLTextAction("insertTableCell", sCell, HTML.Tag.TR, HTML.Tag.TD, HTML.Tag.TH, HTML.Tag.TD).actionPerformed(actionEvent);
-               refreshOnUpdate();
-       }
-
-       /** Method for deleting a row from an HTML Table
-         */
-       private void deleteTableRow()
-       throws BadLocationException
-       {
-               int caretPos = jtpMain.getCaretPosition();
-               Element element = htmlDoc.getCharacterElement(jtpMain.getCaretPosition());
-               Element elementParent = element.getParentElement();
-               int startPoint = -1;
-               int endPoint   = -1;
-               while(elementParent != null && !elementParent.getName().equals("body"))
-               {
-                       if(elementParent.getName().equals("tr"))
-                       {
-                               startPoint = elementParent.getStartOffset();
-                               endPoint   = elementParent.getEndOffset();
-                               break;
-                       }
-                       else
-                       {
-                               elementParent = elementParent.getParentElement();
-                       }
-               }
-               if(startPoint > -1 && endPoint > startPoint)
-               {
-                       htmlDoc.remove(startPoint, endPoint - startPoint);
-                       jtpMain.setDocument(htmlDoc);
-                       registerDocument(htmlDoc);
-                       refreshOnUpdate();
-                       if(caretPos >= htmlDoc.getLength())
-                       {
-                               caretPos = htmlDoc.getLength() - 1;
-                       }
-                       jtpMain.setCaretPosition(caretPos);
-               }
-       }
-
-       /** Method for deleting a column from an HTML Table
-         */
-       private void deleteTableColumn()
-       throws BadLocationException
-       {
-               int caretPos = jtpMain.getCaretPosition();
-               Element element       = htmlDoc.getCharacterElement(jtpMain.getCaretPosition());
-               Element elementParent = element.getParentElement();
-               Element elementCell   = (Element)null;
-               Element elementRow    = (Element)null;
-               Element elementTable  = (Element)null;
-               // Locate the table, row, and cell location of the cursor
-               while(elementParent != null && !elementParent.getName().equals("body"))
-               {
-                       if(elementParent.getName().equals("td"))
-                       {
-                               elementCell = elementParent;
-                       }
-                       else if(elementParent.getName().equals("tr"))
-                       {
-                               elementRow = elementParent;
-                       }
-                       else if(elementParent.getName().equals("table"))
-                       {
-                               elementTable = elementParent;
-                       }
-                       elementParent = elementParent.getParentElement();
-               }
-               int whichColumn = -1;
-               if(elementCell != null && elementRow != null && elementTable != null)
-               {
-                       // Find the column the cursor is in
-                       for(int i = 0; i < elementRow.getElementCount(); i++)
-                       {
-                               if(elementCell == elementRow.getElement(i))
-                               {
-                                       whichColumn = i;
-                               }
-                       }
-                       if(whichColumn > -1)
-                       {
-                               // Iterate through the table rows, deleting cells from the indicated column
-                               for(int i = 0; i < elementTable.getElementCount(); i++)
-                               {
-                                       elementRow  = elementTable.getElement(i);
-                                       elementCell = (elementRow.getElementCount() > whichColumn ? elementRow.getElement(whichColumn) : elementRow.getElement(elementRow.getElementCount() - 1));
-                                       int columnCellStart = elementCell.getStartOffset();
-                                       int columnCellEnd   = elementCell.getEndOffset();
-                                       htmlDoc.remove(columnCellStart, columnCellEnd - columnCellStart);
-                               }
-                               jtpMain.setDocument(htmlDoc);
-                               registerDocument(htmlDoc);
-                               refreshOnUpdate();
-                               if(caretPos >= htmlDoc.getLength())
-                               {
-                                       caretPos = htmlDoc.getLength() - 1;
-                               }
-                               jtpMain.setCaretPosition(caretPos);
-                       }
-               }
-       }
-
-       /** Method for inserting a break (BR) element
-         */
-       private void insertBreak()
-       throws IOException, BadLocationException, RuntimeException
-       {
-               int caretPos = jtpMain.getCaretPosition();
-               htmlKit.insertHTML(htmlDoc, caretPos, "<BR>", 0, 0, HTML.Tag.BR);
-               jtpMain.setCaretPosition(caretPos + 1);
-       }
-
-       /** Method for inserting a non-breaking space (&nbsp;)
-         */
-       private void insertNonbreakingSpace()
-       throws IOException, BadLocationException, RuntimeException
-       {
-               int caretPos = jtpMain.getCaretPosition();
-               htmlDoc.insertString(caretPos, "\240", jtpMain.getInputAttributes());
-               jtpMain.setCaretPosition(caretPos + 1);
-       }
-
-       /** Method for inserting a form element
-         */
-       private void insertFormElement(HTML.Tag baseTag, String baseElement, Hashtable attribs, String[] fieldNames, String[] fieldTypes, String[] fieldValues, boolean hasClosingTag)
-       throws IOException, BadLocationException, RuntimeException
-       {
-               int caretPos = jtpMain.getCaretPosition();
-               StringBuffer compositeElement = new StringBuffer("<" + baseElement);
-               if(attribs != null && attribs.size() > 0)
-               {
-                       Enumeration attribEntries = attribs.keys();
-                       while(attribEntries.hasMoreElements())
-                       {
-                               Object entryKey   = attribEntries.nextElement();
-                               Object entryValue = attribs.get(entryKey);
-                               if(entryValue != null && entryValue != "")
-                               {
-                                       compositeElement.append(" " + entryKey + "=" + '"' + entryValue + '"');
-                               }
-                       }
-               }
-               if(fieldNames != null && fieldNames.length > 0)
-               {
-                       PropertiesDialog propertiesDialog = new PropertiesDialog(this.getFrame(), fieldNames, fieldTypes, fieldValues, Translatrix.getTranslationString("FormDialogTitle"), true);
-                       propertiesDialog.show();
-                       String decision = propertiesDialog.getDecisionValue();
-                       if(decision.equals(Translatrix.getTranslationString("DialogCancel")))
-                       {
-                               propertiesDialog.dispose();
-                               propertiesDialog = null;
-                               return;
-                       }
-                       else
-                       {
-                               for(int iter = 0; iter < fieldNames.length; iter++)
-                               {
-                                       String fieldName = fieldNames[iter];
-                                       String propValue = propertiesDialog.getFieldValue(fieldName);
-                                       if(propValue != null && propValue.length() > 0)
-                                       {
-                                               if(fieldName.equals("checked"))
-                                               {
-                                                       if(propValue.equals("true"))
-                                                       {
-                                                               compositeElement.append(" " + fieldName + "=" + '"' + propValue + '"');
-                                                       }
-                                               }
-                                               else
-                                               {
-                                                       compositeElement.append(" " + fieldName + "=" + '"' + propValue + '"');
-                                               }
-                                       }
-                               }
-                       }
-                       propertiesDialog.dispose();
-                       propertiesDialog = null;
-               }
-               // --- Convenience for editing, this makes the FORM visible
-               if(useFormIndicator && baseElement.equals("form"))
-               {
-                       compositeElement.append(" bgcolor=" + '"' + clrFormIndicator + '"');
-               }
-               // --- END
-               compositeElement.append(">");
-               if(hasClosingTag)
-               {
-                       compositeElement.append("</" + baseElement + ">");
-               }
-               if(baseTag == HTML.Tag.FORM)
-               {
-                       compositeElement.append("<P>&nbsp;</P>");
-               }
-               htmlKit.insertHTML(htmlDoc, caretPos, compositeElement.toString(), 0, 0, baseTag);
-               // jtpMain.setCaretPosition(caretPos + 1);
-               refreshOnUpdate();
-       }
-
-       /** Alternate method call for inserting a form element
-         */
-       private void insertFormElement(HTML.Tag baseTag, String baseElement, Hashtable attribs, String[] fieldNames, String[] fieldTypes, boolean hasClosingTag)
-       throws IOException, BadLocationException, RuntimeException
-       {
-               insertFormElement(baseTag, baseElement, attribs, fieldNames, fieldTypes, new String[fieldNames.length], hasClosingTag);
-       }
-
-       /** Method that handles initial list insertion and deletion
-         */
-       public void manageListElement(Element element)
-       {
-               Element h = htmlUtilities.getListItemParent();
-               Element listElement = h.getParentElement();
-               if(h != null)
-               {
-                       htmlUtilities.removeTag(h, true);
-               }
-       }
-
-       /** Method to initiate a find/replace operation
-         */
-       private void doSearch(String searchFindTerm, String searchReplaceTerm, boolean bIsFindReplace, boolean bCaseSensitive, boolean bStartAtTop)
-       {
-               boolean bReplaceAll = false;
-               JTextPane searchPane = jtpMain;
-               if(jspSource.isShowing() || jtpSource.hasFocus())
-               {
-                       searchPane = jtpSource;
-               }
-               if(searchFindTerm == null || (bIsFindReplace && searchReplaceTerm == null))
-               {
-                       SearchDialog sdSearchInput = new SearchDialog(this.getFrame(), Translatrix.getTranslationString("SearchDialogTitle"), true, bIsFindReplace, bCaseSensitive, bStartAtTop);
-                       searchFindTerm    = sdSearchInput.getFindTerm();
-                       searchReplaceTerm = sdSearchInput.getReplaceTerm();
-                       bCaseSensitive    = sdSearchInput.getCaseSensitive();
-                       bStartAtTop       = sdSearchInput.getStartAtTop();
-                       bReplaceAll       = sdSearchInput.getReplaceAll();
-               }
-               if(searchFindTerm != null && (!bIsFindReplace || searchReplaceTerm != null))
-               {
-                       if(bReplaceAll)
-                       {
-                               int results = findText(searchFindTerm, searchReplaceTerm, bCaseSensitive, 0);
-                               int findOffset = 0;
-                               if(results > -1)
-                               {
-                                       while(results > -1)
-                                       {
-                                               findOffset = findOffset + searchReplaceTerm.length();
-                                               results    = findText(searchFindTerm, searchReplaceTerm, bCaseSensitive, findOffset);
-                                       }
-                               }
-                               else
-                               {
-                                       SimpleInfoDialog sidWarn = new SimpleInfoDialog(this.getFrame(), "", true, Translatrix.getTranslationString("ErrorNoOccurencesFound") + ":\n" + searchFindTerm, SimpleInfoDialog.WARNING);
-                               }
-                       }
-                       else
-                       {
-                               int results = findText(searchFindTerm, searchReplaceTerm, bCaseSensitive, (bStartAtTop ? 0 : searchPane.getCaretPosition()));
-                               if(results == -1)
-                               {
-                                       SimpleInfoDialog sidWarn = new SimpleInfoDialog(this.getFrame(), "", true, Translatrix.getTranslationString("ErrorNoMatchFound") + ":\n" + searchFindTerm, SimpleInfoDialog.WARNING);
-                               }
-                       }
-                       lastSearchFindTerm    = new String(searchFindTerm);
-                       if(searchReplaceTerm != null)
-                       {
-                               lastSearchReplaceTerm = new String(searchReplaceTerm);
-                       }
-                       else
-                       {
-                               lastSearchReplaceTerm = (String)null;
-                       }
-                       lastSearchCaseSetting = bCaseSensitive;
-                       lastSearchTopSetting  = bStartAtTop;
-               }
-       }
-
-       /** Method for finding (and optionally replacing) a string in the text
-         */
-       private int findText(String findTerm, String replaceTerm, boolean bCaseSenstive, int iOffset)
-       {
-               JTextPane jtpFindSource;
-               if(jspSource.isShowing() || jtpSource.hasFocus())
-               {
-                       jtpFindSource = jtpSource;
-               }
-               else
-               {
-                       jtpFindSource = jtpMain;
-               }
-               int searchPlace = -1;
-               try
-               {
-                       Document baseDocument = jtpFindSource.getDocument();
-                       searchPlace =
-                               (bCaseSenstive ?
-                                       baseDocument.getText(0, baseDocument.getLength()).indexOf(findTerm, iOffset) :
-                                       baseDocument.getText(0, baseDocument.getLength()).toLowerCase().indexOf(findTerm.toLowerCase(), iOffset)
-                               );
-                       if(searchPlace > -1)
-                       {
-                               if(replaceTerm != null)
-                               {
-                                       AttributeSet attribs = null;
-                                       if(baseDocument instanceof HTMLDocument)
-                                       {
-                                               Element element = ((HTMLDocument)baseDocument).getCharacterElement(searchPlace);
-                                               attribs = element.getAttributes();
-                                       }
-                                       baseDocument.remove(searchPlace, findTerm.length());
-                                       baseDocument.insertString(searchPlace, replaceTerm, attribs);
-                                       jtpFindSource.setCaretPosition(searchPlace + replaceTerm.length());
-                                       jtpFindSource.requestFocus();
-                                       jtpFindSource.select(searchPlace, searchPlace + replaceTerm.length());
-                               }
-                               else
-                               {
-                                       jtpFindSource.setCaretPosition(searchPlace + findTerm.length());
-                                       jtpFindSource.requestFocus();
-                                       jtpFindSource.select(searchPlace, searchPlace + findTerm.length());
-                               }
-                       }
-               }
-               catch(BadLocationException ble)
-               {
-                       logException("BadLocationException in actionPerformed method", ble);
-                       SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorBadLocationException"), SimpleInfoDialog.ERROR);
-               }
-               return searchPlace;
-       }
-
-       /** Method for inserting an image from a file
-         */
-       private void insertLocalImage(File whatImage)
-       throws IOException, BadLocationException, RuntimeException
-       {
-               if(whatImage == null)
-               {
-                       whatImage = getImageFromChooser(".", extsIMG, Translatrix.getTranslationString("FiletypeIMG"));
-               }
-               if(whatImage != null)
-               {
-                       int caretPos = jtpMain.getCaretPosition();
-                       htmlKit.insertHTML(htmlDoc, caretPos, "<IMG SRC=\"" + whatImage + "\">", 0, 0, HTML.Tag.IMG);
-                       jtpMain.setCaretPosition(caretPos + 1);
-                       refreshOnUpdate();
-               }
-       }
-
-       /** Method for inserting an image from a server
-         */
-       private void insertServerImage()
-       throws BadLocationException
-       {
-               if(ServletURL != null)
-               {
-                       try
-                       {
-                               URL theServlet = new URL(ServletURL + "?GetImages=" + TreePilotSystemID + "&ImageExtensions=" + TreePilotProperties.getString("ValidImageExtensions"));
-                               URLConnection conn = theServlet.openConnection();
-                               ObjectInputStream in = new ObjectInputStream(conn.getInputStream());
-                               String[] imageList = (String[]) in.readObject();
-                               int caretPos = jtpMain.getCaretPosition();
-                               ImageDialog imageDialog = new ImageDialog(this, ImageDir + TreePilotSystemID, imageList, "Image Chooser", true);
-                               String selectedImage = imageDialog.getSelectedImage();
-                               imageDialog.dispose();
-                               if(selectedImage != null  && !selectedImage.equals(""))
-                               {
-                                       htmlKit.insertHTML(htmlDoc, caretPos, selectedImage, 0, 0, HTML.Tag.IMG);
-                                       jtpMain.setCaretPosition(caretPos + 1);
-                               }
-                               jtpMain.requestFocus();
-                               in.close();
-                       }
-                       catch (MalformedURLException mue)
-                       {
-                               System.err.println("MalFormedURLException during insertImage " + mue);
-                       }
-                       catch (IOException ie)
-                       {
-                               System.err.println("IOException during insertImage " + ie);
-                       }
-                       catch (ClassNotFoundException cnfe)
-                       {
-                               System.err.println("ClassNotFoundException during insertImage" + cnfe);
-                       }
-               }
-       }
-
-       /** Method for inserting an image
-         */
-       public String insertFile()
-       {
-               String selectedFile = null;
-               if(ServletURL != null)
-               {
-                       try
-                       {
-                               URL theServlet = new URL(ServletURL + "?GetFiles=" + TreePilotSystemID + "&FileExtensions=" + TreePilotProperties.getString("ValidFileExtensions"));
-                               URLConnection conn = theServlet.openConnection();
-                               ObjectInputStream in = new ObjectInputStream(conn.getInputStream());
-                               String[] fileList = (String[]) in.readObject();
-                               FileDialog fileDialog = new FileDialog(this, ImageDir + TreePilotSystemID, fileList, "File Chooser", true);
-                               selectedFile = fileDialog.getSelectedFile();
-                               fileDialog.dispose();
-                               in.close();
-                       }
-                       catch (MalformedURLException mue)
-                       {
-                               System.err.println("MalFormedURLException during insertFile " + mue);
-                       }
-                       catch (IOException ie)
-                       {
-                               System.err.println("IOException during insertFile " + ie);
-                       }
-                       catch (ClassNotFoundException cnfe)
-                       {
-                               System.err.println("ClassNotFoundException during insertFile" + cnfe);
-                       }
-               }
-               return selectedFile;
-       }
-
-       /** Method for saving text as a complete HTML document
-         */
-       private void writeOut(HTMLDocument doc, File whatFile)
-       throws IOException, BadLocationException
-       {
-               if(whatFile == null)
-               {
-                       whatFile = getFileFromChooser(".", JFileChooser.SAVE_DIALOG, extsHTML, Translatrix.getTranslationString("FiletypeHTML"));
-               }
-               if(whatFile != null)
-               {
-                       FileWriter fw = new FileWriter(whatFile);
-                       htmlKit.write(fw, doc, 0, doc.getLength());
-                       fw.flush();
-                       fw.close();
-                       currentFile = whatFile;
-                       updateTitle();
-               }
-               refreshOnUpdate();
-       }
-
-       /** Method for saving text as an HTML fragment
-         */
-       private void writeOutFragment(HTMLDocument doc, String containingTag)
-       throws IOException, BadLocationException
-       {
-               File whatFile = getFileFromChooser(".", JFileChooser.SAVE_DIALOG, extsHTML, Translatrix.getTranslationString("FiletypeHTML"));
-               if(whatFile != null)
-               {
-                       FileWriter fw = new FileWriter(whatFile);
-//                     Element eleBody = locateElementInDocument((StyledDocument)doc, containingTag);
-//                     htmlKit.write(fw, doc, eleBody.getStartOffset(), eleBody.getEndOffset());
-                       String docTextCase = jtpSource.getText().toLowerCase();
-                       int tagStart       = docTextCase.indexOf("<" + containingTag.toLowerCase());
-                       int tagStartClose  = docTextCase.indexOf(">", tagStart) + 1;
-                       String closeTag    = "</" + containingTag.toLowerCase() + ">";
-                       int tagEndOpen     = docTextCase.indexOf(closeTag);
-                       if(tagStartClose < 0) { tagStartClose = 0; }
-                       if(tagEndOpen < 0 || tagEndOpen > docTextCase.length()) { tagEndOpen = docTextCase.length(); }
-                       String bodyText = jtpSource.getText().substring(tagStartClose, tagEndOpen);
-                       fw.write(bodyText, 0, bodyText.length());
-                       fw.flush();
-                       fw.close();
-               }
-               refreshOnUpdate();
-       }
-
-       /** Method for saving text as an RTF document
-         */
-       private void writeOutRTF(StyledDocument doc)
-       throws IOException, BadLocationException
-       {
-               File whatFile = getFileFromChooser(".", JFileChooser.SAVE_DIALOG, extsRTF, Translatrix.getTranslationString("FiletypeRTF"));
-               if(whatFile != null)
-               {
-                       FileOutputStream fos = new FileOutputStream(whatFile);
-                       RTFEditorKit rtfKit = new RTFEditorKit();
-                       rtfKit.write(fos, doc, 0, doc.getLength());
-                       fos.flush();
-                       fos.close();
-               }
-               refreshOnUpdate();
-       }
-
-       /** Method for saving text as a Base64 encoded document
-         */
-       private void writeOutBase64(String text)
-       throws IOException, BadLocationException
-       {
-               File whatFile = getFileFromChooser(".", JFileChooser.SAVE_DIALOG, extsB64, Translatrix.getTranslationString("FiletypeB64"));
-               if(whatFile != null)
-               {
-                       String base64text = Base64Codec.encode(text);
-                       FileWriter fw = new FileWriter(whatFile);
-                       fw.write(base64text, 0, base64text.length());
-                       fw.flush();
-                       fw.close();
-               }
-               refreshOnUpdate();
-       }
-
-       /** Method to invoke loading HTML into the app
-         */
-       private void openDocument(File whatFile)
-       throws IOException, BadLocationException
-       {
-               if(whatFile == null)
-               {
-                       whatFile = getFileFromChooser(".", JFileChooser.OPEN_DIALOG, extsHTML, Translatrix.getTranslationString("FiletypeHTML"));
-               }
-               if(whatFile != null)
-               {
-                       try
-                       {
-                               loadDocument(whatFile, null);
-                       }
-                       catch(ChangedCharSetException ccse)
-                       {
-                               String charsetType = ccse.getCharSetSpec().toLowerCase();
-                               int pos = charsetType.indexOf("charset");
-                               if(pos == -1)
-                               {
-                                       throw ccse;
-                               }
-                               while(pos < charsetType.length() && charsetType.charAt(pos) != '=')
-                               {
-                                       pos++;
-                               }
-                               pos++; // Places file cursor past the equals sign (=)
-                               String whatEncoding = charsetType.substring(pos).trim();
-                               loadDocument(whatFile, whatEncoding);
-                       }
-               }
-               refreshOnUpdate();
-       }
-
-       /** Method for loading HTML document into the app, including document encoding setting
-         */
-       private void loadDocument(File whatFile, String whatEncoding)
-       throws IOException, BadLocationException
-       {
-               Reader r = null;
-               htmlDoc = (ExtendedHTMLDocument)(htmlKit.createDefaultDocument());
-               try
-               {
-                       if(whatEncoding == null)
-                       {
-                               r = new InputStreamReader(new FileInputStream(whatFile));
-                       }
-                       else
-                       {
-                               r = new InputStreamReader(new FileInputStream(whatFile), whatEncoding);
-                               htmlDoc.putProperty("IgnoreCharsetDirective", new Boolean(true));
-                       }
-                       htmlKit.read(r, htmlDoc, 0);
-                       r.close();
-                       registerDocument(htmlDoc);
-                       jtpSource.setText(jtpMain.getText());
-                       currentFile = whatFile;
-                       updateTitle();
-               }
-               finally
-               {
-                       if(r != null)
-                       {
-                               r.close();
-                       }
-               }
-       }
-
-       /** Method for loading a Base64 encoded document
-         */
-       private void openDocumentBase64(File whatFile)
-       throws IOException, BadLocationException
-       {
-               if(whatFile == null)
-               {
-                       whatFile = getFileFromChooser(".", JFileChooser.OPEN_DIALOG, extsB64, Translatrix.getTranslationString("FiletypeB64"));
-               }
-               if(whatFile != null)
-               {
-                       FileReader fr = new FileReader(whatFile);
-                       int nextChar = 0;
-                       StringBuffer encodedText = new StringBuffer();
-                       try
-                       {
-                               while((nextChar = fr.read()) != -1)
-                               {
-                                       encodedText.append((char)nextChar);
-                               }
-                               fr.close();
-                               jtpSource.setText(Base64Codec.decode(encodedText.toString()));
-                               jtpMain.setText(jtpSource.getText());
-                               registerDocument((ExtendedHTMLDocument)(jtpMain.getDocument()));
-                       }
-                       finally
-                       {
-                               if(fr != null)
-                               {
-                                       fr.close();
-                               }
-                       }
-               }
-       }
-
-       /** Method for loading a Stylesheet into the app
-         */
-       private void openStyleSheet(File fileCSS)
-       throws IOException
-       {
-               if(fileCSS == null)
-               {
-                       fileCSS = getFileFromChooser(".", JFileChooser.OPEN_DIALOG, extsCSS, Translatrix.getTranslationString("FiletypeCSS"));
-               }
-               if(fileCSS != null)
-               {
-                       String currDocText = jtpMain.getText();
-                       htmlDoc = (ExtendedHTMLDocument)(htmlKit.createDefaultDocument());
-                       styleSheet = htmlDoc.getStyleSheet();
-                       URL cssUrl = fileCSS.toURL();
-                       InputStream is = cssUrl.openStream();
-                       BufferedReader br = new BufferedReader(new InputStreamReader(is));
-                       styleSheet.loadRules(br, cssUrl);
-                       br.close();
-                       htmlDoc = new ExtendedHTMLDocument(styleSheet);
-                       registerDocument(htmlDoc);
-                       jtpMain.setText(currDocText);
-                       jtpSource.setText(jtpMain.getText());
-               }
-               refreshOnUpdate();
-       }
-
-       /** Method for serializing the document out to a file
-         */
-       public void serializeOut(HTMLDocument doc)
-       throws IOException
-       {
-               File whatFile = getFileFromChooser(".", JFileChooser.SAVE_DIALOG, extsSer, Translatrix.getTranslationString("FiletypeSer"));
-               if(whatFile != null)
-               {
-                       ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(whatFile));
-                       oos.writeObject(doc);
-                       oos.flush();
-                       oos.close();
-               }
-               refreshOnUpdate();
-       }
-
-       /** Method for reading in a serialized document from a file
-         */
-       public void serializeIn()
-       throws IOException, ClassNotFoundException
-       {
-               File whatFile = getFileFromChooser(".", JFileChooser.OPEN_DIALOG, extsSer, Translatrix.getTranslationString("FiletypeSer"));
-               if(whatFile != null)
-               {
-                       ObjectInputStream ois = new ObjectInputStream(new FileInputStream(whatFile));
-                       htmlDoc = (ExtendedHTMLDocument)(ois.readObject());
-                       ois.close();
-                       registerDocument(htmlDoc);
-                       validate();
-               }
-               refreshOnUpdate();
-       }
-
-       /** Method for obtaining a File for input/output using a JFileChooser dialog
-         */
-       private File getFileFromChooser(String startDir, int dialogType, String[] exts, String desc)
-       {
-               JFileChooser jfileDialog = new JFileChooser(startDir);
-               jfileDialog.setDialogType(dialogType);
-               jfileDialog.setFileFilter(new MutableFilter(exts, desc));
-               int optionSelected = JFileChooser.CANCEL_OPTION;
-               if(dialogType == JFileChooser.OPEN_DIALOG)
-               {
-                       optionSelected = jfileDialog.showOpenDialog(this);
-               }
-               else if(dialogType == JFileChooser.SAVE_DIALOG)
-               {
-                       optionSelected = jfileDialog.showSaveDialog(this);
-               }
-               else // default to an OPEN_DIALOG
-               {
-                       optionSelected = jfileDialog.showOpenDialog(this);
-               }
-               if(optionSelected == JFileChooser.APPROVE_OPTION)
-               {
-                       return jfileDialog.getSelectedFile();
-               }
-               return (File)null;
-       }
-
-       /** Method for obtaining an Image for input using a custom JFileChooser dialog
-         */
-       private File getImageFromChooser(String startDir, String[] exts, String desc)
-       {
-               ImageFileChooser jImageDialog = new ImageFileChooser(startDir);
-               jImageDialog.setDialogType(JFileChooser.CUSTOM_DIALOG);
-               jImageDialog.setFileFilter(new MutableFilter(exts, desc));
-               jImageDialog.setDialogTitle(Translatrix.getTranslationString("ImageDialogTitle"));
-               int optionSelected = JFileChooser.CANCEL_OPTION;
-               optionSelected = jImageDialog.showDialog(this, Translatrix.getTranslationString("Insert"));
-               if(optionSelected == JFileChooser.APPROVE_OPTION)
-               {
-                       return jImageDialog.getSelectedFile();
-               }
-               return (File)null;
-       }
-
-       /** Method for describing the node hierarchy of the document
-         */
-       private void describeDocument(StyledDocument doc)
-       {
-               Element[] elements = doc.getRootElements();
-               for(int i = 0; i < elements.length; i++)
-               {
-                       indent = indentStep;
-                       for(int j = 0; j < indent; j++) { System.out.print(" "); }
-                       System.out.print(elements[i]);
-                       traverseElement(elements[i]);
-                       System.out.println("");
-               }
-       }
-
-       /** Traverses nodes for the describing method
-         */
-       private void traverseElement(Element element)
-       {
-               indent += indentStep;
-               for(int i = 0; i < element.getElementCount(); i++)
-               {
-                       for(int j = 0; j < indent; j++) { System.out.print(" "); }
-                       System.out.print(element.getElement(i));
-                       traverseElement(element.getElement(i));
-               }
-               indent -= indentStep;
-       }
-
-       /** Method to locate a node element by name
-         */
-       private Element locateElementInDocument(StyledDocument doc, String elementName)
-       {
-               Element[] elements = doc.getRootElements();
-               for(int i = 0; i < elements.length; i++)
-               {
-                       if(elements[i].getName().equalsIgnoreCase(elementName))
-                       {
-                               return elements[i];
-                       }
-                       else
-                       {
-                               Element rtnElement = locateChildElementInDocument(elements[i], elementName);
-                               if(rtnElement != null)
-                               {
-                                       return rtnElement;
-                               }
-                       }
-               }
-               return (Element)null;
-       }
-
-       /** Traverses nodes for the locating method
-         */
-       private Element locateChildElementInDocument(Element element, String elementName)
-       {
-               for(int i = 0; i < element.getElementCount(); i++)
-               {
-                       if(element.getElement(i).getName().equalsIgnoreCase(elementName))
-                       {
-                               return element.getElement(i);
-                       }
-               }
-               return (Element)null;
-       }
-
-       /** Convenience method for obtaining the WYSIWYG JTextPane
-         */
-       public JTextPane getTextPane()
-       {
-               return jtpMain;
-       }
-
-       /** Convenience method for obtaining the Source JTextPane
-         */
-       public JTextPane getSourcePane()
-       {
-               return jtpSource;
-       }
-
-       /** Convenience method for obtaining the application as a Frame
-         */
-       public Frame getFrame()
-       {
-               return frameHandler;
-       }
-
-       /** Convenience method for setting the parent Frame
-         */
-       public void setFrame(Frame parentFrame)
-       {
-               frameHandler = parentFrame;
-       }
-
-       /** Convenience method for obtaining the pre-generated menu bar
-         */
-       public JMenuBar getMenuBar()
-       {
-               return jMenuBar;
-       }
-
-       /** Convenience method for obtaining a custom menu bar
-         */
-       public JMenuBar getCustomMenuBar(Vector vcMenus)
-       {
-               jMenuBar = new JMenuBar();
-               for(int i = 0; i < vcMenus.size(); i++)
-               {
-                       String menuToAdd = ((String)(vcMenus.elementAt(i))).toLowerCase();
-                       if(htMenus.containsKey(menuToAdd))
-                       {
-                               jMenuBar.add((JMenu)(htMenus.get(menuToAdd)));
-                       }
-               }
-               return jMenuBar;
-       }
-
-       /** Convenience method for obtaining the pre-generated toolbar
-         */
-       public JToolBar getToolBar(boolean isShowing)
-       {
-               jcbmiViewToolbar.setState(isShowing);
-               return jToolBar;
-       }
-
-       /** Convenience method for obtaining the pre-generated toolbar
-         */
-       public JToolBar getCustomToolBar(Vector vcTools, boolean isShowing)
-       {
-               jcbmiViewToolbar.setState(isShowing);
-               jToolBar = new JToolBar(JToolBar.HORIZONTAL);
-               jToolBar.setFloatable(false);
-               for(int i = 0; i < vcTools.size(); i++)
-               {
-                       String toolToAdd = ((String)(vcTools.elementAt(i))).toLowerCase();
-                       if(toolToAdd.equals(KEY_TOOL_SEP))
-                       {
-                               jToolBar.add(new JToolBar.Separator());
-                       }
-                       else if(htTools.containsKey(toolToAdd))
-                       {
-                               if(htTools.get(toolToAdd) instanceof JButtonNoFocus)
-                               {
-                                       jToolBar.add((JButtonNoFocus)(htTools.get(toolToAdd)));
-                               }
-                               else if(htTools.get(toolToAdd) instanceof JToggleButtonNoFocus)
-                               {
-                                       jToolBar.add((JToggleButtonNoFocus)(htTools.get(toolToAdd)));
-                               }
-                               else if(htTools.get(toolToAdd) instanceof JComboBoxNoFocus)
-                               {
-                                       jToolBar.add((JComboBoxNoFocus)(htTools.get(toolToAdd)));
-                               }
-                               else
-                               {
-                                       jToolBar.add((JComponent)(htTools.get(toolToAdd)));
-                               }
-                       }
-               }
-               return jToolBar;
-       }
-
-       /** Convenience method for obtaining the current file handle
-         */
-       public File getCurrentFile()
-       {
-               return currentFile;
-       }
-
-       /** Convenience method for obtaining the application name
-         */
-       public String getAppName()
-       {
-               return appName;
-       }
-
-       /** Convenience method for obtaining the document text
-         */
-       public String getDocumentText()
-       {
-               return jtpMain.getText();
-       }
-
-       /** Convenience method for obtaining the document text
-         * contained within a tag pair
-         */
-       public String getDocumentSubText(String tagBlock)
-       {
-               return getSubText(tagBlock);
-       }
-
-       /** Method for extracting the text within a tag
-         */
-       private String getSubText(String containingTag)
-       {
-               jtpSource.setText(jtpMain.getText());
-               String docTextCase = jtpSource.getText().toLowerCase();
-               int tagStart       = docTextCase.indexOf("<" + containingTag.toLowerCase());
-               int tagStartClose  = docTextCase.indexOf(">", tagStart) + 1;
-               String closeTag    = "</" + containingTag.toLowerCase() + ">";
-               int tagEndOpen     = docTextCase.indexOf(closeTag);
-               if(tagStartClose < 0) { tagStartClose = 0; }
-               if(tagEndOpen < 0 || tagEndOpen > docTextCase.length()) { tagEndOpen = docTextCase.length(); }
-               return jtpSource.getText().substring(tagStartClose, tagEndOpen);
-       }
-
-       /** Convenience method for obtaining the document text
-               * contained within the BODY tags (a common request)
-         */
-       public String getDocumentBody()
-       {
-               return getSubText("body");
-       }
-
-       /** Convenience method for setting the document text
-         */
-       public void setDocumentText(String sText)
-       {
-               jtpMain.setText(sText);
-               ((HTMLEditorKit)(jtpMain.getEditorKit())).setDefaultCursor(new Cursor(Cursor.TEXT_CURSOR));
-               jtpSource.setText(jtpMain.getText());
-               ((HTMLEditorKit)(jtpSource.getEditorKit())).setDefaultCursor(new Cursor(Cursor.TEXT_CURSOR));
-       }
-
-       /** Convenience method for obtaining the document text
-         */
-       private void updateTitle()
-       {
-               frameHandler.setTitle(appName + (currentFile == null ? "" : " - " + currentFile.getName()));
-       }
-
-       /** Convenience method for clearing out the UndoManager
-         */
-       public void purgeUndos()
-       {
-               if(undoMngr != null)
-               {
-                       undoMngr.discardAllEdits();
-                       undoAction.updateUndoState();
-                       redoAction.updateRedoState();
-               }
-       }
-
-       /** Convenience method for refreshing and displaying changes
-         */
-       public void refreshOnUpdate()
-       {
-               jtpMain.setText(jtpMain.getText());
-               jtpSource.setText(jtpMain.getText());
-               purgeUndos();
-               this.repaint();
-       }
-
-       /** Convenience method for deallocating the app resources
-         */
-       public void dispose()
-       {
-               frameHandler.dispose();
-               System.exit(0);
-       }
-
-       /** Convenience method for fetching icon images from jar file
-         */
-       private ImageIcon getEkitIcon(String iconName)
-       {
-               return new ImageIcon(Toolkit.getDefaultToolkit().getImage(getClass().getResource("icons/" + iconName + "HK.gif")));
-       }
-
-       /** Convenience method for outputting exceptions
-         */
-       private void logException(String internalMessage, Exception e)
-       {
-               System.err.println(internalMessage);
-               e.printStackTrace(System.err);
-       }
-
-       /** Convenience method for toggling source window visibility
-         */
-       private void toggleSourceWindow()
-       {
-               if(!(jspSource.isShowing()))
-               {
-                       jtpSource.setText(jtpMain.getText());
-                       jspltDisplay.setRightComponent(jspSource);
-                       if(exclusiveEdit)
-                       {
-                               jspltDisplay.setDividerLocation(0);
-                               jspltDisplay.setEnabled(false);
-                       }
-                       else
-                       {
-                               jspltDisplay.setDividerLocation(iSplitPos);
-                               jspltDisplay.setEnabled(true);
-                       }
-               }
-               else
-               {
-                       jtpMain.setText(jtpSource.getText());
-                       iSplitPos = jspltDisplay.getDividerLocation();
-                       jspltDisplay.remove(jspSource);
-                       jtpMain.requestFocus();
-               }
-               this.validate();
-               jcbmiViewSource.setSelected(jspSource.isShowing());
-               jtbtnViewSource.setSelected(jspSource.isShowing());
-       }
-
-       /** Searches the specified element for CLASS attribute setting
-         */
-       private String findStyle(Element element)
-       {
-               AttributeSet as = element.getAttributes();
-               if(as == null)
-               {
-                       return null;
-               }
-               Object val = as.getAttribute(HTML.Attribute.CLASS);
-               if(val != null && (val instanceof String))
-               {
-                       return (String)val;
-               }
-               for(Enumeration e = as.getAttributeNames(); e.hasMoreElements();)
-               {
-                       Object key = e.nextElement();
-                       if(key instanceof HTML.Tag)
-                       {
-                               AttributeSet eas = (AttributeSet)(as.getAttribute(key));
-                               if(eas != null)
-                               {
-                                       val = eas.getAttribute(HTML.Attribute.CLASS);
-                                       if(val != null)
-                                       {
-                                               return (String)val;
-                                       }
-                               }
-                       }
-
-               }
-               return null;
-       }
-
-       /** Handles caret tracking and related events, such as displaying the current style
-         * of the text under the caret
-         */
-       private void handleCaretPositionChange(CaretEvent ce)
-       {
-               int caretPos = ce.getDot();
-               Element element = htmlDoc.getCharacterElement(caretPos);
-/*
----- TAG EXPLICATOR CODE -------------------------------------------
-               javax.swing.text.ElementIterator ei = new javax.swing.text.ElementIterator(htmlDoc);
-               Element ele;
-               while((ele = ei.next()) != null)
-               {
-                       System.out.println("ELEMENT : " + ele.getName());
-               }
-               System.out.println("ELEMENT:" + element.getName());
-               Element elementParent = element.getParentElement();
-               System.out.println("ATTRS:");
-               AttributeSet attribs = elementParent.getAttributes();
-               for(Enumeration eAttrs = attribs.getAttributeNames(); eAttrs.hasMoreElements();)
-               {
-                       System.out.println("  " + eAttrs.nextElement().toString());
-               }
-               while(elementParent != null && !elementParent.getName().equals("body"))
-               {
-                       String parentName = elementParent.getName();
-                       System.out.println("PARENT:" + parentName);
-                       System.out.println("ATTRS:");
-                       attribs = elementParent.getAttributes();
-                       for(Enumeration eAttr = attribs.getAttributeNames(); eAttr.hasMoreElements();)
-                       {
-                               System.out.println("  " + eAttr.nextElement().toString());
-                       }
-                       elementParent = elementParent.getParentElement();
-               }
----- END -------------------------------------------
-*/
-               if(element == null)
-               {
-                       return;
-               }
-               String style = null;
-               Vector vcStyles = new Vector();
-               while(element != null)
-               {
-                       if(style == null)
-                       {
-                               style = findStyle(element);
-                       }
-                       vcStyles.add(element);
-                       element = element.getParentElement();
-               }
-               int stylefound = -1;
-               if(style != null)
-               {
-                       for(int i = 0; i < jcmbStyleSelector.getItemCount(); i++)
-                       {
-                               String in = (String)(jcmbStyleSelector.getItemAt(i));
-                               if(in.equalsIgnoreCase(style))
-                               {
-                                       stylefound = i;
-                                       break;
-                               }
-                       }
-               }
-               if(stylefound > -1)
-               {
-                       Action ac = jcmbStyleSelector.getAction();
-                       ac.setEnabled(false);
-                       jcmbStyleSelector.setSelectedIndex(stylefound);
-                       ac.setEnabled(true);
-               }
-               else
-               {
-                       jcmbStyleSelector.setSelectedIndex(0);
-               }
-       }
-
-       /** Server-side image handling methods
-         */
-       protected void setServletURL(String url)
-       {
-               ServletURL = url;
-       }
-
-       protected void setImageDir(String sysDir)
-       {
-               ImageDir = sysDir;
-       }
-
-       public void setTreePilotSystemID(String theSystem)
-       {
-               TreePilotSystemID = theSystem;
-       }
-
-       /** Utility methods
-         */
-       public ExtendedHTMLDocument getExtendedHtmlDoc()
-       {
-               return (ExtendedHTMLDocument)htmlDoc;
-       }
-
-       public int getCaretPosition()
-       {
-               return jtpMain.getCaretPosition();
-       }
-
-       public void setCaretPosition(int newPositon)
-       {
-               boolean end = true;
-               do
-               {
-                       end = true;
-                       try
-                       {
-                               jtpMain.setCaretPosition(newPositon);
-                       }
-                       catch (IllegalArgumentException iae)
-                       {
-                               end = false;
-                               newPositon--;
-                       }
-               } while(!end && newPositon >= 0);
-       }
-
-/* Inner Classes --------------------------------------------- */
-
-       /** Class for implementing Undo as an autonomous action
-         */
-       class UndoAction extends AbstractAction
-       {
-               public UndoAction()
-               {
-                       super(Translatrix.getTranslationString("Undo"));
-                       setEnabled(false);
-               }
-
-               public void actionPerformed(ActionEvent e)
-               {
-                       try
-                       {
-                               undoMngr.undo();
-                       }
-                       catch(CannotUndoException ex)
-                       {
-                               ex.printStackTrace();
-                       }
-                       updateUndoState();
-                       redoAction.updateRedoState();
-               }
-
-               protected void updateUndoState()
-               {
-                       if(undoMngr.canUndo())
-                       {
-                               setEnabled(true);
-                               putValue(Action.NAME, undoMngr.getUndoPresentationName());
-                       }
-                       else
-                       {
-                               setEnabled(false);
-                               putValue(Action.NAME, Translatrix.getTranslationString("Undo"));
-                       }
-               }
-       }
-
-       /** Class for implementing Redo as an autonomous action
-         */
-       class RedoAction extends AbstractAction
-       {
-               public RedoAction()
-               {
-                       super(Translatrix.getTranslationString("Redo"));
-                       setEnabled(false);
-               }
-
-               public void actionPerformed(ActionEvent e)
-               {
-                       try
-                       {
-                               undoMngr.redo();
-                       }
-                       catch(CannotUndoException ex)
-                       {
-                               ex.printStackTrace();
-                       }
-                       updateRedoState();
-                       undoAction.updateUndoState();
-               }
-
-               protected void updateRedoState()
-               {
-                       if(undoMngr.canRedo())
-                       {
-                               setEnabled(true);
-                               putValue(Action.NAME, undoMngr.getRedoPresentationName());
-                       }
-                       else
-                       {
-                               setEnabled(false);
-                               putValue(Action.NAME, Translatrix.getTranslationString("Redo"));
-                       }
-               }
-       }
-
-       /** Class for implementing the Undo listener to handle the Undo and Redo actions
-         */
-       class CustomUndoableEditListener implements UndoableEditListener
-       {
-               public void undoableEditHappened(UndoableEditEvent uee)
-               {
-                       undoMngr.addEdit(uee.getEdit());
-                       undoAction.updateUndoState();
-                       redoAction.updateRedoState();
-               }
-       }
-
-}
diff --git a/ekit/com/hexidec/ekit/EkitCore_Spell.java b/ekit/com/hexidec/ekit/EkitCore_Spell.java
deleted file mode 100644 (file)
index cc31e19..0000000
+++ /dev/null
@@ -1,2879 +0,0 @@
-/*
-GNU Lesser General Public License
-
-EkitCore - Base Java Swing HTML Editor & Viewer Class (Spellcheck Version)
-Copyright (C) 2000-2003 Howard Kistler
-
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public
-License along with this library; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
-package com.hexidec.ekit;
-
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Cursor;
-import java.awt.Dimension;
-import java.awt.Frame;
-import java.awt.Graphics;
-import java.awt.Image;
-import java.awt.Insets;
-import java.awt.Toolkit;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Reader;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.MalformedURLException;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.Vector;
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.Icon;
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JCheckBoxMenuItem;
-import javax.swing.JComboBox;
-import javax.swing.JComponent;
-import javax.swing.JDialog;
-import javax.swing.JEditorPane;
-import javax.swing.JFileChooser;
-import javax.swing.JFrame;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JSplitPane;
-import javax.swing.JTextField;
-import javax.swing.JTextPane;
-import javax.swing.JToggleButton;
-import javax.swing.JToolBar;
-import javax.swing.KeyStroke;
-import javax.swing.event.CaretEvent;
-import javax.swing.event.CaretListener;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-import javax.swing.event.UndoableEditEvent;
-import javax.swing.event.UndoableEditListener;
-import javax.swing.filechooser.FileFilter;
-import javax.swing.text.AttributeSet;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.ChangedCharSetException;
-import javax.swing.text.DefaultEditorKit;
-import javax.swing.text.DefaultStyledDocument;
-import javax.swing.text.Document;
-import javax.swing.text.Element;
-import javax.swing.text.PlainDocument;
-import javax.swing.text.Position;
-import javax.swing.text.Style;
-import javax.swing.text.StyleConstants;
-import javax.swing.text.StyledDocument;
-import javax.swing.text.StyledEditorKit;
-import javax.swing.text.StyledEditorKit.FontSizeAction;
-import javax.swing.text.html.HTML;
-import javax.swing.text.html.HTMLDocument;
-import javax.swing.text.html.HTMLEditorKit;
-import javax.swing.text.html.StyleSheet;
-import javax.swing.text.rtf.RTFEditorKit;
-import javax.swing.undo.UndoManager;
-import javax.swing.undo.CannotUndoException;
-
-import com.hexidec.ekit.action.*;
-import com.hexidec.ekit.component.*;
-import com.hexidec.util.Base64Codec;
-import com.hexidec.util.Translatrix;
-
-import  com.swabunga.spell.engine.*;
-import  com.swabunga.spell.event.*;
-import  com.swabunga.spell.swing.*;
-
-/** EkitCore
-  * Main application class for editing and saving HTML in a Java text component
-  *
-  * @author Howard Kistler
-  * @version 0.9g
-  *
-  * REQUIREMENTS
-  * Java 2 (JDK 1.3 or 1.4)
-  * Swing Library
-  */
-
-public class EkitCore extends JPanel implements ActionListener, KeyListener, DocumentListener, SpellCheckListener
-{
-       /* Components */
-       private JSplitPane jspltDisplay;
-       private JTextPane jtpMain;
-       private ExtendedHTMLEditorKit htmlKit;
-       private ExtendedHTMLDocument htmlDoc;
-       private StyleSheet styleSheet;
-       private JTextPane jtpSource;
-       private JScrollPane jspSource;
-       private JToolBar jToolBar;
-
-       private JCheckBoxMenuItem jcbmiViewToolbar;
-       private JCheckBoxMenuItem jcbmiViewSource;
-
-       private JButtonNoFocus jbtnNewHTML;
-       private JButtonNoFocus jbtnOpenHTML;
-       private JButtonNoFocus jbtnSaveHTML;
-       private JButtonNoFocus jbtnCut;
-       private JButtonNoFocus jbtnCopy;
-       private JButtonNoFocus jbtnPaste;
-       private JButtonNoFocus jbtnBold;
-       private JButtonNoFocus jbtnItalic;
-       private JButtonNoFocus jbtnUnderline;
-       private JButtonNoFocus jbtnStrike;
-       private JButtonNoFocus jbtnSuperscript;
-       private JButtonNoFocus jbtnSubscript;
-       private JButtonNoFocus jbtnUList;
-       private JButtonNoFocus jbtnOList;
-       private JButtonNoFocus jbtnClearFormat;
-       private JButtonNoFocus jbtnAnchor;
-       private JToggleButtonNoFocus jtbtnViewSource;
-       private JComboBoxNoFocus jcmbStyleSelector;
-
-       private Frame frameHandler;
-
-       private HTMLUtilities htmlUtilities = new HTMLUtilities(this);
-
-       /* Actions */
-       private StyledEditorKit.BoldAction actionFontBold;
-       private StyledEditorKit.ItalicAction actionFontItalic;
-       private StyledEditorKit.UnderlineAction actionFontUnderline;
-       private FormatAction actionFontStrike;
-       private FormatAction actionFontSuperscript;
-       private FormatAction actionFontSubscript;
-       private ListAutomationAction actionListUnordered;
-       private ListAutomationAction actionListOrdered;
-       private CustomAction actionSelectFont;
-       private CustomAction actionClearFormat;
-       private CustomAction actionInsertAnchor;
-
-       protected UndoManager undoMngr;
-       protected UndoAction undoAction;
-       protected RedoAction redoAction;
-
-       /* Menus */
-       private JMenuBar jMenuBar;
-       private JMenu jMenuFile;
-       private JMenu jMenuEdit;
-       private JMenu jMenuView;
-       private JMenu jMenuFont;
-       private JMenu jMenuFormat;
-       private JMenu jMenuInsert;
-       private JMenu jMenuTable;
-       private JMenu jMenuForms;
-       private JMenu jMenuSearch;
-       private JMenu jMenuTools;
-       private JMenu jMenuHelp;
-       private JMenu jMenuDebug;
-
-       /* Constants */
-       // Menu Keys
-       public static final String KEY_MENU_FILE   = "file";
-       public static final String KEY_MENU_EDIT   = "edit";
-       public static final String KEY_MENU_VIEW   = "view";
-       public static final String KEY_MENU_FONT   = "font";
-       public static final String KEY_MENU_FORMAT = "format";
-       public static final String KEY_MENU_INSERT = "insert";
-       public static final String KEY_MENU_TABLE  = "table";
-       public static final String KEY_MENU_FORMS  = "forms";
-       public static final String KEY_MENU_SEARCH = "search";
-       public static final String KEY_MENU_TOOLS  = "tools";
-       public static final String KEY_MENU_HELP   = "help";
-       public static final String KEY_MENU_DEBUG  = "debug";
-
-       // Tool Keys
-       public static final String KEY_TOOL_SEP       = "separator";
-       public static final String KEY_TOOL_NEW       = "new";
-       public static final String KEY_TOOL_OPEN      = "open";
-       public static final String KEY_TOOL_SAVE      = "save";
-       public static final String KEY_TOOL_CUT       = "cut";
-       public static final String KEY_TOOL_COPY      = "copy";
-       public static final String KEY_TOOL_PASTE     = "paste";
-       public static final String KEY_TOOL_BOLD      = "bold";
-       public static final String KEY_TOOL_ITALIC    = "italic";
-       public static final String KEY_TOOL_UNDERLINE = "underline";
-       public static final String KEY_TOOL_STRIKE    = "strike";
-       public static final String KEY_TOOL_SUPER     = "superscript";
-       public static final String KEY_TOOL_SUB       = "subscript";
-       public static final String KEY_TOOL_ULIST     = "ulist";
-       public static final String KEY_TOOL_OLIST     = "olist";
-       public static final String KEY_TOOL_CLEAR     = "clearformats";
-       public static final String KEY_TOOL_ANCHOR    = "anchor";
-       public static final String KEY_TOOL_SOURCE    = "viewsource";
-       public static final String KEY_TOOL_STYLES    = "styleselect";
-
-       // Menu & Tool Key Arrays
-       private static Hashtable htMenus = new Hashtable();
-       private static Hashtable htTools = new Hashtable();
-
-       private final String appName = "Ekit";
-       private final String menuDialog = "..."; /* text to append to a MenuItem label when menu item opens a dialog */
-
-       private final boolean useFormIndicator = true; /* Creates a highlighted background on a new FORM so that it may be more easily edited */
-       private final String clrFormIndicator = "#cccccc";
-
-       // System Clipboard Settings
-       private java.awt.datatransfer.Clipboard sysClipboard;
-       private SecurityManager secManager;
-
-       /* Variables */
-       private int iSplitPos = 0;
-
-       private boolean exclusiveEdit = true;
-
-       private String lastSearchFindTerm     = null;
-       private String lastSearchReplaceTerm  = null;
-       private boolean lastSearchCaseSetting = false;
-       private boolean lastSearchTopSetting  = false;
-
-       private File currentFile = null;
-
-       private int indent = 0;
-       private final int indentStep = 4;
-
-       // File extensions for MutableFilter
-       private final String[] extsHTML = { "html", "htm", "shtml" };
-       private final String[] extsCSS  = { "css" };
-       private final String[] extsIMG  = { "gif", "jpg", "jpeg", "png" };
-       private final String[] extsRTF  = { "rtf" };
-       private final String[] extsB64  = { "b64" };
-       private final String[] extsSer  = { "ser" };
-
-       /* Spell Checker Settings */
-       private static String dictFile;
-       private SpellChecker spellCheck = null;
-       private JSpellDialog spellDialog;
-
-       /* Servlet Settings */
-       private String ServletURL = null;
-       private String TreePilotSystemID = "";
-       private String ImageDir = "";
-       private static ResourceBundle TreePilotProperties;
-
-       /** Master Constructor
-         * @param sDocument         [String]  A text or HTML document to load in the editor upon startup.
-         * @param sStyleSheet       [String]  A CSS stylesheet to load in the editor upon startup.
-         * @param sRawDocument      [String]  A document encoded as a String to load in the editor upon startup.
-         * @param urlStyleSheet     [URL]     A URL reference to the CSS style sheet.
-         * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
-         * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
-         * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
-         * @param sLanguage         [String]  The language portion of the Internationalization Locale to run Ekit in.
-         * @param sCountry          [String]  The country portion of the Internationalization Locale to run Ekit in.
-         * @param base64            [boolean] Specifies whether the raw document is Base64 encoded or not.
-         * @param debugMode         [boolean] Specifies whether to show the Debug menu or not.
-         */
-       public EkitCore(String sDocument, String sStyleSheet, String sRawDocument, URL urlStyleSheet, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64, boolean debugMode)
-       {
-               super();
-
-               exclusiveEdit = editModeExclusive;
-
-               frameHandler = new Frame();
-
-               // Determine if system clipboard is available
-               secManager = System.getSecurityManager();
-               if(secManager != null)
-               {
-                       try
-                       {
-                               secManager.checkSystemClipboardAccess();
-                               sysClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
-                       }
-                       catch (SecurityException se)
-                       {
-                               sysClipboard = null;
-                       }
-               }
-
-               /* Localize for language */
-               Translatrix.setBundleName("com.hexidec.ekit.LanguageResources");
-               Locale baseLocale = (Locale)null;
-               if(sLanguage != null && sCountry != null)
-               {
-                       baseLocale = new Locale(sLanguage, sCountry);
-               }
-               Translatrix.setLocale(baseLocale);
-
-               /* Load TreePilot properties */
-               try
-               {
-                       TreePilotProperties = ResourceBundle.getBundle("com.hexidec.ekit.TreePilot");
-               }
-               catch(MissingResourceException mre)
-               {
-                       logException("MissingResourceException while loading treepilot file", mre);
-               }
-
-               /* Create the editor kit, document, and stylesheet */
-               jtpMain = new JTextPane();
-               htmlKit = new ExtendedHTMLEditorKit();
-               htmlDoc = (ExtendedHTMLDocument)(htmlKit.createDefaultDocument());
-               styleSheet = htmlDoc.getStyleSheet();
-               htmlKit.setDefaultCursor(new Cursor(Cursor.TEXT_CURSOR));
-
-               /* Set up the text pane */
-               jtpMain.setEditorKit(htmlKit);
-               jtpMain.setDocument(htmlDoc);
-               jtpMain.setMargin(new Insets(4, 4, 4, 4));
-               jtpMain.addKeyListener(this);
-
-               /* Create the source text area */
-               jtpSource = new JTextPane();
-               jtpSource.setBackground(new Color(212, 212, 212));
-               jtpSource.setSelectionColor(new Color(255, 192, 192));
-               jtpSource.setText(jtpMain.getText());
-               jtpSource.getDocument().addDocumentListener(this);
-
-               /* Add CaretListener for tracking caret location events */
-               jtpMain.addCaretListener(new CaretListener()
-               {
-                       public void caretUpdate(CaretEvent ce)
-                       {
-                               handleCaretPositionChange(ce);
-                       }
-               });
-
-               /* Set up the undo features */
-               undoMngr = new UndoManager();
-               undoAction = new UndoAction();
-               redoAction = new RedoAction();
-               jtpMain.getDocument().addUndoableEditListener(new CustomUndoableEditListener());
-
-               /* Insert raw document, if exists */
-               if(sRawDocument != null && sRawDocument.length() > 0)
-               {
-                       if(base64)
-                       {
-                               jtpMain.setText(Base64Codec.decode(sRawDocument));
-                       }
-                       else
-                       {
-                               jtpMain.setText(sRawDocument);
-                       }
-               }
-               jtpMain.setCaretPosition(0);
-               jtpMain.getDocument().addDocumentListener(this);
-
-               /* Import CSS from reference, if exists */
-               if(urlStyleSheet != null)
-               {
-                       try
-                       {
-                               String currDocText = jtpMain.getText();
-                               htmlDoc = (ExtendedHTMLDocument)(htmlKit.createDefaultDocument());
-                               styleSheet = htmlDoc.getStyleSheet();
-                               BufferedReader br = new BufferedReader(new InputStreamReader(urlStyleSheet.openStream()));
-                               styleSheet.loadRules(br, urlStyleSheet);
-                               br.close();
-                               htmlDoc = new ExtendedHTMLDocument(styleSheet);
-                               registerDocument(htmlDoc);
-                               jtpMain.setText(currDocText);
-                               jtpSource.setText(jtpMain.getText());
-                       }
-                       catch(Exception e)
-                       {
-                               e.printStackTrace(System.out);
-                       }
-               }
-
-               /* Preload the specified HTML document, if exists */
-               if(sDocument != null)
-               {
-                       File defHTML = new File(sDocument);
-                       if(defHTML.exists())
-                       {
-                               try
-                               {
-                                       openDocument(defHTML);
-                               }
-                               catch(Exception e)
-                               {
-                                       logException("Exception in preloading HTML document", e);
-                               }
-                       }
-               }
-
-               /* Preload the specified CSS document, if exists */
-               if(sStyleSheet != null)
-               {
-                       File defCSS = new File(sStyleSheet);
-                       if(defCSS.exists())
-                       {
-                               try
-                               {
-                                       openStyleSheet(defCSS);
-                               }
-                               catch(Exception e)
-                               {
-                                       logException("Exception in preloading CSS stylesheet", e);
-                               }
-                       }
-               }
-
-               /* Collect the actions that the JTextPane is naturally aware of */
-               Hashtable actions = new Hashtable();
-               Action[] actionsArray = jtpMain.getActions();
-               for(int i = 0; i < actionsArray.length; i++)
-               {
-                       Action a = actionsArray[i];
-                       actions.put(a.getValue(Action.NAME), a);
-               }
-
-               /* Create shared actions */
-               actionFontBold        = new StyledEditorKit.BoldAction();
-               actionFontItalic      = new StyledEditorKit.ItalicAction();
-               actionFontUnderline   = new StyledEditorKit.UnderlineAction();
-               actionFontStrike      = new FormatAction(this, Translatrix.getTranslationString("FontStrike"), HTML.Tag.STRIKE);
-               actionFontSuperscript = new FormatAction(this, Translatrix.getTranslationString("FontSuperscript"), HTML.Tag.SUP);
-               actionFontSubscript   = new FormatAction(this, Translatrix.getTranslationString("FontSubscript"), HTML.Tag.SUB);
-               actionListUnordered   = new ListAutomationAction(this, Translatrix.getTranslationString("ListUnordered"), HTML.Tag.UL);
-               actionListOrdered     = new ListAutomationAction(this, Translatrix.getTranslationString("ListOrdered"), HTML.Tag.OL);
-               Hashtable customAttr = new Hashtable();
-               customAttr.put("face","");
-               actionSelectFont      = new CustomAction(this, Translatrix.getTranslationString("FontSelect") + menuDialog, HTML.Tag.FONT, customAttr);
-               actionClearFormat     = new CustomAction(this, Translatrix.getTranslationString("FormatClear"), new HTML.UnknownTag(""));
-               actionInsertAnchor    = new CustomAction(this, Translatrix.getTranslationString("InsertAnchor") + menuDialog, HTML.Tag.A);
-
-               /* Build the menus */
-               /* FILE Menu */
-               jMenuFile              = new JMenu(Translatrix.getTranslationString("File"));
-               htMenus.put(KEY_MENU_FILE, jMenuFile);
-               JMenuItem jmiNew       = new JMenuItem(Translatrix.getTranslationString("NewDocument"));                     jmiNew.setActionCommand("newdoc");        jmiNew.addActionListener(this);      jmiNew.setAccelerator(KeyStroke.getKeyStroke('N', java.awt.Event.CTRL_MASK, false));      if(showMenuIcons) { jmiNew.setIcon(getEkitIcon("New")); }; jMenuFile.add(jmiNew);
-               JMenuItem jmiOpenHTML  = new JMenuItem(Translatrix.getTranslationString("OpenDocument") + menuDialog);       jmiOpenHTML.setActionCommand("openhtml"); jmiOpenHTML.addActionListener(this); jmiOpenHTML.setAccelerator(KeyStroke.getKeyStroke('O', java.awt.Event.CTRL_MASK, false)); if(showMenuIcons) { jmiOpenHTML.setIcon(getEkitIcon("Open")); }; jMenuFile.add(jmiOpenHTML);
-               JMenuItem jmiOpenCSS   = new JMenuItem(Translatrix.getTranslationString("OpenStyle") + menuDialog);          jmiOpenCSS.setActionCommand("opencss");   jmiOpenCSS.addActionListener(this);  jMenuFile.add(jmiOpenCSS);
-               JMenuItem jmiOpenB64   = new JMenuItem(Translatrix.getTranslationString("OpenBase64Document") + menuDialog); jmiOpenB64.setActionCommand("openb64");   jmiOpenB64.addActionListener(this);  jMenuFile.add(jmiOpenB64);
-               jMenuFile.addSeparator();
-               JMenuItem jmiSave      = new JMenuItem(Translatrix.getTranslationString("Save"));                  jmiSave.setActionCommand("save");         jmiSave.addActionListener(this);     jmiSave.setAccelerator(KeyStroke.getKeyStroke('S', java.awt.Event.CTRL_MASK, false)); if(showMenuIcons) { jmiSave.setIcon(getEkitIcon("Save")); }; jMenuFile.add(jmiSave);
-               JMenuItem jmiSaveAs    = new JMenuItem(Translatrix.getTranslationString("SaveAs") + menuDialog);   jmiSaveAs.setActionCommand("saveas");     jmiSaveAs.addActionListener(this);   jMenuFile.add(jmiSaveAs);
-               JMenuItem jmiSaveBody  = new JMenuItem(Translatrix.getTranslationString("SaveBody") + menuDialog); jmiSaveBody.setActionCommand("savebody"); jmiSaveBody.addActionListener(this); jMenuFile.add(jmiSaveBody);
-               JMenuItem jmiSaveRTF   = new JMenuItem(Translatrix.getTranslationString("SaveRTF") + menuDialog);  jmiSaveRTF.setActionCommand("savertf");   jmiSaveRTF.addActionListener(this);  jMenuFile.add(jmiSaveRTF);
-               JMenuItem jmiSaveB64   = new JMenuItem(Translatrix.getTranslationString("SaveB64") + menuDialog);  jmiSaveB64.setActionCommand("saveb64");   jmiSaveB64.addActionListener(this);  jMenuFile.add(jmiSaveB64);
-               jMenuFile.addSeparator();
-               JMenuItem jmiSerialOut = new JMenuItem(Translatrix.getTranslationString("Serialize") + menuDialog);   jmiSerialOut.setActionCommand("serialize");  jmiSerialOut.addActionListener(this); jMenuFile.add(jmiSerialOut);
-               JMenuItem jmiSerialIn  = new JMenuItem(Translatrix.getTranslationString("ReadFromSer") + menuDialog); jmiSerialIn.setActionCommand("readfromser"); jmiSerialIn.addActionListener(this);  jMenuFile.add(jmiSerialIn);
-               jMenuFile.addSeparator();
-               JMenuItem jmiExit      = new JMenuItem(Translatrix.getTranslationString("Exit")); jmiExit.setActionCommand("exit"); jmiExit.addActionListener(this); jMenuFile.add(jmiExit);
-
-               /* EDIT Menu */
-               jMenuEdit            = new JMenu(Translatrix.getTranslationString("Edit"));
-               htMenus.put(KEY_MENU_EDIT, jMenuEdit);
-               if(sysClipboard != null)
-               {
-                       // System Clipboard versions of menu commands
-                       JMenuItem jmiCut     = new JMenuItem(Translatrix.getTranslationString("Cut"));   jmiCut.setActionCommand("textcut");     jmiCut.addActionListener(this);   jmiCut.setAccelerator(KeyStroke.getKeyStroke('X', java.awt.Event.CTRL_MASK, false));   if(showMenuIcons) { jmiCut.setIcon(getEkitIcon("Cut")); }     jMenuEdit.add(jmiCut);
-                       JMenuItem jmiCopy    = new JMenuItem(Translatrix.getTranslationString("Copy"));  jmiCopy.setActionCommand("textcopy");   jmiCopy.addActionListener(this);  jmiCopy.setAccelerator(KeyStroke.getKeyStroke('C', java.awt.Event.CTRL_MASK, false));  if(showMenuIcons) { jmiCopy.setIcon(getEkitIcon("Copy")); }   jMenuEdit.add(jmiCopy);
-                       JMenuItem jmiPaste   = new JMenuItem(Translatrix.getTranslationString("Paste")); jmiPaste.setActionCommand("textpaste"); jmiPaste.addActionListener(this); jmiPaste.setAccelerator(KeyStroke.getKeyStroke('V', java.awt.Event.CTRL_MASK, false)); if(showMenuIcons) { jmiPaste.setIcon(getEkitIcon("Paste")); } jMenuEdit.add(jmiPaste);
-               }
-               else
-               {
-                       // DefaultEditorKit versions of menu commands
-                       JMenuItem jmiCut     = new JMenuItem(new DefaultEditorKit.CutAction());   jmiCut.setText(Translatrix.getTranslationString("Cut"));     jmiCut.setAccelerator(KeyStroke.getKeyStroke('X', java.awt.Event.CTRL_MASK, false));   if(showMenuIcons) { jmiCut.setIcon(getEkitIcon("Cut")); }     jMenuEdit.add(jmiCut);
-                       JMenuItem jmiCopy    = new JMenuItem(new DefaultEditorKit.CopyAction());  jmiCopy.setText(Translatrix.getTranslationString("Copy"));   jmiCopy.setAccelerator(KeyStroke.getKeyStroke('C', java.awt.Event.CTRL_MASK, false));  if(showMenuIcons) { jmiCopy.setIcon(getEkitIcon("Copy")); }   jMenuEdit.add(jmiCopy);
-                       JMenuItem jmiPaste   = new JMenuItem(new DefaultEditorKit.PasteAction()); jmiPaste.setText(Translatrix.getTranslationString("Paste")); jmiPaste.setAccelerator(KeyStroke.getKeyStroke('V', java.awt.Event.CTRL_MASK, false)); if(showMenuIcons) { jmiPaste.setIcon(getEkitIcon("Paste")); } jMenuEdit.add(jmiPaste);
-               }
-               jMenuEdit.addSeparator();
-               JMenuItem jmiUndo    = new JMenuItem(undoAction); jmiUndo.setAccelerator(KeyStroke.getKeyStroke('Z', java.awt.Event.CTRL_MASK, false)); jMenuEdit.add(jmiUndo);
-               JMenuItem jmiRedo    = new JMenuItem(redoAction); jmiRedo.setAccelerator(KeyStroke.getKeyStroke('Y', java.awt.Event.CTRL_MASK, false)); jMenuEdit.add(jmiRedo);
-               jMenuEdit.addSeparator();
-               JMenuItem jmiSelAll  = new JMenuItem((Action)actions.get(DefaultEditorKit.selectAllAction));       jmiSelAll.setText(Translatrix.getTranslationString("SelectAll"));        jmiSelAll.setAccelerator(KeyStroke.getKeyStroke('A', java.awt.Event.CTRL_MASK, false)); jMenuEdit.add(jmiSelAll);
-               JMenuItem jmiSelPara = new JMenuItem((Action)actions.get(DefaultEditorKit.selectParagraphAction)); jmiSelPara.setText(Translatrix.getTranslationString("SelectParagraph")); jMenuEdit.add(jmiSelPara);
-               JMenuItem jmiSelLine = new JMenuItem((Action)actions.get(DefaultEditorKit.selectLineAction));      jmiSelLine.setText(Translatrix.getTranslationString("SelectLine"));      jMenuEdit.add(jmiSelLine);
-               JMenuItem jmiSelWord = new JMenuItem((Action)actions.get(DefaultEditorKit.selectWordAction));      jmiSelWord.setText(Translatrix.getTranslationString("SelectWord"));      jMenuEdit.add(jmiSelWord);
-
-               /* VIEW Menu */
-               jMenuView        = new JMenu(Translatrix.getTranslationString("View"));
-               htMenus.put(KEY_MENU_VIEW, jMenuView);
-               jcbmiViewToolbar = new JCheckBoxMenuItem(Translatrix.getTranslationString("ViewToolbar"), false); jcbmiViewToolbar.setActionCommand("toggletoolbar"); jcbmiViewToolbar.addActionListener(this); jMenuView.add(jcbmiViewToolbar);
-               jcbmiViewSource  = new JCheckBoxMenuItem(Translatrix.getTranslationString("ViewSource"), false);  jcbmiViewSource.setActionCommand("viewsource");     jcbmiViewSource.addActionListener(this);  jMenuView.add(jcbmiViewSource);
-
-               /* FONT Menu */
-               jMenuFont              = new JMenu(Translatrix.getTranslationString("Font"));
-               htMenus.put(KEY_MENU_FONT, jMenuFont);
-               JMenuItem jmiBold      = new JMenuItem(actionFontBold);      jmiBold.setText(Translatrix.getTranslationString("FontBold"));           jmiBold.setAccelerator(KeyStroke.getKeyStroke('B', java.awt.Event.CTRL_MASK, false));      if(showMenuIcons) { jmiBold.setIcon(getEkitIcon("Bold")); }           jMenuFont.add(jmiBold);
-               JMenuItem jmiItalic    = new JMenuItem(actionFontItalic);    jmiItalic.setText(Translatrix.getTranslationString("FontItalic"));       jmiItalic.setAccelerator(KeyStroke.getKeyStroke('I', java.awt.Event.CTRL_MASK, false));    if(showMenuIcons) { jmiItalic.setIcon(getEkitIcon("Italic")); }       jMenuFont.add(jmiItalic);
-               JMenuItem jmiUnderline = new JMenuItem(actionFontUnderline); jmiUnderline.setText(Translatrix.getTranslationString("FontUnderline")); jmiUnderline.setAccelerator(KeyStroke.getKeyStroke('U', java.awt.Event.CTRL_MASK, false)); if(showMenuIcons) { jmiUnderline.setIcon(getEkitIcon("Underline")); } jMenuFont.add(jmiUnderline);
-               JMenuItem jmiStrike    = new JMenuItem(actionFontStrike);    jmiStrike.setText(Translatrix.getTranslationString("FontStrike"));                                                                                                  if(showMenuIcons) { jmiStrike.setIcon(getEkitIcon("Strike")); }       jMenuFont.add(jmiStrike);
-               jMenuFont.addSeparator();
-               jMenuFont.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("FormatBig"), HTML.Tag.BIG)));
-               jMenuFont.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("FormatSmall"), HTML.Tag.SMALL)));
-               JMenu jMenuFontSize = new JMenu(Translatrix.getTranslationString("FontSize"));
-                       String fontSizeKey = "size";
-                       customAttr = new Hashtable(); customAttr.put(fontSizeKey,"1");
-                       jMenuFontSize.add(new JMenuItem(new CustomAction(this, Translatrix.getTranslationString("FontSize1"), HTML.Tag.FONT, customAttr)));
-                       customAttr = new Hashtable(); customAttr.put(fontSizeKey,"2");
-                       jMenuFontSize.add(new JMenuItem(new CustomAction(this, Translatrix.getTranslationString("FontSize2"), HTML.Tag.FONT, customAttr)));
-                       customAttr = new Hashtable(); customAttr.put(fontSizeKey,"3");
-                       jMenuFontSize.add(new JMenuItem(new CustomAction(this, Translatrix.getTranslationString("FontSize3"), HTML.Tag.FONT, customAttr)));
-                       customAttr = new Hashtable(); customAttr.put(fontSizeKey,"4");
-                       jMenuFontSize.add(new JMenuItem(new CustomAction(this, Translatrix.getTranslationString("FontSize4"), HTML.Tag.FONT, customAttr)));
-                       customAttr = new Hashtable(); customAttr.put(fontSizeKey,"5");
-                       jMenuFontSize.add(new JMenuItem(new CustomAction(this, Translatrix.getTranslationString("FontSize5"), HTML.Tag.FONT, customAttr)));
-                       customAttr = new Hashtable(); customAttr.put(fontSizeKey,"6");
-                       jMenuFontSize.add(new JMenuItem(new CustomAction(this, Translatrix.getTranslationString("FontSize6"), HTML.Tag.FONT, customAttr)));
-                       customAttr = new Hashtable(); customAttr.put(fontSizeKey,"7");
-                       jMenuFontSize.add(new JMenuItem(new CustomAction(this, Translatrix.getTranslationString("FontSize7"), HTML.Tag.FONT, customAttr)));
-               jMenuFont.add(jMenuFontSize);
-               jMenuFont.addSeparator();
-               JMenuItem jmiSupscript = new JMenuItem(actionFontSuperscript); if(showMenuIcons) { jmiSupscript.setIcon(getEkitIcon("Super")); } jMenuFont.add(jmiSupscript);
-               JMenuItem jmiSubscript = new JMenuItem(actionFontSubscript);   if(showMenuIcons) { jmiSubscript.setIcon(getEkitIcon("Sub")); }   jMenuFont.add(jmiSubscript);
-               jMenuFont.addSeparator();
-               JMenuItem jmiSerif      = new JMenuItem((Action)actions.get("font-family-Serif"));      jmiSerif.setText(Translatrix.getTranslationString("FontSerif"));           jMenuFont.add(jmiSerif);
-               JMenuItem jmiSansSerif  = new JMenuItem((Action)actions.get("font-family-SansSerif"));  jmiSansSerif.setText(Translatrix.getTranslationString("FontSansserif"));   jMenuFont.add(jmiSansSerif);
-               JMenuItem jmiMonospaced = new JMenuItem((Action)actions.get("font-family-Monospaced")); jmiMonospaced.setText(Translatrix.getTranslationString("FontMonospaced")); jMenuFont.add(jmiMonospaced);
-               JMenuItem jmiSelectFont = new JMenuItem(actionSelectFont);                                                                                                         jMenuFont.add(jmiSelectFont);
-               jMenuFont.addSeparator();
-               JMenu jMenuFontColor = new JMenu(Translatrix.getTranslationString("Color"));
-                       customAttr = new Hashtable(); customAttr.put("color","black");
-                       jMenuFontColor.add(new JMenuItem(new CustomAction(this, Translatrix.getTranslationString("CustomColor") + menuDialog, HTML.Tag.FONT, customAttr)));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorAqua"),    new Color(  0,255,255))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorBlack"),   new Color(  0,  0,  0))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorBlue"),    new Color(  0,  0,255))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorFuschia"), new Color(255,  0,255))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorGray"),    new Color(128,128,128))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorGreen"),   new Color(  0,128,  0))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorLime"),    new Color(  0,255,  0))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorMaroon"),  new Color(128,  0,  0))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorNavy"),    new Color(  0,  0,128))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorOlive"),   new Color(128,128,  0))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorPurple"),  new Color(128,  0,128))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorRed"),     new Color(255,  0,  0))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorSilver"),  new Color(192,192,192))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorTeal"),    new Color(  0,128,128))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorWhite"),   new Color(255,255,255))));
-                       jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction(Translatrix.getTranslationString("ColorYellow"),  new Color(255,255,  0))));
-               jMenuFont.add(jMenuFontColor);
-
-               /* FORMAT Menu */
-               jMenuFormat            = new JMenu(Translatrix.getTranslationString("Format"));
-               htMenus.put(KEY_MENU_FORMAT, jMenuFormat);
-               JMenu jMenuFormatAlign = new JMenu(Translatrix.getTranslationString("Align"));
-                       jMenuFormatAlign.add(new JMenuItem(new StyledEditorKit.AlignmentAction(Translatrix.getTranslationString("AlignLeft"), StyleConstants.ALIGN_LEFT)));
-                       jMenuFormatAlign.add(new JMenuItem(new StyledEditorKit.AlignmentAction(Translatrix.getTranslationString("AlignCenter"), StyleConstants.ALIGN_CENTER)));
-                       jMenuFormatAlign.add(new JMenuItem(new StyledEditorKit.AlignmentAction(Translatrix.getTranslationString("AlignRight"), StyleConstants.ALIGN_RIGHT)));
-                       jMenuFormatAlign.add(new JMenuItem(new StyledEditorKit.AlignmentAction(Translatrix.getTranslationString("AlignJustified"), StyleConstants.ALIGN_JUSTIFIED)));
-               jMenuFormat.add(jMenuFormatAlign);
-               jMenuFormat.addSeparator();
-               JMenu jMenuFormatHeading = new JMenu(Translatrix.getTranslationString("Heading"));
-                       jMenuFormatHeading.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("Heading1"), HTML.Tag.H1)));
-                       jMenuFormatHeading.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("Heading2"), HTML.Tag.H2)));
-                       jMenuFormatHeading.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("Heading3"), HTML.Tag.H3)));
-                       jMenuFormatHeading.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("Heading4"), HTML.Tag.H4)));
-                       jMenuFormatHeading.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("Heading5"), HTML.Tag.H5)));
-                       jMenuFormatHeading.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("Heading6"), HTML.Tag.H6)));
-               jMenuFormat.add(jMenuFormatHeading);
-               jMenuFormat.addSeparator();
-               JMenuItem jmiUList = new JMenuItem(actionListUnordered); if(showMenuIcons) { jmiUList.setIcon(getEkitIcon("UList")); } jMenuFormat.add(jmiUList);
-               JMenuItem jmiOList = new JMenuItem(actionListOrdered);   if(showMenuIcons) { jmiOList.setIcon(getEkitIcon("OList")); } jMenuFormat.add(jmiOList);
-               jMenuFormat.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("ListItem"), HTML.Tag.LI)));
-               jMenuFormat.addSeparator();
-               jMenuFormat.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("FormatBlockquote"), HTML.Tag.BLOCKQUOTE)));
-               jMenuFormat.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("FormatPre"), HTML.Tag.PRE)));
-               jMenuFormat.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("FormatStrong"), HTML.Tag.STRONG)));
-               jMenuFormat.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("FormatEmphasis"), HTML.Tag.EM)));
-               jMenuFormat.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("FormatTT"), HTML.Tag.TT)));
-               jMenuFormat.add(new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("FormatSpan"), HTML.Tag.SPAN)));
-               jMenuFormat.addSeparator();
-               JMenuItem jmiClearStyles = new JMenuItem(actionClearFormat); if(showMenuIcons) { jmiClearStyles.setIcon(getEkitIcon("ClearFormat")); }; jMenuFormat.add(jmiClearStyles);
-
-               /* INSERT Menu */
-               jMenuInsert              = new JMenu(Translatrix.getTranslationString("Insert"));
-               htMenus.put(KEY_MENU_INSERT, jMenuInsert);
-               jMenuInsert.add(new JMenuItem(actionInsertAnchor));
-               JMenuItem jmiBreak       = new JMenuItem(Translatrix.getTranslationString("InsertBreak"));                    jmiBreak.setActionCommand("insertbreak"); jmiBreak.addActionListener(this); jmiBreak.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, java.awt.Event.SHIFT_MASK, false)); jMenuInsert.add(jmiBreak);
-               JMenuItem jmiNBSP        = new JMenuItem(Translatrix.getTranslationString("InsertNBSP"));                     jmiNBSP.setActionCommand("insertnbsp");   jmiNBSP.addActionListener(this);  jMenuInsert.add(jmiNBSP);
-               JMenuItem jmiHRule       = new JMenuItem((Action)actions.get("InsertHR"));                                    jmiHRule.setText(Translatrix.getTranslationString("InsertHorizontalRule")); jMenuInsert.add(jmiHRule);
-               jMenuInsert.addSeparator();
-               JMenuItem jmiImageLocal  = new JMenuItem(Translatrix.getTranslationString("InsertLocalImage") + menuDialog);  jmiImageLocal.setActionCommand("insertlocalimage"); jmiImageLocal.addActionListener(this); jMenuInsert.add(jmiImageLocal);
-               JMenuItem jmiImageServer = new JMenuItem(Translatrix.getTranslationString("InsertServerImage") + menuDialog); jmiImageServer.setActionCommand("insertserverimage"); jmiImageServer.addActionListener(this); jMenuInsert.add(jmiImageServer);
-
-               /* TABLE Menu */
-               jMenuTable              = new JMenu(Translatrix.getTranslationString("Table"));
-               htMenus.put(KEY_MENU_TABLE, jMenuTable);
-               JMenuItem jmiTable       = new JMenuItem(Translatrix.getTranslationString("InsertTable") + menuDialog); jmiTable.setActionCommand("inserttable");             jmiTable.addActionListener(this);       jMenuTable.add(jmiTable);
-               jMenuTable.addSeparator();
-               JMenuItem jmiTableRow    = new JMenuItem(Translatrix.getTranslationString("InsertTableRow"));           jmiTableRow.setActionCommand("inserttablerow");       jmiTableRow.addActionListener(this);    jMenuTable.add(jmiTableRow);
-               JMenuItem jmiTableCol    = new JMenuItem(Translatrix.getTranslationString("InsertTableColumn"));        jmiTableCol.setActionCommand("inserttablecolumn");    jmiTableCol.addActionListener(this);    jMenuTable.add(jmiTableCol);
-               jMenuTable.addSeparator();
-               JMenuItem jmiTableRowDel = new JMenuItem(Translatrix.getTranslationString("DeleteTableRow"));           jmiTableRowDel.setActionCommand("deletetablerow");    jmiTableRowDel.addActionListener(this); jMenuTable.add(jmiTableRowDel);
-               JMenuItem jmiTableColDel = new JMenuItem(Translatrix.getTranslationString("DeleteTableColumn"));        jmiTableColDel.setActionCommand("deletetablecolumn"); jmiTableColDel.addActionListener(this); jMenuTable.add(jmiTableColDel);
-
-               /* FORMS Menu */
-               jMenuForms                    = new JMenu(Translatrix.getTranslationString("Forms"));
-               htMenus.put(KEY_MENU_FORMS, jMenuForms);
-               JMenuItem jmiFormInsertForm   = new JMenuItem(Translatrix.getTranslationString("FormInsertForm")); jmiFormInsertForm.setActionCommand("insertform");     jmiFormInsertForm.addActionListener(this); jMenuForms.add(jmiFormInsertForm);
-               jMenuForms.addSeparator();
-               JMenuItem jmiFormTextfield    = new JMenuItem(Translatrix.getTranslationString("FormTextfield"));  jmiFormTextfield.setActionCommand("inserttextfield"); jmiFormTextfield.addActionListener(this);  jMenuForms.add(jmiFormTextfield);
-               JMenuItem jmiFormTextarea     = new JMenuItem(Translatrix.getTranslationString("FormTextarea"));   jmiFormTextarea.setActionCommand("inserttextarea");   jmiFormTextarea.addActionListener(this);   jMenuForms.add(jmiFormTextarea);
-               JMenuItem jmiFormCheckbox     = new JMenuItem(Translatrix.getTranslationString("FormCheckbox"));   jmiFormCheckbox.setActionCommand("insertcheckbox");   jmiFormCheckbox.addActionListener(this);   jMenuForms.add(jmiFormCheckbox);
-               JMenuItem jmiFormRadio        = new JMenuItem(Translatrix.getTranslationString("FormRadio"));      jmiFormRadio.setActionCommand("insertradiobutton");   jmiFormRadio.addActionListener(this);      jMenuForms.add(jmiFormRadio);
-               JMenuItem jmiFormPassword     = new JMenuItem(Translatrix.getTranslationString("FormPassword"));   jmiFormPassword.setActionCommand("insertpassword");   jmiFormPassword.addActionListener(this);   jMenuForms.add(jmiFormPassword);
-               jMenuForms.addSeparator();
-               JMenuItem jmiFormButton       = new JMenuItem(Translatrix.getTranslationString("FormButton"));       jmiFormButton.setActionCommand("insertbutton");             jmiFormButton.addActionListener(this);       jMenuForms.add(jmiFormButton);
-               JMenuItem jmiFormButtonSubmit = new JMenuItem(Translatrix.getTranslationString("FormButtonSubmit")); jmiFormButtonSubmit.setActionCommand("insertbuttonsubmit"); jmiFormButtonSubmit.addActionListener(this); jMenuForms.add(jmiFormButtonSubmit);
-               JMenuItem jmiFormButtonReset  = new JMenuItem(Translatrix.getTranslationString("FormButtonReset"));  jmiFormButtonReset.setActionCommand("insertbuttonreset");   jmiFormButtonReset.addActionListener(this);  jMenuForms.add(jmiFormButtonReset);
-
-               /* SEARCH Menu */
-               jMenuSearch            = new JMenu(Translatrix.getTranslationString("Search"));
-               htMenus.put(KEY_MENU_SEARCH, jMenuSearch);
-               JMenuItem jmiFind      = new JMenuItem(Translatrix.getTranslationString("SearchFind"));      jmiFind.setActionCommand("find");           jmiFind.addActionListener(this);      jmiFind.setAccelerator(KeyStroke.getKeyStroke('F', java.awt.Event.CTRL_MASK, false));      jMenuSearch.add(jmiFind);
-               JMenuItem jmiFindAgain = new JMenuItem(Translatrix.getTranslationString("SearchFindAgain")); jmiFindAgain.setActionCommand("findagain"); jmiFindAgain.addActionListener(this); jmiFindAgain.setAccelerator(KeyStroke.getKeyStroke('G', java.awt.Event.CTRL_MASK, false)); jMenuSearch.add(jmiFindAgain);
-               JMenuItem jmiReplace   = new JMenuItem(Translatrix.getTranslationString("SearchReplace"));   jmiReplace.setActionCommand("replace");     jmiReplace.addActionListener(this);   jmiReplace.setAccelerator(KeyStroke.getKeyStroke('R', java.awt.Event.CTRL_MASK, false));   jMenuSearch.add(jmiReplace);
-
-               /* TOOLS Menu */
-               jMenuTools = new JMenu(Translatrix.getTranslationString("Tools"));
-               htMenus.put(KEY_MENU_TOOLS, jMenuTools);
-               JMenuItem jmiSpellcheck = new JMenuItem(Translatrix.getTranslationString("ToolSpellcheck")); jmiSpellcheck.setActionCommand("spellcheck"); jmiSpellcheck.addActionListener(this); jMenuTools.add(jmiSpellcheck);
-
-               /* HELP Menu */
-               jMenuHelp = new JMenu(Translatrix.getTranslationString("Help"));
-               htMenus.put(KEY_MENU_HELP, jMenuHelp);
-               JMenuItem jmiAbout = new JMenuItem(Translatrix.getTranslationString("About")); jmiAbout.setActionCommand("helpabout"); jmiAbout.addActionListener(this); jMenuHelp.add(jmiAbout);
-
-               /* DEBUG Menu */
-               jMenuDebug           = new JMenu(Translatrix.getTranslationString("Debug"));
-               htMenus.put(KEY_MENU_DEBUG, jMenuDebug);
-               JMenuItem jmiDesc    = new JMenuItem(Translatrix.getTranslationString("DescribeDoc")); jmiDesc.setActionCommand("describe");       jmiDesc.addActionListener(this);    jMenuDebug.add(jmiDesc);
-               JMenuItem jmiDescCSS = new JMenuItem(Translatrix.getTranslationString("DescribeCSS")); jmiDescCSS.setActionCommand("describecss"); jmiDescCSS.addActionListener(this); jMenuDebug.add(jmiDescCSS);
-               JMenuItem jmiTag     = new JMenuItem(Translatrix.getTranslationString("WhatTags"));    jmiTag.setActionCommand("whattags");        jmiTag.addActionListener(this);     jMenuDebug.add(jmiTag);
-
-               /* Create menubar and add menus */
-               jMenuBar = new JMenuBar();
-               jMenuBar.add(jMenuFile);
-               jMenuBar.add(jMenuEdit);
-               jMenuBar.add(jMenuView);
-               jMenuBar.add(jMenuFont);
-               jMenuBar.add(jMenuFormat);
-               jMenuBar.add(jMenuSearch);
-               jMenuBar.add(jMenuInsert);
-               jMenuBar.add(jMenuTable);
-               jMenuBar.add(jMenuForms);
-               jMenuBar.add(jMenuTools);
-               jMenuBar.add(jMenuHelp);
-               if(debugMode)
-               {
-                       jMenuBar.add(jMenuDebug);
-               }
-
-               /* Create the toolbar */
-               jToolBar = new JToolBar(JToolBar.HORIZONTAL);
-               jToolBar.setFloatable(false);
-               jbtnNewHTML     = new JButtonNoFocus(getEkitIcon("New"));  jbtnNewHTML.setToolTipText(Translatrix.getTranslationString("NewDocument"));   jbtnNewHTML.setActionCommand("newdoc");    jbtnNewHTML.addActionListener(this);  jToolBar.add(jbtnNewHTML);  htTools.put(KEY_TOOL_NEW, jbtnNewHTML);
-               jbtnOpenHTML    = new JButtonNoFocus(getEkitIcon("Open")); jbtnOpenHTML.setToolTipText(Translatrix.getTranslationString("OpenDocument")); jbtnOpenHTML.setActionCommand("openhtml"); jbtnOpenHTML.addActionListener(this); jToolBar.add(jbtnOpenHTML); htTools.put(KEY_TOOL_OPEN, jbtnOpenHTML);
-               jbtnSaveHTML    = new JButtonNoFocus(getEkitIcon("Save")); jbtnSaveHTML.setToolTipText(Translatrix.getTranslationString("SaveDocument")); jbtnSaveHTML.setActionCommand("saveas");   jbtnSaveHTML.addActionListener(this); jToolBar.add(jbtnSaveHTML); htTools.put(KEY_TOOL_SAVE, jbtnSaveHTML);
-               jToolBar.add(new JToolBar.Separator());
-               jbtnCut         = new JButtonNoFocus(new DefaultEditorKit.CutAction());   jbtnCut.setIcon(getEkitIcon("Cut"));     jbtnCut.setText(null);   jbtnCut.setToolTipText(Translatrix.getTranslationString("Cut"));     jToolBar.add(jbtnCut);   htTools.put(KEY_TOOL_CUT, jbtnCut);
-               jbtnCopy        = new JButtonNoFocus(new DefaultEditorKit.CopyAction());  jbtnCopy.setIcon(getEkitIcon("Copy"));   jbtnCopy.setText(null);  jbtnCopy.setToolTipText(Translatrix.getTranslationString("Copy"));   jToolBar.add(jbtnCopy);  htTools.put(KEY_TOOL_COPY, jbtnCopy);
-               jbtnPaste       = new JButtonNoFocus(new DefaultEditorKit.PasteAction()); jbtnPaste.setIcon(getEkitIcon("Paste")); jbtnPaste.setText(null); jbtnPaste.setToolTipText(Translatrix.getTranslationString("Paste")); jToolBar.add(jbtnPaste); htTools.put(KEY_TOOL_PASTE, jbtnPaste);
-               jToolBar.add(new JToolBar.Separator());
-               jbtnBold        = new JButtonNoFocus(actionFontBold);        jbtnBold.setIcon(getEkitIcon("Bold"));               jbtnBold.setText(null);        jbtnBold.setToolTipText(Translatrix.getTranslationString("FontBold"));                 jToolBar.add(jbtnBold);        htTools.put(KEY_TOOL_BOLD, jbtnBold);
-               jbtnItalic      = new JButtonNoFocus(actionFontItalic);      jbtnItalic.setIcon(getEkitIcon("Italic"));           jbtnItalic.setText(null);      jbtnItalic.setToolTipText(Translatrix.getTranslationString("FontItalic"));             jToolBar.add(jbtnItalic);      htTools.put(KEY_TOOL_ITALIC, jbtnItalic);
-               jbtnUnderline   = new JButtonNoFocus(actionFontUnderline);   jbtnUnderline.setIcon(getEkitIcon("Underline"));     jbtnUnderline.setText(null);   jbtnUnderline.setToolTipText(Translatrix.getTranslationString("FontUnderline"));       jToolBar.add(jbtnUnderline);   htTools.put(KEY_TOOL_UNDERLINE, jbtnUnderline);
-               jbtnStrike      = new JButtonNoFocus(actionFontStrike);      jbtnStrike.setIcon(getEkitIcon("Strike"));           jbtnStrike.setText(null);      jbtnStrike.setToolTipText(Translatrix.getTranslationString("FontStrike"));             jToolBar.add(jbtnStrike);      htTools.put(KEY_TOOL_STRIKE, jbtnStrike);
-               jbtnSuperscript = new JButtonNoFocus(actionFontSuperscript); jbtnSuperscript.setIcon(getEkitIcon("Super"));       jbtnSuperscript.setText(null); jbtnSuperscript.setToolTipText(Translatrix.getTranslationString("FontSuperscript")); jToolBar.add(jbtnSuperscript);   htTools.put(KEY_TOOL_SUPER, jbtnSuperscript);
-               jbtnSubscript   = new JButtonNoFocus(actionFontSubscript);   jbtnSubscript.setIcon(getEkitIcon("Sub"));           jbtnSubscript.setText(null);   jbtnSubscript.setToolTipText(Translatrix.getTranslationString("FontSubscript"));     jToolBar.add(jbtnSubscript);     htTools.put(KEY_TOOL_SUB, jbtnSubscript);
-               jbtnUList       = new JButtonNoFocus(actionListUnordered);   jbtnUList.setIcon(getEkitIcon("UList"));             jbtnUList.setText(null);       jbtnUList.setToolTipText(Translatrix.getTranslationString("ListUnordered"));           jToolBar.add(jbtnUList);       htTools.put(KEY_TOOL_ULIST, jbtnUList);
-               jbtnOList       = new JButtonNoFocus(actionListOrdered);     jbtnOList.setIcon(getEkitIcon("OList"));             jbtnOList.setText(null);       jbtnOList.setToolTipText(Translatrix.getTranslationString("ListOrdered"));             jToolBar.add(jbtnOList);       htTools.put(KEY_TOOL_OLIST, jbtnOList);
-               jbtnClearFormat = new JButtonNoFocus(actionClearFormat);     jbtnClearFormat.setIcon(getEkitIcon("ClearFormat")); jbtnClearFormat.setText(null); jbtnClearFormat.setToolTipText(Translatrix.getTranslationString("FormatClear"));       jToolBar.add(jbtnClearFormat); htTools.put(KEY_TOOL_CLEAR, jbtnClearFormat);
-               jToolBar.add(new JToolBar.Separator());
-               jbtnAnchor      = new JButtonNoFocus(actionInsertAnchor); jbtnAnchor.setIcon(getEkitIcon("Anchor")); jbtnAnchor.setText(null); jbtnAnchor.setToolTipText(Translatrix.getTranslationString("ToolAnchor")); jToolBar.add(jbtnAnchor); htTools.put(KEY_TOOL_ANCHOR, jbtnAnchor);
-               jToolBar.add(new JToolBar.Separator());
-               jtbtnViewSource = new JToggleButtonNoFocus(getEkitIcon("Source")); jtbtnViewSource.setText(null); jtbtnViewSource.setToolTipText(Translatrix.getTranslationString("ViewSource")); jtbtnViewSource.setActionCommand("viewsource"); jtbtnViewSource.addActionListener(this); jtbtnViewSource.setPreferredSize(jbtnAnchor.getPreferredSize()); jtbtnViewSource.setMinimumSize(jbtnAnchor.getMinimumSize()); jtbtnViewSource.setMaximumSize(jbtnAnchor.getMaximumSize()); jToolBar.add(jtbtnViewSource); htTools.put(KEY_TOOL_SOURCE, jtbtnViewSource);
-               jToolBar.add(new JToolBar.Separator());
-               jcmbStyleSelector = new JComboBoxNoFocus(); jToolBar.add(jcmbStyleSelector); jcmbStyleSelector.setAction(new StylesAction(jcmbStyleSelector)); htTools.put(KEY_TOOL_STYLES, jcmbStyleSelector);
-
-               /* Create the scroll area for the text pane */
-               JScrollPane jspViewport = new JScrollPane(jtpMain);
-               jspViewport.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
-               jspViewport.setPreferredSize(new Dimension(400, 400));
-               jspViewport.setMinimumSize(new Dimension(32, 32));
-
-               /* Create the scroll area for the source viewer */
-               jspSource = new JScrollPane(jtpSource);
-               jspSource.setPreferredSize(new Dimension(400, 100));
-               jspSource.setMinimumSize(new Dimension(32, 32));
-
-               jspltDisplay = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
-               jspltDisplay.setTopComponent(jspViewport);
-               if(showViewSource)
-               {
-                       jspltDisplay.setBottomComponent(jspSource);
-               }
-               else
-               {
-                       jspltDisplay.setBottomComponent(null);
-               }
-
-               iSplitPos = jspltDisplay.getDividerLocation();
-
-               registerDocumentStyles();
-
-               /* Create spell checker */
-               try
-               {
-                       dictFile = Translatrix.getTranslationString("DictionaryFile");
-                       SpellDictionary dictionary = new SpellDictionary(dictFile); // uses my custom loader in SpellDictionary
-                       spellCheck = new SpellChecker(dictionary);
-                       spellCheck.addSpellCheckListener(this);
-               }
-               catch(Exception e)
-               {
-                       e.printStackTrace();
-               }
-               spellDialog = new JSpellDialog(this.getFrame(), Translatrix.getTranslationString("ToolSpellcheckDialog"), true);
-
-               /* Add the components to the app */
-               this.setLayout(new BorderLayout());
-               this.add(jspltDisplay, BorderLayout.CENTER);
-       }
-
-       /** Common Constructor
-         * @param sDocument         [String]  A text or HTML document to load in the editor upon startup.
-         * @param sStyleSheet       [String]  A CSS stylesheet to load in the editor upon startup.
-         * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
-         * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
-         * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
-         * @param sLanguage         [String]  The language portion of the Internationalization Locale to run Ekit in.
-         * @param sCountry          [String]  The country portion of the Internationalization Locale to run Ekit in.
-         */
-       public EkitCore(String sDocument, String sStyleSheet, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64)
-       {
-               this(sDocument, sStyleSheet, null, null, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false);
-       }
-
-       /** Default Language Constructor
-         * @param sDocument         [String]  A text or HTML document to load in the editor upon startup.
-         * @param sStyleSheet       [String]  A CSS stylesheet to load in the editor upon startup.
-         * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
-         * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
-         * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
-         */
-       public EkitCore(String sDocument, String sStyleSheet, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, boolean base64)
-       {
-               this(sDocument, sStyleSheet, null, null, showViewSource, showMenuIcons, editModeExclusive, null, null, base64, false);
-       }
-
-       /** Raw/Base64 Document & Style Sheet URL Constructor (Ideal for EkitApplet)
-         * @param sRawDocument      [String]  A document encoded as a String to load in the editor upon startup.
-         * @param sRawDocument      [String]  A document encoded as a String to load in the editor upon startup.
-         * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
-         * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
-         * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
-         * @param sLanguage         [String]  The language portion of the Internationalization Locale to run Ekit in.
-         * @param sCountry          [String]  The country portion of the Internationalization Locale to run Ekit in.
-         */
-       public EkitCore(String sRawDocument, URL urlStyleSheet, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64)
-       {
-               this(null, null, sRawDocument, urlStyleSheet, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false);
-       }
-
-       /** Document Constructor
-         * @param sRawDocument      [String]  A document encoded as a String to load in the editor upon startup.
-         * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
-         * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
-         * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
-         * @param sLanguage         [String]  The language portion of the Internationalization Locale to run Ekit in.
-         * @param sCountry          [String]  The country portion of the Internationalization Locale to run Ekit in.
-         */
-       public EkitCore(String sRawDocument, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64)
-       {
-               this(null, null, sRawDocument, null, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false);
-       }
-
-       /** Default Language & Document Constructor
-         * @param sRawDocument      [String]  A document encoded as a String to load in the editor upon startup.
-         * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
-         * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
-         * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
-         */
-       public EkitCore(String sRawDocument, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, boolean base64)
-       {
-               this(null, null, sRawDocument, null, showViewSource, showMenuIcons, editModeExclusive, null, null, base64, false);
-       }
-
-       /** Flags & Language Constructor
-         * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
-         * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
-         * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
-         * @param sLanguage         [String]  The language portion of the Internationalization Locale to run Ekit in.
-         * @param sCountry          [String]  The country portion of the Internationalization Locale to run Ekit in.
-         */
-       public EkitCore(boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry)
-       {
-               this(null, null, null, null, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, false, false);
-       }
-
-       /** Flags Constructor
-         * @param showViewSource    [boolean] Specifies whether or not to show the View Source window on startup.
-         * @param showMenuIcons     [boolean] Specifies whether or not to show icon pictures in menus.
-         * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
-         */
-       public EkitCore(boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive)
-       {
-               this(null, null, null, null, showViewSource, showMenuIcons, editModeExclusive, null, null, false, false);
-       }
-
-       /** Language & Debug Constructor
-         * @param sLanguage [String]  The language portion of the Internationalization Locale to run Ekit in.
-         * @param sCountry  [String]  The country portion of the Internationalization Locale to run Ekit in.
-         * @param debugMode [boolean] Specifies whether to show the Debug menu or not.
-         */
-       public EkitCore(String sLanguage, String sCountry, boolean debugMode)
-       {
-               this(null, null, null, null, false, true, true, sLanguage, sCountry, false, debugMode);
-       }
-
-       /** Language Constructor
-         * @param sLanguage [String]  The language portion of the Internationalization Locale to run Ekit in.
-         * @param sCountry  [String]  The country portion of the Internationalization Locale to run Ekit in.
-         */
-       public EkitCore(String sLanguage, String sCountry)
-       {
-               this(null, null, null, null, false, true, true, sLanguage, sCountry, false, false);
-       }
-
-       /** Debug Constructor
-         * @param debugMode [boolean] Specifies whether to show the Debug menu or not.
-         */
-       public EkitCore(boolean debugMode)
-       {
-               this(null, null, null, null, false, true, true, null, null, false, debugMode);
-       }
-
-       /** Empty Constructor
-         */
-       public EkitCore()
-       {
-               this(null, null, null, null, false, true, true, null, null, false, false);
-       }
-
-       /* ActionListener method */
-       public void actionPerformed(ActionEvent ae)
-       {
-               try
-               {
-                       String command = ae.getActionCommand();
-                       if(command.equals("newdoc"))
-                       {
-                               SimpleInfoDialog sidAsk = new SimpleInfoDialog(this.getFrame(), "", true, Translatrix.getTranslationString("AskNewDocument"), SimpleInfoDialog.QUESTION);
-                               String decision = sidAsk.getDecisionValue();
-                               if(decision.equals(Translatrix.getTranslationString("DialogAccept")))
-                               {
-                                       if(styleSheet != null)
-                                       {
-                                               htmlDoc = new ExtendedHTMLDocument(styleSheet);
-                                       }
-                                       else
-                                       {
-                                               htmlDoc = (ExtendedHTMLDocument)(htmlKit.createDefaultDocument());
-                                       }
-                                       jtpMain.setText("<HTML><BODY></BODY></HTML>");
-                                       jtpSource.setText(jtpMain.getText());
-                                       registerDocument(htmlDoc);
-                                       currentFile = null;
-                                       updateTitle();
-                               }
-                       }
-                       else if(command.equals("openhtml"))
-                       {
-                               openDocument(null);
-                       }
-                       else if(command.equals("opencss"))
-                       {
-                               openStyleSheet(null);
-                       }
-                       else if(command.equals("openb64"))
-                       {
-                               openDocumentBase64(null);
-                       }
-                       else if(command.equals("save"))
-                       {
-                               writeOut((HTMLDocument)(jtpMain.getDocument()), currentFile);
-                               updateTitle();
-                       }
-                       else if(command.equals("saveas"))
-                       {
-                               writeOut((HTMLDocument)(jtpMain.getDocument()), null);
-                       }
-                       else if(command.equals("savebody"))
-                       {
-                               writeOutFragment((HTMLDocument)(jtpMain.getDocument()),"body");
-                       }
-                       else if(command.equals("savertf"))
-                       {
-                               writeOutRTF((StyledDocument)(jtpMain.getStyledDocument()));
-                       }
-                       else if(command.equals("saveb64"))
-                       {
-                               writeOutBase64(jtpSource.getText());
-                       }
-                       else if(command.equals("textcut"))
-                       {
-                               if(jspSource.isShowing() && jtpSource.hasFocus())
-                               {
-                                       jtpSource.cut();
-                               }
-                               else
-                               {
-                                       jtpMain.cut();
-                               }
-                       }
-                       else if(command.equals("textcopy"))
-                       {
-                               if(jspSource.isShowing() && jtpSource.hasFocus())
-                               {
-                                       jtpSource.copy();
-                               }
-                               else
-                               {
-                                       jtpMain.copy();
-                               }
-                       }
-                       else if(command.equals("textpaste"))
-                       {
-                               if(jspSource.isShowing() && jtpSource.hasFocus())
-                               {
-                                       jtpSource.paste();
-                               }
-                               else
-                               {
-                                       jtpMain.paste();
-                               }
-                       }
-                       else if(command.equals("describe"))
-                       {
-                               System.out.println("------------DOCUMENT------------");
-                               System.out.println("Content Type : " + jtpMain.getContentType());
-                               System.out.println("Editor Kit   : " + jtpMain.getEditorKit());
-                               System.out.println("Doc Tree     :");
-                               System.out.println("");
-                               describeDocument(jtpMain.getStyledDocument());
-                               System.out.println("--------------------------------");
-                               System.out.println("");
-                       }
-                       else if(command.equals("describecss"))
-                       {
-                               System.out.println("-----------STYLESHEET-----------");
-                               System.out.println("Stylesheet Rules");
-                               Enumeration rules = styleSheet.getStyleNames();
-                               while(rules.hasMoreElements())
-                               {
-                                       String ruleName = (String)(rules.nextElement());
-                                       Style styleRule = styleSheet.getStyle(ruleName);
-                                       System.out.println(styleRule.toString());
-                               }
-                               System.out.println("--------------------------------");
-                               System.out.println("");
-                       }
-                       else if(command.equals("whattags"))
-                       {
-                               System.out.println("Caret Position : " + jtpMain.getCaretPosition());
-                               AttributeSet attribSet = jtpMain.getCharacterAttributes();
-                               Enumeration attribs = attribSet.getAttributeNames();
-                               System.out.println("Attributes     : ");
-                               while(attribs.hasMoreElements())
-                               {
-                                       String attribName = attribs.nextElement().toString();
-                                       System.out.println("                 " + attribName + " | " + attribSet.getAttribute(attribName));
-                               }
-                       }
-                       else if(command.equals("toggletoolbar"))
-                       {
-                               jToolBar.setVisible(jcbmiViewToolbar.isSelected());
-                       }
-                       else if(command.equals("viewsource"))
-                       {
-                               toggleSourceWindow();
-                       }
-                       else if(command.equals("serialize"))
-                       {
-                               serializeOut((HTMLDocument)(jtpMain.getDocument()));
-                       }
-                       else if(command.equals("readfromser"))
-                       {
-                               serializeIn();
-                       }
-                       else if(command.equals("inserttable"))
-                       {
-                               String[] fieldNames = { "rows", "cols", "border", "cellspacing", "cellpadding", "width" };
-                               String[] fieldTypes = { "text", "text", "text",   "text",        "text",        "text" };
-                               insertTable((Hashtable)null, fieldNames, fieldTypes);
-                       }
-                       else if(command.equals("inserttablerow"))
-                       {
-                               insertTableRow();
-                       }
-                       else if(command.equals("inserttablecolumn"))
-                       {
-                               insertTableColumn();
-                       }
-                       else if(command.equals("deletetablerow"))
-                       {
-                               deleteTableRow();
-                       }
-                       else if(command.equals("deletetablecolumn"))
-                       {
-                               deleteTableColumn();
-                       }
-                       else if(command.equals("insertbreak"))
-                       {
-                               insertBreak();
-                       }
-                       else if(command.equals("insertlocalimage"))
-                       {
-                               insertLocalImage(null);
-                       }
-                       else if(command.equals("insertserverimage"))
-                       {
-                               insertServerImage();
-                       }
-                       else if(command.equals("insertnbsp"))
-                       {
-                               insertNonbreakingSpace();
-                       }
-                       else if(command.equals("insertform"))
-                       {
-                               String[] fieldNames  = { "name", "method",   "enctype" };
-                               String[] fieldTypes  = { "text", "combo",    "text" };
-                               String[] fieldValues = { "",     "POST,GET", "text" };
-                               insertFormElement(HTML.Tag.FORM, "form", (Hashtable)null, fieldNames, fieldTypes, fieldValues, true);
-                       }
-                       else if(command.equals("inserttextfield"))
-                       {
-                               Hashtable htAttribs = new Hashtable();
-                               htAttribs.put("type", "text");
-                               String[] fieldNames = { "name", "value", "size", "maxlength" };
-                               String[] fieldTypes = { "text", "text",  "text", "text" };
-                               insertFormElement(HTML.Tag.INPUT, "input", htAttribs, fieldNames, fieldTypes, false);
-                       }
-                       else if(command.equals("inserttextarea"))
-                       {
-                               String[] fieldNames = { "name", "rows", "cols" };
-                               String[] fieldTypes = { "text", "text", "text" };
-                               insertFormElement(HTML.Tag.TEXTAREA, "textarea", (Hashtable)null, fieldNames, fieldTypes, true);
-                       }
-                       else if(command.equals("insertcheckbox"))
-                       {
-                               Hashtable htAttribs = new Hashtable();
-                               htAttribs.put("type", "checkbox");
-                               String[] fieldNames = { "name", "checked" };
-                               String[] fieldTypes = { "text", "bool" };
-                               insertFormElement(HTML.Tag.INPUT, "input", htAttribs, fieldNames, fieldTypes, false);
-                       }
-                       else if(command.equals("insertradiobutton"))
-                       {
-                               Hashtable htAttribs = new Hashtable();
-                               htAttribs.put("type", "radio");
-                               String[] fieldNames = { "name", "checked" };
-                               String[] fieldTypes = { "text", "bool" };
-                               insertFormElement(HTML.Tag.INPUT, "input", htAttribs, fieldNames, fieldTypes, false);
-                       }
-                       else if(command.equals("insertpassword"))
-                       {
-                               Hashtable htAttribs = new Hashtable();
-                               htAttribs.put("type", "password");
-                               String[] fieldNames = { "name", "value", "size", "maxlength" };
-                               String[] fieldTypes = { "text", "text",  "text", "text" };
-                               insertFormElement(HTML.Tag.INPUT, "input", htAttribs, fieldNames, fieldTypes, false);
-                       }
-                       else if(command.equals("insertbutton"))
-                       {
-                               Hashtable htAttribs = new Hashtable();
-                               htAttribs.put("type", "button");
-                               String[] fieldNames = { "name", "value" };
-                               String[] fieldTypes = { "text", "text" };
-                               insertFormElement(HTML.Tag.INPUT, "input", htAttribs, fieldNames, fieldTypes, false);
-                       }
-                       else if(command.equals("insertbuttonsubmit"))
-                       {
-                               Hashtable htAttribs = new Hashtable();
-                               htAttribs.put("type", "submit");
-                               String[] fieldNames = { "name", "value" };
-                               String[] fieldTypes = { "text", "text" };
-                               insertFormElement(HTML.Tag.INPUT, "input", htAttribs, fieldNames, fieldTypes, false);
-                       }
-                       else if(command.equals("insertbuttonreset"))
-                       {
-                               Hashtable htAttribs = new Hashtable();
-                               htAttribs.put("type", "reset");
-                               String[] fieldNames = { "name", "value" };
-                               String[] fieldTypes = { "text", "text" };
-                               insertFormElement(HTML.Tag.INPUT, "input", htAttribs, fieldNames, fieldTypes, false);
-                       }
-                       else if(command.equals("find"))
-                       {
-                               doSearch((String)null, (String)null, false, lastSearchCaseSetting, lastSearchTopSetting);
-                       }
-                       else if(command.equals("findagain"))
-                       {
-                               doSearch(lastSearchFindTerm, (String)null, false, lastSearchCaseSetting, false);
-                       }
-                       else if(command.equals("replace"))
-                       {
-                               doSearch((String)null, (String)null, true, lastSearchCaseSetting, lastSearchTopSetting);
-                       }
-                       else if(command.equals("exit"))
-                       {
-                               this.dispose();
-                       }
-                       else if(command.equals("helpabout"))
-                       {
-                               SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("About"), true, Translatrix.getTranslationString("AboutMessage"), SimpleInfoDialog.INFO);
-                       }
-                       else if(command.equals("spellcheck"))
-                       {
-                               spellCheck.checkSpelling(new DocumentWordTokenizer(jtpMain.getDocument()));
-                       }
-               }
-               catch(IOException ioe)
-               {
-                       logException("IOException in actionPerformed method", ioe);
-                       SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorIOException"), SimpleInfoDialog.ERROR);
-               }
-               catch(BadLocationException ble)
-               {
-                       logException("BadLocationException in actionPerformed method", ble);
-                       SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorBadLocationException"), SimpleInfoDialog.ERROR);
-               }
-               catch(NumberFormatException nfe)
-               {
-                       logException("NumberFormatException in actionPerformed method", nfe);
-                       SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorNumberFormatException"), SimpleInfoDialog.ERROR);
-               }
-               catch(ClassNotFoundException cnfe)
-               {
-                       logException("ClassNotFound Exception in actionPerformed method", cnfe);
-                       SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorClassNotFoundException "), SimpleInfoDialog.ERROR);
-               }
-               catch(RuntimeException re)
-               {
-                       logException("RuntimeException in actionPerformed method", re);
-                       SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorRuntimeException"), SimpleInfoDialog.ERROR);
-               }
-       }
-
-       /* KeyListener methods */
-       public void keyTyped(KeyEvent ke)
-       {
-               Element elem;
-               String selectedText;
-               int pos = this.getCaretPosition();
-               int repos = -1;
-               if(ke.getKeyChar() == KeyEvent.VK_BACK_SPACE)
-               {
-                       try
-                       {
-                               if(pos > 0)
-                               {
-                                       if((selectedText = jtpMain.getSelectedText()) != null)
-                                       {
-                                               htmlUtilities.delete();
-                                               return;
-                                       }
-                                       else
-                                       {
-                                               int sOffset = htmlDoc.getParagraphElement(pos).getStartOffset();
-                                               if(sOffset == jtpMain.getSelectionStart())
-                                               {
-                                                       boolean content = true;
-                                                       if(htmlUtilities.checkParentsTag(HTML.Tag.LI))
-                                                       {
-                                                               elem = htmlUtilities.getListItemParent();
-                                                               content = false;
-                                                               int so = elem.getStartOffset();
-                                                               int eo = elem.getEndOffset();
-                                                               if(so + 1 < eo)
-                                                               {
-                                                                       char[] temp = jtpMain.getText(so, eo - so).toCharArray();
-                                                                       for(int i=0; i < temp.length; i++)
-                                                                       {
-                                                                               if(!(new Character(temp[i])).isWhitespace(temp[i]))
-                                                                               {
-                                                                                       content = true;
-                                                                               }
-                                                                       }
-                                                               }
-                                                               if(!content)
-                                                               {
-                                                                       Element listElement = elem.getParentElement();
-                                                                       htmlUtilities.removeTag(elem, true);
-                                                                       this.setCaretPosition(sOffset - 1);
-                                                                       return;
-                                                               }
-                                                               else
-                                                               {
-                                                                       jtpMain.setCaretPosition(jtpMain.getCaretPosition() - 1);
-                                                                       jtpMain.moveCaretPosition(jtpMain.getCaretPosition() - 2);
-                                                                       jtpMain.replaceSelection("");
-                                                                       return;
-                                                               }
-                                                       }
-                                                       else if(htmlUtilities.checkParentsTag(HTML.Tag.TABLE))
-                                                       {
-                                                               jtpMain.setCaretPosition(jtpMain.getCaretPosition() - 1);
-                                                               ke.consume();
-                                                               return;
-                                                       }
-                                               }
-                                               jtpMain.replaceSelection("");
-                                               return;
-                                       }
-                               }
-                       }
-                       catch (BadLocationException ble)
-                       {
-                               logException("BadLocationException in keyTyped method", ble);
-                               SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorBadLocationException"), SimpleInfoDialog.ERROR);
-                       }
-                       catch (IOException ioe)
-                       {
-                               logException("IOException in keyTyped method", ioe);
-                               SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorIOException"), SimpleInfoDialog.ERROR);
-                       }
-               }
-               else if(ke.getKeyChar() == KeyEvent.VK_ENTER)
-               {
-                       try
-                       {
-                               if(htmlUtilities.checkParentsTag(HTML.Tag.UL) == true | htmlUtilities.checkParentsTag(HTML.Tag.OL) == true)
-                               {
-                                       elem = htmlUtilities.getListItemParent();
-                                       int so = elem.getStartOffset();
-                                       int eo = elem.getEndOffset();
-                                       char[] temp = this.getTextPane().getText(so,eo-so).toCharArray();
-                                       boolean content = false;
-                                       for(int i=0;i<temp.length;i++)
-                                       {
-                                               if(!(new Character(temp[i])).isWhitespace(temp[i]))
-                                               {
-                                                       content = true;
-                                               }
-                                       }
-                                       if(content)
-                                       {
-                                               int end = -1;
-                                               int j = temp.length;
-                                               do
-                                               {
-                                                       j--;
-                                                       if(new Character(temp[j]).isLetterOrDigit(temp[j]))
-                                                       {
-                                                               end = j;
-                                                       }
-                                               } while (end == -1 && j >= 0);
-                                               j = end;
-                                               do
-                                               {
-                                                       j++;
-                                                       if(!new Character(temp[j]).isSpaceChar(temp[j]))
-                                                       {
-                                                               repos = j - end -1;
-                                                       }
-                                               } while (repos == -1 && j < temp.length);
-                                               if(repos == -1)
-                                               {
-                                                       repos = 0;
-                                               }
-                                       }
-                                       if(elem.getStartOffset() == elem.getEndOffset() || !content)
-                                       {
-                                               manageListElement(elem);
-                                       }
-                                       else
-                                       {
-                                               if(this.getCaretPosition() + 1 == elem.getEndOffset())
-                                               {
-                                                       insertListStyle(elem);
-                                                       this.setCaretPosition(pos - repos);
-                                               }
-                                               else
-                                               {
-                                                       int caret = this.getCaretPosition();
-                                                       String tempString = this.getTextPane().getText(caret, eo - caret);
-                                                       this.getTextPane().select(caret, eo - 1);
-                                                       this.getTextPane().replaceSelection("");
-                                                       htmlUtilities.insertListElement(tempString);
-                                                       Element newLi = htmlUtilities.getListItemParent();
-                                                       this.setCaretPosition(newLi.getEndOffset() - 1);
-                                               }
-                                       }
-                               }
-                       }
-                       catch (BadLocationException ble)
-                       {
-                               logException("BadLocationException in keyTyped method", ble);
-                               SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorBadLocationException"), SimpleInfoDialog.ERROR);
-                       }
-                       catch (IOException ioe)
-                       {
-                               logException("IOException in keyTyped method", ioe);
-                               SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorIOException"), SimpleInfoDialog.ERROR);
-                       }
-               }
-       }
-       public void keyPressed(KeyEvent e) {}
-       public void keyReleased(KeyEvent e) {}
-
-       public void insertListStyle(Element element)
-       throws BadLocationException,IOException
-       {
-               if(element.getParentElement().getName() == "ol")
-               {
-                       actionListOrdered.actionPerformed(new ActionEvent(new Object(), 0, "newListPoint"));
-               }
-               else
-               {
-                       actionListUnordered.actionPerformed(new ActionEvent(new Object(), 0, "newListPoint"));
-               }
-       }
-
-       /* DocumentListener methods */
-       public void changedUpdate(DocumentEvent de)     { handleDocumentChange(de); }
-       public void insertUpdate(DocumentEvent de)      { handleDocumentChange(de); }
-       public void removeUpdate(DocumentEvent de)      { handleDocumentChange(de); }
-       public void handleDocumentChange(DocumentEvent de)
-       {
-               if(!exclusiveEdit)
-               {
-                       if(jspSource.isShowing())
-                       {
-                               if(de.getDocument() instanceof HTMLDocument || de.getDocument() instanceof ExtendedHTMLDocument)
-                               {
-                                       jtpSource.getDocument().removeDocumentListener(this);
-                                       jtpSource.setText(jtpMain.getText());
-                                       jtpSource.getDocument().addDocumentListener(this);
-                               }
-                               else if(de.getDocument() instanceof PlainDocument || de.getDocument() instanceof DefaultStyledDocument)
-                               {
-                                       jtpMain.getDocument().removeDocumentListener(this);
-                                       jtpMain.setText(jtpSource.getText());
-                                       jtpMain.getDocument().addDocumentListener(this);
-                               }
-                       }
-               }
-       }
-
-       /* SpellCheckListener methods */
-       public void spellingError(SpellCheckEvent event)
-       {
-               spellDialog.show(event);
-       }
-
-       /** Method for setting a document as the current document for the text pane
-         * and re-registering the controls and settings for it
-         */
-       public void registerDocument(ExtendedHTMLDocument htmlDoc)
-       {
-               jtpMain.setDocument(htmlDoc);
-               jtpMain.getDocument().addUndoableEditListener(new CustomUndoableEditListener());
-               jtpMain.getDocument().addDocumentListener(this);
-               purgeUndos();
-               registerDocumentStyles();
-       }
-
-       /** Method for locating the available CSS style for the document and adding
-         * them to the styles selector
-         */
-       public void registerDocumentStyles()
-       {
-               if(jcmbStyleSelector == null || htmlDoc == null)
-               {
-                       return;
-               }
-               jcmbStyleSelector.setEnabled(false);
-               jcmbStyleSelector.removeAllItems();
-               jcmbStyleSelector.addItem(Translatrix.getTranslationString("NoCSSStyle"));
-               for(Enumeration e = htmlDoc.getStyleNames(); e.hasMoreElements();)
-               {
-                       String name = (String) e.nextElement();
-                       if(name.length() > 0 && name.charAt(0) == '.')
-                       {
-                               jcmbStyleSelector.addItem(name.substring(1));
-                       }
-               }
-               jcmbStyleSelector.setEnabled(true);
-       }
-
-       /** Method for inserting an HTML Table
-         */
-       private void insertTable(Hashtable attribs, String[] fieldNames, String[] fieldTypes)
-       throws IOException, BadLocationException, RuntimeException, NumberFormatException
-       {
-               int caretPos = jtpMain.getCaretPosition();
-               StringBuffer compositeElement = new StringBuffer("<TABLE");
-               if(attribs != null && attribs.size() > 0)
-               {
-                       Enumeration attribEntries = attribs.keys();
-                       while(attribEntries.hasMoreElements())
-                       {
-                               Object entryKey   = attribEntries.nextElement();
-                               Object entryValue = attribs.get(entryKey);
-                               if(entryValue != null && entryValue != "")
-                               {
-                                       compositeElement.append(" " + entryKey + "=" + '"' + entryValue + '"');
-                               }
-                       }
-               }
-               int rows = 0;
-               int cols = 0;
-               if(fieldNames != null && fieldNames.length > 0)
-               {
-                       PropertiesDialog propertiesDialog = new PropertiesDialog(this.getFrame(), fieldNames, fieldTypes, Translatrix.getTranslationString("FormDialogTitle"), true);
-                       propertiesDialog.show();
-                       String decision = propertiesDialog.getDecisionValue();
-                       if(decision.equals(Translatrix.getTranslationString("DialogCancel")))
-                       {
-                               propertiesDialog.dispose();
-                               propertiesDialog = null;
-                               return;
-                       }
-                       else
-                       {
-                               for(int iter = 0; iter < fieldNames.length; iter++)
-                               {
-                                       String fieldName = fieldNames[iter];
-                                       String propValue = propertiesDialog.getFieldValue(fieldName);
-                                       if(propValue != null && propValue != "" && propValue.length() > 0)
-                                       {
-                                               if(fieldName.equals("rows"))
-                                               {
-                                                       rows = Integer.parseInt(propValue);
-                                               }
-                                               else if(fieldName.equals("cols"))
-                                               {
-                                                       cols = Integer.parseInt(propValue);
-                                               }
-                                               else
-                                               {
-                                                       compositeElement.append(" " + fieldName + "=" + '"' + propValue + '"');
-                                               }
-                                       }
-                               }
-                       }
-                       propertiesDialog.dispose();
-                       propertiesDialog = null;
-               }
-               compositeElement.append(">");
-               for(int i = 0; i < rows; i++)
-               {
-                       compositeElement.append("<TR>");
-                       for(int j = 0; j < cols; j++)
-                       {
-                               compositeElement.append("<TD></TD>");
-                       }
-                       compositeElement.append("</TR>");
-               }
-               compositeElement.append("</TABLE><P>&nbsp;<P>");
-               htmlKit.insertHTML(htmlDoc, caretPos, compositeElement.toString(), 0, 0, HTML.Tag.TABLE);
-               jtpMain.setCaretPosition(caretPos + 1);
-               refreshOnUpdate();
-       }
-
-       /** Method for inserting a row into an HTML Table
-         */
-       private void insertTableRow()
-       {
-               int caretPos = jtpMain.getCaretPosition();
-               Element element = htmlDoc.getCharacterElement(jtpMain.getCaretPosition());
-               Element elementParent = element.getParentElement();
-               int startPoint  = -1;
-               int columnCount = -1;
-               while(elementParent != null && !elementParent.getName().equals("body"))
-               {
-                       if(elementParent.getName().equals("tr"))
-                       {
-                               startPoint  = elementParent.getStartOffset();
-                               columnCount = elementParent.getElementCount();
-                               break;
-                       }
-                       else
-                       {
-                               elementParent = elementParent.getParentElement();
-                       }
-               }
-               if(startPoint > -1 && columnCount > -1)
-               {
-                       jtpMain.setCaretPosition(startPoint);
-                       StringBuffer sRow = new StringBuffer();
-                       sRow.append("<TR>");
-                       for(int i = 0; i < columnCount; i++)
-                       {
-                               sRow.append("<TD></TD>");
-                       }
-                       sRow.append("</TR>");
-                       ActionEvent actionEvent = new ActionEvent(jtpMain, 0, "insertTableRow");
-                       new HTMLEditorKit.InsertHTMLTextAction("insertTableRow", sRow.toString(), HTML.Tag.TABLE, HTML.Tag.TR).actionPerformed(actionEvent);
-                       refreshOnUpdate();
-                       jtpMain.setCaretPosition(caretPos);
-               }
-       }
-
-       /** Method for inserting a column into an HTML Table
-         */
-       private void insertTableColumn()
-       {
-               int caretPos = jtpMain.getCaretPosition();
-               Element element = htmlDoc.getCharacterElement(jtpMain.getCaretPosition());
-               Element elementParent = element.getParentElement();
-               int startPoint = -1;
-               int rowCount   = -1;
-               int cellOffset =  0;
-               while(elementParent != null && !elementParent.getName().equals("body"))
-               {
-                       if(elementParent.getName().equals("table"))
-                       {
-                               startPoint = elementParent.getStartOffset();
-                               rowCount   = elementParent.getElementCount();
-                               break;
-                       }
-                       else if(elementParent.getName().equals("tr"))
-                       {
-                               int rowStart = elementParent.getStartOffset();
-                               int rowCells = elementParent.getElementCount();
-                               for(int i = 0; i < rowCells; i++)
-                               {
-                                       Element currentCell = elementParent.getElement(i);
-                                       if(jtpMain.getCaretPosition() >= currentCell.getStartOffset() && jtpMain.getCaretPosition() <= currentCell.getEndOffset())
-                                       {
-                                               cellOffset = i;
-                                       }
-                               }
-                               elementParent = elementParent.getParentElement();
-                       }
-                       else
-                       {
-                               elementParent = elementParent.getParentElement();
-                       }
-               }
-               if(startPoint > -1 && rowCount > -1)
-               {
-                       jtpMain.setCaretPosition(startPoint);
-                       String sCell = "<TD></TD>";
-                       ActionEvent actionEvent = new ActionEvent(jtpMain, 0, "insertTableCell");
-                       for(int i = 0; i < rowCount; i++)
-                       {
-                               Element row = elementParent.getElement(i);
-                               Element whichCell = row.getElement(cellOffset);
-                               jtpMain.setCaretPosition(whichCell.getStartOffset());
-                               new HTMLEditorKit.InsertHTMLTextAction("insertTableCell", sCell, HTML.Tag.TR, HTML.Tag.TD, HTML.Tag.TH, HTML.Tag.TD).actionPerformed(actionEvent);
-                       }
-                       refreshOnUpdate();
-                       jtpMain.setCaretPosition(caretPos);
-               }
-       }
-
-       /** Method for inserting a cell into an HTML Table
-         */
-       private void insertTableCell()
-       {
-               String sCell = "<TD></TD>";
-               ActionEvent actionEvent = new ActionEvent(jtpMain, 0, "insertTableCell");
-               new HTMLEditorKit.InsertHTMLTextAction("insertTableCell", sCell, HTML.Tag.TR, HTML.Tag.TD, HTML.Tag.TH, HTML.Tag.TD).actionPerformed(actionEvent);
-               refreshOnUpdate();
-       }
-
-       /** Method for deleting a row from an HTML Table
-         */
-       private void deleteTableRow()
-       throws BadLocationException
-       {
-               int caretPos = jtpMain.getCaretPosition();
-               Element element = htmlDoc.getCharacterElement(jtpMain.getCaretPosition());
-               Element elementParent = element.getParentElement();
-               int startPoint = -1;
-               int endPoint   = -1;
-               while(elementParent != null && !elementParent.getName().equals("body"))
-               {
-                       if(elementParent.getName().equals("tr"))
-                       {
-                               startPoint = elementParent.getStartOffset();
-                               endPoint   = elementParent.getEndOffset();
-                               break;
-                       }
-                       else
-                       {
-                               elementParent = elementParent.getParentElement();
-                       }
-               }
-               if(startPoint > -1 && endPoint > startPoint)
-               {
-                       htmlDoc.remove(startPoint, endPoint - startPoint);
-                       jtpMain.setDocument(htmlDoc);
-                       registerDocument(htmlDoc);
-                       refreshOnUpdate();
-                       if(caretPos >= htmlDoc.getLength())
-                       {
-                               caretPos = htmlDoc.getLength() - 1;
-                       }
-                       jtpMain.setCaretPosition(caretPos);
-               }
-       }
-
-       /** Method for deleting a column from an HTML Table
-         */
-       private void deleteTableColumn()
-       throws BadLocationException
-       {
-               int caretPos = jtpMain.getCaretPosition();
-               Element element       = htmlDoc.getCharacterElement(jtpMain.getCaretPosition());
-               Element elementParent = element.getParentElement();
-               Element elementCell   = (Element)null;
-               Element elementRow    = (Element)null;
-               Element elementTable  = (Element)null;
-               // Locate the table, row, and cell location of the cursor
-               while(elementParent != null && !elementParent.getName().equals("body"))
-               {
-                       if(elementParent.getName().equals("td"))
-                       {
-                               elementCell = elementParent;
-                       }
-                       else if(elementParent.getName().equals("tr"))
-                       {
-                               elementRow = elementParent;
-                       }
-                       else if(elementParent.getName().equals("table"))
-                       {
-                               elementTable = elementParent;
-                       }
-                       elementParent = elementParent.getParentElement();
-               }
-               int whichColumn = -1;
-               if(elementCell != null && elementRow != null && elementTable != null)
-               {
-                       // Find the column the cursor is in
-                       for(int i = 0; i < elementRow.getElementCount(); i++)
-                       {
-                               if(elementCell == elementRow.getElement(i))
-                               {
-                                       whichColumn = i;
-                               }
-                       }
-                       if(whichColumn > -1)
-                       {
-                               // Iterate through the table rows, deleting cells from the indicated column
-                               for(int i = 0; i < elementTable.getElementCount(); i++)
-                               {
-                                       elementRow  = elementTable.getElement(i);
-                                       elementCell = (elementRow.getElementCount() > whichColumn ? elementRow.getElement(whichColumn) : elementRow.getElement(elementRow.getElementCount() - 1));
-                                       int columnCellStart = elementCell.getStartOffset();
-                                       int columnCellEnd   = elementCell.getEndOffset();
-                                       htmlDoc.remove(columnCellStart, columnCellEnd - columnCellStart);
-                               }
-                               jtpMain.setDocument(htmlDoc);
-                               registerDocument(htmlDoc);
-                               refreshOnUpdate();
-                               if(caretPos >= htmlDoc.getLength())
-                               {
-                                       caretPos = htmlDoc.getLength() - 1;
-                               }
-                               jtpMain.setCaretPosition(caretPos);
-                       }
-               }
-       }
-
-       /** Method for inserting a break (BR) element
-         */
-       private void insertBreak()
-       throws IOException, BadLocationException, RuntimeException
-       {
-               int caretPos = jtpMain.getCaretPosition();
-               htmlKit.insertHTML(htmlDoc, caretPos, "<BR>", 0, 0, HTML.Tag.BR);
-               jtpMain.setCaretPosition(caretPos + 1);
-       }
-
-       /** Method for inserting a non-breaking space (&nbsp;)
-         */
-       private void insertNonbreakingSpace()
-       throws IOException, BadLocationException, RuntimeException
-       {
-               int caretPos = jtpMain.getCaretPosition();
-               htmlDoc.insertString(caretPos, "\240", jtpMain.getInputAttributes());
-               jtpMain.setCaretPosition(caretPos + 1);
-       }
-
-       /** Method for inserting a form element
-         */
-       private void insertFormElement(HTML.Tag baseTag, String baseElement, Hashtable attribs, String[] fieldNames, String[] fieldTypes, String[] fieldValues, boolean hasClosingTag)
-       throws IOException, BadLocationException, RuntimeException
-       {
-               int caretPos = jtpMain.getCaretPosition();
-               StringBuffer compositeElement = new StringBuffer("<" + baseElement);
-               if(attribs != null && attribs.size() > 0)
-               {
-                       Enumeration attribEntries = attribs.keys();
-                       while(attribEntries.hasMoreElements())
-                       {
-                               Object entryKey   = attribEntries.nextElement();
-                               Object entryValue = attribs.get(entryKey);
-                               if(entryValue != null && entryValue != "")
-                               {
-                                       compositeElement.append(" " + entryKey + "=" + '"' + entryValue + '"');
-                               }
-                       }
-               }
-               if(fieldNames != null && fieldNames.length > 0)
-               {
-                       PropertiesDialog propertiesDialog = new PropertiesDialog(this.getFrame(), fieldNames, fieldTypes, fieldValues, Translatrix.getTranslationString("FormDialogTitle"), true);
-                       propertiesDialog.show();
-                       String decision = propertiesDialog.getDecisionValue();
-                       if(decision.equals(Translatrix.getTranslationString("DialogCancel")))
-                       {
-                               propertiesDialog.dispose();
-                               propertiesDialog = null;
-                               return;
-                       }
-                       else
-                       {
-                               for(int iter = 0; iter < fieldNames.length; iter++)
-                               {
-                                       String fieldName = fieldNames[iter];
-                                       String propValue = propertiesDialog.getFieldValue(fieldName);
-                                       if(propValue != null && propValue.length() > 0)
-                                       {
-                                               if(fieldName.equals("checked"))
-                                               {
-                                                       if(propValue.equals("true"))
-                                                       {
-                                                               compositeElement.append(" " + fieldName + "=" + '"' + propValue + '"');
-                                                       }
-                                               }
-                                               else
-                                               {
-                                                       compositeElement.append(" " + fieldName + "=" + '"' + propValue + '"');
-                                               }
-                                       }
-                               }
-                       }
-                       propertiesDialog.dispose();
-                       propertiesDialog = null;
-               }
-               // --- Convenience for editing, this makes the FORM visible
-               if(useFormIndicator && baseElement.equals("form"))
-               {
-                       compositeElement.append(" bgcolor=" + '"' + clrFormIndicator + '"');
-               }
-               // --- END
-               compositeElement.append(">");
-               if(hasClosingTag)
-               {
-                       compositeElement.append("</" + baseElement + ">");
-               }
-               if(baseTag == HTML.Tag.FORM)
-               {
-                       compositeElement.append("<P>&nbsp;</P>");
-               }
-               htmlKit.insertHTML(htmlDoc, caretPos, compositeElement.toString(), 0, 0, baseTag);
-               // jtpMain.setCaretPosition(caretPos + 1);
-               refreshOnUpdate();
-       }
-
-       /** Alternate method call for inserting a form element
-         */
-       private void insertFormElement(HTML.Tag baseTag, String baseElement, Hashtable attribs, String[] fieldNames, String[] fieldTypes, boolean hasClosingTag)
-       throws IOException, BadLocationException, RuntimeException
-       {
-               insertFormElement(baseTag, baseElement, attribs, fieldNames, fieldTypes, new String[fieldNames.length], hasClosingTag);
-       }
-
-       /** Method that handles initial list insertion and deletion
-         */
-       public void manageListElement(Element element)
-       {
-               Element h = htmlUtilities.getListItemParent();
-               Element listElement = h.getParentElement();
-               if(h != null)
-               {
-                       htmlUtilities.removeTag(h, true);
-               }
-       }
-
-       /** Method to initiate a find/replace operation
-         */
-       private void doSearch(String searchFindTerm, String searchReplaceTerm, boolean bIsFindReplace, boolean bCaseSensitive, boolean bStartAtTop)
-       {
-               boolean bReplaceAll = false;
-               JTextPane searchPane = jtpMain;
-               if(jspSource.isShowing() || jtpSource.hasFocus())
-               {
-                       searchPane = jtpSource;
-               }
-               if(searchFindTerm == null || (bIsFindReplace && searchReplaceTerm == null))
-               {
-                       SearchDialog sdSearchInput = new SearchDialog(this.getFrame(), Translatrix.getTranslationString("SearchDialogTitle"), true, bIsFindReplace, bCaseSensitive, bStartAtTop);
-                       searchFindTerm    = sdSearchInput.getFindTerm();
-                       searchReplaceTerm = sdSearchInput.getReplaceTerm();
-                       bCaseSensitive    = sdSearchInput.getCaseSensitive();
-                       bStartAtTop       = sdSearchInput.getStartAtTop();
-                       bReplaceAll       = sdSearchInput.getReplaceAll();
-               }
-               if(searchFindTerm != null && (!bIsFindReplace || searchReplaceTerm != null))
-               {
-                       if(bReplaceAll)
-                       {
-                               int results = findText(searchFindTerm, searchReplaceTerm, bCaseSensitive, 0);
-                               int findOffset = 0;
-                               if(results > -1)
-                               {
-                                       while(results > -1)
-                                       {
-                                               findOffset = findOffset + searchReplaceTerm.length();
-                                               results    = findText(searchFindTerm, searchReplaceTerm, bCaseSensitive, findOffset);
-                                       }
-                               }
-                               else
-                               {
-                                       SimpleInfoDialog sidWarn = new SimpleInfoDialog(this.getFrame(), "", true, Translatrix.getTranslationString("ErrorNoOccurencesFound") + ":\n" + searchFindTerm, SimpleInfoDialog.WARNING);
-                               }
-                       }
-                       else
-                       {
-                               int results = findText(searchFindTerm, searchReplaceTerm, bCaseSensitive, (bStartAtTop ? 0 : searchPane.getCaretPosition()));
-                               if(results == -1)
-                               {
-                                       SimpleInfoDialog sidWarn = new SimpleInfoDialog(this.getFrame(), "", true, Translatrix.getTranslationString("ErrorNoMatchFound") + ":\n" + searchFindTerm, SimpleInfoDialog.WARNING);
-                               }
-                       }
-                       lastSearchFindTerm    = new String(searchFindTerm);
-                       if(searchReplaceTerm != null)
-                       {
-                               lastSearchReplaceTerm = new String(searchReplaceTerm);
-                       }
-                       else
-                       {
-                               lastSearchReplaceTerm = (String)null;
-                       }
-                       lastSearchCaseSetting = bCaseSensitive;
-                       lastSearchTopSetting  = bStartAtTop;
-               }
-       }
-
-       /** Method for finding (and optionally replacing) a string in the text
-         */
-       private int findText(String findTerm, String replaceTerm, boolean bCaseSenstive, int iOffset)
-       {
-               JTextPane jtpFindSource;
-               if(jspSource.isShowing() || jtpSource.hasFocus())
-               {
-                       jtpFindSource = jtpSource;
-               }
-               else
-               {
-                       jtpFindSource = jtpMain;
-               }
-               int searchPlace = -1;
-               try
-               {
-                       Document baseDocument = jtpFindSource.getDocument();
-                       searchPlace =
-                               (bCaseSenstive ?
-                                       baseDocument.getText(0, baseDocument.getLength()).indexOf(findTerm, iOffset) :
-                                       baseDocument.getText(0, baseDocument.getLength()).toLowerCase().indexOf(findTerm.toLowerCase(), iOffset)
-                               );
-                       if(searchPlace > -1)
-                       {
-                               if(replaceTerm != null)
-                               {
-                                       AttributeSet attribs = null;
-                                       if(baseDocument instanceof HTMLDocument)
-                                       {
-                                               Element element = ((HTMLDocument)baseDocument).getCharacterElement(searchPlace);
-                                               attribs = element.getAttributes();
-                                       }
-                                       baseDocument.remove(searchPlace, findTerm.length());
-                                       baseDocument.insertString(searchPlace, replaceTerm, attribs);
-                                       jtpFindSource.setCaretPosition(searchPlace + replaceTerm.length());
-                                       jtpFindSource.requestFocus();
-                                       jtpFindSource.select(searchPlace, searchPlace + replaceTerm.length());
-                               }
-                               else
-                               {
-                                       jtpFindSource.setCaretPosition(searchPlace + findTerm.length());
-                                       jtpFindSource.requestFocus();
-                                       jtpFindSource.select(searchPlace, searchPlace + findTerm.length());
-                               }
-                       }
-               }
-               catch(BadLocationException ble)
-               {
-                       logException("BadLocationException in actionPerformed method", ble);
-                       SimpleInfoDialog sidAbout = new SimpleInfoDialog(this.getFrame(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorBadLocationException"), SimpleInfoDialog.ERROR);
-               }
-               return searchPlace;
-       }
-
-       /** Method for inserting an image from a file
-         */
-       private void insertLocalImage(File whatImage)
-       throws IOException, BadLocationException, RuntimeException
-       {
-               if(whatImage == null)
-               {
-                       whatImage = getImageFromChooser(".", extsIMG, Translatrix.getTranslationString("FiletypeIMG"));
-               }
-               if(whatImage != null)
-               {
-                       int caretPos = jtpMain.getCaretPosition();
-                       htmlKit.insertHTML(htmlDoc, caretPos, "<IMG SRC=\"" + whatImage + "\">", 0, 0, HTML.Tag.IMG);
-                       jtpMain.setCaretPosition(caretPos + 1);
-                       refreshOnUpdate();
-               }
-       }
-
-       /** Method for inserting an image from a server
-         */
-       private void insertServerImage()
-       throws BadLocationException
-       {
-               if(ServletURL != null)
-               {
-                       try
-                       {
-                               URL theServlet = new URL(ServletURL + "?GetImages=" + TreePilotSystemID + "&ImageExtensions=" + TreePilotProperties.getString("ValidImageExtensions"));
-                               URLConnection conn = theServlet.openConnection();
-                               ObjectInputStream in = new ObjectInputStream(conn.getInputStream());
-                               String[] imageList = (String[]) in.readObject();
-                               int caretPos = jtpMain.getCaretPosition();
-                               ImageDialog imageDialog = new ImageDialog(this, ImageDir + TreePilotSystemID, imageList, "Image Chooser", true);
-                               String selectedImage = imageDialog.getSelectedImage();
-                               imageDialog.dispose();
-                               if(selectedImage != null  && !selectedImage.equals(""))
-                               {
-                                       htmlKit.insertHTML(htmlDoc, caretPos, selectedImage, 0, 0, HTML.Tag.IMG);
-                                       jtpMain.setCaretPosition(caretPos + 1);
-                               }
-                               jtpMain.requestFocus();
-                               in.close();
-                       }
-                       catch (MalformedURLException mue)
-                       {
-                               System.err.println("MalFormedURLException during insertImage " + mue);
-                       }
-                       catch (IOException ie)
-                       {
-                               System.err.println("IOException during insertImage " + ie);
-                       }
-                       catch (ClassNotFoundException cnfe)
-                       {
-                               System.err.println("ClassNotFoundException during insertImage" + cnfe);
-                       }
-               }
-       }
-
-       /** Method for inserting an image
-         */
-       public String insertFile()
-       {
-               String selectedFile = null;
-               if(ServletURL != null)
-               {
-                       try
-                       {
-                               URL theServlet = new URL(ServletURL + "?GetFiles=" + TreePilotSystemID + "&FileExtensions=" + TreePilotProperties.getString("ValidFileExtensions"));
-                               URLConnection conn = theServlet.openConnection();
-                               ObjectInputStream in = new ObjectInputStream(conn.getInputStream());
-                               String[] fileList = (String[]) in.readObject();
-                               FileDialog fileDialog = new FileDialog(this, ImageDir + TreePilotSystemID, fileList, "File Chooser", true);
-                               selectedFile = fileDialog.getSelectedFile();
-                               fileDialog.dispose();
-                               in.close();
-                       }
-                       catch (MalformedURLException mue)
-                       {
-                               System.err.println("MalFormedURLException during insertFile " + mue);
-                       }
-                       catch (IOException ie)
-                       {
-                               System.err.println("IOException during insertFile " + ie);
-                       }
-                       catch (ClassNotFoundException cnfe)
-                       {
-                               System.err.println("ClassNotFoundException during insertFile" + cnfe);
-                       }
-               }
-               return selectedFile;
-       }
-
-       /** Method for saving text as a complete HTML document
-         */
-       private void writeOut(HTMLDocument doc, File whatFile)
-       throws IOException, BadLocationException
-       {
-               if(whatFile == null)
-               {
-                       whatFile = getFileFromChooser(".", JFileChooser.SAVE_DIALOG, extsHTML, Translatrix.getTranslationString("FiletypeHTML"));
-               }
-               if(whatFile != null)
-               {
-                       FileWriter fw = new FileWriter(whatFile);
-                       htmlKit.write(fw, doc, 0, doc.getLength());
-                       fw.flush();
-                       fw.close();
-                       currentFile = whatFile;
-                       updateTitle();
-               }
-               refreshOnUpdate();
-       }
-
-       /** Method for saving text as an HTML fragment
-         */
-       private void writeOutFragment(HTMLDocument doc, String containingTag)
-       throws IOException, BadLocationException
-       {
-               File whatFile = getFileFromChooser(".", JFileChooser.SAVE_DIALOG, extsHTML, Translatrix.getTranslationString("FiletypeHTML"));
-               if(whatFile != null)
-               {
-                       FileWriter fw = new FileWriter(whatFile);
-//                     Element eleBody = locateElementInDocument((StyledDocument)doc, containingTag);
-//                     htmlKit.write(fw, doc, eleBody.getStartOffset(), eleBody.getEndOffset());
-                       String docTextCase = jtpSource.getText().toLowerCase();
-                       int tagStart       = docTextCase.indexOf("<" + containingTag.toLowerCase());
-                       int tagStartClose  = docTextCase.indexOf(">", tagStart) + 1;
-                       String closeTag    = "</" + containingTag.toLowerCase() + ">";
-                       int tagEndOpen     = docTextCase.indexOf(closeTag);
-                       if(tagStartClose < 0) { tagStartClose = 0; }
-                       if(tagEndOpen < 0 || tagEndOpen > docTextCase.length()) { tagEndOpen = docTextCase.length(); }
-                       String bodyText = jtpSource.getText().substring(tagStartClose, tagEndOpen);
-                       fw.write(bodyText, 0, bodyText.length());
-                       fw.flush();
-                       fw.close();
-               }
-               refreshOnUpdate();
-       }
-
-       /** Method for saving text as an RTF document
-         */
-       private void writeOutRTF(StyledDocument doc)
-       throws IOException, BadLocationException
-       {
-               File whatFile = getFileFromChooser(".", JFileChooser.SAVE_DIALOG, extsRTF, Translatrix.getTranslationString("FiletypeRTF"));
-               if(whatFile != null)
-               {
-                       FileOutputStream fos = new FileOutputStream(whatFile);
-                       RTFEditorKit rtfKit = new RTFEditorKit();
-                       rtfKit.write(fos, doc, 0, doc.getLength());
-                       fos.flush();
-                       fos.close();
-               }
-               refreshOnUpdate();
-       }
-
-       /** Method for saving text as a Base64 encoded document
-         */
-       private void writeOutBase64(String text)
-       throws IOException, BadLocationException
-       {
-               File whatFile = getFileFromChooser(".", JFileChooser.SAVE_DIALOG, extsB64, Translatrix.getTranslationString("FiletypeB64"));
-               if(whatFile != null)
-               {
-                       String base64text = Base64Codec.encode(text);
-                       FileWriter fw = new FileWriter(whatFile);
-                       fw.write(base64text, 0, base64text.length());
-                       fw.flush();
-                       fw.close();
-               }
-               refreshOnUpdate();
-       }
-
-       /** Method to invoke loading HTML into the app
-         */
-       private void openDocument(File whatFile)
-       throws IOException, BadLocationException
-       {
-               if(whatFile == null)
-               {
-                       whatFile = getFileFromChooser(".", JFileChooser.OPEN_DIALOG, extsHTML, Translatrix.getTranslationString("FiletypeHTML"));
-               }
-               if(whatFile != null)
-               {
-                       try
-                       {
-                               loadDocument(whatFile, null);
-                       }
-                       catch(ChangedCharSetException ccse)
-                       {
-                               String charsetType = ccse.getCharSetSpec().toLowerCase();
-                               int pos = charsetType.indexOf("charset");
-                               if(pos == -1)
-                               {
-                                       throw ccse;
-                               }
-                               while(pos < charsetType.length() && charsetType.charAt(pos) != '=')
-                               {
-                                       pos++;
-                               }
-                               pos++; // Places file cursor past the equals sign (=)
-                               String whatEncoding = charsetType.substring(pos).trim();
-                               loadDocument(whatFile, whatEncoding);
-                       }
-               }
-               refreshOnUpdate();
-       }
-
-       /** Method for loading HTML document into the app, including document encoding setting
-         */
-       private void loadDocument(File whatFile, String whatEncoding)
-       throws IOException, BadLocationException
-       {
-               Reader r = null;
-               htmlDoc = (ExtendedHTMLDocument)(htmlKit.createDefaultDocument());
-               try
-               {
-                       if(whatEncoding == null)
-                       {
-                               r = new InputStreamReader(new FileInputStream(whatFile));
-                       }
-                       else
-                       {
-                               r = new InputStreamReader(new FileInputStream(whatFile), whatEncoding);
-                               htmlDoc.putProperty("IgnoreCharsetDirective", new Boolean(true));
-                       }
-                       htmlKit.read(r, htmlDoc, 0);
-                       r.close();
-                       registerDocument(htmlDoc);
-                       jtpSource.setText(jtpMain.getText());
-                       currentFile = whatFile;
-                       updateTitle();
-               }
-               finally
-               {
-                       if(r != null)
-                       {
-                               r.close();
-                       }
-               }
-       }
-
-       /** Method for loading a Base64 encoded document
-         */
-       private void openDocumentBase64(File whatFile)
-       throws IOException, BadLocationException
-       {
-               if(whatFile == null)
-               {
-                       whatFile = getFileFromChooser(".", JFileChooser.OPEN_DIALOG, extsB64, Translatrix.getTranslationString("FiletypeB64"));
-               }
-               if(whatFile != null)
-               {
-                       FileReader fr = new FileReader(whatFile);
-                       int nextChar = 0;
-                       StringBuffer encodedText = new StringBuffer();
-                       try
-                       {
-                               while((nextChar = fr.read()) != -1)
-                               {
-                                       encodedText.append((char)nextChar);
-                               }
-                               fr.close();
-                               jtpSource.setText(Base64Codec.decode(encodedText.toString()));
-                               jtpMain.setText(jtpSource.getText());
-                               registerDocument((ExtendedHTMLDocument)(jtpMain.getDocument()));
-                       }
-                       finally
-                       {
-                               if(fr != null)
-                               {
-                                       fr.close();
-                               }
-                       }
-               }
-       }
-
-       /** Method for loading a Stylesheet into the app
-         */
-       private void openStyleSheet(File fileCSS)
-       throws IOException
-       {
-               if(fileCSS == null)
-               {
-                       fileCSS = getFileFromChooser(".", JFileChooser.OPEN_DIALOG, extsCSS, Translatrix.getTranslationString("FiletypeCSS"));
-               }
-               if(fileCSS != null)
-               {
-                       String currDocText = jtpMain.getText();
-                       htmlDoc = (ExtendedHTMLDocument)(htmlKit.createDefaultDocument());
-                       styleSheet = htmlDoc.getStyleSheet();
-                       URL cssUrl = fileCSS.toURL();
-                       InputStream is = cssUrl.openStream();
-                       BufferedReader br = new BufferedReader(new InputStreamReader(is));
-                       styleSheet.loadRules(br, cssUrl);
-                       br.close();
-                       htmlDoc = new ExtendedHTMLDocument(styleSheet);
-                       registerDocument(htmlDoc);
-                       jtpMain.setText(currDocText);
-                       jtpSource.setText(jtpMain.getText());
-               }
-               refreshOnUpdate();
-       }
-
-       /** Method for serializing the document out to a file
-         */
-       public void serializeOut(HTMLDocument doc)
-       throws IOException
-       {
-               File whatFile = getFileFromChooser(".", JFileChooser.SAVE_DIALOG, extsSer, Translatrix.getTranslationString("FiletypeSer"));
-               if(whatFile != null)
-               {
-                       ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(whatFile));
-                       oos.writeObject(doc);
-                       oos.flush();
-                       oos.close();
-               }
-               refreshOnUpdate();
-       }
-
-       /** Method for reading in a serialized document from a file
-         */
-       public void serializeIn()
-       throws IOException, ClassNotFoundException
-       {
-               File whatFile = getFileFromChooser(".", JFileChooser.OPEN_DIALOG, extsSer, Translatrix.getTranslationString("FiletypeSer"));
-               if(whatFile != null)
-               {
-                       ObjectInputStream ois = new ObjectInputStream(new FileInputStream(whatFile));
-                       htmlDoc = (ExtendedHTMLDocument)(ois.readObject());
-                       ois.close();
-                       registerDocument(htmlDoc);
-                       validate();
-               }
-               refreshOnUpdate();
-       }
-
-       /** Method for obtaining a File for input/output using a JFileChooser dialog
-         */
-       private File getFileFromChooser(String startDir, int dialogType, String[] exts, String desc)
-       {
-               JFileChooser jfileDialog = new JFileChooser(startDir);
-               jfileDialog.setDialogType(dialogType);
-               jfileDialog.setFileFilter(new MutableFilter(exts, desc));
-               int optionSelected = JFileChooser.CANCEL_OPTION;
-               if(dialogType == JFileChooser.OPEN_DIALOG)
-               {
-                       optionSelected = jfileDialog.showOpenDialog(this);
-               }
-               else if(dialogType == JFileChooser.SAVE_DIALOG)
-               {
-                       optionSelected = jfileDialog.showSaveDialog(this);
-               }
-               else // default to an OPEN_DIALOG
-               {
-                       optionSelected = jfileDialog.showOpenDialog(this);
-               }
-               if(optionSelected == JFileChooser.APPROVE_OPTION)
-               {
-                       return jfileDialog.getSelectedFile();
-               }
-               return (File)null;
-       }
-
-       /** Method for obtaining an Image for input using a custom JFileChooser dialog
-         */
-       private File getImageFromChooser(String startDir, String[] exts, String desc)
-       {
-               ImageFileChooser jImageDialog = new ImageFileChooser(startDir);
-               jImageDialog.setDialogType(JFileChooser.CUSTOM_DIALOG);
-               jImageDialog.setFileFilter(new MutableFilter(exts, desc));
-               jImageDialog.setDialogTitle(Translatrix.getTranslationString("ImageDialogTitle"));
-               int optionSelected = JFileChooser.CANCEL_OPTION;
-               optionSelected = jImageDialog.showDialog(this, Translatrix.getTranslationString("Insert"));
-               if(optionSelected == JFileChooser.APPROVE_OPTION)
-               {
-                       return jImageDialog.getSelectedFile();
-               }
-               return (File)null;
-       }
-
-       /** Method for describing the node hierarchy of the document
-         */
-       private void describeDocument(StyledDocument doc)
-       {
-               Element[] elements = doc.getRootElements();
-               for(int i = 0; i < elements.length; i++)
-               {
-                       indent = indentStep;
-                       for(int j = 0; j < indent; j++) { System.out.print(" "); }
-                       System.out.print(elements[i]);
-                       traverseElement(elements[i]);
-                       System.out.println("");
-               }
-       }
-
-       /** Traverses nodes for the describing method
-         */
-       private void traverseElement(Element element)
-       {
-               indent += indentStep;
-               for(int i = 0; i < element.getElementCount(); i++)
-               {
-                       for(int j = 0; j < indent; j++) { System.out.print(" "); }
-                       System.out.print(element.getElement(i));
-                       traverseElement(element.getElement(i));
-               }
-               indent -= indentStep;
-       }
-
-       /** Method to locate a node element by name
-         */
-       private Element locateElementInDocument(StyledDocument doc, String elementName)
-       {
-               Element[] elements = doc.getRootElements();
-               for(int i = 0; i < elements.length; i++)
-               {
-                       if(elements[i].getName().equalsIgnoreCase(elementName))
-                       {
-                               return elements[i];
-                       }
-                       else
-                       {
-                               Element rtnElement = locateChildElementInDocument(elements[i], elementName);
-                               if(rtnElement != null)
-                               {
-                                       return rtnElement;
-                               }
-                       }
-               }
-               return (Element)null;
-       }
-
-       /** Traverses nodes for the locating method
-         */
-       private Element locateChildElementInDocument(Element element, String elementName)
-       {
-               for(int i = 0; i < element.getElementCount(); i++)
-               {
-                       if(element.getElement(i).getName().equalsIgnoreCase(elementName))
-                       {
-                               return element.getElement(i);
-                       }
-               }
-               return (Element)null;
-       }
-
-       /** Convenience method for obtaining the WYSIWYG JTextPane
-         */
-       public JTextPane getTextPane()
-       {
-               return jtpMain;
-       }
-
-       /** Convenience method for obtaining the Source JTextPane
-         */
-       public JTextPane getSourcePane()
-       {
-               return jtpSource;
-       }
-
-       /** Convenience method for obtaining the application as a Frame
-         */
-       public Frame getFrame()
-       {
-               return frameHandler;
-       }
-
-       /** Convenience method for setting the parent Frame
-         */
-       public void setFrame(Frame parentFrame)
-       {
-               frameHandler = parentFrame;
-       }
-
-       /** Convenience method for obtaining the pre-generated menu bar
-         */
-       public JMenuBar getMenuBar()
-       {
-               return jMenuBar;
-       }
-
-       /** Convenience method for obtaining a custom menu bar
-         */
-       public JMenuBar getCustomMenuBar(Vector vcMenus)
-       {
-               jMenuBar = new JMenuBar();
-               for(int i = 0; i < vcMenus.size(); i++)
-               {
-                       String menuToAdd = ((String)(vcMenus.elementAt(i))).toLowerCase();
-                       if(htMenus.containsKey(menuToAdd))
-                       {
-                               jMenuBar.add((JMenu)(htMenus.get(menuToAdd)));
-                       }
-               }
-               return jMenuBar;
-       }
-
-       /** Convenience method for obtaining the pre-generated toolbar
-         */
-       public JToolBar getToolBar(boolean isShowing)
-       {
-               jcbmiViewToolbar.setState(isShowing);
-               return jToolBar;
-       }
-
-       /** Convenience method for obtaining the pre-generated toolbar
-         */
-       public JToolBar getCustomToolBar(Vector vcTools, boolean isShowing)
-       {
-               jcbmiViewToolbar.setState(isShowing);
-               jToolBar = new JToolBar(JToolBar.HORIZONTAL);
-               jToolBar.setFloatable(false);
-               for(int i = 0; i < vcTools.size(); i++)
-               {
-                       String toolToAdd = ((String)(vcTools.elementAt(i))).toLowerCase();
-                       if(toolToAdd.equals(KEY_TOOL_SEP))
-                       {
-                               jToolBar.add(new JToolBar.Separator());
-                       }
-                       else if(htTools.containsKey(toolToAdd))
-                       {
-                               if(htTools.get(toolToAdd) instanceof JButtonNoFocus)
-                               {
-                                       jToolBar.add((JButtonNoFocus)(htTools.get(toolToAdd)));
-                               }
-                               else if(htTools.get(toolToAdd) instanceof JToggleButtonNoFocus)
-                               {
-                                       jToolBar.add((JToggleButtonNoFocus)(htTools.get(toolToAdd)));
-                               }
-                               else if(htTools.get(toolToAdd) instanceof JComboBoxNoFocus)
-                               {
-                                       jToolBar.add((JComboBoxNoFocus)(htTools.get(toolToAdd)));
-                               }
-                               else
-                               {
-                                       jToolBar.add((JComponent)(htTools.get(toolToAdd)));
-                               }
-                       }
-               }
-               return jToolBar;
-       }
-
-       /** Convenience method for obtaining the current file handle
-         */
-       public File getCurrentFile()
-       {
-               return currentFile;
-       }
-
-       /** Convenience method for obtaining the application name
-         */
-       public String getAppName()
-       {
-               return appName;
-       }
-
-       /** Convenience method for obtaining the document text
-         */
-       public String getDocumentText()
-       {
-               return jtpMain.getText();
-       }
-
-       /** Convenience method for obtaining the document text
-         * contained within a tag pair
-         */
-       public String getDocumentSubText(String tagBlock)
-       {
-               return getSubText(tagBlock);
-       }
-
-       /** Method for extracting the text within a tag
-         */
-       private String getSubText(String containingTag)
-       {
-               jtpSource.setText(jtpMain.getText());
-               String docTextCase = jtpSource.getText().toLowerCase();
-               int tagStart       = docTextCase.indexOf("<" + containingTag.toLowerCase());
-               int tagStartClose  = docTextCase.indexOf(">", tagStart) + 1;
-               String closeTag    = "</" + containingTag.toLowerCase() + ">";
-               int tagEndOpen     = docTextCase.indexOf(closeTag);
-               if(tagStartClose < 0) { tagStartClose = 0; }
-               if(tagEndOpen < 0 || tagEndOpen > docTextCase.length()) { tagEndOpen = docTextCase.length(); }
-               return jtpSource.getText().substring(tagStartClose, tagEndOpen);
-       }
-
-       /** Convenience method for obtaining the document text
-               * contained within the BODY tags (a common request)
-         */
-       public String getDocumentBody()
-       {
-               return getSubText("body");
-       }
-
-       /** Convenience method for setting the document text
-         */
-       public void setDocumentText(String sText)
-       {
-               jtpMain.setText(sText);
-               ((HTMLEditorKit)(jtpMain.getEditorKit())).setDefaultCursor(new Cursor(Cursor.TEXT_CURSOR));
-               jtpSource.setText(jtpMain.getText());
-               ((HTMLEditorKit)(jtpSource.getEditorKit())).setDefaultCursor(new Cursor(Cursor.TEXT_CURSOR));
-       }
-
-       /** Convenience method for obtaining the document text
-         */
-       private void updateTitle()
-       {
-               frameHandler.setTitle(appName + (currentFile == null ? "" : " - " + currentFile.getName()));
-       }
-
-       /** Convenience method for clearing out the UndoManager
-         */
-       public void purgeUndos()
-       {
-               if(undoMngr != null)
-               {
-                       undoMngr.discardAllEdits();
-                       undoAction.updateUndoState();
-                       redoAction.updateRedoState();
-               }
-       }
-
-       /** Convenience method for refreshing and displaying changes
-         */
-       public void refreshOnUpdate()
-       {
-               jtpMain.setText(jtpMain.getText());
-               jtpSource.setText(jtpMain.getText());
-               purgeUndos();
-               this.repaint();
-       }
-
-       /** Convenience method for deallocating the app resources
-         */
-       public void dispose()
-       {
-               frameHandler.dispose();
-               spellCheck.dispose();
-               spellCheck = null;
-               spellDialog = null;
-               System.exit(0);
-       }
-
-       /** Convenience method for fetching icon images from jar file
-         */
-       private ImageIcon getEkitIcon(String iconName)
-       {
-               return new ImageIcon(Toolkit.getDefaultToolkit().getImage(getClass().getResource("icons/" + iconName + "HK.gif")));
-       }
-
-       /** Convenience method for outputting exceptions
-         */
-       private void logException(String internalMessage, Exception e)
-       {
-               System.err.println(internalMessage);
-               e.printStackTrace(System.err);
-       }
-
-       /** Convenience method for toggling source window visibility
-         */
-       private void toggleSourceWindow()
-       {
-               if(!(jspSource.isShowing()))
-               {
-                       jtpSource.setText(jtpMain.getText());
-                       jspltDisplay.setRightComponent(jspSource);
-                       if(exclusiveEdit)
-                       {
-                               jspltDisplay.setDividerLocation(0);
-                               jspltDisplay.setEnabled(false);
-                       }
-                       else
-                       {
-                               jspltDisplay.setDividerLocation(iSplitPos);
-                               jspltDisplay.setEnabled(true);
-                       }
-               }
-               else
-               {
-                       jtpMain.setText(jtpSource.getText());
-                       iSplitPos = jspltDisplay.getDividerLocation();
-                       jspltDisplay.remove(jspSource);
-                       jtpMain.requestFocus();
-               }
-               this.validate();
-               jcbmiViewSource.setSelected(jspSource.isShowing());
-               jtbtnViewSource.setSelected(jspSource.isShowing());
-       }
-
-       /** Searches the specified element for CLASS attribute setting
-         */
-       private String findStyle(Element element)
-       {
-               AttributeSet as = element.getAttributes();
-               if(as == null)
-               {
-                       return null;
-               }
-               Object val = as.getAttribute(HTML.Attribute.CLASS);
-               if(val != null && (val instanceof String))
-               {
-                       return (String)val;
-               }
-               for(Enumeration e = as.getAttributeNames(); e.hasMoreElements();)
-               {
-                       Object key = e.nextElement();
-                       if(key instanceof HTML.Tag)
-                       {
-                               AttributeSet eas = (AttributeSet)(as.getAttribute(key));
-                               if(eas != null)
-                               {
-                                       val = eas.getAttribute(HTML.Attribute.CLASS);
-                                       if(val != null)
-                                       {
-                                               return (String)val;
-                                       }
-                               }
-                       }
-
-               }
-               return null;
-       }
-
-       /** Handles caret tracking and related events, such as displaying the current style
-         * of the text under the caret
-         */
-       private void handleCaretPositionChange(CaretEvent ce)
-       {
-               int caretPos = ce.getDot();
-               Element element = htmlDoc.getCharacterElement(caretPos);
-/*
----- TAG EXPLICATOR CODE -------------------------------------------
-               javax.swing.text.ElementIterator ei = new javax.swing.text.ElementIterator(htmlDoc);
-               Element ele;
-               while((ele = ei.next()) != null)
-               {
-                       System.out.println("ELEMENT : " + ele.getName());
-               }
-               System.out.println("ELEMENT:" + element.getName());
-               Element elementParent = element.getParentElement();
-               System.out.println("ATTRS:");
-               AttributeSet attribs = elementParent.getAttributes();
-               for(Enumeration eAttrs = attribs.getAttributeNames(); eAttrs.hasMoreElements();)
-               {
-                       System.out.println("  " + eAttrs.nextElement().toString());
-               }
-               while(elementParent != null && !elementParent.getName().equals("body"))
-               {
-                       String parentName = elementParent.getName();
-                       System.out.println("PARENT:" + parentName);
-                       System.out.println("ATTRS:");
-                       attribs = elementParent.getAttributes();
-                       for(Enumeration eAttr = attribs.getAttributeNames(); eAttr.hasMoreElements();)
-                       {
-                               System.out.println("  " + eAttr.nextElement().toString());
-                       }
-                       elementParent = elementParent.getParentElement();
-               }
----- END -------------------------------------------
-*/
-               if(element == null)
-               {
-                       return;
-               }
-               String style = null;
-               Vector vcStyles = new Vector();
-               while(element != null)
-               {
-                       if(style == null)
-                       {
-                               style = findStyle(element);
-                       }
-                       vcStyles.add(element);
-                       element = element.getParentElement();
-               }
-               int stylefound = -1;
-               if(style != null)
-               {
-                       for(int i = 0; i < jcmbStyleSelector.getItemCount(); i++)
-                       {
-                               String in = (String)(jcmbStyleSelector.getItemAt(i));
-                               if(in.equalsIgnoreCase(style))
-                               {
-                                       stylefound = i;
-                                       break;
-                               }
-                       }
-               }
-               if(stylefound > -1)
-               {
-                       Action ac = jcmbStyleSelector.getAction();
-                       ac.setEnabled(false);
-                       jcmbStyleSelector.setSelectedIndex(stylefound);
-                       ac.setEnabled(true);
-               }
-               else
-               {
-                       jcmbStyleSelector.setSelectedIndex(0);
-               }
-       }
-
-       /** Server-side image handling methods
-         */
-       protected void setServletURL(String url)
-       {
-               ServletURL = url;
-       }
-
-       protected void setImageDir(String sysDir)
-       {
-               ImageDir = sysDir;
-       }
-
-       public void setTreePilotSystemID(String theSystem)
-       {
-               TreePilotSystemID = theSystem;
-       }
-
-       /** Utility methods
-         */
-       public ExtendedHTMLDocument getExtendedHtmlDoc()
-       {
-               return (ExtendedHTMLDocument)htmlDoc;
-       }
-
-       public int getCaretPosition()
-       {
-               return jtpMain.getCaretPosition();
-       }
-
-       public void setCaretPosition(int newPositon)
-       {
-               boolean end = true;
-               do
-               {
-                       end = true;
-                       try
-                       {
-                               jtpMain.setCaretPosition(newPositon);
-                       }
-                       catch (IllegalArgumentException iae)
-                       {
-                               end = false;
-                               newPositon--;
-                       }
-               } while(!end && newPositon >= 0);
-       }
-
-/* Inner Classes --------------------------------------------- */
-
-       /** Class for implementing Undo as an autonomous action
-         */
-       class UndoAction extends AbstractAction
-       {
-               public UndoAction()
-               {
-                       super(Translatrix.getTranslationString("Undo"));
-                       setEnabled(false);
-               }
-
-               public void actionPerformed(ActionEvent e)
-               {
-                       try
-                       {
-                               undoMngr.undo();
-                       }
-                       catch(CannotUndoException ex)
-                       {
-                               ex.printStackTrace();
-                       }
-                       updateUndoState();
-                       redoAction.updateRedoState();
-               }
-
-               protected void updateUndoState()
-               {
-                       if(undoMngr.canUndo())
-                       {
-                               setEnabled(true);
-                               putValue(Action.NAME, undoMngr.getUndoPresentationName());
-                       }
-                       else
-                       {
-                               setEnabled(false);
-                               putValue(Action.NAME, Translatrix.getTranslationString("Undo"));
-                       }
-               }
-       }
-
-       /** Class for implementing Redo as an autonomous action
-         */
-       class RedoAction extends AbstractAction
-       {
-               public RedoAction()
-               {
-                       super(Translatrix.getTranslationString("Redo"));
-                       setEnabled(false);
-               }
-
-               public void actionPerformed(ActionEvent e)
-               {
-                       try
-                       {
-                               undoMngr.redo();
-                       }
-                       catch(CannotUndoException ex)
-                       {
-                               ex.printStackTrace();
-                       }
-                       updateRedoState();
-                       undoAction.updateUndoState();
-               }
-
-               protected void updateRedoState()
-               {
-                       if(undoMngr.canRedo())
-                       {
-                               setEnabled(true);
-                               putValue(Action.NAME, undoMngr.getRedoPresentationName());
-                       }
-                       else
-                       {
-                               setEnabled(false);
-                               putValue(Action.NAME, Translatrix.getTranslationString("Redo"));
-                       }
-               }
-       }
-
-       /** Class for implementing the Undo listener to handle the Undo and Redo actions
-         */
-       class CustomUndoableEditListener implements UndoableEditListener
-       {
-               public void undoableEditHappened(UndoableEditEvent uee)
-               {
-                       undoMngr.addEdit(uee.getEdit());
-                       undoAction.updateUndoState();
-                       redoAction.updateRedoState();
-               }
-       }
-
-}
index 07c1122..a8807ba 100644 (file)
@@ -2,7 +2,7 @@
 GNU Lesser General Public License
 
 ExtendedHTMLEditorKit
-Copyright (C) 2001-2002  Frits Jalvingh & Howard Kistler
+Copyright (C) 2001  Frits Jalvingh, Jerry Pommer & Howard Kistler
 
 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
@@ -21,17 +21,16 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 package com.hexidec.ekit.component;
 
+import javax.swing.text.Document;
 import javax.swing.text.Element;
 import javax.swing.text.StyleConstants;
 import javax.swing.text.View;
 import javax.swing.text.ViewFactory;
 import javax.swing.text.html.HTML;
 import javax.swing.text.html.HTMLEditorKit;
+import javax.swing.text.html.StyleSheet;
 
-/* WACKY GERMAN CODE */
 import com.hexidec.ekit.component.ExtendedHTMLDocument;
-import javax.swing.text.html.StyleSheet;
-import javax.swing.text.Document;
 
 /**
   * This class extends HTMLEditorKit so that it can provide other renderer classes
@@ -64,16 +63,16 @@ public class ExtendedHTMLEditorKit extends HTMLEditorKit
                return new HTMLFactoryExtended(BaseUrl);
        }
 
-/* WACKY GERMAN CODE */
-       public Document createDefaultDocument() {
-         StyleSheet styles = getStyleSheet();
-         StyleSheet ss = new StyleSheet();
-         ss.addStyleSheet(styles);
-         ExtendedHTMLDocument doc = new ExtendedHTMLDocument(ss);
-         doc.setParser(getParser());
-         doc.setAsynchronousLoadPriority(4);
-         doc.setTokenThreshold(100);
-         return doc;
+       public Document createDefaultDocument()
+       {
+               StyleSheet styles = getStyleSheet();
+               StyleSheet ss = new StyleSheet();
+               ss.addStyleSheet(styles);
+               ExtendedHTMLDocument doc = new ExtendedHTMLDocument(ss);
+               doc.setParser(getParser());
+               doc.setAsynchronousLoadPriority(4);
+               doc.setTokenThreshold(100);
+               return doc;
        }
 
 /* Inner Classes --------------------------------------------- */
index 6ef7b6c..c2ba48a 100644 (file)
-/*\r
-GNU Lesser General Public License\r
-\r
-RelativeImageView\r
-Copyright (C) 2001-2002  Frits Jalvingh & Howard Kistler\r
-\r
-This library is free software; you can redistribute it and/or\r
-modify it under the terms of the GNU Lesser General Public\r
-License as published by the Free Software Foundation; either\r
-version 2.1 of the License, or (at your option) any later version.\r
-\r
-This library is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
-Lesser General Public License for more details.\r
-\r
-You should have received a copy of the GNU Lesser General Public\r
-License along with this library; if not, write to the Free Software\r
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
-*/\r
-\r
-package com.hexidec.ekit.component;\r
-\r
-import java.awt.Color;\r
-import java.awt.Component;\r
-import java.awt.Container;\r
-import java.awt.Dimension;\r
-import java.awt.Graphics;\r
-import java.awt.Image;\r
-import java.awt.Point;\r
-import java.awt.Rectangle;\r
-import java.awt.Shape;\r
-import java.awt.Toolkit;\r
-import java.awt.event.MouseEvent;\r
-import java.awt.event.MouseListener;\r
-import java.awt.event.MouseMotionListener;\r
-import java.awt.image.ImageObserver;\r
-import java.io.BufferedInputStream;\r
-import java.io.ByteArrayOutputStream;\r
-import java.io.File;\r
-import java.io.InputStream;\r
-import java.io.IOException;\r
-import java.net.MalformedURLException;\r
-import java.net.URL;\r
-import java.util.Dictionary;\r
-import javax.swing.Icon;\r
-import javax.swing.ImageIcon;\r
-import javax.swing.JEditorPane;\r
-import javax.swing.text.AbstractDocument;\r
-import javax.swing.text.AttributeSet;\r
-import javax.swing.text.BadLocationException;\r
-import javax.swing.text.Document;\r
-import javax.swing.text.Element;\r
-import javax.swing.text.JTextComponent;\r
-import javax.swing.text.MutableAttributeSet;\r
-import javax.swing.text.Position;\r
-import javax.swing.text.SimpleAttributeSet;\r
-import javax.swing.text.StyledDocument;\r
-import javax.swing.text.View;\r
-import javax.swing.text.ViewFactory;\r
-import javax.swing.text.html.HTML;\r
-import javax.swing.text.html.HTMLDocument;\r
-import javax.swing.text.html.StyleSheet;\r
-import javax.swing.event.DocumentEvent;\r
-\r
-/**\r
-  * @author <a href="mailto:jal@grimor.com">Frits Jalvingh</a>\r
-  * @version 1.0\r
-  *\r
-  * This code was modeled after an artice on\r
-  * <a href="http://www.javaworld.com/javaworld/javatips/jw-javatip109.html">\r
-  * JavaWorld</a> by Bob Kenworthy.\r
-  */\r
-\r
-public class RelativeImageView extends View implements ImageObserver, MouseListener, MouseMotionListener\r
-{\r
-       public static final String TOP       = "top";\r
-       public static final String TEXTTOP   = "texttop";\r
-       public static final String MIDDLE    = "middle";\r
-       public static final String ABSMIDDLE = "absmiddle";\r
-       public static final String CENTER    = "center";\r
-       public static final String BOTTOM    = "bottom";\r
-       public static final String IMAGE_CACHE_PROPERTY = "imageCache";\r
-\r
-       private static Icon sPendingImageIcon;\r
-       private static Icon sMissingImageIcon;\r
-       private static final String PENDING_IMAGE_SRC = "icons/ImagePendingHK.gif";\r
-       private static final String MISSING_IMAGE_SRC = "icons/ImageMissingHK.gif";\r
-       private static final int DEFAULT_WIDTH  = 32;\r
-       private static final int DEFAULT_HEIGHT = 32;\r
-       private static final int DEFAULT_BORDER = 1;\r
-\r
-       private AttributeSet attr;\r
-       private Element      fElement;\r
-       private Image        fImage;\r
-       private int          fHeight;\r
-       private int          fWidth;\r
-       private Container    fContainer;\r
-       private Rectangle    fBounds;\r
-       private Component    fComponent;\r
-       private Point        fGrowBase; // base of drag while growing image\r
-       private boolean      fGrowProportionally; // should grow be proportional?\r
-       private String BaseUrl;\r
-       private boolean      bLoading; // set to true while the receiver is locked, to indicate the reciever is loading the image. This is used in imageUpdate.\r
-\r
-       /** Constructor\r
-         * Creates a new view that represents an IMG element.\r
-         * @param elem the element to create a view for\r
-         */\r
-       public RelativeImageView(Element elem,String baseurl)\r
-       {\r
-               super(elem);\r
-               BaseUrl = baseurl;\r
-               initialize(elem);\r
-               StyleSheet sheet = getStyleSheet();\r
-               attr = sheet.getViewAttributes(this);\r
-       }\r
-\r
-       private void initialize(Element elem)\r
-       {\r
-               synchronized(this)\r
-               {\r
-                       bLoading = true;\r
-                       fWidth  = 0;\r
-                       fHeight = 0;\r
-               }\r
-               int width = 0;\r
-               int height = 0;\r
-               boolean customWidth = false;\r
-               boolean customHeight = false;\r
-               try\r
-               {\r
-                       fElement = elem;\r
-                       // request image from document's cache\r
-                       AttributeSet attr = elem.getAttributes();\r
-                       if(true || isURL())\r
-                       {\r
-                               URL src = getSourceURL();\r
-                               if(src != null)\r
-                               {\r
-                                       Dictionary cache = (Dictionary)getDocument().getProperty(IMAGE_CACHE_PROPERTY);\r
-                                       if(cache != null)\r
-                                       {\r
-                                               fImage = (Image)cache.get(src);\r
-                                       }\r
-                                       else\r
-                                       {\r
-                                               fImage = Toolkit.getDefaultToolkit().getImage(src);\r
-                                       }\r
-                               }\r
-                       }\r
-                       else\r
-                       {\r
-                               // load image from relative path\r
-                               String src = (String)fElement.getAttributes().getAttribute(HTML.Attribute.SRC);\r
-                               src = processSrcPath(src);\r
-                               fImage = Toolkit.getDefaultToolkit().createImage(src);\r
-                               try\r
-                               {\r
-                                       waitForImage();\r
-                               }\r
-                               catch(InterruptedException ie)\r
-                               {\r
-                                       fImage = null;\r
-                                       // possibly replace with the ImageBroken icon, if that's what is happening\r
-                               }\r
-                       }\r
-\r
-                       // get height & width from params or image or defaults\r
-                       height = getIntAttr(HTML.Attribute.HEIGHT, -1);\r
-                       customHeight = (height > 0);\r
-                       if(!customHeight && fImage != null)\r
-                       {\r
-                               height = fImage.getHeight(this);\r
-                       }\r
-                       if(height <= 0)\r
-                       {\r
-                               height = DEFAULT_HEIGHT;\r
-                       }\r
-\r
-                       width = getIntAttr(HTML.Attribute.WIDTH, -1);\r
-                       customWidth = (width > 0);\r
-                       if(!customWidth && fImage != null)\r
-                       {\r
-                               width = fImage.getWidth(this);\r
-                       }\r
-                       if(width <= 0)\r
-                       {\r
-                               width = DEFAULT_WIDTH;\r
-                       }\r
-\r
-                       if(fImage != null)\r
-                       {\r
-                               if(customHeight && customWidth)\r
-                               {\r
-                                       Toolkit.getDefaultToolkit().prepareImage(fImage, height, width, this);\r
-                               }\r
-                               else\r
-                               {\r
-                                       Toolkit.getDefaultToolkit().prepareImage(fImage, -1, -1, this);\r
-                               }\r
-                       }\r
-               }\r
-               finally\r
-               {\r
-                       synchronized(this)\r
-                       {\r
-                               bLoading = false;\r
-                               if(customHeight || fHeight == 0)\r
-                               {\r
-                                       fHeight = height;\r
-                               }\r
-                               if(customWidth || fWidth == 0)\r
-                               {\r
-                                       fWidth = width;\r
-                               }\r
-                       }\r
-               }\r
-       }\r
-\r
-       /** Determines if path is in the form of a URL\r
-         */\r
-       private boolean isURL()\r
-       {\r
-               String src = (String)fElement.getAttributes().getAttribute(HTML.Attribute.SRC);\r
-               return src.toLowerCase().startsWith("file") || src.toLowerCase().startsWith("http");\r
-       }\r
-\r
-       /** Checks to see if the absolute path is availabe thru an application\r
-         * global static variable or thru a system variable. If so, appends\r
-         * the relative path to the absolute path and returns the String.\r
-         */\r
-       private String processSrcPath(String src)\r
-       {\r
-               String val = src;\r
-               File imageFile = new File(src);\r
-               if(imageFile.isAbsolute())\r
-               {\r
-                       return src;\r
-               }\r
-               boolean found = false;\r
-               Document doc = getDocument();\r
-               if(doc != null)\r
-               {\r
-                       String pv = (String)doc.getProperty("com.hexidec.ekit.docsource");\r
-                       if(pv != null)\r
-                       {\r
-                               File f = new File(pv);\r
-                               val     = (new File(f.getParent(), imageFile.getPath().toString())).toString();\r
-                               found = true;\r
-                       }\r
-               }\r
-               if(!found)\r
-               {\r
-                       String imagePath = System.getProperty("system.image.path.key");\r
-                       if(imagePath != null)\r
-                       {\r
-                               val = (new File(imagePath, imageFile.getPath())).toString();\r
-                       }\r
-               }\r
-               return val;\r
-       }\r
-\r
-       /** Method insures that the image is loaded and not a broken reference\r
-         */\r
-       private void waitForImage()\r
-       throws InterruptedException\r
-       {\r
-               int w = fImage.getWidth(this);\r
-               int h = fImage.getHeight(this);\r
-               while (true)\r
-               {\r
-                       int flags = Toolkit.getDefaultToolkit().checkImage(fImage, w, h, this);\r
-                       if(((flags & ERROR) != 0) || ((flags & ABORT) != 0 ))\r
-                       {\r
-                               throw new InterruptedException();\r
-                       }\r
-                       else if((flags & (ALLBITS | FRAMEBITS)) != 0)\r
-                       {\r
-                               return;\r
-                       }\r
-                       Thread.sleep(10);\r
-               }\r
-       }\r
-\r
-       /** Fetches the attributes to use when rendering. This is\r
-         * implemented to multiplex the attributes specified in the\r
-         * model with a StyleSheet.\r
-         */\r
-       public AttributeSet getAttributes()\r
-       {\r
-               return attr;\r
-       }\r
-\r
-       /** Method tests whether the image within a link\r
-         */\r
-       boolean isLink()\r
-       {\r
-               AttributeSet anchorAttr = (AttributeSet)fElement.getAttributes().getAttribute(HTML.Tag.A);\r
-               if(anchorAttr != null)\r
-               {\r
-                       return anchorAttr.isDefined(HTML.Attribute.HREF);\r
-               }\r
-               return false;\r
-       }\r
-\r
-       /** Method returns the size of the border to use\r
-         */\r
-       int getBorder()\r
-       {\r
-               return getIntAttr(HTML.Attribute.BORDER, isLink() ? DEFAULT_BORDER : 0);\r
-       }\r
-\r
-       /** Method returns the amount of extra space to add along an axis\r
-               */\r
-       int getSpace(int axis)\r
-       {\r
-               return getIntAttr((axis == X_AXIS) ? HTML.Attribute.HSPACE : HTML.Attribute.VSPACE, 0);\r
-       }\r
-\r
-       /** Method returns the border's color, or null if this is not a link\r
-       */\r
-       Color getBorderColor()\r
-       {\r
-               StyledDocument doc = (StyledDocument)getDocument();\r
-               return doc.getForeground(getAttributes());\r
-       }\r
-\r
-       /** Method returns the image's vertical alignment\r
-         */\r
-       float getVerticalAlignment()\r
-       {\r
-               String align = (String)fElement.getAttributes().getAttribute(HTML.Attribute.ALIGN);\r
-               if(align != null)\r
-               {\r
-                       align = align.toLowerCase();\r
-                       if(align.equals(TOP) || align.equals(TEXTTOP))\r
-                       {\r
-                               return 0.0f;\r
-                       }\r
-                       else if(align.equals(this.CENTER) || align.equals(MIDDLE) || align.equals(ABSMIDDLE))\r
-                       {\r
-                               return 0.5f;\r
-                       }\r
-               }\r
-               return 1.0f; // default alignment is bottom\r
-       }\r
-\r
-       boolean hasPixels(ImageObserver obs)\r
-       {\r
-               return ((fImage != null) && (fImage.getHeight(obs) > 0) && (fImage.getWidth(obs) > 0));\r
-       }\r
-\r
-       /** Method returns a URL for the image source, or null if it could not be determined\r
-         */\r
-       private URL getSourceURL()\r
-       {\r
-               String src = (String)fElement.getAttributes().getAttribute(HTML.Attribute.SRC);\r
-               if(src == null)\r
-               {\r
-                       return null;\r
-               }\r
-               //URL reference = ((HTMLDocument)getDocument()).getBase();\r
-               try\r
-               {\r
-                       URL reference = new URL(BaseUrl);\r
-                       URL u = new URL(reference,src);\r
-                       return u;\r
-               }\r
-               catch(MalformedURLException mue)\r
-               {\r
-                       return null;\r
-               }\r
-       }\r
-\r
-       /** Method looks up an integer-valued attribute (not recursive!)\r
-         */\r
-       private int getIntAttr(HTML.Attribute name, int iDefault)\r
-       {\r
-               AttributeSet attr = fElement.getAttributes();\r
-               if(attr.isDefined(name))\r
-               {\r
-                       int i;\r
-                       String val = (String)attr.getAttribute(name);\r
-                       if(val == null)\r
-                       {\r
-                               i = iDefault;\r
-                       }\r
-                       else\r
-                       {\r
-                               try\r
-                               {\r
-                                       i = Math.max(0, Integer.parseInt(val));\r
-                               }\r
-                               catch(NumberFormatException nfe)\r
-                               {\r
-                                       i = iDefault;\r
-                               }\r
-                       }\r
-                       return i;\r
-               }\r
-               else\r
-               {\r
-                       return iDefault;\r
-               }\r
-       }\r
-\r
-       /**\r
-       * Establishes the parent view for this view.\r
-       * Seize this moment to cache the AWT Container I'm in.\r
-       */\r
-       public void setParent(View parent)\r
-       {\r
-               super.setParent(parent);\r
-               fContainer = ((parent != null) ? getContainer() : null);\r
-               if((parent == null) && (fComponent != null))\r
-               {\r
-                       fComponent.getParent().remove(fComponent);\r
-                       fComponent = null;\r
-               }\r
-       }\r
-\r
-       /** My attributes may have changed. */\r
-       public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f)\r
-       {\r
-               super.changedUpdate(e, a, f);\r
-               float align = getVerticalAlignment();\r
-\r
-               int height = fHeight;\r
-               int width  = fWidth;\r
-\r
-               initialize(getElement());\r
-\r
-               boolean hChanged = fHeight != height;\r
-               boolean wChanged = fWidth != width;\r
-               if(hChanged || wChanged || getVerticalAlignment() != align)\r
-               {\r
-                       getParent().preferenceChanged(this, hChanged, wChanged);\r
-               }\r
-       }\r
-\r
-\r
-       /**\r
-         * Paints the image.\r
-         *\r
-         * @param g the rendering surface to use\r
-         * @param a the allocated region to render into\r
-         * @see View#paint\r
-         */\r
-       public void paint(Graphics g, Shape a)\r
-       {\r
-               Color oldColor = g.getColor();\r
-               fBounds = a.getBounds();\r
-               int border = getBorder();\r
-               int x = fBounds.x + border + getSpace(X_AXIS);\r
-               int y = fBounds.y + border + getSpace(Y_AXIS);\r
-               int width = fWidth;\r
-               int height = fHeight;\r
-               int sel = getSelectionState();\r
-\r
-               // If no pixels yet, draw gray outline and icon\r
-               if(!hasPixels(this))\r
-               {\r
-                       g.setColor(Color.lightGray);\r
-                       g.drawRect(x, y, width - 1, height - 1);\r
-                       g.setColor(oldColor);\r
-                       loadImageStatusIcons();\r
-                       Icon icon = ((fImage == null) ? sMissingImageIcon : sPendingImageIcon);\r
-                       if(icon != null)\r
-                       {\r
-                               icon.paintIcon(getContainer(), g, x, y);\r
-                       }\r
-               }\r
-\r
-               // Draw image\r
-               if(fImage != null)\r
-               {\r
-                       g.drawImage(fImage, x, y, width, height, this);\r
-               }\r
-\r
-               // If selected exactly, we need a black border & grow-box\r
-               Color bc = getBorderColor();\r
-               if(sel == 2)\r
-               {\r
-                       // Make sure there's room for a border\r
-                       int delta = 2 - border;\r
-                       if(delta > 0)\r
-                       {\r
-                               x += delta;\r
-                               y += delta;\r
-                               width -= delta << 1;\r
-                               height -= delta << 1;\r
-                               border = 2;\r
-                       }\r
-                       bc = null;\r
-                       g.setColor(Color.black);\r
-                       // Draw grow box\r
-                       g.fillRect(x + width - 5, y + height - 5, 5, 5);\r
-               }\r
-\r
-               // Draw border\r
-               if(border > 0)\r
-               {\r
-                       if(bc != null)\r
-                       {\r
-                               g.setColor(bc);\r
-                       }\r
-                       // Draw a thick rectangle:\r
-                       for(int i = 1; i <= border; i++)\r
-                       {\r
-                               g.drawRect(x - i, y - i, width - 1 + i + i, height - 1 + i + i);\r
-                       }\r
-                       g.setColor(oldColor);\r
-               }\r
-       }\r
-\r
-       /** Request that this view be repainted. Assumes the view is still at its last-drawn location.\r
-         */\r
-       protected void repaint(long delay)\r
-       {\r
-               if((fContainer != null) && (fBounds != null))\r
-               {\r
-                       fContainer.repaint(delay, fBounds.x, fBounds.y, fBounds.width, fBounds.height);\r
-               }\r
-       }\r
-\r
-       /**\r
-         * Determines whether the image is selected, and if it's the only thing selected.\r
-         * @return  0 if not selected, 1 if selected, 2 if exclusively selected.\r
-         * "Exclusive" selection is only returned when editable.\r
-         */\r
-       protected int getSelectionState()\r
-       {\r
-               int p0 = fElement.getStartOffset();\r
-               int p1 = fElement.getEndOffset();\r
-               if(fContainer instanceof JTextComponent)\r
-               {\r
-                       JTextComponent textComp = (JTextComponent)fContainer;\r
-                       int start = textComp.getSelectionStart();\r
-                       int end = textComp.getSelectionEnd();\r
-                       if((start <= p0) && (end >= p1))\r
-                       {\r
-                               if((start == p0) && (end == p1) && isEditable())\r
-                               {\r
-                                       return 2;\r
-                               }\r
-                               else\r
-                               {\r
-                                       return 1;\r
-                               }\r
-                       }\r
-               }\r
-               return 0;\r
-       }\r
-\r
-       protected boolean isEditable()\r
-       {\r
-               return ((fContainer instanceof JEditorPane) && ((JEditorPane)fContainer).isEditable());\r
-       }\r
-\r
-       /** Returns the text editor's highlight color.\r
-         */\r
-       protected Color getHighlightColor()\r
-       {\r
-               JTextComponent textComp = (JTextComponent)fContainer;\r
-               return textComp.getSelectionColor();\r
-       }\r
-\r
-       // Progressive display -------------------------------------------------\r
-\r
-       // This can come on any thread. If we are in the process of reloading\r
-       // the image and determining our state (loading == true) we don't fire\r
-       // preference changed, or repaint, we just reset the fWidth/fHeight as\r
-       // necessary and return. This is ok as we know when loading finishes\r
-       // it will pick up the new height/width, if necessary.\r
-\r
-       private static boolean sIsInc = true;\r
-       private static int sIncRate = 100;\r
-\r
-       public boolean imageUpdate(Image img, int flags, int x, int y, int width, int height)\r
-       {\r
-               if((fImage == null) || (fImage != img))\r
-               {\r
-                       return false;\r
-               }\r
-\r
-               // Bail out if there was an error\r
-               if((flags & (ABORT|ERROR)) != 0)\r
-               {\r
-                       fImage = null;\r
-                       repaint(0);\r
-                       return false;\r
-               }\r
-\r
-               // Resize image if necessary\r
-               short changed = 0;\r
-               if((flags & ImageObserver.HEIGHT) != 0)\r
-               {\r
-                       if(!getElement().getAttributes().isDefined(HTML.Attribute.HEIGHT))\r
-                       {\r
-                               changed |= 1;\r
-                       }\r
-               }\r
-               if((flags & ImageObserver.WIDTH) != 0)\r
-               {\r
-                       if(!getElement().getAttributes().isDefined(HTML.Attribute.WIDTH))\r
-                       {\r
-                               changed |= 2;\r
-                       }\r
-               }\r
-\r
-               synchronized(this)\r
-               {\r
-                       if((changed & 1) == 1)\r
-                       {\r
-                               fWidth = width;\r
-                       }\r
-                       if((changed & 2) == 2)\r
-                       {\r
-                               fHeight = height;\r
-                       }\r
-                       if(bLoading)\r
-                       {\r
-                               // No need to resize or repaint, still in the process of loading\r
-                               return true;\r
-                       }\r
-               }\r
-\r
-               if(changed != 0)\r
-               {\r
-                       // May need to resize myself, asynchronously\r
-                       Document doc = getDocument();\r
-                       try\r
-                       {\r
-                               if(doc instanceof AbstractDocument)\r
-                               {\r
-                                       ((AbstractDocument)doc).readLock();\r
-                               }\r
-                               preferenceChanged(this, true, true);\r
-                       }\r
-                       finally\r
-                       {\r
-                               if(doc instanceof AbstractDocument)\r
-                               {\r
-                                       ((AbstractDocument)doc).readUnlock();\r
-                               }\r
-                       }\r
-                       return true;\r
-               }\r
-\r
-               // Repaint when done or when new pixels arrive\r
-               if((flags & (FRAMEBITS|ALLBITS)) != 0)\r
-               {\r
-                       repaint(0);\r
-               }\r
-               else if((flags & SOMEBITS) != 0)\r
-               {\r
-                       if(sIsInc)\r
-                       {\r
-                               repaint(sIncRate);\r
-                       }\r
-               }\r
-               return ((flags & ALLBITS) == 0);\r
-       }\r
-\r
-       // Layout --------------------------------------------------------------\r
-\r
-       /** Determines the preferred span for this view along an axis.\r
-         *\r
-         * @param axis may be either X_AXIS or Y_AXIS\r
-         * @returns  the span the view would like to be rendered into.\r
-         *           Typically the view is told to render into the span\r
-         *           that is returned, although there is no guarantee.\r
-         *           The parent may choose to resize or break the view.\r
-         */\r
-       public float getPreferredSpan(int axis)\r
-       {\r
-               int extra = 2 * (getBorder() + getSpace(axis));\r
-               switch(axis)\r
-               {\r
-                       case View.X_AXIS:\r
-                               return fWidth+extra;\r
-                       case View.Y_AXIS:\r
-                               return fHeight+extra;\r
-                       default:\r
-                               throw new IllegalArgumentException("Invalid axis in getPreferredSpan() : " + axis);\r
-               }\r
-       }\r
-\r
-       /** Determines the desired alignment for this view along an\r
-         * axis. This is implemented to give the alignment to the\r
-         * bottom of the icon along the y axis, and the default\r
-         * along the x axis.\r
-         *\r
-         * @param axis may be either X_AXIS or Y_AXIS\r
-         * @returns the desired alignment. This should be a value\r
-         *   between 0.0 and 1.0 where 0 indicates alignment at the\r
-         *   origin and 1.0 indicates alignment to the full span\r
-         *   away from the origin. An alignment of 0.5 would be the\r
-         *   center of the view.\r
-         */\r
-       public float getAlignment(int axis)\r
-       {\r
-               switch(axis)\r
-               {\r
-                       case View.Y_AXIS:\r
-                               return getVerticalAlignment();\r
-                       default:\r
-                               return super.getAlignment(axis);\r
-               }\r
-       }\r
-\r
-       /** Provides a mapping from the document model coordinate space\r
-         * to the coordinate space of the view mapped to it.\r
-         *\r
-         * @param pos the position to convert\r
-         * @param a the allocated region to render into\r
-         * @return the bounding box of the given position\r
-         * @exception BadLocationException if the given position does not represent a\r
-         *   valid location in the associated document\r
-         * @see View#modelToView\r
-         */\r
-       public Shape modelToView(int pos, Shape a, Position.Bias b)\r
-       throws BadLocationException\r
-       {\r
-               int p0 = getStartOffset();\r
-               int p1 = getEndOffset();\r
-               if((pos >= p0) && (pos <= p1))\r
-               {\r
-                       Rectangle r = a.getBounds();\r
-                       if(pos == p1)\r
-                       {\r
-                               r.x += r.width;\r
-                       }\r
-                       r.width = 0;\r
-                       return r;\r
-               }\r
-               return null;\r
-       }\r
-\r
-       /** Provides a mapping from the view coordinate space to the logical\r
-         * coordinate space of the model.\r
-         *\r
-         * @param x the X coordinate\r
-         * @param y the Y coordinate\r
-         * @param a the allocated region to render into\r
-         * @return the location within the model that best represents the\r
-         *         given point of view\r
-         * @see View#viewToModel\r
-         */\r
-       public int viewToModel(float x, float y, Shape a, Position.Bias[] bias)\r
-       {\r
-               Rectangle alloc = (Rectangle) a;\r
-               if(x < (alloc.x + alloc.width))\r
-               {\r
-                       bias[0] = Position.Bias.Forward;\r
-                       return getStartOffset();\r
-               }\r
-               bias[0] = Position.Bias.Backward;\r
-               return getEndOffset();\r
-       }\r
-\r
-       /** Change the size of this image. This alters the HEIGHT and WIDTH\r
-         * attributes of the Element and causes a re-layout.\r
-         */\r
-       protected void resize(int width, int height)\r
-       {\r
-               if((width == fWidth) && (height == fHeight))\r
-               {\r
-                       return;\r
-               }\r
-               fWidth = width;\r
-               fHeight= height;\r
-               // Replace attributes in document\r
-               MutableAttributeSet attr = new SimpleAttributeSet();\r
-               attr.addAttribute(HTML.Attribute.WIDTH ,Integer.toString(width));\r
-               attr.addAttribute(HTML.Attribute.HEIGHT,Integer.toString(height));\r
-               ((StyledDocument)getDocument()).setCharacterAttributes(fElement.getStartOffset(), fElement.getEndOffset(), attr, false);\r
-       }\r
-\r
-       // Mouse event handling ------------------------------------------------\r
-\r
-       /** Select or grow image when clicked.\r
-         */\r
-       public void mousePressed(MouseEvent e)\r
-       {\r
-               Dimension size = fComponent.getSize();\r
-               if((e.getX() >= (size.width - 7)) && (e.getY() >= (size.height - 7)) && (getSelectionState() == 2))\r
-               {\r
-                       // Click in selected grow-box:\r
-                       Point loc = fComponent.getLocationOnScreen();\r
-                       fGrowBase = new Point(loc.x + e.getX() - fWidth, loc.y + e.getY() - fHeight);\r
-                       fGrowProportionally = e.isShiftDown();\r
-               }\r
-               else\r
-               {\r
-                       // Else select image:\r
-                       fGrowBase = null;\r
-                       JTextComponent comp = (JTextComponent)fContainer;\r
-                       int start = fElement.getStartOffset();\r
-                       int end = fElement.getEndOffset();\r
-                       int mark = comp.getCaret().getMark();\r
-                       int dot  = comp.getCaret().getDot();\r
-                       if(e.isShiftDown())\r
-                       {\r
-                               // extend selection if shift key down:\r
-                               if(mark <= start)\r
-                               {\r
-                                       comp.moveCaretPosition(end);\r
-                               }\r
-                               else\r
-                               {\r
-                                       comp.moveCaretPosition(start);\r
-                               }\r
-                       }\r
-                       else\r
-                       {\r
-                               // just select image, without shift:\r
-                               if(mark != start)\r
-                               {\r
-                                       comp.setCaretPosition(start);\r
-                               }\r
-                               if(dot != end)\r
-                               {\r
-                                       comp.moveCaretPosition(end);\r
-                               }\r
-                       }\r
-               }\r
-       }\r
-\r
-       /** Resize image if initial click was in grow-box: */\r
-       public void mouseDragged(MouseEvent e)\r
-       {\r
-               if(fGrowBase != null)\r
-               {\r
-                       Point loc = fComponent.getLocationOnScreen();\r
-                       int width = Math.max(2, loc.x + e.getX() - fGrowBase.x);\r
-                       int height= Math.max(2, loc.y + e.getY() - fGrowBase.y);\r
-                       if(e.isShiftDown() && fImage != null)\r
-                       {\r
-                               // Make sure size is proportional to actual image size\r
-                               float imgWidth = fImage.getWidth(this);\r
-                               float imgHeight = fImage.getHeight(this);\r
-                               if((imgWidth > 0) && (imgHeight > 0))\r
-                               {\r
-                                       float prop = imgHeight / imgWidth;\r
-                                       float pwidth = height / prop;\r
-                                       float pheight = width * prop;\r
-                                       if(pwidth > width)\r
-                                       {\r
-                                               width = (int)pwidth;\r
-                                       }\r
-                                       else\r
-                                       {\r
-                                               height = (int)pheight;\r
-                                       }\r
-                               }\r
-                       }\r
-                       resize(width,height);\r
-               }\r
-       }\r
-\r
-       public void mouseReleased(MouseEvent me)\r
-       {\r
-               fGrowBase = null;\r
-               //! Should post some command to make the action undo-able\r
-       }\r
-\r
-       /** On double-click, open image properties dialog.\r
-         */\r
-       public void mouseClicked(MouseEvent me)\r
-       {\r
-               if(me.getClickCount() == 2)\r
-               {\r
-                       //$ IMPLEMENT\r
-               }\r
-       }\r
-\r
-       public void mouseEntered(MouseEvent me) { ; }\r
-       public void mouseMoved(MouseEvent me)   { ; }\r
-       public void mouseExited(MouseEvent me)  { ; }\r
-\r
-       // Static icon accessors -----------------------------------------------\r
-\r
-       private Icon makeIcon(final String gifFile)\r
-       throws IOException\r
-       {\r
-               /* Copy resource into a byte array. This is\r
-                * necessary because several browsers consider\r
-                * Class.getResource a security risk because it\r
-                * can be used to load additional classes.\r
-                * Class.getResourceAsStream just returns raw\r
-                * bytes, which we can convert to an image.\r
-                */\r
-               InputStream resource = RelativeImageView.class.getResourceAsStream(gifFile);\r
-\r
-               if(resource == null)\r
-               {\r
-                       return null;\r
-               }\r
-               BufferedInputStream in = new BufferedInputStream(resource);\r
-               ByteArrayOutputStream out = new ByteArrayOutputStream(1024);\r
-               byte[] buffer = new byte[1024];\r
-               int n;\r
-               while((n = in.read(buffer)) > 0)\r
-               {\r
-                       out.write(buffer, 0, n);\r
-               }\r
-               in.close();\r
-               out.flush();\r
-\r
-               buffer = out.toByteArray();\r
-               if(buffer.length == 0)\r
-               {\r
-                       System.err.println("WARNING : " + gifFile + " is zero-length");\r
-                       return null;\r
-               }\r
-               return new ImageIcon(buffer);\r
-       }\r
-\r
-       private void loadImageStatusIcons()\r
-       {\r
-               try\r
-               {\r
-                       if(sPendingImageIcon == null)\r
-                       {\r
-                               sPendingImageIcon = makeIcon(PENDING_IMAGE_SRC);\r
-                       }\r
-                       if(sMissingImageIcon == null)\r
-                       {\r
-                               sMissingImageIcon = makeIcon(MISSING_IMAGE_SRC);\r
-                       }\r
-               }\r
-               catch(Exception e)\r
-               {\r
-                       System.err.println("ImageView : Couldn't load image icons");\r
-               }\r
-       }\r
-\r
-       protected StyleSheet getStyleSheet()\r
-       {\r
-               HTMLDocument doc = (HTMLDocument)getDocument();\r
-               return doc.getStyleSheet();\r
-       }\r
-\r
-}\r
+/*
+GNU Lesser General Public License
+
+RelativeImageView
+Copyright (C) 2001  Frits Jalvingh & Howard Kistler
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+package com.hexidec.ekit.component;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.Toolkit;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.awt.image.ImageObserver;
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Dictionary;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JEditorPane;
+import javax.swing.text.AbstractDocument;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
+import javax.swing.text.Element;
+import javax.swing.text.JTextComponent;
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.Position;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.StyledDocument;
+import javax.swing.text.View;
+import javax.swing.text.ViewFactory;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.HTMLDocument;
+import javax.swing.text.html.StyleSheet;
+import javax.swing.event.DocumentEvent;
+
+/**
+  * @author <a href="mailto:jal@grimor.com">Frits Jalvingh</a>
+  * @version 1.0
+  *
+  * This code was modeled after an artice on
+  * <a href="http://www.javaworld.com/javaworld/javatips/jw-javatip109.html">
+  * JavaWorld</a> by Bob Kenworthy.
+  */
+
+public class RelativeImageView extends View implements ImageObserver, MouseListener, MouseMotionListener
+{
+       public static final String TOP       = "top";
+       public static final String TEXTTOP   = "texttop";
+       public static final String MIDDLE    = "middle";
+       public static final String ABSMIDDLE = "absmiddle";
+       public static final String CENTER    = "center";
+       public static final String BOTTOM    = "bottom";
+       public static final String IMAGE_CACHE_PROPERTY = "imageCache";
+
+       private static Icon sPendingImageIcon;
+       private static Icon sMissingImageIcon;
+       private static final String PENDING_IMAGE_SRC = "icons/ImagePendingHK.gif";
+       private static final String MISSING_IMAGE_SRC = "icons/ImageMissingHK.gif";
+       private static final int DEFAULT_WIDTH  = 32;
+       private static final int DEFAULT_HEIGHT = 32;
+       private static final int DEFAULT_BORDER = 1;
+
+       private AttributeSet attr;
+       private Element      fElement;
+       private Image        fImage;
+       private int          fHeight;
+       private int          fWidth;
+       private Container    fContainer;
+       private Rectangle    fBounds;
+       private Component    fComponent;
+       private Point        fGrowBase; // base of drag while growing image
+       private boolean      fGrowProportionally; // should grow be proportional?
+       private String BaseUrl;
+       private boolean      bLoading; // set to true while the receiver is locked, to indicate the reciever is loading the image. This is used in imageUpdate.
+
+       /** Constructor
+         * Creates a new view that represents an IMG element.
+         * @param elem the element to create a view for
+         */
+       public RelativeImageView(Element elem,String baseurl)
+       {
+               super(elem);
+               BaseUrl = baseurl;
+               initialize(elem);
+               StyleSheet sheet = getStyleSheet();
+               attr = sheet.getViewAttributes(this);
+       }
+
+       private void initialize(Element elem)
+       {
+               synchronized(this)
+               {
+                       bLoading = true;
+                       fWidth  = 0;
+                       fHeight = 0;
+               }
+               int width = 0;
+               int height = 0;
+               boolean customWidth = false;
+               boolean customHeight = false;
+               try
+               {
+                       fElement = elem;
+                       // request image from document's cache
+                       AttributeSet attr = elem.getAttributes();
+                       if(true || isURL())
+                       {
+                               URL src = getSourceURL();
+                               if(src != null)
+                               {
+                                       Dictionary cache = (Dictionary)getDocument().getProperty(IMAGE_CACHE_PROPERTY);
+                                       if(cache != null)
+                                       {
+                                               fImage = (Image)cache.get(src);
+                                       }
+                                       else
+                                       {
+                                               fImage = Toolkit.getDefaultToolkit().getImage(src);
+                                       }
+                               }
+                       }
+                       else
+                       {
+                               // load image from relative path
+                               String src = (String)fElement.getAttributes().getAttribute(HTML.Attribute.SRC);
+                               src = processSrcPath(src);
+                               fImage = Toolkit.getDefaultToolkit().createImage(src);
+                               try
+                               {
+                                       waitForImage();
+                               }
+                               catch(InterruptedException ie)
+                               {
+                                       fImage = null;
+                                       // possibly replace with the ImageBroken icon, if that's what is happening
+                               }
+                       }
+
+                       // get height & width from params or image or defaults
+                       height = getIntAttr(HTML.Attribute.HEIGHT, -1);
+                       customHeight = (height > 0);
+                       if(!customHeight && fImage != null)
+                       {
+                               height = fImage.getHeight(this);
+                       }
+                       if(height <= 0)
+                       {
+                               height = DEFAULT_HEIGHT;
+                       }
+
+                       width = getIntAttr(HTML.Attribute.WIDTH, -1);
+                       customWidth = (width > 0);
+                       if(!customWidth && fImage != null)
+                       {
+                               width = fImage.getWidth(this);
+                       }
+                       if(width <= 0)
+                       {
+                               width = DEFAULT_WIDTH;
+                       }
+
+                       if(fImage != null)
+                       {
+                               if(customHeight && customWidth)
+                               {
+                                       Toolkit.getDefaultToolkit().prepareImage(fImage, height, width, this);
+                               }
+                               else
+                               {
+                                       Toolkit.getDefaultToolkit().prepareImage(fImage, -1, -1, this);
+                               }
+                       }
+               }
+               finally
+               {
+                       synchronized(this)
+                       {
+                               bLoading = false;
+                               if(customHeight || fHeight == 0)
+                               {
+                                       fHeight = height;
+                               }
+                               if(customWidth || fWidth == 0)
+                               {
+                                       fWidth = width;
+                               }
+                       }
+               }
+       }
+
+       /** Determines if path is in the form of a URL
+         */
+       private boolean isURL()
+       {
+               String src = (String)fElement.getAttributes().getAttribute(HTML.Attribute.SRC);
+               return src.toLowerCase().startsWith("file") || src.toLowerCase().startsWith("http");
+       }
+
+       /** Checks to see if the absolute path is availabe thru an application
+         * global static variable or thru a system variable. If so, appends
+         * the relative path to the absolute path and returns the String.
+         */
+       private String processSrcPath(String src)
+       {
+               String val = src;
+               File imageFile = new File(src);
+               if(imageFile.isAbsolute())
+               {
+                       return src;
+               }
+               boolean found = false;
+               Document doc = getDocument();
+               if(doc != null)
+               {
+                       String pv = (String)doc.getProperty("com.hexidec.ekit.docsource");
+                       if(pv != null)
+                       {
+                               File f = new File(pv);
+                               val     = (new File(f.getParent(), imageFile.getPath().toString())).toString();
+                               found = true;
+                       }
+               }
+               if(!found)
+               {
+                       String imagePath = System.getProperty("system.image.path.key");
+                       if(imagePath != null)
+                       {
+                               val = (new File(imagePath, imageFile.getPath())).toString();
+                       }
+               }
+               return val;
+       }
+
+       /** Method insures that the image is loaded and not a broken reference
+         */
+       private void waitForImage()
+       throws InterruptedException
+       {
+               int w = fImage.getWidth(this);
+               int h = fImage.getHeight(this);
+               while (true)
+               {
+                       int flags = Toolkit.getDefaultToolkit().checkImage(fImage, w, h, this);
+                       if(((flags & ERROR) != 0) || ((flags & ABORT) != 0 ))
+                       {
+                               throw new InterruptedException();
+                       }
+                       else if((flags & (ALLBITS | FRAMEBITS)) != 0)
+                       {
+                               return;
+                       }
+                       Thread.sleep(10);
+               }
+       }
+
+       /** Fetches the attributes to use when rendering. This is
+         * implemented to multiplex the attributes specified in the
+         * model with a StyleSheet.
+         */
+       public AttributeSet getAttributes()
+       {
+               return attr;
+       }
+
+       /** Method tests whether the image within a link
+         */
+       boolean isLink()
+       {
+               AttributeSet anchorAttr = (AttributeSet)fElement.getAttributes().getAttribute(HTML.Tag.A);
+               if(anchorAttr != null)
+               {
+                       return anchorAttr.isDefined(HTML.Attribute.HREF);
+               }
+               return false;
+       }
+
+       /** Method returns the size of the border to use
+         */
+       int getBorder()
+       {
+               return getIntAttr(HTML.Attribute.BORDER, isLink() ? DEFAULT_BORDER : 0);
+       }
+
+       /** Method returns the amount of extra space to add along an axis
+               */
+       int getSpace(int axis)
+       {
+               return getIntAttr((axis == X_AXIS) ? HTML.Attribute.HSPACE : HTML.Attribute.VSPACE, 0);
+       }
+
+       /** Method returns the border's color, or null if this is not a link
+       */
+       Color getBorderColor()
+       {
+               StyledDocument doc = (StyledDocument)getDocument();
+               return doc.getForeground(getAttributes());
+       }
+
+       /** Method returns the image's vertical alignment
+         */
+       float getVerticalAlignment()
+       {
+               String align = (String)fElement.getAttributes().getAttribute(HTML.Attribute.ALIGN);
+               if(align != null)
+               {
+                       align = align.toLowerCase();
+                       if(align.equals(TOP) || align.equals(TEXTTOP))
+                       {
+                               return 0.0f;
+                       }
+                       else if(align.equals(this.CENTER) || align.equals(MIDDLE) || align.equals(ABSMIDDLE))
+                       {
+                               return 0.5f;
+                       }
+               }
+               return 1.0f; // default alignment is bottom
+       }
+
+       boolean hasPixels(ImageObserver obs)
+       {
+               return ((fImage != null) && (fImage.getHeight(obs) > 0) && (fImage.getWidth(obs) > 0));
+       }
+
+       /** Method returns a URL for the image source, or null if it could not be determined
+         */
+       private URL getSourceURL()
+       {
+               String src = (String)fElement.getAttributes().getAttribute(HTML.Attribute.SRC);
+               if(src == null)
+               {
+                       return null;
+               }
+               try
+               {
+                       URL reference = new URL(BaseUrl);
+                       URL u = new URL(reference,src);
+                       return u;
+               }
+               catch(MalformedURLException mue)
+               {
+                       return null;
+               }
+       }
+
+       /** Method looks up an integer-valued attribute (not recursive!)
+         */
+       private int getIntAttr(HTML.Attribute name, int iDefault)
+       {
+               AttributeSet attr = fElement.getAttributes();
+               if(attr.isDefined(name))
+               {
+                       int i;
+                       String val = (String)attr.getAttribute(name);
+                       if(val == null)
+                       {
+                               i = iDefault;
+                       }
+                       else
+                       {
+                               try
+                               {
+                                       i = Math.max(0, Integer.parseInt(val));
+                               }
+                               catch(NumberFormatException nfe)
+                               {
+                                       i = iDefault;
+                               }
+                       }
+                       return i;
+               }
+               else
+               {
+                       return iDefault;
+               }
+       }
+
+       /**
+       * Establishes the parent view for this view.
+       * Seize this moment to cache the AWT Container I'm in.
+       */
+       public void setParent(View parent)
+       {
+               super.setParent(parent);
+               fContainer = ((parent != null) ? getContainer() : null);
+               if((parent == null) && (fComponent != null))
+               {
+                       fComponent.getParent().remove(fComponent);
+                       fComponent = null;
+               }
+       }
+
+       /** My attributes may have changed. */
+       public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f)
+       {
+               super.changedUpdate(e, a, f);
+               float align = getVerticalAlignment();
+
+               int height = fHeight;
+               int width  = fWidth;
+
+               initialize(getElement());
+
+               boolean hChanged = fHeight != height;
+               boolean wChanged = fWidth != width;
+               if(hChanged || wChanged || getVerticalAlignment() != align)
+               {
+                       getParent().preferenceChanged(this, hChanged, wChanged);
+               }
+       }
+
+
+       /**
+         * Paints the image.
+         *
+         * @param g the rendering surface to use
+         * @param a the allocated region to render into
+         * @see View#paint
+         */
+       public void paint(Graphics g, Shape a)
+       {
+               Color oldColor = g.getColor();
+               fBounds = a.getBounds();
+               int border = getBorder();
+               int x = fBounds.x + border + getSpace(X_AXIS);
+               int y = fBounds.y + border + getSpace(Y_AXIS);
+               int width = fWidth;
+               int height = fHeight;
+               int sel = getSelectionState();
+
+               // If no pixels yet, draw gray outline and icon
+               if(!hasPixels(this))
+               {
+                       g.setColor(Color.lightGray);
+                       g.drawRect(x, y, width - 1, height - 1);
+                       g.setColor(oldColor);
+                       loadImageStatusIcons();
+                       Icon icon = ((fImage == null) ? sMissingImageIcon : sPendingImageIcon);
+                       if(icon != null)
+                       {
+                               icon.paintIcon(getContainer(), g, x, y);
+                       }
+               }
+
+               // Draw image
+               if(fImage != null)
+               {
+                       g.drawImage(fImage, x, y, width, height, this);
+               }
+
+               // If selected exactly, we need a black border & grow-box
+               Color bc = getBorderColor();
+               if(sel == 2)
+               {
+                       // Make sure there's room for a border
+                       int delta = 2 - border;
+                       if(delta > 0)
+                       {
+                               x += delta;
+                               y += delta;
+                               width -= delta << 1;
+                               height -= delta << 1;
+                               border = 2;
+                       }
+                       bc = null;
+                       g.setColor(Color.black);
+                       // Draw grow box
+                       g.fillRect(x + width - 5, y + height - 5, 5, 5);
+               }
+
+               // Draw border
+               if(border > 0)
+               {
+                       if(bc != null)
+                       {
+                               g.setColor(bc);
+                       }
+                       // Draw a thick rectangle:
+                       for(int i = 1; i <= border; i++)
+                       {
+                               g.drawRect(x - i, y - i, width - 1 + i + i, height - 1 + i + i);
+                       }
+                       g.setColor(oldColor);
+               }
+       }
+
+       /** Request that this view be repainted. Assumes the view is still at its last-drawn location.
+         */
+       protected void repaint(long delay)
+       {
+               if((fContainer != null) && (fBounds != null))
+               {
+                       fContainer.repaint(delay, fBounds.x, fBounds.y, fBounds.width, fBounds.height);
+               }
+       }
+
+       /**
+         * Determines whether the image is selected, and if it's the only thing selected.
+         * @return  0 if not selected, 1 if selected, 2 if exclusively selected.
+         * "Exclusive" selection is only returned when editable.
+         */
+       protected int getSelectionState()
+       {
+               int p0 = fElement.getStartOffset();
+               int p1 = fElement.getEndOffset();
+               if(fContainer instanceof JTextComponent)
+               {
+                       JTextComponent textComp = (JTextComponent)fContainer;
+                       int start = textComp.getSelectionStart();
+                       int end = textComp.getSelectionEnd();
+                       if((start <= p0) && (end >= p1))
+                       {
+                               if((start == p0) && (end == p1) && isEditable())
+                               {
+                                       return 2;
+                               }
+                               else
+                               {
+                                       return 1;
+                               }
+                       }
+               }
+               return 0;
+       }
+
+       protected boolean isEditable()
+       {
+               return ((fContainer instanceof JEditorPane) && ((JEditorPane)fContainer).isEditable());
+       }
+
+       /** Returns the text editor's highlight color.
+         */
+       protected Color getHighlightColor()
+       {
+               JTextComponent textComp = (JTextComponent)fContainer;
+               return textComp.getSelectionColor();
+       }
+
+       // Progressive display -------------------------------------------------
+
+       // This can come on any thread. If we are in the process of reloading
+       // the image and determining our state (loading == true) we don't fire
+       // preference changed, or repaint, we just reset the fWidth/fHeight as
+       // necessary and return. This is ok as we know when loading finishes
+       // it will pick up the new height/width, if necessary.
+
+       private static boolean sIsInc = true;
+       private static int sIncRate = 100;
+
+       public boolean imageUpdate(Image img, int flags, int x, int y, int width, int height)
+       {
+               if((fImage == null) || (fImage != img))
+               {
+                       return false;
+               }
+
+               // Bail out if there was an error
+               if((flags & (ABORT|ERROR)) != 0)
+               {
+                       fImage = null;
+                       repaint(0);
+                       return false;
+               }
+
+               // Resize image if necessary
+               short changed = 0;
+               if((flags & ImageObserver.HEIGHT) != 0)
+               {
+                       if(!getElement().getAttributes().isDefined(HTML.Attribute.HEIGHT))
+                       {
+                               changed |= 1;
+                       }
+               }
+               if((flags & ImageObserver.WIDTH) != 0)
+               {
+                       if(!getElement().getAttributes().isDefined(HTML.Attribute.WIDTH))
+                       {
+                               changed |= 2;
+                       }
+               }
+
+               synchronized(this)
+               {
+                       if((changed & 1) == 1)
+                       {
+                               fWidth = width;
+                       }
+                       if((changed & 2) == 2)
+                       {
+                               fHeight = height;
+                       }
+                       if(bLoading)
+                       {
+                               // No need to resize or repaint, still in the process of loading
+                               return true;
+                       }
+               }
+
+               if(changed != 0)
+               {
+                       // May need to resize myself, asynchronously
+                       Document doc = getDocument();
+                       try
+                       {
+                               if(doc instanceof AbstractDocument)
+                               {
+                                       ((AbstractDocument)doc).readLock();
+                               }
+                               preferenceChanged(this, true, true);
+                       }
+                       finally
+                       {
+                               if(doc instanceof AbstractDocument)
+                               {
+                                       ((AbstractDocument)doc).readUnlock();
+                               }
+                       }
+                       return true;
+               }
+
+               // Repaint when done or when new pixels arrive
+               if((flags & (FRAMEBITS|ALLBITS)) != 0)
+               {
+                       repaint(0);
+               }
+               else if((flags & SOMEBITS) != 0)
+               {
+                       if(sIsInc)
+                       {
+                               repaint(sIncRate);
+                       }
+               }
+               return ((flags & ALLBITS) == 0);
+       }
+
+       // Layout --------------------------------------------------------------
+
+       /** Determines the preferred span for this view along an axis.
+         *
+         * @param axis may be either X_AXIS or Y_AXIS
+         * @returns  the span the view would like to be rendered into.
+         *           Typically the view is told to render into the span
+         *           that is returned, although there is no guarantee.
+         *           The parent may choose to resize or break the view.
+         */
+       public float getPreferredSpan(int axis)
+       {
+               int extra = 2 * (getBorder() + getSpace(axis));
+               switch(axis)
+               {
+                       case View.X_AXIS:
+                               return fWidth+extra;
+                       case View.Y_AXIS:
+                               return fHeight+extra;
+                       default:
+                               throw new IllegalArgumentException("Invalid axis in getPreferredSpan() : " + axis);
+               }
+       }
+
+       /** Determines the desired alignment for this view along an
+         * axis. This is implemented to give the alignment to the
+         * bottom of the icon along the y axis, and the default
+         * along the x axis.
+         *
+         * @param axis may be either X_AXIS or Y_AXIS
+         * @returns the desired alignment. This should be a value
+         *   between 0.0 and 1.0 where 0 indicates alignment at the
+         *   origin and 1.0 indicates alignment to the full span
+         *   away from the origin. An alignment of 0.5 would be the
+         *   center of the view.
+         */
+       public float getAlignment(int axis)
+       {
+               switch(axis)
+               {
+                       case View.Y_AXIS:
+                               return getVerticalAlignment();
+                       default:
+                               return super.getAlignment(axis);
+               }
+       }
+
+       /** Provides a mapping from the document model coordinate space
+         * to the coordinate space of the view mapped to it.
+         *
+         * @param pos the position to convert
+         * @param a the allocated region to render into
+         * @return the bounding box of the given position
+         * @exception BadLocationException if the given position does not represent a
+         *   valid location in the associated document
+         * @see View#modelToView
+         */
+       public Shape modelToView(int pos, Shape a, Position.Bias b)
+       throws BadLocationException
+       {
+               int p0 = getStartOffset();
+               int p1 = getEndOffset();
+               if((pos >= p0) && (pos <= p1))
+               {
+                       Rectangle r = a.getBounds();
+                       if(pos == p1)
+                       {
+                               r.x += r.width;
+                       }
+                       r.width = 0;
+                       return r;
+               }
+               return null;
+       }
+
+       /** Provides a mapping from the view coordinate space to the logical
+         * coordinate space of the model.
+         *
+         * @param x the X coordinate
+         * @param y the Y coordinate
+         * @param a the allocated region to render into
+         * @return the location within the model that best represents the
+         *         given point of view
+         * @see View#viewToModel
+         */
+       public int viewToModel(float x, float y, Shape a, Position.Bias[] bias)
+       {
+               Rectangle alloc = (Rectangle) a;
+               if(x < (alloc.x + alloc.width))
+               {
+                       bias[0] = Position.Bias.Forward;
+                       return getStartOffset();
+               }
+               bias[0] = Position.Bias.Backward;
+               return getEndOffset();
+       }
+
+       /** Change the size of this image. This alters the HEIGHT and WIDTH
+         * attributes of the Element and causes a re-layout.
+         */
+       protected void resize(int width, int height)
+       {
+               if((width == fWidth) && (height == fHeight))
+               {
+                       return;
+               }
+               fWidth = width;
+               fHeight= height;
+               // Replace attributes in document
+               MutableAttributeSet attr = new SimpleAttributeSet();
+               attr.addAttribute(HTML.Attribute.WIDTH ,Integer.toString(width));
+               attr.addAttribute(HTML.Attribute.HEIGHT,Integer.toString(height));
+               ((StyledDocument)getDocument()).setCharacterAttributes(fElement.getStartOffset(), fElement.getEndOffset(), attr, false);
+       }
+
+       // Mouse event handling ------------------------------------------------
+
+       /** Select or grow image when clicked.
+         */
+       public void mousePressed(MouseEvent e)
+       {
+               Dimension size = fComponent.getSize();
+               if((e.getX() >= (size.width - 7)) && (e.getY() >= (size.height - 7)) && (getSelectionState() == 2))
+               {
+                       // Click in selected grow-box:
+                       Point loc = fComponent.getLocationOnScreen();
+                       fGrowBase = new Point(loc.x + e.getX() - fWidth, loc.y + e.getY() - fHeight);
+                       fGrowProportionally = e.isShiftDown();
+               }
+               else
+               {
+                       // Else select image:
+                       fGrowBase = null;
+                       JTextComponent comp = (JTextComponent)fContainer;
+                       int start = fElement.getStartOffset();
+                       int end = fElement.getEndOffset();
+                       int mark = comp.getCaret().getMark();
+                       int dot  = comp.getCaret().getDot();
+                       if(e.isShiftDown())
+                       {
+                               // extend selection if shift key down:
+                               if(mark <= start)
+                               {
+                                       comp.moveCaretPosition(end);
+                               }
+                               else
+                               {
+                                       comp.moveCaretPosition(start);
+                               }
+                       }
+                       else
+                       {
+                               // just select image, without shift:
+                               if(mark != start)
+                               {
+                                       comp.setCaretPosition(start);
+                               }
+                               if(dot != end)
+                               {
+                                       comp.moveCaretPosition(end);
+                               }
+                       }
+               }
+       }
+
+       /** Resize image if initial click was in grow-box: */
+       public void mouseDragged(MouseEvent e)
+       {
+               if(fGrowBase != null)
+               {
+                       Point loc = fComponent.getLocationOnScreen();
+                       int width = Math.max(2, loc.x + e.getX() - fGrowBase.x);
+                       int height= Math.max(2, loc.y + e.getY() - fGrowBase.y);
+                       if(e.isShiftDown() && fImage != null)
+                       {
+                               // Make sure size is proportional to actual image size
+                               float imgWidth = fImage.getWidth(this);
+                               float imgHeight = fImage.getHeight(this);
+                               if((imgWidth > 0) && (imgHeight > 0))
+                               {
+                                       float prop = imgHeight / imgWidth;
+                                       float pwidth = height / prop;
+                                       float pheight = width * prop;
+                                       if(pwidth > width)
+                                       {
+                                               width = (int)pwidth;
+                                       }
+                                       else
+                                       {
+                                               height = (int)pheight;
+                                       }
+                               }
+                       }
+                       resize(width,height);
+               }
+       }
+
+       public void mouseReleased(MouseEvent me)
+       {
+               fGrowBase = null;
+               //! Should post some command to make the action undo-able
+       }
+
+       /** On double-click, open image properties dialog.
+         */
+       public void mouseClicked(MouseEvent me)
+       {
+               if(me.getClickCount() == 2)
+               {
+                       //$ IMPLEMENT
+               }
+       }
+
+       public void mouseEntered(MouseEvent me) { ; }
+       public void mouseMoved(MouseEvent me)   { ; }
+       public void mouseExited(MouseEvent me)  { ; }
+
+       // Static icon accessors -----------------------------------------------
+
+       private Icon makeIcon(final String gifFile)
+       throws IOException
+       {
+               /* Copy resource into a byte array. This is
+                * necessary because several browsers consider
+                * Class.getResource a security risk because it
+                * can be used to load additional classes.
+                * Class.getResourceAsStream just returns raw
+                * bytes, which we can convert to an image.
+                */
+               InputStream resource = RelativeImageView.class.getResourceAsStream(gifFile);
+
+               if(resource == null)
+               {
+                       return null;
+               }
+               BufferedInputStream in = new BufferedInputStream(resource);
+               ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
+               byte[] buffer = new byte[1024];
+               int n;
+               while((n = in.read(buffer)) > 0)
+               {
+                       out.write(buffer, 0, n);
+               }
+               in.close();
+               out.flush();
+
+               buffer = out.toByteArray();
+               if(buffer.length == 0)
+               {
+                       System.err.println("WARNING : " + gifFile + " is zero-length");
+                       return null;
+               }
+               return new ImageIcon(buffer);
+       }
+
+       private void loadImageStatusIcons()
+       {
+               try
+               {
+                       if(sPendingImageIcon == null)
+                       {
+                               sPendingImageIcon = makeIcon(PENDING_IMAGE_SRC);
+                       }
+                       if(sMissingImageIcon == null)
+                       {
+                               sMissingImageIcon = makeIcon(MISSING_IMAGE_SRC);
+                       }
+               }
+               catch(Exception e)
+               {
+                       System.err.println("ImageView : Couldn't load image icons");
+               }
+       }
+
+       protected StyleSheet getStyleSheet()
+       {
+               HTMLDocument doc = (HTMLDocument)getDocument();
+               return doc.getStyleSheet();
+       }
+
+}
diff --git a/ekit/com/hexidec/util/CMUS.proposal.txt b/ekit/com/hexidec/util/CMUS.proposal.txt
deleted file mode 100644 (file)
index c03b0ae..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Common MUsical Score\r\r/* ========================================================================= *\r                         CMUS - Common Musical Score\r\r                     An IFF File format for interchanging\r                   musical data using Common Music Notation\r\r                            by Talin (David Joiner)\r\r                                  Verion 0.4\r * ========================================================================= */\r\r#ifndef CMUS_H\r#define CMUS_H\r\r/* ========================================================================= *\r    Note to Non-Amiga users of this document\r    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r        CMUS is an IFF (Interchange File Format) file. IFF is a "Meta-standard"\r    for making extensible, self-identifying file formats, and was developed\r    by Commodore and Electronic Arts. In order to understand CMUS you will\r    need to get the IFF Documentation. The quickest way to do this is to\r    get the "Amiga ROM Kernal Manual: Devices" volume and look in the Appendix.\r * ========================================================================= *\r    Note on Timing:\r    ~~~~~~~~~~~~~~~\r        Common Music Notation is a symbolic, rather than a literal\r    representation. It is supposed to be interpreted by the player. A note\r    which is listed as "A quarter note", will seldom be played at the exact\r    time or duration as written. These deviations from mathematically perfect\r    time are important; they are part of what musicians call "feel" or\r    "liveliness".\r        Accordingly, FORM CMUS has two different kinds of timing information.\r    _Formal Time_ is represented in symbolic form: Each symbol has a field\r    which indicates it's duration (dotted quarter-note, etc) in symbolic units.\r    The formal start time of an event can be obtained by summing the durations\r    of all the previous times in the measure.\r        In addition, there is also _Casual Time_. Each event has a "start time"\r    which is the number of basic clock units from the start of the measure to\r    the start of that event. Some event types also have "duration" fields of\r    a similar nature.\r        In general, although there will probably be a strong correlation\r    between formal time and casual time, there is no guarantee of this.\r    Certainly this FORM does not enforce any relationship between the two.\r    This means that you cannot, in general, derive one from the other. You can\r    at most make an educated guess, and even that is a non-trivial problem\r    from an algorithmic point of view.\r\r * ========================================================================= *\r    Note on Layout Measurements:\r    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r        In general, I have tried to make all measurements as "device-\r    independent" as possible.\r\r        Measurements of page dimensions and other page-related information\r    such as margins and indentations are represented in micrometers.\r        Converting from micrometers to inches and "big points" (the definition\r    of points used by Adobe and Apple) can be done with the following\r    formulas:\r\r        inches = micrometers / 25400;\r\r        points = micrometers * 72 / 25400;\r\r        Vertical distances of musical items are all measured in "Levels".\r    A level is one half the distance between the lines of a staff. A note on\r    the centerline of the staff is at level zero. Placing the note just above\r    that line (between the 2nd and 3rd staff line) makes it level 1, while\r    placing it below the centerline makes it level -1. Note that up is positive\r    in this coordinate system.\r        Note positions are recorded as a fraction of the measure width.\r\r * ========================================================================= *\r    Rules for clipboard use:\r    ~~~~~~~~~~~~~~~~~~~~~~~~\r        A CMUS chunk may be copied to the clipboard. In such cases, it is\r    possible that only a subset of the data might be written. Specifically,\r    measures and signatures which occur before the first selection point,\r    or after the last selection point should not be included. Note that\r    the measure containing the first selection point should be written,\r    however, even if it is not in the selection range itself. (As to whether\r    measure-lines are selectable is up to the application). In addition,\r    an initial time signature item for that measure should be written as\r    well; key signature and clef items are optional in this case. The\r    application receiving the clip has the option of whether to use the\r    signature items in the clip, or to ignore them and use the existing\r    signatures in the score. The application can also decide to "insert"\r    the clip into the score (causing existing other events to be shifted\r    later in time), or "merging" the events with the existing items.\r    The application can also choose to respect measure lines in the clip\r    (each new measure line causes the notes to be pasted into the next\r    measure) or to "flow" the notes across measure boundaries.\r        Note that the notes in a clip may be non-contiguous. For example,\r    If the user were to select every second note and copy those to the\r    clipboard, there would be "gaps" in the clipped track. Unfortunately,\r    a reader program would not be able to detect those gaps (since formal\r    time does not have an explicit start time) and thus the formal time\r    and the casual time would get out of sync. To avoid this problem,\r    "filler" events can be inserted into the score to fill up the empty space.\r    Note that the duration of a filler event is formal, unlike all the\r    other events.\r        Notation programs which only support contiguous selection (i.e.\r    can't have a deselected note between two selected notes) can ignore\r    filler items.\r        A filler event at the end of the measure is not neccessary.\r    In fact, there is no requirement in CMUS that a measure be "filled".\r    In addition, certain music programs allow more notes in a measure than\r    would legally fit (only while editing, the extra notes are never played).\r    CMUS readers should handle this case robustly.\r\r        This allows a reader to make intelligent use of the clip. The clip\r    can be pasted relative to an insertion point, and the relationship of\r    notes to measures can be (optionally) preserved, even if the selection\r    was non-contiguous.\r * ========================================================================= *\r    Future Directions\r    ~~~~~~~~~~~~~~~~~\r        A number of musical features are currently mising from the CMUS spec,\r    such as the ability for a track to jump from one staff to another. In\r    addition, there are a number of features which would be desirable on the\r    "page" level, such as seperate margins for each page (currently, there is\r    no representation of individual pages in the spec).\r        All of these things can easily be added by defining new IFF chunks\r    or new event types. I have not done this because I feel that these\r    additional features would best be designed by the person who needs them,\r    in other words someone designing a music product that requires such\r    features and is familiar with the issues inolved. Otherwise, the format\r    might be defined wrongly, missing subtle advantages which\r*/\r\r/* ========================================================================= *\r                             General Definitions\r * ========================================================================= */\r\rtypedef long            Micrometers;\r\r#if CM_MICRO_CONVERSION\r\r    /* (optional) conversion to / from inches */\r\r#define InchesToMicros(inches)  ((inches) * 25400)\r#define MicrosToInches(micros)  (((micros) + 12700) / 25400)\r\r#define HundredthsToMicros(inches)  ((inches) * 254)\r#define MicrosToHundredths(micros)  (((micros) + 127) / 254)\r\r#define PointsToMicros(points)  (((points) * 25400 + 36) / 72)\r#define MicrosToPoints(micros)  (((micros) * 72 + 12700) / 25400)\r\r#endif\r\r/* ========================================================================= *\r                           Score Header Chunk (SCHD)\r * ========================================================================= */\r\rtypedef struct {\r    WORD                scBarsPerLine;      /* preferred bars per line      */\r    WORD                scOverallVolume;    /* overall volume of score      */\r\r    Micrometers         scPageWidth,        /* width of page                */\r                        scPageHeight,       /* height of page               */\r                        scTopMargin,        /* top margin of score on page 1*/\r                        scFirstLineIndent,  /* left margin indent on line 1 */\r                        scLineIndent;       /* left indent on other lines   */\r} CM_ScoreHeader;\r\r/* ========================================================================= *\r                            Staff Table Chunk (STAF)\r\r   This section describes the data structures which are used in the CMUS 'STAF'\r   Chunk. There is one STFF chunk per score, which contains an array of\r   StaffEntry structres (1 per staff in the document).\r\r * ========================================================================= */\r\rtypedef struct {\r    WORD                staffFlags;         /* various flags                */\r\r        /*  This defines the vertical size of a measure. Both of the distances\r            are measured from the center line of the staff (in fact all staff-\r            relative distances are represented this way).\r        */\r\r    Micrometers         staffSpaceAbove,    /* space above staff            */\r                        staffSpaceBelow;    /* space below staff            */\r\r    Micrometers         staffLevelSize;     /* distance between staff lines */\r\r} CM_StaffEntry;\r\r    /* This flag indicates that a formfeed should be done before printing\r        this staff (used when a score has more staffs than will fit on a page.\r    */\r\r#define STAFF_PAGEBREAK (1<<0)\r\r    /*  This indicates that the measure lines for this staff should not be\r        connected to the measure lines for the staff below\r    */\r\r#define STAFF_BAR_BROKEN (1<<1)\r\r    /*  This flag indicates that a set of "curly braces" should connect this\r        staff with the staff below.\r    */\r\r#define STAFF_BRACED    (1<<2)              /* Staff is "braced" with next  */\r\r    /*  These flags indicate the start and end of a square bracket which can\r        span over several staffs. The brace should start at the staff\r        marked with the "START" bit and continue until a staff with the\r        "END" bit is encountered.\r    */\r\r#define STAFF_BRACKET_START (1<<3)\r#define STAFF_BRACKET_END   (1<<4)\r\r/* ========================================================================= *\r                               Track Chunk (TRCK)\r\r   This section describes the data structures which are used in the CMUS 'TRCK'\r   Chunk.\r\r   A track is a sequence of notes which reside on a staff. In the simplest\r   case, there is one TRCK chunk per melody line in the score. However, a\r   track can contain chords, rests, etc, as well.\r\r   A more precise definition of a track is that a track is a sequence of\r   chords, where all the notes within each chord have the same start time\r   and the same duration (in formal time of course; in casual time anything\r   is possible). Note that ties can be used to create the illusion of\r   having broken this rule.\r\r * ========================================================================= */\r\r/*  Track Header structure:\r\r    Each track begins with a track header structure, followed by any number\r    of score items. (Use the chunk length to determine when to stop reading\r    score items).\r*/\r\rtypedef struct {\r    UWORD               trkStaff,           /* staff number to place this on*/\r                        trkTrack,           /* track number within staff    */\r                        trkFlags;           /* flags for staff header       */\r\r        /*  Sometimes notes on the staff are written transposed from how they\r            should actually be played. This is the number that should be added\r            to the pitch before it is actually played back.\r        */\r\r    WORD                trkTransposition;   /* playback transposition       */\r\r} CM_TrackHeader;\r\r/* ========================================================================= *\r                                      Track Item\r * ========================================================================= */\r\r/*  Item Header:\r\r    Score items are variable in length. The first byte of the item is the\r    length of the item in WORDS. This will allow new item types to be added\r    in the future. All score items are an integer number of WORDS long.\r\r    Each score item has a standard header structure, followed by a variable\r    amount of item-specific data. The 'itemType' field is used to determine what\r    that data is.\r\r    'itemLength' is the length of the item in WORDS. This allows items to be\r    from 2 to 512 bytes long. (The value '0' is reserved as a special case).\r\r    'itemXPos' contains the X position of the item in fractions of the measure's\r    width. Note that the area containing the signatures, and the area just\r    before the ending measure line are not considered part of this range.\r    Think of it this way: The value 0 is the first possible note position.\r    The value 0x7fff if the last possible note position. Items placed at\r    these positions should not run into the graphics at either the beginning\r    or the end of the measure. In addition, negative numbers are also\r    allows, which is used for symbols which penetrate into the "signature"\r    area. In this case, 0 represents the first possible note position, and\r    -0x8000 represents the actual barline. This convention is normally only\r    used for lyrics, which can intrude into the signature area.\r\r    'itemStart' is used to represent the real starting time of each event.\r    This is recorded as a delta-time, in other words itemStart contains\r    how many clock ticks have elapsed between the current item and the item\r    before it. Note that because of the fact that events can sometimes occur\r    out of order (for example, notes in a chord can be ordered by pitch rather\r    than by time, and they might not all start at exactly the same clock),\r    this value can be negative.\r        In addition, the clock is reset at each measure boundary. In other\r    words, the length of a measure is determined only by it's time signature,\r    and not by the delta between the last note and the next measure line.\r    In fact, the itemStart field for measure line items is ignored and should\r    always be set to zero.\r        An item's start time does NOT have to exactly match the event's\r    "formal" time. For example, an event at the beginning of a measure does\r    not have to start at exactly time zero, but can be offset somewhat.\r    This allows the subtle nuances of a live performance to be preserved, if\r    the notation software allows for that capability.\r\r    The 'itemStart' field (and the noteDuration field defined later) use a\r    clock standard of 960 clock ticks per whole note. Thus, a quarter note\r    is one/quarter that, or 240. This number is divisible by 3, 5, and several\r    powers of two, making it convenient for representing triplets and\r    quintuplets as well as small note values.\r*/\r\rtypedef struct {\r    UBYTE               itemLength,         /* length of item in WORDS      */\r                        itemType;           /* type of item                 */\r    WORD                itemXPos;           /* horizontal position of item  */\r    WORD                itemStart;          /* start time, in ticks         */\r} CM_ItemHeader;\r\r#define WHOLE_NOTE_DURATION     960         /* duration of a whole note     */\r\r#define MAX_ITEM_XPOS   0x7fff\r#define MMIN_ITEM_XPOS  -0x8000\r\r    /* type codes for chunk item types */\r\renum notation_item_types {\r    MEASURE_ITEM = 0,                       /* measure line                 */\r    SIGNATURE_ITEM,                         /* time sig., key sig., or clef */\r    NOTE_ITEM,                              /* first note in a chord        */\r    CHORD_ITEM,                             /* additional notes in a chord  */\r    FILLER_ITEM,                            /* fills up empty gaps          */\r    DYNAMIC_ITEM,                           /* dynamic volume item (fff)    */\r    INSTRUMENT_ITEM,                        /* instrument change item       */\r    TEMPO_ITEM,                             /* tempo change item            */\r    REPEAT_ITEM,                            /* for jumping around in score  */\r    BEGIN_GROUP_ITEM,                       /* begin slur, crescendo, etc.  */\r    END_GROUP_ITEM,                         /* end slur, crecendo, etc.     */\r    TABLATURE_ITEM,                         /* guitar or other tablature    */\r};\r\r/* ========================================================================= *\r                                  Measure Line Item\r * ========================================================================= */\r\r/*  This item represents the beginning of a new measure. As such, there should\r    be one of these at the beginning of the track, but not at the end.\r*/\r\rtypedef struct {\r    CM_ItemHeader       measureItem;        /* item header                  */\r    Micrometers         measureWidth;       /* width of measure             */\r    UBYTE               measureFlags;       /* various flags, see below     */\r\r        /*  measureEnding: If non-zero, it means that this measure is part\r            of an ending block. The value indicates which ending this measure\r            is part of. For example, if the value = 1, then this measure\r            is only played the first time through, if the value = 2 then\r            it is only played the second time through.\r\r            Each "repeat" section in the score can have it's own set of\r            endings.\r\r            "Endings" can be longer than one measure. Each measure that\r            is encountered that has the same value of measureEnding as the\r            previous measure is considered part of the same ending.\r        */\r\r    UBYTE               measureEnding;      /* "ending" this measure is in  */\r} CM_Measure;\r\r#define MEASURE_FULL_WIDTH 0x7fff           /* full width of score          */\r\renum measureFlags {\r\r        /*  Draw a double bar at the end of this measure. The reason for\r            associating the double-bar flag with the next measure line is\r            because double bar can occur at the end of the score but not\r            at the beginning.\r        */\r    MEASUREF_DOUBLE_BAR = (1<<0),\r\r        /*  This is a "line break", in other words it indicates that this\r            measure should start a new line.\r        */\r\r    MEASUREF_NEW_LINE   = (1<<1),\r\r        /*  If set, this flags means that the measure width was set by the\r            user. It not set, it means that measure width was calculated on\r            the fly, and can be re-adjusted feely if needed to line things\r            up. Note that this width includes signatures, but does not include\r            any indentation from the left margin of the document.\r        */\r\r    MEASUREF_FIXED      = (1<<2),\r\r};\r\r/* ========================================================================= *\r                               Signature Items\r * ========================================================================= */\r\r    /*  Signature items are usually placed just after the measure line.\r\r        Some notators have the ability to change clef in the middle of a\r        measure, but not all notators need support this. If it is not\r        supported, and a clef is encountered in the middle of a measure, it\r        is assumed to apply to the entire measure and therefore is associated\r        with the previous measure line.\r    */\r\r    /*  Signature types: Each signature has a "sigSubType" field which\r        indicates the type of signature. In addition, the high bit of the\r        signature type field indicates that the signature should not be\r        shown visibly.\r    */\r\renum SignatureTypes {\r    SIGTYPE_TIMESIG=1,\r    SIGTYPE_CLEF,\r    SIGTYPE_MAJORKEY,\r    SIGTYPE_MINORKEY,\r\r    SIGTYPE_HIDDEN=(1<<7)\r};\r\r    /*  Stores a time signature. 'Beats' is the number above the line, and\r        'Notes' is the number below the line. For example, '3/4' time is\r        stored as beats = 3, notes = 4.\r\r        "Common Time" (The "C" symbol) which is equivalent to 4/4 is stored\r        as 4/0 (beats = 4, notes = 0).\r\r        "Cut Time" ("C" with a slash through it) which is equivalent to\r        2/4 is stored as 2/0 (beats = 2, notes = 0).\r\r        In other words, the value "0" in "sigNotes" should always be treated\r        as the value "4" when calculating measure lengths. See the\r        MEASURE_LENGTH macro for an example of this.\r    */\r\rtypedef struct {\r    CM_ItemHeader       sigItem;            /* item header                  */\r    UBYTE               sigSubType,         /* (= SIGTYPE_TIMESIG)          */\r                        sigBeats,           /* beats per bar                */\r                        sigNotes,           /* size of each beat            */\r                        sigPad;\r} CM_TimeSignature;\r\r    /* compute the measure length in clock ticks */\r\r#define MEASURE_LENGTH(beats, notes) \\r    (WHOLE_NOTE_DURATION * beats / (notes ? notes : 4))\r\r    /* stores a Clef */\r\rtypedef struct {\r    CM_ItemHeader       sigItem;            /* item header                  */\r    UBYTE               sigSubType;         /* (= SIGTYPE_CLEF)             */\r    UBYTE               sigClef;            /* new clef                     */\r} CM_Clef;\r\r    /*  Definitions of clef types. Note clef modifier bits which are used as\r        part of this field as well.\r    */\r\renum ClefTypes {\r    TREBLE_CLEF = 0,                        /* G clef in normal position    */\r    BASS_CLEF,                              /* F clef in normal position    */\r    ALTO_CLEF,                              /* C clef centered on line 3    */\r    TENOR_CLEF,                             /* C clef centered on line 2    */\r\r        /* optional clefs, some of which are obselete (in the U.S.) */\r\r    SOPRANO_CLEF,                           /* C clef centered on line 5    */\r    MEZZO_SOPRANO_CLEF,                     /* C clef centered on line 4    */\r    BARITONE_CLEF,                          /* F clef one line lower        */\r    FRENCH_VIOLIN_CLEF,                     /* G clef one line lower        */\r\r        /*  For drum scores. One of the things implied by a drum clef is that\r            there might not be a relationship between a note's vertical\r            position and it's MIDI note number, unlike other clef types.\r            (This could be especially handy for work with MIDI drum machines).\r        */\r\r    DRUM_CLEF,                              /* vertical lines or box        */\r\r        /* clef modifier bits: A clef can be raised or lowered by one or two\r            octaves. This is notated by placing a small "8" or "15" above or\r            below the clef.\r        */\r\r    CLEF_DOWN_1_OCTAVE=(1<<4),              /* clef 1 oct lower (8 below)   */\r    CLEF_DOWN_2_OCTAVES=(1<<5),             /* clef 2 oct lower (15 below)  */\r    CLEF_UP_1_OCTAVE=(1<<6),                /* clef 1 oct higher (8 above)  */\r    CLEF_UP_2_OCTAVE=(1<<7),                /* clef 2 oct higher (15 above) */\r};\r\r    /*  stores a Key Signature. (used for both major and minor)\r\r        'sigKeySig' is a signed BYTE, where '0' is the key of C. Positive\r        numbers represent the number of sharps, so 1=G, 2=D, etc, around the\r        circle of fifths. Negative numbers represent the number of flats,\r        F=-1, B-Flat = -2, etc.\r\r        For minor keys, 0 is the key of A-minor, which like C has no sharps\r        or flats.\r\r        Other types of key signatures may be supported in the future, but\r        will probably be done as a different type of signature item.\r    */\r\rtypedef struct {\r    CM_ItemHeader       sigItem;            /* item header                  */\r    UBYTE               sigSubType;         /* (== SIGTYPE_KEYSIG)          */\r    BYTE                sigKeySig;          /* new key signature            */\r} CM_KeySignature;\r\r    /* major key definitions */\r\r#define KEY_OF_C_MAJOR           0\r#define KEY_OF_G_MAJOR           1\r#define KEY_OF_D_MAJOR           2\r#define KEY_OF_A_MAJOR           3\r#define KEY_OF_E_MAJOR           4\r#define KEY_OF_B_MAJOR           5\r#define KEY_OF_F_SHARP_MAJOR     6\r#define KEY_OF_C_SHARP_MAJOR     7\r#define KEY_OF_F_MAJOR          -1\r#define KEY_OF_B_FLAT_MAJOR     -2\r#define KEY_OF_E_FLAT_MAJOR     -3\r#define KEY_OF_A_FLAT_MAJOR     -4\r#define KEY_OF_D_FLAT_MAJOR     -5\r#define KEY_OF_G_FLAT_MAJOR     -6\r#define KEY_OF_C_FLAT_MAJOR     -7\r\r    /* minor key definitions */\r\r#define KEY_OF_A_MINOR           0\r#define KEY_OF_E_MINOR           1\r#define KEY_OF_B_MINOR           2\r#define KEY_OF_F_SHARP_MINOR     3\r#define KEY_OF_C_SHARP_MINOR     4\r#define KEY_OF_G_SHARP_MINOR     5\r#define KEY_OF_D_SHARP_MINOR     6\r#define KEY_OF_A_SHARP_MINOR     7\r#define KEY_OF_D_MINOR          -1\r#define KEY_OF_G_MINOR          -2\r#define KEY_OF_C_MINOR          -3\r#define KEY_OF_F_MINOR          -4\r#define KEY_OF_B_FLAT_MINOR     -5\r#define KEY_OF_E_FLAT_MINOR     -6\r#define KEY_OF_A_FLAT_MINOR     -7\r\r/* ========================================================================= *\r                              Note or Chord item\r * ========================================================================= */\r\r    /*  Note Items.\r\r        CHORDS: The first note of a chord is always of type "note".\r        Additional notes, or "intervals" are stored using the "chord"\r        type. The itemXPos, noteTuple, noteDots, noteDivision, noteStyle,\r        noteArpeggio, noteTrill and and noteBeamHeight fields are ignored\r        for chord items and are derived from the base note, however score\r        writers should set them to the same as the base note for consistency.\r\r        RESTS: A rest is a note item with a notePitch of 255. Rests may not\r        be chorded.\r\r        DRUM HEADS: If the NOTEF_DRUM flag is set, indicating that the\r        note has a "drum head" rather than an ordinary note head, then\r        all of the pitch-modifier fields should be ignored.\r\r        OPTIONAL FIELDS: For less sophisticated programs, many of the fields\r        in the note structure can be ignored.\r            At a minimum, notation programs should look at noteLevel,\r        noteAccidental, noteDivision and noteDots. When writing, all other\r        fields can be set to zero, with the exception of noteDuration\r        which should be set to the formal duration of the note in clock\r        ticks.\r            Sequencer programs should look at notePitch and noteDuration\r        when loading CMUS scores. Writing is more difficult. It is suggested\r        that unless the program is very sophisticated, that a different\r        FORM, or perhaps a Standard MIDI File, be used for writing out\r        sequencer data, as most of the fields in CMUS have meaning only to\r        a notator-type program.\r\r        Explanation of Fields:\r        ~~~~~~~~~~~~~~~~~~~~~~\r\r        noteDuration -- The casual duration of the note.\r\r        noteFlags -- various flags which affect either this note. Note that\r            the NOTEF_TIED and NOTEF_TIEDOWN can be different for each\r            note in a chord.\r\r        noteDots: 0, 1 or 2 depending on the number of "dots" this note\r            has. A dotted note is 50% longer. A double-dotted note is\r            75% longer.\r\r        noteDivision: Indicates the base duration of the note: whole note,\r            half note, quarter note, etc.\r\r        notePitch: The MIDI pitch number for this note.\r\r        noteArpeggio: Indicates an arpeggiated chord, one where the individual\r            notes are played sequentially (like a harp).\r\r        noteTrill: Trills are a rapid alternation between two notes. There\r            are vaious kinds, see below.\r\r        noteAccidental: This includes things like sharps and flats.\r\r        noteLevel: This is the distance, in levels, from the center line of\r            the staff.\r\r        noteBeamHeight: The height of a beamed group of notes isn't always\r            related to the height that the stem would be if the note were not\r            beamed. This field is the distance, in levels, from the center\r            line of the staff to the beam's position. This field is only\r            meaningful for the first and last note of a beam.\r\r        noteStyle: This is a field of flags which indicate things like\r            Staccato, Legato, and other "performance style" modifiers.\r    */\r\r/*  What the note structure looks like with bitfields:\r\r    CM_ItemHeader       noteItem;           -- item header\r\r    UWORD               noteDuration;       -- real duration, in ticks\r    UWORD               noteFlags;\r\r    unsigned int        Pad1           : 2\r                        noteDots       : 2, -- dotted, double-dotted\r                        noteDivision   : 4, -- quarter note, etc.\r\r    UBYTE               notePitch;          -- MIDI note number\r    unsigned int        noteArpeggio   : 2, -- arpeggiation\r                        noteTrill      : 3, -- various trill types\r                        noteAccidental : 3; -- sharp, flat, etc.\r\r    BYTE                noteLevel;          -- dist from staff centerline\r    BYTE                noteBeamHeight;     -- Y position of beam\r    UBYTE               noteStyle;          -- Note Style type\r*/\r\rtypedef struct {\r    CM_ItemHeader       noteItem;           /* item header                  */\r\r    UWORD               noteDuration;       /* real duration, in ticks      */\r    UWORD               noteFlags;          /* various note flags           */\r\r    UBYTE               noteDivision;       /* formal note length           */\r\r    UBYTE               notePitch;          /* MIDI note number             */\r    UBYTE               notePitchMods;      /* modifications to pitch       */\r    BYTE                noteLevel;          /* vertical position            */\r\r    BYTE                noteBeamHeight;     /* y position of beam           */\r    UBYTE               noteStyle;          /* Note Style type              */\r} CM_Note;\r\r    /* macros to access the various bitfields */\r\r#define CM_NoteDots(f)          (((f).noteDivision >> 4) & 0x03)\r#define CM_NoteDivision(f)      ((f).noteDivision & 0x0f)\r\r#define CM_NoteAccidental(f)    ((f).notePitchMods & 7)\r#define CM_NoteTrill(f)         (((f).notePitchMods >> 3) & 7)\r#define CM_NoteArpeggiation(f)  (((f).notePitchMods >> 6) & 3)\r\r#define CM_SetNoteDivision(note, division, dots) \\r        ((note).noteDivision = (dots << 4) | division)\r\r#define CM_SetNotePitchMods(note, arp, trill, accidental) \\r        ((note).notePitchMods = (arp << 6) | ((trill << 3) & 7) | (accidental & 7))\r\r#define CM_RestPitch    255\r\renum note_dots {\r    NO_DOT = 0,                             /* Note is normal duration      */\r    DOTTED_NOTE = 1,                        /* Note is 50% longer           */\r    DOUBLE_DOTTED = 2                       /* note is 75% longer           */\r};\r\renum note_divisions {\r    DOUBLE_WHOLE_NOTE = 0,\r    WHOLE_NOTE,\r    HALF_NOTE,\r    QUARTER_NOTE,\r    EIGHTH_NOTE,\r    SIXTEENTH_NOTE,\r    NOTE_32,\r    NOTE_64,\r    NOTE_128,\r    NOTE_256\r};\r\renum note_accidentals {\r    NOTE_ACC_NONE=0,\r    NOTE_ACC_DOUBLE_FLAT,\r    NOTE_ACC_FLAT,\r    NOTE_ACC_HALF_FLAT,\r    NOTE_ACC_NATURAL,\r    NOTE_ACC_HALF_SHARP,\r    NOTE_ACC_SHARP,\r    NOTE_ACC_DOUBLE_SHARP,\r\r        /*  drum styles: used in place of accidental when NOTEF_DRUM is set.\r            Hollow symbols are used in place of "hollow" note heads, such\r            as half notes.\r\r            Note that the assignment of drum parts to symbols is arbtrary,\r            however the X symbol in jazz notation means "brush", and the\r            triangle symbol is often assigned to the triangle instrument.\r            Note also that normal note heads are often used for many\r            drum instruments.\r        */\r\r    NOTE_DRUM_X=0,                          /* An "x" instead of note head  */\r    NOTE_DRUM_DIAMOND,                      /* diamond shape                */\r    NOTE_DRUM_SQUARE,                       /* square box                   */\r    NOTE_DRUM_TRIANGLE,                     /* triangle                     */\r\r};\r\r    /*  trills and tremolos and other pitch modulations which can be attached\r        to a note. Note that these apply to the entire chord.\r    */\r\renum note_trills {\r    NOTE_PMOD_NONE=0,\r    NOTE_PMOD_TRILL,\r    NOTE_PMOD_MORDENT,\r    NOTE_PMOD_INV_MORDENT,\r    NOTE_PMOD_TURN,\r};\r\r    /*  Arpeggiation, indicated as a vertical sqiggly line before the chord */\r\renum note_arp_mods {\r    NOTE_ARPEGGIO = 1,\r    NOTE_REV_ARPEGGIO = 2,\r};\r\r    /* note style flags */\r\r#define NSTYLEF_STACCATO        (1<<0)      /* Staccatto mark ('.')         */\r#define NSTYLEF_STACCATISSIMO   (1<<1)      /* Staccattissimo mark (wedge)  */\r#define NSTYLEF_LEGATO          (1<<2)      /* Legato ('-')                 */\r#define NSTYLEF_SFORZANDO       (1<<3)      /* Szorzando ('^')              */\r#define NSTYLEF_ACCENT          (1<<4)      /* Accent ('>')                 */\r#define NSTYLEF_TENUTO          (1<<5)      /* Tenuto (short '-')           */\r\r    /* general note flags */\r\renum noteFlags {\r    NOTEF_STEMDOWN      = (1<<0),           /* Note's stem is down          */\r    NOTEF_BEAMED        = (1<<1),           /* Note is beamed with next note*/\r    NOTEF_TIED          = (1<<2),           /* Note is tied with next note  */\r    NOTEF_TIEDOWN       = (1<<3),           /* tie direction is DOWN        */\r    NOTEF_GRACE         = (1<<4),           /* display as grace note        */\r    NOTEF_CUE           = (1<<5),           /* display as cue note          */\r    NOTEF_DRUM          = (1<<6),           /* note has a drum head         */\r    NOTEF_STEMSET       = (1<<7),           /* Stem direction fixed by user */\r\r    NOTEF_RES1          = (1<<12),          /* reserved by DMCS for play    */\r    NOTEF_RES2          = (1<<13),          /*      styles (sorry :-)       */\r    NOTEF_RES3          = (1<<14),\r    NOTEF_RES4          = (1<<15),\r};\r\r/* ========================================================================= *\r                                 Filler item\r * ========================================================================= */\r\r    /*  This item is used for supporting sparse clips. The fillerDuration\r        field contains the total of the formal durations of the missing\r        items between the previous event and the next one.\r    */\r\rtypedef struct {\r    CM_ItemHeader       fillerItem;         /* item header                  */\r    UWORD               fillerDuration;     /* formal size of items left out*/\r} CM_Filler;\r\r/* ========================================================================= *\r                                 Dynamic Item\r * ========================================================================= */\r\r    /*  This item specifies a MIDI volume. Note that the relationship between\r        Volume and dynamic markings (such as fff, pp, etc) is defined\r        elsewhere.\r    */\r\rtypedef struct {\r    CM_ItemHeader       dynItem;            /* item header                  */\r    BYTE                dynLevelPos;        /* vertical position in leveks  */\r    UBYTE               dynVolume;          /* midi pressure number (0..127)*/\r    BYTE                dynSymbol;          /* dynamic symbol, see below    */\r    UBYTE               dynPad;\r} CM_Dynamic;\r\r    /*  Dynamic symbols:\r\r        0 = symbol not specified, derive from MIDI volume.\r        +1 = mf         -1 = mp\r        +2 = f          -2 = p\r        +3 = ff         -3 = pp\r        +4 = fff        -4 = ppp\r                (etc)\r    */\r\r/* ========================================================================= *\r                               Instrument item\r * ========================================================================= */\r\r    /*  Rather than embedding the instrument names in the actual score, a\r        seperate "instrument table" chunk will be defined.\r    */\r\rtypedef struct {\r    CM_ItemHeader       instItem;           /* instrument item              */\r    UBYTE               instNumber;         /* instrument number from table */\r    UBYTE               instPad;\r} CM_Instrument;\r\r/* ========================================================================= *\r                                  Tempo Item\r * ========================================================================= */\r\r    /*  For compatibility with Standard MIDI files, tempo is represented as\r        microseconds per quarter note, rather than the more commonly used\r        quarter notes per minute. To convert from one to the other, the\r        following formula works both ways:\r\r                T = 60,000,000 / t;\r\r        For accuracy, you may want to round:\r\r                T = (60,000,000 + t/2) / t;\r\r        Of course, the user interface of the program should not use units\r        like this.\r    */\r\rtypedef struct {\r    CM_ItemHeader       tempoItem;          /* item header                  */\r    ULONG               tempoValue;         /* new tempo value              */\r} CM_Tempo;\r\r/* ========================================================================= *\r                                 Repeat Item\r * ========================================================================= */\r\r    /*  This is a general category of items for jumping around in the\r        score in a non-sequential fashion. It includes things like\r        begin/end repeat bars, repeat measure, Da Capo, etc.\r\r        "repeatCount" is the number of times that the jump should occur,\r        not the total number of times a passage should be played. For example,\r        an begin/end repeat which is to play twice (once through, and then\r        prepeated once) should have a repeatCount of "1".\r\r        In addition, repeatCount should be associated with the jump rather\r        than the label. This imples that the count should go with the\r        "end" of a begin/end block rather than the "begin".\r    */\r\rtypedef struct {\r    CM_ItemHeader       repeatItem;         /* item header                  */\r    UBYTE               repeatType;         /* subtype of group             */\r    UBYTE               repeatCount;        /* number of times to jump      */\r} CM_Repeat;\r\renum repeat_types {\r    REPEAT_BLOCK_BEGIN=0,                   /* defines a repeat block       */\r    REPEAT_BLOCK_END,\r\r    REPEAT_LAST_MEASURE,                    /* jumps back 1 measure         */\r    REPEAT_LAST_TWO_MEASURES,               /* jumps back 2 measures        */\r\r    REPEAT_MEASURE_REST,                    /* rest for N measures          */\r                                            /* (not really a jump)          */\r        /* labels to go to */\r\r    REPEAT_LABEL_SEGNO,                     /* The "sign" D.S. refers to    */\r    REPEAT_LABEL_CODA,                      /* The Coda symbol              */\r\r        /* goto operators */\r\r    REPEAT_DC,                              /* D.C.                         */\r    REPEAT_DC_AL_FINE,                      /* D.C. al fine                 */\r    REPEAT_DS,                              /* D.S.                         */\r    REPEAT_DS_AL_FINE,                      /* D.S. al fine                 */\r    REPEAT_DS_AL_CODA,                      /* D.S. al coda                 */\r};\r\r/* ========================================================================= *\r                                   Group Item\r * ========================================================================= */\r\r    /*  A "Group" Item is defined as a Slur, Crescendo, or Octave Raiser.\r        In general, groups can apply to any contiguous range of notes\r        on a track, and groups of the same type can note overlap.\r\r        Note that in some cases, such as for example a crecendo, although\r        the modification is technically "attached" to a particular\r        track, it affects all the tracks on that staff.\r    */\r\rtypedef struct {\r    CM_ItemHeader       groupItem;          /* item header                  */\r    UBYTE               groupType;          /* subtype of group             */\r\r        /*  To even out the structure, we'll add an extra byte which means\r            different things based on the group type. Right now it is\r            only defined in the case of a crescendo / decrescendo in which\r            case it means the final volume.\r\r            For all others, it should be set to zero.\r        */\r\r    UBYTE               groupVal;\r} CM_Group;\r\r    /* Types of group items supported */\r\renum group_types {\r    GROUPTYPE_SLUR_UP=0,\r    GROUPTYPE_SLUR_DOWN,\r    GROUPTYPE_CRESCENDO,\r    GROUPTYPE_DECRESCENDO,\r    GROUPTYPE_OCTAVE_UP,                    /* "8va" symbol                 */\r    GROUPTYPE_OCTAVE_DOWN,                  /* "8vb" symbol                 */\r    GROUPTYPE_GLISSANDO_UP,\r    GROUPTYPE_GLISSANDO_DOWN,\r\r    GROUPTYPE_TUPLET,                       /* see below                    */\r    GROUPTYPE_TRILL,                        /* the one with the wavy line   */\r    GROUPTYPE_TREMOLO,                      /* Slashes below a beam         */\r};\r\r    /* Tuplets are a subtype of group items, and as such have an extended\r        structure. Unlike other group types, tuplet group items can be nested.\r\r        Note that for ending a tuplet, the extra fields are not required\r        and a normal "Group" structure can be used. Each tuplet ending\r        item matches the nearest previous unmatched tuplet item.\r    */\r\rtypedef struct {\r    CM_ItemHeader       tupletItem;         /* item header                  */\r    UBYTE               tupletType;         /* subtype of group             */\r\r        /*  tupletNumber indicates how many notes can fit in the space of\r            'tupletSpace'. For example, a triplet, i.e. "3 in the space of 2",\r            or 2/3 duration, can be represented as tupletNumber = 3,\r            tupletSpace = 2.\r        */\r\r    UBYTE               tupletNumber,       /* How manu items               */\r                        tupletSpace;        /* in the space of how many     */\r\r        /*  tupletDigits represents the binary number which should be\r            displayed above the tuplet; For example, for a triplet this\r            should be 3.\r        */\r\r    UBYTE               tupletDigits;       /* number to display            */\r\r        /*  tupletFlags is for later use when we want tuplets combined with\r            slurs / brackets. Currently there are no flags defined, so the\r            field should be all zeroes.\r        */\r\r    UBYTE               tupletFlags,        /* various flags                */\r                        tupletPad;\r} CM_Tuplet;\r\r/* ========================================================================= *\r                                    Tablature Item\r * ========================================================================= */\r\r    /*  The Tablature item is used for guitar, banjo or other fretted\r        instruments. It's a two-dimensional array of bits, which is drawn\r        as a grid indicating the exact placement of fingers.\r\r        In addition, most tablatures have the name of the chord placed above\r        the grid. This can be quite complex, looking something like this:\r\r                     7+6\r                C min\r\r        Which means: "C minor, with an added seventh and a raised sixth".\r    */\r\rtypedef struct {\r    CM_ItemHeader       tabItem;            /* item header                  */\r\r        /*  tabRoot is used to indicate the name of the chord placed above\r            the tablature. Note that the root can have superscripts, which\r            are defined elsewhere.\r\r            unsigned int    rootLetter      : 3,    -- A, B, C, etc.\r                            rootAccidental  : 2,    -- accidental of root\r                            rootType        : 3,    -- major, minor, etc.\r        */\r\r    UBYTE               tabRoot;            /* describes root of chord      */\r\r        /*  tabDimensions is a field of two 4 bit values, representing the\r            width and height of the tablature array. A dimension of (0,0)\r            indicates that only the chord symbol should be used.\r        */\r\r    UBYTE               tabDimensions;      /* width/height of tab array    */\r\r        /*  tabIntervals is an optional field -- if it's zero, it means that\r            the writing program wasn't sophisticated enough to set it.\r            (This is generally true for programs that are typographical\r            rather than musical in orientation).\r\r            The field used to exactly describe the intervals in the\r            chord above the root. Each interval may be:\r\r                0 - missing ( no interval)\r                1 - lowered ( one half-step below major chord position )\r                2 - normal  ( in the normal position for a major chord )\r                3 - raised  ( one half-step above major chord position )\r\r            unsigned int    chordThird      : 2,    -- (missing, -1, 0, +1)\r                            chordFifth      : 2,    -- (missing, -1, 0, +1)\r                            chordSeventh    : 2,    -- (missing, -1, 0, +1)\r                            chordNinth      : 2,    -- (missing, -1, 0, +1)\r                            chordEleventh   : 2,    -- (missing, -1, 0, +1)\r                            chordThirteenth : 2,    -- (missing, -1, 0, +1)\r                            chordFifteenth  : 2,    -- (missing, -1, 0, +1)\r                            chordValid      : 1,    -- TRUE if field valid\r                            chordPad        : 1;\r        */\r\r    UWORD               tabIntervals;       /* describes exact chord intervals*/\r\r        /*  tabArray is a byte array of finger positions.\r\r            Each byte represents a string. The value of the byte\r            can be from 0 (representing an open string), or 1-16\r            (representing a finger placed above the Nth fret). The high\r            4 bits are reserved for now, but may be used later to indicate\r            special placement of the fingers.\r\r            Note that the tabArray can be longer or shorter than 6 bytes,\r            up to a maximum of 16 strings. In such cases, the event length\r            stored in the CM_ItemHeader would be adjusted accordingly.\r        */\r\r    UBYTE               tabArray[6];        /* tablature array              */\r\r        /*  Following the tabArray field is an optional variable-length\r            ASCII string which is the actual text of the superscript,\r            such as "maj6+7".\r\r            The length of the string can be computed comparing the end of\r            the event with the end of the tab-array. Null termination is\r            not required.\r        */\r\r};\r\renum chord_accidentals {\r    CHORD_ACC_NONE=0,\r    CHORD_ACC_FLAT,\r    CHORD_ACC_NATURAL,\r    CHORD_ACC_SHARP\r};\r\renum chord_types {\r    CHORD_TYPE_MAJOR,\r    CHORD_TYPE_MINOR,\r    CHORD_TYPE_DIMINISHED,\r    CHORD_TYPE_AUGMENTED,\r    CHORD_TYPE_SUSPENDED\r};\r\renum chord_letters {\r    CHORD_LETTER_A=0,\r    CHORD_LETTER_B,\r    CHORD_LETTER_C,\r    CHORD_LETTER_D,\r    CHORD_LETTER_E,\r    CHORD_LETTER_F,\r    CHORD_LETTER_G\r};\r\r/* ========================================================================= *\r                           Lyric Font Chunk (LFON)\r\r    This section describes the data structures which are used in the CMUS\r    'LFON' Chunk.\r\r    LFON chunks are used to store the font table for the document. Embedded\r    within the Lyric, Annotation and title chunks are font specifiers which\r    refer to a given font by number. That number is an index into this table.\r\r    There is one LFON chunk per font. Each LFON chunk consists of the following\r    header, and then the name of the font. The terminating NULL should be\r    included in the font name.\r\r * ========================================================================= */\r\rtypedef struct {\r    UWORD               fontNumber;             /* number assigned to font  */\r    UWORD               fontHeight;             /* height of font in points */\r\r    /* fontName follows */\r\r} CM_FontEntry;\r\r/* ========================================================================= *\r                              Lyric Chunk (LYRC)\r\r    This section describes the data structures which are used in the CMUS\r    'LYRC' Chunk.\r\r    Each lyric is associated with a particular track, and a particular measure\r    within that track. The reason for this is because certain elements within\r    the lyrics can be "attached" to notes within a track, so that syllables\r    of the lyric can properly appear under the notes.\r\r    Lyrics associated with a particular track are written immediately after\r    that track. In other words, when reading a lyric, it should be associated\r    with the previously read track.\r\r * ========================================================================= */\r\r    /*  This is the header structure for a lyric. It is followed by the actual\r        text of the lyric. No terminating NUL is used.\r\r        Attaching syllables to notes: This is an optional feature which need\r        not be supported by all readers. Basically, the TAB character is used\r        to specify a block of text to align with the next note. Essentially,\r        each chord on the trackÊacts as a center-justified tab-stop. This is\r        similar to the way tab stops work on medium- to high-end word\r        processors: All the text between a tab, and the next tab (or the end\r        of the line) is "centered" at the tab-stop position. Readers\r        which don't wish to deal with this level of complexity can just\r        treat the tab as a space.\r    */\r\rtypedef struct {\r    UWORD               lyricMeasure;       /* starting measure of lyric    */\r\r        /*  Position of the upper-left coordinate of the lyric.\r            This can be positive or negative, and is interpreted just like\r            the 'itemXPos' field for track events.\r        */\r\r    WORD                lyricXPos;          /* position relative to measure */\r\r        /*  lyricLevel is the position, in micrometers, of the upper-\r            left corner of the lyric's extent box.\r\r            lyricHeight is also in micrometers.\r        */\r\r    Micrometers         lyricLevel,         /* distance from center of staff*/\r                        lyricHeight;        /* height of lyric extent       */\r\r        /*  Width is in micrometers. */\r\r    Micrometers         lyricWidth;\r\r        /* lyric text string follows */\r\r} CM_Lyric;\r\r    /*  Codes for specification of fonts and text styles. The "newfont" code\r        is followed by the font number. If no font is specified, font #0 is\r        the default.\r    */\r\renum {\r    LSTYLE_BOLD_ON=0x80,\r    LSTYLE_BOLD_OFF,\r    LSTYLE_ITALIC_ON,\r    LSTYLE_ITALIC_OFF,\r    LSTYLE_UNDER_ON,\r    LSTYLE_UNDER_OFF,\r    LSTYLE_NEWFONT,                             /* font number follows      */\r};\r\r/* ========================================================================= *\r                             Annotation chunks (ANOT)\r\r    This section describes the data structures which are used in the CMUS\r    'ANOT' Chunk. Note that there is a standard IFF chunk called 'ANNO'\r    which can be added to any file to annotate the file. The 'ANOT' is\r    used to specify annotations to the music, not to the file.\r\r * ========================================================================= */\r\r    /*  Annotation chunks are specified exactly like Lyric chunks. The only\r        reason for distinguishing between the two is that a "stripper" program\r        might want to strip out one or the other.\r    */\r\r/* ========================================================================= *\r                               Title Chunk (TITL)\r\r    This section describes the data structures which are used in the CMUS 'TITL'\r    Chunk. Unlike Lyrics, Titles are placed at fixed positions on the page\r    (generally at the top) and are are not adjusted based on the positioning\r    of any particular measure.\r\r * ========================================================================= */\r\r    /*  Title chunks are specified exactly like Lyric chunks, except that the\r        lyricMeasure field is ignored and should be set to 0.\r\r        In particular, the lyricXPos field is no longer based on measure width,\r        but is now a fractional width of the document. Similarly, the\r        lyricLevel field is the number of levels from the top of the page.\r        (Or should that be an absolute measure?)\r    */\r\r/* ========================================================================= *\r                          CMUS Instrument Table (FORM INST)\r\r        The instrument table fo the CMUS form is stored as an embedded FORM\r    called 'INST'. Each instrument in the table is one INST form.\r\r        Instruments can be configured for MIDI, internal audio, or both.\r    When using internal sounds, samples can be sepcified using an embedded\r    FORM 8SVX, or any other IFF sampled sound FORM that the program wishes\r    to support. Sampled sounds can be embedded in the file, or external\r    sample files can be referenced from within the file, by pathname.\r\r        Here's a summary of the chunks which can be included in an INST\r    form:\r\r        'INHD': This is the instrument header. It contains the instrument\r            number, and the various MIDI-related parameters. The chunk\r            format is defined below.\r\r        'FORM 8SVX': This is an embedded sampled sound file. The sampled\r            sound is to be associated with the instrument.\r\r        'SFIL': This is a reference to a sampled sound in a different file,\r            and can be used instead of an embedded sample. The chunk format\r            is simply the name of the file. If the file contains more than\r            one sample, only the first is used. (A different chunk can be\r            defined to select the Nth sample, if it turns out that this\r            feature might be desired).\r\r        'SHAR': This allows a instrument to share a sampled sound with\r            another instrument. This would be used instead of either and\r            embedded sample or an 'SFIL' chunk. The chunk format is simple\r            a UWORD of the instrument number to share with; This\r            instrument must have been previously loaded.\r\r        'ATAK': Identical with the ATAK chunk in FORM 8SVX, this allows\r            the instrument have a different envelope than the one in\r            the sampled sound file.\r\r        'RLSE': Identical with the RLSE chunk in FORM 8SVX, this allows the\r            instrument have a different envelope than the one in the\r            sampled sound file.\r\r        'NAME': is a standard chunk which can be added to any IFF FORM.\r            In this case, it is used to store the instrument name. Other\r            standard chunks which can be added are "AUTH" (author name),\r            "VERS" (version string), "ANNO" (Annotations) and "(C) "\r            (copyright notice).\r\r    Note: If there is no sampled sound specified, either through an\r        embedded sample or SFIL or SHAR chunks, then this instrument is\r        a MIDI-only instrument.\r\r * ========================================================================= */\r\r    /* Instrument header chunk -- INHD */\r\rtypedef struct {\r\r        /*  'instNumber' corresponds to the instrument number used\r            in the "instrument event" in the TRCK chunk.\r        */\r\r    UBYTE               instNumber;\r\r    UBYTE               instFlags;          /* various flags                */\r    WORD                instTune;           /* tuning, in 1/100 semitones   */\r    WORD                instVolume;         /* overall volume, 0-0xffff     */\r\r        /*  "Pan" can be used by both MIDI and sampled sound instruments, and\r            indicates a preferences for left or right. It ranges from 0 to\r            127 (same as MIDI), with 0 being ?? and 127 being ??.\r        */\r\r    UBYTE               instPan;\r\r        /*  MIDI-related variables */\r\r    UBYTE               instMidiChannel;    /* MIDI channel to use          */\r    UBYTE               instMidiPreset;     /* MIDI Preset for this channel */\r    UBYTE               instMidiPort;       /* Hardware port #, if applies  */\r\r} InstrumentHeader;\r\r#define INST_MAXVOL     0x0ffff\r#define INST_MAXPAN     127\r\r    /* various flags for instFlags */\r\r#define INSTF_MIDI      (1<<0)              /* MIDI is enabled              */\r#define INSTF_MIDIVOL   (1<<1)              /* use MIDI volume, not velocity*/\r\r#endif\r
\ No newline at end of file
diff --git a/ekit/com/hexidec/util/CMUScodec.java b/ekit/com/hexidec/util/CMUScodec.java
deleted file mode 100644 (file)
index da300fd..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/*\rGNU General Public License\r\rCMUScodec\rCopyright (C) 2002  Howard A Kistler\r\rThis program is free software; you can redistribute it and/or\rmodify it under the terms of the GNU General Public License\ras published by the Free Software Foundation; either version 2\rof the License, or (at your option) any later version.\r\rThis program is distributed in the hope that it will be useful,\rbut WITHOUT ANY WARRANTY; without even the implied warranty of\rMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\rGNU General Public License for more details.\r\rYou should have received a copy of the GNU General Public License\ralong with this program; if not, write to the Free Software\rFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\r*/\r\rpackage com.hexidec.util;\r\rimport java.awt.AWTException;\rimport java.io.File;\rimport java.io.FileInputStream;\rimport java.io.FileNotFoundException;\rimport java.io.FileOutputStream;\rimport java.io.FileWriter;\rimport java.io.IOException;\r\r/** CMUScodec\r  *\r  * Utility for reading (and eventually converting) Deluxe Music\r  * Construction Set (DMCS) files\r  *\r  * @author Howard Kistler\r  * @version 0.1\r  *\r  * VERSION HISTORY\r  * 0.1 (03/13/2002) - initial creation (03/13/2002)\r  */\r\rpublic class CMUScodec\r{\r\r//  Constants ---------------------------------------------------------------------------->\r\r/*\r       CMUS File Structure\r\r   FILE HEADER\r    ====================\r   (At the beginning of each file)\r\r       IFF Form Chunk\r         4 bytes - FORM\r         4 bytes - ?\r            4 bytes - CMUS\r\r        Score Header Chunk\r             4 bytes - SCHD\r         10 bytes - 00 00 00 1A 00 02 00 00 00 02\r               2 bytes - (significant number[s]?)\r             2 bytes - 00 04 (# of channels maybe?)\r         2 bytes - Ch\r           12 bytes - 00 00 00 00 00 00 0C E6 00 00 0C E6\r         2 bytes - (2 byte significant number, or 00 and 1 byte significant?)\r\r  DSCR HEADER BLOCK\r              4 bytes - DSCR\r         14 bytes - ?\r\r  Staff Table Chunk\r              4 bytes - STAF\r         X bytes - ? (1 entry per staff in score)\r\r      DSTF HEADER BLOCK\r              4 bytes - DSTF\r         X bytes - ?\r\r   LFON HEADER BLOCK\r              4 bytes - LFON\r         4 bytes - 00 00 00 0F\r          4 bytes - 00 00 00 08\r          X bytes - Font Name\r            2 bytes - 00 00\r\r       SONG BODY\r      ====================\r\r  TRCK BLOCKS\r            4 bytes - TRCK\r         X bytes - track data\r\r  INSTRUMENT BLOCK\r       ====================\r\r  Each Instrument Contains:\r              4 bytes - FORM\r         4 bytes - (number?)\r            8 bytes - INSTINHD\r             4 bytes - 00 00 00 0A\r          1 byte  - Instrument Number\r            1 byte  - (zero pad?)\r          8 bytes - 00 00 FF FF 40 00 00 00\r              4 bytes - NAME\r         4 bytes - Name Byte Count\r              Y bytes - Name Bytes (Y = value from above)\r            1 byte  - (zero pad?)\r          [Optional Instrument Path]\r                     4 bytes - SFIL\r                 4 bytes - Path Byte Count\r                      Y bytes - Path Bytes (Y = value from above)\r            1 byte  - (zero pad)\r\r*/\r\r      // Decoder Vars\r        private static byte[] bData;\r   private static int iPlace;\r\r//  Public Vartypes ---------------------------------------------------------------------->\r\r       public final static int FILETYPE_DMCS   = 0;\r   public final static int FILETYPE_CMUS   = 1;\r   public final static int FILETYPE_SMUS   = 2;\r   public final static int FILETYPE_TEXT   = 3;\r   public final static int FILETYPE_FINALE = 4;\r\r  private final static byte NUL = (byte)0;\r\r//  Constructor -------------------------------------------------------------------------->\r\r public CMUScodec()\r     {\r      }\r\r//  Decode Method ------------------------------------------------------------------------>\r\r        public static void decode(String sourceFile, String destFile)\r  throws FileNotFoundException, IOException, AWTException\r        {\r              convertToTextFile(sourceFile, destFile);\r       }\r\r//  Encode Method ------------------------------------------------------------------------>\r\r        public static void encode(String sourceFile, String destFile, int fileType)\r    throws FileNotFoundException, IOException, AWTException\r        {\r//            String newFormat = convertToFormat(sourceFile, fileType);\r//            writeToDMCSFile(newFormat, destFile);\r  }\r\r//  CMUS-to-TEXT File Conversion -------------------------------------------------------->\r\r protected static void convertToTextFile(String inFile, String outFile)\r throws IOException\r     {\r              File srcFile = new File(inFile);\r               FileInputStream fis = new FileInputStream(srcFile);\r            int filesize = (int)(srcFile.length());\r                bData = new byte[filesize];\r            iPlace = 0;\r            int iCounter = 0;\r              while(iCounter < filesize)\r             {\r                      bData[iCounter] = (byte)(fis.read());\r                  iCounter++;\r            }\r              fis.close();\r\r          FileWriter fw = new FileWriter(new File(outFile));\r\r            String sOutput = "FILE SIZE  : " + srcFile.length() + "\r";\r            fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "BYTES READ : " + iCounter + "\r";\r           fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "====================\rFILE CONTENTS\r====================\r";\r               fw.write(sOutput, 0, sOutput.length());\r\r               while(iPlace < iCounter)\r               {\r                      String chunk = "" + (char)(bData[iPlace++]) + (char)(bData[iPlace++]) + (char)(bData[iPlace++]) + (char)(bData[iPlace++]);\r                     if     (chunk.equals("FORM")) { parseFORM(fw); }\r                       else if(chunk.equals("SCHD")) { parseSCHD(fw); }\r                       else if(chunk.equals("DSCR")) { parseDSCR(fw); }\r                       else if(chunk.equals("STAF")) { parseSTAF(fw); }\r                       else if(chunk.equals("DSTF")) { parseDSTF(fw); }\r                       else if(chunk.equals("LFON")) { parseLFON(fw); }\r                       else if(chunk.equals("TRCK")) { parseTRCK(fw); }\r                       else if(chunk.equals("INHD")) { parseINHD(fw); }\r                       else if(chunk.equals("NAME")) { parseNAME(fw); }\r                       else if(chunk.equals("SFIL")) { parseSFIL(fw); }\r                       else\r                   { \r                             sOutput = "UNKNOWN CHUNK : " + chunk + "\r";\r                           fw.write(sOutput, 0, sOutput.length());\r                                iPlace = iCounter;\r                             break;\r                 }\r              }\r/*\r           4 bytes - FORM\r         4 bytes - (number?)\r            4 bytes - INST\r         4 bytes - type : INHD, SFIL, SHAR or others\r            4 bytes - 00 00 00 0A\r          1 byte  - Instrument Number\r            1 byte  - (zero pad?)\r          8 bytes - 00 00 FF FF 40 00 00 00\r              4 bytes - NAME\r         4 bytes - Name Byte Count\r              Y bytes - Name Bytes (Y = value from above)\r            1 byte  - (zero pad?)\r          [Optional Instrument Path]\r                     4 bytes - SFIL\r                 4 bytes - Path Byte Count\r                      Y bytes - Path Bytes (Y = value from above)\r            1 byte  - (zero pad)\r*/\r\r               fw.flush();\r            fw.close();\r    }\r\r//  Chunk Parsing Methods---------------------------------------------------------------->\r\r private static void parseFORM(FileWriter fw)\r   throws IOException\r     {\r              String sOutput = "--------------------\rFORM CHUNK\r--------------------\r";\r           fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "FORM BLOCK : FORM\r";\r               fw.write(sOutput, 0, sOutput.length());\r\r               int iSize =\r                    (int)(\r                         ((bData[iPlace++]) << 24) +\r                            ((bData[iPlace++]) << 16) +\r                            ((bData[iPlace++]) <<  8) +\r                            ((bData[iPlace++])      )\r                              );\r             sOutput = "SIZE BLOCK : " + iSize + "\r";\r              fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "TYPE BLOCK : " + (char)(bData[iPlace++]) + (char)(bData[iPlace++]) + (char)(bData[iPlace++]) + (char)(bData[iPlace++]) + "\r";\r              fw.write(sOutput, 0, sOutput.length());\r        }\r\r     private static void parseSCHD(FileWriter fw)\r   throws IOException\r     {\r              String sOutput = "--------------------\rSCORE HEADER CHUNK\r--------------------\r";\r           fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "SCHD BLOCK : SCHD\r";\r               fw.write(sOutput, 0, sOutput.length());\r\r               int iData =\r                    (int)(\r                         ((bData[iPlace++]) <<  8) +\r                            ((bData[iPlace++])      )\r                              );\r             sOutput = "WORD BLOCK 1 : " + iData + "\r";\r            fw.write(sOutput, 0, sOutput.length());\r\r               iData =\r                        (int)(\r                         ((bData[iPlace++]) <<  8) +\r                            ((bData[iPlace++])      )\r                              );\r             sOutput = "WORD BLOCK 2 : " + iData + "\r";\r            fw.write(sOutput, 0, sOutput.length());\r\r               iData =\r                        (int)(\r                         ((bData[iPlace++]) <<  8) +\r                            ((bData[iPlace++])      )\r                              );\r             sOutput = "WORD BLOCK 3 : " + iData + "\r";\r            fw.write(sOutput, 0, sOutput.length());\r\r               iData =\r                        (int)(\r                         ((bData[iPlace++]) <<  8) +\r                            ((bData[iPlace++])      )\r                              );\r             sOutput = "WORD BLOCK 4 : " + iData + "\r";\r            fw.write(sOutput, 0, sOutput.length());\r\r               iData =\r                        (int)(\r                         ((bData[iPlace++]) <<  8) +\r                            ((bData[iPlace++])      )\r                              );\r             sOutput = "WORD BLOCK 5 : " + iData + "\r";\r            fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "BYTE 6a: " + bData[iPlace++] + "\r";\r                fw.write(sOutput, 0, sOutput.length());\r                sOutput = "BYTE 6b: " + bData[iPlace++] + "\r";\r                fw.write(sOutput, 0, sOutput.length());\r\r               iData =\r                        (int)(\r                         ((bData[iPlace++]) <<  8) +\r                            ((bData[iPlace++])      )\r                              );\r             sOutput = "WORD BLOCK 7+: " + iData + "\r";\r            fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "Ch BLOCK : " + (char)(bData[iPlace++]) + (char)(bData[iPlace++]) + "\r";\r            fw.write(sOutput, 0, sOutput.length());\r\r               for(int i = 0; i < 6; i++)\r             {\r                      iData =\r                                (int)(\r                                 ((bData[iPlace++]) <<  8) +\r                                    ((bData[iPlace++])      )\r                                      );\r                     sOutput = "SUB WORD " + (i + 1) + ": " + iData + "\r";\r                 fw.write(sOutput, 0, sOutput.length());\r                }\r\r             iData =\r                        (int)(\r                         ((bData[iPlace++]) <<  8) +\r                            ((bData[iPlace++])      )\r                              );\r             sOutput = "SUB WORD 7 : " + iData + "\r";\r              fw.write(sOutput, 0, sOutput.length());\r        }\r\r     private static void parseDSCR(FileWriter fw)\r   throws IOException\r     {\r              String sOutput = "--------------------\rDSCR CHUNK\r--------------------\r";\r           fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "DSCR BLOCK : DSCR\r";\r               fw.write(sOutput, 0, sOutput.length());\r\r               for(int i = 0; i < 7; i++)\r             {\r                      int iData =\r                            (int)(\r                                 ((bData[iPlace++]) <<  8) +\r                                    ((bData[iPlace++])      )\r                                      );\r                     sOutput = "DSCR WORD " + i + ": " + iData + "\r";\r                      fw.write(sOutput, 0, sOutput.length());\r                }\r      }\r\r     private static void parseSTAF(FileWriter fw)\r   throws IOException\r     {\r              String sOutput = "--------------------\rSTAFF TABLE CHUNK\r--------------------\r";\r            fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "STAF BLOCK : STAF\r";\r               fw.write(sOutput, 0, sOutput.length());\r\r               int iStaffLeadByte =\r                   (int)(\r                         (bData[iPlace++] <<  8) +\r                              (bData[iPlace++]      )\r                                );\r             sOutput = "STAF Lead Byte : " + iStaffLeadByte + "\r";\r         fw.write(sOutput, 0, sOutput.length());\r\r               int iStaffByteCount =\r                  (int)(\r                         (bData[iPlace++] <<  8) +\r                              (bData[iPlace++]      )\r                                );\r             sOutput = "STAF Byte Count : " + iStaffByteCount + "\r";\r               fw.write(sOutput, 0, sOutput.length());\r\r               for(int i = 0; i < iStaffByteCount; i++)\r               {\r                      sOutput = "STAF Byte " + (i+1) + " : " + bData[iPlace++] + "\r";\r                       fw.write(sOutput, 0, sOutput.length());\r                }\r      }\r\r     private static void parseDSTF(FileWriter fw)\r   throws IOException\r     {\r              String sOutput = "--------------------\rDSTF CHUNK\r--------------------\r";\r           fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "DSTF BLOCK : DSTF\r";\r               fw.write(sOutput, 0, sOutput.length());\r\r               int iDstaffLeadByte =\r                  (int)(\r                         (bData[iPlace++] <<  8) +\r                              (bData[iPlace++]      )\r                                );\r             sOutput = "DSTF Lead Byte : " + iDstaffLeadByte + "\r";\r                fw.write(sOutput, 0, sOutput.length());\r\r               int iDstaffByteCount =\r                 (int)(\r                         (bData[iPlace++] <<  8) +\r                              (bData[iPlace++]      )\r                                );\r             sOutput = "DSTF Byte Count : " + iDstaffByteCount + "\r";\r              fw.write(sOutput, 0, sOutput.length());\r\r               for(int i = 0; i < iDstaffByteCount; i++)\r              {\r                      sOutput = "DSTF Byte " + (i+1) + " : " + bData[iPlace++] + "\r";\r                       fw.write(sOutput, 0, sOutput.length());\r                }\r      }\r\r     private static void parseLFON(FileWriter fw)\r   throws IOException\r     {\r              String sOutput = "--------------------\rLYRIC FONT CHUNK\r--------------------\r";\r             fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "LFON BLOCK : LFON\r";\r               fw.write(sOutput, 0, sOutput.length());\r\r               int iFontNumber =\r                      (int)(\r                         ((bData[iPlace++]) << 24) +\r                            ((bData[iPlace++]) << 16) +\r                            ((bData[iPlace++]) <<  8) +\r                            ((bData[iPlace++])      )\r                              );\r             sOutput = "FONT NUMBER : " + iFontNumber + "\r";\r               fw.write(sOutput, 0, sOutput.length());\r\r               int iFontHeight =\r                      (int)(\r                         ((bData[iPlace++]) << 24) +\r                            ((bData[iPlace++]) << 16) +\r                            ((bData[iPlace++]) <<  8) +\r                            ((bData[iPlace++])      )\r                              );\r             sOutput = "FONT HEIGHT : " + iFontHeight + "\r";\r               fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "Font Name : ";\r              while(bData[iPlace++] != NUL)\r          {\r                      sOutput = sOutput + (char)(bData[iPlace-1]);\r           }\r              sOutput = sOutput + "\r";\r              fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "[TERMNUL] : " + bData[iPlace++] + "\r";\r             fw.write(sOutput, 0, sOutput.length());\r        }\r\r     private static void parseTRCK(FileWriter fw)\r   throws IOException\r     {\r              String sOutput = "--------------------\rTRACK CHUNK\r--------------------\r";\r          fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "TRCK BLOCK : TRCK\r";\r               fw.write(sOutput, 0, sOutput.length());\r\r               int iTrackLeadByte =\r                   (int)(\r                         (bData[iPlace++] <<  8) +\r                              (bData[iPlace++]      )\r                                );\r             sOutput = "TRCK Lead Byte : " + iTrackLeadByte + "\r";\r         fw.write(sOutput, 0, sOutput.length());\r\r               int iTrackByteCount =\r                  (int)(\r                         (bData[iPlace++] <<  8) +\r                              (bData[iPlace++]      )\r                                );\r             sOutput = "TRCK Byte Count : " + iTrackByteCount + "\r";\r               fw.write(sOutput, 0, sOutput.length());\r\r               int iTrackStaff =\r                      (int)(\r                         (bData[iPlace++] <<  8) +\r                              (bData[iPlace++]      )\r                                );\r             sOutput = "TRCK Staff : " + iTrackStaff + "\r";\r                fw.write(sOutput, 0, sOutput.length());\r\r               int iTrackTrack =\r                      (int)(\r                         (bData[iPlace++] <<  8) +\r                              (bData[iPlace++]      )\r                                );\r             sOutput = "TRCK Track : " + iTrackTrack + "\r";\r                fw.write(sOutput, 0, sOutput.length());\r\r               int iTrackFlags =\r                      (int)(\r                         (bData[iPlace++] <<  8) +\r                              (bData[iPlace++]      )\r                                );\r             sOutput = "TRCK Flags : " + iTrackFlags + "\r";\r                fw.write(sOutput, 0, sOutput.length());\r\r               int iTrackTransposition =\r                      (int)(\r                         (bData[iPlace++] <<  8) +\r                              (bData[iPlace++]      )\r                                );\r             sOutput = "TRCK Trans : " + iTrackTransposition + "\r";\r                fw.write(sOutput, 0, sOutput.length());\r\r               for(int i = 0; i < iTrackByteCount - 8;)\r               {\r                      int iItemLength = (int)(bData[iPlace++]);\r                      sOutput = "ITEM LEN  : " + iItemLength + "\r";\r                 fw.write(sOutput, 0, sOutput.length());\r                        i++;\r\r                  sOutput = "ITEM TYPE : " + bData[iPlace++] + "\r";\r                     fw.write(sOutput, 0, sOutput.length());\r                        i++;\r\r                  int iItemXPos =\r                                (int)(\r                                 (bData[iPlace++] <<  8) +\r                                      (bData[iPlace++]      )\r                                        );\r                     sOutput = "ITEM XPOS : " + iItemXPos + "\r";\r                   fw.write(sOutput, 0, sOutput.length());\r                        i++;i++;\r\r                      int iItemStart =\r                               (int)(\r                                 (bData[iPlace++] <<  8) +\r                                      (bData[iPlace++]      )\r                                        );\r                     sOutput = "ITEM START: " + iItemStart + "\r";\r                  fw.write(sOutput, 0, sOutput.length());\r                        i++;i++;\r\r                      for(int j = 0; j < iItemLength - 3; j++)\r                       {\r                              int iItemData =\r                                        (int)(\r                                         (bData[iPlace++] <<  8) +\r                                              (bData[iPlace++]      )\r                                                );\r                             sOutput = "ITEM WORD " + j + " : " + iItemData + "\r";\r                         fw.write(sOutput, 0, sOutput.length());\r                                i++;i++;\r                       }\r              }\r      }\r\r     private static void parseINHD(FileWriter fw)\r   throws IOException\r     {\r              String sOutput = "--------------------\rINSTRUMENT HEADER CHUNK\r--------------------\r";\r              fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "INHD BLOCK : INHD\r";\r               fw.write(sOutput, 0, sOutput.length());\r\r               int iPadding =\r                 (int)(\r                         (bData[iPlace++] <<  8) +\r                              (bData[iPlace++]      )\r                                );\r             sOutput = "(HEADPAD)  : " + iPadding + "\r";\r           fw.write(sOutput, 0, sOutput.length());\r                byte instrumentNumber = bData[iPlace++];\r               sOutput = "INST #     : " + instrumentNumber + "\r";\r           fw.write(sOutput, 0, sOutput.length());\r                byte instrumentFlags  = bData[iPlace++];\r               sOutput = "INST FLAGS : " + instrumentFlags + "\r";\r            fw.write(sOutput, 0, sOutput.length());\r                int  instrumentTune   =\r                        (int)(\r                         (bData[iPlace++] <<  8) +\r                              (bData[iPlace++]      )\r                                );\r             sOutput = "INST TUNE  : " + instrumentTune + "\r";\r             fw.write(sOutput, 0, sOutput.length());\r                int  instrumentVolume =\r                        (int)(\r                         (bData[iPlace++] <<  8) +\r                              (bData[iPlace++]      )\r                                );\r             sOutput = "INST VOL   : " + instrumentVolume + "\r";\r           fw.write(sOutput, 0, sOutput.length());\r                byte instrumentPan = bData[iPlace++];\r          sOutput = "INST PAN   : " + instrumentNumber + "\r";\r           fw.write(sOutput, 0, sOutput.length());\r                byte instrumentMIDIChannel = bData[iPlace++];\r          sOutput = "MIDI CHAN   : " + instrumentNumber + "\r";\r          fw.write(sOutput, 0, sOutput.length());\r                byte instrumentMIDIPreset = bData[iPlace++];\r           sOutput = "MIDI PRESET : " + instrumentNumber + "\r";\r          fw.write(sOutput, 0, sOutput.length());\r                byte instrumentMIDIPort = bData[iPlace++];\r             sOutput = "MIDI PORT   : " + instrumentNumber + "\r";\r          fw.write(sOutput, 0, sOutput.length());\r                iPadding =\r                     (int)(\r                         (bData[iPlace++] <<  8) +\r                              (bData[iPlace++]      )\r                                );\r             sOutput = "(TAILPAD)  : " + iPadding + "\r";\r           fw.write(sOutput, 0, sOutput.length());\r        }\r\r     private static void parseNAME(FileWriter fw)\r   throws IOException\r     {\r              String sOutput = "--------------------\rINSTRUMENT NAME CHUNK\r--------------------\r";\r                fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "NAME BLOCK : NAME\r";\r               fw.write(sOutput, 0, sOutput.length());\r\r               int iNameHeadInt =\r                     (int)(\r                         (bData[iPlace++] <<  8) +\r                              (bData[iPlace++]      )\r                                );\r             sOutput = "NAME HEAD  : " + iNameHeadInt + "\r";\r               fw.write(sOutput, 0, sOutput.length());\r\r               int iNameByteCount =\r                   (int)(\r                         (bData[iPlace++] <<  8) +\r                              (bData[iPlace++]      )\r                                );\r             sOutput = "NAME BYTES : " + iNameByteCount + "\r";\r             fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "Instrument Name : ";\r                for(int i = 1; i < iNameByteCount; i++)\r                {\r                      sOutput = sOutput + (char)(bData[iPlace++]);\r           }\r              sOutput = sOutput + "\r";\r              fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "(PADNUL1)  : " + bData[iPlace++] + "\r";\r            fw.write(sOutput, 0, sOutput.length());\r\r               if((int)(iNameByteCount / 2.0) < (iNameByteCount / 2.0))\r               {\r                      sOutput = "(PADNUL2)  : " + bData[iPlace++] + "\r";\r                    fw.write(sOutput, 0, sOutput.length());\r                }\r      }\r\r     private static void parseSFIL(FileWriter fw)\r   throws IOException\r     {\r              String sOutput = "--------------------\rINSTRUMENT SAMPLE FILE CHUNK\r--------------------\r";\r         fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "SFIL BLOCK : SFIL\r";\r               fw.write(sOutput, 0, sOutput.length());\r\r               int iSampleFileBytes =\r                 (int)(\r                         ((bData[iPlace++]) << 24) +\r                            ((bData[iPlace++]) << 16) +\r                            ((bData[iPlace++]) <<  8) +\r                            ((bData[iPlace++])      )\r                              );\r             sOutput = "SFIL BYTES : " + iSampleFileBytes + "\r";\r           fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "Sample File Name : ";\r               for(int i = 1; i < iSampleFileBytes; i++)\r              {\r                      sOutput = sOutput + (char)(bData[iPlace++]);\r           }\r              sOutput = sOutput + "\r";\r              fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "(PADNUL)   : " + bData[iPlace++] + "\r";\r            fw.write(sOutput, 0, sOutput.length());\r        }\r\r//  File Write Method ------------------------------------------------------------------->\r\r protected static void writeToDMCSFile(String fileData, String outFile)\r throws IOException\r     {\r/*\r           FileOutputStream fos = new FileOutputStream(new File(outFile));\r\r               byte FileSizeByte1 = (byte)(fileData.length()         & 0xFF);\r         byte FileSizeByte2 = (byte)((fileData.length() >> 8)  & 0xFF);\r         byte FileSizeByte3 = (byte)((fileData.length() >> 16) & 0xFF);\r         byte FileSizeByte4 = (byte)((fileData.length() >> 24) & 0xFF);\r\r                byte[] DMCSFileHeader = new byte[]\r             {\r                      FileHeaderFormWord[0], FileHeaderFormWord[1], FileHeaderFormWord[2], FileHeaderFormWord[3],\r                    FileSizeByte1,         FileSizeByte2,         FileSizeByte3,         FileSizeByte4,\r                    FileHeaderTypeWord[0], FileHeaderTypeWord[1], FileHeaderTypeWord[2], FileHeaderTypeWord[3],\r                    FileHeaderOSAMWord[0], FileHeaderOSAMWord[1], FileHeaderOSAMWord[2], FileHeaderOSAMWord[3],\r                    FileHeaderTailWord[0], FileHeaderTailWord[1], FileHeaderTailWord[2], FileHeaderTailWord[3]\r             };\r             fos.write(DMCSFileHeader);\r\r            byte BitmapWidthByte1      = (byte)(IntBitmapWidth          & 0xFF);\r           byte BitmapWidthByte2      = (byte)((IntBitmapWidth >> 8)   & 0xFF);\r           byte BitmapWidthByte3      = (byte)((IntBitmapWidth >> 16)  & 0xFF);\r           byte BitmapWidthByte4      = (byte)((IntBitmapWidth >> 24)  & 0xFF);\r           byte BitmapHeightByte1     = (byte)(IntBitmapHeight         & 0xFF);\r           byte BitmapHeightByte2     = (byte)((IntBitmapHeight >> 8)  & 0xFF);\r           byte BitmapHeightByte3     = (byte)((IntBitmapHeight >> 16) & 0xFF);\r           byte BitmapHeightByte4     = (byte)((IntBitmapHeight >> 24) & 0xFF);\r           byte BitmapImageSizeByte1  = (byte)(IntBitmapSize           & 0xFF);\r           byte BitmapImageSizeByte2  = (byte)((IntBitmapSize >> 8)    & 0xFF);\r           byte BitmapImageSizeByte3  = (byte)((IntBitmapSize >> 16)   & 0xFF);\r           byte BitmapImageSizeByte4  = (byte)((IntBitmapSize >> 24)   & 0xFF);\r\r          byte[] BitmapBodyHeader = new byte[] {\r                 InfoHeaderSizeByte1,        InfoHeaderSizeByte2,        InfoHeaderSizeByte3,        InfoHeaderSizeByte4,\r                       BitmapWidthByte1,           BitmapWidthByte2,           BitmapWidthByte3,           BitmapWidthByte4,\r                  BitmapHeightByte1,          BitmapHeightByte2,          BitmapHeightByte3,          BitmapHeightByte4,\r                 BitmapPlanesByte1,          BitmapPlanesByte2,\r                 BitmapBitCountByte1,        BitmapBitCountByte2,\r                       BitmapCompressionByte1,     BitmapCompressionByte2,     BitmapCompressionByte3,     BitmapCompressionByte4,\r                    BitmapImageSizeByte1,       BitmapImageSizeByte2,       BitmapImageSizeByte3,       BitmapImageSizeByte4,\r                      BitmapXPixelsPerMByte1,     BitmapXPixelsPerMByte2,     BitmapXPixelsPerMByte3,     BitmapXPixelsPerMByte4,\r                    BitmapYPixelsPerMByte1,     BitmapYPixelsPerMByte2,     BitmapYPixelsPerMByte3,     BitmapYPixelsPerMByte4,\r                    BitmapColorsUsedByte1,      BitmapColorsUsedByte2,      BitmapColorsUsedByte3,      BitmapColorsUsedByte4,\r                     BitmapColorsImportantByte1, BitmapColorsImportantByte2, BitmapColorsImportantByte3, BitmapColorsImportantByte4\r         };\r             fos.write(BitmapBodyHeader);\r\r          int bodySize = IntBitmapWidth * IntBitmapHeight;\r               int bitPad = 4 - ((IntBitmapWidth * 3) % 4);\r           if(bitPad == 4) { bitPad = 0; }\r                int countRow = 1;\r              int indexRow = bodySize - IntBitmapWidth;\r              int indexLastRow = indexRow;\r           byte[] rgbArray = new byte[3];\r\r                for(int i = 0; i < bodySize; i++)\r              {\r                      int colorValue = PixelMap[indexRow];\r                   rgbArray[0] = (byte)(colorValue         & 0xFF); // red\r                        rgbArray[1] = (byte)((colorValue >> 8)  & 0xFF); // green\r                      rgbArray[2] = (byte)((colorValue >> 16) & 0xFF); // blue\r                       fos.write(rgbArray);\r                   if(countRow == IntBitmapWidth)\r                 {\r                              // pad row to 4 bits requirement\r                               for(int p = 0; p < bitPad; p++)\r                                {\r                                      fos.write(0x00);\r                               }\r                              countRow = 1;\r                          indexRow = indexLastRow - IntBitmapWidth;\r                              indexLastRow = indexRow;\r                       }\r                      else\r                   {\r                              countRow++;\r                    }\r                      indexRow++;\r            }\r\r             fos.flush();\r           fos.close();\r*/\r        }\r\r     public static void main(String[] args)\r {\r              if(args.length < 3)\r            {\r                      System.out.println("USAGE : CMUScodec -action input output");\r          }\r              else\r           {\r                      if(args[0].equals("-t"))\r                       {\r                              try\r                            {\r                                      decode(args[1], args[2]);\r                              }\r                              catch(Exception e)\r                             {\r                                      System.out.println(e);\r                         }\r                      }\r                      else\r                   {\r                              System.out.println("action " + args[0] + "not yet supported");\r                 }\r              }\r      }\r\r}\r
\ No newline at end of file
diff --git a/ekit/com/hexidec/util/Cartesian.java b/ekit/com/hexidec/util/Cartesian.java
deleted file mode 100644 (file)
index 3a5444d..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-package com.hexidec.util;
-
-public class Cartesian
-{
-       private int x;
-       private int y;
-
-       public Cartesian(int x, int y)
-       {
-               this.x = x;
-               this.y = y;
-       }
-
-       public Cartesian(Cartesian cartesian)
-       {
-               this.x = cartesian.getX();
-               this.y = cartesian.getY();
-       }
-
-       public Cartesian()
-       {
-               this(0, 0);
-       }
-
-       public int getX() { return x; }
-       public int getY() { return y; }
-
-       public void setX(int i) { x = i; }
-       public void setY(int i) { y = i; }
-
-       public void mirror(Cartesian cpSource)
-       {
-               this.setX(cpSource.getX());
-               this.setY(cpSource.getY());
-       }
-
-       public void add(Cartesian cpAdd)
-       {
-               this.setX(this.getX() + cpAdd.getX());
-               this.setY(this.getY() + cpAdd.getY());
-       }
-
-       public void subtract(Cartesian cpSub)
-       {
-               this.setX(this.getX() - cpSub.getX());
-               this.setY(this.getY() - cpSub.getY());
-       }
-
-       public void scale(int magnitude)
-       {
-               this.setX(this.getX() * magnitude);
-               this.setY(this.getY() * magnitude);
-       }
-
-       public Cartesian getScaledInstance(int magnitude)
-       {
-               Cartesian cpNew = this.dupe();
-               cpNew.scale(magnitude);
-               return cpNew;
-       }
-
-       public Cartesian getScaledInstance(Cartesian cpMagnitude)
-       {
-               Cartesian cpNew = this.dupe();
-               cpNew.setX(cpNew.getX() * cpMagnitude.getX());
-               cpNew.setY(cpNew.getY() * cpMagnitude.getY());
-               return cpNew;
-       }
-
-       public Cartesian addToLimit(Cartesian cpBase, Cartesian cpMin, Cartesian cpMax)
-       {
-               Cartesian cpNew = this.dupe();
-               cpNew.add(cpBase);
-               if(cpNew.getX() < cpMin.getX()) { cpNew.setX(cpMin.getX()); }
-               if(cpNew.getY() < cpMin.getY()) { cpNew.setY(cpMin.getY()); }
-               if(cpNew.getX() > cpMax.getX()) { cpNew.setX(cpMax.getX()); }
-               if(cpNew.getY() > cpMax.getY()) { cpNew.setY(cpMax.getY()); }
-               return cpNew;
-       }
-
-       public Cartesian translate(Cartesian cpOffset, boolean unknown)
-       {
-               Cartesian cpNew = this.dupe();
-               cpNew.add(cpOffset);
-               return cpNew;
-       }
-
-       public Cartesian translate(Cartesian cpOffset)
-       {
-               return translate(cpOffset, false);
-       }
-
-       public double distance(Cartesian cpTarget)
-       {
-               // Formula -> SQRT(SQR(x2 - x1) + SQR(y2 - y1))
-               int xDiff = cpTarget.getX() - this.getX();
-               int yDiff = cpTarget.getY() - this.getY();
-               return Math.sqrt((xDiff * xDiff) + (yDiff * yDiff));
-       }
-
-       public Cartesian midpoint(Cartesian cpTarget)
-       {
-               // Formula -> (x1 + x2) / 2, (y1 + y2) / 2
-               int xMid = (this.getX() + cpTarget.getX()) / 2;
-               int yMid = (this.getY() + cpTarget.getY()) / 2;
-               return new Cartesian(xMid, yMid);
-       }
-
-       public double slope(Cartesian cpTarget)
-       {
-               // Formula -> (y1 - y2) / (x1 - x2)
-               int xDiff = this.getX() - cpTarget.getX();
-               int yDiff = this.getY() - cpTarget.getY();
-               return yDiff / xDiff;
-       }
-
-       public Cartesian dupe()
-       {
-               return new Cartesian(this);
-       }
-
-       public boolean equals(Cartesian cpCompare)
-       {
-               return ((this.getX() == cpCompare.getX()) && (this.getY() == cpCompare.getY()));
-       }
-
-       public String toString()
-       {
-               return "(" + this.getX() + "," + this.getY() + ")";
-       }
-
-       public String toKey()
-       {
-               return "X" + this.getX() + "Y" + this.getY();
-       }
-
-}
\ No newline at end of file
diff --git a/ekit/com/hexidec/util/DMCScodec.java b/ekit/com/hexidec/util/DMCScodec.java
deleted file mode 100644 (file)
index bf797f0..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/*\rGNU General Public License\r\rDMCScodec\rCopyright (C) 2002  Howard A Kistler\r\rThis program is free software; you can redistribute it and/or\rmodify it under the terms of the GNU General Public License\ras published by the Free Software Foundation; either version 2\rof the License, or (at your option) any later version.\r\rThis program is distributed in the hope that it will be useful,\rbut WITHOUT ANY WARRANTY; without even the implied warranty of\rMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\rGNU General Public License for more details.\r\rYou should have received a copy of the GNU General Public License\ralong with this program; if not, write to the Free Software\rFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\r*/\r\rpackage com.hexidec.util;\r\rimport java.awt.AWTException;\rimport java.io.File;\rimport java.io.FileInputStream;\rimport java.io.FileNotFoundException;\rimport java.io.FileOutputStream;\rimport java.io.FileWriter;\rimport java.io.IOException;\r\r/** DMCScodec\r  *\r  * Utility for reading (and eventually converting) Deluxe Music\r  * Construction Set (DMCS) files\r  *\r  * @author Howard Kistler\r  * @version 0.1\r  *\r  * VERSION HISTORY\r  * 0.1 (03/13/2002) - initial creation (03/13/2002)\r  */\r\rpublic class DMCScodec\r{\r\r//  Constants ---------------------------------------------------------------------------->\r\r/*\r       DMCS File Structure\r\r   FILE HEADER\r    ====================\r   (At the beginning of each file)\r        FILE HEADER BLOCK\r              4 bytes - FORM\r         4 bytes - ?\r            4 bytes - DMCS\r         4 bytes - AMGA (for Amiga files)\r               4 bytes - ? (all zeroes?)\r      SC HEADER BLOCK\r                4 bytes - USC1\r         8 bytes - ?\r            4 bytes - ?\r            8 bytes - ?\r            4 x 32 bytes - ?\r               1 byte - Title Byte count (number of letters in song title)\r            X bytes - Song Title (length stated in previous byte)\r          16 bytes - 00 05 FE 77 01 01 01 02 00 00 3F 80 00 7F 00 00\r\r    SONG BODY\r      ====================\r   UBR1 BLOCKS\r            4 bytes - UBR1\r\r        INSTRUMENT BLOCK\r       ====================\r   (At the end of each file)\r      INSTRUMENT HEAD BLOCK\r          4 bytes - UVLT\r         22 bytes -  00 00 00 12 00 00 00 0A 00 13 00 1F 00 2F 00 3F 00 51 00 69 00 7F\r  INDIVIDUAL INSTRUMENT BLOCKS\r           4 bytes - UIID\r         4 bytes - ? (small int)\r                X bytes - Instrument Name\r              2 bytes - 00 00 (last instrument may have just one byte of 00)\r*/\r\r     // Header Array Sizes\r  private final static byte StartFileHeaderSize = (byte)20;\r      private final static byte InfoHeaderSize = (byte)40; // InfoHeader is always 40 bytes in size for BMP/ICO/CUR format\r\r  // File Header Fields\r  private final static byte[] FileHeaderFormWord = { 'F', 'O', 'R', 'M', };\r      private       static byte[] FileHeaderSizeWord = new byte[4];\r  private final static byte[] FileHeaderTypeWord = { 'D', 'M', 'C', 'S' };\r       private final static byte[] FileHeaderOSAMWord = { 'A', 'M', 'G', 'A' }; // OS Word for Amiga DMCS files\r       private final static byte[] FileHeaderTailWord = { (byte)0, (byte)0, (byte)0, (byte)0 };\r\r      // Song Body Fields\r    private final static byte[] SongBlockUnitWord = { 'U', 'B', 'R', '1' };\r\r       // Instrument Body Fields\r      private final static byte[] InstrumentBlockHeadWord = { 'U', 'V', 'L', 'T' };\r  private final static byte[] InstrumentBlockUnitWord = { 'U', 'I', 'I', 'D' };\r\r//  Public Vartypes ---------------------------------------------------------------------->\r\r    public final static int FILETYPE_DMCS   = 1;\r   public final static int FILETYPE_TEXT   = 2;\r   public final static int FILETYPE_FINALE = 3;\r\r//  Constructor -------------------------------------------------------------------------->\r\r     public DMCScodec()\r     {\r      }\r\r//  Decode Method ------------------------------------------------------------------------>\r\r        public static void decode(String sourceFile, String destFile)\r  throws FileNotFoundException, IOException, AWTException\r        {\r              convertToTextFile(sourceFile, destFile);\r       }\r\r//  Encode Method ------------------------------------------------------------------------>\r\r        public static void encode(String sourceFile, String destFile, int fileType)\r    throws FileNotFoundException, IOException, AWTException\r        {\r//            String newFormat = convertToFormat(sourceFile, fileType);\r//            writeToDMCSFile(newFormat, destFile);\r  }\r\r//  DMCS-to-TEXT File Conversion -------------------------------------------------------->\r\r protected static void convertToTextFile(String inFile, String outFile)\r throws IOException\r     {\r              File srcFile = new File(inFile);\r               FileInputStream fis = new FileInputStream(srcFile);\r            int filesize = (int)(srcFile.length());\r                byte[] bData = new byte[filesize];\r             int iCounter = 0;\r              while(iCounter < filesize)\r             {\r                      bData[iCounter] = (byte)(fis.read());\r                  iCounter++;\r            }\r              fis.close();\r\r          FileWriter fw = new FileWriter(new File(outFile));\r\r            String sOutput = "FILE SIZE  : " + srcFile.length() + "\r";\r            fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "BYTES READ : " + iCounter + "\r";\r           fw.write(sOutput, 0, sOutput.length());\r\r               int iPlace = 0;\r\r               sOutput = "====================\rFILE HEADER\r====================\r";\r         fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "--------------------\rFILE HEADER BLOCK\r--------------------\r";\r           fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "FORM BLOCK : " + (char)(bData[iPlace++]) + (char)(bData[iPlace++]) + (char)(bData[iPlace++]) + (char)(bData[iPlace++]) + "\r";\r              fw.write(sOutput, 0, sOutput.length());\r\r               int iSize =\r                    (int)(\r                         ((bData[iPlace++]) << 24) +\r                            ((bData[iPlace++]) << 16) +\r                            ((bData[iPlace++]) <<  8) +\r                            ((bData[iPlace++])      )\r                              );\r             sOutput = "SIZE BLOCK : " + iSize + "\r";\r              fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "TYPE BLOCK : " + (char)(bData[iPlace++]) + (char)(bData[iPlace++]) + (char)(bData[iPlace++]) + (char)(bData[iPlace++]) + "\r";\r              fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "OS BLOCK   : " + (char)(bData[iPlace++]) + (char)(bData[iPlace++]) + (char)(bData[iPlace++]) + (char)(bData[iPlace++]) + "\r";\r              fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "TAIL BLOCK : " + (char)(bData[iPlace++]) + (char)(bData[iPlace++]) + (char)(bData[iPlace++]) + (char)(bData[iPlace++]) + "\r";\r              fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "--------------------\rSC HEADER BLOCK\r--------------------\r";\r             fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "USC1 BLOCK : " + (char)(bData[iPlace++]) + (char)(bData[iPlace++]) + (char)(bData[iPlace++]) + (char)(bData[iPlace++]) + "\r";\r              fw.write(sOutput, 0, sOutput.length());\r\r               int iData =\r                    (int)(\r                         ((bData[iPlace++]) << 24) +\r                            ((bData[iPlace++]) << 16) +\r                            ((bData[iPlace++]) <<  8) +\r                            ((bData[iPlace++])      )\r                              );\r             sOutput = "DATA INT 1 : " + iData + "\r";\r              fw.write(sOutput, 0, sOutput.length());\r\r               iData =\r                        (int)(\r                         ((bData[iPlace++]) << 24) +\r                            ((bData[iPlace++]) << 16) +\r                            ((bData[iPlace++]) <<  8) +\r                            ((bData[iPlace++])      )\r                              );\r             sOutput = "DATA INT 2 : " + iData + "\r";\r              fw.write(sOutput, 0, sOutput.length());\r\r               iData =\r                        (int)(\r                         ((bData[iPlace++]) << 24) +\r                            ((bData[iPlace++]) << 16) +\r                            ((bData[iPlace++]) <<  8) +\r                            ((bData[iPlace++])      )\r                              );\r             sOutput = "DATA INT 3 : " + iData + "\r";\r              fw.write(sOutput, 0, sOutput.length());\r\r               iData =\r                        (int)(\r                         ((bData[iPlace++]) << 24) +\r                            ((bData[iPlace++]) << 16) +\r                            ((bData[iPlace++]) <<  8) +\r                            ((bData[iPlace++])      )\r                              );\r             sOutput = "DATA INT 4 : " + iData + "\r";\r              fw.write(sOutput, 0, sOutput.length());\r\r               iData =\r                        (int)(\r                         ((bData[iPlace++]) << 24) +\r                            ((bData[iPlace++]) << 16) +\r                            ((bData[iPlace++]) <<  8) +\r                            ((bData[iPlace++])      )\r                              );\r             sOutput = "DATA INT 5 : " + iData + "\r";\r              fw.write(sOutput, 0, sOutput.length());\r\r               for(int i = 0; i < 32; i++)\r            {\r                      iData =\r                                (int)(\r                                 ((bData[iPlace++]) << 24) +\r                                    ((bData[iPlace++]) << 16) +\r                                    ((bData[iPlace++]) <<  8) +\r                                    ((bData[iPlace++])      )\r                                      );\r                     sOutput = "SUB INT " + (i+1) + " : " + iData + "\r";\r                   fw.write(sOutput, 0, sOutput.length());\r                }\r\r             sOutput = "PAD BYTES  : " + bData[iPlace++] + bData[iPlace++] + bData[iPlace++] + bData[iPlace++] + "\r";\r              fw.write(sOutput, 0, sOutput.length());\r\r               int titleCharCount = (int)(bData[iPlace++]);\r           sOutput = "TITLE BYTE : " + titleCharCount  + "\r";\r            fw.write(sOutput, 0, sOutput.length());\r\r               sOutput = "SONG TITLE : ";\r             for(int i = 0; i < titleCharCount; i++)\r                {\r                      sOutput = sOutput + (char)(bData[iPlace++]);\r           }\r              sOutput = sOutput + "\r";\r              fw.write(sOutput, 0, sOutput.length());\r\r               for(int i = 0; i < 19; i++)\r            {\r                      sOutput = "POST BYTE " + (i+1) + " : " + bData[iPlace++] + "\r";\r                       fw.write(sOutput, 0, sOutput.length());\r                }\r\r             sOutput = "====================\rSONG BODY\r====================\r";\r           fw.write(sOutput, 0, sOutput.length());\r\r               byte byteA = (byte)0;\r          byte byteB = (byte)0;\r          String blockWord = "";\r         while(iPlace < filesize - 5)\r           {\r                      byteA = bData[iPlace++];\r                       byteB = bData[iPlace++];\r                       blockWord = "" + (char)byteA + (char)byteB;\r                    if(blockWord.equals("UB"))\r                     {\r                              byte byteC = bData[iPlace++];\r                          byte byteD = bData[iPlace++];\r                          String blockWord2 = "" + (char)byteC + (char)byteD;\r                            if(blockWord2.equals("R1"))\r                            {\r                                      sOutput = "--------------------\rUBR1 DATA BLOCK\r--------------------\r";\r                                     fw.write(sOutput, 0, sOutput.length());\r\r                                       sOutput = "DATA HEAD  : " + blockWord + blockWord2 + "\r";\r                                     fw.write(sOutput, 0, sOutput.length());\r                                }\r                              else\r                           {\r                                      int iWord =\r                                            (int)(\r                                                 (byteA <<  8) +\r                                                        (byteB      )\r                                                  );\r                                     sOutput = "WORD VALUE : " + iWord + "\r";\r                                      fw.write(sOutput, 0, sOutput.length());\r                                        iWord =\r                                                (int)(\r                                                 (byteC <<  8) +\r                                                        (byteD      )\r                                                  );\r                                     sOutput = "WORD VALUE : " + iWord + "\r";\r                                      fw.write(sOutput, 0, sOutput.length());\r                                }\r                      }\r                      else if(blockWord.equals("UV"))\r                        {\r                              byte byteC = bData[iPlace++];\r                          byte byteD = bData[iPlace++];\r                          String blockWord2 = "" + (char)byteC + (char)byteD;\r                            if(blockWord2.equals("LT"))\r                            {\r                                      sOutput = "====================\rINSTRUMENT BLOCK\r====================\r";\r                                    fw.write(sOutput, 0, sOutput.length());\r        \r                                       sOutput = "--------------------\rINSTRUMENT HEAD BLOCK\r--------------------\r";\r                                       fw.write(sOutput, 0, sOutput.length());\r        \r                                       sOutput = "GROUP HEAD : " + blockWord + blockWord2 + "\r";\r                                     fw.write(sOutput, 0, sOutput.length());\r\r                                       int iWord = 0;\r                                 for(int i = 0; i < 11; i++)\r                                    {\r                                              iWord =\r                                                        (int)(\r                                                         ((bData[iPlace++]) <<  8) +\r                                                            ((bData[iPlace++])      )\r                                                              );\r                                             sOutput = "SUB WORD " + (i+1) + " : " + iWord + "\r";\r                                          fw.write(sOutput, 0, sOutput.length());\r                                        }\r                              }\r                              else\r                           {\r                                      int iWord =\r                                            (int)(\r                                                 (byteA <<  8) +\r                                                        (byteB      )\r                                                  );\r                                     sOutput = "WORD VALUE : " + iWord + "\r";\r                                      fw.write(sOutput, 0, sOutput.length());\r                                        iWord =\r                                                (int)(\r                                                 (byteC <<  8) +\r                                                        (byteD      )\r                                                  );\r                                     sOutput = "WORD VALUE : " + iWord + "\r";\r                                      fw.write(sOutput, 0, sOutput.length());\r                                }\r                      }\r                      else if(blockWord.equals("UI"))\r                        {\r                              byte byteC = bData[iPlace++];\r                          byte byteD = bData[iPlace++];\r                          String blockWord2 = "" + (char)byteC + (char)byteD;\r                            if(blockWord2.equals("ID"))\r                            {\r                                      sOutput = "--------------------\rINDIVIDUAL INSTRUMENT BLOCK\r--------------------\r";\r                                 fw.write(sOutput, 0, sOutput.length());\r\r                                       sOutput = "INSTR HEAD : " + blockWord + blockWord2 + "\r";\r                                     fw.write(sOutput, 0, sOutput.length());\r\r                                       int iVal =\r                                             (int)(\r                                                 ((bData[iPlace++]) << 24) +\r                                                    ((bData[iPlace++]) << 16) +\r                                                    ((bData[iPlace++]) <<  8) +\r                                                    ((bData[iPlace++])      )\r                                                      );\r                                     sOutput = "NAME BYTES : " + iVal + "\r";\r                                       fw.write(sOutput, 0, sOutput.length());\r\r                                       sOutput = "INSTR NAME : ";\r                                     for(int i = 0; i < iVal - 1; i++)\r                                      {\r                                              sOutput = sOutput + (char)(bData[iPlace++]);\r                                   }\r                                      sOutput = sOutput + "\r";\r                                      fw.write(sOutput, 0, sOutput.length());\r\r                                       if(iPlace < filesize - 2)\r                                      {\r                                              sOutput = "PAD BYTES  : " + bData[iPlace++] + bData[iPlace++] + "\r";\r                                          fw.write(sOutput, 0, sOutput.length());\r                                        }\r                              }\r                              else\r                           {\r                                      int iWord =\r                                            (int)(\r                                                 (byteA <<  8) +\r                                                        (byteB      )\r                                                  );\r                                     sOutput = "WORD VALUE : " + iWord + "\r";\r                                      fw.write(sOutput, 0, sOutput.length());\r                                        iWord =\r                                                (int)(\r                                                 (byteC <<  8) +\r                                                        (byteD      )\r                                                  );\r                                     sOutput = "WORD VALUE : " + iWord + "\r";\r                                      fw.write(sOutput, 0, sOutput.length());\r                                }\r                      }\r                      else {\r                         int iWord =\r                                    (int)(\r                                         (byteA <<  8) +\r                                                (byteB      )\r                                          );\r                             sOutput = "WORD VALUE : " + iWord + "\r";\r                              fw.write(sOutput, 0, sOutput.length());\r                        }\r              }\r\r             fw.flush();\r            fw.close();\r    }\r\r//  File Write Method ------------------------------------------------------------------->\r\r protected static void writeToDMCSFile(String fileData, String outFile)\r throws IOException\r     {\r              FileOutputStream fos = new FileOutputStream(new File(outFile));\r\r               byte FileSizeByte1 = (byte)(fileData.length()         & 0xFF);\r         byte FileSizeByte2 = (byte)((fileData.length() >> 8)  & 0xFF);\r         byte FileSizeByte3 = (byte)((fileData.length() >> 16) & 0xFF);\r         byte FileSizeByte4 = (byte)((fileData.length() >> 24) & 0xFF);\r\r                byte[] DMCSFileHeader = new byte[]\r             {\r                      FileHeaderFormWord[0], FileHeaderFormWord[1], FileHeaderFormWord[2], FileHeaderFormWord[3],\r                    FileSizeByte1,         FileSizeByte2,         FileSizeByte3,         FileSizeByte4,\r                    FileHeaderTypeWord[0], FileHeaderTypeWord[1], FileHeaderTypeWord[2], FileHeaderTypeWord[3],\r                    FileHeaderOSAMWord[0], FileHeaderOSAMWord[1], FileHeaderOSAMWord[2], FileHeaderOSAMWord[3],\r                    FileHeaderTailWord[0], FileHeaderTailWord[1], FileHeaderTailWord[2], FileHeaderTailWord[3]\r             };\r             fos.write(DMCSFileHeader);\r\r/*\r         byte BitmapWidthByte1      = (byte)(IntBitmapWidth          & 0xFF);\r           byte BitmapWidthByte2      = (byte)((IntBitmapWidth >> 8)   & 0xFF);\r           byte BitmapWidthByte3      = (byte)((IntBitmapWidth >> 16)  & 0xFF);\r           byte BitmapWidthByte4      = (byte)((IntBitmapWidth >> 24)  & 0xFF);\r           byte BitmapHeightByte1     = (byte)(IntBitmapHeight         & 0xFF);\r           byte BitmapHeightByte2     = (byte)((IntBitmapHeight >> 8)  & 0xFF);\r           byte BitmapHeightByte3     = (byte)((IntBitmapHeight >> 16) & 0xFF);\r           byte BitmapHeightByte4     = (byte)((IntBitmapHeight >> 24) & 0xFF);\r           byte BitmapImageSizeByte1  = (byte)(IntBitmapSize           & 0xFF);\r           byte BitmapImageSizeByte2  = (byte)((IntBitmapSize >> 8)    & 0xFF);\r           byte BitmapImageSizeByte3  = (byte)((IntBitmapSize >> 16)   & 0xFF);\r           byte BitmapImageSizeByte4  = (byte)((IntBitmapSize >> 24)   & 0xFF);\r\r          byte[] BitmapBodyHeader = new byte[] {\r                 InfoHeaderSizeByte1,        InfoHeaderSizeByte2,        InfoHeaderSizeByte3,        InfoHeaderSizeByte4,\r                       BitmapWidthByte1,           BitmapWidthByte2,           BitmapWidthByte3,           BitmapWidthByte4,\r                  BitmapHeightByte1,          BitmapHeightByte2,          BitmapHeightByte3,          BitmapHeightByte4,\r                 BitmapPlanesByte1,          BitmapPlanesByte2,\r                 BitmapBitCountByte1,        BitmapBitCountByte2,\r                       BitmapCompressionByte1,     BitmapCompressionByte2,     BitmapCompressionByte3,     BitmapCompressionByte4,\r                    BitmapImageSizeByte1,       BitmapImageSizeByte2,       BitmapImageSizeByte3,       BitmapImageSizeByte4,\r                      BitmapXPixelsPerMByte1,     BitmapXPixelsPerMByte2,     BitmapXPixelsPerMByte3,     BitmapXPixelsPerMByte4,\r                    BitmapYPixelsPerMByte1,     BitmapYPixelsPerMByte2,     BitmapYPixelsPerMByte3,     BitmapYPixelsPerMByte4,\r                    BitmapColorsUsedByte1,      BitmapColorsUsedByte2,      BitmapColorsUsedByte3,      BitmapColorsUsedByte4,\r                     BitmapColorsImportantByte1, BitmapColorsImportantByte2, BitmapColorsImportantByte3, BitmapColorsImportantByte4\r         };\r             fos.write(BitmapBodyHeader);\r\r          int bodySize = IntBitmapWidth * IntBitmapHeight;\r               int bitPad = 4 - ((IntBitmapWidth * 3) % 4);\r           if(bitPad == 4) { bitPad = 0; }\r                int countRow = 1;\r              int indexRow = bodySize - IntBitmapWidth;\r              int indexLastRow = indexRow;\r           byte[] rgbArray = new byte[3];\r\r                for(int i = 0; i < bodySize; i++)\r              {\r                      int colorValue = PixelMap[indexRow];\r                   rgbArray[0] = (byte)(colorValue         & 0xFF); // red\r                        rgbArray[1] = (byte)((colorValue >> 8)  & 0xFF); // green\r                      rgbArray[2] = (byte)((colorValue >> 16) & 0xFF); // blue\r                       fos.write(rgbArray);\r                   if(countRow == IntBitmapWidth)\r                 {\r                              // pad row to 4 bits requirement\r                               for(int p = 0; p < bitPad; p++)\r                                {\r                                      fos.write(0x00);\r                               }\r                              countRow = 1;\r                          indexRow = indexLastRow - IntBitmapWidth;\r                              indexLastRow = indexRow;\r                       }\r                      else\r                   {\r                              countRow++;\r                    }\r                      indexRow++;\r            }\r*/\r\r          fos.flush();\r           fos.close();\r   }\r\r     public static void main(String[] args)\r {\r              if(args.length < 3)\r            {\r                      System.out.println("USAGE : DMCScodec -action input output");\r          }\r              else\r           {\r                      if(args[0].equals("-t"))\r                       {\r                              try\r                            {\r                                      decode(args[1], args[2]);\r                              }\r                              catch(Exception e)\r                             {\r                                      System.out.println(e);\r                         }\r                      }\r                      else\r                   {\r                              System.out.println("action " + args[0] + "not yet supported");\r                 }\r              }\r      }\r\r}\r
\ No newline at end of file
diff --git a/ekit/com/hexidec/util/MutableFilter.java b/ekit/com/hexidec/util/MutableFilter.java
deleted file mode 100644 (file)
index bbeb3fc..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*\r
-GNU Lesser General Public License\r
-\r
-MutableFilter\r
-Copyright (C) 2000-2002  Howard A Kistler\r
-\r
-This library is free software; you can redistribute it and/or\r
-modify it under the terms of the GNU Lesser General Public\r
-License as published by the Free Software Foundation; either\r
-version 2.1 of the License, or (at your option) any later version.\r
-\r
-This library is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
-Lesser General Public License for more details.\r
-\r
-You should have received a copy of the GNU Lesser General Public\r
-License along with this library; if not, write to the Free Software\r
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
-*/\r
-\r
-package com.hexidec.util;\r
-\r
-import java.io.File;\r
-import javax.swing.filechooser.FileFilter;\r
-\r
-/** Class for providing JFileChooser with a FileFilter\r
-  */\r
-public class MutableFilter extends FileFilter\r
-{\r
-       private String[] acceptableExtensions;\r
-       private String descriptor;\r
-\r
-       public MutableFilter(String[] exts, String desc)\r
-       {\r
-               acceptableExtensions = exts;\r
-               StringBuffer strbDesc = new StringBuffer(desc + " (");\r
-               for(int i = 0; i < acceptableExtensions.length; i++)\r
-               {\r
-                       if(i > 0) { strbDesc.append(", "); }\r
-                       strbDesc.append("*." + acceptableExtensions[i]);\r
-               }\r
-               strbDesc.append(")");\r
-               descriptor = strbDesc.toString();\r
-       }\r
-\r
-       public boolean accept(File file)\r
-       {\r
-               if(file.isDirectory())\r
-               {\r
-                       return true;\r
-               }\r
-               String fileName = file.getName();\r
-               String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length()).toLowerCase();\r
-               if(fileExt != null)\r
-               {\r
-                       for(int i = 0; i < acceptableExtensions.length; i++)\r
-                       {\r
-                               if(fileExt.equals(acceptableExtensions[i]))\r
-                               {\r
-                                       return true;\r
-                               }\r
-                       }\r
-                       return false;\r
-               }\r
-               else\r
-               {\r
-                       return false;\r
-               }\r
-       }\r
-\r
-       public String getDescription()\r
-       {\r
-               return descriptor;\r
-       }\r
-}\r
-\r
diff --git a/ekit/com/hexidec/util/PatternReplacer.java b/ekit/com/hexidec/util/PatternReplacer.java
deleted file mode 100644 (file)
index 3fadfb0..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-package com.hexidec.util;\r
-\r
-/*\r
-GNU General Public License\r
-\r
-PatternReplacer - Simple Pattern Replacement Class\r
-Copyright (C) 2001  Howard A Kistler\r
-\r
-This program is free software; you can redistribute it and/or\r
-modify it under the terms of the GNU General Public License\r
-as published by the Free Software Foundation; either version 2\r
-of the License, or (at your option) any later version.\r
-\r
-This program is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-GNU General Public License for more details.\r
-\r
-You should have received a copy of the GNU General Public License\r
-along with this program; if not, write to the Free Software\r
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\r
-*/\r
-\r
-import java.util.Hashtable;\r
-\r
-/** PatternReplacer\r
-  * Utility class for replacing patterns in script strings\r
-  *\r
-  * @author Howard Kistler\r
-  * @version 0.2\r
-  *\r
-  * VERSION HISTORY\r
-  * 0.1 (04/04/2001) - initial creation (04/04/2001)\r
-  * 0.2 (04/09/2001) - separation into own class (04/09/2001)\r
-  */\r
-\r
-public class PatternReplacer {\r
-\r
-       private Hashtable patternTable;\r
-\r
-       public PatternReplacer(Hashtable patterns) {\r
-               patternTable = patterns;\r
-       }\r
-\r
-       public PatternReplacer() {\r
-               patternTable = new Hashtable();\r
-       }\r
-\r
-       public void addPattern(String pattern, String replacement) {\r
-               if(patternTable.containsKey(pattern)) {\r
-                       patternTable.remove(pattern);\r
-               }\r
-               patternTable.put(pattern, replacement);\r
-       }\r
-\r
-       public void removePattern(String pattern) {\r
-               if(patternTable.containsKey(pattern)) {\r
-                       patternTable.remove(pattern);\r
-               }\r
-       }\r
-\r
-       public String getPattern(String pattern) {\r
-               if(patternTable.containsKey(pattern)) {\r
-                       return (String)(patternTable.get(pattern));\r
-               }\r
-               return null;\r
-       }\r
-\r
-       public void clearPatterns() {\r
-               patternTable.clear();\r
-       }\r
-\r
-       public int patternCount() {\r
-               return patternTable.size();\r
-       }\r
-\r
-}\r
-\r
diff --git a/ekit/com/hexidec/util/TreeSpider$FileTreeComparator.class b/ekit/com/hexidec/util/TreeSpider$FileTreeComparator.class
deleted file mode 100644 (file)
index 473353b..0000000
Binary files a/ekit/com/hexidec/util/TreeSpider$FileTreeComparator.class and /dev/null differ
diff --git a/ekit/com/hexidec/util/TreeSpider.class b/ekit/com/hexidec/util/TreeSpider.class
deleted file mode 100644 (file)
index d2d873c..0000000
Binary files a/ekit/com/hexidec/util/TreeSpider.class and /dev/null differ
diff --git a/ekit/com/hexidec/util/TreeSpider.java b/ekit/com/hexidec/util/TreeSpider.java
deleted file mode 100644 (file)
index b738860..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/*\rGNU General Public License\r\rTreeSpider - Directory & File Traversal Utility Class\rCopyright (C) 2000  Howard A Kistler\r\rThis program is free software; you can redistribute it and/or\rmodify it under the terms of the GNU General Public License\ras published by the Free Software Foundation; either version 2\rof the License, or (at your option) any later version.\r\rThis program is distributed in the hope that it will be useful,\rbut WITHOUT ANY WARRANTY; without even the implied warranty of\rMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\rGNU General Public License for more details.\r\rYou should have received a copy of the GNU General Public License\ralong with this program; if not, write to the Free Software\rFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\r*/\r\rpackage com.hexidec.util;\r\rimport java.io.File;\rimport java.util.Arrays;\rimport java.util.Collections;\rimport java.util.Comparator;\rimport java.util.Enumeration;\rimport java.util.Hashtable;\rimport java.util.Vector;\rimport javax.swing.tree.DefaultMutableTreeNode;\rimport javax.swing.tree.DefaultTreeModel;\r\r/** TreeSpider\r  * Utility class for traversing, scanning & describing directory/file structures\r  *\r  * @author Howard Kistler\r  * @version 0.2\r  *\r  * VERSION HISTORY\r  * 0.1 (09/14/2000) - initial creation (started on 08/09/2000)\r  * 0.2 (09/22/2001) - numerous enhancements\r  */\r\rpublic class TreeSpider {\r\r private File rootFile;\r private Vector vcFiles;\r        private Vector vcExtensions;\r   private int maxDepth;\r  private boolean bScreenExtensions;\r     private boolean bFileNamesOnly;\r        private boolean bDisplayMode;\r  private FileTreeComparator localComparison;\r\r//  Constructors ---------------------------------------------------------------------------->\r\r   /* Main Constructor */\r public TreeSpider(String origin, Vector exts, boolean caseSensitive, int mDepth) {\r             rootFile = new File(origin);\r           vcFiles = new Vector();\r                vcExtensions = exts;\r           maxDepth = mDepth;\r             bScreenExtensions = false;\r             bFileNamesOnly = false;\r                bDisplayMode = false;\r          if(vcExtensions.size() > 0) {\r                  bScreenExtensions = true;\r              }\r              localComparison = new FileTreeComparator(caseSensitive);\r       }\r\r     /* Alternate Constructor */\r    public TreeSpider(String origin, Vector exts, boolean caseSensitive) {\r         this(origin, new Vector(), caseSensitive, 0);\r  }\r\r     /* Alternate Constructor */\r    public TreeSpider(String origin, boolean caseSensitive, int mDepth) {\r          this(origin, new Vector(), caseSensitive, mDepth);\r     }\r\r     /* Alternate Constructor */\r    public TreeSpider(String origin, boolean caseSensitive) {\r              this(origin, new Vector(), caseSensitive, 0);\r  }\r\r     /* Alternate Constructor */\r    public TreeSpider(String origin, int mDepth) {\r         this(origin, new Vector(), false, mDepth);\r     }\r\r     /* Alternate Constructor */\r    public TreeSpider(String origin) {\r             this(origin, new Vector(), false, 0);\r  }\r\r     /* Alternate Constructor */\r    public TreeSpider() {\r          this(".", new Vector(), false, 0);\r     }\r\r//  Public Class Methods -------------------------------------------------------------------->\r\r     /** Returns a DefaultTreeModel built from the specified root file */\r   public DefaultTreeModel fetchTree(File newRootFile) {\r          return describeTree(newRootFile);\r      }\r\r     /** Returns a DefaultTreeModel built from the preset root file */\r      public DefaultTreeModel fetchTree() {\r          return describeTree(rootFile);\r }\r\r     /** Returns an unsorted listing of the file tree */\r    public Vector fetchMassListing() {\r             return fetchListing();\r }\r\r     /** Returns an index-style listing of the file tree of complete file names and paths */\r        public Vector sortMassListing() {\r              Vector vcListing = fetchListing();\r             Collections.sort(vcListing, localComparison);\r          return vcListing;\r      }\r\r     /** Returns an index-style listing of the file tree of file names only */\r      public Vector sortFileListing() {\r              Vector vcListing = trimToName(fetchListing());\r         Collections.sort(vcListing, localComparison);\r          return vcListing;\r      }\r\r     /** Returns a directory-style listing of the file tree */\r      public Hashtable collectListing() {\r            Vector vcListing = fetchListing();\r             Hashtable htCollected = new Hashtable();\r               for(int i = 0; i < vcListing.size(); i++) {\r                    String fullname = (String)(vcListing.elementAt(i));\r                    String filepath = fullname.substring(0, fullname.lastIndexOf(File.separator));\r                 String filename = fullname.substring(fullname.lastIndexOf(File.separator) + 1, fullname.length());\r                     if(htCollected.containsKey(filepath)) {\r                                ((Vector)(htCollected.get(filepath))).add(filename);\r                   }\r                      else {\r                         htCollected.put(filepath, new Vector());\r                               ((Vector)(htCollected.get(filepath))).add(filename);\r                   }\r              }\r              return htCollected;\r    }\r\r//  Internal Class Methods ------------------------------------------------------------------>\r\r     private DefaultTreeModel describeTree(File rootFile) {\r         DefaultMutableTreeNode treeRoot = new DefaultMutableTreeNode(rootFile.getName());\r              DefaultTreeModel treeModel = new DefaultTreeModel(treeRoot);\r           if(!(rootFile.isDirectory())) {\r                        return treeModel;\r              }\r              String rootStr = rootFile.getAbsolutePath().trim() + File.separator;\r           Vector vcContents = fetchListing();\r            while(vcContents.size() > 0) {\r                 String nodeName = (String)(vcContents.elementAt(0));\r                   if(nodeName.startsWith(rootStr)) {\r                             nodeName = nodeName.substring(rootStr.length());\r                               if(nodeName.indexOf(File.separator) > -1) {\r                                    String baseNode = nodeName.substring(0, nodeName.indexOf(File.separator));\r                                     describeTreeSubNodes(vcContents, treeModel, treeRoot, rootStr, baseNode);\r                              }\r                              else {\r                                 treeModel.insertNodeInto(new DefaultMutableTreeNode(nodeName), treeRoot, treeModel.getChildCount(treeRoot));\r                                   vcContents.removeElementAt(0);\r                         }\r                      }\r                      else {\r                         vcContents.removeElementAt(0);\r                 }\r              }\r              return treeModel;\r      }\r\r     private void describeTreeSubNodes(Vector vcNodes, DefaultTreeModel treeModel, DefaultMutableTreeNode nodeParent, String basePath, String baseNodeName) {\r               DefaultMutableTreeNode thisNode = new DefaultMutableTreeNode(baseNodeName);\r            treeModel.insertNodeInto(thisNode, nodeParent, treeModel.getChildCount(nodeParent));\r           boolean inSubNode = true;\r              String fullNodePath = basePath + baseNodeName + File.separator;\r                while(inSubNode && vcNodes.size() > 0) {\r                       String nodeName = (String)(vcNodes.elementAt(0));\r                      if(nodeName.startsWith(fullNodePath)) {\r                                nodeName = nodeName.substring(fullNodePath.length());\r                          if(nodeName.indexOf(File.separator) > -1) {\r                                    String baseNode = nodeName.substring(0, nodeName.indexOf(File.separator));\r                                     describeTreeSubNodes(vcNodes, treeModel, thisNode, fullNodePath, baseNode);\r                            }\r                              else {\r                                 treeModel.insertNodeInto(new DefaultMutableTreeNode(nodeName), thisNode, treeModel.getChildCount(thisNode));\r                                   vcNodes.removeElementAt(0);\r                            }\r                      }\r                      else {\r                         inSubNode = false;\r                     }\r              }\r      }\r\r     private Vector fetchListing() {\r                Vector vcFetch = new Vector();\r         if(rootFile.isDirectory()) {\r                   vcFetch.add(exploreFolder("", rootFile, new Vector(), 1));\r             }\r              else {\r                 String fullFile = rootFile.getAbsolutePath().trim();\r                   if(!bScreenExtensions || (bScreenExtensions && screensOkay(fullFile))) {\r                               vcFetch.add(fullFile);\r                 }\r              }\r              return describeListing(vcFetch);\r       }\r\r     private Vector trimToName(Vector fullFiles) {\r          Vector vcReturn = new Vector(fullFiles.size());\r                for(int i = 0; i < fullFiles.size(); i++) {\r                    String trimName = (String)(fullFiles.elementAt(i));\r                    if(trimName.indexOf(File.separator) > -1) {\r                            vcReturn.add(trimName.substring(trimName.lastIndexOf(File.separator) + 1, trimName.length()));\r                 }\r                      else {\r                         vcReturn.add(trimName);\r                        }\r              }\r              return vcReturn;\r       }\r\r     /* Recursively explores file folders and subfolders, adding all files which match the filtered type\r       to the returning Vector.\r     */\r    private Vector exploreFolder(String currentLocal, File folder, Vector vcWorking, int currDepth) {\r              if((maxDepth != 0) && currDepth > maxDepth) {\r                  return vcWorking;\r              }\r              String fullDescriptor = currentLocal + File.separator + folder.getName();\r              File[] contents = folder.listFiles();\r          for(int i = 0; i < contents.length; i++) {\r                     if(contents[i].isDirectory()) {\r                                vcWorking.add(exploreFolder(fullDescriptor, contents[i], new Vector(), currDepth + 1));\r                        }\r                      else {\r                         String completeName = contents[i].getAbsolutePath();\r                           if(bFileNamesOnly) { completeName = contents[i].getName(); }\r                           if(!bScreenExtensions || (bScreenExtensions && screensOkay(completeName))) {\r                                   vcWorking.add(completeName.trim());\r                            }\r                      }\r              }\r              Collections.sort(vcWorking, localComparison);\r          return vcWorking;\r      }       \r\r      /* Explores only current file folder, adding all files which match the filtered type\r      to the returning Vector.\r     */\r    private Vector exploreFolderOnly(String currentLocal, File folder, Vector vcWorking) {\r         String fullDescriptor = currentLocal + File.separator + folder.getName();\r              File[] contents = folder.listFiles();\r          for(int i = 0; i < contents.length; i++) {\r                     if(contents[i].isDirectory()) {\r                                /* ignore */\r                   }\r                      else {\r                         String completeName = contents[i].getAbsolutePath();\r                           if(bFileNamesOnly) { completeName = contents[i].getName(); }\r                           if(!bScreenExtensions || (bScreenExtensions && screensOkay(completeName))) {\r                                   vcWorking.add(completeName.trim());\r                            }\r                      }\r              }\r              Collections.sort(vcWorking, localComparison);\r          return vcWorking;\r      }       \r\r      private Vector describeListing(Vector vcTree) {\r                Collections.sort(vcTree, localComparison);\r             Vector vcDescription = new Vector();\r           for(int i = 0; i < vcTree.size(); i++) {\r                       if(vcTree.elementAt(i) instanceof Vector) {\r                            describeNode((Vector)(vcTree.elementAt(i)), vcDescription);\r                    }\r                      else {\r                         vcDescription.add(vcTree.elementAt(i));\r                        }\r              }\r              return vcDescription;\r  }\r\r     private void describeNode(Vector vcNode, Vector vcStore) {\r             for(int i = 0; i < vcNode.size(); i++) {\r                       if(vcNode.elementAt(i) instanceof Vector) {\r                            describeNode((Vector)(vcNode.elementAt(i)), vcStore);\r                  }\r                      else {\r                         vcStore.add(vcNode.elementAt(i));\r                      }\r              }\r      }\r\r     private boolean screensOkay(String filename) {\r         for(int i = 0; i < vcExtensions.size(); i++) {\r                 String extension = ((String)(vcExtensions.elementAt(i))).toLowerCase();\r                        if(filename.toLowerCase().endsWith(extension)) {\r                               return true;\r                   }\r              }\r              return false;\r  }\r\r//  Accessor Methods ------------------------------------------------------------------------>\r\r     public File    getRootFile()        { return rootFile; }\r       public Vector  getFiles()           { return vcFiles; }\r        public Vector  getExtensions()      { return vcExtensions; }\r   public int     getMaxDepth()        { return maxDepth; }\r       public boolean doScreenExtensions() { return bScreenExtensions; }\r      public boolean showFileNamesOnly()  { return bFileNamesOnly; }\r public boolean getDisplayMode()     { return bDisplayMode; }\r\r  public void setRootFile(File f)            { rootFile = f; }\r   public void setFiles(Vector vc)            { vcFiles = vc; }\r   public void setExtensions(Vector vc)       {\r           vcExtensions = vc;\r             if(vcExtensions.size() > 0) {\r                  setScreenExtensions(true);\r             }\r              else {\r                 setScreenExtensions(false);\r            }\r      }\r      public void setMaxDepth(int i)             { maxDepth = i; }\r   public void setScreenExtensions(boolean b) { bScreenExtensions = b; }\r  public void setFileNamesOnly(boolean b)    { bFileNamesOnly = b; }\r     public void setDisplayMode(boolean b)      { bDisplayMode = b; }\r\r//  Unit Test Method ------------------------------------------------------------------------>\r\r      /** Unit test method for testing the code with example settings */\r     public static void unitTest(String dir) {\r              Vector vcCommonExts = new Vector();\r            vcCommonExts.add(".java");\r             vcCommonExts.add(".class");\r            vcCommonExts.add(".txt");\r              vcCommonExts.add(".html");\r             vcCommonExts.add(".htm");\r              vcCommonExts.add(".gif");\r              vcCommonExts.add(".jpeg");\r             vcCommonExts.add(".jpg");\r              TreeSpider testSpider = new TreeSpider(dir, vcCommonExts, false, 0);\r           System.out.println("UNIT TEST SCAN");\r          Hashtable htColl = testSpider.collectListing();\r                Enumeration enumKeys = htColl.keys();\r          while(enumKeys.hasMoreElements()) {\r                    String key = (String)(enumKeys.nextElement());\r                 System.out.println(key);\r                       Vector vcValues = (Vector)(htColl.get(key));\r                   for(int i = 0; i < vcValues.size(); i++) {\r                             System.out.println("  " + vcValues.elementAt(i));\r                      }\r              }\r      }\r\r//  Main Method ----------------------------------------------------------------------------->\r\r     public static void main(String[] args) {\r               if(args.length < 1) {\r                  try {\r                          TreeSpider.unitTest((new File(".")).getCanonicalPath());\r                       }\r                      catch(java.io.IOException ioe) {\r                               System.out.println("Unable to resolve current directory. Please specify a directory explicitly.");\r                             System.exit(1);\r                        }\r              }\r              else {\r                 TreeSpider.unitTest(args[0]);\r          }\r      }\r\r//  Inner Classes --------------------------------------------------------------------------->\r\r     /* Class for sorting file listings by directory then name */\r   class FileTreeComparator implements Comparator\r {\r              private boolean isCaseSensitive;\r\r              public FileTreeComparator(boolean caseCheck) {\r                 isCaseSensitive = caseCheck;\r           }\r\r             public FileTreeComparator() {\r                  isCaseSensitive = true;\r                }\r\r             public int compare(Object objA, Object objB) {\r                 if(objA instanceof Vector) {\r                           if(objB instanceof Vector) {\r                                   if(((Vector)(objA)).size() < 1)\r                                        {\r                                              return -1;\r                                     }\r                                      else if(((Vector)(objB)).size() < 1)\r                                   {\r                                              return 1;\r                                      }\r                                      else\r                                   {\r                                              return compare(((Vector)(objA)).elementAt(0), ((Vector)(objB)).elementAt(0));\r                                  }\r                              }\r                              else {\r                                 return 1;\r                              }\r                      }\r                      else if(objB instanceof Vector) {\r                              return -1;\r                     }\r                      else {\r                         String strA = (String)objA;\r                            String strB = (String)objB;\r                            return (isCaseSensitive ? strA.compareTo(strB) : strA.compareToIgnoreCase(strB));\r                      }\r              }\r      }\r\r}
\ No newline at end of file
index 01578a2..515f7af 100644 (file)
Binary files a/ekit/ekit.jar and b/ekit/ekit.jar differ
index ae61115..caff6c1 100644 (file)
Binary files a/ekit/ekitapplet.jar and b/ekit/ekitapplet.jar differ