Search in sources :

Example 41 with ValueNamePair

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

the class WSearchEditorAutoComplete method setUserObject.

@Override
public void setUserObject(Object userObject) {
    String textOld = getText();
    //
    super.setUserObject(userObject);
    //
    Object value = null;
    if (userObject == null) {
        editor.setValue(null);
    } else if (userObject instanceof ValueNamePair) {
        ValueNamePair vnp = (ValueNamePair) userObject;
        value = vnp.getValue();
    } else if (userObject instanceof KeyNamePair) {
        KeyNamePair knp = (KeyNamePair) userObject;
        value = knp.getKey();
    } else {
        log.warning("Not supported - " + userObject + ", class=" + userObject.getClass());
        return;
    }
    editor.setValue(value);
    if (value == null) {
        setText(textOld);
    }
}
Also used : ValueNamePair(org.compiere.util.ValueNamePair) KeyNamePair(org.compiere.util.KeyNamePair)

Example 42 with ValueNamePair

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

the class WSearchEditorAutoComplete method fetchUserObject.

@Override
protected Object fetchUserObject(ResultSet rs) throws SQLException {
    final boolean isNumber = lookup.getColumnName().endsWith("_ID");
    String name = rs.getString(3);
    if (isNumber) {
        int key = rs.getInt(1);
        KeyNamePair p = new KeyNamePair(key, name);
        return p;
    } else {
        String value = rs.getString(2);
        ValueNamePair p = new ValueNamePair(value, name);
        return p;
    }
}
Also used : KeyNamePair(org.compiere.util.KeyNamePair) ValueNamePair(org.compiere.util.ValueNamePair)

Example 43 with ValueNamePair

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

the class AdempierePLAF method setPLAF.

//  getThemes
/**************************************************************************
	 *  Set PLAF based on Ini Properties
	 */
public static void setPLAF() {
    String look = Ini.getProperty(Ini.P_UI_LOOK);
    String lookTheme = Ini.getProperty(Ini.P_UI_THEME);
    //  Search for PLAF
    ValueNamePair plaf = null;
    for (int i = 0; i < s_looks.length; i++) {
        if (s_looks[i].getName().equals(look)) {
            plaf = s_looks[i];
            break;
        }
    }
    //  Search for Theme
    ValueNamePair theme = null;
    for (int i = 0; i < s_metalThemes.length; i++) {
        if (s_metalThemes[i].getName().equals(lookTheme)) {
            theme = s_metalThemes[i];
            break;
        }
    }
    if (theme == null) {
        for (int i = 0; i < s_plasticThemes.length; i++) {
            if (s_plasticThemes[i].getName().equals(lookTheme)) {
                theme = s_plasticThemes[i];
                break;
            }
        }
    }
    //  Set PLAF
    setPLAF(plaf == null ? s_defaultPLAF : plaf, theme, true);
}
Also used : ValueNamePair(org.compiere.util.ValueNamePair)

Example 44 with ValueNamePair

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

the class WFActivity method cmd_OK.

//	cmd_button
/**
	 * 	Save
	 */
private void cmd_OK() {
    log.config("Activity=" + m_activity);
    if (m_activity == null)
        return;
    int AD_User_ID = Env.getAD_User_ID(Env.getCtx());
    String textMsg = fTextMsg.getText();
    //
    MWFNode node = m_activity.getNode();
    Object forward = fForward.getValue();
    // ensure activity is ran within a transaction - [ 1953628 ]
    Trx trx = Trx.get(Trx.createTrxName("FWFA"), true);
    m_activity.set_TrxName(trx.getTrxName());
    if (forward != null) {
        log.config("Forward to " + forward);
        int fw = ((Integer) forward).intValue();
        if (fw == AD_User_ID || fw == 0) {
            log.log(Level.SEVERE, "Forward User=" + fw);
            trx.rollback();
            trx.close();
            return;
        }
        if (!m_activity.forwardTo(fw, textMsg)) {
            ADialog.error(m_WindowNo, this, "CannotForward");
            trx.rollback();
            trx.close();
            return;
        }
    } else //	User Choice - Answer
    if (MWFNode.ACTION_UserChoice.equals(node.getAction())) {
        if (m_column == null)
            m_column = node.getColumn();
        //	Do we have an answer?
        int dt = m_column.getAD_Reference_ID();
        String value = fAnswerText.getText();
        if (dt == DisplayType.YesNo || dt == DisplayType.List) {
            ValueNamePair pp = (ValueNamePair) fAnswerList.getSelectedItem();
            value = pp.getValue();
        }
        if (value == null || value.length() == 0) {
            ADialog.error(m_WindowNo, this, "FillMandatory", Msg.getMsg(Env.getCtx(), "Answer"));
            trx.rollback();
            trx.close();
            return;
        }
        //
        log.config("Answer=" + value + " - " + textMsg);
        try {
            m_activity.setUserChoice(AD_User_ID, value, dt, textMsg);
        } catch (Exception e) {
            log.log(Level.SEVERE, node.getName(), e);
            ADialog.error(m_WindowNo, this, "Error", e.toString());
            trx.rollback();
            trx.close();
            return;
        }
    } else //	User Action
    {
        log.config("Action=" + node.getAction() + " - " + textMsg);
        try {
            // ensure activity is ran within a transaction
            m_activity.setUserConfirmation(AD_User_ID, textMsg);
        } catch (Exception e) {
            log.log(Level.SEVERE, node.getName(), e);
            ADialog.error(m_WindowNo, this, "Error", e.toString());
            trx.rollback();
            trx.close();
            return;
        }
    }
    trx.commit();
    trx.close();
    this.setCursor(Cursor.getDefaultCursor());
    ADialog.info(m_WindowNo, this, "WorkflowResult", Msg.parseTranslation(Env.getCtx(), "@AD_WF_Node_ID@") + " : " + m_activity.getNodeName() + " -> " + m_activity.getTextMsg());
    //	Next
    loadActivities();
}
Also used : MWFNode(org.compiere.wf.MWFNode) Trx(org.compiere.util.Trx) ValueNamePair(org.compiere.util.ValueNamePair)

Example 45 with ValueNamePair

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

the class WFActivity method display.

//	loadActivities
/**
	 * 	Display.
	 * 	@param index index of table
	 * 	Fill Editors
	 */
public void display(IDColumn id) {
    log.fine("ID=" + id);
    m_activity = resetDisplay(id);
    //
    if (m_menu != null) {
        m_menu.updateActivities(selTable.getModel().getRowCount());
    }
    if (m_activity == null)
        return;
    //	Display Activity
    fNode.setText(m_activity.getNodeName());
    fDescription.setText(m_activity.getNodeDescription());
    fHelp.setText(m_activity.getNodeHelp());
    //
    fHistory.setText(m_activity.getHistoryHTML());
    //	User Actions
    MWFNode node = m_activity.getNode();
    if (MWFNode.ACTION_UserChoice.equals(node.getAction())) {
        if (m_column == null)
            m_column = node.getColumn();
        if (m_column != null && m_column.get_ID() != 0) {
            int dt = m_column.getAD_Reference_ID();
            if (dt == DisplayType.YesNo) {
                //	_YesNo
                ValueNamePair[] values = MRefList.getList(Env.getCtx(), 319, false);
                fAnswerList.setModel(new DefaultComboBoxModel(values));
                fAnswerList.setVisible(true);
            } else if (dt == DisplayType.List) {
                ValueNamePair[] values = MRefList.getList(Env.getCtx(), m_column.getAD_Reference_Value_ID(), false);
                fAnswerList.setModel(new DefaultComboBoxModel(values));
                fAnswerList.setVisible(true);
            } else //	other display types come here
            {
                fAnswerText.setText("");
                fAnswerText.setVisible(true);
            }
        }
    } else //	--
    if (MWFNode.ACTION_UserWindow.equals(node.getAction()) || MWFNode.ACTION_UserForm.equals(node.getAction())) {
        fAnswerButton.setText(node.getName());
        fAnswerButton.setToolTipText(node.getDescription());
        fAnswerButton.setVisible(true);
    } else
        /*
		else if (MWFNode.ACTION_UserWorkbench.equals(node.getAction()))
			log.log(Level.SEVERE, "Workflow Action not implemented yet"); */
        log.log(Level.SEVERE, "Unknown Node Action: " + node.getAction());
    statusBar.setStatusDB(String.valueOf(selTable.getSelectedRow() + 1) + "/" + selTable.getRowCount());
    statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "WFActivities"));
}
Also used : MWFNode(org.compiere.wf.MWFNode) ValueNamePair(org.compiere.util.ValueNamePair) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

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