/*
JSiteMap 0.9.3 - A Java Site Map Generator
Copyright (C) 2003 Pierre Blanc
Pierre Blanc: blanc_teutoburgo@yahoo.it
http://www.site-map.tk
http://it.geocities.com/teutoburgo
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or go to http://www.gnu.org/copyleft/gpl.html
*/
package tk.teutoburgo.jsitemap;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.util.*;
/**
* <p>Title: Java Site Map Generator</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: www.site-map.tk</p>
* @author Pierre Blanc
* @version 0.9.3
*/
public class JSiteMapApplet
extends Applet {
public static final String BOOLEAN
="boolean", NUMBER
="number",
STRING="string";
ScriptGenerator sg=new ScriptGenerator();
private String startTag
="<A name=sitemap>", hrefTag
="",
hrefEndTag="</A>", startListTag="<UL>", endListTag="</UL>",
listItemTag="<LI>", endListItemTag="</LI>",
htmlCode="", endURLTag="",
STOPTag="", memory="", SHOW="Show license";
boolean isStandalone = false, showLicense=true, addOptions=true;
int rows=9, cols=60;
PopUp window;
//Get a parameter value
return isStandalone
? System.
getProperty(key, def
) :
(getParameter(key) != null ? getParameter(key) : def);
}
//Construct the applet
public JSiteMapApplet() {
}
//Initialize the applet
public void init() {
try {
if(!isStandalone){
addOptions=false;
startTag=getParameter("startTag");
hrefTag=getParameter("hrefTag");
hrefEndTag=getParameter("hrefEndTag");
startListTag=getParameter("startListTag");
endListTag=getParameter("endListTag");
listItemTag=getParameter("listItemTag");
endListItemTag=getParameter("endListItemTag");
endURLTag=getParameter("endURLTag");
STOPTag=getParameter("STOPTag");
htmlCode=getParameter("htmlCode");
}else{
"./config/JSiteMap.cfg");
p.load(fis);
startTag=p.getProperty("startTag");
hrefTag=p.getProperty("hrefTag");
hrefEndTag=p.getProperty("hrefEndTag");
startListTag=p.getProperty("startListTag");
endListTag=p.getProperty("endListTag");
listItemTag=p.getProperty("listItemTag");
endListItemTag=p.getProperty("endListItemTag");
endURLTag=p.getProperty("endURLTag");
STOPTag=p.getProperty("STOPTag");
htmlCode=p.getProperty("htmlCode");
String addUserOptions
=p.
getProperty("addUserOptions");
if(addUserOptions.equals("false"))
addOptions=false;
options=util.readOptions("./config/menuOptions.cfg");
window=new PopUp(options);
}
jbInit();
// System.out.println("tag="+hrefTag);
parser
= new Parser(startTag, hrefTag, hrefEndTag,
startListTag, endListTag, listItemTag,
endListItemTag, endURLTag, STOPTag);
}
e.printStackTrace();
}
}
//Component initialization
this.setLayout(borderLayout1);
/* textArea1.setColumns(50);
textArea1.setRows(7);
textArea2.setColumns(50);
textArea2.setRows(7);*/
textArea1.setText(htmlCode);
buttonGenerate.setLabel("Dynamic");
buttonGenerate.
addMouseListener(new java.
awt.
event.
MouseAdapter() {
buttonGenerate_mouseClicked(e);
}
});
buttonClear.setLabel("Clear all");
buttonClear.
addMouseListener(new java.
awt.
event.
MouseAdapter() {
buttonClear_mouseClicked(e);
}
});
buttonLicense.setLabel(SHOW);
buttonLicense.
addMouseListener(new java.
awt.
event.
MouseAdapter() {
buttonLicense_mouseClicked(e);
}
});
buttonHTML.setLabel("Static");
buttonHTML.
addMouseListener(new java.
awt.
event.
MouseAdapter() {
buttonHTML_mouseClicked(e);
}
});
buttonConfig.setLabel("Configure");
buttonConfig.
addMouseListener(new java.
awt.
event.
MouseAdapter() {
buttonConfig_mouseClicked(e);
}
});
panelEast.setLayout(gridLayout1);
gridLayout1.setColumns(1);
gridLayout1.setRows(6);
label1.setText("Insert HTML report code and press \'Dynamic\' or \'Static\'");
label2.setText("Copy generated javascript code into .js file");
labelGenerate.setText("Generate map:");
labelAuthor.setText("Copyright (C) P.Blanc 2003 - blanc_teutoburgo"+
"@yahoo.it - http://www.site-map.tk");
labelTitle.setText("JSiteMap 0.9.3 - Java Site Map Generator");
panelNorth.setLayout(gridLayout2);
gridLayout2.setColumns(1);
gridLayout2.setRows(2);
centerPanel.add(label1, null);
centerPanel.add(textArea1, null);
panelEast.add(labelGenerate, null);
panelEast.add(buttonGenerate, null);
panelEast.add(buttonHTML, null);
if(isStandalone)
panelEast.add(buttonConfig, null);
panelEast.add(buttonClear, null);
panelStatus.
setBackground(Color.
lightGray);
panelEast.add(panelStatus, null);
panelInfo.add(labelTitle, null);
panelInfo.add(buttonLicense, null);
panelNorth.add(panelInfo, null);
panelNorth.add(labelAuthor, null);
centerPanel.add(label2, null);
centerPanel.add(textArea2, null);
if(isStandalone){
if(addOptions)
cbOptions.setState(true);
cbOptions.
addMouseListener(new java.
awt.
event.
MouseAdapter() {
cbOptions_mouseClicked(e);
}
});
panelSouth.add(cbOptions);
}
}
//Start the applet
public void start() {
}
//Stop the applet
public void stop() {
}
//Destroy the applet
public void destroy() {
}
//Get Applet information
public String getAppletInfo
() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo
() {
return null;
}
//Main method
public static void main
(String[] args
) {
JSiteMapApplet applet = new JSiteMapApplet();
applet.isStandalone = true;
super.processWindowEvent(e);
}
}
public synchronized void setTitle
(String title
) {
super.setTitle(title);
enableEvents
(AWTEvent.
WINDOW_EVENT_MASK);
}
};
frame.setTitle("JSiteMap");
applet.init();
applet.start();
frame.setSize(580,500);
frame.setLocation((d.width - frame.getSize().width) / 2,
(d.height - frame.getSize().height) / 2);
frame.setVisible(true);
}
panelStatus.
setBackground(Color.
yellow);
textArea2.setText("Working..");
String htmlCode
=textArea1.
getText();
// System.out.println("-------text: "+htmlCode);
TeutoTreeNode map=parser.parse(htmlCode);
if(map!=null){
if(addOptions){
int n=options.size();
for(int i=0; i<n; i++){
if(option[2].equals(STRING)){
if(!option[1].equals(""))
scriptCode+=option[0]+"=\""+option[1]+"\";\n";
}else
scriptCode+=option[0]+"="+option[1]+";\n";
}
scriptCode+="\n";
}
scriptCode+=sg.generate(map);
sg.resetNodeNumber();
textArea2.setText(scriptCode);
panelStatus.
setBackground(Color.
green);
label2.setText("Copy generated javascript code into .js file");
} else{
textArea2.setText("ERROR! Invalid input code.");
panelStatus.
setBackground(Color.
red);
}
}
panelStatus.
setBackground(Color.
yellow);
textArea2.setText("Working..");
String htmlCode
=textArea1.
getText();
String htmlMap
=parser.
getHTMLMap(htmlCode
);
if(htmlMap!=null){
textArea2.setText(htmlMap);
panelStatus.
setBackground(Color.
green);
label2.setText("Copy generated HTML code into .html file");
} else{
textArea2.setText("ERROR! Invalid input code.");
panelStatus.
setBackground(Color.
red);
}
}
textArea1.setText("");
textArea2.setText("");
panelStatus.
setBackground(Color.
lightGray);
}
window.setSize(600,400);
window.show();
}
if(showLicense){
memory=textArea1.getText();
textArea1.setText("This software is under the GNU GPL license v.2. This"+
" product includes software developed by the Apache Software"+
" Foundation (http://www.apache.org/). The Javascript Tree Menu is"+
" copyright of Morten Wang and comes with the BSD license.");
buttonLicense.setLabel("Back");
} else {
textArea1.setText(memory);
buttonLicense.setLabel(SHOW);
}
showLicense=!showLicense;
}
addOptions=!addOptions;
}
}