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); } }
/** * 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); } }