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.esofthead.mycollab.mobile.MobileApplication.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {
    LOG.debug("Init mycollab mobile application {}", this.toString());

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

        @Override//ww  w.  jav a2  s.c  om
        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(AppContext
                        .getMessage(GenericI18Enum.ERROR_USER_INPUT_MESSAGE, invalidException.getMessage()));
            } else {

                UsageExceedBillingPlanException usageBillingException = (UsageExceedBillingPlanException) getExceptionType(
                        e, UsageExceedBillingPlanException.class);
                if (usageBillingException != null) {
                    if (AppContext.isAdmin()) {
                        ConfirmDialog.show(UI.getCurrent(),
                                AppContext.getMessage(GenericI18Enum.EXCEED_BILLING_PLAN_MSG_FOR_ADMIN),
                                AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                                AppContext.getMessage(GenericI18Enum.BUTTON_NO),
                                new ConfirmDialog.CloseListener() {
                                    private static final long serialVersionUID = 1L;

                                    @Override
                                    public void onClose(ConfirmDialog dialog) {
                                        if (dialog.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(
                                AppContext.getMessage(GenericI18Enum.EXCEED_BILLING_PLAN_MSG_FOR_USER));
                    }
                } else {
                    LOG.error("Error", e);
                    NotificationUtil.showErrorNotification(
                            AppContext.getMessage(GenericI18Enum.ERROR_USER_NOTICE_INFORMATION_MESSAGE));
                }
            }

        }
    });

    initialUrl = this.getPage().getUriFragment();
    MyCollabSession.putVariable(CURRENT_APP, this);
    currentContext = new AppContext();
    postSetupApp(request);
    try {
        currentContext.initDomain(initialSubDomain);
    } catch (Exception e) {
        // TODO: show content notice user there is no existing domain
        return;
    }

    this.getLoadingIndicatorConfiguration().setFirstDelay(0);
    this.getLoadingIndicatorConfiguration().setSecondDelay(300);
    this.getLoadingIndicatorConfiguration().setThirdDelay(500);

    final MobileNavigationManager manager = new MobileNavigationManager();
    manager.addNavigationListener(new NavigationManager.NavigationListener() {
        private static final long serialVersionUID = -2317588983851761998L;

        @SuppressWarnings("unchecked")
        @Override
        public void navigate(NavigationEvent event) {
            NavigationManager currentNavigator = (NavigationManager) event.getSource();
            if (event.getDirection() == Direction.BACK) {
                Component nextComponent = currentNavigator.getNextComponent();
                ViewState currentState = MobileHistoryViewManager.peak();

                if (!(currentState instanceof NullViewState)
                        && currentState.getPresenter().getView().equals(nextComponent)) {
                    ViewState viewState = MobileHistoryViewManager.pop();
                    while (!(viewState instanceof NullViewState)) {
                        if (viewState.getPresenter().getView().equals(currentNavigator.getCurrentComponent())) {
                            viewState.getPresenter().go(viewState.getContainer(), viewState.getParams());
                            break;
                        }
                        viewState = MobileHistoryViewManager.pop(false);
                    }
                }
                if (nextComponent instanceof NavigationView) {
                    ((NavigationView) nextComponent).setPreviousComponent(null);
                }
                currentNavigator.removeComponent(nextComponent);
                currentNavigator.getState().setNextComponent(null);

            }
        }
    });
    setContent(manager);

    registerControllers(manager);

    getPage().addUriFragmentChangedListener(new UriFragmentChangedListener() {

        private static final long serialVersionUID = -6410955178515535406L;

        @Override
        public void uriFragmentChanged(UriFragmentChangedEvent event) {
            setInitialUrl(event.getUriFragment());
            enter(event.getUriFragment());
        }
    });
    enter(initialUrl);
}

From source file:com.esofthead.mycollab.vaadin.ui.UIUtils.java

License:Open Source License

public static void removeAllWindows() {
    Collection<Window> windows = UI.getCurrent().getWindows();
    for (Window window : windows) {
        window.close();
    }/*from w ww  . ja  v  a  2  s.  c  o  m*/
}

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

License:Open Source License

private void handleException(Throwable e) {
    IgnoreException ignoreException = (IgnoreException) getExceptionType(e, IgnoreException.class);
    if (ignoreException != null) {
        return;//from   www.j  a va2s .  c o  m
    }

    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(
                AppContext.getMessage(GenericI18Enum.ERROR_USER_INPUT_MESSAGE, invalidException.getMessage()));
        return;
    }

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

    ResourceNotFoundException resourceNotFoundException = (ResourceNotFoundException) getExceptionType(e,
            ResourceNotFoundException.class);
    if (resourceNotFoundException != null) {
        NotificationUtil.showWarningNotification("Can not found resource.");
        LOG.error("404", resourceNotFoundException);
    }

    UsageExceedBillingPlanException usageBillingException = (UsageExceedBillingPlanException) getExceptionType(
            e, UsageExceedBillingPlanException.class);
    if (usageBillingException != null) {
        if (AppContext.isAdmin()) {
            ConfirmDialogExt.show(UI.getCurrent(),
                    AppContext.getMessage(GenericI18Enum.WINDOW_ATTENTION_TITLE,
                            SiteConfiguration.getSiteName()),
                    AppContext.getMessage(GenericI18Enum.EXCEED_BILLING_PLAN_MSG_FOR_ADMIN),
                    AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                    AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void onClose(ConfirmDialog dialog) {
                            if (dialog.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(
                    AppContext.getMessage(GenericI18Enum.EXCEED_BILLING_PLAN_MSG_FOR_USER));
        }
    } else {
        LOG.error("Error", e);
        NotificationUtil.showErrorNotification(
                AppContext.getMessage(GenericI18Enum.ERROR_USER_NOTICE_INFORMATION_MESSAGE));

    }
}

From source file:com.etest.view.systemadministration.SemestralTeam.AddSemestralTeamMembersWindow.java

Window removeTeamMemberWindow(int facultyRowId) {
    Window sub = new Window();
    sub.setCaption("REMOVE TEAM MEMBER");
    sub.setWidth("250px");
    sub.setModal(true);/*from  w  w  w  .j  a va  2s.  c  om*/
    sub.center();

    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSizeFull();
    vlayout.setMargin(true);

    Button removeBtn = new Button("REMOVE");
    removeBtn.setWidth("100%");
    removeBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    removeBtn.addStyleName(ValoTheme.BUTTON_SMALL);
    removeBtn.addClickListener((Button.ClickEvent event) -> {
        boolean result = tts.removeTeamMember(getTeamTeachId(), facultyRowId);
        if (result) {
            populateDataTable();
            sub.close();
        }
    });
    vlayout.addComponent(removeBtn);

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

    return sub;
}

From source file:com.etest.view.systemadministration.SemestralTeam.AddSemestralTeamMembersWindow.java

Window editTeamMemberPositionWindow(int facultyRowId) {
    Window sub = new Window();
    sub.setCaption("REMOVE TEAM MEMBER");
    sub.setWidth("250px");
    sub.setModal(true);/*ww w . j  a va2s . c om*/
    sub.center();

    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSizeFull();
    vlayout.setSpacing(true);
    vlayout.setMargin(true);

    String name = fs.getFacultyNameById(facultyRowId);
    vlayout.addComponent(new Label("Set " + name.toUpperCase() + " as Team Leader."));

    Button updateBtn = new Button("UPDATE");
    updateBtn.setWidth("100%");
    updateBtn.setIcon(FontAwesome.USER);
    updateBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    updateBtn.addStyleName(ValoTheme.BUTTON_SMALL);
    updateBtn.addClickListener((Button.ClickEvent event) -> {
        int userId = us.getUserIdByFacultyId(facultyRowId);
        boolean result = tts.updateTeamTeach(getTeamTeachId(), userId);
        if (result) {
            sub.close();
            populateDataTable();
            close();
        }
    });
    vlayout.addComponent(updateBtn);

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

    return sub;
}

From source file:com.etest.view.testbank.CellCaseWindow.java

Window modifyCaseWindow(CellCase cellCase) {
    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setMargin(true);/*from  ww w .  j  av  a 2  s .  co m*/
    v.setSpacing(true);

    Window sub = new Window("MODIFY");
    sub.setWidth("400px");
    sub.setModal(true);
    sub.center();

    ComboBox actionDone = new ComboBox("Action: ");
    actionDone.setWidth("70%");
    actionDone.addStyleName(ValoTheme.COMBOBOX_SMALL);
    actionDone.setNullSelectionAllowed(false);
    actionDone.addItem("resolved");
    actionDone.addItem("clarified");
    actionDone.addItem("modified");
    actionDone.setImmediate(true);
    v.addComponent(actionDone);

    TextArea remarks = new TextArea("Remarks: ");
    remarks.setWidth("100%");
    remarks.setRows(3);
    v.addComponent(remarks);

    Button modify = new Button("UPDATE");
    modify.setWidth("70%");
    modify.setIcon(FontAwesome.EDIT);
    modify.addStyleName(ValoTheme.BUTTON_PRIMARY);
    modify.addStyleName(ValoTheme.BUTTON_SMALL);
    modify.addClickListener((Button.ClickEvent event) -> {
        if (remarks.getValue() == null || remarks.getValue().trim().isEmpty()) {
            Notification.show("Add remarks!", Notification.Type.WARNING_MESSAGE);
            return;
        }

        if (actionDone.getValue() == null) {
            Notification.show("Add action!", Notification.Type.WARNING_MESSAGE);
            return;
        }

        cellCase.setActionDone(actionDone.getValue().toString());
        cellCase.setRemarks(remarks.getValue().trim());
        boolean result = ccs.modifyCellCase(cellCase);
        if (result) {
            Notification.show("Case has been Modified!", Notification.Type.TRAY_NOTIFICATION);
            sub.close();
            close();
        }
    });
    v.addComponent(modify);

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

    return sub;
}

From source file:com.etest.view.testbank.CellCaseWindow.java

Window deleteCaseWindow() {
    Window sub = new Window("DELETE");
    sub.setWidth("250px");
    sub.setModal(true);//from  w  ww  . java 2  s. c o  m
    sub.center();

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

    Button delete = new Button("DELETE CASE?");
    delete.setWidth("100%");
    delete.setImmediate(true);
    delete.addClickListener((Button.ClickEvent event) -> {
        boolean result = ccs.removeCellCase(getCellCaseId());
        if (result) {
            sub.close();
            close();
        }
    });

    v.addComponent(delete);

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

    return sub;
}

From source file:com.etest.view.testbank.cellitem.CellItemWindow.java

Window modifyCellItemWindow(CellItem ci) {
    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setMargin(true);/*from w w w  . ja  va  2  s  .c  o  m*/
    v.setSpacing(true);

    Window sub = new Window("MODIFY");
    sub.setWidth("400px");
    sub.setModal(true);
    sub.center();

    ComboBox actionDone = new ComboBox("Action: ");
    actionDone.setWidth("70%");
    actionDone.addStyleName(ValoTheme.COMBOBOX_SMALL);
    actionDone.setNullSelectionAllowed(false);
    actionDone.addItem("resolved");
    actionDone.addItem("clarified");
    actionDone.addItem("modified");
    actionDone.setImmediate(true);
    v.addComponent(actionDone);

    TextArea remarks = new TextArea("Remarks: ");
    remarks.setWidth("100%");
    remarks.setRows(3);
    v.addComponent(remarks);

    Button modify = new Button("UPDATE");
    modify.setWidth("70%");
    modify.setIcon(FontAwesome.EDIT);
    modify.addStyleName(ValoTheme.BUTTON_PRIMARY);
    modify.addStyleName(ValoTheme.BUTTON_SMALL);
    modify.addClickListener((Button.ClickEvent event) -> {
        if (remarks.getValue() == null || remarks.getValue().trim().isEmpty()) {
            Notification.show("Add remarks!", Notification.Type.WARNING_MESSAGE);
            return;
        }

        if (actionDone.getValue() == null) {
            Notification.show("Add action!", Notification.Type.WARNING_MESSAGE);
            return;
        }

        ci.setRemarks(remarks.getValue().trim());
        ci.setActionDone(actionDone.getValue().toString());
        boolean result = cis.modifyCellItem(ci);
        if (result) {
            sub.close();
            close();
        }
    });
    v.addComponent(modify);

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

    return sub;
}

From source file:com.etest.view.testbank.cellitem.CellItemWindow.java

Window modifyKeyWindow(int itemKeyId, int cellItemId, String keyValue, String optionValue,
        boolean isOptionKeyExist) {
    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setMargin(true);// www  .  ja  v  a2s  .  com
    v.setSpacing(true);

    Window sub = new Window("MODIFY");
    sub.setWidth("400px");
    sub.setModal(true);
    sub.center();

    ComboBox actionDone = new ComboBox("Action: ");
    actionDone.setWidth("70%");
    actionDone.addStyleName(ValoTheme.COMBOBOX_SMALL);
    actionDone.setNullSelectionAllowed(false);
    actionDone.addItem("resolved");
    actionDone.addItem("clarified");
    actionDone.addItem("modified");
    actionDone.setImmediate(true);
    v.addComponent(actionDone);

    TextArea remarks = new TextArea("Remarks: ");
    remarks.setWidth("100%");
    remarks.setRows(3);
    v.addComponent(remarks);

    Button modify = new Button("UPDATE");
    modify.setWidth("70%");
    modify.setIcon(FontAwesome.EDIT);
    modify.addStyleName(ValoTheme.BUTTON_PRIMARY);
    modify.addStyleName(ValoTheme.BUTTON_SMALL);
    modify.addClickListener((Button.ClickEvent event) -> {
        if (remarks.getValue() == null || remarks.getValue().trim().isEmpty()) {
            Notification.show("Add remarks!", Notification.Type.WARNING_MESSAGE);
            return;
        }

        if (actionDone.getValue() == null) {
            Notification.show("Add action!", Notification.Type.WARNING_MESSAGE);
            return;
        }

        boolean result = k.modifyItemKey(itemKeyId, cellItemId, keyValue, optionValue, isOptionKeyExist,
                remarks.getValue().trim(), actionDone.getValue().toString());
        if (result) {
            Notification.show("Key SUCCESSFULLY modified", Notification.Type.TRAY_NOTIFICATION);
            sub.close();
        }
    });
    v.addComponent(modify);

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

    return sub;
}

From source file:com.etest.view.testbank.cellitem.ViewStemWindow.java

Window removeKeyWindow(int itemKeyId) {
    Window sub = new Window("REMOVE KEY");
    sub.setWidth("300px");
    sub.setModal(true);/*  www  . ja  v  a2  s . c  om*/
    sub.center();

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

    Button remove = new Button("CONFIRM REMOVE KEY?");
    remove.setWidth("100%");
    remove.setIcon(FontAwesome.TRASH_O);
    remove.addStyleName(ValoTheme.BUTTON_PRIMARY);
    remove.addStyleName(ValoTheme.BUTTON_SMALL);
    remove.addClickListener((Button.ClickEvent event) -> {
        boolean result = k.removeItemKey(itemKeyId);
        if (result) {
            sub.close();
            close();
        }
    });
    v.addComponent(remove);

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

    return sub;
}