Example usage for com.vaadin.ui Window close

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

Introduction

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

Prototype

public void close() 

Source Link

Document

Method that handles window closing (from UI).

Usage

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

Window getTopicWindow(Item item) {
    Window sub = new Window("TOPIC: ");
    sub.setWidth("500px");
    sub.setModal(true);/*w ww.  j  a v a 2 s  .  co  m*/
    sub.center();
    sub.setResizable(false);

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

    topic.setInputPrompt("Select a Topic..");
    topic.addStyleName(ValoTheme.COMBOBOX_SMALL);
    topic.setWidth("100%");
    topic.addValueChangeListener((Property.ValueChangeEvent event) -> {
        if (event.getProperty().getValue() == null) {
        } else {
            syllabusId = (int) event.getProperty().getValue();
            topicStr = topic.getItem(topic.getValue()).toString();
        }
    });
    v.addComponent(topic);

    Button button = new Button("CLOSE");
    button.setWidth("50%");
    button.setIcon(FontAwesome.TASKS);
    button.addStyleName(ValoTheme.BUTTON_PRIMARY);
    button.addStyleName(ValoTheme.BUTTON_SMALL);
    button.addClickListener((Button.ClickEvent event) -> {
        if (topic.getValue() == null) {
            Notification.show("Select a Topic!", Notification.Type.WARNING_MESSAGE);
        } else {
            populateGridRow(item);
            populateGridFooter();
        }
        sub.close();
    });
    v.addComponent(button);
    v.setComponentAlignment(button, Alignment.MIDDLE_RIGHT);

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

    return sub;
}

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);/*from www. j  a  va 2 s  .  c  o  m*/
    sub.center();
    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);// w w w  .j  a  va  2s.  c  om
    sub.center();
    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  a  va 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.mechanicshop.components.TableLayout.java

public void createCustomMessage() {
    final TextArea textArea = new TextArea();
    textArea.setImmediate(true);//from   w w  w. j a va2 s  .  c  om
    textArea.setColumns(30);
    textArea.setRows(10);
    textArea.addStyleName(ValoTheme.TEXTAREA_SMALL);
    textArea.setRequired(true);
    final Window subWindow = new Window();
    subWindow.setModal(true);
    subWindow.setHeight("350px");
    subWindow.setWidth("500px");
    subWindow.setCaption("Insert Message");
    subWindow.setStyleName(ValoTheme.WINDOW_TOP_TOOLBAR);
    subWindow.setClosable(false);
    subWindow.setResizable(false);

    HorizontalLayout layoutButtons = new HorizontalLayout();
    layoutButtons.setMargin(false);
    Button sendBtn = new Button("Send");
    sendBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                textArea.validate();
                String message = textArea.getValue();
                smsSenderService.sendMessageMassive(message);
                subWindow.close();
                Notification.show("Message Sent");
            } catch (Exception e) {

            }
        }
    });
    sendBtn.setImmediate(true);
    sendBtn.setStyleName(ValoTheme.BUTTON_TINY);
    sendBtn.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    Button cancelBtn = new Button("Cancel");
    cancelBtn.setStyleName(ValoTheme.BUTTON_TINY);
    cancelBtn.addStyleName(ValoTheme.BUTTON_DANGER);
    cancelBtn.setImmediate(true);
    cancelBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            subWindow.close();

        }
    });

    layoutButtons.setSizeUndefined();
    layoutButtons.setSpacing(true);
    layoutButtons.addComponents(cancelBtn, sendBtn);

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.addComponent(textArea);
    layout.addComponent(layoutButtons);
    layout.setComponentAlignment(textArea, Alignment.MIDDLE_CENTER);
    layout.setComponentAlignment(layoutButtons, Alignment.MIDDLE_RIGHT);
    layout.setExpandRatio(textArea, 3);

    layout.setSizeFull();

    subWindow.setContent(layout);
    subWindow.center();

    getUI().addWindow(subWindow);
}

From source file:com.mycollab.mobile.MobileApplication.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {
    OfflineMode offlineMode = new OfflineMode();
    offlineMode.extend(this);

    // Maintain the session when the browser app closes
    offlineMode.setPersistentSessionCookie(true);

    // Define the timeout in secs to wait when a server
    // request is sent before falling back to offline mode
    offlineMode.setOfflineModeTimeout(15);

    VaadinSession.getCurrent().setErrorHandler(new DefaultErrorHandler() {
        private static final long serialVersionUID = 1L;

        @Override//ww  w .  j  a  v  a 2s  . c o m
        public void error(com.vaadin.server.ErrorEvent event) {
            Throwable e = event.getThrowable();
            IgnoreException ignoreException = (IgnoreException) getExceptionType(e, IgnoreException.class);
            if (ignoreException != null) {
                return;
            }

            SessionExpireException sessionExpireException = (SessionExpireException) getExceptionType(e,
                    SessionExpireException.class);
            if (sessionExpireException != null) {
                Page.getCurrent().getJavaScript().execute("window.location.reload();");
                return;
            }

            UserInvalidInputException invalidException = (UserInvalidInputException) getExceptionType(e,
                    UserInvalidInputException.class);
            if (invalidException != null) {
                NotificationUtil.showWarningNotification(UserUIContext
                        .getMessage(GenericI18Enum.ERROR_USER_INPUT_MESSAGE, invalidException.getMessage()));
            } else {
                UsageExceedBillingPlanException usageBillingException = (UsageExceedBillingPlanException) getExceptionType(
                        e, UsageExceedBillingPlanException.class);
                if (usageBillingException != null) {
                    if (UserUIContext.isAdmin()) {
                        ConfirmDialog.show(UI.getCurrent(),
                                UserUIContext.getMessage(GenericI18Enum.EXCEED_BILLING_PLAN_MSG_FOR_ADMIN),
                                UserUIContext.getMessage(GenericI18Enum.BUTTON_YES),
                                UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), dialog -> {
                                    if (dialog.isConfirmed()) {
                                        Collection<Window> windows = UI.getCurrent().getWindows();
                                        for (Window window : windows) {
                                            window.close();
                                        }
                                        EventBusFactory.getInstance().post(new ShellEvent.GotoUserAccountModule(
                                                this, new String[] { "billing" }));
                                    }
                                });

                    } else {
                        NotificationUtil.showErrorNotification(
                                UserUIContext.getMessage(GenericI18Enum.EXCEED_BILLING_PLAN_MSG_FOR_USER));
                    }
                } else {
                    LOG.error("Error", e);
                    NotificationUtil.showErrorNotification(
                            UserUIContext.getMessage(GenericI18Enum.ERROR_USER_NOTICE_INFORMATION_MESSAGE));
                }
            }

        }
    });

    setCurrentFragmentUrl(this.getPage().getUriFragment());
    currentContext = new UserUIContext();
    postSetupApp(request);

    final NavigationManager manager = new NavigationManager();
    setContent(manager);

    registerControllers(manager);
    ThemeManager.loadMobileTheme(MyCollabUI.getAccountId());

    getPage().addUriFragmentChangedListener(new UriFragmentChangedListener() {
        private static final long serialVersionUID = -6410955178515535406L;

        @Override
        public void uriFragmentChanged(UriFragmentChangedEvent event) {
            setCurrentFragmentUrl(event.getUriFragment());
            enter(event.getUriFragment());
        }
    });
    detectAutoLogin();
}

From source file:com.mycollab.web.DesktopApplication.java

License:Open Source License

private void handleException(VaadinRequest request, Throwable e) {
    IgnoreException ignoreException = getExceptionType(e, IgnoreException.class);
    if (ignoreException != null) {
        return;//from   ww w.ja  va 2 s  . c o m
    }

    DebugException debugException = getExceptionType(e, DebugException.class);
    if (debugException != null) {
        LOG.error("Debug error", e);
        return;
    }

    SessionExpireException sessionExpireException = getExceptionType(e, SessionExpireException.class);
    if (sessionExpireException != null) {
        Page.getCurrent().getJavaScript().execute("window.location.reload();");
        return;
    }

    UsageExceedBillingPlanException usageBillingException = getExceptionType(e,
            UsageExceedBillingPlanException.class);
    if (usageBillingException != null) {
        if (UserUIContext.isAdmin()) {
            ConfirmDialogExt.show(UI.getCurrent(),
                    UserUIContext.getMessage(GenericI18Enum.WINDOW_ATTENTION_TITLE, MyCollabUI.getSiteName()),
                    UserUIContext.getMessage(GenericI18Enum.EXCEED_BILLING_PLAN_MSG_FOR_ADMIN),
                    UserUIContext.getMessage(GenericI18Enum.BUTTON_YES),
                    UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> {
                        if (confirmDialog.isConfirmed()) {
                            Collection<Window> windowsList = UI.getCurrent().getWindows();
                            for (Window window : windowsList) {
                                window.close();
                            }
                            EventBusFactory.getInstance().post(
                                    new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" }));
                        }
                    });

        } else {
            NotificationUtil.showErrorNotification(
                    UserUIContext.getMessage(GenericI18Enum.EXCEED_BILLING_PLAN_MSG_FOR_USER));
        }
        return;
    }

    UserInvalidInputException invalidException = getExceptionType(e, UserInvalidInputException.class);
    if (invalidException != null) {
        NotificationUtil.showWarningNotification(UserUIContext
                .getMessage(GenericI18Enum.ERROR_USER_INPUT_MESSAGE, invalidException.getMessage()));
        return;
    }

    UnsupportedFeatureException unsupportedException = getExceptionType(e, UnsupportedFeatureException.class);
    if (unsupportedException != null) {
        NotificationUtil.showFeatureNotPresentInSubscription();
        return;
    }

    ResourceNotFoundException resourceNotFoundException = getExceptionType(e, ResourceNotFoundException.class);
    if (resourceNotFoundException != null) {
        NotificationUtil.showWarningNotification(UserUIContext.getMessage(ErrorI18nEnum.RESOURCE_NOT_FOUND));
        LOG.error("404", resourceNotFoundException);
        return;
    }

    SecureAccessException secureAccessException = getExceptionType(e, SecureAccessException.class);
    if (secureAccessException != null) {
        NotificationUtil.showWarningNotification("You can not access the specific resource");
        EventBusFactory.getInstance()
                .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "preview" }));
        return;
    }

    for (Class systemEx : systemExceptions) {
        Exception ex = (Exception) getExceptionType(e, systemEx);
        if (ex != null) {
            ConfirmDialog dialog = ConfirmDialogExt.show(DesktopApplication.this,
                    UserUIContext.getMessage(GenericI18Enum.WINDOW_ERROR_TITLE, MyCollabUI.getSiteName()),
                    UserUIContext.getMessage(GenericI18Enum.ERROR_USER_SYSTEM_ERROR, ex.getMessage()),
                    UserUIContext.getMessage(GenericI18Enum.BUTTON_YES),
                    UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> {
                    });
            Button okBtn = dialog.getOkButton();
            BrowserWindowOpener opener = new BrowserWindowOpener("http://support.mycollab.com");
            opener.extend(okBtn);
            return;
        }
    }

    IllegalStateException asyncNotSupport = getExceptionType(e, IllegalStateException.class);
    if (asyncNotSupport != null && asyncNotSupport.getMessage().contains("!asyncSupported")) {
        ConfirmDialog dialog = ConfirmDialogExt.show(DesktopApplication.this,
                UserUIContext.getMessage(GenericI18Enum.WINDOW_ERROR_TITLE, MyCollabUI.getSiteName()),
                UserUIContext.getMessage(ErrorI18nEnum.WEBSOCKET_NOT_SUPPORT),
                UserUIContext.getMessage(GenericI18Enum.BUTTON_YES),
                UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> {
                });
        Button okBtn = dialog.getOkButton();
        BrowserWindowOpener opener = new BrowserWindowOpener("http://support.mycollab.com");
        opener.extend(okBtn);
        if (request != null) {
            String remoteAddress = request.getRemoteHost();
            if (remoteAddress != null) {
                if (!ipLists.contains(remoteAddress)) {
                    LOG.error("Async not supported: " + printRequest(request));
                    ipLists.add(remoteAddress);
                }
            }
        }
        return;
    }

    EofException eofException = getExceptionType(e, EofException.class);
    if (eofException != null) {
        return;
    }
    LOG.error("Error", e);
    ConfirmDialog dialog = ConfirmDialogExt.show(DesktopApplication.this,
            UserUIContext.getMessage(GenericI18Enum.WINDOW_ERROR_TITLE, MyCollabUI.getSiteName()),
            UserUIContext.getMessage(GenericI18Enum.ERROR_USER_NOTICE_INFORMATION_MESSAGE),
            UserUIContext.getMessage(GenericI18Enum.BUTTON_YES),
            UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> {
            });
    Button okBtn = dialog.getOkButton();
    BrowserWindowOpener opener = new BrowserWindowOpener("http://support.mycollab.com");
    opener.extend(okBtn);
}

From source file:com.oodrive.nuage.webui.component.window.AbstractConfirmationWindow.java

License:Apache License

@SuppressWarnings("serial")
@Override/*from  w w  w. j  a v  a  2  s.  co m*/
public Window init(final AbstractItemModel model) {

    // Add new window
    final Window vvrConfirmationWindow = new Window("Confirmation");
    vvrConfirmationWindow.center();
    vvrConfirmationWindow.setResizable(false);
    final VerticalLayout vvrConfirmationLayout = new VerticalLayout();
    vvrConfirmationLayout.setMargin(true);
    vvrConfirmationWindow.setContent(vvrConfirmationLayout);

    // Message to display before buttons
    final Label confirmationMessage = new Label(confirmation);
    vvrConfirmationLayout.addComponent(confirmationMessage);
    vvrConfirmationLayout.setComponentAlignment(confirmationMessage, Alignment.MIDDLE_CENTER);
    vvrConfirmationLayout.setSpacing(true);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    vvrConfirmationLayout.addComponent(buttonLayout);
    // Button OK
    final Button okButton = new Button("OK");
    buttonLayout.setSizeFull();
    buttonLayout.addComponent(okButton);
    buttonLayout.setComponentAlignment(okButton, Alignment.MIDDLE_CENTER);
    okButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                action.execute(model);
                vvrConfirmationWindow.close();
            } catch (final Exception e) {
                vvrConfirmationWindow.close();
            }
        }
    });

    // Button cancel
    final Button cancelButton = new Button("Cancel");
    buttonLayout.addComponent(cancelButton);
    buttonLayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER);
    cancelButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            // Just close the window
            vvrConfirmationWindow.close();
        }
    });
    return vvrConfirmationWindow;
}

From source file:com.oodrive.nuage.webui.component.window.ErrorWindow.java

License:Apache License

@SuppressWarnings("serial")
@Override//from   w w w . j  a v a 2s.  com
public final Window init(final AbstractItemModel model) {
    // Add new window with title "Error"
    final Window vvrErrorWindow = new Window("Error");
    vvrErrorWindow.center();
    vvrErrorWindow.setResizable(false);
    final VerticalLayout vvrErrorLayout = new VerticalLayout();
    vvrErrorLayout.setMargin(true);
    vvrErrorWindow.setContent(vvrErrorLayout);

    // Display message
    final Label errorMessage = new Label(message);
    vvrErrorLayout.addComponent(errorMessage);
    vvrErrorLayout.setComponentAlignment(errorMessage, Alignment.MIDDLE_CENTER);
    vvrErrorLayout.setSpacing(true);

    // Button OK
    final Button okButton = new Button("OK");
    vvrErrorLayout.addComponent(okButton);
    vvrErrorLayout.setComponentAlignment(okButton, Alignment.BOTTOM_CENTER);
    okButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            // Just close the window
            vvrErrorWindow.close();
        }
    });
    return vvrErrorWindow;
}

From source file:com.oodrive.nuage.webui.component.window.VvrAttributesWindow.java

License:Apache License

@SuppressWarnings("serial")
@Override//from  w w w. j av a 2s.  co m
public final Window init(final AbstractItemModel model) {

    // Cast model in vvrModel
    final VvrModel vvrModel = (VvrModel) model;
    // Add new window
    final Window vvrAttributesWindow = new Window("VVR Attributes");
    vvrAttributesWindow.center();
    vvrAttributesWindow.setWidth("400px");
    vvrAttributesWindow.setResizable(false);

    final VerticalLayout layout = new VerticalLayout();
    vvrAttributesWindow.setContent(layout);
    layout.setMargin(true);

    final FormLayout vvrAttributesLayout = new FormLayout();
    layout.addComponent(vvrAttributesLayout);
    vvrAttributesLayout.setMargin(true);

    // Enter NAME
    String value = vvrModel.getVvrName();
    if (value == null) {
        value = "";
    }
    final TextField name = new TextField("Name", value);
    name.setSizeFull();
    vvrAttributesLayout.addComponent(name);

    // Enter description
    value = vvrModel.getVvrDescription();
    if (value == null) {
        value = "";
    }
    final TextField desc = new TextField("Description", value);
    desc.setSizeFull();
    vvrAttributesLayout.addComponent(desc);

    // Enter name
    final TextField vvrUUID = new TextField("UUID");
    vvrUUID.setValue(vvrUuid.toString());
    vvrUUID.setReadOnly(true);
    vvrUUID.setSizeFull();
    vvrAttributesLayout.addComponent(vvrUUID);

    // OK button
    final HorizontalLayout hzlayout = new HorizontalLayout();
    layout.addComponent(hzlayout);
    hzlayout.setSizeFull();

    final Button okButton = new Button("OK");
    hzlayout.addComponent(okButton);
    hzlayout.setComponentAlignment(okButton, Alignment.MIDDLE_CENTER);

    okButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            WaitingComponent.executeBackground(vvrModel, new Background() {
                @Override
                public void processing() {
                    vvrModel.setVvrName(name.getValue());
                    vvrModel.setVvrDescription(desc.getValue());
                }

                @Override
                public void postProcessing() {
                }
            });
            vvrAttributesWindow.close();
        }
    });

    // Cancel button
    final Button cancelButton = new Button("Cancel");
    hzlayout.addComponent(cancelButton);
    hzlayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER);

    cancelButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            // Just close the window
            vvrAttributesWindow.close();
        }
    });
    return vvrAttributesWindow;
}