We are trying to read some data from MySQL database from an applet. The output is a Graphic shown in the form of network connecting nodes. We are using an open API from TomSawyer Software, a graphic layout tool.
As a standalone application, the program runs absolutely fine. But after converting to an applet, we get an "access denied" error when it tries to load.(java.util.PropertyPermission java.class.path read)
Any suggestions??? Thanks.
I am pasting the source code from the HTML file and the java source code.
<html>
<head>
<title>step 5</title>
</head>
<body>
<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
WIDTH = 600 HEIGHT = 500 codebase="<PARAM NAME = CODE VALUE = "BSAApplet1.class" >
<PARAM NAME = ARCHIVE VALUE = "ts4.jar" >
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
<PARAM NAME="scriptable" VALUE="false">
<COMMENT>
<EMBED type="application/x-java-applet;version=1.3" CODE = "BSAApplet1.class" WIDTH = 600 HEIGHT = 500 scriptable=false pluginspage="
</NOEMBED></EMBED>
</OBJECT>
<!--
<APPLET CODE = "BSAApplet1.class" ARCHIVE = "ts4.jar" WIDTH = 600 HEIGHT = 500>
</APPLET>
-->
</body>
</html>
Java Source
import javax.swing.*;
import java.sql.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import com.tomsawyer.editor.*;
import com.tomsawyer.editor.state.*;
import com.tomsawyer.editor.ui.*;
import com.tomsawyer.editorx.ui.*;
import com.tomsawyer.glt.*;
//import com.tomsawyer.graph.*;
//import ui.*;
import java.util.*;
// database support
import gov.uspto.sdi.common.*;
//import org.gjt.mm.mysql.*;
//
// This class contains the example editor.
//
public class BSAApplet extends JApplet
implements ActionListener {
// common components
private PropsFile pfDB = new PropsFile( "db.properties" );
// private LogFile lf = new LogFile( "example1.log" );
java.sql.Connection connection;
//1 private TSEGraph graph;
private TSDigraph digraph;
private TSEGraph graph;
private TSEGraphWindow graphWindow;
private ArrayList nodes = new ArrayList();
private ArrayList edges = new ArrayList();
// These constants hold strings which represent commands.
public static final String CREATE_SERVER = "Create Server";
public static final String CREATE_CLIENT = "Create Client";
public static final String CREATE_EDGES = "Create Edges";
public static final String SELECT = "Select";
public static final String DELETE = "Delete";
public BSAApplet() {
}
public BSAApplet( ArrayList nodes, ArrayList edges ) {
this.nodes = nodes;
this.edges = edges;
}
public void init() {
}
public void start() {
// Initialize the graph.
this.initGraph();
// Initialize the GUI.
this.initGUI();
// Initialize the graph window. Set the graph and default
// state.
this.graphWindow.setDefaultState(new TSESelectState());
this.graphWindow.switchState(this.graphWindow.getDefaultState());
}
public void stop() {}
public void destroy() {}
public void initGraph() {
TSManager.initGLT();
String[] node, edge;
TSENode[] graphNodes = new TSENode[ nodes.size() ];
TSNode[] digraphNodes = new TSNode[ nodes.size() ];
ArrayList diedges = new ArrayList();
digraph = new TSDigraph();
// create a dinode for every node
Iterator e0 = nodes.iterator();
for( int i = 0; e0.hasNext(); i++ ) {
e0.next();
digraphNodes = (TSNode) digraph.addNode();
}
// create a diedge for each edge
Iterator e1 = edges.iterator();
while( e1.hasNext() ) {
edge = (String[]) e1.next();
digraph.addEdge( digraphNodes[ getNodeIndex( edge[1] ) ], digraphNodes[ getNodeIndex( edge[2] ) ] );
}
// set the layout style
//digraph.layoutStyle(TSLayoutStyle.HIERARCHICAL);
//digraph.layoutStyle(TSLayoutStyle.SYMMETRIC);
//digraph.layoutStyle(TSLayoutStyle.ORTHOGONAL);
digraph.layoutStyle(TSLayoutStyle.CIRCULAR);
// perform the layout
digraph.layout();
// build the real graph with the coordinates supplied by
// the layout digraph
this.graph = new TSEGraph();
Iterator e2 = nodes.iterator();
//BSANodeLabelUI ui;
//TSEImageNodeUI ui = new TSEImageNodeUI();
//ui.setImage(new TSEImage(TSEImageNodeUI.class,
//"images/cb5.gif");
TSEImageNodeUI ui = new TSEImageNodeUI();
ui.setImage(new TSEImage(this.getClass(),"images/cb0.gif");
String imageSuffix = "";
for( int i = 0; e2.hasNext(); i++ ) {
// extract the companion node and dinode
String[] n = (String[]) e2.next();
TSNode n0 = digraphNodes;
// add the node to the graph
//ui = new BSANodeLabelUI( n[1] );
graphNodes = (TSENode) this.graph.addNode();
// set image
double rand = Math.random();
if( rand < 0.1 ) {
imageSuffix = "blu";
} else if( rand < 0.2 ) {
imageSuffix = "yel";
} else if( rand > 0.9 ) {
imageSuffix = "red";
} else if( rand > 0.8 ) {
imageSuffix = "grn";
} else {
imageSuffix = "gry";
}
ui.setImage(new TSEImage(this.getClass(),"images/cb_"
+ imageSuffix + ".gif");
//( (TSENode) graphNodes ).setUI( ui );
( (TSENode) graphNodes ).setUI((TSEObjectUI) ui.clone());
( ( (TSENode) graphNodes ).addLabel() ).setTag(n[1]);
//System.out.println( ( ( ( (TSENode) graphNodes ).addLabel() ).getSize() ).toString() );
// set the coordinates
//( (TSENode) graphNodes ).name = n;
( (TSENode) graphNodes ).setCenter( n0.x(), n0.y() );
}
Iterator e3 = edges.iterator();
for( int i = 0; e3.hasNext(); i++ ) {
edge = (String[]) e3.next();
this.graph.addEdge( graphNodes[ getNodeIndex( edge[1] ) ], graphNodes[ getNodeIndex( edge[2] ) ] );
}
digraph.discard();
digraph = null;
}
public void initGUI() {
// Set up the main frame window.
JFrame rootFrame = new JFrame();
rootFrame.getContentPane().setLayout(new BorderLayout());
// Create the graph window, which is the main component of the
// example editor.
this.graphWindow = new TSEGraphWindow(this.graph);
this.graphWindow.setZoomLevel( 1, true );
// Create a button panel.
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new GridLayout(4, 1));
// Create a server button and add it to the button panel.
JButton serverButton = new JButton("Server"
serverButton.setActionCommand(this.CREATE_SERVER);
serverButton.addActionListener(this);
buttonPanel.add(serverButton);
// Create a client button and add it to the button panel.
JButton clientButton = new JButton("Client"
clientButton.setActionCommand(this.CREATE_CLIENT);
clientButton.addActionListener(this);
buttonPanel.add(clientButton);
// Create a connect button and add it to the button panel.
JButton connectButton = new JButton("Connect"
connectButton.setActionCommand(this.CREATE_EDGES);
connectButton.addActionListener(this);
buttonPanel.add(connectButton);
// Create a select button and add it to the button panel.
JButton selectButton = new JButton("Select"
selectButton.setActionCommand(this.SELECT);
selectButton.addActionListener(this);
buttonPanel.add(selectButton);
// Add the two components, the button panel, and the
// graph window.
rootFrame.getContentPane().add(this.graphWindow,
BorderLayout.CENTER);
//rootFrame.getContentPane().add(buttonPanel,
//BorderLayout.EAST);
// Set a default size and make the application visible.
rootFrame.setSize(400, 400);
rootFrame.setVisible(true);
// Add a keyboard binding to the graph window.
this.graphWindow.registerKeyboardAction(this,
this.DELETE,
KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
JComponent.WHEN_IN_FOCUSED_WINDOW);
// Center the graph in the graph window.
this.graphWindow.centerGraph(true);
// Make sure that the application knows when the user
// wishes to close it.
//rootFrame.addWindowListener(this);
}
public void actionPerformed(ActionEvent event) {
String action = event.getActionCommand();
if (action == this.CREATE_SERVER) {
// The server button is pressed so set the corresponding node UI.
TSEImageNodeUI ui = new TSEImageNodeUI();
//ui.setImage(new TSEImage(TSEImageNodeUI.class, "images/server.gif");
//this.graphWindow.setCurrentNodeUI(ui);
// Switch to the create node state.
this.graphWindow.switchState(new TSECreateNodeState());
} else if (action == this.CREATE_CLIENT) {
// The client button is pressed so set the corresponding node UI.
//TSEImageNodeUI ui = new TSEImageNodeUI();
//ui.setImage(new TSEImage(TSEImageNodeUI.class, "images/terminal.gif");
//this.graphWindow.setCurrentNodeUI(ui);
// Switch to the create node state.
this.graphWindow.switchState(new TSECreateNodeState());
} else if (action == this.CREATE_EDGES) {
this.graphWindow.switchState(new TSECreateEdgeState());
} else if (action == this.SELECT) {
this.graphWindow.switchState(new TSESelectState());
} else if (action == this.DELETE) {
// Delete the selected items.
this.graphWindow.deleteSelected();
}
}
public void setNodes( ArrayList nodes ) {
this.nodes = nodes;
}
public void setEdges( ArrayList edges ) {
this.edges = edges;
}
private int getNodeIndex( String code ) {
int index = 0;
String[] node;
Iterator e = nodes.iterator();
for( int i = 0; e.hasNext(); i++ ) {
node = (String[]) e.next();
if( node[1].equals( code ) ) {
return i;
}
}
return index;
}
public void getData() {
getData( "" );
}
public void getData( String where ) {
try {
// connect to the database
Class.forName("org.gjt.mm.mysql.Driver".newInstance();
String url = pfDB.getProp( "bsa.url" );
connection = DriverManager.getConnection( url );
System.out.println( "connection established: " + !connection.isClosed() );
// select the system data and pack the list
Statement statement1 = connection.createStatement();
String selectSystems =
"select sys_key, sys_code, sys_name"
+ " from systems"
+ ( where == "" ? "" : " where " + where )
+ " order by sys_code";
ResultSet rs1 = statement1.executeQuery( selectSystems );
while( rs1.next() ) {
System.out.println(
rs1.getInt( "sys_key" )
+ ", " + rs1.getString( "sys_code" )
+ ", " + rs1.getString( "sys_name" )
);
String[] s = new String[3];
s[0] = new Integer( rs1.getInt( "sys_key" ) ).toString();
s[1] = rs1.getString( "sys_code" );
s[2] = rs1.getString( "sys_name" );
nodes.add( s );
}
// select the system_association data and pack the list
Statement statement2 = connection.createStatement();
String selectEdges =
"select sa.sa_key, s1.sys_code, s2.sys_code"
+ " from system_associations sa, systems s1, systems s2"
+ " where sa.parent_sys_key = s1.sys_key"
+ " and sa.child_sys_key = s2.sys_key"
+ ( where == "" ? "" : " and " + where )
+ " order by s1.sys_code, s2.sys_code";
ResultSet rs2 = statement2.executeQuery( selectEdges );
while( rs2.next() ) {
System.out.println(
rs2.getInt( "sa.sa_key" )
+ ", " + rs2.getString( "s1.sys_code" )
+ ", " + rs2.getString( "s2.sys_code" )
);
String[] s = new String[3];
s[0] = new Integer( rs2.getInt( "sa.sa_key" ) ).toString();
s[1] = rs2.getString( "s1.sys_code" );
s[2] = rs2.getString( "s2.sys_code" );
edges.add( s );
}
// ready to go...
start();
} catch( Exception e ) {
e.printStackTrace( System.out );
} finally {
try {
connection.close();
} catch( SQLException e ) {
e.printStackTrace( System.out );
}
}
//setNodes( nodes );
//setEdges( edges );
}
public void test() {
String code = "sys";
String name = "system";
// build a list of nodes
for( int i = 0; i < 9; i++ ) {
String[] s = new String[3];
s[0] = new Integer(i).toString();
s[1] = code + i;
s[2] = name + i;
nodes.add( s );
}
// build a list of edges
String[] a = { "1", "sys0", "sys2" };
String[] b = { "2", "sys0", "sys4" };
String[] c = { "3", "sys0", "sys6" };
String[] d = { "4", "sys0", "sys8" };
String[] e = { "13", "sys0", "sys5" };
String[] f = { "5", "sys2", "sys1" };
String[] g = { "6", "sys2", "sys3" };
String[] h = { "7", "sys4", "sys2" };
String[] i = { "8", "sys4", "sys3" };
String[] j = { "11", "sys5", "sys7" };
String[] k = { "9", "sys6", "sys5" };
String[] l = { "10", "sys6", "sys7" };
String[] m = { "12", "sys8", "sys6" };
String[] n = { "13", "sys6", "sys8" };
edges.add( a );
edges.add( b );
edges.add( c );
edges.add( d );
edges.add( e );
edges.add( f );
edges.add( g );
edges.add( h );
edges.add( i );
edges.add( j );
edges.add( k );
edges.add( l );
edges.add( m );
edges.add( n );
setNodes( nodes );
setEdges( edges );
start();
}
public static void main(String[] args) {
// A final variable is used since it should not be garbage-
// collected after the main method is completed.
if( args.length != 1 ) {
System.out.println( "\nUsage:\n" );
System.out.println( "\tjava BSAApplet test\n" );
return;
}
final BSAApplet editor = new BSAApplet();
if( args[0].equals( "test" ) ) {
editor.test();
} else {
// Set up the GUI and start the editor.
editor.getData();
}
}
}
As a standalone application, the program runs absolutely fine. But after converting to an applet, we get an "access denied" error when it tries to load.(java.util.PropertyPermission java.class.path read)
Any suggestions??? Thanks.
I am pasting the source code from the HTML file and the java source code.
<html>
<head>
<title>step 5</title>
</head>
<body>
<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
WIDTH = 600 HEIGHT = 500 codebase="<PARAM NAME = CODE VALUE = "BSAApplet1.class" >
<PARAM NAME = ARCHIVE VALUE = "ts4.jar" >
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
<PARAM NAME="scriptable" VALUE="false">
<COMMENT>
<EMBED type="application/x-java-applet;version=1.3" CODE = "BSAApplet1.class" WIDTH = 600 HEIGHT = 500 scriptable=false pluginspage="
</NOEMBED></EMBED>
</OBJECT>
<!--
<APPLET CODE = "BSAApplet1.class" ARCHIVE = "ts4.jar" WIDTH = 600 HEIGHT = 500>
</APPLET>
-->
</body>
</html>
Java Source
import javax.swing.*;
import java.sql.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import com.tomsawyer.editor.*;
import com.tomsawyer.editor.state.*;
import com.tomsawyer.editor.ui.*;
import com.tomsawyer.editorx.ui.*;
import com.tomsawyer.glt.*;
//import com.tomsawyer.graph.*;
//import ui.*;
import java.util.*;
// database support
import gov.uspto.sdi.common.*;
//import org.gjt.mm.mysql.*;
//
// This class contains the example editor.
//
public class BSAApplet extends JApplet
implements ActionListener {
// common components
private PropsFile pfDB = new PropsFile( "db.properties" );
// private LogFile lf = new LogFile( "example1.log" );
java.sql.Connection connection;
//1 private TSEGraph graph;
private TSDigraph digraph;
private TSEGraph graph;
private TSEGraphWindow graphWindow;
private ArrayList nodes = new ArrayList();
private ArrayList edges = new ArrayList();
// These constants hold strings which represent commands.
public static final String CREATE_SERVER = "Create Server";
public static final String CREATE_CLIENT = "Create Client";
public static final String CREATE_EDGES = "Create Edges";
public static final String SELECT = "Select";
public static final String DELETE = "Delete";
public BSAApplet() {
}
public BSAApplet( ArrayList nodes, ArrayList edges ) {
this.nodes = nodes;
this.edges = edges;
}
public void init() {
}
public void start() {
// Initialize the graph.
this.initGraph();
// Initialize the GUI.
this.initGUI();
// Initialize the graph window. Set the graph and default
// state.
this.graphWindow.setDefaultState(new TSESelectState());
this.graphWindow.switchState(this.graphWindow.getDefaultState());
}
public void stop() {}
public void destroy() {}
public void initGraph() {
TSManager.initGLT();
String[] node, edge;
TSENode[] graphNodes = new TSENode[ nodes.size() ];
TSNode[] digraphNodes = new TSNode[ nodes.size() ];
ArrayList diedges = new ArrayList();
digraph = new TSDigraph();
// create a dinode for every node
Iterator e0 = nodes.iterator();
for( int i = 0; e0.hasNext(); i++ ) {
e0.next();
digraphNodes = (TSNode) digraph.addNode();
}
// create a diedge for each edge
Iterator e1 = edges.iterator();
while( e1.hasNext() ) {
edge = (String[]) e1.next();
digraph.addEdge( digraphNodes[ getNodeIndex( edge[1] ) ], digraphNodes[ getNodeIndex( edge[2] ) ] );
}
// set the layout style
//digraph.layoutStyle(TSLayoutStyle.HIERARCHICAL);
//digraph.layoutStyle(TSLayoutStyle.SYMMETRIC);
//digraph.layoutStyle(TSLayoutStyle.ORTHOGONAL);
digraph.layoutStyle(TSLayoutStyle.CIRCULAR);
// perform the layout
digraph.layout();
// build the real graph with the coordinates supplied by
// the layout digraph
this.graph = new TSEGraph();
Iterator e2 = nodes.iterator();
//BSANodeLabelUI ui;
//TSEImageNodeUI ui = new TSEImageNodeUI();
//ui.setImage(new TSEImage(TSEImageNodeUI.class,
//"images/cb5.gif");
TSEImageNodeUI ui = new TSEImageNodeUI();
ui.setImage(new TSEImage(this.getClass(),"images/cb0.gif");
String imageSuffix = "";
for( int i = 0; e2.hasNext(); i++ ) {
// extract the companion node and dinode
String[] n = (String[]) e2.next();
TSNode n0 = digraphNodes;
// add the node to the graph
//ui = new BSANodeLabelUI( n[1] );
graphNodes = (TSENode) this.graph.addNode();
// set image
double rand = Math.random();
if( rand < 0.1 ) {
imageSuffix = "blu";
} else if( rand < 0.2 ) {
imageSuffix = "yel";
} else if( rand > 0.9 ) {
imageSuffix = "red";
} else if( rand > 0.8 ) {
imageSuffix = "grn";
} else {
imageSuffix = "gry";
}
ui.setImage(new TSEImage(this.getClass(),"images/cb_"
+ imageSuffix + ".gif");
//( (TSENode) graphNodes ).setUI( ui );
( (TSENode) graphNodes ).setUI((TSEObjectUI) ui.clone());
( ( (TSENode) graphNodes ).addLabel() ).setTag(n[1]);
//System.out.println( ( ( ( (TSENode) graphNodes ).addLabel() ).getSize() ).toString() );
// set the coordinates
//( (TSENode) graphNodes ).name = n;
( (TSENode) graphNodes ).setCenter( n0.x(), n0.y() );
}
Iterator e3 = edges.iterator();
for( int i = 0; e3.hasNext(); i++ ) {
edge = (String[]) e3.next();
this.graph.addEdge( graphNodes[ getNodeIndex( edge[1] ) ], graphNodes[ getNodeIndex( edge[2] ) ] );
}
digraph.discard();
digraph = null;
}
public void initGUI() {
// Set up the main frame window.
JFrame rootFrame = new JFrame();
rootFrame.getContentPane().setLayout(new BorderLayout());
// Create the graph window, which is the main component of the
// example editor.
this.graphWindow = new TSEGraphWindow(this.graph);
this.graphWindow.setZoomLevel( 1, true );
// Create a button panel.
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new GridLayout(4, 1));
// Create a server button and add it to the button panel.
JButton serverButton = new JButton("Server"
serverButton.setActionCommand(this.CREATE_SERVER);
serverButton.addActionListener(this);
buttonPanel.add(serverButton);
// Create a client button and add it to the button panel.
JButton clientButton = new JButton("Client"
clientButton.setActionCommand(this.CREATE_CLIENT);
clientButton.addActionListener(this);
buttonPanel.add(clientButton);
// Create a connect button and add it to the button panel.
JButton connectButton = new JButton("Connect"
connectButton.setActionCommand(this.CREATE_EDGES);
connectButton.addActionListener(this);
buttonPanel.add(connectButton);
// Create a select button and add it to the button panel.
JButton selectButton = new JButton("Select"
selectButton.setActionCommand(this.SELECT);
selectButton.addActionListener(this);
buttonPanel.add(selectButton);
// Add the two components, the button panel, and the
// graph window.
rootFrame.getContentPane().add(this.graphWindow,
BorderLayout.CENTER);
//rootFrame.getContentPane().add(buttonPanel,
//BorderLayout.EAST);
// Set a default size and make the application visible.
rootFrame.setSize(400, 400);
rootFrame.setVisible(true);
// Add a keyboard binding to the graph window.
this.graphWindow.registerKeyboardAction(this,
this.DELETE,
KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
JComponent.WHEN_IN_FOCUSED_WINDOW);
// Center the graph in the graph window.
this.graphWindow.centerGraph(true);
// Make sure that the application knows when the user
// wishes to close it.
//rootFrame.addWindowListener(this);
}
public void actionPerformed(ActionEvent event) {
String action = event.getActionCommand();
if (action == this.CREATE_SERVER) {
// The server button is pressed so set the corresponding node UI.
TSEImageNodeUI ui = new TSEImageNodeUI();
//ui.setImage(new TSEImage(TSEImageNodeUI.class, "images/server.gif");
//this.graphWindow.setCurrentNodeUI(ui);
// Switch to the create node state.
this.graphWindow.switchState(new TSECreateNodeState());
} else if (action == this.CREATE_CLIENT) {
// The client button is pressed so set the corresponding node UI.
//TSEImageNodeUI ui = new TSEImageNodeUI();
//ui.setImage(new TSEImage(TSEImageNodeUI.class, "images/terminal.gif");
//this.graphWindow.setCurrentNodeUI(ui);
// Switch to the create node state.
this.graphWindow.switchState(new TSECreateNodeState());
} else if (action == this.CREATE_EDGES) {
this.graphWindow.switchState(new TSECreateEdgeState());
} else if (action == this.SELECT) {
this.graphWindow.switchState(new TSESelectState());
} else if (action == this.DELETE) {
// Delete the selected items.
this.graphWindow.deleteSelected();
}
}
public void setNodes( ArrayList nodes ) {
this.nodes = nodes;
}
public void setEdges( ArrayList edges ) {
this.edges = edges;
}
private int getNodeIndex( String code ) {
int index = 0;
String[] node;
Iterator e = nodes.iterator();
for( int i = 0; e.hasNext(); i++ ) {
node = (String[]) e.next();
if( node[1].equals( code ) ) {
return i;
}
}
return index;
}
public void getData() {
getData( "" );
}
public void getData( String where ) {
try {
// connect to the database
Class.forName("org.gjt.mm.mysql.Driver".newInstance();
String url = pfDB.getProp( "bsa.url" );
connection = DriverManager.getConnection( url );
System.out.println( "connection established: " + !connection.isClosed() );
// select the system data and pack the list
Statement statement1 = connection.createStatement();
String selectSystems =
"select sys_key, sys_code, sys_name"
+ " from systems"
+ ( where == "" ? "" : " where " + where )
+ " order by sys_code";
ResultSet rs1 = statement1.executeQuery( selectSystems );
while( rs1.next() ) {
System.out.println(
rs1.getInt( "sys_key" )
+ ", " + rs1.getString( "sys_code" )
+ ", " + rs1.getString( "sys_name" )
);
String[] s = new String[3];
s[0] = new Integer( rs1.getInt( "sys_key" ) ).toString();
s[1] = rs1.getString( "sys_code" );
s[2] = rs1.getString( "sys_name" );
nodes.add( s );
}
// select the system_association data and pack the list
Statement statement2 = connection.createStatement();
String selectEdges =
"select sa.sa_key, s1.sys_code, s2.sys_code"
+ " from system_associations sa, systems s1, systems s2"
+ " where sa.parent_sys_key = s1.sys_key"
+ " and sa.child_sys_key = s2.sys_key"
+ ( where == "" ? "" : " and " + where )
+ " order by s1.sys_code, s2.sys_code";
ResultSet rs2 = statement2.executeQuery( selectEdges );
while( rs2.next() ) {
System.out.println(
rs2.getInt( "sa.sa_key" )
+ ", " + rs2.getString( "s1.sys_code" )
+ ", " + rs2.getString( "s2.sys_code" )
);
String[] s = new String[3];
s[0] = new Integer( rs2.getInt( "sa.sa_key" ) ).toString();
s[1] = rs2.getString( "s1.sys_code" );
s[2] = rs2.getString( "s2.sys_code" );
edges.add( s );
}
// ready to go...
start();
} catch( Exception e ) {
e.printStackTrace( System.out );
} finally {
try {
connection.close();
} catch( SQLException e ) {
e.printStackTrace( System.out );
}
}
//setNodes( nodes );
//setEdges( edges );
}
public void test() {
String code = "sys";
String name = "system";
// build a list of nodes
for( int i = 0; i < 9; i++ ) {
String[] s = new String[3];
s[0] = new Integer(i).toString();
s[1] = code + i;
s[2] = name + i;
nodes.add( s );
}
// build a list of edges
String[] a = { "1", "sys0", "sys2" };
String[] b = { "2", "sys0", "sys4" };
String[] c = { "3", "sys0", "sys6" };
String[] d = { "4", "sys0", "sys8" };
String[] e = { "13", "sys0", "sys5" };
String[] f = { "5", "sys2", "sys1" };
String[] g = { "6", "sys2", "sys3" };
String[] h = { "7", "sys4", "sys2" };
String[] i = { "8", "sys4", "sys3" };
String[] j = { "11", "sys5", "sys7" };
String[] k = { "9", "sys6", "sys5" };
String[] l = { "10", "sys6", "sys7" };
String[] m = { "12", "sys8", "sys6" };
String[] n = { "13", "sys6", "sys8" };
edges.add( a );
edges.add( b );
edges.add( c );
edges.add( d );
edges.add( e );
edges.add( f );
edges.add( g );
edges.add( h );
edges.add( i );
edges.add( j );
edges.add( k );
edges.add( l );
edges.add( m );
edges.add( n );
setNodes( nodes );
setEdges( edges );
start();
}
public static void main(String[] args) {
// A final variable is used since it should not be garbage-
// collected after the main method is completed.
if( args.length != 1 ) {
System.out.println( "\nUsage:\n" );
System.out.println( "\tjava BSAApplet test\n" );
return;
}
final BSAApplet editor = new BSAApplet();
if( args[0].equals( "test" ) ) {
editor.test();
} else {
// Set up the GUI and start the editor.
editor.getData();
}
}
}