void dynDepartament() {
    KeyNamePair cat = (KeyNamePair) categoryCombo.getSelectedItem();
    departmentCombo.removeActionListener(this);
    departmentCombo.removeAllItems();

    String sql = "SELECT XX_VMR_DEPARTMENT_ID, VALUE||'-'||NAME " + " FROM XX_VMR_DEPARTMENT ";

    if (cat != null && cat.getKey() != -1) {
      sql += " WHERE XX_VMR_CATEGORY_ID = " + cat.getKey();
    }
    sql += " ORDER BY VALUE||'-'||NAME ";
    sql = MRole.getDefault().addAccessSQL(sql, "", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      pstmt = DB.prepareStatement(sql, null);
      rs = pstmt.executeQuery();

      departmentCombo.addItem(new KeyNamePair(-1, null));
      while (rs.next()) {
        departmentCombo.addItem(new KeyNamePair(rs.getInt(1), rs.getString(2)));
      }
      rs.close();
      pstmt.close();

      departmentCombo.addActionListener(this);
      departmentCombo.setEnabled(true);
      departmentCombo.setEditable(true);
    } catch (SQLException e) {
      log.log(Level.SEVERE, sql, e);
    } finally {
      DB.closeResultSet(rs);
      DB.closeStatement(pstmt);
    }
  }
Beispiel #2
0
  /**
   * Descripción de Método
   *
   * @param AD_PrintFormat_ID
   */
  private void fillComboReport(int AD_PrintFormat_ID) {
    comboReport.removeActionListener(this);
    comboReport.removeAllItems();

    KeyNamePair selectValue = null;

    // fill Report Options

    String sql =
        MRole.getDefault()
            .addAccessSQL(
                "SELECT AD_PrintFormat_ID, Name, Description "
                    + "FROM AD_PrintFormat "
                    + "WHERE AD_Table_ID=? AND IsActive='Y' "
                    + "ORDER BY Name",
                "AD_PrintFormat",
                MRole.SQL_NOTQUALIFIED,
                MRole.SQL_RO);
    int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID();

    try {
      PreparedStatement pstmt = DB.prepareStatement(sql);

      pstmt.setInt(1, AD_Table_ID);

      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2));

        comboReport.addItem(pp);

        if (rs.getInt(1) == AD_PrintFormat_ID) {
          selectValue = pp;
        }
      }

      rs.close();
      pstmt.close();
    } catch (SQLException e) {
      log.log(Level.SEVERE, "", e);
    }

    StringBuffer sb = new StringBuffer("** ").append(Msg.getMsg(m_ctx, "NewReport")).append(" **");
    KeyNamePair pp = new KeyNamePair(-1, sb.toString());

    // comboReport.addItem( pp );

    if (selectValue != null) {
      comboReport.setSelectedItem(selectValue);
    }

    comboReport.addActionListener(this);
  } // fillComboReport
  /** Actualiza el combobox de repositorios */
  public void refresh() {
    // Eliminamos los items actuales y la posibilidad de que salte el evento
    locationsCombo.removeActionListener(this);
    locationsCombo.removeAllItems();

    // Añadimos los repositorios actualizados
    for (URI uri : P2.get().getRepositories()) {
      locationsCombo.addItem(uri);
    }

    locationsCombo.addActionListener(this);
  }
  // Datos
  void dynCategory() {

    categoryCombo.removeActionListener(this);
    String sql = "SELECT XX_VMR_CATEGORY_ID, VALUE||'-'||NAME " + " FROM XX_VMR_CATEGORY ";
    sql += " ORDER BY VALUE||'-'||NAME ";
    sql = MRole.getDefault().addAccessSQL(sql, "", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      pstmt = DB.prepareStatement(sql, null);
      rs = pstmt.executeQuery();

      categoryCombo.addItem(new KeyNamePair(-1, null));
      while (rs.next()) {
        categoryCombo.addItem(new KeyNamePair(rs.getInt(1), rs.getString(2)));
      }
      categoryCombo.addActionListener(this);
    } catch (SQLException e) {
      log.log(Level.SEVERE, sql, e);
    } finally {
      DB.closeResultSet(rs);
      DB.closeStatement(pstmt);
    }
  }
Beispiel #5
0
  /** Descripción de Método */
  private void initLocator() {
    log.fine("");

    // Load Warehouse

    String sql = "SELECT M_Warehouse_ID, Name FROM M_Warehouse";

    if (m_only_Warehouse_ID != 0) {
      sql += " WHERE M_Warehouse_ID=" + m_only_Warehouse_ID;
    }

    String SQL =
        MRole.getDefault().addAccessSQL(sql, "M_Warehouse", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO)
            + " ORDER BY 2";

    try {
      PreparedStatement pstmt = DB.prepareStatement(SQL);
      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        fWarehouse.addItem(new KeyNamePair(rs.getInt(1), rs.getString(2)));
      }

      rs.close();
      pstmt.close();
    } catch (SQLException e) {
      log.log(Level.SEVERE, "warehouse", e);
    }

    log.fine("Warehouses=" + fWarehouse.getItemCount());

    // Load existing Locators

    m_mLocator.fillComboBox(m_mandatory, true, true, false);
    log.fine(m_mLocator.toString());
    fLocator.setModel(m_mLocator);
    fLocator.setValue(m_M_Locator_ID);
    fLocator.addActionListener(this);
    displayLocator();

    //

    fCreateNew.setSelected(false);
    fCreateNew.addActionListener(this);
    enableNew();

    //

    fWarehouse.addActionListener(this);
    fX.addKeyListener(this);
    fY.addKeyListener(this);
    fZ.addKeyListener(this);

    // Guarda el ID de la ubicación con la cual se invocó el constructor
    // de este diálogo. Este ID se utiliza en caso de cancelar el diálogo
    // para recuperar el valor que tenía previamente el ID de ubicación.
    m_OriginalLocatorID = m_M_Locator_ID;

    // Update UI

    pack();
  } // initLocator
  /** Dynanmic Init & fill fields - Called when Country changes! */
  private void initLocation() {
    // Kenos
    fCity.setPreferredSize(new Dimension(225, 25));
    fCountry.setPreferredSize(new Dimension(225, 25));
    //

    MCountry country = m_location.getCountry();
    log.fine(
        country.getName()
            + ", Region="
            + country.isHasRegion()
            + " "
            + country.getDisplaySequence()
            + ", C_Location_ID="
            + m_location.getC_Location_ID());
    //	new Region
    if (m_location.getC_Country_ID() != s_oldCountry_ID && country.isHasRegion()) {
      fRegion = new CComboBox(MRegion.getRegions(Env.getCtx(), country.getC_Country_ID()));
      if (m_location.getRegion() != null) fRegion.setSelectedItem(m_location.getRegion());
      /*else
      	if(m_location.getCountry().getC_Country_ID() == 139 && m_location.getAD_Org_ID() != 0){
      		int C_Location_ID = MOrgInfo.get(Env.getCtx(),m_location.getAD_Org_ID()).getC_Location_ID();
      		if (C_Location_ID != 0)
      		{
      			MLocation location =
      				new MLocation(Env.getCtx(), C_Location_ID, null);
      			MRegion region = new MRegion(Env.getCtx(), location.getC_Region_ID(), null);
      			fRegion.setSelectedItem(region);
      			m_location.setRegion(region);
      			//	refrseh
      			fRegion.requestFocus();	//	allows to use Keybord selection
      		}
      	}
      */
      // Kenos
      fRegion.addActionListener(this);
      //
      lRegion.setText(country.getRegionName());
      s_oldCountry_ID = m_location.getC_Country_ID();
    }
    // Kenos// Faire
    if (m_location.getCountry().isHasRegion()
        && m_location.getRegion() != null
        && m_location.getCountry().getC_Country_ID() == 139) // 139 = Brasil
    {
      fCity.setEditable(false);
      fCity.removeAllItems();
      fCity = new CComboBox(getCCity());
      if (m_location.getC_City_ID() != 0)
        fCity.setSelectedItem(new MCity(Env.getCtx(), m_location.getC_City_ID(), null));
    } else {
      fCity.removeAllItems();
      fCity.setEditable(true);
      fCity.setSelectedItem(m_location.getCity());
    }
    // Kenos

    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.gridy = 0; // 	line
    gbc.gridx = 0;
    gbc.gridwidth = 1;
    gbc.insets = fieldInsets;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 0;
    gbc.weighty = 0;

    mainPanel.add(Box.createVerticalStrut(5), gbc); // 	top gap

    int line = 1;
    addLine(line++, lAddress1, fAddress1);
    addLine(line++, lAddress2, fAddress2);
    addLine(line++, lAddress3, fAddress3);
    addLine(line++, lAddress4, fAddress4);

    //  sequence of City Postal Region - @P@ @C@ - @C@, @R@ @P@
    String ds = country.getDisplaySequence();
    if (ds == null || ds.length() == 0) {
      log.log(Level.SEVERE, "DisplaySequence empty - " + country);
      ds = ""; // 	@C@,  @P@
    }
    StringTokenizer st = new StringTokenizer(ds, "@", false);
    while (st.hasMoreTokens()) {
      String s = st.nextToken();
      if (s.startsWith("C")) addLine(line++, lCity, fCity);
      else if (s.startsWith("P")) addLine(line++, lPostal, fPostal);
      else if (s.startsWith("A")) addLine(line++, lPostalAdd, fPostalAdd);
      else if (s.startsWith("R") && m_location.getCountry().isHasRegion())
        addLine(line++, lRegion, fRegion);
    }
    //  Country Last
    addLine(line++, lCountry, fCountry);

    //	Fill it
    if (m_location.getC_Location_ID() != 0) {
      fAddress1.setText(m_location.getAddress1());
      fAddress2.setText(m_location.getAddress2());
      fAddress3.setText(m_location.getAddress3());
      fAddress4.setText(m_location.getAddress4());
      // fCity.setText(m_location.getCity()); - Kenos (linha comentada)
      fPostal.setText(m_location.getPostal());
      fPostalAdd.setText(m_location.getPostal_Add());
      if (m_location.getCountry().isHasRegion()) {
        lRegion.setText(m_location.getCountry().getRegionName());
        fRegion.setSelectedItem(m_location.getRegion());
      }
      fCountry.setSelectedItem(country);
    }

    //	Update UI
    pack();
  } //	initLocation
  /**
   * Descripción de Método
   *
   * @throws Exception
   */
  void jbInit() throws Exception {
    CompiereColor.setBackground(this);
    mainPanel.setLayout(mainLayout);
    mainLayout.setHgap(5);
    mainLayout.setVgap(5);
    this.getContentPane().add(mainPanel);
    northPanel.setLayout(northLayout);
    northPanel.add(toolBar, BorderLayout.CENTER);
    toolBar.add(bLoad);
    toolBar.add(bDelete);
    toolBar.add(bSave);
    toolBar.add(bOpen);
    toolBar.add(cbContent);
    mainPanel.add(northPanel, BorderLayout.NORTH);

    //

    bOpen.setEnabled(false);
    bOpen.setIcon(Env.getImageIcon("Editor24.gif"));
    bOpen.setMargin(new Insets(0, 2, 0, 2));
    bOpen.setToolTipText(Msg.getMsg(Env.getCtx(), "Open"));
    bOpen.addActionListener(this);

    //

    bSave.setEnabled(false);
    bSave.setIcon(Env.getImageIcon("Export24.gif"));
    bSave.setMargin(new Insets(0, 2, 0, 2));
    bSave.setToolTipText(Msg.getMsg(Env.getCtx(), "AttachmentSave"));
    bSave.addActionListener(this);

    //

    bLoad.setIcon(Env.getImageIcon("Import24.gif"));
    bLoad.setMargin(new Insets(0, 2, 0, 2));
    bLoad.setToolTipText(Msg.getMsg(Env.getCtx(), "Load"));
    bLoad.addActionListener(this);

    //

    bDelete.setIcon(Env.getImageIcon("Delete24.gif"));
    bDelete.setMargin(new Insets(0, 2, 0, 2));
    bDelete.setToolTipText(Msg.getMsg(Env.getCtx(), "Delete"));
    bDelete.addActionListener(this);

    //

    Dimension size = cbContent.getPreferredSize();

    size.width = 200;
    cbContent.setPreferredSize(size);

    // cbContent.setToolTipText(text);

    cbContent.addActionListener(this);
    cbContent.setLightWeightPopupEnabled(false); // Acrobat Panel is heavy

    //

    text.setBackground(CompierePLAF.getInfoBackground());
    text.setPreferredSize(new Dimension(200, 200));

    //

    mainPanel.add(confirmPanel, BorderLayout.SOUTH);
    confirmPanel.addActionListener(this);
    bDeleteAll = ConfirmPanel.createDeleteButton(true);
    confirmPanel.addButton(bDeleteAll);
    bDeleteAll.addActionListener(this);

    //

    info.setText("-");
    info.setReadWrite(false);
    graphPanel.add(info, BorderLayout.CENTER);

    //

    mainPanel.add(centerPane, BorderLayout.CENTER);
    centerPane.add(graphPanel, JSplitPane.LEFT);
    centerPane.add(text, JSplitPane.RIGHT);
    centerPane.setResizeWeight(.75); // more to graph
  } // jbInit
  /** Initialize all panel fields and editors based on {@link #asiTemplate}. */
  private final void initAttributes() {
    final Properties ctx = getCtx();
    final boolean isProductWindow = isProductWindow();
    final boolean isProcessParameter = isProcessParameter();
    final boolean isPureProductASI = isPureProductASI();
    final boolean allowSelectExistingASI = isAllowSelectExistingASI();
    final MAttributeSet as = asiTemplate.getMAttributeSet();
    Check.assumeNotNull(as, "attribute set not null");
    final boolean isASITemplateNew = asiTemplate.getM_AttributeSetInstance_ID() <= 0;

    //
    // Show Select existing ASI (if allowed)
    if (allowSelectExistingASI) {
      // New/Edit - Selection
      if (isASITemplateNew) // new ASI
      cbNewEdit.setText(msgBL.getMsg(ctx, "NewRecord"));
      else cbNewEdit.setText(msgBL.getMsg(ctx, "EditRecord"));
      cbNewEdit.addActionListener(this);
      centerPanel.add(cbNewEdit, new ALayoutConstraint(m_row++, 0));
      bSelectExistingASI.setText(msgBL.getMsg(ctx, "SelectExisting"));
      bSelectExistingASI.addActionListener(this);
      centerPanel.add(bSelectExistingASI, null);
    }

    //
    // Fetch M_Attributes
    final List<MAttribute> attributes;
    if (isProductWindow) {
      attributes = Arrays.asList(as.getMAttributes(false)); // non-instance attributes
    } else if (isPureProductASI) {
      // Regular product's attribute set instance attributes
      attributes = Arrays.asList(as.getMAttributes(true)); // all instance attributes
    } else if (isProcessParameter) {
      final IQueryBuilder<MAttribute> attributesQueryBuilder =
          queryBL
              .createQueryBuilder(MAttribute.class)
              .setContext(ctx, ITrx.TRXNAME_None)
              .addOnlyActiveRecordsFilter()
              .addOnlyContextClient();
      attributesQueryBuilder
          .orderBy()
          .addColumn(I_M_Attribute.COLUMNNAME_Name)
          .addColumn(I_M_Attribute.COLUMNNAME_M_Attribute_ID);
      attributes = attributesQueryBuilder.create().list(MAttribute.class);
    } else {
      attributes = Collections.emptyList();
    }

    //
    // Create attributes UI editors
    for (final MAttribute attribute : attributes) {
      if (!attributeExcludeBL.isExcludedAttribute(
          attribute, as, m_AD_Column_ID, attributeContext.isSOTrx())) {
        addAttributeLine(attribute);
      }
    }

    //
    // Lot
    if (isPureProductASI && as.isLot()) {
      CLabel label = new CLabel(msgBL.translate(ctx, "Lot"));
      label.setLabelFor(fieldLotString);
      centerPanel.add(label, new ALayoutConstraint(m_row++, 0));
      centerPanel.add(fieldLotString, null);
      fieldLotString.setText(asiTemplate.getLot());
      // M_Lot_ID
      // int AD_Column_ID = 9771; // M_AttributeSetInstance.M_Lot_ID
      // fieldLot = new VLookup ("M_Lot_ID", false,false, true,
      // MLookupFactory.get(getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.TableDir));
      final String sql =
          "SELECT M_Lot_ID, Name "
              + "FROM M_Lot l "
              + "WHERE EXISTS (SELECT M_Product_ID FROM M_Product p "
              + "WHERE p.M_AttributeSet_ID="
              + asiTemplate.getM_AttributeSet_ID()
              + " AND p.M_Product_ID=l.M_Product_ID)";
      fieldLot = new CComboBox<>(DB.getKeyNamePairs(sql, true));
      label = new CLabel(msgBL.translate(ctx, "M_Lot_ID"));
      label.setLabelFor(fieldLot);
      centerPanel.add(label, new ALayoutConstraint(m_row++, 0));
      centerPanel.add(fieldLot, null);
      if (asiTemplate.getM_Lot_ID() > 0) {
        for (int i = 1; i < fieldLot.getItemCount(); i++) {
          KeyNamePair pp = fieldLot.getItemAt(i);
          if (pp.getKey() == asiTemplate.getM_Lot_ID()) {
            fieldLot.setSelectedIndex(i);
            fieldLotString.setEditable(false);
            break;
          }
        }
      }
      fieldLot.addActionListener(this);
      // New Lot Button
      if (asiTemplate.getMAttributeSet().getM_LotCtl_ID() > 0) {
        if (Env.getUserRolePermissions().isTableAccess(MLot.Table_ID, false)
            && Env.getUserRolePermissions().isTableAccess(MLotCtl.Table_ID, false)
            && !asiTemplate.isExcludeLot(m_AD_Column_ID, attributeContext.isSOTrx())) {
          centerPanel.add(bLot, null);
          bLot.addActionListener(this);
        }
      }
      // Popup
      fieldLot.addMouseListener(new VPAttributeDialog_mouseAdapter(this)); // popup
      mZoom = new CMenuItem(msgBL.getMsg(ctx, "Zoom"), Images.getImageIcon2("Zoom16"));
      mZoom.addActionListener(this);
      popupMenu.add(mZoom);
    } // Lot

    //
    // SerNo
    if (isPureProductASI && as.isSerNo()) {
      CLabel label = new CLabel(msgBL.translate(ctx, "SerNo"));
      label.setLabelFor(fieldSerNo);
      fieldSerNo.setText(asiTemplate.getSerNo());
      centerPanel.add(label, new ALayoutConstraint(m_row++, 0));
      centerPanel.add(fieldSerNo, null);
      // New SerNo Button
      if (asiTemplate.getMAttributeSet().getM_SerNoCtl_ID() != 0) {
        if (Env.getUserRolePermissions().isTableAccess(MSerNoCtl.Table_ID, false)
            && !asiTemplate.isExcludeSerNo(m_AD_Column_ID, attributeContext.isSOTrx())) {
          centerPanel.add(bSerNo, null);
          bSerNo.addActionListener(this);
        }
      }
    } // SerNo

    //
    // GuaranteeDate.
    // We are displaying it if we deal with a pure product ASI (i.e. user is not editing the ASI
    // from product window),
    // and if:
    // * the attribute set requires a GuaranteeDate
    // * or if the ASI has a GuaranteeDate already set
    if (isPureProductASI && (as.isGuaranteeDate() || asiTemplate.getGuaranteeDate() != null)) {
      CLabel label = new CLabel(msgBL.translate(ctx, "GuaranteeDate"));
      label.setLabelFor(fieldGuaranteeDate);
      if (isASITemplateNew) {
        Date guaranteeDate = asiTemplate.getGuaranteeDate();
        if (guaranteeDate == null) {
          guaranteeDate =
              attributesBL.calculateBestBeforeDate(
                  ctx,
                  m_M_Product_ID, // product
                  attributeContext.getC_BPartner_ID(), // vendor bpartner
                  Env.getDate(ctx) // dateReceipt
                  );
        }
        fieldGuaranteeDate.setValue(guaranteeDate);
      } else {
        fieldGuaranteeDate.setValue(asiTemplate.getGuaranteeDate());
      }
      centerPanel.add(label, new ALayoutConstraint(m_row++, 0));
      centerPanel.add(fieldGuaranteeDate, null);
      fieldGuaranteeDateDisplayed = true;
    } // GuaranteeDate

    // Make sure we have at least something to edit or something to select,
    // else there is no point in showing empty this window.
    if (m_row == 0) {
      throw new AdempiereException("@PAttributeNoInfo@");
    }

    //
    // New/Edit Window
    if (allowSelectExistingASI) {
      cbNewEdit.setSelected(isASITemplateNew);
      cmd_newEdit();
    }

    //
    // Attrribute Set Instance Description
    {
      final CLabel labelDescription = new CLabel(msgBL.translate(ctx, "Description"));
      labelDescription.setLabelFor(fieldDescription);
      fieldDescription.setText(asiTemplate.getDescription());
      fieldDescription.setEditable(false);
      centerPanel.add(labelDescription, new ALayoutConstraint(m_row++, 0));
      centerPanel.add(fieldDescription, null);
    }

    // Window usually to wide (??)
    {
      final Dimension dd = centerPanel.getPreferredSize();
      dd.width = Math.min(500, dd.width);
      centerPanel.setPreferredSize(dd);
    }
  } // initAttribute
  private CPanel generateRepositoriesPanel() {
    CPanel panel = new CPanel();
    panel.setLayout(new BorderLayout());

    CPanel topPanel = new CPanel();
    topPanel.setLayout(new GridBagLayout());
    panel.add(topPanel, BorderLayout.NORTH);

    locationsCombo = new CComboBox(P2.get().getRepositories());
    locationsCombo.addActionListener(this);
    locationLabel.setText(Msg.translate(Env.getCtx(), "Repositories"));
    locationLabel.setLabelFor(locationsCombo);

    topPanel.add(
        locationLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            0,
            0));
    topPanel.add(
        locationsCombo,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.3,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(2, 2, 2, 20),
            0,
            0));

    repositoryBtn = new CButton(Msg.getMsg(ctx, "Manage Repositories"));
    repositoryBtn.addActionListener(this);

    topPanel.add(
        repositoryBtn,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(10, 1, 2, 100),
            0,
            0));

    CPanel tablePanel = new CPanel();
    panel.add(tablePanel, BorderLayout.CENTER);

    // Available iu
    repoAppsList = new BasicEventList<IUnitModel>();
    FilterList<IUnitModel> repoFilterList = new FilterList<IUnitModel>(repoAppsList);
    EventTableModel<IUnitModel> tepoTableModel =
        new EventTableModel<IUnitModel>(repoFilterList, new IUnitTableFormat());
    table = new JTable(tepoTableModel);
    tablePanel.add(new JScrollPane(table));

    CPanel btnPanel = new CPanel();
    panel.add(btnPanel, BorderLayout.SOUTH);

    installBtn = new CButton(Msg.getMsg(Env.getAD_Language(ctx), "Install"));
    installBtn.addActionListener(this);
    btnPanel.add(installBtn);

    return panel;
  }
Beispiel #10
0
  /** Descripción de Método */
  private void dynInit() {
    createMenu();

    //              comboZoom.addActionListener(this);
    // Change Listener to set Page no

    // centerScrollPane.getViewport().addChangeListener( this );

    // Max Page

    m_pageMax = m_viewPanel.getPageCount();
    spinnerModel.setMaximum(new Integer(m_pageMax));
    spinner.addChangeListener(this);
    fillComboReport(m_reportEngine.getPrintFormat().getID());

    // View Panel Mouse Listener

    m_viewPanel.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e)) {
              mouse_clicked(e, true);
            } else if (e.getClickCount() > 1) {
              mouse_clicked(e, false);
            }
          }
        });

    // fill Drill Options (Name, TableName)

    comboDrill.addItem(new ValueNamePair(null, ""));

    String sql =
        "SELECT t.AD_Table_ID, t.TableName, e.PrintName, NULLIF(e.PO_PrintName,e.PrintName) "
            + "FROM AD_Column c "
            + " INNER JOIN AD_Column used ON (c.ColumnName=used.ColumnName)"
            + " INNER JOIN AD_Table t ON (used.AD_Table_ID=t.AD_Table_ID AND t.IsView='N' AND t.AD_Table_ID <> c.AD_Table_ID)"
            + " INNER JOIN AD_Column cKey ON (t.AD_Table_ID=cKey.AD_Table_ID AND cKey.IsKey='Y')"
            + " INNER JOIN AD_Element e ON (cKey.ColumnName=e.ColumnName) "
            + "WHERE c.AD_Table_ID=? AND c.IsKey='Y' "
            + "ORDER BY 3";
    boolean trl = !Env.isBaseLanguage(Env.getCtx(), "AD_Element");

    if (trl) {
      sql =
          "SELECT t.AD_Table_ID, t.TableName, et.PrintName, NULLIF(et.PO_PrintName,et.PrintName) "
              + "FROM AD_Column c"
              + " INNER JOIN AD_Column used ON (c.ColumnName=used.ColumnName)"
              + " INNER JOIN AD_Table t ON (used.AD_Table_ID=t.AD_Table_ID AND t.IsView='N' AND t.AD_Table_ID <> c.AD_Table_ID)"
              + " INNER JOIN AD_Column cKey ON (t.AD_Table_ID=cKey.AD_Table_ID AND cKey.IsKey='Y')"
              + " INNER JOIN AD_Element e ON (cKey.ColumnName=e.ColumnName)"
              + " INNER JOIN AD_Element_Trl et ON (e.AD_Element_ID=et.AD_Element_ID) "
              + "WHERE c.AD_Table_ID=? AND c.IsKey='Y'"
              + " AND et.AD_Language=? "
              + "ORDER BY 3";
    }

    try {
      PreparedStatement pstmt = DB.prepareStatement(sql);

      pstmt.setInt(1, m_reportEngine.getPrintFormat().getAD_Table_ID());

      if (trl) {
        pstmt.setString(2, Env.getAD_Language(Env.getCtx()));
      }

      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        String tableName = rs.getString(2);
        String name = rs.getString(3);
        String poName = rs.getString(4);

        if (poName != null) {
          name += "/" + poName;
        }

        comboDrill.addItem(new ValueNamePair(tableName, name));
      }

      rs.close();
      pstmt.close();
    } catch (SQLException e) {
      log.log(Level.SEVERE, "Drill", e);
    }

    if (comboDrill.getItemCount() == 1) {
      labelDrill.setVisible(false);
      comboDrill.setVisible(false);
    } else {
      comboDrill.addActionListener(this);
    }

    revalidate();
  } // dynInit