コード例 #1
0
ファイル: InfoProduct.java プロジェクト: ecartago/opensixen
  /** Static Setup - add fields to parameterPanel */
  private void statInit() {
    labelValue.setText(Msg.getMsg(Env.getCtx(), "Value"));
    fieldValue.setBackground(AdempierePLAF.getInfoBackground());
    fieldValue.addActionListener(this);

    labelName.setText(Msg.getMsg(Env.getCtx(), "Name"));
    fieldName.setBackground(AdempierePLAF.getInfoBackground());
    fieldName.addActionListener(this);

    labelUPC.setText(Msg.translate(Env.getCtx(), "UPC"));
    fieldUPC.setBackground(AdempierePLAF.getInfoBackground());
    fieldUPC.addActionListener(this);

    labelSKU.setText(Msg.translate(Env.getCtx(), "SKU"));
    fieldSKU.setBackground(AdempierePLAF.getInfoBackground());
    fieldSKU.addActionListener(this);

    labelWarehouse.setText(Msg.getMsg(Env.getCtx(), "Warehouse"));
    pickWarehouse.setBackground(AdempierePLAF.getInfoBackground());

    labelPriceList.setText(Msg.getMsg(Env.getCtx(), "PriceListVersion"));
    pickPriceList.setBackground(AdempierePLAF.getInfoBackground());

    labelProductCategory.setText(Msg.translate(Env.getCtx(), "M_Product_Category_ID"));
    pickProductCategory.setBackground(AdempierePLAF.getInfoBackground());

    // @Trifon
    labelAS.setText(Msg.translate(Env.getCtx(), "M_AttributeSet_ID"));
    pickAS.setBackground(AdempierePLAF.getInfoBackground());

    m_InfoPAttributeButton.setMargin(new Insets(2, 2, 2, 2));
    m_InfoPAttributeButton.setToolTipText(Msg.getMsg(Env.getCtx(), "InfoPAttribute"));
    m_InfoPAttributeButton.addActionListener(this);

    labelVendor.setText(Msg.translate(Env.getCtx(), "Vendor"));
    fieldVendor.setBackground(AdempierePLAF.getInfoBackground());
    fieldVendor.addActionListener(this);

    //	Line 1
    parameterPanel.setLayout(new ALayout());
    parameterPanel.add(labelValue, new ALayoutConstraint(0, 0));
    parameterPanel.add(fieldValue, null);
    parameterPanel.add(labelUPC, null);
    parameterPanel.add(fieldUPC, null);
    parameterPanel.add(labelWarehouse, null);
    parameterPanel.add(pickWarehouse, null);
    parameterPanel.add(m_InfoPAttributeButton);
    //	Line 2
    parameterPanel.add(labelName, new ALayoutConstraint(1, 0));
    parameterPanel.add(fieldName, null);
    parameterPanel.add(labelSKU, null);
    parameterPanel.add(fieldSKU, null);
    parameterPanel.add(labelVendor, null);
    parameterPanel.add(fieldVendor, null);

    // Line 3
    parameterPanel.add(labelPriceList, new ALayoutConstraint(2, 0));
    parameterPanel.add(pickPriceList, null);
    parameterPanel.add(labelProductCategory, null);
    parameterPanel.add(pickProductCategory, null);
    parameterPanel.add(labelAS, null); // @Trifon
    parameterPanel.add(pickAS, null); // @Trifon

    //	Product Attribute Instance
    m_PAttributeButton = ConfirmPanel.createPAttributeButton(true);
    confirmPanel.addButton(m_PAttributeButton);
    m_PAttributeButton.addActionListener(this);
    m_PAttributeButton.setEnabled(false);

    // Begin - fer_luck @ centuryon
    // add taskpane
    fieldDescription.setBackground(AdempierePLAF.getInfoBackground());
    fieldDescription.setEditable(false);
    fieldDescription.setPreferredSize(new Dimension(INFO_WIDTH - 100, 100));

    warehouseStockPanel.setTitle(Msg.translate(Env.getCtx(), "WarehouseStock"));
    warehouseStockPanel.setUI(new AdempiereTaskPaneUI());
    warehouseStockPanel.getContentPane().setBackground(new ColorUIResource(251, 248, 241));
    warehouseStockPanel.getContentPane().setForeground(new ColorUIResource(251, 0, 0));

    ColumnInfo[] s_layoutWarehouse =
        new ColumnInfo[] {
          new ColumnInfo(Msg.translate(Env.getCtx(), "Warehouse"), "Warehouse", String.class),
          new ColumnInfo(
              Msg.translate(Env.getCtx(), "QtyAvailable"), "sum(QtyAvailable)", Double.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "sum(QtyOnHand)", Double.class),
          new ColumnInfo(
              Msg.translate(Env.getCtx(), "QtyReserved"), "sum(QtyReserved)", Double.class),
          new ColumnInfo(
              Msg.translate(Env.getCtx(), "QtyAllocated"), "sum(QtyAllocated)", Double.class)
        };
    /** From Clause */
    String s_sqlFrom = " M_PRODUCT_STOCK_V ";
    /** Where Clause */
    String s_sqlWhere = "Value = ?";
    m_sqlWarehouse =
        warehouseTbl.prepareTable(
            s_layoutWarehouse, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_STOCK_V");
    m_sqlWarehouse += " Group By Warehouse, documentnote ";
    warehouseTbl.setRowSelectionAllowed(true);
    warehouseTbl.setMultiSelection(false);
    warehouseTbl.addMouseListener(this);
    warehouseTbl.getSelectionModel().addListSelectionListener(this);
    warehouseTbl.setShowTotals(true);
    warehouseTbl.autoSize();

    ColumnInfo[] s_layoutSubstitute =
        new ColumnInfo[] {
          new ColumnInfo(Msg.translate(Env.getCtx(), "Warehouse"), "orgname", String.class),
          new ColumnInfo(
              Msg.translate(Env.getCtx(), "Value"),
              "(Select Value from M_Product p where p.M_Product_ID=M_PRODUCT_SUBSTITUTERELATED_V.Substitute_ID)",
              String.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", String.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "QtyAvailable"), "QtyAvailable", Double.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "QtyOnHand", Double.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "QtyReserved", Double.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "PriceStd"), "PriceStd", Double.class)
        };
    s_sqlFrom = "M_PRODUCT_SUBSTITUTERELATED_V";
    s_sqlWhere = "M_Product_ID = ? AND M_PriceList_Version_ID = ? and RowType = 'S'";
    m_sqlSubstitute =
        substituteTbl.prepareTable(
            s_layoutSubstitute, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_SUBSTITUTERELATED_V");
    substituteTbl.setRowSelectionAllowed(false);
    substituteTbl.setMultiSelection(false);
    substituteTbl.addMouseListener(this);
    substituteTbl.getSelectionModel().addListSelectionListener(this);
    substituteTbl.autoSize();

    ColumnInfo[] s_layoutRelated =
        new ColumnInfo[] {
          new ColumnInfo(Msg.translate(Env.getCtx(), "Warehouse"), "orgname", String.class),
          new ColumnInfo(
              Msg.translate(Env.getCtx(), "Value"),
              "(Select Value from M_Product p where p.M_Product_ID=M_PRODUCT_SUBSTITUTERELATED_V.Substitute_ID)",
              String.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", String.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "QtyAvailable"), "QtyAvailable", Double.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "QtyOnHand", Double.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "QtyReserved", Double.class),
          new ColumnInfo(Msg.translate(Env.getCtx(), "PriceStd"), "PriceStd", Double.class)
        };
    s_sqlFrom = "M_PRODUCT_SUBSTITUTERELATED_V";
    s_sqlWhere = "M_Product_ID = ? AND M_PriceList_Version_ID = ? and RowType = 'R'";
    m_sqlRelated =
        relatedTbl.prepareTable(
            s_layoutRelated, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_SUBSTITUTERELATED_V");
    relatedTbl.setRowSelectionAllowed(false);
    relatedTbl.setMultiSelection(false);
    relatedTbl.addMouseListener(this);
    relatedTbl.getSelectionModel().addListSelectionListener(this);
    relatedTbl.autoSize();

    // Available to Promise Tab
    m_tableAtp.setRowSelectionAllowed(false);
    m_tableAtp.setMultiSelection(false);

    CTabbedPane jTab = new CTabbedPane();
    jTab.addTab(Msg.translate(Env.getCtx(), "Warehouse"), new JScrollPane(warehouseTbl));
    jTab.setPreferredSize(new Dimension(INFO_WIDTH, SCREEN_HEIGHT > 600 ? 250 : 105));
    jTab.addTab(Msg.translate(Env.getCtx(), "Description"), new JScrollPane(fieldDescription));
    jTab.addTab(Msg.translate(Env.getCtx(), "Substitute_ID"), new JScrollPane(substituteTbl));
    jTab.addTab(Msg.translate(Env.getCtx(), "RelatedProduct_ID"), new JScrollPane(relatedTbl));
    jTab.addTab(Msg.getMsg(Env.getCtx(), "ATP"), new JScrollPane(m_tableAtp));
    jTab.addChangeListener(this);
    tablePanel.setPreferredSize(new Dimension(INFO_WIDTH, SCREEN_HEIGHT > 600 ? 255 : 110));
    tablePanel.add(jTab);

    warehouseStockPanel.setCollapsed(true);
    warehouseStockPanel.add(tablePanel);
    this.addonPanel.add(warehouseStockPanel);

    this.p_table.addKeyListener(
        new KeyAdapter() {
          public void keyReleased(KeyEvent ke) {
            int row = ((MiniTable) ke.getSource()).getSelectedRow();
            refresh(
                ((MiniTable) ke.getSource()).getValueAt(row, 2),
                new BigDecimal(pickWarehouse.getValue().toString()).intValue(),
                new BigDecimal(pickPriceList.getValue().toString()).intValue());
            warehouseStockPanel.setCollapsed(false);
          }
        });

    this.p_table.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent me) {
            int row = ((MiniTable) me.getSource()).getSelectedRow();
            refresh(
                ((MiniTable) me.getSource()).getValueAt(row, 2),
                new BigDecimal(pickWarehouse.getValue().toString()).intValue(),
                new BigDecimal(pickPriceList.getValue().toString()).intValue());
            warehouseStockPanel.setCollapsed(false);
          }
        });
    // End - fer_luck @ centuryon
  } //	statInit
コード例 #2
0
  /**
   * Dynamic Init
   *
   * @param C_BPartner_ID BP
   */
  private void dynInit(int C_BPartner_ID) {
    log.config("C_BPartner_ID=" + C_BPartner_ID);
    if (C_BPartner_ID != 0) {
      int ShelfLifeMinPct = 0;
      int ShelfLifeMinDays = 0;
      String sql =
          "SELECT bp.ShelfLifeMinPct, bpp.ShelfLifeMinPct, bpp.ShelfLifeMinDays "
              + "FROM C_BPartner bp "
              + " LEFT OUTER JOIN C_BPartner_Product bpp"
              + " ON (bp.C_BPartner_ID=bpp.C_BPartner_ID AND bpp.M_Product_ID=?) "
              + "WHERE bp.C_BPartner_ID=?";
      PreparedStatement pstmt = null;
      ResultSet rs = null;
      try {
        pstmt = DB.prepareStatement(sql, null);
        pstmt.setInt(1, m_M_Product_ID);
        pstmt.setInt(2, C_BPartner_ID);
        rs = pstmt.executeQuery();
        if (rs.next()) {
          ShelfLifeMinPct = rs.getInt(1); // 	BP
          int pct = rs.getInt(2); // 	BP_P
          if (pct > 0) // 	overwrite
          ShelfLifeMinDays = pct;
          ShelfLifeMinDays = rs.getInt(3);
        }
      } catch (Exception e) {
        log.log(Level.SEVERE, sql, e);
      } finally {
        DB.close(rs, pstmt);
        rs = null;
        pstmt = null;
      }
      if (ShelfLifeMinPct > 0) {
        s_sqlMinLife =
            " AND COALESCE(TRUNC(((daysbetween(asi.GuaranteeDate, SYSDATE))/p.GuaranteeDays)*100),0)>="
                + ShelfLifeMinPct;
        log.config("PAttributeInstance.dynInit - ShelfLifeMinPct=" + ShelfLifeMinPct);
      }
      if (ShelfLifeMinDays > 0) {
        s_sqlMinLife +=
            " AND COALESCE((daysbetween(asi.GuaranteeDate, SYSDATE)),0)>=" + ShelfLifeMinDays;
        log.config("PAttributeInstance.dynInit - ShelfLifeMinDays=" + ShelfLifeMinDays);
      }
    } //	BPartner != 0

    m_sql =
        m_table.prepareTable(
                s_layout, s_sqlFrom, s_sqlWhereWithoutWarehouse + s_sqlNonZero, false, "asi")
            + " ORDER BY asi.GuaranteeDate, s.QtyOnHand"; //	oldest, smallest first
    //
    m_table.setRowSelectionAllowed(true);
    m_table.setMultiSelection(false);
    m_table.addMouseListener(this);
    m_table.getSelectionModel().addListSelectionListener(this);
    //
    refresh();

    //  The minitable class overrides the Enter key if multi-selection is false
    m_table.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "doDispose");
    m_table.getActionMap().put("doDispose", doDispose);
  }
コード例 #3
0
  private void dynInit() {
    // Llenar los filtros de busquedas
    llenarcombos();
    // generacion de las columnas para los avisos de Creditos
    ColumnInfo[] layoutACC =
        new ColumnInfo[] {

          // 0 Proveedor
          new ColumnInfo(Msg.translate(Env.getCtx(), "C_BPartner_ID"), ".", String.class),

          // 1 País
          new ColumnInfo(Msg.translate(Env.getCtx(), "CountryName"), ".", String.class),

          // 2 Departamento
          new ColumnInfo(Msg.translate(Env.getCtx(), "XX_VMR_Department_ID"), ".", String.class),

          // 3 Categoría
          new ColumnInfo(Msg.translate(Env.getCtx(), "Categoria"), ".", String.class),

          // 4 Mes
          new ColumnInfo(Msg.translate(Env.getCtx(), "XX_Month"), ".", Integer.class),

          // 5 Año
          new ColumnInfo(Msg.translate(Env.getCtx(), "XX_Year"), ".", Integer.class),

          // 6 Compras hechas
          new ColumnInfo(Msg.translate(Env.getCtx(), "PurchasesDone"), "total", float.class),

          // 7 Descuentos generados
          new ColumnInfo(Msg.translate(Env.getCtx(), "GeneratedDiscount"), ".", float.class),

          // 8 Avisos pendientes
          new ColumnInfo(Msg.translate(Env.getCtx(), "PendingAdvices"), ".", float.class),
        };

    xTableACC.prepareTable(layoutACC, "", "", true, "");

    //  Visual
    CompiereColor.setBackground(this);
    xTableACC.getSelectionModel().addListSelectionListener(this);
    xTableACC.getColumnModel().getColumn(0).setMinWidth(350);
    xTableACC.getColumnModel().getColumn(1).setMinWidth(150);
    xTableACC.getColumnModel().getColumn(2).setMinWidth(190);
    xTableACC.getColumnModel().getColumn(3).setMinWidth(110);
    xTableACC.getColumnModel().getColumn(4).setMinWidth(25);
    xTableACC.getColumnModel().getColumn(4).setMaxWidth(30);
    xTableACC.getColumnModel().getColumn(5).setMinWidth(30);
    xTableACC.getColumnModel().getColumn(5).setMaxWidth(35);
    xTableACC.getColumnModel().getColumn(6).setMinWidth(140);
    xTableACC.getColumnModel().getColumn(7).setMinWidth(150);
    xTableACC.getColumnModel().getColumn(8).setMinWidth(140);
    xTableACC.getSelectionModel().addListSelectionListener(this);

    ColumnInfo[] layoutAAP =
        new ColumnInfo[] {

          // 0 Proveedor
          new ColumnInfo(
              Msg.translate(Env.getCtx(), "C_BPartner_ID"), "vendorID", KeyNamePair.class),

          // 1 País
          new ColumnInfo(Msg.translate(Env.getCtx(), "CountryName"), ".", KeyNamePair.class),

          // 2 Mes
          new ColumnInfo(Msg.translate(Env.getCtx(), "Month"), ".", Integer.class),

          // 3 Año
          new ColumnInfo(Msg.translate(Env.getCtx(), "Year"), ".", Integer.class),

          // 4 Tipo
          new ColumnInfo(Msg.translate(Env.getCtx(), "XX_Notificationtype"), ".", String.class),

          // 5 Compras hechas
          new ColumnInfo(Msg.translate(Env.getCtx(), "PurchasesDone"), "total", float.class),

          // 6 Descuentos generados
          new ColumnInfo(Msg.translate(Env.getCtx(), "GeneratedDiscount"), ".", float.class),

          // 7 Avisos pendientes
          new ColumnInfo(Msg.translate(Env.getCtx(), "PendingAdvices"), ".", float.class),
        };

    xTableAAP.prepareTable(layoutAAP, "", "", true, "");

    //  Visual
    CompiereColor.setBackground(this);
    xTableAAP.getSelectionModel().addListSelectionListener(this);
    xTableAAP.getColumnModel().getColumn(0).setMinWidth(350);
    xTableAAP.getColumnModel().getColumn(1).setMinWidth(150);
    xTableAAP.getColumnModel().getColumn(2).setMinWidth(25);
    xTableAAP.getColumnModel().getColumn(2).setMaxWidth(30);
    xTableAAP.getColumnModel().getColumn(3).setMinWidth(30);
    xTableAAP.getColumnModel().getColumn(3).setMaxWidth(35);
    xTableAAP.getColumnModel().getColumn(4).setMinWidth(90);
    xTableAAP.getColumnModel().getColumn(5).setMinWidth(150);
    xTableAAP.getColumnModel().getColumn(6).setMinWidth(140);
    xTableAAP.getColumnModel().getColumn(7).setMinWidth(140);
    xTableAAP.getSelectionModel().addListSelectionListener(this);

    ColumnInfo[] layoutDetails =
        new ColumnInfo[] {

          // 0 Proveedor
          new ColumnInfo(Msg.translate(Env.getCtx(), "C_BPartner_ID"), ".", String.class),

          // 1 Mes
          new ColumnInfo(Msg.translate(Env.getCtx(), "Month"), ".", Integer.class),

          // 2 Año
          new ColumnInfo(Msg.translate(Env.getCtx(), "Year"), ".", Integer.class),

          // 3 Departamento
          new ColumnInfo(Msg.translate(Env.getCtx(), "XX_VMR_Department_ID"), ".", String.class),

          // 4 Categoría
          new ColumnInfo(Msg.translate(Env.getCtx(), "Categoria"), ".", String.class),

          // 5 Descuento
          new ColumnInfo(Msg.translate(Env.getCtx(), "XX_PubAmountDisc"), ".", float.class)
        };

    xTableDetails.prepareTable(layoutDetails, "", "", true, "");

    //  Visual
    CompiereColor.setBackground(this);
    xTableDetails.getSelectionModel().addListSelectionListener(this);
    xTableDetails.getColumnModel().getColumn(0).setMinWidth(350);
    xTableDetails.getColumnModel().getColumn(1).setMinWidth(25);
    xTableDetails.getColumnModel().getColumn(1).setMaxWidth(30);
    xTableDetails.getColumnModel().getColumn(2).setMinWidth(30);
    xTableDetails.getColumnModel().getColumn(2).setMaxWidth(35);
    xTableDetails.getColumnModel().getColumn(3).setMinWidth(190);
    xTableDetails.getColumnModel().getColumn(4).setMinWidth(150);
    xTableDetails.getColumnModel().getColumn(5).setMinWidth(120);
    xTableDetails.getSelectionModel().addListSelectionListener(this);

    bSearch.addActionListener(this);
    bReset.addActionListener(this);

    // Se cargan los acuerdos
    tableInit_option = 0;
    tableInit();
    tableDetailsInit();
    totalCalculation();

    xTableACC.getTableHeader().setReorderingAllowed(false);
    xTableAAP.getTableHeader().setReorderingAllowed(false);
    xTableDetails.getTableHeader().setReorderingAllowed(false);
    // xTable.setAutoResizeMode(3);
    // data();

    //  Init
    statusBar.setStatusLine("");
    statusBar.setStatusDB(0);

    // estatus
    statusBar.setStatusLine("Acuerdos Comerciales y Cartas Compromiso");
    statusBar.setStatusDB(xTableACC.getRowCount() + xTableAAP.getRowCount());
  } //  dynInit
コード例 #4
0
  /** Dynamic Init. Table Layout, Visual, Listener */
  private void dynInit() {

    ColumnInfo[] layout =
        new ColumnInfo[] {
          new ColumnInfo(Msg.translate(Env.getCtx(), "M_Product_ID"), ".", KeyNamePair.class), //  1
          new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), ".", String.class) //  2
        };

    xProductTable.prepareTable(layout, "", "", false, "");
    xAssociateTable.prepareTable(layout, "", "", true, "");

    xAssociateTable.setAutoResizeMode(3);
    xProductTable.setAutoResizeMode(3);

    //  Visual
    CompiereColor.setBackground(this);

    //  Listener
    xProductTable.getSelectionModel().addListSelectionListener(this);
    xAssociateTable.getModel().addTableModelListener(this);
    bDisassociate.addActionListener(this);
    bNewProduct.addActionListener(this);

    // pregunto si hay productos asociados para ver si cargo las tablas
    boolean ready = verify();

    if (ready == false) {

      tableInit_option = 0;
      tableInit();
      tableLoad(xProductTable);

    } else {
      tableInit_option = 1;
      tableInit();
      tableLoad(xAssociateTable);

      bNewProduct.setEnabled(false);
      bDisassociate.setEnabled(true);
    }

    xProductTable.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {

              int rowP = xProductTable.getSelectedRow();

              if (!(rowP == -1)) {
                cmd_associate();
              }
            }
          }
        });

    //  Init
    statusBar.setStatusLine("");
    statusBar.setStatusDB(0);

    MOrder order = new MOrder(Env.getCtx(), LineRefProv.getC_Order_ID(), null);

    boolean block = false;
    String oS = order.getXX_OrderStatus();
    String compS = order.getDocStatus();
    if (oS.equals("AN") || compS.equals("CO")) {
      block = true;
    }

    if (order.isXX_OrderReadyStatus() && order.getXX_OrderType().equalsIgnoreCase("Nacional"))
      block = true;

    if (order.getXX_OrderType().equalsIgnoreCase("Importada")
        && order.get_ValueAsInt("XX_ImportingCompany_ID") != 0) {

      if (order.get_ValueAsInt("XX_ImportingCompany_ID")
          != Env.getCtx().getContextAsInt("#XX_L_VSI_CLIENTCENTROBECO_ID")) {
        block = true;
      }
    }

    if (order.getXX_StoreDistribution().equals("Y") || block) {
      xProductTable.setEnabled(false);
      xAssociateTable.setEnabled(false);
      bNewProduct.setEnabled(false);
      bDisassociate.setEnabled(false);
    }
  } //  dynInit