![JAR search and dependency download from the Maven repository](/logo.png)
pluginssrc.ingenias.codeproc.HTMLDocumentGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ingened Show documentation
Show all versions of ingened Show documentation
Meta-language editor built over INGENME. It is the most basic editor to be used in the rest of projects
/*
Copyright (C) 2002 Rafael Martinez, Jorge Gomez Sanz
This file is part of INGENIAS IDE, a support tool for the INGENIAS
methodology, availabe at http://grasia.fdi.ucm.es/ingenias or
http://ingenias.sourceforge.net
INGENIAS IDE 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.
INGENIAS IDE 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 INGENIAS IDE; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package ingenias.codeproc;
import ingenias.generator.browser.*;
import ingenias.generator.datatemplate.*;
import ingenias.generator.interpreter.Codegen;
import ingenias.editor.*;
import ingenias.editor.entities.Entity;
import ingenias.exception.NotFound;
import ingenias.exception.NullEntity;
import java.util.*;
import java.awt.Frame;
import java.awt.geom.Rectangle2D;
import java.io.*;
import org.jgraph.graph.AttributeMap;
import org.jgraph.graph.DefaultGraphCell;
/**
* This class generates HTML documentation from a INGENIAS specification
*
*@author Jorge Gomez
*@created 29 de marzo de 2003
*/
public class HTMLDocumentGenerator
extends ingenias.editor.extension.BasicCodeGeneratorImp {
/**
* Initialises HTML generation from a file containing INGENIAS specification
* and files containing templates to fullfill
*
*@param file Path to file containing INGENIAS specification
*@param diagramTemplate Description of Parameter
*@param indexTemplate Description of Parameter
*@param output Output path for the specification
*@exception Exception Error accessing any file or malformed XML exception
*/
public HTMLDocumentGenerator(String file) throws Exception {
super(file);
this.addTemplate("pluginssrc/templates/index.xml");
this.addTemplate("pluginssrc/templates/diagram.xml");
}
/**
* Initialises HTML generation from an existing browser
* and files containing templates to fullfill.
*
*@param diagramTemplate Description of Parameter
*@param indexTemplate Description of Parameter
*@exception Exception Description of Exception
*/
public HTMLDocumentGenerator(Browser browser) throws Exception {
super(browser);
this.addTemplate("pluginssrc/templates/index.xml");
this.addTemplate("pluginssrc/templates/diagram.xml");
}
@Override
public String getVersion() {
return "@modhtmldoc.ver@";
}
public boolean verify() {
return true;
}
public Vector defaultProperties() {
Vector result=new Vector();
Properties p = new Properties();
/*result.add(
new ingenias.editor.ProjectProperty(this.getName(),"htmldoc", "HTML document folder",
"html",
"The document folder that will contain HTML version of this specification"));*/
return result;
}
public String getName() {
return "HTML Document generator";
}
public String getDescription() {
return "It generates HTML documentation of your diagrams";
}
/**
* Generates HTML code
*
*@exception Exception XML exception
*/
public Sequences generate() {
Sequences seq = new Sequences();
try {
this.generateIndex(seq);
this.generatePages(seq);
copyResourceFromTo("pluginssrc/logograsia.jpg", ( (ProjectProperty)this.getProperty("htmldoc:output")).
value+"/logograsia.jpg");
}
catch (Exception ex) {
ex.printStackTrace();
}
return seq;
}
/**
* Generates an index page for the documentation
*
*@exception Exception Description of Exception
*/
private String[] toArray(String path) {
StringTokenizer st = new StringTokenizer(path);
int tokens = st.countTokens();
String[] result = new String[tokens];
for (int k = 0; k < tokens; k++) {
result[k] = st.nextToken();
}
return result;
}
private String toSafeName(String name){
name=name.replace('/','_');
name=name.replace('\\','_');
name=name.replace(' ','_');
return name;
}
private void generateIndex(Sequences p) throws Exception {
Graph[] gs = browser.getGraphs();
p.addVar(new Var("output",
( (ProjectProperty)this.getProperty("htmldoc:output")).
value));
Hashtable pathtable = new Hashtable();
Hashtable paths = new Hashtable();
Hashtable depth = new Hashtable();
Vector alreadyShown=new Vector();
float increment=25f/gs.length;
for (int k = 0; k < gs.length; k++) {
Repeat rp1=null;
this.setProgress((int) (k*increment));
String[] path=gs[k].getPath();
boolean already=true;
while (already){
rp1 = new Repeat("paquete");
p.addRepeat(rp1);
int j=0;
for (j=0;j0){
target.write(bytes,0,read);
}
} while (read!=-1);
target.close();
streamToModiaf.close();
return destination;
}
/**
* Generates HTMLdoc from a INGENIAS specification file (1st param), a diagram
* template (2nd param), and an indexTemplate (3rd param)
*
*@param args Description of Parameter
*@exception Exception Description of Exception
*/
public static void main(String args[]) throws Exception {
System.out.println("INGENIAS HTML Document Generator (C) 2012 Jorge Gomez");
System.out.println("This program comes with ABSOLUTELY NO WARRANTY; for details check www.gnu.org/copyleft/gpl.html.");
System.out.println("This is free software, and you are welcome to redistribute it under certain conditions;; for details check www.gnu.org/copyleft/gpl.html.");
if (args.length==0){
System.err.println("The first argument (mandatory) has to be the specification file and the second " +
"the outputfolder folder");
} else {
if (args.length>=2){
ingenias.editor.Log.initInstance(new PrintWriter(System.out));
ModelJGraph.disableAllListeners(); // this disable layout listeners that slow down code generation
// it is a bug of the platform which will be addressed in the future
ingenias.editor.Log.initInstance(new PrintWriter(System.out));
HTMLDocumentGenerator html = new HTMLDocumentGenerator(args[0]);
Properties props = html.getBrowser().getState().prop;
new File(args[1]+"/target/dochtml").mkdirs();
html.putProperty(new ProjectProperty("htmldoc","htmldoc:output","output",args[1]+"/target/dochtml","htmldoc"));
html.run();
if (ingenias.editor.Log.getInstance().areThereErrors() ){
for (Frame f:Frame.getFrames()){
f.dispose();
}
throw new RuntimeException("There are the following code generation errors: "+Log.getInstance().getErrors());
}
} else {
System.err.println("The first argument (mandatory) has to be the specification file and the second " +
"the outputfolder");
}
}
for (Frame f:Frame.getFrames()){
f.dispose();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy