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);
}
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();
}
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();
}
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);
}
}
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);
}
}
Aggregations