label run-as selector
configure tabsheet to selected role
This commit is contained in:
parent
f97acf975c
commit
3a8c86b3c8
@ -12,6 +12,7 @@ import com.vaadin.ui.Button;
|
||||
import com.vaadin.ui.Component;
|
||||
import com.vaadin.ui.Form;
|
||||
import com.vaadin.ui.HorizontalLayout;
|
||||
import com.vaadin.ui.Label;
|
||||
import com.vaadin.ui.Select;
|
||||
import com.vaadin.ui.VerticalLayout;
|
||||
import com.vaadin.ui.Window;
|
||||
@ -150,6 +151,7 @@ public abstract class AbstractModule implements Module, Serializable {
|
||||
application.setRunAs(property.getValue().toString());
|
||||
}
|
||||
});
|
||||
toolbar.addComponent(new Label(application.getLocaleConfig().getText("runAs")));
|
||||
toolbar.addComponent(selRunAs);
|
||||
}
|
||||
|
||||
|
@ -46,9 +46,10 @@ public class MainApplication extends Application implements HttpServletRequestLi
|
||||
private Remote remote;
|
||||
private Map<String, Module> modules;
|
||||
private Locale requestLocale;
|
||||
private String role = "NONE";
|
||||
private String loginUserRole = "NONE";
|
||||
private String runAs = null;
|
||||
private TabSheet tabSheet;
|
||||
private Window mainWindow;
|
||||
|
||||
|
||||
@Override
|
||||
@ -59,21 +60,43 @@ public class MainApplication extends Application implements HttpServletRequestLi
|
||||
}
|
||||
localeConfig = new LocaleConfig(locale, "main");
|
||||
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 {
|
||||
Object rolesArrayObj = remote.callSearch("role", null);
|
||||
if (rolesArrayObj != null && rolesArrayObj instanceof Object[]) {
|
||||
Object[] rolesArray = (Object[]) rolesArrayObj;
|
||||
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) {
|
||||
showSystemException(e);
|
||||
}
|
||||
Window mainWindow = new Window(localeConfig.getText("applicationtitle"));
|
||||
return "NONE";
|
||||
}
|
||||
|
||||
private Module initTabSheet() {
|
||||
tabSheet = new TabSheet();
|
||||
tabSheet.setSizeFull();
|
||||
String modulesParamString = localeConfig.getText("modules." + role);
|
||||
String modulesParamString = localeConfig.getText("modules." + readUserRole());
|
||||
modules = new HashMap<String, Module>();
|
||||
Module firstModule = null;
|
||||
for (String className : modulesParamString.split(",")) {
|
||||
@ -93,23 +116,11 @@ public class MainApplication extends Application implements HttpServletRequestLi
|
||||
}
|
||||
tabSheet.addListener(this);
|
||||
mainWindow.setContent(tabSheet);
|
||||
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);
|
||||
}
|
||||
return firstModule;
|
||||
}
|
||||
|
||||
public String getLoginUserRole() {
|
||||
return role;
|
||||
return loginUserRole;
|
||||
}
|
||||
|
||||
public String getProxyTicket() {
|
||||
@ -201,6 +212,7 @@ public class MainApplication extends Application implements HttpServletRequestLi
|
||||
|
||||
public void setRunAs(String runAs) {
|
||||
this.runAs = runAs;
|
||||
initTabSheet();
|
||||
Component selectedTab = tabSheet.getSelectedTab();
|
||||
Tab tab = tabSheet.getTab(selectedTab);
|
||||
Module module = modules.get(tab.getCaption());
|
||||
|
@ -5,6 +5,7 @@ confirmdelete=confirm delete
|
||||
save=save
|
||||
abort=abort
|
||||
new=new
|
||||
runas=run as
|
||||
modules.NONE=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
|
||||
|
@ -5,3 +5,4 @@ confirmdelete=Diesen Eintrag l
|
||||
save=speichern
|
||||
abort=abbrechen
|
||||
new=Eintrag anlegen
|
||||
runas=als Benutzer
|
||||
|
Loading…
Reference in New Issue
Block a user