Exemple #1
0
 /** Load data. */
 private ArrayList loadData() {
   try {
     ArrayList vos = new ArrayList();
     BufferedReader br =
         new BufferedReader(new InputStreamReader(new FileInputStream("orders.txt")));
     String line = null;
     SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
     OrdersVO vo = null;
     String[] t = null;
     while ((line = br.readLine()) != null) {
       t = line.split(";");
       vo = new OrdersVO();
       vos.add(vo);
       vo.setOrderDate(sdf.parse(t[0]));
       vo.setCategory(t[1]);
       vo.setSubCategory(t[2]);
       vo.setCountry(t[3]);
       vo.setZone(t[4]);
       vo.setAgent(t[5]);
       vo.setItem(t[6]);
       vo.setSellQty(new BigDecimal(t[7]));
       vo.setSellAmount(new BigDecimal(t[8]));
     }
     br.close();
     return vos;
   } catch (Exception ex) {
     ex.printStackTrace();
     return new ArrayList();
   }
 }
Exemple #2
0
  public NavigatorBar() {
    try {
      jbInit();
      controlPageNr.setColumns(3);
      controlPageNr.setValue(new Integer(1));
      controlPageNr.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              if (controlPageNr.getDouble() == null) controlPageNr.setValue(new Integer(1));
              if (!checkValidPage()) return;
              currentPageNr = controlPageNr.getDouble().intValue();
              gotoPage();
            }
          });
      controlPageNr.addFocusListener(
          new FocusAdapter() {

            public void focusGained(FocusEvent e) {
              if (controlPageNr.getDouble() == null) controlPageNr.setValue(new Integer(1));
              currentPageNr = controlPageNr.getDouble().intValue();
            }

            public void focusLost(FocusEvent e) {
              if (controlPageNr.getDouble() == null) controlPageNr.setValue(new Integer(1));
              if (!checkValidPage()) return;
              int lastValue = currentPageNr;
              currentPageNr = controlPageNr.getDouble().intValue();
              if (lastValue != currentPageNr) gotoPage();
            }
          });

      firstButton.setToolTipText(
          ClientSettings.getInstance()
              .getResources()
              .getResource("Load the first block of records"));
      firstButton.setPreferredSize(new Dimension(32, 32));
      prevPgButton.setToolTipText(
          ClientSettings.getInstance()
              .getResources()
              .getResource("Load the previous block of records"));
      prevPgButton.setPreferredSize(new Dimension(32, 32));
      prevButton.setToolTipText(
          ClientSettings.getInstance()
              .getResources()
              .getResource("Select the previous row in grid"));
      prevButton.setPreferredSize(new Dimension(32, 32));
      nextButton.setToolTipText(
          ClientSettings.getInstance().getResources().getResource("Select the next row in grid"));
      nextButton.setPreferredSize(new Dimension(32, 32));
      nextPgButton.setToolTipText(
          ClientSettings.getInstance()
              .getResources()
              .getResource("Load the next block of records"));
      nextPgButton.setPreferredSize(new Dimension(32, 32));
      lastButton.setToolTipText(
          ClientSettings.getInstance()
              .getResources()
              .getResource("Load the last block of records"));
      lastButton.setPreferredSize(new Dimension(32, 32));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public SupplierDetailFrame(final SupplierController controller) {
    try {
      jbInit();
      setSize(750, 550);
      setMinimumSize(new Dimension(750, 550));

      supplierPanel.setFormController(controller);
      supplierPanel.setInsertButton(insertButton);
      supplierPanel.setEditButton(editButton);
      supplierPanel.setReloadButton(reloadButton);
      supplierPanel.setDeleteButton(deleteButton);
      supplierPanel.setSaveButton(saveButton);
      supplierPanel.setFunctionId("PUR01");
      organizationPanel.setFunctionId("PUR01");

      // link the parent grid to the current Form...
      HashSet pk = new HashSet();
      pk.add("companyCodeSys01REG04");
      pk.add("progressiveREG04");
      supplierPanel.linkGrid(
          controller.getGridFrame().getGrid(), pk, true, true, true, navigatorBar);

      // banks lookup...
      bankDataLocator.setGridMethodName("loadBanks");
      bankDataLocator.setValidationMethodName("validateBankCode");
      controlBank.setLookupController(bankController);
      controlBank.setControllerMethodName("getBanksList");
      bankController.setLookupDataLocator(bankDataLocator);
      bankController.setFrameTitle("banks");
      bankController.setLookupValueObjectClassName("org.jallinone.registers.bank.java.BankVO");
      bankController.addLookup2ParentLink("bankCodeREG12", "bankCodeReg12PUR01");
      bankController.addLookup2ParentLink("descriptionREG12", "descriptionREG12");
      bankController.setAllColumnVisible(false);
      bankController.setVisibleColumn("bankCodeREG12", true);
      bankController.setVisibleColumn("descriptionREG12", true);
      bankController.setPreferredWidthColumn("descriptionREG12", 200);
      new CustomizedColumns(new BigDecimal(232), bankController);

      // payments lookup...
      payDataLocator.setGridMethodName("loadPayments");
      payDataLocator.setValidationMethodName("validatePaymentCode");
      controlPayment.setLookupController(payController);
      controlPayment.setControllerMethodName("getPaymentsList");
      payController.setLookupDataLocator(payDataLocator);
      payController.setFrameTitle("payments");
      payController.setLookupValueObjectClassName(
          "org.jallinone.registers.payments.java.PaymentVO");
      payController.addLookup2ParentLink("paymentCodeREG10", "paymentCodeReg10PUR01");
      payController.addLookup2ParentLink("descriptionSYS10", "paymentDescriptionSYS10");
      payController.setAllColumnVisible(false);
      payController.setVisibleColumn("paymentCodeREG10", true);
      payController.setVisibleColumn("descriptionSYS10", true);
      payController.setPreferredWidthColumn("descriptionSYS10", 200);
      new CustomizedColumns(new BigDecimal(212), payController);
      payController.addLookupListener(
          new LookupListener() {

            public void beforeLookupAction(
                org.openswing.swing.message.receive.java.ValueObject parentVO) {
              DetailSupplierVO vo = (DetailSupplierVO) parentVO;
              payDataLocator
                  .getLookupValidationParameters()
                  .put(ApplicationConsts.COMPANY_CODE_SYS01, vo.getCompanyCodeSys01REG04());
              payDataLocator
                  .getLookupFrameParams()
                  .put(ApplicationConsts.COMPANY_CODE_SYS01, vo.getCompanyCodeSys01REG04());
            }

            public void codeChanged(
                org.openswing.swing.message.receive.java.ValueObject parentVO,
                Collection parentChangedAttributes) {}

            public void codeValidated(boolean validated) {}

            public void forceValidate() {}
          });

      // items lookup...
      itemDataLocator.setGridMethodName("loadItems");
      itemDataLocator.setValidationMethodName("validateItemCode");
      colItemCode.setLookupController(itemController);
      colItemCode.setControllerMethodName("getItemsList");
      itemController.setLookupDataLocator(itemDataLocator);
      itemController.setFrameTitle("items");
      itemController.setLookupValueObjectClassName("org.jallinone.items.java.GridItemVO");
      itemController.addLookup2ParentLink("companyCodeSys01ITM01", "companyCodeSys01PUR02");
      itemController.addLookup2ParentLink("itemCodeITM01", "itemCodeItm01PUR02");
      itemController.addLookup2ParentLink("descriptionSYS10", "descriptionSYS10");
      itemController.setAllColumnVisible(false);
      itemController.setVisibleColumn("itemCodeITM01", true);
      itemController.setVisibleColumn("descriptionSYS10", true);
      itemController.setPreferredWidthColumn("descriptionSYS10", 200);
      new CustomizedColumns(ApplicationConsts.ID_ITEMS_GRID, itemController);
      itemController.addLookupListener(
          new LookupListener() {

            public void codeValidated(boolean validated) {}

            public void codeChanged(ValueObject parentVO, Collection parentChangedAttributes) {
              GridItemVO vo = (GridItemVO) itemController.getLookupVO();
              if (vo.getItemCodeITM01() != null) {
                SupplierItemVO supplierVO = (SupplierItemVO) parentVO;
                supplierVO.setSupplierItemCodePUR02(vo.getItemCodeITM01());
              }
            }

            public void beforeLookupAction(ValueObject parentVO) {}

            public void forceValidate() {}
          });

      // purchase um lookup...
      umDataLocator.setGridMethodName("loadMeasures");
      umDataLocator.setValidationMethodName("validateMeasureCode");
      colUmCode.setLookupController(umController);
      colUmCode.setControllerMethodName("getMeasureUnitsList");
      umController.setLookupDataLocator(umDataLocator);
      umController.setFrameTitle("measures");
      umController.setLookupValueObjectClassName("org.jallinone.registers.measure.java.MeasureVO");
      umController.addLookup2ParentLink("umCodeREG02", "umCodeReg02PUR02");
      umController.addLookup2ParentLink("decimalsREG02", "decimalsREG02");
      umController.setAllColumnVisible(false);
      umController.setVisibleColumn("umCodeREG02", true);
      umController.setVisibleColumn("decimalsREG02", true);
      new CustomizedColumns(ApplicationConsts.ID_UM_GRID, umController);
      umController.addLookupListener(
          new LookupListener() {

            public void codeValidated(boolean validated) {}

            public void codeChanged(ValueObject parentVO, Collection parentChangedAttributes) {
              MeasureVO vo = (MeasureVO) umController.getLookupVO();
              if (vo.getUmCodeREG02() != null) {
                colMinQty.setDecimals(vo.getDecimalsREG02().intValue());
                colMultipleQty.setDecimals(vo.getDecimalsREG02().intValue());
                SupplierItemVO supplierVO = (SupplierItemVO) parentVO;
                if (supplierVO.getMinPurchaseQtyPUR02() != null)
                  supplierVO.setMinPurchaseQtyPUR02(
                      supplierVO
                          .getMinPurchaseQtyPUR02()
                          .setScale(vo.getDecimalsREG02().intValue(), BigDecimal.ROUND_HALF_UP));
                if (supplierVO.getMultipleQtyPUR02() != null)
                  supplierVO.setMultipleQtyPUR02(
                      supplierVO
                          .getMultipleQtyPUR02()
                          .setScale(vo.getDecimalsREG02().intValue(), BigDecimal.ROUND_HALF_UP));
              }
            }

            public void beforeLookupAction(ValueObject parentVO) {}

            public void forceValidate() {}
          });

      itemsGrid.setController(new SupplierItemsController(this));
      itemsGrid.setGridDataLocator(itemsGridDataLocator);
      itemsGridDataLocator.setServerMethodName("loadSupplierItems");

      treePanel.addHierarTreeListener(
          new HierarTreeListener() {

            public void loadDataCompleted(boolean error) {
              if (treePanel.getTree().getRowCount() > 0) treePanel.getTree().setSelectionRow(0);
              if (treePanel.getTree().getSelectionPath() != null)
                controller.leftClick(
                    (DefaultMutableTreeNode)
                        treePanel.getTree().getSelectionPath().getLastPathComponent());
            }
          });

      treePanel.setTreeController(controller);
      treePanel.setFunctionId("PUR01");

      init();

      itemsGrid.enableDrag(ApplicationConsts.ID_SUPPLIER_ITEMS_GRID.toString());

      // debit account code lookup...
      controlDebitsCode.setLookupController(debitController);
      controlDebitsCode.setControllerMethodName("getAccounts");
      debitController.setLookupDataLocator(debitDataLocator);
      debitDataLocator.setGridMethodName("loadAccounts");
      debitDataLocator.setValidationMethodName("validateAccountCode");
      debitController.setFrameTitle("accounts");
      debitController.setAllowTreeLeafSelectionOnly(false);
      debitController.setLookupValueObjectClassName(
          "org.jallinone.accounting.accounts.java.AccountVO");
      debitController.addLookup2ParentLink("accountCodeACC02", "debitAccountCodeAcc02PUR01");
      debitController.addLookup2ParentLink("descriptionSYS10", "debitAccountDescrPUR01");
      debitController.setFramePreferedSize(new Dimension(400, 400));
      debitController.setAllColumnVisible(false);
      debitController.setVisibleColumn("accountCodeACC02", true);
      debitController.setVisibleColumn("descriptionSYS10", true);
      debitController.setFilterableColumn("accountCodeACC02", true);
      debitController.setFilterableColumn("descriptionSYS10", true);
      debitController.setSortedColumn("accountCodeACC02", "ASC", 1);
      debitController.setSortableColumn("accountCodeACC02", true);
      debitController.setSortableColumn("descriptionSYS10", true);
      debitController.setPreferredWidthColumn("accountCodeACC02", 100);
      debitController.setPreferredWidthColumn("descriptionSYS10", 290);
      debitController.addLookupListener(
          new LookupListener() {

            public void codeValidated(boolean validated) {}

            public void codeChanged(ValueObject parentVO, Collection parentChangedAttributes) {}

            public void beforeLookupAction(ValueObject parentVO) {
              debitDataLocator
                  .getLookupFrameParams()
                  .put(ApplicationConsts.COMPANY_CODE_SYS01, controlCompanyCode.getValue());
              debitDataLocator
                  .getLookupValidationParameters()
                  .put(ApplicationConsts.COMPANY_CODE_SYS01, controlCompanyCode.getValue());
            }

            public void forceValidate() {}
          });

      // costs account code lookup...
      controlCostsCode.setLookupController(costsController);
      controlCostsCode.setControllerMethodName("getAccounts");
      costsController.setLookupDataLocator(costsDataLocator);
      costsDataLocator.setGridMethodName("loadAccounts");
      costsDataLocator.setValidationMethodName("validateAccountCode");
      costsController.setFrameTitle("accounts");
      costsController.setAllowTreeLeafSelectionOnly(false);
      costsController.setLookupValueObjectClassName(
          "org.jallinone.accounting.accounts.java.AccountVO");
      costsController.addLookup2ParentLink("accountCodeACC02", "costsAccountCodeAcc02PUR01");
      costsController.addLookup2ParentLink("descriptionSYS10", "costsAccountDescrPUR01");
      costsController.setFramePreferedSize(new Dimension(400, 400));
      costsController.setAllColumnVisible(false);
      costsController.setVisibleColumn("accountCodeACC02", true);
      costsController.setVisibleColumn("descriptionSYS10", true);
      costsController.setFilterableColumn("accountCodeACC02", true);
      costsController.setFilterableColumn("descriptionSYS10", true);
      costsController.setSortedColumn("accountCodeACC02", "ASC", 1);
      costsController.setSortableColumn("accountCodeACC02", true);
      costsController.setSortableColumn("descriptionSYS10", true);
      costsController.setPreferredWidthColumn("accountCodeACC02", 100);
      costsController.setPreferredWidthColumn("descriptionSYS10", 290);
      costsController.addLookupListener(
          new LookupListener() {

            public void codeValidated(boolean validated) {}

            public void codeChanged(ValueObject parentVO, Collection parentChangedAttributes) {}

            public void beforeLookupAction(ValueObject parentVO) {
              costsDataLocator
                  .getLookupFrameParams()
                  .put(ApplicationConsts.COMPANY_CODE_SYS01, controlCompanyCode.getValue());
              costsDataLocator
                  .getLookupValidationParameters()
                  .put(ApplicationConsts.COMPANY_CODE_SYS01, controlCompanyCode.getValue());
            }

            public void forceValidate() {}
          });

      CustomizedControls customizedControls =
          new CustomizedControls(tabbedPane, supplierPanel, ApplicationConsts.ID_SUPPLIER_GRID);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemple #4
0
  /** Create data. */
  private void createData() {
    try {
      String[] categories = new String[] {"Hardware", "Software"};
      String[][] subCategories =
          new String[][] {
            {"PC", "Monitor", "Printer"},
            {"O.S.", "IDEs", "Office Appl.", "Database", "Games", "Other SW"}
          };
      String[] agents = new String[] {"Agent 1", "Agent 2", "Agent 3"};
      String[] countries = new String[] {"Italy", "France", "Germany", "Other"};
      String[][] zones =
          new String[][] {
            {"North Italy", "Center Italy", "South Italy"},
            {"Paris", "Outside Paris"},
            {"East", "West"},
            {"Iberica Peninsula", "U.K. & Ireland", "Be.Ne.Lux.", "East Europe"}
          };
      HashMap items = new HashMap();
      items.put("PC", new String[] {"Dell", "HP"});
      items.put("Monitor", new String[] {"LG", "Sony", "Philips"});
      items.put("Printer", new String[] {"HP", "Epson"});
      items.put("O.S.", new String[] {"Windows", "Linux", "Mac"});
      items.put("IDEs", new String[] {"JBuilder", "IBM RAD", "MS Visual Studio .NET"});
      items.put("Office Appl.", new String[] {"MS Office 2007", "Open Office"});
      items.put("Database", new String[] {"Oracle", "MS SQLServer", "Sybase", "IBM DB2"});
      items.put("Games", new String[] {"Need4Speed", "Fifa"});
      items.put("Other SW", new String[] {"Norton AV", "Photoshop"});

      FileOutputStream out = new FileOutputStream("orders.txt");
      String line = null;
      int i = 0;
      Calendar cal = Calendar.getInstance();
      cal.set(cal.YEAR, 2007);
      cal.set(cal.MONTH, 0);
      cal.set(cal.DAY_OF_MONTH, 1);
      cal.set(cal.HOUR_OF_DAY, 0);
      cal.set(cal.MINUTE, 0);
      cal.set(cal.SECOND, 0);
      cal.set(cal.MILLISECOND, 0);
      long t = cal.getTimeInMillis();
      SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
      String date = null;
      int maxRows = 2000000;
      String[] ii = null;
      String[] sub = null;
      String[] z = null;
      do {
        date = sdf.format(new java.util.Date(t));
        for (int k1 = 0; k1 < categories.length; k1++) {
          sub = subCategories[k1];
          for (int k2 = 0; k2 < sub.length; k2++) {
            if (i >= maxRows) break;
            for (int k3 = 0; k3 < countries.length; k3++) {
              z = zones[k3];
              for (int k4 = 0; k4 < z.length; k4++)
                for (int k5 = 0; k5 < agents.length; k5++) {
                  if (i >= maxRows) break;
                  ii = (String[]) items.get(sub[k2]);
                  for (int k6 = 0; k6 < ii.length; k6++) {
                    if (i >= maxRows) break;

                    line =
                        date
                            + ";"
                            + categories[k1]
                            + ";"
                            + sub[k2]
                            + ";"
                            + countries[k3]
                            + ";"
                            + z[k4]
                            + ";"
                            + agents[k5]
                            + ";"
                            + ii[k6]
                            + ";"
                            + new BigDecimal(Math.random() * 10)
                                .setScale(0, BigDecimal.ROUND_HALF_UP)
                            + ";"
                            + new BigDecimal(Math.random() * 1000)
                                .setScale(2, BigDecimal.ROUND_HALF_UP)
                            + ";"
                            + "\n";
                    out.write(line.getBytes());
                    out.flush();
                    i++;
                  }
                }
            }
          }
        }
        t += 86400000;
      } while (i < maxRows);
      out.close();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }