Search in sources :

Example 36 with ValueNamePair

use of org.compiere.util.ValueNamePair in project adempiere by adempiere.

the class Viewer method cmd_translate.

//	cmd_zoom
/**
	 * 	Show Translation Dialog.
	 *  Translate base table entry, will be copied to trl tables if not multi-lingual
	 */
private void cmd_translate() {
    ArrayList<ValueNamePair> list = new ArrayList<ValueNamePair>();
    ValueNamePair pp = null;
    String sql = "SELECT Name, AD_Language FROM AD_Language WHERE IsSystemLanguage='Y' ORDER BY 1";
    try {
        PreparedStatement pstmt = DB.prepareStatement(sql, null);
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) list.add(new ValueNamePair(rs.getString(2), rs.getString(1)));
        rs.close();
        pstmt.close();
    } catch (SQLException e) {
        log.log(Level.SEVERE, sql, e);
    }
    if (list.size() == 0) {
        ADialog.warn(m_WindowNo, this, "NoTranslation");
        return;
    }
    //	Dialog
    String title = Msg.getMsg(Env.getCtx(), "PrintFormatTrl", true);
    String message = Msg.getMsg(Env.getCtx(), "PrintFormatTrl", false);
    int choice = JOptionPane.showOptionDialog(this, message, title, JOptionPane.OK_OPTION, JOptionPane.QUESTION_MESSAGE, null, list.toArray(), null);
    if (choice == JOptionPane.CLOSED_OPTION)
        return;
    //
    pp = (ValueNamePair) list.get(choice);
    String AD_Language = pp.getValue();
    int AD_PrintFormat_ID = m_reportEngine.getPrintFormat().get_ID();
    log.config(AD_Language + " - AD_PrintFormat_ID=" + AD_PrintFormat_ID);
    StringBuffer sb = new StringBuffer();
    //	English
    if (Language.isBaseLanguage(AD_Language)) {
        sb.append("UPDATE AD_PrintFormatItem pfi " + "SET Name = (SELECT e.Name FROM AD_Element e, AD_Column c" + " WHERE e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID)," + "PrintName = (SELECT e.PrintName FROM AD_Element e, AD_Column c" + " WHERE e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID) " + "WHERE AD_PrintFormat_ID=").append(AD_PrintFormat_ID).append(" AND EXISTS (SELECT * FROM AD_Element e, AD_Column c" + " WHERE e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID)");
    } else {
        AD_Language = "'" + AD_Language + "'";
        sb.append("UPDATE AD_PrintFormatItem pfi " + "SET Name = (SELECT e.Name FROM AD_Element_Trl e, AD_Column c" + " WHERE e.AD_Language=").append(AD_Language).append(" AND e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID), " + "PrintName = (SELECT e.PrintName FROM AD_Element_Trl e, AD_Column c" + "	WHERE e.AD_Language=").append(AD_Language).append(" AND e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID) " + "WHERE AD_PrintFormat_ID=").append(AD_PrintFormat_ID).append(" AND EXISTS (SELECT * FROM AD_Element_Trl e, AD_Column c" + " WHERE e.AD_Language=").append(AD_Language).append(" AND e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID)");
    }
    int count = DB.executeUpdate(sb.toString(), null);
    log.config("Count=" + count);
    //
    m_reportEngine.setPrintFormat(MPrintFormat.get(Env.getCtx(), AD_PrintFormat_ID, true));
    revalidate();
}
Also used : SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) ValueNamePair(org.compiere.util.ValueNamePair) Point(java.awt.Point)

Example 37 with ValueNamePair

use of org.compiere.util.ValueNamePair in project adempiere by adempiere.

the class Viewer method dynInit.

//	jbInit
/**
	 * 	Dynamic Init
	 */
private void dynInit() {
    createMenu();
    comboZoom.setSelectedIndex(m_viewPanel.getZoomLevel());
    comboZoom.addActionListener(this);
    //	Change Listener to set Page no
    //pb comment this out so that scrolling works normally
    //centerScrollPane.getViewport().addChangeListener(this);
    // end pb
    //	Default summary from print format
    summary.setSelected(m_reportEngine.getPrintFormat().isSummary());
    //FR 201156
    summary.addActionListener(this);
    //	Max Page
    m_pageMax = m_viewPanel.getPageCount();
    spinnerModel.setMaximum(new Integer(m_pageMax));
    spinner.addChangeListener(this);
    fillComboReport(m_reportEngine.getPrintFormat().get_ID());
    //	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, null);
        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, sql, e);
    }
    if (comboDrill.getItemCount() == 1) {
        labelDrill.setVisible(false);
        comboDrill.setVisible(false);
    } else
        comboDrill.addActionListener(this);
    revalidate();
}
Also used : MouseEvent(java.awt.event.MouseEvent) SQLException(java.sql.SQLException) MouseAdapter(java.awt.event.MouseAdapter) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) ValueNamePair(org.compiere.util.ValueNamePair)

Example 38 with ValueNamePair

use of org.compiere.util.ValueNamePair in project adempiere by adempiere.

the class TranslationController method getTableList.

public ArrayList<ValueNamePair> getTableList() {
    ArrayList<ValueNamePair> list = new ArrayList<ValueNamePair>();
    //	Fill Table
    list.add(new ValueNamePair("", ""));
    String sql = "SELECT Name, TableName " + "FROM AD_Table " + "WHERE TableName LIKE '%_Trl' AND TableName<>'AD_Column_Trl' " + "ORDER BY Name";
    try {
        PreparedStatement pstmt = DB.prepareStatement(sql, null);
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            ValueNamePair vp = new ValueNamePair(rs.getString(2), rs.getString(1));
            list.add(vp);
        }
        rs.close();
        pstmt.close();
    } catch (SQLException e) {
        log.log(Level.SEVERE, sql, e);
    }
    return list;
}
Also used : SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) ValueNamePair(org.compiere.util.ValueNamePair)

Example 39 with ValueNamePair

use of org.compiere.util.ValueNamePair in project adempiere by adempiere.

the class TranslationController method getLanguageList.

public ArrayList<ValueNamePair> getLanguageList() {
    ArrayList<ValueNamePair> list = new ArrayList<ValueNamePair>();
    //	Fill Language
    String sql = "SELECT Name, AD_Language " + "FROM AD_Language " + "WHERE IsActive='Y' AND (IsSystemLanguage='Y' OR IsBaseLanguage='Y')" + "ORDER BY Name";
    try {
        PreparedStatement pstmt = DB.prepareStatement(sql, null);
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            ValueNamePair vp = new ValueNamePair(rs.getString(2), rs.getString(1));
            list.add(vp);
        }
        rs.close();
        pstmt.close();
    } catch (SQLException e) {
        log.log(Level.SEVERE, sql, e);
    }
    return list;
}
Also used : SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) ValueNamePair(org.compiere.util.ValueNamePair)

Example 40 with ValueNamePair

use of org.compiere.util.ValueNamePair in project adempiere by adempiere.

the class VTranslationDialog method dynInit.

//	jbInit
/**
	 * 	Dynamic Init.
	 * 	- fill Language & Table
	 */
private void dynInit() {
    //	Fill Client
    ArrayList<KeyNamePair> clients = getClientList();
    for (KeyNamePair client : clients) cbClient.addItem(client);
    //	Fill Language
    ArrayList<ValueNamePair> languages = getLanguageList();
    for (ValueNamePair language : languages) cbLanguage.addItem(language);
    //	Fill Table
    ArrayList<ValueNamePair> tables = getTableList();
    for (ValueNamePair table : tables) cbTable.addItem(table);
    //	Info
    setStatusBar(statusBar);
}
Also used : KeyNamePair(org.compiere.util.KeyNamePair) ValueNamePair(org.compiere.util.ValueNamePair)

Aggregations

ValueNamePair (org.compiere.util.ValueNamePair)109 KeyNamePair (org.compiere.util.KeyNamePair)35 SQLException (java.sql.SQLException)22 ArrayList (java.util.ArrayList)22 PreparedStatement (java.sql.PreparedStatement)20 ResultSet (java.sql.ResultSet)19 Timestamp (java.sql.Timestamp)9 GridField (org.compiere.model.GridField)7 BigDecimal (java.math.BigDecimal)5 MetalLookAndFeel (javax.swing.plaf.metal.MetalLookAndFeel)5 MetalTheme (javax.swing.plaf.metal.MetalTheme)5 MInvoice (org.compiere.model.MInvoice)5 MLookup (org.compiere.model.MLookup)5 MLookupInfo (org.compiere.model.MLookupInfo)5 HRPayPrint (org.eevolution.service.HRPayPrint)5 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)4 ListItem (org.adempiere.webui.component.ListItem)4 MCashLine (org.compiere.model.MCashLine)4 AdempiereUserError (org.compiere.util.AdempiereUserError)4 NamePair (org.compiere.util.NamePair)4