2 GNU Lesser General Public License
4 EkitApplet - Java Swing HTML Editor & Viewer Applet
5 Copyright (C) 2000-2003 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
.Toolkit
;
26 import java
.awt
.event
.KeyEvent
;
27 import java
.net
.MalformedURLException
;
29 import java
.util
.Vector
;
30 import javax
.swing
.JApplet
;
31 import javax
.swing
.JLabel
;
33 import com
.hexidec
.ekit
.EkitCore
;
36 * Applet for editing and saving HTML in a Java browser component
38 * @author Howard Kistler
42 * Java 2 (JDK 1.3 or 1.4)
46 public class EkitApplet
extends JApplet
51 private JLabel jlblStatus
;
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 if(this.getParameter("TOOLBAR") != null
) { showToolBar
= this.getParameter("TOOLBAR").equalsIgnoreCase("true"); }
81 boolean showViewSource
= ((this.getParameter("SOURCEVIEW") != null
&& this.getParameter("SOURCEVIEW").equalsIgnoreCase("true")));
82 String sLanguage
= this.getParameter("LANGCODE");
83 String sCountry
= this.getParameter("LANGCOUNTRY");
84 boolean editModeExclusive
= true
;
85 if(this.getParameter("EXCLUSIVE") != null
) { editModeExclusive
= this.getParameter("EXCLUSIVE").equalsIgnoreCase("true"); }
86 boolean showMenuIcons
= true
;
87 if(this.getParameter("MENUICONS") != null
) { showMenuIcons
= this.getParameter("MENUICONS").equalsIgnoreCase("true"); }
89 ekitCore
= new EkitCore(sRawDocument
, urlCSS
, showViewSource
, showMenuIcons
, editModeExclusive
, sLanguage
, sCountry
, base64
, this.getParameter("BASEURL"));
91 /* Obtain image servlet information */
92 ekitCore
.setServletURL(this.getParameter("SERVLETURL"));
93 ekitCore
.setImageDir(this.getParameter("IMAGEDIR"));
94 ekitCore
.setTreePilotSystemID(this.getParameter("SYSTEMID"));
96 /* Add menus, based on whether or not they are requested (all are shown by default) */
97 Vector vcMenus
= new Vector();
98 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
); }
99 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
); }
100 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
); }
101 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
); }
102 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
); }
103 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
); }
104 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
); }
105 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
); }
106 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
); }
107 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
); }
108 this.setJMenuBar(ekitCore
.getCustomMenuBar(vcMenus
));
110 jlblStatus
= new JLabel();
112 /* Add the components to the app */
113 this.getContentPane().setLayout(new BorderLayout());
114 this.getContentPane().add(ekitCore
, BorderLayout
.CENTER
);
115 this.getContentPane().add(jlblStatus
, BorderLayout
.SOUTH
);
118 Vector vcTools
= new Vector();
119 vcTools
.add(EkitCore
.KEY_TOOL_NEW
);
120 vcTools
.add(EkitCore
.KEY_TOOL_SEP
);
121 vcTools
.add(EkitCore
.KEY_TOOL_CUT
);
122 vcTools
.add(EkitCore
.KEY_TOOL_COPY
);
123 vcTools
.add(EkitCore
.KEY_TOOL_PASTE
);
124 vcTools
.add(EkitCore
.KEY_TOOL_SEP
);
125 vcTools
.add(EkitCore
.KEY_TOOL_BOLD
);
126 vcTools
.add(EkitCore
.KEY_TOOL_ITALIC
);
127 vcTools
.add(EkitCore
.KEY_TOOL_UNDERLINE
);
128 vcTools
.add(EkitCore
.KEY_TOOL_STRIKE
);
129 vcTools
.add(EkitCore
.KEY_TOOL_SUPER
);
130 vcTools
.add(EkitCore
.KEY_TOOL_SUB
);
131 vcTools
.add(EkitCore
.KEY_TOOL_ULIST
);
132 vcTools
.add(EkitCore
.KEY_TOOL_OLIST
);
133 vcTools
.add(EkitCore
.KEY_TOOL_SEP
);
134 vcTools
.add(EkitCore
.KEY_TOOL_CLEAR
);
135 vcTools
.add(EkitCore
.KEY_TOOL_SEP
);
136 vcTools
.add(EkitCore
.KEY_TOOL_ANCHOR
);
137 vcTools
.add(EkitCore
.KEY_TOOL_SEP
);
138 vcTools
.add(EkitCore
.KEY_TOOL_SOURCE
);
139 vcTools
.add(EkitCore
.KEY_TOOL_SEP
);
140 vcTools
.add(EkitCore
.KEY_TOOL_STYLES
);
141 this.getContentPane().add(ekitCore
.getCustomToolBar(vcTools
, showToolBar
), BorderLayout
.NORTH
);
146 public void start() { ; }
147 public void stop() { ; }
148 public void destroy() { ; }
150 /** Method for passing back the document text to the applet's container.
151 * This is the entire document, including the top-level HTML tags.
153 public String
getDocumentText()
155 return ekitCore
.getDocumentText();
158 /** Method for passing back the document body to the applet's container.
159 * This is only the text contained within the BODY tags.
161 public String
getDocumentBody()
163 return ekitCore
.getDocumentSubText("body");
166 /** Method for setting the document manually.
167 * Will need code in the web page to call this.
169 public void setDocumentText(String text
)
171 ekitCore
.setDocumentText(text
);