Package com.rakaizsys.eims

Source Code of com.rakaizsys.eims.EIMSAppFrame

package com.rakaizsys.eims;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.sql.SQLException;
import java.util.List;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.border.BevelBorder;

import org.jdesktop.swingx.JXHyperlink;
import org.jdesktop.swingx.JXTaskPane;
import org.jdesktop.swingx.JXTaskPaneContainer;
import org.jdesktop.swingx.JXTitledPanel;
import org.pushingpixels.substance.api.skin.SubstanceCremeCoffeeLookAndFeel;

import com.rakaizsys.eims.view.DesktopView;
import com.rakaizsys.eims.view.TabbedView;
import com.rakaizsys.eims.view.ViewPanel;
import com.rakaizsys.eims.view.customer.CustomerList;
import com.rakaizsys.eims.view.customer.service.CustomerServicesList;
import com.rakaizsys.eims.view.finance.VouchersList;
import com.rakaizsys.eims.view.finance.bank.BankAccountsList;
import com.rakaizsys.eims.view.finance.bank.BanksList;
import com.rakaizsys.eims.view.hr.emp.EmployeeForm;
import com.rakaizsys.eims.view.hr.emp.EmployeeList;
import com.rakaizsys.eims.view.hr.emp.payment.EmployeePaymentsList;
import com.rakaizsys.eims.view.hr.profession.ProfessionList;
import com.rakaizsys.eims.view.hr.sponsor.SponsorList;
import com.rakaizsys.eims.view.items.ItemsList;
import com.rakaizsys.eims.view.service.ServiceList;
import com.rakaizsys.eims.view.templates.DBObjectList;
import com.rakaizsys.eims.view.util.ViewUtil;

public class EIMSAppFrame {

  private JFrame frmEstablishmentInformationManagement;
  private JTextField txtUsername;
  private JTextField txtLoginDate;
  private ViewPanel viewPanel;
  private JMenuItem mntmProfessions;

  private static EIMSAppFrame appFrame;
 
  private JMenuItem mntmVacationTypes;
  private JPanel viewOptPanel;
  private JMenu mnCustomer;
  private JMenuItem mntmCustomers;
  private JMenuItem mntmCustomerTypes;
  private JMenu mnServices;
  private JMenuItem mntmServices;
  private JMenuItem mntmCustomerService;
  private JLabel lblStatus;
  private JMenuItem mntmBankAccounts;
  private JMenuItem mntmItemTypes;
 

  /**
   * Launch the application.
   */
  public static void main(String[] args) {
 
   
   
   
    EventQueue.invokeLater(new Runnable() {
      public void run() {
        try {

          final EIMSAppFrame window = getInstance();
          window.doMntmConnectActionPerformed(null);
          window.doBtnTabViewActionPerformed(null);
          window.frmEstablishmentInformationManagement.setVisible(true);
         
          window.frmEstablishmentInformationManagement.addWindowListener(new WindowAdapter() {

              @Override
              public void windowClosing(
                WindowEvent e) {
                window.doMntmDisconnectActionPerformed(null);
              }
             
          });
          Class.forName("com.rakaizsys.eims.db.SQLMapHolder");
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    });
  }
 
 
  public static EIMSAppFrame getInstance() {
    if (appFrame == null)
      appFrame = new EIMSAppFrame();
    return appFrame;
  }

  public JFrame getFrame() {
    return frmEstablishmentInformationManagement;
  }

  /**
   * Create the application.
   *
   * @wbp.parser.entryPoint
   */
  public EIMSAppFrame() {
    initialize();
  }

  /**
   * Initialize the contents of the frame.
   */
  private void initialize() {
    frmEstablishmentInformationManagement = new JFrame();
    this.frmEstablishmentInformationManagement.setTitle("Establishment Information Management System");
    this.frmEstablishmentInformationManagement.setName("Establishment Information Management System");
    frmEstablishmentInformationManagement.setBounds(100, 100, 587, 641);
    frmEstablishmentInformationManagement.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final JMenuBar menuBar = new JMenuBar();
    menuBar.setName("menuBar");
    this.frmEstablishmentInformationManagement.setJMenuBar(menuBar);

    final JMenu mnFile = new JMenu("File");
    mnFile.setName("mnFile");
    menuBar.add(mnFile);
   
    JMenuItem mntmConnect = new JMenuItem("Connect");
    mntmConnect.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        doMntmConnectActionPerformed(e);
      }
    });
    mnFile.add(mntmConnect);
   
    JMenuItem mntmDisconnect = new JMenuItem("Disconnect");
    mntmDisconnect.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        doMntmDisconnectActionPerformed(e);
      }
    });
    mnFile.add(mntmDisconnect);

    final JMenuItem mntmLogin = new JMenuItem("Login");
    mntmLogin.setName("mntmLogin");
    mnFile.add(mntmLogin);

    final JMenuItem mntmLogout = new JMenuItem("Logout");
    mntmLogout.setName("mntmLogout");
    mnFile.add(mntmLogout);
    mnFile.addSeparator();

    final JMenuItem mntmNew = new JMenuItem("New");
    mntmNew.setName("mntmNew");
    mnFile.add(mntmNew);

    final JMenuItem mntmSave = new JMenuItem("Save");
    mntmSave.setName("mntmSave");
    mnFile.add(mntmSave);
    mnFile.addSeparator();
    final JMenuItem mntmExit = new JMenuItem("Exit");
    mntmExit.setName("mntmExit");
    mnFile.add(mntmExit);

    final JMenu mnHR = new JMenu("Human Resources");
    menuBar.add(mnHR);

    final JMenuItem mntmEmployees = new JMenuItem("Employees");
    mntmEmployees.setName("mntmEmployees");
    mntmEmployees.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        doMntmEmployeesActionPerformed(e);
      }
    });
    mnHR.add(mntmEmployees);
    mnHR.add(getMntmProfessions());

    final JMenuItem mntmSponsors = new JMenuItem("Sponsors");
    mntmSponsors.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent arg0) {
        doMntmSponsorsActionPerformed(arg0);
      }
    });
    mntmSponsors.setName("mntmSponsors");
    mnHR.add(mntmSponsors);

    this.mntmVacationTypes = new JMenuItem("Vacation Types");
    this.mntmVacationTypes.addActionListener(new ActionListener() {
      public void actionPerformed(final ActionEvent arg0) {
        doMntmVacationTypesActionPerformed(arg0);
      }
    });
    this.mntmVacationTypes.setName("mntmVacationTypes");
    mnHR.add(this.mntmVacationTypes);
   
    JMenuItem mntmEmployeePayments = new JMenuItem("Employee Payments");
    mntmEmployeePayments.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        doMntmEmployeePaymentsActionPerformed(e);
      }
    });
    mnHR.add(mntmEmployeePayments);

    this.mnCustomer = new JMenu("Customer");
    this.mnCustomer.setName("mnCustomer");
    menuBar.add(this.mnCustomer);

    this.mntmCustomers = new JMenuItem("Customers");
    this.mntmCustomers.addActionListener(new ActionListener() {
      public void actionPerformed(final ActionEvent arg0) {
        doMntmCustomersActionPerformed(arg0);
      }
    });
    this.mntmCustomers.setName("mntmCustomers");
    this.mnCustomer.add(this.mntmCustomers);

    this.mntmCustomerTypes = new JMenuItem("Customer Types");
    this.mntmCustomerTypes.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        doMntmCustomerTypesActionPerformed(e);
      }
    });
    this.mntmCustomerTypes.setName("mntmCustomerTypes");
    this.mnCustomer.add(this.mntmCustomerTypes);
   
    this.mntmCustomerService = new JMenuItem("Customer Service");
    this.mntmCustomerService.addActionListener(new ActionListener() {
      public void actionPerformed(final ActionEvent arg0) {
        doMntmCustomerServiceActionPerformed(arg0);
      }
    });
    this.mntmCustomerService.setName("mntmCustomerService");
    this.mnCustomer.add(this.mntmCustomerService);
   
    this.mnServices = new JMenu("Services");
    this.mnServices.setName("mnServices");
    menuBar.add(this.mnServices);
   
    this.mntmServices = new JMenuItem("Services");
    this.mntmServices.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        doMntmServicesActionPerformed(e);
      }
    });
    this.mntmServices.setName("mntmServices");
    this.mnServices.add(this.mntmServices);
   
    JMenu mnItems = new JMenu("Items");
    menuBar.add(mnItems);
   
    JMenuItem mntmItemsList = new JMenuItem("Items List");
    mntmItemsList.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent arg0) {
        doMntmItemsListActionPerformed(arg0);
      }
    });
    mnItems.add(mntmItemsList);
   
    this.mntmItemTypes = new JMenuItem("Item Types");
    this.mntmItemTypes.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        doMntmItemTypesActionPerformed(e);
      }
    });
    mnItems.add(this.mntmItemTypes);
   
    JMenu mnFinance = new JMenu("Finance");
    menuBar.add(mnFinance);
   
    JMenuItem mntmVoucher = new JMenuItem("Vouchers");
    mntmVoucher.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent arg0) {
        doMntmVoucherActionPerformed(arg0);
      }
    });
    mnFinance.add(mntmVoucher);
   
    JMenuItem mntmBanks = new JMenuItem("Banks");
    mntmBanks.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        doMntmBanksActionPerformed(e);
      }
    });
    mnFinance.add(mntmBanks);
   
    this.mntmBankAccounts = new JMenuItem("Bank Accounts");
    this.mntmBankAccounts.addActionListener(new ActionListener() {
      public void actionPerformed(final ActionEvent e) {
        doMntmBankAccountsActionPerformed(e);
      }
    });
    mnFinance.add(this.mntmBankAccounts);
   
    JMenuItem mntmBills = new JMenuItem("Bills");
    mnFinance.add(mntmBills);

    final JPanel statusPanel = new JPanel();
    statusPanel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null,
        null, null));
    this.frmEstablishmentInformationManagement.getContentPane().add(statusPanel, BorderLayout.SOUTH);
    GridBagLayout gbl_statusPanel = new GridBagLayout();
    gbl_statusPanel.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
    gbl_statusPanel.rowHeights = new int[] { 0, 0 };
    gbl_statusPanel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0,
        1.0, 0.0, Double.MIN_VALUE };
    gbl_statusPanel.rowWeights = new double[] { 1.0, Double.MIN_VALUE };
    statusPanel.setLayout(gbl_statusPanel);

    final JLabel lblUserName = new JLabel("User Name:");
    GridBagConstraints gbc_lblUserName = new GridBagConstraints();
    gbc_lblUserName.insets = new Insets(2, 2, 2, 5);
    gbc_lblUserName.anchor = GridBagConstraints.EAST;
    gbc_lblUserName.gridx = 0;
    gbc_lblUserName.gridy = 0;
    statusPanel.add(lblUserName, gbc_lblUserName);

    this.txtUsername = new JTextField();
    this.txtUsername.setEditable(false);
    GridBagConstraints gbc_txtUsername = new GridBagConstraints();
    gbc_txtUsername.insets = new Insets(2, 2, 2, 5);
    gbc_txtUsername.anchor = GridBagConstraints.LINE_START;
    gbc_txtUsername.gridx = 1;
    gbc_txtUsername.gridy = 0;
    statusPanel.add(this.txtUsername, gbc_txtUsername);
    this.txtUsername.setColumns(10);

    final JLabel lblLoginDate = new JLabel("Login Date");
    GridBagConstraints gbc_lblLoginDate = new GridBagConstraints();
    gbc_lblLoginDate.insets = new Insets(2, 2, 2, 5);
    gbc_lblLoginDate.anchor = GridBagConstraints.EAST;
    gbc_lblLoginDate.gridx = 2;
    gbc_lblLoginDate.gridy = 0;
    statusPanel.add(lblLoginDate, gbc_lblLoginDate);

    this.txtLoginDate = new JTextField();
    this.txtLoginDate.setEditable(false);
    GridBagConstraints gbc_txtLoginDate = new GridBagConstraints();
    gbc_txtLoginDate.insets = new Insets(2, 2, 2, 5);
    gbc_txtLoginDate.fill = GridBagConstraints.HORIZONTAL;
    gbc_txtLoginDate.gridx = 3;
    gbc_txtLoginDate.gridy = 0;
    statusPanel.add(this.txtLoginDate, gbc_txtLoginDate);
    this.txtLoginDate.setColumns(10);
   
    this.lblStatus = new JLabel("");
    GridBagConstraints gbc_lblStatus = new GridBagConstraints();
    gbc_lblStatus.anchor = GridBagConstraints.LINE_END;
    gbc_lblStatus.insets = new Insets(0, 0, 0, 5);
    gbc_lblStatus.gridx = 5;
    gbc_lblStatus.gridy = 0;
    statusPanel.add(this.lblStatus, gbc_lblStatus);

    this.viewOptPanel = new JPanel();
    final FlowLayout flowLayout = (FlowLayout) this.viewOptPanel
        .getLayout();
    flowLayout.setAlignment(FlowLayout.TRAILING);
    flowLayout.setVgap(0);
    flowLayout.setHgap(0);
    this.viewOptPanel.setName("viewOptPanel");
    GridBagConstraints gbc_viewOptPanel = new GridBagConstraints();
    gbc_viewOptPanel.fill = GridBagConstraints.BOTH;
    gbc_viewOptPanel.gridx = 6;
    gbc_viewOptPanel.gridy = 0;
    statusPanel.add(this.viewOptPanel, gbc_viewOptPanel);

    final JButton btnDesktopView = new JButton("");
    this.viewOptPanel.add(btnDesktopView);
    btnDesktopView.setToolTipText("Desktop View");
    btnDesktopView.setIcon(new ImageIcon(EIMSAppFrame.class
        .getResource("/icons/16/application.png")));
    btnDesktopView.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        doBtnDesktopViewActionPerformed(e);
      }
    });

    final JButton btnTabView = new JButton("");
    btnTabView.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        doBtnTabViewActionPerformed(e);
      }
    });
    this.viewOptPanel.add(btnTabView);
    btnTabView.setToolTipText("Tab View");
    btnTabView.setIcon(new ImageIcon(EIMSAppFrame.class
        .getResource("/icons/16/structurepanetab.png")));
  }

  protected void doMntmEmployeesActionPerformed(ActionEvent e) {
    addView(new EmployeeList());

  }

  protected void doBtnTabViewActionPerformed(ActionEvent e) {
    List<JComponent> components = null;
    if (viewPanel != null) {
      components = viewPanel.getViews();
    }
    viewPanel = new TabbedView();
    if (components != null) {
      for (Component component : components)
        viewPanel.addView((JComponent) component);
    }
    this.frmEstablishmentInformationManagement.getContentPane().add(viewPanel);
    this.frmEstablishmentInformationManagement.validate();
  }

  protected void doBtnDesktopViewActionPerformed(ActionEvent e) {
    List<JComponent> components = null;
    if (viewPanel != null) {
      components = viewPanel.getViews();
      frmEstablishmentInformationManagement.getContentPane().remove(viewPanel);
    }
    viewPanel = new DesktopView();
    if (components != null) {
      for (Component component : components)
        viewPanel.addView((JComponent) component);
    }
    this.frmEstablishmentInformationManagement.getContentPane().add(viewPanel);
    this.frmEstablishmentInformationManagement.validate();
  }

  protected JMenuItem getMntmProfessions() {
    if (mntmProfessions == null) {
      mntmProfessions = new JMenuItem("Professions");
      mntmProfessions.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          doMntmProfessionsActionPerformed(e);
        }
      });
      mntmProfessions.setName("mntmProfessions");
    }
    return mntmProfessions;
  }

  protected void doMntmProfessionsActionPerformed(ActionEvent e) {
    addView(new ProfessionList());
  }

  protected void doMntmSponsorsActionPerformed(ActionEvent e) {
    addView(new SponsorList());
  }

  protected void doMntmVacationTypesActionPerformed(final ActionEvent e) {
    addView(new DBObjectList("EIMS.VAC_TYPES"));
  }

  public void addView(JComponent component) {
    this.viewPanel.addView(component);
  }

  protected void doMntmCustomersActionPerformed(final ActionEvent e) {
    addView(new CustomerList());
  }

  protected void doMntmCustomerTypesActionPerformed(ActionEvent e) {
    addView(new DBObjectList("EIMS.CUSTOMER_TYPES"));
  }
  protected void doMntmServicesActionPerformed(ActionEvent e) {
    addView(new ServiceList());
  }
  protected void doMntmCustomerServiceActionPerformed(final ActionEvent e) {
      addView(new CustomerServicesList());
  }
  protected void doMntmItemsListActionPerformed(ActionEvent e) {
    addView(new ItemsList());
  }
  protected void doMntmVoucherActionPerformed(ActionEvent e) {
    addView(new VouchersList());
  }
  protected void doMntmBanksActionPerformed(ActionEvent e) {
    addView(new BanksList());
  }
  protected void doMntmBankAccountsActionPerformed(final ActionEvent e) {
      addView(new BankAccountsList());
  }
  protected void doMntmEmployeePaymentsActionPerformed(ActionEvent e) {
    addView(new EmployeePaymentsList());
  }
  protected void doHprlnkNewEmployeeActionPerformed(ActionEvent e) {
    addView(new EmployeeForm());
  }
  protected void doMntmItemTypesActionPerformed(ActionEvent e) {
    addView(new DBObjectList("EIMS.ITEM_TYPES"));
  }
  protected void doMntmConnectActionPerformed(ActionEvent e) {
    try {
      EIMSDBServer.starDBServer();
    } catch (SQLException ex) {
      ViewUtil.showErrorMessage("Error: Cannot connect to database", ex);
    }
  }
  protected void doMntmDisconnectActionPerformed(ActionEvent e) {
    try {
      EIMSDBServer.stopDBServer();
    } catch (SQLException ex) {
      ViewUtil.showErrorMessage("Error: Cannot connect to database", ex);
    }
  }
}
TOP

Related Classes of com.rakaizsys.eims.EIMSAppFrame

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.