Skip to content

Commit

Permalink
Put SourceForge logo on generated pages
Browse files Browse the repository at this point in the history
  • Loading branch information
johncurrier committed Jun 8, 2005
1 parent a551c90 commit 7e6485c
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 33 deletions.
54 changes: 37 additions & 17 deletions src/net/sourceforge/schemaspy/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,12 @@ public static void main(String[] argv) {
if (css == null)
css = "schemaSpy.css";

int maxThreads = Integer.MAX_VALUE;
String threads = properties.getProperty("dbThreads");
if (threads == null)
threads = properties.getProperty("dbthreads");
if (threads != null)
maxThreads = Integer.parseInt(threads);
threads = getParam(args, "-dbThreads", false, false);
if (threads == null)
threads = getParam(args, "-dbthreads", false, false);
if (threads != null)
maxThreads = Integer.parseInt(threads);
if (maxThreads < 0)
maxThreads = Integer.MAX_VALUE;
else if (maxThreads == 0)
maxThreads = 1;
int maxDbThreads = getMaxDbThreads(args, properties);

if (!args.remove("-nologo")) {
// nasty hack, but passing this info everywhere churns my stomach
System.setProperty("sourceforgelogo", "true");
}

ConnectionURLBuilder urlBuilder = null;
try {
Expand Down Expand Up @@ -126,7 +117,7 @@ else if (maxThreads == 0)
//
// create the spy
//
SchemaSpy spy = new SchemaSpy(connection, meta, dbName, schema, properties, maxThreads);
SchemaSpy spy = new SchemaSpy(connection, meta, dbName, schema, properties, maxDbThreads);
Database db = spy.getDatabase();

LineWriter out;
Expand Down Expand Up @@ -273,6 +264,33 @@ else if (maxThreads == 0)
}
}

/**
* getMaxDbThreads
*
* @param args List
* @param properties Properties
* @return int
*/
private static int getMaxDbThreads(List args, Properties properties) {
int maxThreads = Integer.MAX_VALUE;
String threads = properties.getProperty("dbThreads");
if (threads == null)
threads = properties.getProperty("dbthreads");
if (threads != null)
maxThreads = Integer.parseInt(threads);
threads = getParam(args, "-dbThreads", false, false);
if (threads == null)
threads = getParam(args, "-dbthreads", false, false);
if (threads != null)
maxThreads = Integer.parseInt(threads);
if (maxThreads < 0)
maxThreads = Integer.MAX_VALUE;
else if (maxThreads == 0)
maxThreads = 1;

return maxThreads;
}

/**
* dumpNoDataMessage
*
Expand Down Expand Up @@ -456,6 +474,8 @@ private static void dumpUsage(String errorMessage, boolean detailed, boolean det
System.out.println(" use 1 if you get 'already closed' type errors");
System.out.println(" -nohtml defaults to generate html");
System.out.println(" -noimplied defaults to generate implied relationships");
System.out.println(" -nologo don't put SourceForge logo on generated pages");
System.out.println(" (please don't disable unless absolutely necessary)");
System.out.println(" -help detailed help");
System.out.println(" -dbhelp display databaseType-specific help");
System.out.println();
Expand All @@ -464,7 +484,7 @@ private static void dumpUsage(String errorMessage, boolean detailed, boolean det
}

if (!detailed) {
System.out.println(" java -jar " + getLoadedFromJar() + " -help to display detailed help");
System.out.println(" java -jar " + getLoadedFromJar() + " -help to display more detailed help");
System.out.println();
}

Expand Down
40 changes: 24 additions & 16 deletions src/net/sourceforge/schemaspy/view/HtmlFormatter.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
package net.sourceforge.schemaspy.view;

import java.io.IOException;
import net.sourceforge.schemaspy.model.Database;
import net.sourceforge.schemaspy.model.Table;
import net.sourceforge.schemaspy.util.LineWriter;
import java.io.*;
import net.sourceforge.schemaspy.model.*;
import net.sourceforge.schemaspy.util.*;

public class HtmlFormatter {
protected void writeHeader(Database db, Table table, String text, LineWriter out) throws IOException {
out.writeln("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>");
out.writeln("<HTML>");
out.writeln("<HEAD>");
out.write(" <TITLE>SchemaSpy - ");
out.writeln("<html>");
out.writeln("<head>");
out.write(" <title>SchemaSpy - ");
out.write(getDescription(db, table, text, false));
out.writeln("</TITLE>");
out.write(" <LINK rel=stylesheet href='");
out.writeln("</title>");
out.write(" <link rel=stylesheet href='");
if (table != null)
out.write("../");
out.writeln("schemaSpy.css' type='text/css'>");
out.writeln(" <META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=ISO-8859-1'>");
out.writeln(" <meta HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=ISO-8859-1'>");
out.writeln(" <SCRIPT LANGUAGE='JavaScript' TYPE='text/javascript' SRC='" + (table == null ? "" : "../") + "schemaSpy.js'></SCRIPT>");
out.writeln("</HEAD>");
out.writeln("<BODY onload='syncOptions()'>");
out.writeln("</head>");
out.writeln("<body onload='syncOptions()'>");
out.writeln("<table width='100%'>");
out.writeln(" <tr>");
out.write(" <td class='heading' valign='top'><h1>");
Expand Down Expand Up @@ -74,10 +73,19 @@ protected String getDescription(Database db, Table table, String text, boolean h
return description.toString();
}

protected boolean sourceForgeLogoEnabled() {
// I hate this hack, but I don't want to have to pass this boolean everywhere...
return System.getProperty("sourceforgelogo") != null;
}

protected void writeLegend(boolean tableDetails, LineWriter out) throws IOException {
out.writeln(" <table class='legend' border='0'>");
out.writeln(" <tr><td class='dataTable'>Legend:</td></tr>");
out.writeln(" <tr><td>");
out.writeln(" <tr>");
out.writeln(" <td class='dataTable' valign='bottom'>Legend:</td>");
if (sourceForgeLogoEnabled())
out.writeln(" <td class='tableHolder' align='right' valign='top'><a href=\"http://sourceforge.net\"><img src=\"http://sourceforge.net/sflogo.php?group_id=137197&amp;type=1\" alt=\"SourceForge.net Logo\" border=\"0\" height=\"31\" width=\"88\"></a></td>");
out.writeln(" </tr>");
out.writeln(" <tr><td colspan='2'>");
out.writeln(" <table class='dataTable' border='1'>");
out.writeln(" <tbody>");
out.writeln(" <tr><td class='primaryKey'>Primary key columns</td></tr>");
Expand All @@ -92,7 +100,7 @@ protected void writeLegend(boolean tableDetails, LineWriter out) throws IOExcept
}

protected void writeFooter(LineWriter out) throws IOException {
out.writeln("</BODY>");
out.writeln("</HTML>");
out.writeln("</body>");
out.writeln("</html>");
}
}

0 comments on commit 7e6485c

Please sign in to comment.