Example usage for com.vaadin.ui Window setModal

List of usage examples for com.vaadin.ui Window setModal

Introduction

In this page you can find the example usage for com.vaadin.ui Window setModal.

Prototype

public void setModal(boolean modal) 

Source Link

Document

Sets window modality.

Usage

From source file:com.etest.view.tq.TQCoverageUI.java

Window getPickWindow(Item item, String propertyId) {
    Window sub = new Window("Field Value: ");
    sub.setWidth("150px");
    sub.setModal(true);
    sub.center();/*from   ww w . j  a  v  a  2 s .  c o m*/
    sub.setResizable(false);

    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setMargin(true);
    v.setSpacing(true);

    TextField field = new CommonTextField("Enter Value..", "Enter a Value: ");
    v.addComponent(field);

    Button button = new Button("CLOSE");
    button.setWidth("100%");
    button.setIcon(FontAwesome.TASKS);
    button.addStyleName(ValoTheme.BUTTON_PRIMARY);
    button.addStyleName(ValoTheme.BUTTON_SMALL);
    button.addClickListener((Button.ClickEvent event) -> {
        boolean isNumeric = CommonUtilities.isNumeric(field.getValue().trim());
        if (!isNumeric) {
            return;
        }

        boolean isGreaterThanInTB = tq.isGreaterThanInTB(item, propertyId, field.getValue().trim());
        if (isGreaterThanInTB) {
            Notification.show("Not allowed to exceed in total Items in Test Bank!",
                    Notification.Type.ERROR_MESSAGE);
            return;
        } else {
            item.getItemProperty(CommonUtilities.replaceStringTBToPick(propertyId))
                    .setValue(CommonUtilities.convertStringToInt(field.getValue()));
            footer.getCell(CommonUtilities.replaceStringTBToPick(propertyId)).setText(String.valueOf(
                    tq.calculateTotalPickItems(grid, CommonUtilities.replaceStringTBToPick(propertyId))));
        }
        sub.close();
    });
    v.addComponent(button);
    v.setComponentAlignment(button, Alignment.BOTTOM_CENTER);

    sub.setContent(v);
    sub.getContent().setHeightUndefined();

    return sub;
}

From source file:com.etest.view.tq.TQCoverageUI.java

Window getMaxItemsWindow(Item item, double previousValue) {
    Window sub = new Window("Field Value: ");
    sub.setWidth("150px");
    sub.setModal(true);
    sub.center();//from w  ww.  j a  v a2  s. c  o  m
    sub.setResizable(false);

    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setMargin(true);
    v.setSpacing(true);

    TextField field = new CommonTextField("Enter Value..", "Enter a Value: ");
    v.addComponent(field);

    Button button = new Button("CLOSE");
    button.setWidth("100%");
    button.setIcon(FontAwesome.TASKS);
    button.addStyleName(ValoTheme.BUTTON_PRIMARY);
    button.addStyleName(ValoTheme.BUTTON_SMALL);
    button.addClickListener((Button.ClickEvent event) -> {
        boolean isNumeric = CommonUtilities.isNumeric(field.getValue().trim());
        if (!isNumeric) {
            return;
        }

        item.getItemProperty("Max Items").setValue(CommonUtilities.convertStringToDouble(field.getValue()));
        if (tq.calculateTotalMaxItems(grid) == CommonUtilities
                .convertStringToDouble(totalItems.getValue().trim())) {
            footer.getCell("Max Items").setText(String.valueOf(tq.calculateTotalMaxItems(grid)));
        } else {
            item.getItemProperty("Max Items").setValue(previousValue);
            footer.getCell("Max Items").setText(String.valueOf(tq.calculateTotalMaxItems(grid)));
            ShowErrorNotification.warning("Total Max Items should be equal to Total Test Items");
            return;
        }

        sub.close();
    });
    v.addComponent(button);
    v.setComponentAlignment(button, Alignment.BOTTOM_CENTER);

    sub.setContent(v);
    sub.getContent().setHeightUndefined();

    return sub;
}

From source file:com.etest.view.tq.TQCoverageWindow.java

Window confirmDeleteWindow() {
    Window sub = new Window("TQ Coverage");
    sub.setWidth("250px");
    sub.setResizable(false);/*from w  w  w  .  j av  a 2s .  co m*/
    sub.setModal(true);
    sub.center();

    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setMargin(true);

    Button delete = new Button("DELETE TQ?");
    delete.setWidth("100%");
    delete.setIcon(FontAwesome.TRASH_O);
    delete.addStyleName(ValoTheme.BUTTON_PRIMARY);
    delete.addStyleName(ValoTheme.BUTTON_SMALL);
    delete.addClickListener((Button.ClickEvent event) -> {
        boolean result = tq.deleteTQCoverage(getTQCoverageId());
        if (result) {
            sub.close();
            close();
        }
    });
    v.addComponent(delete);

    sub.setContent(v);
    sub.getContent().setHeightUndefined();

    return sub;
}

From source file:com.expressui.core.MainApplication.java

License:Open Source License

/**
 * Opens a separate error Window with the full stack trace of a throwable
 * and error box highlighting the root cause message.
 *
 * @param throwable full stack trace of this throwable is displayed in error Window
 */// ww w. j  a  v a2 s.c o  m
public void openErrorWindow(Throwable throwable) {
    showError(ExceptionUtils.getRootCauseMessage(throwable));

    String message = ExceptionUtils.getFullStackTrace(throwable);
    Window errorWindow = new Window(uiMessageSource.getMessage("mainApplication.errorWindowCaption"));
    errorWindow.addStyleName("opaque");
    VerticalLayout layout = (VerticalLayout) errorWindow.getContent();
    layout.setSpacing(true);
    layout.setWidth("100%");
    errorWindow.setWidth("100%");
    errorWindow.setModal(true);
    Label label = new Label(message);
    label.setContentMode(Label.CONTENT_PREFORMATTED);
    layout.addComponent(label);
    errorWindow.setClosable(true);
    errorWindow.setScrollable(true);
    getMainWindow().addWindow(errorWindow);
}

From source file:com.foc.vaadin.FocWebApplication.java

License:Apache License

@Override
public void addWindow(Window window) throws IllegalArgumentException, NullPointerException {
    boolean executedWithoutPopup = false;

    if (isMobile()) {
        Object content = window.getContent();
        if (content instanceof ICentralPanel) {
            if (getContent() != null && getContent() instanceof FocCentralPanel) {
                window.setContent(null);
                FocCentralPanel centralComponent = (FocCentralPanel) getContent();

                centralComponent.changeCentralPanelContent((ICentralPanel) content, true);

                executedWithoutPopup = true;
            }//  ww  w.  j av  a  2s. co m
        }
    }

    if (!executedWithoutPopup) {
        window.setModal(true);
        super.addWindow(window);
    }
}

From source file:com.foc.web.modules.workflow.UserCompanyRights_Form.java

License:Apache License

@Override
public boolean validationCheckData(FVValidationLayout validationLayout) {
    boolean error = super.validationCheckData(validationLayout);
    if (!error && getUserCompanyRights() != null && getUserCompanyRights().getCompany() != null
            && getUserCompanyRights().getCompany().getSiteListSize() > 0) {
        if (getUserCompanyRights().getCompany().getSiteListSize() == 1) {
            if (WFTitleDesc.getInstance().getFocList().size() == 1) {
                WFSite site = (WFSite) getUserCompanyRights().getCompany().getAnySite();
                WFTitle title = (WFTitle) WFTitleDesc.getInstance().getFocList().getFocObject(0);
                WFOperator operator = (WFOperator) site.getOperatorList().newEmptyItem();
                operator.setUser(getUserCompanyRights().getUser());
                operator.setTitle(title);
            } else {
                ArrayList<WFSite> selectedSiteList = new ArrayList<WFSite>();
                selectedSiteList.add((WFSite) getUserCompanyRights().getCompany().getAnySite());
                FocList focList = WFTitleDesc.getList(FocList.LOAD_IF_NEEDED);
                XMLViewKey xmlViewKey = new XMLViewKey(WFTitleDesc.getInstance().getStorageName(),
                        XMLViewKey.TYPE_TABLE, WorkflowWebModule.CTXT_TITLE_SELECTION, XMLViewKey.VIEW_DEFAULT);
                WFTitle_TitleSelection_Table centralPanel = (WFTitle_TitleSelection_Table) XMLViewDictionary
                        .getInstance().newCentralPanel((FocCentralPanel) getMainWindow(), xmlViewKey, focList);
                centralPanel.setSelectedSiteList(selectedSiteList);
                centralPanel.setUser(getUserCompanyRights().getUser());
                Window titleSelectionWindow = null;
                FocCentralPanel centralWindow = new FocCentralPanel();
                centralWindow.fill();// w  w  w .j  av  a2 s. c  o m
                centralWindow.changeCentralPanelContent(centralPanel, false);
                titleSelectionWindow = centralWindow.newWrapperWindow();
                titleSelectionWindow.setPositionX(300);
                titleSelectionWindow.setPositionY(100);
                FocWebApplication.getInstanceForThread().addWindow(titleSelectionWindow);
                titleSelectionWindow.setModal(true);
            }
        } else {
            if (WFTitleDesc.getInstance().getFocList().size() > 0
                    && WFTitleDesc.getInstance().getFocList().size() == 1) {
                popupWorkfloSiteSelectionTable(false);
            } else {
                popupWorkfloSiteSelectionTable(true);
            }
        }
    }
    return error;
}

From source file:com.foc.web.modules.workflow.UserCompanyRights_Form.java

License:Apache License

private void popupWorkfloSiteSelectionTable(boolean hasMultipleTitles) {
    Company companyToFilterOn = getUserCompanyRights().getCompany();
    if (companyToFilterOn != null) {
        //20160107
        FocListWrapper wrapper = companyToFilterOn.newFocListWrapperForCurrentCompany();

        XMLViewKey xmlViewKey = new XMLViewKey(WFSiteDesc.getInstance().getStorageName(), XMLViewKey.TYPE_TABLE,
                WorkflowWebModule.CTXT_SITE_SELECTION, XMLViewKey.VIEW_DEFAULT);
        WFSite_SiteSelection_Table centralPanel = (WFSite_SiteSelection_Table) XMLViewDictionary.getInstance()
                .newCentralPanel(getMainWindow(), xmlViewKey, wrapper);
        centralPanel.setFocDataOwner(true);
        centralPanel.setHasMultipleTitles(hasMultipleTitles);
        centralPanel.setUser(getUserCompanyRights().getUser());
        Window titleSelectionWindow = null;
        FocCentralPanel centralWindow = new FocCentralPanel();
        centralWindow.fill();/*from   w w  w.j  ava  2s  . co  m*/
        centralWindow.changeCentralPanelContent(centralPanel, false);
        titleSelectionWindow = centralWindow.newWrapperWindow();
        titleSelectionWindow.setPositionX(300);
        titleSelectionWindow.setPositionY(100);
        FocWebApplication.getInstanceForThread().addWindow(titleSelectionWindow);
        titleSelectionWindow.setModal(true);
    }
}

From source file:com.foc.web.modules.workflow.WFSite_SiteSelection_Table.java

License:Apache License

public void insertRowsAfterSelection() {
    if (isHasMultipleTitles()) {
        FocList focList = WFTitleDesc.getList(FocList.LOAD_IF_NEEDED);
        XMLViewKey xmlViewKey = new XMLViewKey(WFTitleDesc.getInstance().getStorageName(),
                XMLViewKey.TYPE_TABLE, WorkflowWebModule.CTXT_TITLE_SELECTION, XMLViewKey.VIEW_DEFAULT);
        WFTitle_TitleSelection_Table centralPanel = (WFTitle_TitleSelection_Table) XMLViewDictionary
                .getInstance().newCentralPanel(getMainWindow(), xmlViewKey, focList);
        centralPanel.setSelectedSiteList(getSelectedSites());
        centralPanel.setUser(getUser());
        Window titleSelectionWindow = null;
        FocCentralPanel centralWindow = new FocCentralPanel();
        centralWindow.fill();/*from w w  w.j  a v a 2s.c om*/
        centralWindow.changeCentralPanelContent(centralPanel, false);
        titleSelectionWindow = centralWindow.newWrapperWindow();
        titleSelectionWindow.setPositionX(300);
        titleSelectionWindow.setPositionY(100);
        FocWebApplication.getInstanceForThread().addWindow(titleSelectionWindow);
        titleSelectionWindow.setModal(true);
    } else {
        WFTitle title = (WFTitle) WFTitleDesc.getInstance().getFocList().getFocObject(0);
        FocUser user = getUser();
        for (int i = 0; i < getSelectedSites().size(); i++) {
            WFSite site = getSelectedSites().get(i);
            WFOperator operator = (WFOperator) site.getOperatorList().newEmptyItem();
            operator.setTitle(title);
            operator.setUser(user);
            site.getOperatorList().add(operator);
            operator.validate(true);
        }
    }
}

From source file:com.hack23.cia.web.impl.ui.application.views.pageclicklistener.SetGoogleAuthenticatorCredentialClickListener.java

License:Apache License

@Override
public void buttonClick(final ClickEvent event) {
    final SetGoogleAuthenticatorCredentialResponse response = (SetGoogleAuthenticatorCredentialResponse) applicationManager
            .service(googleAuthRequest);

    if (ServiceResult.SUCCESS == response.getResult()) {

        try {//from w ww. jav a  2s .  c o  m
            final URI keyUri = new URI(response.getOtpAuthTotpURL());
            final QRCode qrCode = new QRCode(QR_CODE, keyUri.toASCIIString());
            qrCode.setHeight(QR_CODE_IMAGE_SIZE);
            qrCode.setWidth(QR_CODE_IMAGE_SIZE);

            final Window mywindow = new Window(GOOGLE_AUTHENTICATOR_QR_CODE);
            mywindow.setHeight(MODAL_WINDOW_SIZE);
            mywindow.setWidth(MODAL_WINDOW_SIZE);

            mywindow.setPositionX(WINDOW_POSITION);
            mywindow.setPositionY(WINDOW_POSITION);

            final VerticalLayout panelContent = new VerticalLayout();

            mywindow.setContent(panelContent);
            panelContent.addComponent(qrCode);

            mywindow.setModal(true);
            UI.getCurrent().addWindow(mywindow);

        } catch (final URISyntaxException e) {
            LOGGER.warn(PROBLEM_DISPLAYING_QR_CODE, e);
            Notification.show(PROBLEM_DISPLAYING_QR_CODE, ERROR_MESSAGE, Notification.Type.WARNING_MESSAGE);
        }

    } else {
        Notification.show(PROBLEM_ENABLE_GOOGLE_AUTHENTICATOR, ERROR_MESSAGE,
                Notification.Type.WARNING_MESSAGE);
        LOGGER.info(PROBLEM_ENABLE_GOOGLE_AUTHENTICATOR_SESSIONID, googleAuthRequest.getSessionId());
    }
}

From source file:com.haulmont.cuba.web.exception.NoUserSessionHandler.java

License:Apache License

protected void showNoUserSessionDialog(App app) {
    Messages messages = AppBeans.get(Messages.NAME);

    Window dialog = new NoUserSessionExceptionDialog();
    dialog.setStyleName("c-nousersession-dialog");
    dialog.setCaption(messages.getMainMessage("dialogs.Information", locale));
    dialog.setClosable(false);//from  w w  w  . j a v  a  2s.  c o  m
    dialog.setResizable(false);
    dialog.setModal(true);

    AppUI ui = app.getAppUI();

    if (ui.isTestMode()) {
        dialog.setCubaId("optionDialog");
        dialog.setId(ui.getTestIdManager().getTestId("optionDialog"));
    }

    Label messageLab = new CubaLabel();
    messageLab.setWidthUndefined();
    messageLab.setValue(messages.getMainMessage("noUserSession.message", locale));

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setWidthUndefined();
    layout.setStyleName("c-nousersession-dialog-layout");
    layout.setSpacing(true);
    dialog.setContent(layout);

    Button reloginBtn = new Button();
    if (ui.isTestMode()) {
        reloginBtn.setCubaId("reloginBtn");
        reloginBtn.setId(ui.getTestIdManager().getTestId("reloginBtn"));
    }
    reloginBtn.addStyleName(WebButton.ICON_STYLE);
    reloginBtn.addStyleName("c-primary-action");
    reloginBtn.addClickListener(event -> relogin());
    reloginBtn.setCaption(messages.getMainMessage(Type.OK.getMsgKey()));

    String iconName = AppBeans.get(Icons.class).get(Type.OK.getIconKey());
    reloginBtn.setIcon(WebComponentsHelper.getIcon(iconName));

    ClientConfig clientConfig = AppBeans.get(Configuration.class).getConfig(ClientConfig.class);
    setClickShortcut(reloginBtn, clientConfig.getCommitShortcut());

    reloginBtn.focus();

    layout.addComponent(messageLab);
    layout.addComponent(reloginBtn);

    layout.setComponentAlignment(reloginBtn, Alignment.BOTTOM_RIGHT);

    ui.addWindow(dialog);

    dialog.center();
}