Package nu.lazy8.ledger.jdbc

Examples of nu.lazy8.ledger.jdbc.DataComboBox


    accountEditor = new IntegerField("Account", "transaction", view);
    column.setCellEditor(new DefaultCellEditor(accountEditor));
    column.setPreferredWidth(accountIntFieldSize);
    column.setCellRenderer(numberRenderer);

    accountCombo = new DataComboBox(new JdbcTable("APP.Account", 2, view), true, "Account", "transaction", view);
    accountCombo.loadComboBox("AccDesc", "Account", (Integer) cc.comboBox.getSelectedItemsKey());
    column = tableView.getColumn(dataModel.getColumnName(COL_ACCOUNTNAME));
    column.setCellEditor(new DefaultCellEditor(accountCombo));
    column.setPreferredWidth(accountNameFieldSize);

    column = tableView.getColumn(dataModel.getColumnName(COL_CUSTOMERNUM));
    customerEditor = new IntegerField("Customer", "transaction", view);
    column.setCellEditor(new DefaultCellEditor(customerEditor));
    column.setPreferredWidth(accountIntFieldSize);
    column.setCellRenderer(numberRenderer);

    customerCombo = new DataComboBox(new JdbcTable(
        "SELECT CompId,CustId,CustName FROM Customer2 WHERE CompId=? ORDER BY CustName"
        , view, new int[]{Types.INTEGER}), true, "Customer", "transaction", view);
    customerCombo.loadComboBox("CustName", "CustId", (Integer) cc.comboBox.getSelectedItemsKey());
    column = tableView.getColumn(dataModel.getColumnName(COL_CUSTOMERNAME));
    column.setPreferredWidth(accountNameFieldSize);
    column.setCellEditor(new DefaultCellEditor(customerCombo));

    column = tableView.getColumn(dataModel.getColumnName(COL_DEBIT));
    column.setPreferredWidth(accountTotalSize);
    debitEditor = new DoubleField("DebitAccountTotal", "transaction", view);
    column.setCellEditor(new DefaultCellEditor(debitEditor));
    column.setCellRenderer(numberRenderer);

    column = tableView.getColumn(dataModel.getColumnName(COL_CREDIT));
    column.setPreferredWidth(accountTotalSize);
    creditEditor = new DoubleField("CreditAccountTotal", "transaction", view);
    column.setCellEditor(new DefaultCellEditor(creditEditor));
    column.setCellRenderer(numberRenderer);

    tableView.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);

    tableView.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    ListSelectionModel colSM =
        tableView.getColumnModel().getSelectionModel();
    colSM.addListSelectionListener(
      new ListSelectionListener() {
        //{{{ +valueChanged(ListSelectionEvent) : void
        public void valueChanged(ListSelectionEvent e) {
          //Ignore extra messages.
          //if(true)return;
          if (e.getValueIsAdjusting()) {
            return;
          }
          if ((Calendar.getInstance().getTime().getTime() - lastTimeHere) < 100) {
            return;
          }
          lastTimeHere = Calendar.getInstance().getTime().getTime();
          ListSelectionModel lsm = (ListSelectionModel) e.getSource();
          if (!lsm.isSelectionEmpty()) {
            switch (lsm.getMinSelectionIndex()) {
              case COL_TEXT:
                textCommentsEditor.showHelp();
                break;
              case COL_ACCOUNTNUM:
                accountEditor.showHelp();
                break;
              case COL_ACCOUNTNAME:
                accountEditor.showHelp();
                break;
              case COL_CUSTOMERNUM:
                customerEditor.showHelp();
                break;
              case COL_CUSTOMERNAME:
                customerEditor.showHelp();
                break;
              case COL_DEBIT:
                debitEditor.showHelp();
                break;
              case COL_CREDIT:
                creditEditor.showHelp();
                break;
            }
          }
        }//}}}
      });

    KeyStroke aKeyStroke = KeyStroke.getKeyStroke("ENTER");
    InputMap im = tableView.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    im.remove(aKeyStroke);
    im.getParent().remove(aKeyStroke);
    tableView.setInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, im);
    im = tableView.getInputMap(JComponent.WHEN_FOCUSED);
    im.remove(aKeyStroke);
    tableView.setInputMap(JComponent.WHEN_FOCUSED, im);
    im = tableView.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.remove(aKeyStroke);
    tableView.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, im);
    tableView.getInputMap(JComponent.WHEN_FOCUSED).put(aKeyStroke, "eatme");
    tableView.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(aKeyStroke, "eatme");
    Action anAction =
      new Action() {

        //{{{ +actionPerformed(ActionEvent) : void
        public void actionPerformed(ActionEvent e) {
          ListSelectionModel rsm = tableView.getSelectionModel();
          ListSelectionModel csm = tableView.getColumnModel().getSelectionModel();

          int selectedRow = rsm.getAnchorSelectionIndex();
          int selectedColumn = csm.getAnchorSelectionIndex();
          Log.log(Log.DEBUG, "actionPerformed", "actionPerformed="
               + selectedRow + ":" + selectedColumn + ":");

          switch (selectedColumn) {
            case COL_ACCOUNTNUM:
              if (SetupInfo.getBoolProperty(SetupInfo.INPUT_TABSTOP_CUSTOMER)) {
                tableView.editCellAt(selectedRow, COL_CUSTOMERNUM);
                csm.setSelectionInterval(COL_CUSTOMERNUM, COL_CUSTOMERNUM);
              } else {
                tableView.editCellAt(selectedRow, COL_DEBIT);
                csm.setSelectionInterval(COL_DEBIT, COL_DEBIT);
              }
              if (debitTotal.getDouble().compareTo(
                  creditTotal.getDouble()) == 0 &&
                  creditTotal.getDouble().doubleValue() != 0 &&
                  tableFields[selectedRow][COL_ACCOUNTNUM].length() == 0) {

                tableView.editCellAt(selectedRow, COL_ACCOUNTNUM);
                csm.setSelectionInterval(COL_ACCOUNTNUM, COL_ACCOUNTNUM);
                nextComp = dataMovementPane.butAdd;
                dataMovementPane.butAdd.requestFocus();
                //tableView.transferFocus();//this doesnt do anything anymore
              } else
                  if (tableFields[selectedRow][COL_ACCOUNTNAME].length() == 0) {
                tableView.editCellAt(selectedRow, COL_ACCOUNTNAME);
                csm.setSelectionInterval(COL_ACCOUNTNAME, COL_ACCOUNTNAME);
                //create a model dialog to get a name to the new account number
                JDialog dialog = new JDialog((Frame) GUIUtilities.getView(tableView), true);
                AccountForm af = new AccountForm(true, tableFields[selectedRow][COL_ACCOUNTNUM].toString(), dialog, view);
                dialog.getContentPane().setLayout(new GridLayout(1, 1));
                dialog.getContentPane().add(af);
                dialog.pack();
                dialog.setLocationRelativeTo(GUIUtilities.getView(tableView));
                //This next command will not return untill the dialog dissappears.
                dialog.setVisible(true);
                if (af.isOk()) {
                  accountCombo = new DataComboBox(new JdbcTable("APP.Account", 2, view), true, "Account", "transaction", view);
                  accountCombo.loadComboBox("AccDesc", "Account", (Integer) cc.comboBox.getSelectedItemsKey());
                  TableColumn column = tableView.getColumn(dataModel.getColumnName(COL_ACCOUNTNAME));
                  column.setCellEditor(new DefaultCellEditor(accountCombo));
                  AccountNumberChanged(af.accountNum(), selectedRow, COL_ACCOUNTNUM);
                  dataModel.fireTableCellUpdated(selectedRow, COL_ACCOUNTNUM);
                  if (SetupInfo.getBoolProperty(SetupInfo.INPUT_TABSTOP_CUSTOMER)) {
                    tableView.editCellAt(selectedRow, COL_CUSTOMERNUM);
                    csm.setSelectionInterval(COL_CUSTOMERNUM, COL_CUSTOMERNUM);
                  } else {
                    tableView.editCellAt(selectedRow, COL_DEBIT);
                    csm.setSelectionInterval(COL_DEBIT, COL_DEBIT);
                  }
                } else {
                  accountCombo.showPopup();
                }
              }

              break;
            case COL_CUSTOMERNUM:
              tableView.editCellAt(selectedRow, COL_DEBIT);
              csm.setSelectionInterval(COL_DEBIT, COL_DEBIT);
              if (tableFields[selectedRow][COL_CUSTOMERNAME].length() == 0) {
                tableView.editCellAt(selectedRow, COL_CUSTOMERNAME);
                csm.setSelectionInterval(COL_CUSTOMERNAME, COL_CUSTOMERNAME);
                //create a model dialog to get a name to the new customer number
                JDialog dialog = new JDialog((Frame) GUIUtilities.getView(tableView), true);
                CustomerForm cf = new CustomerForm(true, tableFields[selectedRow][COL_CUSTOMERNUM].toString(), dialog, view);
                dialog.getContentPane().setLayout(new BorderLayout());
                dialog.getContentPane().add(BorderLayout.CENTER, cf);
                dialog.pack();
                dialog.setLocationRelativeTo(GUIUtilities.getView(tableView));
                //This next command will not return untill the dialog dissappears.
                dialog.setVisible(true);
                if (cf.isOk()) {
                  customerCombo = new DataComboBox(new JdbcTable(
                      "SELECT CompId,CustId,CustName FROM Customer2 WHERE CompId=? ORDER BY CustName"
                      , view, new int[]{Types.INTEGER}), true, "Customer", "transaction", view);
                  customerCombo.loadComboBox("CustName", "CustId", (Integer) cc.comboBox.getSelectedItemsKey());
                  TableColumn column = tableView.getColumn(dataModel.getColumnName(COL_CUSTOMERNAME));
                  column.setCellEditor(new DefaultCellEditor(customerCombo));
View Full Code Here


  public void getSpecialGuiPane(JPanel jPanel1) {
    AddDateComponents(jPanel1, "allreports");
    JLabel label1 = new HelpedLabel(Translator.getTranslation("Account"),
        "Account", "allreports", view);
    jPanel1.add(label1);
    accountComboBox = new DataComboBox(new JdbcTable("APP.Account", 2, view), true,
        "Account", "allreports", view);
    accountComboBox.setMaximumSize(new Dimension(accountNameFieldSize, accountNameFieldSize));
    accountComboBox.setMinimumSize(new Dimension(accountNameFieldSize / 2, 1));
    jPanel1.add(accountComboBox);

    JLabel label2 = new HelpedLabel(Translator.getTranslation("Customer"),
        "Customer", "allreports", view);
    jPanel1.add(label2);
    customerComboBox = new DataComboBox(new JdbcTable(
        "SELECT CompId,CustId,CustName FROM Customer2 WHERE CompId=? ORDER BY CustName"
        , view, new int[]{Types.INTEGER}), true, "Customer", "allreports", view);
    customerComboBox.setMaximumSize(new Dimension(accountNameFieldSize, accountNameFieldSize));
    customerComboBox.setMinimumSize(new Dimension(accountNameFieldSize / 2, 1));
    customerComboBox.loadComboBox("CustName", "CustId", (Integer) cc.comboBox.getSelectedItemsKey());
View Full Code Here

    super.getSpecialGuiPane(jPanel1);

    JLabel label2 = new HelpedLabel(Translator.getTranslation("Customer"),
        "Customer", "allreports", view);
    jPanel1.add(label2);
    customerComboBox = new DataComboBox(new JdbcTable(
        "SELECT CompId,CustId,CustName FROM Customer2 WHERE CompId=? ORDER BY CustName"
        , view, new int[]{Types.INTEGER}), true, "Customer", "allreports", view);
    customerComboBox.setMaximumSize(new Dimension(accountNameFieldSize, accountNameFieldSize));
    customerComboBox.setMinimumSize(new Dimension(accountNameFieldSize / 2, 1));
    customerComboBox.loadComboBox("CustName", "CustId", (Integer) cc.comboBox.getSelectedItemsKey());
View Full Code Here

      getContentPane().add(centerPanel, BorderLayout.CENTER);
 
      HelpedLabel label1 = new HelpedLabel(Translator.getTranslation("Company"), "company", helpFile, view);
      centerPanel.add(label1);
 
      comboBox = new DataComboBox(new JdbcTable("Company", 1, view), false, "company", helpFile, view);
      comboBox.setMaximumSize(new Dimension(accountNameFieldSize, accountNameFieldSize));
      comboBox.setMinimumSize(new Dimension(accountNameFieldSize / 2, 1));
      centerPanel.add(comboBox);
 
      comboBox.loadComboBox("Name", "CompId", new Integer(0));
View Full Code Here

   * @param  useCustomer  Description of the Parameter
   */
  public AccountPeriodTable(JFrame view, int CompId, java.util.Date periodStart,
      java.util.Date periodStop, int periodType, int numPeriods, boolean useCustomer) {
//Log.log(Log.DEBUG,this,"AccountPeriodTable="+periodType + ";"+periodStart + ";" +periodStop);
    DataConnection dc = DataConnection.getInstance(view);
    if (dc == null || !dc.bIsConnectionMade) {
      return;
    }
    Calendar cPeriodStart = Calendar.getInstance();
    cPeriodStart.setTime(periodStart);
    String periodDescription = "";
    Calendar selectStartDate = Calendar.getInstance();
    Calendar selectStopDate = Calendar.getInstance();
    SimpleDateFormat sd;

    if (periodType == PERIOD_ALL || periodType == PERIOD_GIVEN) {
      numPeriods = 1;
    }

    for (int i = 0; i < numPeriods; i++) {
      selectStartDate.setTime(periodStart);
      selectStopDate.setTime(periodStart);
      switch (periodType) {
        case PERIOD_DAY:
          selectStartDate.add(Calendar.DATE, i);
          selectStopDate.add(Calendar.DATE, i);
          periodDescription = DateField.ConvertDateToLocalizedString(selectStartDate.getTime());
          break;
        case PERIOD_WEEK:
          selectStartDate.add(Calendar.DATE, i * 7);
          selectStopDate.add(Calendar.DATE, ((i + 1) * 7) - 1);
          periodDescription = DateField.ConvertDateToLocalizedString(selectStartDate.getTime());
          break;
        case PERIOD_BIWEEK:
          selectStartDate.add(Calendar.DATE, i * 14);
          selectStopDate.add(Calendar.DATE, ((i + 1) * 14) - 1);
          periodDescription = DateField.ConvertDateToLocalizedString(selectStartDate.getTime());
          break;
        case PERIOD_MONTH:
          selectStartDate.add(Calendar.MONTH, i);
          selectStopDate.add(Calendar.MONTH, i + 1);
          selectStopDate.add(Calendar.DATE, -1);
          sd = new SimpleDateFormat("yyyy.MMM");
          periodDescription = sd.format(selectStartDate.getTime());
          break;
        case PERIOD_BIMONTH:
          selectStartDate.add(Calendar.MONTH, i * 2);
          selectStopDate.add(Calendar.MONTH, (i * 2) + 2);
          selectStopDate.add(Calendar.DATE, -1);
          sd = new SimpleDateFormat("yyyy.MMM");
          periodDescription = sd.format(selectStartDate.getTime());
          break;
        case PERIOD_QUARTER:
          selectStartDate.add(Calendar.MONTH, i * 3);
          selectStopDate.add(Calendar.MONTH, (i * 3) + 3);
          selectStopDate.add(Calendar.DATE, -1);
          sd = new SimpleDateFormat("yyyy.MMM");
          periodDescription = sd.format(selectStartDate.getTime());
          break;
        case PERIOD_HALFYEAR:
          selectStartDate.add(Calendar.MONTH, i * 6);
          selectStopDate.add(Calendar.MONTH, (i * 6) + 6);
          selectStopDate.add(Calendar.DATE, -1);
          sd = new SimpleDateFormat("yyyy.MMM");
          periodDescription = sd.format(selectStartDate.getTime());
          break;
        case PERIOD_YEAR:
          selectStartDate.add(Calendar.YEAR, i);
          selectStopDate.add(Calendar.YEAR, i + 1);
          selectStopDate.add(Calendar.DATE, -1);
          sd = new SimpleDateFormat("yyyy");
          periodDescription = sd.format(selectStartDate.getTime());
          break;
        case PERIOD_ALL:
          java.sql.Date startDate = GetEarliestDate(CompId);
          selectStartDate.setTime(startDate);
          java.sql.Date stopDate = GetLatestDate(CompId);
          selectStopDate.setTime(stopDate);
          periodDescription = DateField.ConvertDateToLocalizedString(selectStartDate.getTime())
               + "<->" + DateField.ConvertDateToLocalizedString(selectStopDate.getTime());
          break;
        case PERIOD_GIVEN:
          selectStartDate.setTime(periodStart);
          selectStopDate.setTime(periodStop);
          periodDescription = DateField.ConvertDateToLocalizedString(selectStartDate.getTime())
               + "<->" + DateField.ConvertDateToLocalizedString(selectStopDate.getTime());
          break;
      }
      try {
        java.sql.Date start = new java.sql.Date(selectStartDate.getTime().getTime());
        java.sql.Date stop = new java.sql.Date(selectStopDate.getTime().getTime());

        PreparedStatement st = dc.con.prepareStatement(dc.filterSQL(getSelectStatement(CompId, useCustomer)));
        st.setDate(1, start);
        st.setDate(2, stop);
        ResultSet rs = st.executeQuery();

        int numRows = 0;
View Full Code Here

   */
  public final static java.sql.Date GetEarliestDate(int CompId) {
    java.sql.Date returnDate =
        new java.sql.Date(Calendar.getInstance().getTime().getTime());
    try {
      DataConnection dc = DataConnection.getInstance(null);
      if (dc == null || !dc.bIsConnectionMade) {
        return new java.sql.Date(Calendar.getInstance().getTime().getTime());
      }
      Statement st = dc.con.createStatement();
      ResultSet rss = st.executeQuery(dc.filterSQL("SELECT MIN(Activity2.InvDate) FROM Activity2 WHERE CompId=" + CompId));
      if (rss.next()) {
        returnDate = rss.getDate(1);
      }
      rss.close();
    } catch (Exception e) {}
View Full Code Here

   */
  public final static java.sql.Date GetLatestDate(int CompId) {
    java.sql.Date returnDate =
        new java.sql.Date(Calendar.getInstance().getTime().getTime());
    try {
      DataConnection dc = DataConnection.getInstance(null);
      if (dc == null || !dc.bIsConnectionMade) {
        return new java.sql.Date(Calendar.getInstance().getTime().getTime());
      }
      Statement st = dc.con.createStatement();
      ResultSet rss = st.executeQuery(dc.filterSQL("SELECT MAX(Activity2.InvDate) FROM Activity2 WHERE CompId=" + CompId));
      if (rss.next()) {
        returnDate = rss.getDate(1);
      }
      rss.close();
    } catch (Exception e) {}
View Full Code Here

   *
   * @return    Description of the Return Value
   */
  public boolean IsDeleteOK() {
    try {
      DataConnection dc = DataConnection.getInstance(view);
      if (dc == null || !dc.bIsConnectionMade) {
        return false;
      }
      PreparedStatement stmt = dc.con.prepareStatement(dc.filterSQL(
          "SELECT * FROM APP.Account where CompId=? and IsAsset=?"));
      stmt.setInt(1, ((Integer) cc.comboBox.getSelectedItemsKey()).intValue());
      stmt.setInt(2, textField1.getInteger().intValue());
      ResultSet rs = stmt.executeQuery();
      if (rs.next()) {
View Full Code Here

   * @param  viewStatic        Description of the Parameter
   * @param  deleteCompanyDef  Description of the Parameter
   */
  public static void RemoveCompanyFromDatabase(int companyId, JFrame viewStatic, boolean deleteCompanyDef) {
    try {
      DataConnection dcc = DataConnection.getInstance(viewStatic);
      if (dcc == null || !dcc.bIsConnectionMade) {
        return;
      }
      Statement st = dcc.con.createStatement();
      st.executeUpdate(dcc.filterSQL("DELETE FROM Activity2 WHERE CompId=" + companyId));
      st = dcc.con.createStatement();
      st.executeUpdate(dcc.filterSQL("DELETE FROM Amount WHERE CompId=" + companyId));
      st = dcc.con.createStatement();
      st.executeUpdate(dcc.filterSQL("DELETE FROM APP.Account WHERE CompId=" + companyId));
      st = dcc.con.createStatement();
      st.executeUpdate(dcc.filterSQL("DELETE FROM Customer2 WHERE CompId=" + companyId));
      st = dcc.con.createStatement();
      st.executeUpdate(dcc.filterSQL("DELETE FROM UniqNum WHERE CompId=" + companyId));
      st = dcc.con.createStatement();
      st.executeUpdate(dcc.filterSQL("DELETE FROM AccountingPeriods WHERE CompId=" + companyId));
      st = dcc.con.createStatement();
      st.executeUpdate(dcc.filterSQL("DELETE FROM AccountType WHERE CompId=" + companyId));
      if (deleteCompanyDef) {
        st = dcc.con.createStatement();
        st.executeUpdate(dcc.filterSQL("DELETE FROM Company WHERE CompId=" + companyId));
      }
      EditBus.send(new CompanyListChanged(null, "no parameters"));
    } catch (Exception e) {
      Log.log(Log.DEBUG, null, "Error in RemoveCompanyFromDatabase= " + e);
    }
View Full Code Here

  //{{{ +showFirstScreen() : void
  /**
   *  Description of the Method
   */
  public void showFirstScreen() {
    DataConnection dc = DataConnection.getInstance(frameParent);
    if (dc == null || !dc.bIsConnectionMade) {
      setVisible(false);
      return;
    }

View Full Code Here

TOP

Related Classes of nu.lazy8.ledger.jdbc.DataComboBox

Copyright © 2018 www.massapicom. 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.