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