2 GNU Lesser General Public License
4 EkitApplet - Java Swing HTML Editor & Viewer Applet
5 Copyright (C) 2000 Howard Kistler
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 package com
.hexidec
.ekit
;
24 import java
.awt
.BorderLayout
;
25 import java
.awt
.GridBagLayout
;
26 import java
.awt
.GridBagConstraints
;
27 import java
.awt
.Toolkit
;
28 import java
.awt
.event
.KeyEvent
;
29 import java
.net
.MalformedURLException
;
31 import java
.util
.Vector
;
32 import javax
.swing
.JApplet
;
33 import javax
.swing
.JLabel
;
35 import com
.hexidec
.ekit
.EkitCore
;
38 * Applet for editing and saving HTML in a Java browser component
40 * @author Howard Kistler
44 * Java 2 (JDK 1.3 or 1.4)
48 public class EkitApplet
extends JApplet
57 getRootPane().putClientProperty("defeatSystemEventQueueCheck", Boolean
.TRUE
);
64 String sRawDocument
= this.getParameter("DOCUMENT");
65 String sStyleSheetRef
= this.getParameter("STYLESHEET");
66 boolean base64
= ((this.getParameter("BASE64") != null
) && this.getParameter("BASE64").equalsIgnoreCase("true"));
67 URL urlCSS
= (URL
)null
;
70 if(sStyleSheetRef
!= null
&& sStyleSheetRef
.length() > 0)
72 urlCSS
= new URL(this.getCodeBase(), sStyleSheetRef
);
75 catch(MalformedURLException murle
)
77 murle
.printStackTrace(System
.err
);
79 boolean showToolBar
= true
;
80 boolean showToolBarMulti
= false
;
81 if(this.getParameter("TOOLBAR") != null
) { showToolBar
= this.getParameter("TOOLBAR").equalsIgnoreCase("true"); }
82 if(this.getParameter("TOOLBARMULTI") != null
) { showToolBar
= this.getParameter("TOOLBARMULTI").equalsIgnoreCase("true"); showToolBarMulti
= this.getParameter("TOOLBARMULTI").equalsIgnoreCase("true"); }
83 boolean showViewSource
= ((this.getParameter("SOURCEVIEW") != null
&& this.getParameter("SOURCEVIEW").equalsIgnoreCase("true")));
84 String sLanguage
= this.getParameter("LANGCODE");
85 String sCountry
= this.getParameter("LANGCOUNTRY");
86 boolean editModeExclusive
= true
;
87 if(this.getParameter("EXCLUSIVE") != null
) { editModeExclusive
= this.getParameter("EXCLUSIVE").equalsIgnoreCase("true"); }
88 boolean showMenuIcons
= true
;
89 if(this.getParameter("MENUICONS") != null
) { showMenuIcons
= this.getParameter("MENUICONS").equalsIgnoreCase("true"); }
90 boolean spellChecker
= false
;
91 if(this.getParameter("SPELLCHECK") != null
) { spellChecker
= this.getParameter("SPELLCHECK").equalsIgnoreCase("true"); }
95 //ekitCore = new EkitCoreSpell(sRawDocument, urlCSS, showToolBar, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, showToolBarMulti, this.getParameter("BASEURL"));
99 ekitCore
= new EkitCore(sRawDocument
, urlCSS
, showToolBar
, showViewSource
, showMenuIcons
, editModeExclusive
, sLanguage
, sCountry
, base64
, false
, showToolBarMulti
, this.getParameter("BASEURL"));
102 /* Obtain image servlet information */
103 ekitCore
.setServletURL(this.getParameter("SERVLETURL"));
104 ekitCore
.setImageDir(this.getParameter("IMAGEDIR"));
105 ekitCore
.setTreePilotSystemID(this.getParameter("SYSTEMID"));
107 /* Add menus, based on whether or not they are requested (all are shown by default) */
108 Vector vcMenus
= new Vector();
109 if(this.getParameter("MENU_EDIT") != null
) { if(this.getParameter("MENU_EDIT").equalsIgnoreCase("true")) { vcMenus
.add(EkitCore
.KEY_MENU_EDIT
); } } else { vcMenus
.add(EkitCore
.KEY_MENU_EDIT
); }
110 if(this.getParameter("MENU_VIEW") != null
) { if(this.getParameter("MENU_VIEW").equalsIgnoreCase("true")) { vcMenus
.add(EkitCore
.KEY_MENU_VIEW
); } } else { vcMenus
.add(EkitCore
.KEY_MENU_VIEW
); }
111 if(this.getParameter("MENU_FONT") != null
) { if(this.getParameter("MENU_FONT").equalsIgnoreCase("true")) { vcMenus
.add(EkitCore
.KEY_MENU_FONT
); } } else { vcMenus
.add(EkitCore
.KEY_MENU_FONT
); }
112 if(this.getParameter("MENU_FORMAT") != null
) { if(this.getParameter("MENU_FORMAT").equalsIgnoreCase("true")) { vcMenus
.add(EkitCore
.KEY_MENU_FORMAT
); } } else { vcMenus
.add(EkitCore
.KEY_MENU_FORMAT
); }
113 if(this.getParameter("MENU_INSERT") != null
) { if(this.getParameter("MENU_INSERT").equalsIgnoreCase("true")) { vcMenus
.add(EkitCore
.KEY_MENU_INSERT
); } } else { vcMenus
.add(EkitCore
.KEY_MENU_INSERT
); }
114 if(this.getParameter("MENU_TABLE") != null
) { if(this.getParameter("MENU_TABLE").equalsIgnoreCase("true")) { vcMenus
.add(EkitCore
.KEY_MENU_TABLE
); } } else { vcMenus
.add(EkitCore
.KEY_MENU_TABLE
); }
115 if(this.getParameter("MENU_FORMS") != null
) { if(this.getParameter("MENU_FORMS").equalsIgnoreCase("true")) { vcMenus
.add(EkitCore
.KEY_MENU_FORMS
); } } else { vcMenus
.add(EkitCore
.KEY_MENU_FORMS
); }
116 if(this.getParameter("MENU_SEARCH") != null
) { if(this.getParameter("MENU_SEARCH").equalsIgnoreCase("true")) { vcMenus
.add(EkitCore
.KEY_MENU_SEARCH
); } } else { vcMenus
.add(EkitCore
.KEY_MENU_SEARCH
); }
117 if(this.getParameter("MENU_TOOLS") != null
) { if(this.getParameter("MENU_TOOLS").equalsIgnoreCase("true")) { vcMenus
.add(EkitCore
.KEY_MENU_TOOLS
); } } else { vcMenus
.add(EkitCore
.KEY_MENU_TOOLS
); }
118 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
); }
119 this.setJMenuBar(ekitCore
.getCustomMenuBar(vcMenus
));
121 /* Add the components to the app */
126 this.getContentPane().setLayout(new GridBagLayout());
127 GridBagConstraints gbc
= new GridBagConstraints();
128 gbc
.fill
= GridBagConstraints
.HORIZONTAL
;
129 gbc
.anchor
= GridBagConstraints
.NORTH
;
137 Vector vcTools
= new Vector();
138 vcTools
.add(EkitCore
.KEY_TOOL_NEW
);
139 vcTools
.add(EkitCore
.KEY_TOOL_SEP
);
140 vcTools
.add(EkitCore
.KEY_TOOL_CUT
);
141 vcTools
.add(EkitCore
.KEY_TOOL_COPY
);
142 vcTools
.add(EkitCore
.KEY_TOOL_PASTE
);
143 vcTools
.add(EkitCore
.KEY_TOOL_SEP
);
144 vcTools
.add(EkitCore
.KEY_TOOL_CLEAR
);
145 vcTools
.add(EkitCore
.KEY_TOOL_SEP
);
146 vcTools
.add(EkitCore
.KEY_TOOL_ANCHOR
);
147 vcTools
.add(EkitCore
.KEY_TOOL_SEP
);
148 vcTools
.add(EkitCore
.KEY_TOOL_SOURCE
);
149 this.getContentPane().add(ekitCore
.customizeToolBar(EkitCore
.TOOLBAR_MAIN
, vcTools
, showToolBar
), gbc
);
152 this.getContentPane().add(ekitCore
.getToolBarFormat(showToolBar
), gbc
);
155 this.getContentPane().add(ekitCore
.getToolBarStyles(showToolBar
), gbc
);
157 gbc
.anchor
= GridBagConstraints
.CENTER
;
158 gbc
.fill
= GridBagConstraints
.BOTH
;
161 this.getContentPane().add(ekitCore
, gbc
);
165 Vector vcTools
= new Vector();
166 vcTools
.add(EkitCore
.KEY_TOOL_NEW
);
167 vcTools
.add(EkitCore
.KEY_TOOL_SEP
);
168 vcTools
.add(EkitCore
.KEY_TOOL_CUT
);
169 vcTools
.add(EkitCore
.KEY_TOOL_COPY
);
170 vcTools
.add(EkitCore
.KEY_TOOL_PASTE
);
171 vcTools
.add(EkitCore
.KEY_TOOL_SEP
);
172 vcTools
.add(EkitCore
.KEY_TOOL_BOLD
);
173 vcTools
.add(EkitCore
.KEY_TOOL_ITALIC
);
174 vcTools
.add(EkitCore
.KEY_TOOL_UNDERLINE
);
175 vcTools
.add(EkitCore
.KEY_TOOL_STRIKE
);
176 vcTools
.add(EkitCore
.KEY_TOOL_SUPER
);
177 vcTools
.add(EkitCore
.KEY_TOOL_SUB
);
178 vcTools
.add(EkitCore
.KEY_TOOL_ULIST
);
179 vcTools
.add(EkitCore
.KEY_TOOL_OLIST
);
180 vcTools
.add(EkitCore
.KEY_TOOL_SEP
);
181 vcTools
.add(EkitCore
.KEY_TOOL_CLEAR
);
182 vcTools
.add(EkitCore
.KEY_TOOL_SEP
);
183 vcTools
.add(EkitCore
.KEY_TOOL_ANCHOR
);
184 vcTools
.add(EkitCore
.KEY_TOOL_SEP
);
185 vcTools
.add(EkitCore
.KEY_TOOL_SOURCE
);
186 vcTools
.add(EkitCore
.KEY_TOOL_SEP
);
187 vcTools
.add(EkitCore
.KEY_TOOL_STYLES
);
189 this.getContentPane().setLayout(new BorderLayout());
190 this.getContentPane().add(ekitCore
, BorderLayout
.CENTER
);
191 this.getContentPane().add(ekitCore
.customizeToolBar(EkitCore
.TOOLBAR_MAIN
, vcTools
, showToolBar
), BorderLayout
.NORTH
);
197 public void start() { ; }
198 public void stop() { ; }
199 public void destroy() { ; }
201 /** Method for passing back the document text to the applet's container.
202 * This is the entire document, including the top-level HTML tags.
204 public String
getDocumentText()
206 return ekitCore
.getDocumentText();
209 /** Method for passing back the document body to the applet's container.
210 * This is only the text contained within the BODY tags.
212 public String
getDocumentBody()
214 return ekitCore
.getDocumentSubText("body");
217 /** Method for setting the document manually.
218 * Will need code in the web page to call this.
220 public void setDocumentText(String text
)
222 ekitCore
.setDocumentText(text
);