Example usage for com.vaadin.ui Notification show

List of usage examples for com.vaadin.ui Notification show

Introduction

In this page you can find the example usage for com.vaadin.ui Notification show.

Prototype

public static Notification show(String caption, Type type) 

Source Link

Document

Shows a notification message the current page.

Usage

From source file:com.klwork.explorer.ui.business.project.TodoSharePopupWindow.java

License:Apache License

public TodoSharePopupWindow(String projectId) {
    super("0");
    this.socialUserWeiboService = ViewToolManager.getBean("socialUserWeiboService");
    this.socialSinaService = ViewToolManager.getBean("socialSinaService");
    this.socialUserAccountService = ViewToolManager.getBean("socialUserAccountService");
    this.socialMainService = ViewToolManager.getBean("socialMainService");
    this.i18nManager = ViewToolManager.getI18nManager();

    this.projectId = projectId;//id

    initTodoListImage(projectId);/*from   w  w  w  . j av  a  2  s . co m*/
    mainLayout = new VerticalLayout() {
        {
            setSizeFull();
            setSpacing(true);
            setMargin(new MarginInfo(true, true, false, true));

            addComponent(new HorizontalLayout() {// ?,?
                {
                    // setSizeFull();
                    // setSpacing(true);
                    setWidth("100%");
                    // setSpacing(true);
                    // setMargin(true);
                    /*Image image = initFaceComponet();
                    addComponent(image);
                    setExpandRatio(image, 1.2f);
                    setComponentAlignment(image, Alignment.MIDDLE_LEFT);*/
                    //
                    Label inputFontField = initInputFontField();
                    addComponent(inputFontField);
                    // setExpandRatio(image, 1.0f);
                    setComponentAlignment(inputFontField, Alignment.MIDDLE_RIGHT);
                    setExpandRatio(inputFontField, 0.2f);
                }
            });

            // ?

            weiboContentTA.setWidth("100%");
            weiboContentTA.setColumns(25);
            weiboContentTA.focus();
            addComponent(weiboContentTA);

            /*Label descriptionField = new Label();
            descriptionField.addStyleName("wb_text");
            descriptionField.setContentMode(ContentMode.HTML);
            descriptionField.setValue();
            addComponent(descriptionField);*/

            accountGroup = new OptionGroup("?????");
            accountGroup.setMultiSelect(true);
            accountGroup.setStyleName("horizontal");
            addComponent(accountGroup);
            SocialUserAccountQuery query = new SocialUserAccountQuery();
            query.setOwnUser(LoginHandler.getLoggedInUser().getId());

            List<SocialUserAccount> list = socialUserAccountService.findSocialUserAccountByQueryCriteria(query,
                    null);
            for (Iterator iterator = list.iterator(); iterator.hasNext();) {
                SocialUserAccount s = (SocialUserAccount) iterator.next();
                String p = s.getId();
                Item i = accountGroup.addItem(p);
                accountGroup.setItemCaption(p, s.queryTypeName() + "_" + s.getName());
            }

            // 
            HorizontalLayout buttonLayout = new HorizontalLayout() {
                {
                    setSpacing(true);
                    setSizeFull();

                    Image image = initFaceComponet();//
                    addComponent(image);
                    setComponentAlignment(image, Alignment.TOP_LEFT);
                    // setMargin(true);
                    Button okButton = new Button("?");
                    addComponent(okButton);
                    setComponentAlignment(okButton, Alignment.TOP_RIGHT);

                    okButton.addClickListener(new ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            handlerSendWeibo();
                            Notification.show("??", Notification.Type.HUMANIZED_MESSAGE);
                            close();
                        }
                    });
                    setExpandRatio(okButton, 1.0f);

                    Button cancleButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL));
                    addComponent(cancleButton);
                    setComponentAlignment(cancleButton, Alignment.TOP_RIGHT);

                    cancleButton.addClickListener(new ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            // handleFormSubmit();
                            close();
                        }
                    });
                }
            };
            addComponent(buttonLayout);
            setExpandRatio(buttonLayout, 1f);

        }
    };
    setContent(mainLayout);
    setMainLayout(mainLayout);
    setWeiboContentTextArea(weiboContentTA);
}

From source file:com.klwork.explorer.ui.business.social.DiscussPopupWindow.java

License:Apache License

public VerticalLayout initMainLayout(final SocialUserWeibo userWeibo) {
    return new VerticalLayout() {
        {//from   ww  w.ja  v a2s  .  com
            setSizeFull();
            setSpacing(true);
            setMargin(new MarginInfo(true, true, false, true));

            Label descriptionField = new Label();
            descriptionField.addStyleName("wb_text");
            descriptionField.setContentMode(ContentMode.HTML);
            descriptionField.setValue(
                    "@" + userWeibo.getUserScreenName() + ":" + mainPage.textTranslate(userWeibo.getText()));
            addComponent(descriptionField);

            addComponent(new HorizontalLayout() {// ?,?
                {
                    setWidth("100%");

                    //
                    Label inputFontField = initInputFontField();
                    addComponent(inputFontField);
                    // setExpandRatio(image, 1.0f);
                    setComponentAlignment(inputFontField, Alignment.MIDDLE_RIGHT);
                    setExpandRatio(inputFontField, 0.2f);
                }
            });

            // ?
            weiboContentTA = new TextArea("");
            weiboContentTA.setWidth("100%");
            weiboContentTA.setColumns(25);
            weiboContentTA.focus();
            addComponent(weiboContentTA);
            scheduleEventFieldGroup.bind(weiboContentTA, "content");

            // ?
            addComponent(new HorizontalLayout() {
                {
                    setSpacing(true);
                    // setSizeFull();
                    // setMargin(true);
                    CheckBox simuField = CommonFieldHandler.createCheckBox("");
                    simuField.addValueChangeListener(new Property.ValueChangeListener() {

                        private static final long serialVersionUID = -7104996493482558021L;

                        @Override
                        public void valueChange(ValueChangeEvent event) {
                            Object value = event.getProperty().getValue();
                        }

                    });
                    addComponent(simuField);
                    // setExpandRatio(image, 1.0f);
                    setComponentAlignment(simuField, Alignment.MIDDLE_LEFT);

                    Label commentLable = new Label();
                    commentLable.setContentMode(ContentMode.HTML);
                    commentLable.setValue("????");

                    addComponent(commentLable);
                    // setExpandRatio(image, 1.0f);
                    setComponentAlignment(commentLable, Alignment.MIDDLE_LEFT);

                    Image image = initFaceComponet();//
                    addComponent(image);
                }
            });

            // 
            HorizontalLayout buttonLayout = new HorizontalLayout() {
                {
                    setSpacing(true);
                    setSizeFull();
                    // setMargin(true);
                    Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK));
                    addComponent(okButton);
                    setComponentAlignment(okButton, Alignment.TOP_RIGHT);

                    okButton.addClickListener(new ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            BinderHandler.commit(scheduleEventFieldGroup);
                            int ret = socialService.discussWeibo(weiboForwardSend);
                            if (ret == 1) {
                                Notification.show("??", Notification.Type.HUMANIZED_MESSAGE);
                            }
                            close();
                        }
                    });
                    setExpandRatio(okButton, 1.0f);

                    Button cancleButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL));
                    addComponent(cancleButton);
                    setComponentAlignment(cancleButton, Alignment.TOP_RIGHT);

                    cancleButton.addClickListener(new ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            close();
                        }
                    });
                }
            };
            addComponent(buttonLayout);
            setExpandRatio(buttonLayout, 1f);

        }
    };
}

From source file:com.klwork.explorer.ui.business.social.SaveToNotePopupWindow.java

License:Apache License

public VerticalLayout initMainLayout(final SocialUserWeibo userWeibo) {
    return new VerticalLayout() {
        {/*from  ww w. ja  v a  2  s. co m*/
            setSizeFull();
            setSpacing(true);
            setMargin(new MarginInfo(true, true, false, true));

            Label descriptionField = new Label();
            descriptionField.addStyleName("wb_text");
            descriptionField.setContentMode(ContentMode.HTML);
            descriptionField.setValue("");
            addComponent(descriptionField);
            // ?
            weiboContentTA = new TextArea("");
            weiboContentTA.setWidth("100%");
            weiboContentTA.setColumns(25);
            weiboContentTA.focus();
            addComponent(weiboContentTA);
            scheduleEventFieldGroup.bind(weiboContentTA, "content");

            if (hasOrginWeibo) {// 
                weiboContentTA.setValue("//@" + userWeibo.getUserScreenName() + ": " + userWeibo.getText());
            } else {
                weiboContentTA.setValue(userWeibo.getText());
                //+ mainPage.textTranslate(userWeibo.getText()));
            }

            //,
            addComponent(new VerticalLayout() {
                {
                    setSpacing(true);

                    TextField titleField = CommonFieldHandler.createTextField("");
                    scheduleEventFieldGroup.bind(titleField, "title");

                    //???
                    if (userWeibo.getText() != null && userWeibo.getText().length() > 10) {
                        titleField.setValue(userWeibo.getText().substring(0, 10));
                    }
                    addComponent(titleField);
                    // setSizeFull();
                    // setMargin(true);
                    SocialUserAccount noteAccount = socialUserAccountService
                            .findSocialUserByType(socialUserAccount.getOwnUser(), DictDef.dictInt("evernote"));
                    if (noteAccount != null) {
                        noteEntity.setUserAccountId(noteAccount.getId());
                    }

                    Map<String, String> map = socialEvernoteService.queryNotebook(noteAccount);
                    ComboBox noteMap = CommonFieldHandler.createComBox("", map, "");
                    addComponent(noteMap);
                    setComponentAlignment(noteMap, Alignment.MIDDLE_LEFT);
                }
            });

            // 
            HorizontalLayout buttonLayout = new HorizontalLayout() {
                {
                    setSpacing(true);
                    setSizeFull();
                    // setMargin(true);
                    Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK));
                    addComponent(okButton);
                    setComponentAlignment(okButton, Alignment.TOP_RIGHT);

                    okButton.addClickListener(new ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            BinderHandler.commit(scheduleEventFieldGroup);
                            //?
                            int ret = socialEvernoteService.saveWeiboToNotes(noteEntity);
                            if (ret == 1) {
                                Notification.show("??", Notification.Type.HUMANIZED_MESSAGE);
                            } else {
                                Notification.show("??!", Notification.Type.HUMANIZED_MESSAGE);
                            }
                            close();
                        }
                    });
                    setExpandRatio(okButton, 1.0f);

                    Button cancleButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL));
                    addComponent(cancleButton);
                    setComponentAlignment(cancleButton, Alignment.TOP_RIGHT);

                    cancleButton.addClickListener(new ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            close();
                        }
                    });
                }
            };
            addComponent(buttonLayout);
            setExpandRatio(buttonLayout, 1f);

        }
    };
}

From source file:com.klwork.explorer.ui.business.social.TransmitPopupWindow.java

License:Apache License

public TransmitPopupWindow(final SocialUserWeibo userWeibo, final AbstractWeiboDisplayPage mainPage) {
    super(mainPage.getSocialType());
    this.socialUserWeiboService = ViewToolManager.getBean("socialUserWeiboService");
    this.socialService = AbstractSocialService.querySocialClass(mainPage.getSocialType());

    this.i18nManager = ViewToolManager.getI18nManager();

    weiboForwardSend.setWeibId(userWeibo.getWeiboId());
    weiboForwardSend.setUserAccountId(userWeibo.getUserAccountId());
    this.userWeibo = userWeibo;
    if (userWeibo.getRetweetedId() != null) {
        orginWeibo = socialUserWeiboService.findSocialUserWeiboById(userWeibo.getRetweetedId());
        hasOrginWeibo = true;//from ww w.j a va 2s. c  om
        weiboForwardSend.setWeibId(orginWeibo.getId());
    }

    scheduleEventFieldGroup.setBuffered(true);
    if (currentBeanItem != null) {
        scheduleEventFieldGroup.setItemDataSource(currentBeanItem);
    }

    mainLayout = new VerticalLayout() {
        {
            setSizeFull();
            setSpacing(true);
            setMargin(new MarginInfo(true, true, false, true));

            Label descriptionField = new Label();
            descriptionField.addStyleName("wb_text");
            descriptionField.setContentMode(ContentMode.HTML);
            descriptionField.setValue(
                    "@" + userWeibo.getUserScreenName() + ":" + mainPage.textTranslate(userWeibo.getText()));
            if (hasOrginWeibo) {
                descriptionField.setValue("@" + orginWeibo.getUserScreenName() + ":"
                        + mainPage.textTranslate(orginWeibo.getText()));
            }
            addComponent(descriptionField);

            addComponent(new HorizontalLayout() {// ?,?
                {
                    // setSizeFull();
                    // setSpacing(true);
                    setWidth("100%");
                    // setSpacing(true);
                    // setMargin(true);
                    /*Image image = initFaceComponet();
                    addComponent(image);
                    setExpandRatio(image, 1.2f);
                    setComponentAlignment(image, Alignment.MIDDLE_LEFT);*/
                    //
                    Label inputFontField = initInputFontField();
                    addComponent(inputFontField);
                    // setExpandRatio(image, 1.0f);
                    setComponentAlignment(inputFontField, Alignment.MIDDLE_RIGHT);
                    setExpandRatio(inputFontField, 0.2f);
                }
            });

            // ?

            weiboContentTA.setWidth("100%");
            weiboContentTA.setColumns(25);
            weiboContentTA.focus();
            addComponent(weiboContentTA);
            scheduleEventFieldGroup.bind(weiboContentTA, "content");
            if (hasOrginWeibo) {// 
                weiboContentTA.setValue("//@" + userWeibo.getUserScreenName() + ": " + userWeibo.getText());
            }

            // ?
            addComponent(new HorizontalLayout() {
                {
                    setSpacing(true);
                    // setSizeFull();
                    // setMargin(true);
                    CheckBox simuField = CommonFieldHandler.createCheckBox("");
                    simuField.addValueChangeListener(new Property.ValueChangeListener() {

                        private static final long serialVersionUID = -7104996493482558021L;

                        @Override
                        public void valueChange(ValueChangeEvent event) {
                            Object value = event.getProperty().getValue();
                        }

                    });
                    addComponent(simuField);
                    // setExpandRatio(image, 1.0f);
                    setComponentAlignment(simuField, Alignment.MIDDLE_LEFT);

                    Label commentLable = new Label();
                    commentLable.setContentMode(ContentMode.HTML);
                    commentLable.setValue("? " + "" + userWeibo.getUserScreenName());

                    addComponent(commentLable);
                    // setExpandRatio(image, 1.0f);
                    setComponentAlignment(commentLable, Alignment.MIDDLE_LEFT);

                    Image image = initFaceComponet();//
                    addComponent(image);
                }
            });

            if (hasOrginWeibo) {
                // ?
                addComponent(new HorizontalLayout() {
                    {
                        // setSizeFull();
                        setSpacing(true);
                        // setMargin(true);
                        CheckBox simuOriginalField = CommonFieldHandler.createCheckBox("");
                        simuOriginalField.addValueChangeListener(new Property.ValueChangeListener() {

                            private static final long serialVersionUID = -7104996493482558021L;

                            @Override
                            public void valueChange(ValueChangeEvent event) {
                                Object value = event.getProperty().getValue();
                            }

                        });
                        addComponent(simuOriginalField);
                        // setExpandRatio(image, 1.0f);
                        setComponentAlignment(simuOriginalField, Alignment.MIDDLE_LEFT);

                        Label commentLable = new Label();
                        commentLable.setContentMode(ContentMode.HTML);
                        commentLable
                                .setValue("? " + "" + orginWeibo.getUserScreenName());

                        addComponent(commentLable);
                        // setExpandRatio(image, 1.0f);
                        setComponentAlignment(commentLable, Alignment.MIDDLE_LEFT);
                    }
                });
            }

            // 
            HorizontalLayout buttonLayout = new HorizontalLayout() {
                {
                    setSpacing(true);
                    setSizeFull();
                    // setMargin(true);
                    Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK));
                    addComponent(okButton);
                    setComponentAlignment(okButton, Alignment.TOP_RIGHT);

                    okButton.addClickListener(new ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            BinderHandler.commit(scheduleEventFieldGroup);
                            int ret = socialService.forwardWeibo(weiboForwardSend);
                            if (ret == 1) {
                                Notification.show("??", Notification.Type.HUMANIZED_MESSAGE);
                            }
                            close();
                        }
                    });
                    setExpandRatio(okButton, 1.0f);

                    Button cancleButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL));
                    addComponent(cancleButton);
                    setComponentAlignment(cancleButton, Alignment.TOP_RIGHT);

                    cancleButton.addClickListener(new ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            // handleFormSubmit();
                            close();
                        }
                    });
                }
            };
            addComponent(buttonLayout);
            setExpandRatio(buttonLayout, 1f);

        }
    };
    setContent(mainLayout);
    setMainLayout(mainLayout);
    setWeiboContentTextArea(weiboContentTA);
}

From source file:com.klwork.explorer.ui.business.social.WeiboSendPopupWindow.java

License:Apache License

public WeiboSendPopupWindow(final SocialUserAccount socialUserAccount) {
    super(socialUserAccount.getType().toString());
    this.socialUserWeiboService = ViewToolManager.getBean("socialUserWeiboService");
    this.socialSinaService = ViewToolManager.getBean("socialSinaService");
    this.socialUserAccountService = ViewToolManager.getBean("socialUserAccountService");
    this.socialMainService = ViewToolManager.getBean("socialMainService");
    this.i18nManager = ViewToolManager.getI18nManager();
    this.socialUserAccount = socialUserAccount;

    scheduleEventFieldGroup.setBuffered(true);
    if (currentBeanItem != null) {
        scheduleEventFieldGroup.setItemDataSource(currentBeanItem);
    }//  www  . ja  v a  2  s.  c o  m

    mainLayout = new VerticalLayout() {
        {
            setSizeFull();
            setSpacing(true);
            setMargin(new MarginInfo(true, true, false, true));

            addComponent(new HorizontalLayout() {// ?,?
                {
                    // setSizeFull();
                    // setSpacing(true);
                    setWidth("100%");
                    // setSpacing(true);
                    // setMargin(true);
                    /*
                     * Image image = initFaceComponet();
                     * addComponent(image); setExpandRatio(image, 1.2f);
                     * setComponentAlignment(image, Alignment.MIDDLE_LEFT);
                     */
                    //
                    Label inputFontField = initInputFontField();
                    addComponent(inputFontField);
                    // setExpandRatio(image, 1.0f);
                    setComponentAlignment(inputFontField, Alignment.MIDDLE_RIGHT);
                    setExpandRatio(inputFontField, 0.2f);
                }
            });

            // ?

            weiboContentTA.setWidth("100%");
            weiboContentTA.setColumns(25);
            weiboContentTA.focus();
            addComponent(weiboContentTA);
            scheduleEventFieldGroup.bind(weiboContentTA, "content");

            /*
             * Label descriptionField = new Label();
             * descriptionField.addStyleName("wb_text");
             * descriptionField.setContentMode(ContentMode.HTML);
             * descriptionField.setValue(); addComponent(descriptionField);
             */

            accountGroup = new OptionGroup("?????");
            accountGroup.setMultiSelect(true);
            accountGroup.setStyleName("horizontal");
            addComponent(accountGroup);
            SocialUserAccountQuery query = new SocialUserAccountQuery();
            query.setOwnUser(socialUserAccount.getOwnUser());

            List<SocialUserAccount> list = socialUserAccountService.findSocialUserAccountByQueryCriteria(query,
                    null);
            for (Iterator iterator = list.iterator(); iterator.hasNext();) {
                SocialUserAccount s = (SocialUserAccount) iterator.next();
                String p = s.getId();
                if (p.equals(socialUserAccount.getId())) {
                    continue;
                }
                Item i = accountGroup.addItem(p);
                accountGroup.setItemCaption(p, s.queryTypeName() + "_" + s.getName());
            }

            // 
            HorizontalLayout buttonLayout = new HorizontalLayout() {
                {
                    setSpacing(true);
                    setSizeFull();

                    Image image = initFaceComponet();// 
                    addComponent(image);
                    setComponentAlignment(image, Alignment.TOP_LEFT);
                    // setMargin(true);
                    Button okButton = new Button("?");
                    addComponent(okButton);
                    setComponentAlignment(okButton, Alignment.TOP_RIGHT);

                    okButton.addClickListener(new ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            BinderHandler.commit(scheduleEventFieldGroup);
                            handlerSendWeibo();
                            Notification.show("??", Notification.Type.HUMANIZED_MESSAGE);
                            close();
                        }
                    });
                    setExpandRatio(okButton, 1.0f);

                    Button cancleButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL));
                    addComponent(cancleButton);
                    setComponentAlignment(cancleButton, Alignment.TOP_RIGHT);

                    cancleButton.addClickListener(new ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            // handleFormSubmit();
                            close();
                        }
                    });
                }
            };
            addComponent(buttonLayout);
            setExpandRatio(buttonLayout, 1f);

        }
    };
    setContent(mainLayout);
    setMainLayout(mainLayout);
    setWeiboContentTextArea(weiboContentTA);
}

From source file:com.klwork.explorer.web.MyNavigationUI.java

License:Apache License

/**
 * Exception on action//  w  w w.j  a v a 2 s  . c  o m
 */
@Override
public void error(com.vaadin.server.ErrorEvent event) {
    // connector event
    if (event.getThrowable().getCause() instanceof IllegalArgumentException) {
        IllegalArgumentException exception = (IllegalArgumentException) event.getThrowable().getCause();
        Notification.show(exception.getMessage(), Notification.Type.ERROR_MESSAGE);

        // Cleanup view. Now Vaadin ignores errors and always shows the view.  :-(
        // since beta10
        setContent(null);
        return;
    }

    // Error on page load. Now it doesn't work. User sees standard error page.
    if (event.getThrowable() instanceof IllegalArgumentException) {
        IllegalArgumentException exception = (IllegalArgumentException) event.getThrowable();

        Label label = new Label(exception.getMessage());
        label.setWidth(-1, Unit.PERCENTAGE);

        Link goToMain = new Link("Go to main", new ExternalResource("/"));

        VerticalLayout layout = new VerticalLayout();
        layout.addComponent(label);
        layout.addComponent(goToMain);
        layout.setComponentAlignment(label, Alignment.MIDDLE_CENTER);
        layout.setComponentAlignment(goToMain, Alignment.MIDDLE_CENTER);

        VerticalLayout mainLayout = new VerticalLayout();
        mainLayout.setSizeFull();
        mainLayout.addComponent(layout);
        mainLayout.setComponentAlignment(layout, Alignment.MIDDLE_CENTER);

        setContent(mainLayout);
        Notification.show(exception.getMessage(), Notification.Type.ERROR_MESSAGE);
        return;
    }

    DefaultErrorHandler.doDefault(event);
}

From source file:com.lst.deploymentautomation.vaadin.core.AppNavigator.java

License:Open Source License

@Override
public void navigateTo(String stateWithHistory) {
    historyId = getHistoryId(stateWithHistory);

    LspsUI ui = (LspsUI) UI.getCurrent();
    if (ui.getPage().getBrowserWindowWidth() < 768) {
        ui.addStyleName("l-menu-collapsed");
        ui.getUser().setSetting("collapsedMenu", true);
    }//from ww  w  .  j a v  a 2 s .c  om

    String navigationState;
    AppView view;
    if (historyId == null) {
        historyId = Long.toHexString(System.currentTimeMillis() % ONE_YEAR); //now modulo one year
        navigationState = stateWithHistory;
        view = null;

    } else {
        navigationState = getNavigationState(stateWithHistory);
        view = views.get(historyId);
    }

    if (view != null) {
        int historyIndex = history.indexOf(historyId);
        if (historyIndex >= 0) {
            //move back in history
            List<String> entriesToMove = history.subList(historyIndex + 1, history.size());
            future.addAll(0, entriesToMove); //add to the beginning of the future
            entriesToMove.clear(); //remove from the history
        } else {
            //move forward in history
            int futureIndex = future.indexOf(historyId);
            List<String> entriesToMove = future.subList(0, futureIndex + 1);
            history.addAll(entriesToMove); //add to the beginning of the history
            entriesToMove.clear(); //remove from the future
        }

        //return to an already existing view
        navigateTo(view, navigationState, "");

    } else {
        //create new view and navigate to it
        try {
            super.navigateTo(navigationState);
        } catch (AccessControlException e) {
            Notification.show(e.getMessage(), Type.ERROR_MESSAGE);
        }
    }
}

From source file:com.lst.deploymentautomation.vaadin.core.AppNavigator.java

License:Open Source License

@Override
protected void navigateTo(View view, String viewName, String parameters) {
    AppView currentView = (view instanceof AppView) ? (AppView) view : null;

    boolean screenNotYetInHistory = currentView != null && views.get(historyId) == null;
    if (screenNotYetInHistory) {
        //remember the view for the given historyId
        views.put(historyId, currentView);
        history.add(historyId);/*from   ww  w . j  a  v a2s  .  c o m*/

        //if the history is too long, remove oldest entry
        if (history.size() > MAX_VIEW_COUNT) {
            String oldHistoryId = history.remove(0);
            AppView old = views.remove(oldHistoryId);
            old.cleanup();
        }

        //clear the future and delete all related views
        for (String oldHistoryId : future) {
            AppView old = views.remove(oldHistoryId);
            old.cleanup();
        }
        future.clear();
    }
    try {
        super.navigateTo(view, viewName, parameters);
    } catch (AccessControlException e) {
        Notification.show(e.getMessage(), Type.ERROR_MESSAGE);
    }
}

From source file:com.lst.deploymentautomation.vaadin.core.LspsUI.java

License:Open Source License

/**
 * Shows a warning message to the user.// www  .  ja v a  2  s  . co m
 * @param key
 * @param args
 */
public void showWarningMessage(String key, Object... args) {
    String msg = getMessage(key, args);
    Notification.show(msg, Notification.Type.WARNING_MESSAGE);
}

From source file:com.mcparland.john.vaadin_cookbook.CRUD.java

License:Apache License

/**
 * Create the form for the given item./*from ww w  .  ja v a  2s  .co m*/
 * 
 * @param item
 *            the item.
 * @return a layout for the form.
 */
@SuppressWarnings("serial")
private Layout createForm(Item item) {
    FormLayout layout = new FormLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    final FieldGroup group = new FieldGroup(item);
    for (Object propertyId : group.getUnboundPropertyIds()) {
        layout.addComponent(group.buildAndBind(propertyId));
    }
    Button button = new Button("Commmit");
    button.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            try {
                group.commit();
            } catch (CommitException e) {
                Notification.show(e.getCause().getMessage(), Notification.Type.ERROR_MESSAGE);
            }
        }
    });
    layout.addComponent(button);
    return layout;
}