Search in sources :

Example 61 with ValueNamePair

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

the class PLAFEditor method setLFSelection.

//  dynInit
/**
	 *  Set Picks From Environment
	 */
private void setLFSelection() {
    m_setting = true;
    //  Search for PLAF
    ValueNamePair plaf = null;
    LookAndFeel lookFeel = UIManager.getLookAndFeel();
    String look = lookFeel.getClass().getName();
    for (int i = 0; i < AdempierePLAF.getPLAFs().length; i++) {
        ValueNamePair vp = AdempierePLAF.getPLAFs()[i];
        if (vp.getValue().equals(look)) {
            plaf = vp;
            break;
        }
    }
    if (plaf != null)
        lfField.setSelectedItem(plaf);
    //  Search for Theme
    MetalTheme metalTheme = null;
    ValueNamePair theme = null;
    boolean metal = UIManager.getLookAndFeel() instanceof MetalLookAndFeel;
    themeField.setModel(new DefaultComboBoxModel(AdempierePLAF.getThemes()));
    if (metal) {
        theme = null;
        AppContext context = AppContext.getAppContext();
        metalTheme = (MetalTheme) context.get("currentMetalTheme");
        if (metalTheme != null) {
            String lookTheme = metalTheme.getName();
            for (int i = 0; i < AdempierePLAF.getThemes().length; i++) {
                ValueNamePair vp = AdempierePLAF.getThemes()[i];
                if (vp.getName().equals(lookTheme)) {
                    theme = vp;
                    break;
                }
            }
        }
        if (theme != null)
            themeField.setSelectedItem(theme);
    }
    m_setting = false;
    log.info(lookFeel + " - " + metalTheme);
}
Also used : MetalTheme(javax.swing.plaf.metal.MetalTheme) AppContext(sun.awt.AppContext) ValueNamePair(org.compiere.util.ValueNamePair) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel) LookAndFeel(javax.swing.LookAndFeel) CompiereLookAndFeel(org.compiere.plaf.CompiereLookAndFeel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel)

Example 62 with ValueNamePair

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

the class PreviewPanel method lookAndFeelSelectionChanged.

/**
	 * Handle look and feel selection changed
	 * @param e
	 */
protected void lookAndFeelSelectionChanged(ListSelectionEvent e) {
    if (m_setting)
        return;
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    ValueNamePair laf = (ValueNamePair) lookList.getSelectedValue();
    LookAndFeel currentLaf = UIManager.getLookAndFeel();
    MetalTheme currentTheme = MetalLookAndFeel.getCurrentTheme();
    AdempierePLAF.setPLAF(laf, null, false);
    previewPanel.refresh(currentLaf, currentTheme);
    SwingUtilities.updateComponentTreeUI(previewPanel);
    updatePreviewComponents();
    setLFSelection();
    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    this.repaint();
}
Also used : MetalTheme(javax.swing.plaf.metal.MetalTheme) ValueNamePair(org.compiere.util.ValueNamePair) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel) LookAndFeel(javax.swing.LookAndFeel)

Example 63 with ValueNamePair

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

the class PreviewPanel method themeSelectionChanged.

/**
	 * Handle theme selection changed
	 * @param e
	 */
protected void themeSelectionChanged(ListSelectionEvent e) {
    if (m_setting)
        return;
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    ValueNamePair laf = (ValueNamePair) lookList.getSelectedValue();
    ValueNamePair theme = (ValueNamePair) themeList.getSelectedValue();
    LookAndFeel currentLaf = UIManager.getLookAndFeel();
    MetalTheme currentTheme = MetalLookAndFeel.getCurrentTheme();
    AdempierePLAF.setPLAF(laf, theme, false);
    previewPanel.refresh(currentLaf, currentTheme);
    SwingUtilities.updateComponentTreeUI(previewPanel);
    updatePreviewComponents();
    setLFSelection();
    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    this.repaint();
}
Also used : MetalTheme(javax.swing.plaf.metal.MetalTheme) ValueNamePair(org.compiere.util.ValueNamePair) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel) LookAndFeel(javax.swing.LookAndFeel)

Example 64 with ValueNamePair

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

the class PO method saveEx.

//	save
/**
	 * Update Value or create new record.
	 * @throws AdempiereException
	 * @see #save()
	 */
public void saveEx() throws AdempiereException {
    if (!save()) {
        String msg = null;
        ValueNamePair err = CLogger.retrieveError();
        if (err != null)
            msg = err.getName();
        if (msg == null || msg.length() == 0)
            msg = "SaveError";
        throw new AdempiereException(msg);
    }
}
Also used : AdempiereException(org.adempiere.exceptions.AdempiereException) ValueNamePair(org.compiere.util.ValueNamePair)

Example 65 with ValueNamePair

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

the class VLookupAutoCompleter method setUserObject.

@Override
public void setUserObject(Object userObject) {
    String textOld = textBox.getText();
    int caretPosition = textBox.getCaretPosition();
    //
    super.setUserObject(userObject);
    // Object valueOld = editor.getValue();
    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.actionCombo(value);
    if (value == null) {
        textBox.setText(textOld);
        textBox.setCaretPosition(caretPosition);
    }
}
Also used : ValueNamePair(org.compiere.util.ValueNamePair) KeyNamePair(org.compiere.util.KeyNamePair)

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