Search in sources :

Example 1 with Application

use of com.storedobject.ui.Application 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)

Example 2 with Application

use of com.storedobject.ui.Application in project SODevelopment by syampillai.

the class AbstractQuantityField method onAttach.

@Override
protected void onAttach(AttachEvent attachEvent) {
    super.onAttach(attachEvent);
    Application a = Application.get();
    if (a != null) {
        ((TextField) getField()).setAutoselect(!a.getWebBrowser().isAndroid());
    }
}
Also used : CustomTextField(com.storedobject.vaadin.CustomTextField) TextField(com.vaadin.flow.component.textfield.TextField) Application(com.storedobject.ui.Application)

Example 3 with Application

use of com.storedobject.ui.Application in project SODevelopment by syampillai.

the class SelectLocation method get.

public static InventoryLocation get(int... types) {
    Application a = Application.get();
    if (a == null) {
        return null;
    }
    SelectStore.Assignment assignment = a.getData(SelectStore.Assignment.class);
    if (assignment != null && assignment.location != null && checkType(assignment.location, types)) {
        return assignment.location;
    }
    InventoryLocation loc = a.getTransactionManager().getUser().listLinks(InventoryVirtualLocation.class).filter(l -> checkType(l, types)).single(false);
    if (loc == null) {
        return null;
    }
    if (assignment == null) {
        assignment = new SelectStore.Assignment();
        a.setData(SelectStore.Assignment.class, assignment);
    }
    assignment.location = loc;
    return loc;
}
Also used : InventoryLocation(com.storedobject.core.InventoryLocation) List(java.util.List) ObjectComboField(com.storedobject.ui.ObjectComboField) InventoryVirtualLocation(com.storedobject.core.InventoryVirtualLocation) Application(com.storedobject.ui.Application) DataForm(com.storedobject.vaadin.DataForm) Logic(com.storedobject.core.Logic) InventoryLocation(com.storedobject.core.InventoryLocation) Application(com.storedobject.ui.Application)

Example 4 with Application

use of com.storedobject.ui.Application in project SODevelopment by syampillai.

the class SelectLocation method process.

@Override
protected boolean process() {
    Application a = Application.get();
    close();
    SelectStore.Assignment assignment = a.getData(SelectStore.Assignment.class);
    if (assignment == null) {
        assignment = new SelectStore.Assignment();
        a.setData(SelectStore.Assignment.class, assignment);
    }
    assignment.location = locField.getValue();
    if (logic != null) {
        Application.get().execute(logic);
    }
    return true;
}
Also used : Application(com.storedobject.ui.Application)

Example 5 with Application

use of com.storedobject.ui.Application in project SODevelopment by syampillai.

the class SelectStore method process.

@Override
protected boolean process() {
    Application a = Application.get();
    close();
    SelectStore.Assignment assignment = a.getData(SelectStore.Assignment.class);
    if (assignment == null) {
        assignment = new SelectStore.Assignment();
        a.setData(SelectStore.Assignment.class, assignment);
    }
    assignment.store = storeField.getValue();
    if (logic != null) {
        Application.get().execute(logic);
    }
    return true;
}
Also used : Application(com.storedobject.ui.Application)

Aggregations

Application (com.storedobject.ui.Application)9 InventoryLocation (com.storedobject.core.InventoryLocation)1 InventoryVirtualLocation (com.storedobject.core.InventoryVirtualLocation)1 Logic (com.storedobject.core.Logic)1 StoredObject (com.storedobject.core.StoredObject)1 TextContentProducer (com.storedobject.core.TextContentProducer)1 PDFReport (com.storedobject.pdf.PDFReport)1 ObjectComboField (com.storedobject.ui.ObjectComboField)1 ButtonIcon (com.storedobject.vaadin.ButtonIcon)1 CustomTextField (com.storedobject.vaadin.CustomTextField)1 DataForm (com.storedobject.vaadin.DataForm)1 SpeakerButton (com.storedobject.vaadin.SpeakerButton)1 HasText (com.vaadin.flow.component.HasText)1 HtmlComponent (com.vaadin.flow.component.HtmlComponent)1 TextField (com.vaadin.flow.component.textfield.TextField)1 Writer (java.io.Writer)1 List (java.util.List)1