Search in sources :

Example 1 with UserPreference

use of org.adempiere.webui.util.UserPreference in project adempiere by adempiere.

the class DefaultDesktop method doCreatePart.

protected Component doCreatePart(Component parent) {
    SidePanel pnlSide = new SidePanel();
    HeaderPanel pnlHead = new HeaderPanel();
    pnlSide.getMenuPanel().addMenuListener(this);
    layout = new Borderlayout();
    if (parent != null) {
        layout.setParent(parent);
        layout.setWidth("100%");
        layout.setHeight("100%");
        layout.setStyle("position: absolute");
    } else
        layout.setPage(page);
    dashboardRunnable = new DashboardRunnable(layout.getDesktop(), this);
    North n = new North();
    n.setSplittable(true);
    n.setCollapsible(false);
    layout.appendChild(n);
    pnlHead.setParent(n);
    West w = new West();
    layout.appendChild(w);
    w.setWidth("300px");
    w.setCollapsible(true);
    w.setSplittable(true);
    w.setTitle(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Menu")));
    w.setFlex(true);
    w.addEventListener(Events.ON_OPEN, new EventListener() {

        @Override
        public void onEvent(Event event) throws Exception {
            OpenEvent oe = (OpenEvent) event;
            UserPreference pref = SessionManager.getSessionApplication().getUserPreference();
            pref.setProperty(UserPreference.P_MENU_COLLAPSED, !oe.isOpen());
            pref.savePreference();
        }
    });
    UserPreference pref = SessionManager.getSessionApplication().getUserPreference();
    boolean menuCollapsed = pref.isPropertyBool(UserPreference.P_MENU_COLLAPSED);
    w.setOpen(!menuCollapsed);
    pnlSide.setParent(w);
    windowArea = new Center();
    windowArea.setParent(layout);
    windowArea.setFlex(true);
    windowContainer.createPart(windowArea);
    createHomeTab();
    return layout;
}
Also used : Center(org.zkoss.zkex.zul.Center) SidePanel(org.adempiere.webui.panel.SidePanel) West(org.zkoss.zkex.zul.West) Borderlayout(org.zkoss.zkex.zul.Borderlayout) DashboardRunnable(org.adempiere.webui.dashboard.DashboardRunnable) IOException(java.io.IOException) HeaderPanel(org.adempiere.webui.panel.HeaderPanel) Event(org.zkoss.zk.ui.event.Event) OpenEvent(org.zkoss.zk.ui.event.OpenEvent) North(org.zkoss.zkex.zul.North) UserPreference(org.adempiere.webui.util.UserPreference) EventListener(org.zkoss.zk.ui.event.EventListener) OpenEvent(org.zkoss.zk.ui.event.OpenEvent)

Example 2 with UserPreference

use of org.adempiere.webui.util.UserPreference in project adempiere by adempiere.

the class LoginPanel method onUserIdChange.

private void onUserIdChange() {
    String userId = txtUserId.getValue();
    if (userId != null && userId.length() > 0) {
        int AD_User_ID = DB.getSQLValue(null, "SELECT AD_User_ID FROM AD_User WHERE Name = ?", userId);
        if (AD_User_ID > 0) {
            // Elaine 2009/02/06 Load preference from AD_Preference
            UserPreference userPreference = SessionManager.getSessionApplication().loadUserPreference(AD_User_ID);
            String initDefault = userPreference.getProperty(UserPreference.P_LANGUAGE);
            for (int i = 0; i < lstLanguage.getItemCount(); i++) {
                Comboitem li = lstLanguage.getItemAtIndex(i);
                if (li.getLabel().equals(initDefault)) {
                    lstLanguage.setSelectedIndex(i);
                    // Elaine 2009/04/17 language changed
                    languageChanged(li.getLabel());
                    break;
                }
            }
        }
    }
}
Also used : UserPreference(org.adempiere.webui.util.UserPreference) Comboitem(org.zkoss.zul.Comboitem)

Example 3 with UserPreference

use of org.adempiere.webui.util.UserPreference 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 4 with UserPreference

use of org.adempiere.webui.util.UserPreference 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 5 with UserPreference

use of org.adempiere.webui.util.UserPreference 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)

Aggregations

UserPreference (org.adempiere.webui.util.UserPreference)11 Comboitem (org.zkoss.zul.Comboitem)5 ComboItem (org.adempiere.webui.component.ComboItem)4 KeyNamePair (org.compiere.util.KeyNamePair)4 IOException (java.io.IOException)3 DashboardRunnable (org.adempiere.webui.dashboard.DashboardRunnable)3 HeaderPanel (org.adempiere.webui.panel.HeaderPanel)3 SidePanel (org.adempiere.webui.panel.SidePanel)3 Event (org.zkoss.zk.ui.event.Event)3 EventListener (org.zkoss.zk.ui.event.EventListener)3 OpenEvent (org.zkoss.zk.ui.event.OpenEvent)3 Div (org.zkoss.zul.Div)3 Accordion (org.adempiere.webui.component.Accordion)2 Combobox (org.adempiere.webui.component.Combobox)2 Label (org.adempiere.webui.component.Label)2 DashboardPanel (org.adempiere.webui.dashboard.DashboardPanel)2 Component (org.zkoss.zk.ui.Component)2 Borderlayout (org.zkoss.zul.Borderlayout)2 Center (org.zkoss.zul.Center)2 North (org.zkoss.zul.North)2