MpBiz.java :  » ERP-CRM-Financial » Evaristo-4.0 » com » m16e » mpbiz » Java Open Source

Java Open Source » ERP CRM Financial » Evaristo 4.0 
Evaristo 4.0 » com » m16e » mpbiz » MpBiz.java
/*
 * MpBiz.java
 */

package com.m16e.mpbiz;

import com.m16e.mpbiz.common.MpBizApp;
import com.m16e.mpbiz.common.MpBizApp.SessionType;
import com.m16e.mpbiz.common.MpBizAppConfig;
import com.m16e.mpbiz.common.MpBizAppContext;
import com.m16e.mpbiz.common.MpBizCompanyData;
import com.m16e.mpbiz.common.MpBizConstants;
import com.m16e.mpbiz.common.MpBizDatabaseProvider;
import com.m16e.mpbiz.common.MpBizFactory;
import com.m16e.mpbiz.common.MpBizUser;
import com.m16e.mpbiz.common.bizclasses.MpBizException;
import com.m16e.mpbiz.docs.MpDocFactory;
import com.m16e.mpbiz.i18n.MpBizBundle;
import com.m16e.mpbiz.listeners.MpBizListener;
import com.m16e.mpbiz.tables.DbDoc;
import com.m16e.mpbiz.tables.DbEnt;
import com.m16e.mpbiz.tables.DbProd;
import com.m16e.tools.MpAppConfig;
import com.m16e.tools.MpAppContext;
import com.m16e.tools.MpDay;
import com.m16e.tools.MpToolsException;
import com.m16e.tools.Tools;
import com.m16e.tools.db.Database;
import com.m16e.tools.db.DatabaseProvider;
import com.m16e.tools.db.DbBundle;
import com.m16e.tools.db.DbConnection;
import com.m16e.tools.files.MpFileUtils;
import com.m16e.tools.gui.GuiFactory;
import com.m16e.tools.gui.MpSplashFrame;
import com.m16e.tools.gui.MpSysTrayIcon;
import com.m16e.tools.i18n.LocaleBundle;
import com.m16e.tools.i18n.MpBundle;
import com.m16e.tools.log4j.MpLog4jFactory;
import com.m16e.tools.xgm.XgmComponent;
import com.m16e.tools.xgm.XgmException;
import com.m16e.tools.xgm.XgmFactory;
import com.m16e.tools.xgm.XgmListener;
import com.m16e.tools.xgm.XgmRootContainer;
import com.m16e.tools.xgm.XgmRootContainerInstance;
import com.m16e.tools.xgm.XgmRootContainerListener;
import com.m16e.tools.xml.XmlTreeNode;
import com.m16e.tools.xml.XmlTreeNodeable;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.SystemTray;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.sql.SQLException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTextArea;
import org.apache.log4j.Logger;


////////////////////////////////////////////////////////////
public class MpBiz
extends MpBizApp
implements MpBizMBean, XgmRootContainerListener
{
  private static Logger logger = Logger.getLogger( MpBiz.class );

  public static final String ABOUT = "about";
  public static final String HELP = "help";
  public static final String DB_INFO = "db-info";
  public static final String SPLASH_ICON_PATH =
    "com/m16e/mpbiz/resources/img/evaristo-splash.png";

  static final String CURRENCY_NAME = "currency_name";

  public static final String XGM_MAIN_MENU_FRAME = "main-menu-frame";

  MpBizListener mpBizListener = null;

  XgmRootContainer xrcMenu = null;

  static MpBiz onlyInstance = null;

  MpSplashFrame splashFrame = null;
  JPopupMenu jpmTrayMenu = new JPopupMenu();

  ////////////////////////////////////////////////////////////
  public MpBiz()
  throws MpBizException
  {
    if( onlyInstance != null )
      throw new MpBizException( "SECOND INSTANCE NOT ALLOWED" );
    onlyInstance = this;
  }

  //////////////////////////////////////////////////////////
  public void init( String[] args )
  throws Exception
  {
    parseArgs( args );
    ImageIcon icon = MpFileUtils.readIconResource( SPLASH_ICON_PATH );
    if( isHideSplash() )
      icon = null;

    logger.info(
      "MpBiz version " + MpBizConstants.MPBIZ_VERSION_NUMBER +
      " - build: " + MpBizConstants.MPBIZ_BUILD_NUMBER +
      "\ndate: " + MpBizConstants.MPBIZ_BUILD_DATE + "\n" +
      "Icon: " + (icon == null ? "NULL" : SPLASH_ICON_PATH) );

    XgmRootContainer.setRootContainerListener( this );
    DatabaseProvider dbProvider = MpBizDatabaseProvider.getInstance();
    MpAppContext.getInstance().setDatabaseProvider( dbProvider );
    MpAppContext.getInstance().setAppHomeDir( getProfileDir() );
    splashFrame = start( null, SessionType.STANDARD, icon );
    if( splashFrame != null )
    {
      splashFrame.setVisible( false );
    }
    login();
    Thread t =
      new Thread(
        new Runnable()
        {
          public void run()
          {
            try
            {
              Thread.sleep( 3000 );
              refreshTableInfo();
            }
            catch( Exception e )
            {
              logger.error( e.getMessage(), e );
            }
          }
        } );
    t.start();
  }

//  //////////////////////////////////////////////////////////
//  public MpBiz( String profileDir, String propsFile, DbConnection con )
//  throws SQLException, MpBizException, XgmException, DatabaseException
//  {
//    this();
//    start( profileDir, propsFile, con );
//  }
//
  ////////////////////////////////////////////////////////////
  public static MpBiz getInstance() { return onlyInstance; }

  ////////////////////////////////////////////////////////////
  public void parseArgs( String[] args )
  throws Exception
  {
    if( logger.isInfoEnabled() )
    {
      StringBuilder sb = new StringBuilder();
      for( String s : args )
      {
        sb.append( "\n" + s );
      }
      logger.info( "args: " + sb.toString() );
    }
    boolean debugConsole = false;
    if( args.length > 0 )
    {
      for( int f = 0; f < args.length; f++ )
      {
        if( args[f].equals( "-p" ) )
        {
          setProfileDir( args[++f] );
        }
        else if( args[f].equals( "-f" ) )
        {
          setConfigFile( args[++f] );
        }
        else if( args[f].equals( "-wh" ) )
        {
          setDefaultWarehose( new Integer( args[++f] ) );
        }
        else if( args[0].startsWith( "-v" ) )
        {
          System.out.println(
            "\n\nMpBiz version " + MpBizConstants.MPBIZ_VERSION_NUMBER +
            "\ndate: " + MpBizConstants.MPBIZ_BUILD_DATE );
          System.exit( 0 );
        }
        else if( args[f].equals( "-l" ) )
        {
//          setLogFile( args[++f] );
          f++;
        }
        else if( args[f].equals( "--no-splash" ) )
        {
          setHideSplash( true );
        }
        else if( args[f].equals( "-X" ) )
        {
          debugConsole = true;
        }
        else
        {
          System.out.println(
            "\n\nUsage: \n  MpBiz (args)" +
            "\n    -p <profile dir> : uses <profile dir> as the working directory" +
            "\n    -f <props-file> : reads properties from alternate config file" +
            "\n    -wh <warehouse> : use <warehouse> as default" +
            "\n    -h : this help message" +
            "\n    --no-splash : don't use splash" +
            "\n    -v: version" );
          System.exit( 0 );
        }
      }
    }
    JTextArea debugTextArea = null;
    if( debugConsole )
    {
      debugTextArea = new JTextArea();
      JScrollPane jsp = new JScrollPane( debugTextArea );
      JFrame jf = new JFrame();
      jf.setTitle( "Error message" );
      jf.setSize( 500, 300 );
      jf.setLayout( new BorderLayout() );
      jf.getContentPane().add( "Center", jsp );

      Dimension dim = jf.getToolkit().getScreenSize();
      Rectangle abounds = jf.getBounds();
      Dimension dd = jf.getSize();
      jf.setLocation( (dim.width - abounds.width) / 2,
        (dim.height - abounds.height) / 2 );
      jf.setVisible( true );
      jf.requestFocus();

    }
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

    // Construct the ObjectName for the MBean we will register
    ObjectName name = new ObjectName( "com.m16e.mpbiz:type=MpBiz" );
    mbs.registerMBean( this, name );

  }
  ////////////////////////////////////////////////////////////
  @Override
  public String getAppName() { return MpBizConstants.MPBIZ_APP_NAME; }
  @Override
  public String getDbVersion() { return MpBizConstants.MPBIZ_REQUIERED_DB_VERSION; }
  @Override
  public String getVersion() { return MpBizConstants.MPBIZ_VERSION_NUMBER; }
  @Override
  public String getBuildDate() { return MpBizConstants.MPBIZ_BUILD_DATE; }
  @Override
  public String getBuildNumber() { return MpBizConstants.MPBIZ_BUILD_NUMBER; }

  ////////////////////////////////////////////////////////////
  @Override
  public String getAboutMessage()
  {
    String appName = getAppName();
    String version = getVersion();
    String release = getBuildNumber();
    String date = getBuildDate();
    String s =
      appName + " " + version  + " - " + release + "\n" +
      "made by Mem\u00F3ria Persistente, Lda.\n" +
      "URL: http://www.m16e.com\n" +
      "E-mail: geral@m16e.com\n" +
      "Date: " + date + "\n" +
      "Author(s):\n" +
      "  Carlos Correia\n";
    return s;
  }

//  ////////////////////////////////////////////////////////////
//  public void initTables()
//  throws SQLException, MpDocException, XgmException
//  {
//    MpDocFactory.getInstance().refreshTables();
//  }
//
  ////////////////////////////////////////////////////////////
  public DatabaseProvider getDatabaseProvider()
  {
    return MpBizDatabaseProvider.getInstance();
  }

  ////////////////////////////////////////////////////////////
  @Override
  public MpSplashFrame start(
    DbConnection con, SessionType sessionType, ImageIcon icon )
  throws MpBizException
  {
    splashFrame = super.start( con, sessionType, icon );
    MpBundle bundle = MpBizBundle.getInstance();

    DatabaseProvider dbProvider = MpBizDatabaseProvider.getInstance();
    MpAppContext.getInstance().setDatabaseProvider( dbProvider );

    if( splashFrame != null )
    {
      splashFrame.setProgressText(
        bundle.getBundleMessage( MpBizBundle.MSG_CONFIGURING_UI ) );
    }
    MpBizAppContext.setAboutMessage( getAboutMessage() );
    MpBizAppContext.setDbInfoMessage( getDbInfoMessage() );
    try
    {
      MpBizAppConfig.getInstance().getBizCompanyData().getCompanyInfo();
    }
    catch( Exception e )
    {
      logger.error( e.getMessage(), e );
      throw new MpBizException( e );
    }
    return splashFrame;
  }

  ////////////////////////////////////////////////////////////
  public XgmListener getXgmListener()
  {
    if( mpBizListener == null )
      mpBizListener = new MpBizListener();
    return mpBizListener;
  }

  ////////////////////////////////////////////////////////////
  private void closeDB()
  {
    try
    {
      MpAppContext.getInstance().getDatabase().close();
    }
    catch( Exception e )
    {
      logger.error( e.getMessage(), e );
    }
  }

  ////////////////////////////////////////////////////////////
  void createJPopupMenu()
  {
    jpmTrayMenu.removeAll();

    JMenu jm = new JMenu( "Evaristo" );

    JMenuItem jmi =
      new JMenuItem(
        new AbstractAction( "Procurar Entidades" )
        {
          public void actionPerformed( ActionEvent e )
          {
            EventQueue.invokeLater(
              new Runnable() {
                public void run()
                {
                  MpBizFactory.getInstance().findEntByLimits(
                    getXgmListener(), null, DbEnt.T_NAME, null );
                }
              } );
          }
        } );
    jmi.setFont( jmi.getFont().deriveFont( Font.PLAIN ) );
    jmi.setFont( jmi.getFont().deriveFont( 10f ) );
    jm.add( jmi );

    jmi =
      new JMenuItem(
        new AbstractAction( "Procurar Produtos" )
        {
          public void actionPerformed( ActionEvent e )
          {
            EventQueue.invokeLater(
              new Runnable() {
                public void run()
                {
                  MpBizFactory.getInstance().findProdByLimits(
                    getXgmListener(), null, DbProd.T_NAME );
                }
              } );
          }
        } );
    jmi.setFont( jmi.getFont().deriveFont( Font.PLAIN ) );
    jmi.setFont( jmi.getFont().deriveFont( 10f ) );
    jm.add( jmi );

    jmi =
      new JMenuItem(
        new AbstractAction( "Procurar Documentos" )
        {
          public void actionPerformed( ActionEvent e )
          {
            EventQueue.invokeLater(
              new Runnable() {
                public void run()
                {
                  MpBizFactory.getInstance().findDocByLimits(
                    getXgmListener(), null, DbDoc.T_NAME );
                }
              } );
          }
        } );
    jmi.setFont( jmi.getFont().deriveFont( Font.PLAIN ) );
    jmi.setFont( jmi.getFont().deriveFont( 10f ) );
    jm.add( jmi );

    jpmTrayMenu.add( jm );

    jpmTrayMenu.add(
      getActiveContainersItems(
        XgmRootContainerInstance.getTopmostContainer()) );

    JMenuItem exitItem = new JMenuItem( "Fechar" );
    exitItem.addActionListener(
      new ActionListener() {
        public void actionPerformed( ActionEvent e ) {
          EventQueue.invokeLater( new Runnable() {
            public void run()
            {
              boolean confirmed = 
                GuiFactory.confirmMsg(
                  (Component) null,
                  MpBizBundle.getInstance().getBundleMessage(
                    MpBizBundle.MSG_CONFIRM_EXIT_APP ) );

              if( confirmed )
              {
                closeDB();
                xrcMenu.setVisible( false );
                System.exit( 0 );
              }
            }
          } );
        }
      } );
    exitItem.setFont( jmi.getFont().deriveFont( Font.PLAIN ) );
    exitItem.setFont( jmi.getFont().deriveFont( 10f ) );
    jpmTrayMenu.add( exitItem );
    jpmTrayMenu.invalidate();
  }

  ////////////////////////////////////////////////////////////
  public void xrcClosed( XgmRootContainer xrc )
  {
    String title = xrc.getTitle();
    XmlTreeNodeable xtnWindow =
      XgmRootContainerInstance.getContainerByInstanceNumber(
        xrc.getInstanceNumber() );
    if( xtnWindow != null )
    {
      createJPopupMenu();
    }
  }

  ////////////////////////////////////////////////////////////
  public void xrcOpened( XgmRootContainer xrc )
  {
    String title = xrc.getTitle();
    if( title == null || title.length() == 0 )
      return;

    createJPopupMenu();
  }

  ////////////////////////////////////////////////////////////
  private JMenuItem getActiveContainerItem( final XgmRootContainerInstance xrci )
  {
    JMenuItem jmi = null;
    String title = xrci.toString();
    if( title != null )
    {
      jmi =
        new JMenuItem(
          new AbstractAction( title )
          {
            public void actionPerformed( ActionEvent e )
            {
              EventQueue.invokeLater(
                new Runnable() {
                  public void run()
                  {
                    xrci.getXrc().setVisible( true);
                  }
                } );
            }
          } );
      jmi.setFont( jmi.getFont().deriveFont( Font.PLAIN ) );
      jmi.setFont( jmi.getFont().deriveFont( 10f ) );
    }
    return jmi;
  }

  ////////////////////////////////////////////////////////////
  private JMenuItem getActiveContainersItems( XgmRootContainerInstance xrci )
  {
    if( !xrci.hasChildren() )
    {
      return getActiveContainerItem( xrci );
    }
    JMenuItem jmTop = new JMenu( xrci.toString() );
    jmTop.setFont( jmTop.getFont().deriveFont( Font.PLAIN ) );
    jmTop.setFont( jmTop.getFont().deriveFont( 10f ) );

    JMenuItem jmiThis = getActiveContainerItem( xrci );
    jmiThis.setText(
      MpBizBundle.getInstance().getBundleMessage(
        MpBizBundle.MSG_THIS_WINDOW ) + ": " + xrci.toString() );
    jmiThis.setFont( jmiThis.getFont().deriveFont( Font.PLAIN ) );
    jmiThis.setFont( jmiThis.getFont().deriveFont( 10f ) );
    jmTop.add( jmiThis );
    jmTop.add( new JSeparator() );

    for( XmlTreeNodeable x : xrci.getChildren() )
    {
      if( x instanceof XgmRootContainerInstance )
      {
        jmTop.add( getActiveContainerItem( (XgmRootContainerInstance) x) );
      }
    }
    return jmTop;
  }

  ////////////////////////////////////////////////////////////
  @Override
  public void openMenu( MpBizUser mbu )
  throws MpBizException
  {
    try
    {
      mpBizListener = (MpBizListener) getXgmListener();
      WindowListener wl = new MpBizWindowListener( mbu.getUsername() );
      xrcMenu = new XgmRootContainer( mpBizListener );
      String mainMenuFile = MpBizAppConfig.getInstance().getMainMenuFile();
      String layout = XgmFactory.getInstance().readLayout( mainMenuFile );
      XmlTreeNode xtnLayout = new XmlTreeNode();
      xtnLayout.fromXml( layout );
      MpBizAppConfig.getInstance().fillCompanyData( xtnLayout );
      xrcMenu.setLayout( mainMenuFile, xtnLayout, false );


      XgmComponent xc =
        xrcMenu.getComponentByName(
          MpBizCompanyData.CompanyDataField.NAME.getName() );
      if( xc != null )
      {
        String companyName =
          MpBizAppConfig.getInstance().getBizCompanyData().getValue(
            MpBizCompanyData.CompanyDataField.NAME.getName() );
        if( companyName != null )
        {
          xc.setComponentValueFromString( companyName );
        }
      }

      xc = xrcMenu.getComponentByName( MpBizAppContext.DEFAULT_WAREHOUSE );
      if( xc != null )
      {
        Integer warehouse = MpBizAppContext.getInstance().getDefaultWarehouse();
        if( warehouse != null )
        {
          String text =
            MpBizBundle.getInstance().getBundleMessage(
              MpBizBundle.STR_WAREHOUSE ) + " (" + warehouse + ")";
          xc.setComponentValueFromString( text );
        }
      }

      xc = xrcMenu.getComponentByName( MpBizAppContext.DEFAULT_DATE );
      if( xc != null )
      {
        MpDay defaultDate = MpDocFactory.getInstance().getDefaultDocDate();
        if( defaultDate != null )
        {
          String text = defaultDate.getDateYYYYMMDD();
          xc.setComponentValueFromString( text );
        }
      }

      JFrame menuWindow = (JFrame) xrcMenu.getSwingContainer();
      menuWindow.setLocale( MpAppContext.getInstance().getLocale() );
      String appName = getAppName();
      String version = getVersion();
      menuWindow.setTitle(
        "www.m16e.com - " + appName + " - " + version );
      menuWindow.addWindowListener( wl );
      //xrcMenu.addXgmListener( this );
      if( !mbu.isAdmin() )
      {
        XgmComponent xComp = xrcMenu.getComponentByName( "tab" );
        if( xComp != null )
        {
          Component comp = xComp.getSwingComponent();
          comp.setVisible( false );
          xc = xrcMenu.getComponentByName( "invent" );
          if( xc != null )
          {
            comp = xc.getSwingComponent();
            comp.setVisible( false );
          }
        }
      }
      else
      {
        xc = xrcMenu.getComponentByName( "tab-all-users" );
        if( xc != null )
        {
          xc.getSwingComponent().setVisible( false );
        }
      }
      menuWindow.setLocationByPlatform( false );

      menuWindow.setLocation( 0, 0 );

      if( splashFrame != null )
      {
        splashFrame.setVisible( false );
      }
      xrcMenu.getSwingComponent().validate();
      MpAppConfig.SysTrayMsgType msgType = MpAppConfig.getInstance().getSysTrayMsgType();
      boolean useSysTray = MpAppConfig.getInstance().getUseSysTray();
      boolean openMainMenuOnStart =
        MpAppConfig.getInstance().getOpenMainMenuOnStart();
      if( useSysTray && SystemTray.isSupported() )
      {
        ImageIcon imageIcon =
          Tools.getImageIcon(
            MpAppConfig.getInstance().getSysTrayIconFile(), true );
        final MpSysTrayIcon tray =
          new MpSysTrayIcon( imageIcon.getImage(), "Evaristo" );
        createJPopupMenu();
        tray.setJPopupMenu( jpmTrayMenu );
        SystemTray.getSystemTray().add( tray );

        xrcMenu.getSwingComponent().setVisible( openMainMenuOnStart );
        if( !openMainMenuOnStart &&
            msgType == MpAppConfig.SysTrayMsgType.VERBOSE )
        {
          JOptionPane.showMessageDialog(
            null,
            MpBizBundle.getInstance().getBundleMessage(
              MpBizBundle.MSG_APP_ATTACHED_TO_SYSTRAY ) );
        }
      }
      else
      {
        xrcMenu.getSwingComponent().setVisible( true );
      }
    }
    catch( Exception e )
    {
      logger.error( e.getMessage(), e );
      throw new MpBizException( e.getMessage() );
    }
  }

  ////////////////////////////////////////////////////////////
  public String getDbBundleMessage( String key )
    throws MpToolsException
  {
    return DbBundle.getInstance().getBundleMessage( key );
  }

  ////////////////////////////////////////////////////////////
  public String getToolsBundleMessage( String key )
  {
    return LocaleBundle.getInstance().getBundleMessage( key );
  }

  ////////////////////////////////////////////////////////////
  public String getLayoutFilename( String file )
  throws FileNotFoundException, IOException
  {
    return XgmFactory.getInstance().getLayoutFilename( file );
  }

  ////////////////////////////////////////////////////////////
  public String readLayout( String file )
    throws FileNotFoundException, IOException, MpToolsException, XgmException
  {
    return XgmFactory.getInstance().readLayout( file );
  }

  ////////////////////////////////////////////////////////////
  @Override
  public String getDbInfoMessage()
  {
    Database db = null;
    try
    {
      db = MpAppContext.getInstance().getDatabase();
    } catch (SQLException ex)
    {
      ex.printStackTrace();
    }
    return
      "Database: " + db.getDatabaseProductName() +
      " - " + db.getDatabaseProductVersion() + "\n" +
      "URL: " + db.getDbConnection().getDriverUrl();
  }

  ////////////////////////////////////////////////////////////
  public String getDbURL()
  {
    Database db = null;
    try
    {
      db = MpAppContext.getInstance().getDatabase();
    } catch (SQLException ex)
    {
      ex.printStackTrace();
    }
    return db.getDbConnection().getDriverUrl();
  }

  ////////////////////////////////////////////////////////////
  private class MpBizWindowListener
  extends WindowAdapter
  {
    private String username = null;

    ////////////////////////////////////////////////////////////
    public MpBizWindowListener( String user )
    {
      username = user;
    }

    ////////////////////////////////////////////////////////////
    private void close()
    {
      boolean useSysTray = MpAppConfig.getInstance().getUseSysTray();
      if( jpmTrayMenu != null &&
          useSysTray && SystemTray.isSupported() )
      {
        xrcMenu.setVisible( false );
        XgmRootContainerInstance xrciTop =
          XgmRootContainerInstance.getTopmostContainer();
        for( XmlTreeNodeable x : xrciTop.getChildren() )
        {
          XgmRootContainerInstance.setVisible( x, false );
        }
        if( MpAppConfig.getInstance().getSysTrayMsgType() ==
          MpAppConfig.SysTrayMsgType.VERBOSE )
        {
          JOptionPane.showMessageDialog(
            null,
            MpBizBundle.getInstance().getBundleMessage(
              MpBizBundle.MSG_APP_ATTACHED_TO_SYSTRAY ) );
        }
      }
      else
      {
        closeDB();
        System.out.println(
          "<MpBiz.MpBizWindowListener.windowClosing>\n  user:" +
          username + " LOGGED OUT" +
          "\n  time: " + new java.util.Date() );
        System.exit( 0 );
      }
    }

    ////////////////////////////////////////////////////////////
    @Override
    public void windowClosing( WindowEvent e )
    {
      close();
    }

    ////////////////////////////////////////////////////////////
    @Override
    public void windowClosed( WindowEvent e )
    {
      close();
    }

  }

  ////////////////////////////////////////////////////////////
  @Override
  public String getHelpFile()
  {
    return MpBizAppContext.getHelpFile();
  }

  ////////////////////////////////////////////////////////////
  public static void main( String[] args )
  {
    System.out.println( "Staring MpBiz..." );
    MpBiz mpBiz = null;
    MpLog4jFactory.configure();
//    if( args.length > 0 )
//    {
//      for( int f = 0; f < args.length; f++ )
//      {
//        if( args[f].equals( "-l" ) )
//        {
//          System.out.println( "Staring Logger..." );
//          MpBizApp.setLogFile( args[++f] );
//        }
//      }
//    }
    try
    {
      System.out.println( "Staring app..." );
      mpBiz = new MpBiz();
      mpBiz.init( args );
    }
    catch( Exception e )
    {
      logger.error( e.getMessage(), e );
      JOptionPane.showMessageDialog( null, e.getMessage() );
      System.exit( -1 );
    }
  }


}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.