forked from Coded/SIPRP
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
173 lines
4.7 KiB
173 lines
4.7 KiB
package siprp;
|
|
|
|
import siprp.ficha.*;
|
|
|
|
import com.evolute.utils.*;
|
|
import com.evolute.utils.db.*;
|
|
import com.evolute.utils.db.keyretrievers.*;
|
|
import com.evolute.utils.jdbc.*;
|
|
import com.evolute.utils.sql.*;
|
|
import com.evolute.utils.ui.*;
|
|
import com.evolute.utils.ui.window.*;
|
|
|
|
import javax.jdo.JDOHelper;
|
|
import javax.jdo.PersistenceManager;
|
|
import javax.jdo.PersistenceManagerFactory;
|
|
import javax.jdo.Transaction;
|
|
|
|
import java.awt.*;
|
|
import java.io.*;
|
|
import java.text.*;
|
|
import java.util.*;
|
|
import javax.swing.*;
|
|
import javax.swing.tree.*;
|
|
|
|
public class Main implements Connector
|
|
{
|
|
private final static ClassLoader classLoader = new EVUtilsImageLib().getClass().getClassLoader();
|
|
|
|
private static final String dbase = "siprp";
|
|
private SIPRPTracker siprpTracker;
|
|
|
|
public static void main( String args[] )
|
|
throws Exception
|
|
{
|
|
/* Calendar cal = Calendar.getInstance();
|
|
cal.set( 2004, 06, 14 );
|
|
if( cal.before( Calendar.getInstance() ) )
|
|
{
|
|
com.evolute.utils.ui.DialogException.showException( new RuntimeException( "Unknown error ocurred." ) );
|
|
}
|
|
else
|
|
{
|
|
*/ Insert.setDefaultKeyRetriever( JDBCAutoKeyRetriever.DEFAULT );
|
|
String server = System.getProperty( "server.address" );
|
|
// if( server == null )
|
|
// {
|
|
// server = "ws_fpalma";
|
|
// }
|
|
//
|
|
// String user = "root";
|
|
// String passwd = "UNIXLuvsU";
|
|
//
|
|
// DBManager dbm = new JDBCManager( "jdbc:mysql://" + server + "/" + dbase,
|
|
// user, passwd , 10, 8, 8, null );
|
|
|
|
UnicodeChecker.setUseDoubleSlash( true );
|
|
// Singleton.setInstance( Singleton.DEFAULT_DBMANAGER, dbm );
|
|
|
|
// StatementExecuterFactory.initialize(
|
|
// new DBStatementExecuter( dbm.getSharedExecuter() ) );
|
|
// }
|
|
// FichaWindow window = new FichaWindow();
|
|
/* window.setLogo( new ImageIcon(
|
|
new Main().getClass().getClassLoader().getResource( "logo/logo_w400.png" )
|
|
).getImage() );*/
|
|
// window.show();
|
|
new LoginWindow( new Main(), "logo"+File.separator + "logo_w400.jpg",
|
|
new String[] { "SIPRPSoft" },
|
|
new String[] { "Vers\u00E3o 0.1", "(EVOLUTE 2004)" }, "",
|
|
"root", "UNIXLuvsU", new JPanel() ).show();
|
|
|
|
}
|
|
|
|
public boolean connect( String user, String passwd )
|
|
{
|
|
try
|
|
{
|
|
// run initialization SQL
|
|
SQLQuery initQuery[] = new SQLQuery[] {};
|
|
String server = System.getProperty( "server.address" );
|
|
if( server == null )
|
|
{
|
|
server = "ws_fpalma";
|
|
}
|
|
DBManager dbm = new JDBCManager( "jdbc:mysql://" + server + "/" + dbase,
|
|
user, passwd , 10, 8, 8, null );
|
|
// UnicodeChecker.setUseDoubleSlash( true );
|
|
Singleton.setInstance( Singleton.DEFAULT_DBMANAGER, dbm );
|
|
|
|
StatementExecuterFactory.initialize(
|
|
new DBStatementExecuter( dbm.getSharedExecuter() ) );
|
|
|
|
Properties props = new Properties();
|
|
props.load( classLoader.getResourceAsStream( "speedo.properties" ) );
|
|
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory( props );
|
|
PersistenceManager pm = pmf.getPersistenceManager();
|
|
Singleton.setInstance( SingletonConstants.PERSISTENCE_MANAGER, pm );
|
|
com.evolute.utils.jdo.JDOObject.setPersistentManager( pm );
|
|
|
|
pm.currentTransaction().begin();
|
|
siprp.data.Empresa emp = new siprp.data.Empresa();
|
|
emp.set( siprp.data.Empresa.ID, new Integer( 999 ) );
|
|
emp.set( siprp.data.Empresa.DESIGNACAO_SOCIAL, "JDO_TESTE" );
|
|
pm.makePersistent( emp );
|
|
pm.currentTransaction().commit();
|
|
|
|
StatementExecuterFactory.initialize(
|
|
new DBStatementExecuter( dbm.getSharedExecuter() ) );
|
|
StatementExecuterFactory.initialize(
|
|
new DBStatementExecuter( dbm.getSharedExecuter() ) );
|
|
Singleton.setInstance( Singleton.TODAY, new Date() );
|
|
|
|
//cleanData( dbm.getSharedExecuter() );
|
|
//msg( dbm.getSharedExecuter() );
|
|
}
|
|
catch( Exception ex )
|
|
{
|
|
DialogException.showExceptionMessage( ex, "N\u00E3o foi poss\u00EDvel estabelecer"
|
|
+ " a liga\u00E7\u00E3o \u00E0 base de dados.", false );
|
|
return false;
|
|
}
|
|
Singleton.setInstance( Singleton.USERNAME, user );
|
|
|
|
//Singleton.setInstance( Singleton.USERNAME, user );
|
|
siprpTracker = new SIPRPTracker();
|
|
return true;
|
|
}
|
|
|
|
public boolean disconnect()
|
|
{
|
|
if( siprpTracker.quit() )
|
|
{
|
|
siprpTracker = null;
|
|
try
|
|
{
|
|
( ( DBManager )Singleton.getInstance(
|
|
Singleton.DEFAULT_DBMANAGER ) ).close();
|
|
Singleton.clear();
|
|
}
|
|
catch( DBException ex )
|
|
{
|
|
DialogException.showException( ex );
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public void executeAction( DefaultMutableTreeNode node )
|
|
{
|
|
try
|
|
{
|
|
siprpTracker.openWindow( ( String )node.getUserObject() );
|
|
}
|
|
catch( Exception ex )
|
|
{
|
|
DialogException.showException( ex );
|
|
}
|
|
}
|
|
|
|
public void exit()
|
|
{
|
|
if( siprpTracker == null || siprpTracker.quit() )
|
|
{
|
|
System.exit( 0 );
|
|
}
|
|
}
|
|
|
|
public MutableTreeNode getTree()
|
|
{
|
|
return siprpTracker.getRoot();
|
|
}
|
|
} |