Search in sources :

Example 16 with Comboitem

use of org.zkoss.zul.Comboitem in project adempiere by adempiere.

the class RolePanel method validateRoles.

/**
     *  validate Roles
     *
    **/
public void validateRoles() {
    Comboitem lstItemRole = lstRole.getSelectedItem();
    Comboitem lstItemClient = lstClient.getSelectedItem();
    Comboitem lstItemOrg = lstOrganisation.getSelectedItem();
    Comboitem lstItemWarehouse = lstWarehouse.getSelectedItem();
    if (lstItemRole == null || lstItemRole.getValue() == null) {
        throw new WrongValueException(lstRole, Msg.getMsg(m_ctx, "FillMandatory") + lblRole.getValue());
    } else if (lstItemClient == null || lstItemClient.getValue() == null) {
        throw new WrongValueException(lstClient, Msg.getMsg(m_ctx, "FillMandatory") + lblClient.getValue());
    } else if (lstItemOrg == null || lstItemOrg.getValue() == null) {
        throw new WrongValueException(lstOrganisation, Msg.getMsg(m_ctx, "FillMandatory") + lblOrganisation.getValue());
    }
    int orgId = 0, warehouseId = 0;
    orgId = Integer.parseInt((String) lstItemOrg.getValue());
    KeyNamePair orgKNPair = new KeyNamePair(orgId, lstItemOrg.getLabel());
    KeyNamePair warehouseKNPair = null;
    if (lstItemWarehouse != null && lstItemWarehouse.getValue() != null) {
        warehouseId = Integer.parseInt((String) lstItemWarehouse.getValue());
        warehouseKNPair = new KeyNamePair(warehouseId, lstItemWarehouse.getLabel());
    }
    String msg = login.validateLogin(orgKNPair);
    if (msg != null && msg.length() > 0) {
        throw new WrongValueException(msg);
    }
    msg = login.loadPreferences(orgKNPair, warehouseKNPair, null, null);
    if (!(msg == null || msg.length() == 0)) {
        throw new WrongValueException(msg);
    }
    wndLogin.loginCompleted();
    // Elaine 2009/02/06 save preference to AD_Preference
    UserPreference userPreference = SessionManager.getSessionApplication().getUserPreference();
    userPreference.setProperty(UserPreference.P_LANGUAGE, Env.getContext(m_ctx, UserPreference.LANGUAGE_NAME));
    userPreference.setProperty(UserPreference.P_ROLE, lstItemRole != null ? (String) lstItemRole.getValue() : "0");
    userPreference.setProperty(UserPreference.P_CLIENT, lstItemClient != null ? (String) lstItemClient.getValue() : "0");
    userPreference.setProperty(UserPreference.P_ORG, lstItemOrg != null ? (String) lstItemOrg.getValue() : "0");
    userPreference.setProperty(UserPreference.P_WAREHOUSE, lstItemWarehouse != null ? (String) lstItemWarehouse.getValue() : "0");
    userPreference.savePreference();
//
}
Also used : Comboitem(org.zkoss.zul.Comboitem) UserPreference(org.adempiere.webui.util.UserPreference) KeyNamePair(org.compiere.util.KeyNamePair) WrongValueException(org.zkoss.zk.ui.WrongValueException)

Example 17 with Comboitem

use of org.zkoss.zul.Comboitem in project adempiere by adempiere.

the class LoginPanel method initComponents.

private void initComponents() {
    lblUserId = new Label();
    lblUserId.setId("lblUserId");
    lblUserId.setValue("User ID");
    lblPassword = new Label();
    lblPassword.setId("lblPassword");
    lblPassword.setValue("Password");
    lblLanguage = new Label();
    lblLanguage.setId("lblLanguage");
    lblLanguage.setValue("Language");
    txtUserId = new Textbox();
    txtUserId.setId("txtUserId");
    //txtUserId.setCols(25);
    txtUserId.setMaxlength(40);
    //txtUserId.setWidth("220px");
    // Elaine 2009/02/06
    txtUserId.addEventListener(Events.ON_CHANGE, this);
    txtPassword = new Textbox();
    txtPassword.setId("txtPassword");
    txtPassword.setType("password");
    //txtPassword.setCols(25);
    //txtPassword.setWidth("220px");
    lstLanguage = new Combobox();
    lstLanguage.setAutocomplete(true);
    lstLanguage.setAutodrop(true);
    lstLanguage.setId("lstLanguage");
    lstLanguage.addEventListener(Events.ON_SELECT, this);
    //lstLanguage.setWidth("220px");
    // Update Language List
    lstLanguage.getItems().clear();
    ArrayList<String> supported = Env.getSupportedLanguages();
    String[] availableLanguages = Language.getNames();
    for (String langName : availableLanguages) {
        Language language = Language.getLanguage(langName);
        if (!language.isBaseLanguage()) {
            if (!supported.contains(language.getAD_Language()))
                continue;
        }
        lstLanguage.appendItem(langName, language.getAD_Language());
    }
    chkRememberMe = new Checkbox(Msg.getMsg(Language.getBaseAD_Language(), "RememberMe"));
    chkRememberMe.setId("chkRememberMe");
    // Make the default language the language of client System
    String defaultLanguage = MClient.get(ctx, 0).getAD_Language();
    for (int i = 0; i < lstLanguage.getItemCount(); i++) {
        Comboitem li = lstLanguage.getItemAtIndex(i);
        if (li.getValue().equals(defaultLanguage)) {
            lstLanguage.setSelectedIndex(i);
            languageChanged(li.getLabel());
            break;
        }
    }
}
Also used : Language(org.compiere.util.Language) Combobox(org.adempiere.webui.component.Combobox) Checkbox(org.zkoss.zul.Checkbox) Label(org.adempiere.webui.component.Label) Textbox(org.adempiere.webui.component.Textbox) Comboitem(org.zkoss.zul.Comboitem)

Example 18 with Comboitem

use of org.zkoss.zul.Comboitem in project adempiere by adempiere.

the class WTableDirEditor method onEvent.

public void onEvent(Event event) {
    if (Events.ON_SELECT.equalsIgnoreCase(event.getName())) {
        Object newValue = getValue();
        if (isValueChange(newValue)) {
            ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
            super.fireValueChange(changeEvent);
        }
    } else if (Events.ON_BLUR.equalsIgnoreCase(event.getName())) {
        Comboitem item = getComponent().getSelectedItem();
        if (item == null) {
            setValue(oldValue);
        } else {
            //on select not fire for empty label item
            if (item.getLabel().equals("")) {
                Object newValue = getValue();
                if (isValueChange(newValue)) {
                    ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
                    super.fireValueChange(changeEvent);
                    oldValue = newValue;
                }
            }
        }
    }
}
Also used : ValueChangeEvent(org.adempiere.exceptions.ValueChangeEvent) Comboitem(org.zkoss.zul.Comboitem)

Example 19 with Comboitem

use of org.zkoss.zul.Comboitem in project adempiere by adempiere.

the class WTableDirEditor method getValue.

@Override
public Object getValue() {
    Object retVal = null;
    Comboitem selItem = getComponent().getSelectedItem();
    if (selItem != null) {
        retVal = selItem.getValue();
        if ((retVal instanceof Integer) && (Integer) retVal == -1)
            retVal = null;
    }
    return retVal;
}
Also used : Comboitem(org.zkoss.zul.Comboitem)

Example 20 with Comboitem

use of org.zkoss.zul.Comboitem in project adempiere by adempiere.

the class WTableDirEditor method getDisplay.

@Override
public String getDisplay() {
    String display = null;
    Comboitem selItem = getComponent().getSelectedItem();
    if (selItem != null) {
        display = selItem.getLabel();
    }
    return display;
}
Also used : Comboitem(org.zkoss.zul.Comboitem)

Aggregations

Comboitem (org.zkoss.zul.Comboitem)21 UserPreference (org.adempiere.webui.util.UserPreference)5 Iterator (java.util.Iterator)4 HttpClient (org.apache.commons.httpclient.HttpClient)4 GetMethod (org.apache.commons.httpclient.methods.GetMethod)4 KeyNamePair (org.compiere.util.KeyNamePair)4 JSONArray (org.json.simple.JSONArray)4 JSONObject (org.json.simple.JSONObject)4 JSONParser (org.json.simple.parser.JSONParser)4 ComboItem (org.adempiere.webui.component.ComboItem)3 MapLayer (au.org.emii.portal.menu.MapLayer)2 WrongValueException (org.zkoss.zk.ui.WrongValueException)2 FieldDTO (au.org.ala.spatial.dto.FieldDTO)1 LayerSelection (au.org.ala.spatial.util.LayerSelection)1 ValueChangeEvent (org.adempiere.exceptions.ValueChangeEvent)1 Combobox (org.adempiere.webui.component.Combobox)1 Label (org.adempiere.webui.component.Label)1 Textbox (org.adempiere.webui.component.Textbox)1 Language (org.compiere.util.Language)1 Event (org.zkoss.zk.ui.event.Event)1