Search in sources :

Example 6 with UserPreference

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

Example 7 with UserPreference

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

the class WPreference method onSave.

private void onSave() {
    UserPreference preference = SessionManager.getSessionApplication().getUserPreference();
    boolean changeTheme = false;
    int newTheme_ID = 0;
    // Set theme
    if (selectedTheme.getValue() != null && ((Integer) selectedTheme.getValue()).intValue() > 0) {
        newTheme_ID = ((Integer) selectedTheme.getValue()).intValue();
    }
    if (newTheme_ID != preference.getPropertyAsInt(UserPreference.P_ZK_THEME_PREFERENCE)) {
        changeTheme = true;
    }
    preference.setProperty(UserPreference.P_AUTO_COMMIT, (Boolean) autoCommit.getValue() ? "Y" : "N");
    preference.setProperty(UserPreference.P_AUTO_NEW, (Boolean) autoNew.getValue() ? "Y" : "N");
    preference.setProperty(UserPreference.P_WINDOW_TAB_COLLAPSIBLE, (Boolean) tabCollapsible.getValue() ? "Y" : "N");
    preference.setProperty(UserPreference.P_WINDOW_TAB_PLACEMENT, (String) tabPlacement.getSelectedItem().getValue());
    preference.setProperty(UserPreference.P_ZK_THEME_PREFERENCE, newTheme_ID);
    preference.savePreference();
    //update context
    Env.setAutoCommit(Env.getCtx(), "y".equalsIgnoreCase(preference.getProperty(UserPreference.P_AUTO_COMMIT)));
    Env.setAutoNew(Env.getCtx(), "y".equalsIgnoreCase(preference.getProperty(UserPreference.P_AUTO_NEW)));
    this.detach();
    if (changeTheme) {
        // Reload the page - it will use the new theme
        Executions.sendRedirect(null);
    }
}
Also used : UserPreference(org.adempiere.webui.util.UserPreference)

Example 8 with UserPreference

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

the class NavBarDesktop 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);
    leftRegion = new West();
    layout.appendChild(leftRegion);
    leftRegion.setWidth("300px");
    leftRegion.setCollapsible(true);
    leftRegion.setSplittable(true);
    leftRegion.setTitle("Navigation");
    //leftRegion.setHflex("true");
    leftRegion.setVflex("true");
    leftRegion.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);
    leftRegion.setOpen(!menuCollapsed);
    navigationPanel = new Accordion();
    navigationPanel.setParent(leftRegion);
    navigationPanel.setWidth("100%");
    navigationPanel.setHeight("100%");
    navigationPanel.add(pnlSide, "Application Menu");
    Div div = new Div();
    favPanel = (DPFavourites) Executions.createComponents(FAVOURITES_PATH, div, null);
    navigationPanel.add(div, "Favourites");
    //setup drag and drop for favourites
    div = navigationPanel.getHeader(1);
    div.setDroppable(DPFavourites.FAVOURITE_DROPPABLE);
    div.addEventListener(Events.ON_DROP, this);
    div = new Div();
    Component component = Executions.createComponents(ACTIVITIES_PATH, div, null);
    if (component instanceof DashboardPanel) {
        DashboardPanel dashboardPanel = (DashboardPanel) component;
        dashboardRunnable.add(dashboardPanel);
    }
    navigationPanel.add(div, "Activities");
    div = new Div();
    Executions.createComponents(VIEWS_PATH, div, null);
    navigationPanel.add(div, Msg.getMsg(Env.getCtx(), "View").replaceAll("&", ""));
    navigationPanel.setSelectedIndex(0);
    windowArea = new Center();
    windowArea.setParent(layout);
    windowArea.setHflex("true");
    windowArea.setVflex("true");
    windowContainer.createPart(windowArea);
    createHomeTab();
    return layout;
}
Also used : Center(org.zkoss.zul.Center) SidePanel(org.adempiere.webui.panel.SidePanel) West(org.zkoss.zul.West) Borderlayout(org.zkoss.zul.Borderlayout) DashboardRunnable(org.adempiere.webui.dashboard.DashboardRunnable) IOException(java.io.IOException) Div(org.zkoss.zul.Div) DashboardPanel(org.adempiere.webui.dashboard.DashboardPanel) Accordion(org.adempiere.webui.component.Accordion) HeaderPanel(org.adempiere.webui.panel.HeaderPanel) Event(org.zkoss.zk.ui.event.Event) OpenEvent(org.zkoss.zk.ui.event.OpenEvent) DropEvent(org.zkoss.zk.ui.event.DropEvent) North(org.zkoss.zul.North) UserPreference(org.adempiere.webui.util.UserPreference) EventListener(org.zkoss.zk.ui.event.EventListener) Component(org.zkoss.zk.ui.Component) OpenEvent(org.zkoss.zk.ui.event.OpenEvent)

Example 9 with UserPreference

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

the class NavBar2Desktop 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.setHflex("true");
    w.setVflex("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);
    Center center = new Center();
    center.setParent(layout);
    center.setHflex("true");
    center.setVflex("true");
    Borderlayout innerLayout = new Borderlayout();
    innerLayout.setHeight("100%");
    innerLayout.setWidth("100%");
    innerLayout.setParent(center);
    West innerW = new West();
    innerW.setWidth("200px");
    innerW.setCollapsible(true);
    innerW.setTitle("Navigation");
    innerW.setSplittable(true);
    innerW.setCollapsible(true);
    innerW.setParent(innerLayout);
    shortcutPanel = new Accordion();
    shortcutPanel.setWidth("100%");
    shortcutPanel.setHeight("100%");
    innerW.appendChild(shortcutPanel);
    Div div = new Div();
    Executions.createComponents(FAVOURITES_PATH, div, null);
    shortcutPanel.add(div, "Favourites");
    div = new Div();
    Component component = Executions.createComponents(ACTIVITIES_PATH, div, null);
    if (component instanceof DashboardPanel) {
        DashboardPanel dashboardPanel = (DashboardPanel) component;
        dashboardRunnable.add(dashboardPanel);
    }
    shortcutPanel.add(div, "Activities");
    shortcutPanel.setSelectedIndex(0);
    windowArea = new Center();
    windowArea.setParent(innerLayout);
    windowArea.setHflex("true");
    windowArea.setVflex("true");
    windowContainer.createPart(windowArea);
    createHomeTab();
    return layout;
}
Also used : Center(org.zkoss.zul.Center) SidePanel(org.adempiere.webui.panel.SidePanel) West(org.zkoss.zul.West) Borderlayout(org.zkoss.zul.Borderlayout) DashboardRunnable(org.adempiere.webui.dashboard.DashboardRunnable) IOException(java.io.IOException) Div(org.zkoss.zul.Div) DashboardPanel(org.adempiere.webui.dashboard.DashboardPanel) Accordion(org.adempiere.webui.component.Accordion) HeaderPanel(org.adempiere.webui.panel.HeaderPanel) Event(org.zkoss.zk.ui.event.Event) OpenEvent(org.zkoss.zk.ui.event.OpenEvent) North(org.zkoss.zul.North) UserPreference(org.adempiere.webui.util.UserPreference) EventListener(org.zkoss.zk.ui.event.EventListener) Component(org.zkoss.zk.ui.Component) OpenEvent(org.zkoss.zk.ui.event.OpenEvent)

Example 10 with UserPreference

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

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