Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/hexidec/ekit/EkitApplet.java


1   /*
2   Main Applet
3   */
4   
5   package com.hexidec.ekit;
6   
7   import java.awt.BorderLayout;
8   import java.awt.Toolkit;
9   import java.awt.event.KeyEvent;
10  import java.net.MalformedURLException;
11  import java.net.URL;
12  import java.util.Vector;
13  import javax.swing.JApplet;
14  import javax.swing.JLabel;
15  
16  
17  /** EkitApplet
18    * Applet for editing and saving HTML in a Java browser component
19    *
20    * @author Howard Kistler
21    * Modified Andre Haynes
22    * @version 1.0
23    *
24    * REQUIREMENTS
25    * Java 2 (JDK 1.3 or 1.4)
26    * Swing Library
27    */
28  
29  public class EkitApplet extends JApplet
30  {
31    /* Components */
32    EkitCore ekitCore;
33  
34    private JLabel jlblStatus;
35  
36         /** Constructor
37      */
38    public EkitApplet()
39    {
40      getRootPane().putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);
41    }
42  
43    /** Applet Init
44      */
45    public void init()
46    {
47      
48              /* Get Applet Parameters 
49               Docmument to be edited */
50              String sRawDocument         = this.getParameter("DOCUMENT");  
51              String sFilePathDelimiter   = this.getParameter("TABLEDELIMITER");
52              String sFilePaths           = this.getParameter("FILEPATHS");
53              String sRootName            = this.getParameter("ROOTNAME");    
54              String sStyleSheetRef       = this.getParameter("STYLESHEET");
55              String sLanguage            = this.getParameter("LANGCODE");
56              String sCountry             = this.getParameter("LANGCOUNTRY");
57              String sDefaultTables       = this.getParameter("TABLES");
58              String sCustomText          = this.getParameter("CUSTOMTEXT");
59              
60              /* Paramater Check */
61              if(sFilePathDelimiter == null)
62              {
63                  sFilePathDelimiter = ":::";
64              }
65              
66              if(sRootName == null)
67              {
68                  sRootName = "Website";
69              }
70              
71              /** Css file comes from CodeBase parameters
72               **/
73              URL urlCSS = (URL)null;
74              try
75              {
76                if(sStyleSheetRef != null && sStyleSheetRef.length() > 0)
77      {
78                      urlCSS = new URL(this.getCodeBase(), sStyleSheetRef);
79      }
80              }
81              catch(MalformedURLException murle)
82              {
83      murle.printStackTrace(System.err);
84              }
85              
86              URL urlFilePaths = (URL)null;
87              try
88              {
89                if(sFilePaths != null && sFilePaths.length() > 0)
90      {
91                      urlFilePaths = new URL(this.getCodeBase(), sFilePaths);
92      }
93              }
94              catch(MalformedURLException murle)
95              {
96      murle.printStackTrace(System.err);
97              }
98              
99              if (sCustomText == null) 
100             {
101                 sCustomText = "";
102             } 
103             
104             if (sDefaultTables == null) 
105             {
106                 sDefaultTables = "";
107             } 
108             
109             //Set Parameters
110             boolean showViewSource = false; 
111             boolean editModeExclusive = true;
112             boolean showMenuIcons = true;
113            
114             ekitCore = new EkitCore(null, null, sRawDocument, urlCSS, showViewSource, 
115                                showMenuIcons, editModeExclusive, sLanguage, sCountry, 
116                                false, urlFilePaths, sRootName, sFilePathDelimiter, 
117                                sDefaultTables, sCustomText);
118             this.setJMenuBar(ekitCore.getMenuBar());
119             jlblStatus = new JLabel();
120     
121             /* Add the components to the app */
122             this.getContentPane().setLayout(new BorderLayout());
123             this.getContentPane().add(ekitCore, BorderLayout.CENTER);
124             this.getContentPane().add(jlblStatus, BorderLayout.SOUTH);
125             this.getContentPane().add(ekitCore.getToolBar(), BorderLayout.NORTH);
126 
127   }
128 
129   /* Applet methods */
130   public void start()   { 
131             ekitCore.insertParagraphs();
132             ekitCore.firstParse();
133             ekitCore.insertParagraphs();
134         }
135   
136         public void stop()    
137         {
138             ekitCore = null;
139         }
140   public void destroy() { }
141         
142   /** Method for passing back the document text to the applet's container.
143     * This is the entire document, including the top-level HTML tags.
144     */
145   public String getDocumentText()
146   {
147     return ekitCore.getDocumentText();
148   }
149 
150   /** Method for passing back the document body to the applet's container.
151     * This is only the text contained within the BODY tags.
152     */
153   public String getDocumentBody()
154   {
155                 return ekitCore.getDocumentSubTextForApplet("body");
156   }
157 
158        
159         
160         /** Metthod for inserting a string into the body
161     */
162   public void insertText(String sText)
163   {
164                 try 
165                 {
166                     sText.trim();
167                     if(sText != null) 
168                     {
169                         ekitCore.insertExternalString(sText);
170                  
171                     }
172                 }
173                 catch (Exception e) {}
174 
175         }
176         
177         public void insertString(String sText)
178         {
179             try
180             {
181                 if(sText != null)
182                 {
183                        ekitCore.insertString(sText);
184                 }
185             }
186             catch (Exception e) {}
187         }
188         
189         public void insertHTMLString(String sText, String sTag)
190         {
191             try
192             {
193                 if(sText != null)
194                 {
195                        ekitCore.insertHTMLString(sText,sTag);
196                 }
197             }
198             catch (Exception e) {}
199         }
200         
201 }