label run-as selector

configure tabsheet to selected role
This commit is contained in:
Peter Hormanns 2012-10-31 11:33:43 +01:00
parent f97acf975c
commit 3a8c86b3c8
4 changed files with 34 additions and 18 deletions

View File

@ -12,6 +12,7 @@ import com.vaadin.ui.Button;
import com.vaadin.ui.Component; import com.vaadin.ui.Component;
import com.vaadin.ui.Form; import com.vaadin.ui.Form;
import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Select; import com.vaadin.ui.Select;
import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window; import com.vaadin.ui.Window;
@ -150,6 +151,7 @@ public abstract class AbstractModule implements Module, Serializable {
application.setRunAs(property.getValue().toString()); application.setRunAs(property.getValue().toString());
} }
}); });
toolbar.addComponent(new Label(application.getLocaleConfig().getText("runAs")));
toolbar.addComponent(selRunAs); toolbar.addComponent(selRunAs);
} }

View File

@ -46,9 +46,10 @@ public class MainApplication extends Application implements HttpServletRequestLi
private Remote remote; private Remote remote;
private Map<String, Module> modules; private Map<String, Module> modules;
private Locale requestLocale; private Locale requestLocale;
private String role = "NONE"; private String loginUserRole = "NONE";
private String runAs = null; private String runAs = null;
private TabSheet tabSheet; private TabSheet tabSheet;
private Window mainWindow;
@Override @Override
@ -59,21 +60,43 @@ public class MainApplication extends Application implements HttpServletRequestLi
} }
localeConfig = new LocaleConfig(locale, "main"); localeConfig = new LocaleConfig(locale, "main");
remote = new Remote(this); remote = new Remote(this);
loginUserRole = readUserRole();
mainWindow = new Window(localeConfig.getText("applicationtitle"));
Module firstModule = initTabSheet();
setMainWindow(mainWindow);
setErrorHandler(new Terminal.ErrorListener() {
private static final long serialVersionUID = 1L;
@Override
public void terminalError(Terminal.ErrorEvent event) {
event.getThrowable().printStackTrace();
}
});
try {
firstModule.reload();
} catch (HsarwebException e) {
showSystemException(e);
}
}
private String readUserRole() {
try { try {
Object rolesArrayObj = remote.callSearch("role", null); Object rolesArrayObj = remote.callSearch("role", null);
if (rolesArrayObj != null && rolesArrayObj instanceof Object[]) { if (rolesArrayObj != null && rolesArrayObj instanceof Object[]) {
Object[] rolesArray = (Object[]) rolesArrayObj; Object[] rolesArray = (Object[]) rolesArrayObj;
if (rolesArray.length > 0 && rolesArray[0] instanceof Map<?, ?>) { if (rolesArray.length > 0 && rolesArray[0] instanceof Map<?, ?>) {
role = (String) ((Map<?, ?>) rolesArray[0]).get("role"); return (String) ((Map<?, ?>) rolesArray[0]).get("role");
} }
} }
} catch (HsarwebException e) { } catch (HsarwebException e) {
showSystemException(e); showSystemException(e);
} }
Window mainWindow = new Window(localeConfig.getText("applicationtitle")); return "NONE";
}
private Module initTabSheet() {
tabSheet = new TabSheet(); tabSheet = new TabSheet();
tabSheet.setSizeFull(); tabSheet.setSizeFull();
String modulesParamString = localeConfig.getText("modules." + role); String modulesParamString = localeConfig.getText("modules." + readUserRole());
modules = new HashMap<String, Module>(); modules = new HashMap<String, Module>();
Module firstModule = null; Module firstModule = null;
for (String className : modulesParamString.split(",")) { for (String className : modulesParamString.split(",")) {
@ -93,23 +116,11 @@ public class MainApplication extends Application implements HttpServletRequestLi
} }
tabSheet.addListener(this); tabSheet.addListener(this);
mainWindow.setContent(tabSheet); mainWindow.setContent(tabSheet);
setMainWindow(mainWindow); return firstModule;
setErrorHandler(new Terminal.ErrorListener() {
private static final long serialVersionUID = 1L;
@Override
public void terminalError(Terminal.ErrorEvent event) {
event.getThrowable().printStackTrace();
}
});
try {
firstModule.reload();
} catch (HsarwebException e) {
showSystemException(e);
}
} }
public String getLoginUserRole() { public String getLoginUserRole() {
return role; return loginUserRole;
} }
public String getProxyTicket() { public String getProxyTicket() {
@ -201,6 +212,7 @@ public class MainApplication extends Application implements HttpServletRequestLi
public void setRunAs(String runAs) { public void setRunAs(String runAs) {
this.runAs = runAs; this.runAs = runAs;
initTabSheet();
Component selectedTab = tabSheet.getSelectedTab(); Component selectedTab = tabSheet.getSelectedTab();
Tab tab = tabSheet.getTab(selectedTab); Tab tab = tabSheet.getTab(selectedTab);
Module module = modules.get(tab.getCaption()); Module module = modules.get(tab.getCaption());

View File

@ -5,6 +5,7 @@ confirmdelete=confirm delete
save=save save=save
abort=abort abort=abort
new=new new=new
runas=run as
modules.NONE=de.hsadmin.web.HomeModule modules.NONE=de.hsadmin.web.HomeModule
modules.USER=de.hsadmin.web.HomeModule modules.USER=de.hsadmin.web.HomeModule
modules.DOM_ADMIN=de.hsadmin.web.DomainReadonlyModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.HomeModule modules.DOM_ADMIN=de.hsadmin.web.DomainReadonlyModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.HomeModule

View File

@ -5,3 +5,4 @@ confirmdelete=Diesen Eintrag l
save=speichern save=speichern
abort=abbrechen abort=abbrechen
new=Eintrag anlegen new=Eintrag anlegen
runas=als Benutzer