Search in sources :

Example 1 with ComboItem

use of org.adempiere.webui.component.ComboItem in project adempiere by adempiere.

the class RolePanel method updateWarehouseList.

private void updateWarehouseList() {
    lstWarehouse.getItems().clear();
    lstWarehouse.setText("");
    Comboitem lstItemOrganisation = lstOrganisation.getSelectedItem();
    if (lstItemOrganisation != null) {
        //  initial warehouse - Elaine 2009/02/06
        UserPreference userPreference = SessionManager.getSessionApplication().getUserPreference();
        String initDefault = userPreference.getProperty(UserPreference.P_WAREHOUSE);
        KeyNamePair organisationKNPair = new KeyNamePair(new Integer((String) lstItemOrganisation.getValue()), lstItemOrganisation.getLabel());
        KeyNamePair[] warehouseKNPairs = login.getWarehouses(organisationKNPair);
        if (warehouseKNPairs != null && warehouseKNPairs.length > 0) {
            for (int i = 0; i < warehouseKNPairs.length; i++) {
                ComboItem ci = new ComboItem(warehouseKNPairs[i].getName(), warehouseKNPairs[i].getID());
                lstWarehouse.appendChild(ci);
                if (warehouseKNPairs[i].getID().equals(initDefault))
                    lstWarehouse.setSelectedItem(ci);
            }
            if (lstWarehouse.getSelectedIndex() == -1 && lstWarehouse.getItemCount() > 0)
                lstWarehouse.setSelectedIndex(0);
        }
    //
    }
}
Also used : Comboitem(org.zkoss.zul.Comboitem) UserPreference(org.adempiere.webui.util.UserPreference) KeyNamePair(org.compiere.util.KeyNamePair) ComboItem(org.adempiere.webui.component.ComboItem)

Example 2 with ComboItem

use of org.adempiere.webui.component.ComboItem in project adempiere by adempiere.

the class RolePanel method initComponents.

@SuppressWarnings("unchecked")
private void initComponents() {
    Language language = Env.getLanguage(m_ctx);
    ResourceBundle res = ResourceBundle.getBundle(RESOURCE, language.getLocale());
    lblRole = new Label();
    lblRole.setId("lblRole");
    lblRole.setValue(res.getString("Role"));
    lblClient = new Label();
    lblClient.setId("lblClient");
    lblClient.setValue(res.getString("Client"));
    lblOrganisation = new Label();
    lblOrganisation.setId("lblOrganisation");
    lblOrganisation.setValue(res.getString("Organization"));
    lblWarehouse = new Label();
    lblWarehouse.setId("lblWarehouse");
    lblWarehouse.setValue(res.getString("Warehouse"));
    lstRole = new Combobox();
    lstRole.setAutocomplete(true);
    lstRole.setAutodrop(true);
    lstRole.setId("lstRole");
    lstRole.addEventListener(Events.ON_SELECT, this);
    lstClient = new Combobox();
    lstClient.setAutocomplete(true);
    lstClient.setAutodrop(true);
    lstClient.setId("lstClient");
    lstClient.addEventListener(Events.ON_SELECT, this);
    lstOrganisation = new Combobox();
    lstOrganisation.setAutocomplete(true);
    lstOrganisation.setAutodrop(true);
    lstOrganisation.setId("lstOrganisation");
    lstOrganisation.addEventListener(Events.ON_SELECT, this);
    lstWarehouse = new Combobox();
    lstWarehouse.setAutocomplete(true);
    lstWarehouse.setAutodrop(true);
    lstWarehouse.setId("lstWarehouse");
    lstWarehouse.addEventListener(Events.ON_SELECT, this);
    btnOk = new Button();
    btnOk.setId("btnOk");
    btnOk.setLabel("Ok");
    btnOk.addEventListener("onClick", this);
    btnCancel = new Button();
    btnCancel.setId("btnCancel");
    btnCancel.setLabel("Cancel");
    btnCancel.addEventListener("onClick", this);
    // initial role - Elaine 2009/02/06
    UserPreference userPreference = SessionManager.getSessionApplication().getUserPreference();
    String initDefault = userPreference.getProperty(UserPreference.P_ROLE);
    for (int i = 0; i < rolesKNPairs.length; i++) {
        ComboItem ci = new ComboItem(rolesKNPairs[i].getName(), rolesKNPairs[i].getID());
        lstRole.appendChild(ci);
        if (rolesKNPairs[i].getID().equals(initDefault))
            lstRole.setSelectedItem(ci);
    }
    if (lstRole.getSelectedIndex() == -1 && lstRole.getItemCount() > 0)
        lstRole.setSelectedIndex(0);
    // If we have only one role, we can hide the combobox - metas-2009_0021_AP1_G94
    if (lstRole.getItemCount() == 1 && !MSysConfig.getBooleanValue("ALogin_ShowOneRole", true)) {
        lstRole.setSelectedIndex(0);
        lblRole.setVisible(false);
        lstRole.setVisible(false);
    } else {
        lblRole.setVisible(true);
        lstRole.setVisible(true);
    }
    updateClientList();
}
Also used : Language(org.compiere.util.Language) Button(org.zkoss.zul.Button) Combobox(org.adempiere.webui.component.Combobox) Label(org.adempiere.webui.component.Label) ResourceBundle(java.util.ResourceBundle) UserPreference(org.adempiere.webui.util.UserPreference) ComboItem(org.adempiere.webui.component.ComboItem)

Example 3 with ComboItem

use of org.adempiere.webui.component.ComboItem in project adempiere by adempiere.

the class RolePanel method updateOrganisationList.

private void updateOrganisationList() {
    lstOrganisation.getItems().clear();
    lstOrganisation.setText("");
    Comboitem lstItemClient = lstClient.getSelectedItem();
    if (lstItemClient != null) {
        //  initial organisation - Elaine 2009/02/06
        UserPreference userPreference = SessionManager.getSessionApplication().getUserPreference();
        String initDefault = userPreference.getProperty(UserPreference.P_ORG);
        KeyNamePair clientKNPair = new KeyNamePair(new Integer((String) lstItemClient.getValue()), lstItemClient.getLabel());
        KeyNamePair[] orgKNPairs = login.getOrgs(clientKNPair);
        if (orgKNPairs != null && orgKNPairs.length > 0) {
            for (int i = 0; i < orgKNPairs.length; i++) {
                ComboItem ci = new ComboItem(orgKNPairs[i].getName(), orgKNPairs[i].getID());
                lstOrganisation.appendChild(ci);
                if (orgKNPairs[i].getID().equals(initDefault))
                    lstOrganisation.setSelectedItem(ci);
            }
            if (lstOrganisation.getSelectedIndex() == -1 && lstOrganisation.getItemCount() > 0)
                lstOrganisation.setSelectedIndex(0);
        }
    //
    }
    updateWarehouseList();
}
Also used : Comboitem(org.zkoss.zul.Comboitem) UserPreference(org.adempiere.webui.util.UserPreference) KeyNamePair(org.compiere.util.KeyNamePair) ComboItem(org.adempiere.webui.component.ComboItem)

Example 4 with ComboItem

use of org.adempiere.webui.component.ComboItem in project adempiere by adempiere.

the class RolePanel method updateClientList.

private void updateClientList() {
    lstClient.getItems().clear();
    Comboitem lstItemRole = lstRole.getSelectedItem();
    if (lstItemRole != null) {
        //  initial client - Elaine 2009/02/06
        UserPreference userPreference = SessionManager.getSessionApplication().getUserPreference();
        String initDefault = userPreference.getProperty(UserPreference.P_CLIENT);
        KeyNamePair roleKNPair = new KeyNamePair(new Integer((String) lstItemRole.getValue()), lstItemRole.getLabel());
        KeyNamePair[] clientKNPairs = login.getClients(roleKNPair);
        if (clientKNPairs != null && clientKNPairs.length > 0) {
            for (int i = 0; i < clientKNPairs.length; i++) {
                ComboItem ci = new ComboItem(clientKNPairs[i].getName(), clientKNPairs[i].getID());
                lstClient.appendChild(ci);
                if (clientKNPairs[i].getID().equals(initDefault))
                    lstClient.setSelectedItem(ci);
            }
            if (lstClient.getSelectedIndex() == -1 && lstClient.getItemCount() > 0)
                lstClient.setSelectedIndex(0);
        }
        //
        //force reload of default role
        MRole.getDefault(m_ctx, true);
    }
    login.getRoles(m_userName, m_password);
    updateOrganisationList();
}
Also used : Comboitem(org.zkoss.zul.Comboitem) UserPreference(org.adempiere.webui.util.UserPreference) KeyNamePair(org.compiere.util.KeyNamePair) ComboItem(org.adempiere.webui.component.ComboItem)

Aggregations

ComboItem (org.adempiere.webui.component.ComboItem)4 UserPreference (org.adempiere.webui.util.UserPreference)4 KeyNamePair (org.compiere.util.KeyNamePair)3 Comboitem (org.zkoss.zul.Comboitem)3 ResourceBundle (java.util.ResourceBundle)1 Combobox (org.adempiere.webui.component.Combobox)1 Label (org.adempiere.webui.component.Label)1 Language (org.compiere.util.Language)1 Button (org.zkoss.zul.Button)1