Esempio n. 1
0
  /** Create Grid */
  private void createGrid() {
    if (attributeCombo1 == null || m_setting) return; // 	init
    int indexAttr1 = attributeCombo1.getSelectedIndex();
    int indexAttr2 = attributeCombo2.getSelectedIndex();
    if (indexAttr1 == indexAttr2) {
      log.warning("Same Attribute Selected");
      tabbedPane.setSelectedIndex(0);
      return;
    }
    m_setting = true;
    m_M_PriceList_Version_ID = 0;
    KeyNamePair pl = (KeyNamePair) pickPriceList.getSelectedItem();
    if (pl != null) m_M_PriceList_Version_ID = pl.getKey();
    m_M_Warehouse_ID = 0;
    KeyNamePair wh = (KeyNamePair) pickWarehouse.getSelectedItem();
    if (wh != null) m_M_Warehouse_ID = wh.getKey();

    //	x dimension
    int cols = 2;
    MAttributeValue[] xValues = null;
    if (indexAttr1 > 0) xValues = m_attributes[indexAttr1 - 1].getMAttributeValues();
    if (xValues != null) {
      cols = xValues.length;
      log.info("X - " + m_attributes[indexAttr1 - 1].getName() + " #" + xValues.length);
    }

    //	y dimension
    int rows = 2;
    MAttributeValue[] yValues = null;
    if (indexAttr2 > 0) yValues = m_attributes[indexAttr2 - 1].getMAttributeValues();
    if (yValues != null) {
      rows = yValues.length;
      log.info("Y - " + m_attributes[indexAttr2 - 1].getName() + " #" + yValues.length);
    }

    //
    gridPanel.removeAll();
    CPanel grid = new CPanel(new GridLayout(rows, cols, 5, 5));
    gridPanel.add(modePanel, BorderLayout.NORTH);
    gridPanel.add(new CScrollPane(grid), BorderLayout.CENTER);
    //
    log.info("Rows=" + rows + " - Cols=" + cols);
    for (int row = 0; row < rows; row++) {
      for (int col = 0; col < cols; col++) {
        MAttributeValue xValue = null;
        if (xValues != null) xValue = xValues[col];
        MAttributeValue yValue = null;
        if (yValues != null) yValue = yValues[row];
        //	log.fine("Row=" + row + " - Col=" + col);
        //
        if (row == 0 && col == 0) {
          CPanel descr = new CPanel(new GridLayout(2, 1, 0, 0));
          if (xValues != null)
            descr.add(new JLabel(m_attributes[indexAttr1 - 1].getName(), JLabel.TRAILING));
          if (yValues != null) descr.add(new JLabel(m_attributes[indexAttr2 - 1].getName()));
          grid.add(descr);
        } else if (row == 0) // 	column labels
        {
          if (xValue != null) {
            grid.add(new JLabel(xValue.getName(), JLabel.TRAILING));
          } else grid.add(new JLabel());
        } else if (col == 0) // 	row labels
        {
          if (yValue != null) grid.add(new JLabel(yValue.getName()));
          else grid.add(new JLabel());
        } else {
          grid.add(getGridElement(xValue, yValue));
        }
      }
    }
    //
    tabbedPane.setSelectedIndex(1);
    m_setting = false;
    m_frame.pack();
  } //	createGrid