Search in sources :

Example 1 with SpeakerButton

use of com.storedobject.vaadin.SpeakerButton in project SODevelopment by syampillai.

the class ApplicationFrame method loggedin.

@Override
public void loggedin(com.storedobject.vaadin.Application application) {
    if (!ApplicationServer.getGlobalBooleanProperty("application.config.toolbox.hide")) {
        Application a = (Application) application;
        boolean landscape = a.getDeviceWidth() > a.getDeviceHeight();
        TransactionManager tm = ((Application) application).getTransactionManager();
        SystemUser su = tm.getUser();
        application.setLocale(su.getLocale());
        Person p = su.getPerson();
        application.speak("Welcome " + p);
        StringBuilder sb = new StringBuilder();
        sb.append(su.getLogin()).append(" (").append(p.getName()).append(')');
        SystemEntity se = tm.getEntity();
        if (se != null) {
            Entity e = se.getEntity();
            sb.append(", ").append(e.getName()).append(", ").append(e.getLocation());
        }
        HasText user = getUserNameComponent();
        String s = sb.toString();
        if (landscape) {
            user.setText(s);
            ((HtmlComponent) user).setTitle("ID:" + su.getId());
        } else {
            user.setText(su.getName());
            ((HtmlComponent) user).setTitle(su.getId() + ":" + s);
        }
        ButtonIcon logoutButton = new ButtonIcon("icons:exit-to-app", e -> a.logout());
        logoutButton.setStyle("color", "var(--lumo-error-color)");
        logoutButton.getElement().setAttribute("title", "Sign out");
        logoutButton.getElement().setAttribute("tabindex", "-1");
        getToolbox().add(new SpeakerButton(), ((Application) application).getAlertButton(), new CompactSwitcher(a).icon, logoutButton);
    }
    if (!ApplicationServer.getGlobalBooleanProperty("application.config.menu.hide")) {
        getDrawerToggle().setVisible(true);
    }
}
Also used : ButtonIcon(com.storedobject.vaadin.ButtonIcon) HasText(com.vaadin.flow.component.HasText) HtmlComponent(com.vaadin.flow.component.HtmlComponent) SpeakerButton(com.storedobject.vaadin.SpeakerButton) Application(com.storedobject.ui.Application)

Aggregations

Application (com.storedobject.ui.Application)1 ButtonIcon (com.storedobject.vaadin.ButtonIcon)1 SpeakerButton (com.storedobject.vaadin.SpeakerButton)1 HasText (com.vaadin.flow.component.HasText)1 HtmlComponent (com.vaadin.flow.component.HtmlComponent)1