Example usage for com.vaadin.ui Button.ClickListener Button.ClickListener

List of usage examples for com.vaadin.ui Button.ClickListener Button.ClickListener

Introduction

In this page you can find the example usage for com.vaadin.ui Button.ClickListener Button.ClickListener.

Prototype

Button.ClickListener

Source Link

Usage

From source file:com.esofthead.mycollab.shell.view.components.UpgradeConfirmWindow.java

License:Open Source License

public UpgradeConfirmWindow(final String version, String manualDownloadLink, final String installerFilePath) {
    super("A new update is ready to install");
    this.setModal(true);
    this.setResizable(false);
    this.center();
    this.setWidth("600px");
    this.installerFilePath = installerFilePath;

    currentUI = UI.getCurrent();//from  ww w .ja v  a 2s  . com

    MVerticalLayout content = new MVerticalLayout();
    this.setContent(content);

    String headerTemplate = "MyCollab just got better . For the "
            + "enhancements and security purpose, you should upgrade to the latest version";
    Div titleDiv = new Div().appendText(String.format(headerTemplate, version)).setStyle("font-weight:bold");
    content.with(new Label(titleDiv.write(), ContentMode.HTML));

    Div manualInstallLink = new Div().appendText("    Manual install: ")
            .appendChild(new A(manualDownloadLink, "_blank").appendText("Download link"));
    content.with(new Label(manualInstallLink.write(), ContentMode.HTML));

    Div manualUpgradeHowtoLink = new Div().appendText("    Manual upgrade: ").appendChild(
            new A("https://community.mycollab.com/docs/hosting-mycollab-on-your-own-server/upgrade-mycollab-automatically/",
                    "_blank").appendText("Link"));
    content.with(new Label(manualUpgradeHowtoLink.write(), ContentMode.HTML));

    Div releaseNoteLink = new Div().appendText("    Release Notes: ").appendChild(
            new A("https://community.mycollab.com/docs/hosting-mycollab-on-your-own-server/releases/", "_blank")
                    .appendText("Link"));
    content.with(new Label(releaseNoteLink.write(), ContentMode.HTML));

    MHorizontalLayout buttonControls = new MHorizontalLayout().withMargin(true);
    Button skipBtn = new Button(AppContext.getMessage(GenericI18Enum.ACTION_SKIP), new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            UpgradeConfirmWindow.this.close();
        }
    });
    skipBtn.addStyleName(UIConstants.BUTTON_OPTION);

    Button autoUpgradeBtn = new Button("Auto Upgrade", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            close();
            navigateToWaitingUpgradePage();
        }
    });
    if (installerFilePath == null) {
        autoUpgradeBtn.setEnabled(false);
    }
    autoUpgradeBtn.addStyleName(UIConstants.BUTTON_ACTION);
    buttonControls.with(skipBtn, autoUpgradeBtn);
    content.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT);
}

From source file:com.esofthead.mycollab.shell.view.MainView.java

License:Open Source License

private CustomLayout createTopMenu() {
    final CustomLayout layout = CustomLayoutExt.createLayout("topNavigation");
    layout.setStyleName("topNavigation");
    layout.setHeight("40px");
    layout.setWidth("100%");

    Button accountLogo = AccountLogoFactory
            .createAccountLogoImageComponent(ThemeManager.loadLogoPath(AppContext.getAccountId()), 150);

    accountLogo.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override/*  w  ww .jav  a  2 s .c o  m*/
        public void buttonClick(final ClickEvent event) {
            final UserPreference pref = AppContext.getUserPreference();
            if (pref.getLastmodulevisit() == null
                    || ModuleNameConstants.PRJ.equals(pref.getLastmodulevisit())) {
                EventBusFactory.getInstance().post(new ShellEvent.GotoProjectModule(this, null));
            } else if (ModuleNameConstants.CRM.equals(pref.getLastmodulevisit())) {
                EventBusFactory.getInstance().post(new ShellEvent.GotoCrmModule(this, null));
            } else if (ModuleNameConstants.ACCOUNT.equals(pref.getLastmodulevisit())) {
                EventBusFactory.getInstance().post(new ShellEvent.GotoUserAccountModule(this, null));
            } else if (ModuleNameConstants.FILE.equals(pref.getLastmodulevisit())) {
                EventBusFactory.getInstance().post(new ShellEvent.GotoFileModule(this, null));
            }
        }
    });
    layout.addComponent(accountLogo, "mainLogo");

    serviceMenu = new ServiceMenu();
    serviceMenu.addStyleName("topNavPopup");

    serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_CRM),
            MyCollabResource.newResource(WebResourceIds._16_customer), new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance().post(new ShellEvent.GotoCrmModule(this, null));
                }
            });

    serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_PROJECT),
            MyCollabResource.newResource(WebResourceIds._16_project), new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    if (!event.isCtrlKey() && !event.isMetaKey()) {
                        EventBusFactory.getInstance().post(new ShellEvent.GotoProjectModule(this, null));
                    }
                }
            });

    serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_DOCUMENT),
            MyCollabResource.newResource(WebResourceIds._16_document), new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance().post(new ShellEvent.GotoFileModule(this, null));
                }
            });

    serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_PEOPLE),
            MyCollabResource.newResource(WebResourceIds._16_account), new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance()
                            .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "user", "list" }));
                }
            });

    layout.addComponent(serviceMenu, "serviceMenu");

    final MHorizontalLayout accountLayout = new MHorizontalLayout()
            .withMargin(new MarginInfo(false, true, false, false));
    accountLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    final Label accountNameLabel = new Label(AppContext.getSubDomain());
    accountNameLabel.setStyleName("subdomain");
    accountLayout.addComponent(accountNameLabel);

    // display trial box if user in trial mode
    SimpleBillingAccount billingAccount = AppContext.getBillingAccount();
    if (AccountStatusConstants.TRIAL.equals(billingAccount.getStatus())) {
        Label informLbl = new Label("", ContentMode.HTML);
        informLbl.addStyleName("trialEndingNotification");
        informLbl.setHeight("100%");
        HorizontalLayout informBox = new HorizontalLayout();
        informBox.addStyleName("trialInformBox");
        informBox.setSizeFull();
        informBox.addComponent(informLbl);
        informBox.setMargin(new MarginInfo(false, true, false, false));
        informBox.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void layoutClick(LayoutClickEvent event) {
                EventBusFactory.getInstance()
                        .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" }));
            }
        });
        accountLayout.addComponent(informBox);
        accountLayout.setSpacing(true);
        accountLayout.setComponentAlignment(informBox, Alignment.MIDDLE_LEFT);

        Date createdTime = billingAccount.getCreatedtime();
        long timeDeviation = System.currentTimeMillis() - createdTime.getTime();
        int daysLeft = (int) Math.floor(timeDeviation / (1000 * 60 * 60 * 24));
        if (daysLeft > 30) {
            BillingService billingService = ApplicationContextUtil.getSpringBean(BillingService.class);
            BillingPlan freeBillingPlan = billingService.getFreeBillingPlan();
            billingAccount.setBillingPlan(freeBillingPlan);

            informLbl.setValue("<div class='informBlock'>TRIAL ENDING<br>"
                    + " 0 DAYS LEFT</div><div class='informBlock'>&gt;&gt;</div>");
        } else {
            if (AppContext.isAdmin()) {
                informLbl.setValue("<div class='informBlock'>TRIAL ENDING<br>" + (30 - daysLeft)
                        + " DAYS LEFT</div><div class='informBlock'>&gt;&gt;</div>");
            } else {
                informLbl.setValue("<div class='informBlock'>TRIAL ENDING<br>" + (30 - daysLeft)
                        + " DAYS LEFT</div><div class='informBlock'>&gt;&gt;</div>");
            }
        }
    }

    NotificationButton notificationButton = new NotificationButton();
    accountLayout.addComponent(notificationButton);
    if (AppContext.getSession().getTimezone() == null) {
        EventBusFactory.getInstance().post(new ShellEvent.NewNotification(this, new TimezoneNotification()));
    }

    if (StringUtils.isBlank(AppContext.getSession().getAvatarid())) {
        EventBusFactory.getInstance()
                .post(new ShellEvent.NewNotification(this, new RequestUploadAvatarNotification()));
    }

    if (SiteConfiguration.getDeploymentMode() != DeploymentMode.site && AppContext.isAdmin()) {
        try {
            Client client = ClientBuilder.newBuilder().build();
            WebTarget target = client.target("https://api.mycollab.com/api/checkupdate");
            Response response = target.request().get();
            String values = response.readEntity(String.class);
            Gson gson = new Gson();
            Properties props = gson.fromJson(values, Properties.class);
            String version = props.getProperty("version");
            if (!MyCollabVersion.getVersion().equals(version)) {
                EventBusFactory.getInstance()
                        .post(new ShellEvent.NewNotification(this, new NewUpdateNotification(props)));
            }
        } catch (Exception e) {
            LOG.error("Error when call remote api", e);
        }
    }

    UserAvatarComp userAvatar = new UserAvatarComp();
    accountLayout.addComponent(userAvatar);
    accountLayout.setComponentAlignment(userAvatar, Alignment.MIDDLE_LEFT);

    final PopupButton accountMenu = new PopupButton(AppContext.getSession().getDisplayName());
    final VerticalLayout accLayout = new VerticalLayout();
    accLayout.setWidth("140px");

    final Button myProfileBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_PROFILE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    accountMenu.setPopupVisible(false);
                    EventBusFactory.getInstance()
                            .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "preview" }));
                }
            });
    myProfileBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.PROFILE));
    myProfileBtn.setStyleName("link");
    accLayout.addComponent(myProfileBtn);

    final Button myAccountBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_BILLING),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    accountMenu.setPopupVisible(false);
                    EventBusFactory.getInstance()
                            .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" }));
                }
            });
    myAccountBtn.setStyleName("link");
    myAccountBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.BILLING));
    accLayout.addComponent(myAccountBtn);

    final Button userMgtBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_USERS_AND_ROLES),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    accountMenu.setPopupVisible(false);
                    EventBusFactory.getInstance()
                            .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "user", "list" }));
                }
            });
    userMgtBtn.setStyleName("link");
    userMgtBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.USERS));
    accLayout.addComponent(userMgtBtn);

    final Button signoutBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SIGNOUT),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    AppContext.getInstance().clearSession();
                    EventBusFactory.getInstance().post(new ShellEvent.LogOut(this, null));
                }
            });
    signoutBtn.setStyleName("link");
    signoutBtn.setIcon(FontAwesome.SIGN_OUT);
    accLayout.addComponent(signoutBtn);

    accountMenu.setContent(accLayout);
    accountMenu.setStyleName("accountMenu");
    accountMenu.addStyleName("topNavPopup");
    accountLayout.addComponent(accountMenu);

    layout.addComponent(accountLayout, "accountMenu");

    return layout;
}

From source file:com.esofthead.mycollab.shell.view.MainViewImpl.java

License:Open Source License

private MHorizontalLayout buildAccountMenuLayout() {
    accountLayout.removeAllComponents();

    if (SiteConfiguration.isDemandEdition()) {
        // display trial box if user in trial mode
        SimpleBillingAccount billingAccount = AppContext.getBillingAccount();
        if (AccountStatusConstants.TRIAL.equals(billingAccount.getStatus())) {
            if ("Free".equals(billingAccount.getBillingPlan().getBillingtype())) {
                Label informLbl = new Label(
                        "<div class='informBlock'>FREE CHARGE<br>UPGRADE</div><div class='informBlock'>&gt;&gt;</div>",
                        ContentMode.HTML);
                informLbl.addStyleName("trialEndingNotification");
                informLbl.setHeight("100%");
                HorizontalLayout informBox = new HorizontalLayout();
                informBox.addStyleName("trialInformBox");
                informBox.setSizeFull();
                informBox.addComponent(informLbl);
                informBox.setMargin(new MarginInfo(false, true, false, false));
                informBox.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override/*  w w w . jav  a2 s.c om*/
                    public void layoutClick(LayoutClickEvent event) {
                        EventBusFactory.getInstance()
                                .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" }));
                    }
                });
                accountLayout.with(informBox).withAlign(informBox, Alignment.MIDDLE_LEFT);
            } else {
                Label informLbl = new Label("", ContentMode.HTML);
                informLbl.addStyleName("trialEndingNotification");
                informLbl.setHeight("100%");
                HorizontalLayout informBox = new HorizontalLayout();
                informBox.addStyleName("trialInformBox");
                informBox.setSizeFull();
                informBox.setMargin(new MarginInfo(false, true, false, false));
                informBox.addComponent(informLbl);
                informBox.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void layoutClick(LayoutClickEvent event) {
                        EventBusFactory.getInstance()
                                .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" }));
                    }
                });
                accountLayout.with(informBox).withAlign(informBox, Alignment.MIDDLE_LEFT);

                Duration dur = new Duration(new DateTime(billingAccount.getCreatedtime()), new DateTime());
                int daysLeft = dur.toStandardDays().getDays();
                if (daysLeft > 30) {
                    informLbl.setValue(
                            "<div class='informBlock'>Trial<br></div><div class='informBlock'>&gt;&gt;</div>");
                    //                        AppContext.getInstance().setIsValidAccount(false);
                } else {
                    informLbl.setValue(String.format("<div class='informBlock'>Trial ending<br>%d days "
                            + "left</div><div class='informBlock'>&gt;&gt;</div>", 30 - daysLeft));
                }
            }
        }
    }

    Label accountNameLabel = new Label(AppContext.getSubDomain());
    accountNameLabel.addStyleName("subdomain");
    accountLayout.addComponent(accountNameLabel);

    if (SiteConfiguration.isCommunityEdition()) {
        Button buyPremiumBtn = new Button("Upgrade to Pro edition", new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                UI.getCurrent().addWindow(new AdWindow());
            }
        });
        buyPremiumBtn.setIcon(FontAwesome.SHOPPING_CART);
        buyPremiumBtn.addStyleName("ad");
        accountLayout.addComponent(buyPremiumBtn);
    }

    LicenseResolver licenseResolver = AppContextUtil.getSpringBean(LicenseResolver.class);
    if (licenseResolver != null) {
        LicenseInfo licenseInfo = licenseResolver.getLicenseInfo();
        if (licenseInfo != null) {
            if (licenseInfo.isExpired()) {
                Button buyPremiumBtn = new Button(AppContext.getMessage(LicenseI18nEnum.EXPIRE_NOTIFICATION),
                        new ClickListener() {
                            @Override
                            public void buttonClick(ClickEvent event) {
                                UI.getCurrent().addWindow(new BuyPremiumSoftwareWindow());
                            }
                        });
                buyPremiumBtn.setIcon(FontAwesome.SHOPPING_CART);
                buyPremiumBtn.addStyleName("ad");
                accountLayout.addComponent(buyPremiumBtn);
            } else if (licenseInfo.isTrial()) {
                Duration dur = new Duration(new DateTime(), new DateTime(licenseInfo.getExpireDate()));
                int days = dur.toStandardDays().getDays();
                Button buyPremiumBtn = new Button(
                        AppContext.getMessage(LicenseI18nEnum.TRIAL_NOTIFICATION, days), new ClickListener() {
                            @Override
                            public void buttonClick(ClickEvent event) {
                                UI.getCurrent().addWindow(new BuyPremiumSoftwareWindow());
                            }
                        });
                buyPremiumBtn.setIcon(FontAwesome.SHOPPING_CART);
                buyPremiumBtn.addStyleName("ad");
                accountLayout.addComponent(buyPremiumBtn);
            }
        }
    }

    NotificationComponent notificationComponent = new NotificationComponent();
    accountLayout.addComponent(notificationComponent);

    if (StringUtils.isBlank(AppContext.getUser().getAvatarid())) {
        EventBusFactory.getInstance()
                .post(new ShellEvent.NewNotification(this, new RequestUploadAvatarNotification()));
    }

    if (!SiteConfiguration.isDemandEdition()) {
        ExtMailService mailService = AppContextUtil.getSpringBean(ExtMailService.class);
        if (!mailService.isMailSetupValid()) {
            EventBusFactory.getInstance()
                    .post(new ShellEvent.NewNotification(this, new SmtpSetupNotification()));
        }

        SimpleUser user = AppContext.getUser();
        GregorianCalendar tenDaysAgo = new GregorianCalendar();
        tenDaysAgo.add(Calendar.DATE, -10);

        if (Boolean.TRUE.equals(user.getRequestad()) && user.getRegisteredtime().before(tenDaysAgo.getTime())) {
            UI.getCurrent().addWindow(new AdRequestWindow(user));
        }
    }

    Resource userAvatarRes = UserAvatarControlFactory.createAvatarResource(AppContext.getUserAvatarId(), 24);
    final PopupButton accountMenu = new PopupButton("");
    accountMenu.setIcon(userAvatarRes);
    accountMenu.setDescription(AppContext.getUserDisplayName());

    OptionPopupContent accountPopupContent = new OptionPopupContent();

    Button myProfileBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_PROFILE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    accountMenu.setPopupVisible(false);
                    EventBusFactory.getInstance()
                            .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "preview" }));
                }
            });
    myProfileBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.PROFILE));
    accountPopupContent.addOption(myProfileBtn);

    Button userMgtBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_USERS_AND_ROLES),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    accountMenu.setPopupVisible(false);
                    EventBusFactory.getInstance()
                            .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "user", "list" }));
                }
            });
    userMgtBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.USERS));
    accountPopupContent.addOption(userMgtBtn);

    Button generalSettingBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_SETTING),
            new ClickListener() {
                @Override
                public void buttonClick(ClickEvent clickEvent) {
                    accountMenu.setPopupVisible(false);
                    EventBusFactory.getInstance().post(
                            new ShellEvent.GotoUserAccountModule(this, new String[] { "setting", "general" }));
                }
            });
    generalSettingBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.GENERAL_SETTING));
    accountPopupContent.addOption(generalSettingBtn);

    Button themeCustomizeBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_THEME), new ClickListener() {
        @Override
        public void buttonClick(ClickEvent clickEvent) {
            accountMenu.setPopupVisible(false);
            EventBusFactory.getInstance()
                    .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "setting", "theme" }));
        }
    });
    themeCustomizeBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.THEME_CUSTOMIZE));
    accountPopupContent.addOption(themeCustomizeBtn);

    if (!SiteConfiguration.isDemandEdition()) {
        Button setupBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_SETUP), new ClickListener() {
            @Override
            public void buttonClick(ClickEvent clickEvent) {
                accountMenu.setPopupVisible(false);
                EventBusFactory.getInstance()
                        .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "setup" }));
            }
        });
        setupBtn.setIcon(FontAwesome.WRENCH);
        accountPopupContent.addOption(setupBtn);
    }

    accountPopupContent.addSeparator();

    Button helpBtn = new Button(AppContext.getMessage(GenericI18Enum.ACTION_HELP));
    helpBtn.setIcon(FontAwesome.MORTAR_BOARD);
    ExternalResource helpRes = new ExternalResource("https://community.mycollab.com/meet-mycollab/");
    BrowserWindowOpener helpOpener = new BrowserWindowOpener(helpRes);
    helpOpener.extend(helpBtn);
    accountPopupContent.addOption(helpBtn);

    Button supportBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SUPPORT));
    supportBtn.setIcon(FontAwesome.LIFE_SAVER);
    ExternalResource supportRes = new ExternalResource("http://support.mycollab.com/");
    BrowserWindowOpener supportOpener = new BrowserWindowOpener(supportRes);
    supportOpener.extend(supportBtn);
    accountPopupContent.addOption(supportBtn);

    Button translateBtn = new Button(AppContext.getMessage(GenericI18Enum.ACTION_TRANSLATE));
    translateBtn.setIcon(FontAwesome.PENCIL);
    ExternalResource translateRes = new ExternalResource(
            "https://community.mycollab.com/docs/developing-mycollab/translating/");
    BrowserWindowOpener translateOpener = new BrowserWindowOpener(translateRes);
    translateOpener.extend(translateBtn);
    accountPopupContent.addOption(translateBtn);

    if (!SiteConfiguration.isCommunityEdition()) {
        Button myAccountBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_BILLING),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        accountMenu.setPopupVisible(false);
                        EventBusFactory.getInstance()
                                .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" }));
                    }
                });
        myAccountBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.BILLING));
        accountPopupContent.addOption(myAccountBtn);
    }

    accountPopupContent.addSeparator();
    Button aboutBtn = new Button("About MyCollab", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent clickEvent) {
            accountMenu.setPopupVisible(false);
            Window aboutWindow = ViewManager.getCacheComponent(AbstractAboutWindow.class);
            UI.getCurrent().addWindow(aboutWindow);
        }
    });
    aboutBtn.setIcon(FontAwesome.INFO_CIRCLE);
    accountPopupContent.addOption(aboutBtn);

    Button releaseNotesBtn = new Button("Release Notes");
    ExternalResource releaseNotesRes = new ExternalResource(
            "https://community.mycollab.com/docs/hosting-mycollab-on-your-own-server/releases/");
    BrowserWindowOpener releaseNotesOpener = new BrowserWindowOpener(releaseNotesRes);
    releaseNotesOpener.extend(releaseNotesBtn);

    releaseNotesBtn.setIcon(FontAwesome.BULLHORN);
    accountPopupContent.addOption(releaseNotesBtn);

    Button signoutBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SIGNOUT),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    accountMenu.setPopupVisible(false);
                    EventBusFactory.getInstance().post(new ShellEvent.LogOut(this, null));
                }
            });
    signoutBtn.setIcon(FontAwesome.SIGN_OUT);
    accountPopupContent.addSeparator();
    accountPopupContent.addOption(signoutBtn);

    accountMenu.setContent(accountPopupContent);
    accountLayout.addComponent(accountMenu);
    return accountLayout;
}

From source file:com.esofthead.mycollab.shell.view.SetupNewInstanceView.java

License:Open Source License

public SetupNewInstanceView() {
    this.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    MVerticalLayout content = new MVerticalLayout().withWidth("600px");
    this.with(content);
    content.with(ELabel.h2("Last step, you are almost there!").withWidthUndefined());
    content.with(ELabel.h3("All fields are required *").withStyleName("overdue").withWidthUndefined());
    content.with(// w  w w.j a v  a  2  s  . c  o m
            new ELabel(AppContext.getMessage(ShellI18nEnum.OPT_SUPPORTED_LANGUAGES_INTRO), ContentMode.HTML)
                    .withStyleName(UIConstants.META_COLOR));
    GridFormLayoutHelper formLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(2, 8, "200px");
    formLayoutHelper.getLayout().setWidth("600px");
    final TextField adminField = formLayoutHelper.addComponent(new TextField(), "Admin email", 0, 0);
    final PasswordField passwordField = formLayoutHelper.addComponent(new PasswordField(), "Admin password", 0,
            1);
    final PasswordField retypePasswordField = formLayoutHelper.addComponent(new PasswordField(),
            "Retype Admin password", 0, 2);
    final DateFormatField dateFormatField = formLayoutHelper.addComponent(
            new DateFormatField(SimpleBillingAccount.DEFAULT_DATE_FORMAT),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_YYMMDD_FORMAT),
            AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 3);

    final DateFormatField shortDateFormatField = formLayoutHelper.addComponent(
            new DateFormatField(SimpleBillingAccount.DEFAULT_SHORT_DATE_FORMAT),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_MMDD_FORMAT),
            AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 4);

    final DateFormatField longDateFormatField = formLayoutHelper.addComponent(
            new DateFormatField(SimpleBillingAccount.DEFAULT_LONG_DATE_FORMAT),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_HUMAN_DATE_FORMAT),
            AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 5);

    final TimeZoneSelectionField timeZoneSelectionField = formLayoutHelper.addComponent(
            new TimeZoneSelectionField(false), AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_TIMEZONE), 0,
            6);
    timeZoneSelectionField.setValue(TimeZone.getDefault().getID());
    final LanguageSelectionField languageBox = formLayoutHelper.addComponent(new LanguageSelectionField(),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_LANGUAGE), 0, 7);
    languageBox.setValue(Locale.US.toLanguageTag());
    content.with(formLayoutHelper.getLayout());

    Button installBtn = new Button("Setup", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            String adminName = adminField.getValue();
            String password = passwordField.getValue();
            String retypePassword = retypePasswordField.getValue();
            if (!StringUtils.isValidEmail(adminName)) {
                NotificationUtil.showErrorNotification("Invalid email value");
                return;
            }

            if (!password.equals(retypePassword)) {
                NotificationUtil.showErrorNotification("Password is not match");
                return;
            }

            String dateFormat = dateFormatField.getValue();
            String shortDateFormat = shortDateFormatField.getValue();
            String longDateFormat = longDateFormatField.getValue();
            if (!isValidDayPattern(dateFormat) || !isValidDayPattern(shortDateFormat)
                    || !isValidDayPattern(longDateFormat)) {
                NotificationUtil.showErrorNotification("Invalid date format");
                return;
            }
            String language = languageBox.getValue();
            String timezoneDbId = timeZoneSelectionField.getValue();
            BillingAccountMapper billingAccountMapper = AppContextUtil
                    .getSpringBean(BillingAccountMapper.class);
            BillingAccountExample ex = new BillingAccountExample();
            ex.createCriteria().andIdEqualTo(AppContext.getAccountId());
            List<BillingAccount> billingAccounts = billingAccountMapper.selectByExample(ex);
            BillingAccount billingAccount = billingAccounts.get(0);
            billingAccount.setDefaultlanguagetag(language);
            billingAccount.setDefaultyymmddformat(dateFormat);
            billingAccount.setDefaultmmddformat(shortDateFormat);
            billingAccount.setDefaulthumandateformat(longDateFormat);
            billingAccount.setDefaulttimezone(timezoneDbId);
            billingAccountMapper.updateByPrimaryKey(billingAccount);

            BillingAccountService billingAccountService = AppContextUtil
                    .getSpringBean(BillingAccountService.class);

            billingAccountService.createDefaultAccountData(adminName, password, timezoneDbId, language, true,
                    true, AppContext.getAccountId());
            ((DesktopApplication) UI.getCurrent()).doLogin(adminName, password, false);

        }
    });
    installBtn.addStyleName(UIConstants.BUTTON_ACTION);
    content.with(installBtn).withAlign(installBtn, Alignment.TOP_RIGHT);
}

From source file:com.esofthead.mycollab.shell.view.UpgradeConfirmWindow.java

License:Open Source License

public UpgradeConfirmWindow(Properties props) {
    super("There is the new MyCollab update");
    this.props = props;
    this.setModal(true);
    this.setResizable(false);
    this.center();
    this.setWidth("600px");

    MVerticalLayout content = new MVerticalLayout();
    this.setContent(content);

    Div titleDiv = new Div().appendText(String.format(headerTemplate, props.getProperty("version")))
            .setStyle("font-weight:bold");
    content.with(new Label(titleDiv.write(), ContentMode.HTML));

    Div manualInstallLink = new Div().appendText("&nbsp;&nbsp;&nbsp;&nbsp;Manual install: ")
            .appendChild(new A(props.getProperty("downloadLink"), "_blank").appendText("Download link"));
    content.with(new Label(manualInstallLink.write(), ContentMode.HTML));

    Div releaseNoteLink = new Div().appendText("&nbsp;&nbsp;&nbsp;&nbsp;Release Notes: ")
            .appendChild(new A(props.getProperty("releaseNotes"), "_blank").appendText("Link"));
    content.with(new Label(releaseNoteLink.write(), ContentMode.HTML));

    MHorizontalLayout buttonControls = new MHorizontalLayout().withMargin(true);
    Button skipBtn = new Button("Skip", new Button.ClickListener() {
        @Override// ww w.  jav  a 2 s. c o m
        public void buttonClick(Button.ClickEvent clickEvent) {
            UpgradeConfirmWindow.this.close();
        }
    });
    skipBtn.addStyleName(UIConstants.THEME_GRAY_LINK);

    Button autoUpgradeBtn = new Button("Auto Upgrade", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            UI.getCurrent().setPollInterval(1000);
            new Thread(new AutoUpgradeProcess()).start();
            UpgradeConfirmWindow.this.close();
        }
    });
    autoUpgradeBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    buttonControls.with(skipBtn, autoUpgradeBtn);
    content.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT);
}

From source file:com.esofthead.mycollab.ui.chart.PieChartWrapper.java

License:Open Source License

@Override
protected final ComponentContainer createLegendBox() {
    final CssLayout mainLayout = new CssLayout();
    mainLayout.addStyleName("legendBoxContent");
    mainLayout.setSizeUndefined();/*from ww w  . j  av  a2  s.  c o m*/
    final List keys = pieDataSet.getKeys();

    for (int i = 0; i < keys.size(); i++) {
        MHorizontalLayout layout = new MHorizontalLayout()
                .withMargin(new MarginInfo(false, false, false, true));
        layout.addStyleName("inline-block");
        layout.setSizeUndefined();
        layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

        final Comparable key = (Comparable) keys.get(i);
        int colorIndex = i % CHART_COLOR_STR.size();
        final String color = "<div style = \" width:13px;height:13px;background: #"
                + CHART_COLOR_STR.get(colorIndex) + "\" />";
        final Label lblCircle = new Label(color);
        lblCircle.setContentMode(ContentMode.HTML);

        String btnCaption;
        if (enumKeyCls == null) {
            if (key instanceof Key) {
                btnCaption = String.format("%s (%d)", StringUtils.trim(((Key) key).getDisplayName(), 20, true),
                        pieDataSet.getValue(key).intValue());
            } else {
                btnCaption = String.format("%s (%d)", key, pieDataSet.getValue(key).intValue());
            }
        } else {
            btnCaption = String.format("%s(%d)", AppContext.getMessage(enumKeyCls, key.toString()),
                    pieDataSet.getValue(key).intValue());
        }
        final Button btnLink = new Button(StringUtils.trim(btnCaption, 25, true), new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                if (key instanceof Key) {
                    clickLegendItem(((Key) key).getKey());
                } else {
                    clickLegendItem(key.toString());
                }
            }
        });
        btnLink.setDescription(btnCaption);
        btnLink.addStyleName(UIConstants.BUTTON_LINK);
        layout.with(lblCircle, btnLink);
        mainLayout.addComponent(layout);
    }
    mainLayout.setWidth("100%");
    return mainLayout;
}

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

License:Open Source License

protected ComponentContainer buildButtonControls() {
    MHorizontalLayout controlsLayout = new MHorizontalLayout().withMargin(true).withStyleName("addNewControl")
            .withWidth("100%");

    updateBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_UPDATE_LABEL),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override//ww  w. j a  v  a 2 s .com
                public void buttonClick(ClickEvent event) {
                    updateForm.commit();
                    massUpdateCommand.massUpdate(beanItem);
                    MassUpdateWindow.this.close();
                }
            });
    updateBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    updateBtn.setIcon(FontAwesome.SAVE);

    closeBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLOSE), new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            MassUpdateWindow.this.close();
        }
    });
    closeBtn.setStyleName(UIConstants.THEME_GRAY_LINK);

    Label spacing = new Label();
    controlsLayout.with(spacing, updateBtn, closeBtn).alignAll(Alignment.MIDDLE_RIGHT).expand(spacing);
    return controlsLayout;
}

From source file:com.esofthead.mycollab.vaadin.ui.table.CustomizedTableWindow.java

License:Open Source License

public CustomizedTableWindow(final String viewId, final AbstractPagedBeanTable<?, ?> table) {
    super("Customize View");
    this.viewId = viewId;
    this.addStyleName("customize-table-window");
    this.setWidth("400px");
    this.setResizable(false);
    this.setModal(true);
    this.center();

    this.tableItem = table;
    customViewStoreService = ApplicationContextUtil.getSpringBean(CustomViewStoreService.class);

    final VerticalLayout contentLayout = new VerticalLayout();
    contentLayout.setSpacing(true);/*from w w  w .j  ava2 s.c o m*/
    contentLayout.setMargin(true);
    this.setContent(contentLayout);

    this.listBuilder = new ListBuilder();
    this.listBuilder.setImmediate(true);
    this.listBuilder.setColumns(0);
    this.listBuilder.setLeftColumnCaption("Available Columns");
    this.listBuilder.setRightColumnCaption("View Columns");
    this.listBuilder.setWidth(100, Sizeable.Unit.PERCENTAGE);

    this.listBuilder.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
    final BeanItemContainer<TableViewField> container = new BeanItemContainer<>(TableViewField.class,
            this.getAvailableColumns());
    this.listBuilder.setContainerDataSource(container);
    Iterator<TableViewField> iterator = getAvailableColumns().iterator();
    while (iterator.hasNext()) {
        TableViewField field = iterator.next();
        this.listBuilder.setItemCaption(field, AppContext.getMessage(field.getDescKey()));
    }
    this.setSelectedViewColumns();
    contentLayout.addComponent(this.listBuilder);
    contentLayout.setComponentAlignment(listBuilder, Alignment.MIDDLE_CENTER);

    Button restoreLink = new Button("Restore to default", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @SuppressWarnings("unchecked")
        @Override
        public void buttonClick(ClickEvent event) {
            List<TableViewField> defaultSelectedColumns = tableItem.getDefaultSelectedColumns();
            if (defaultSelectedColumns != null) {
                final List<TableViewField> selectedColumns = new ArrayList<>();
                final BeanItemContainer<TableViewField> container = (BeanItemContainer<TableViewField>) CustomizedTableWindow.this.listBuilder
                        .getContainerDataSource();
                final Collection<TableViewField> itemIds = container.getItemIds();

                for (TableViewField column : defaultSelectedColumns) {
                    for (final TableViewField viewField : itemIds) {
                        if (column.getField().equals(viewField.getField())) {
                            selectedColumns.add(viewField);
                        }
                    }
                }

                CustomizedTableWindow.this.listBuilder.setValue(selectedColumns);
            }

        }
    });
    restoreLink.setStyleName("link");
    contentLayout.addComponent(restoreLink);
    contentLayout.setComponentAlignment(restoreLink, Alignment.MIDDLE_RIGHT);

    final HorizontalLayout buttonControls = new HorizontalLayout();
    buttonControls.setSpacing(true);
    final Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @SuppressWarnings("unchecked")
                @Override
                public void buttonClick(final ClickEvent event) {
                    final List<TableViewField> selectedColumns = (List<TableViewField>) CustomizedTableWindow.this.listBuilder
                            .getValue();
                    table.setDisplayColumns(selectedColumns);
                    CustomizedTableWindow.this.close();

                    // Save custom table view def
                    CustomViewStore viewDef = new CustomViewStore();
                    viewDef.setSaccountid(AppContext.getAccountId());
                    viewDef.setCreateduser(AppContext.getUsername());
                    viewDef.setViewid(viewId);
                    viewDef.setViewinfo(XStreamJsonDeSerializer.toJson(new ArrayList<>(selectedColumns)));
                    customViewStoreService.saveOrUpdateViewLayoutDef(viewDef);
                }
            });
    saveBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    saveBtn.setIcon(FontAwesome.SAVE);
    buttonControls.addComponent(saveBtn);

    final Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    CustomizedTableWindow.this.close();
                }
            });
    cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK);
    buttonControls.addComponent(cancelBtn);

    contentLayout.addComponent(buttonControls);
    contentLayout.setComponentAlignment(buttonControls, Alignment.MIDDLE_CENTER);
}

From source file:com.esofthead.mycollab.vaadin.web.ui.AbstractBeanBlockList.java

License:Open Source License

protected CssLayout createPageControls() {
    this.controlBarWrapper = new CssLayout();
    this.controlBarWrapper.setWidth("100%");

    final HorizontalLayout controlBar = new HorizontalLayout();
    controlBar.setWidth("100%");
    this.controlBarWrapper.addComponent(controlBar);

    pageManagement = new MHorizontalLayout();

    // defined layout here ---------------------------

    if (currentPage > 1) {
        final Button firstLink = new Button("1", new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override/*from w  w w.j  ava2  s  .  c o m*/
            public void buttonClick(final ClickEvent event) {
                AbstractBeanBlockList.this.pageChange(1);
            }
        });
        firstLink.addStyleName("buttonPaging");
        pageManagement.addComponent(firstLink);
    }
    if (currentPage >= 5) {
        final Label ss1 = new Label("...");
        ss1.addStyleName("buttonPaging");
        pageManagement.addComponent(ss1);
    }
    if (currentPage > 3) {
        final Button previous2 = new Button("" + (currentPage - 2), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                pageChange(currentPage - 2);
            }
        });
        previous2.addStyleName("buttonPaging");
        pageManagement.addComponent(previous2);
    }
    if (currentPage > 2) {
        final Button previous1 = new Button("" + (currentPage - 1), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                AbstractBeanBlockList.this.pageChange(currentPage - 1);
            }
        });
        previous1.addStyleName("buttonPaging");
        pageManagement.addComponent(previous1);
    }
    // Here add current ButtonLinkLegacy
    final Button current = new Button("" + currentPage, new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            AbstractBeanBlockList.this.pageChange(currentPage);
        }
    });
    current.addStyleName("buttonPaging");
    current.addStyleName("current");

    pageManagement.addComponent(current);
    final int range = totalPage - currentPage;
    if (range >= 1) {
        final Button next1 = new Button("" + (currentPage + 1), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                AbstractBeanBlockList.this.pageChange(currentPage + 1);
            }
        });
        next1.addStyleName("buttonPaging");
        pageManagement.addComponent(next1);
    }
    if (range >= 2) {
        final Button next2 = new Button("" + (currentPage + 2), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                AbstractBeanBlockList.this.pageChange(currentPage + 2);
            }
        });
        next2.addStyleName("buttonPaging");
        pageManagement.addComponent(next2);
    }
    if (range >= 4) {
        final Label ss2 = new Label("...");
        ss2.addStyleName("buttonPaging");
        pageManagement.addComponent(ss2);
    }
    if (range >= 3) {
        final Button last = new Button("" + totalPage, new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                pageChange(totalPage);
            }
        });
        last.addStyleName("buttonPaging");
        pageManagement.addComponent(last);
    }

    pageManagement.setWidth(null);
    controlBar.addComponent(pageManagement);
    controlBar.setComponentAlignment(pageManagement, Alignment.MIDDLE_RIGHT);

    return this.controlBarWrapper;
}

From source file:com.esofthead.mycollab.vaadin.web.ui.AbstractBeanPagedList.java

License:Open Source License

protected MHorizontalLayout createPageControls() {
    controlBarWrapper = new MHorizontalLayout().withFullWidth()
            .withMargin(new MarginInfo(false, true, false, true)).withStyleName(listControlStyle);

    pageManagement = new MHorizontalLayout().withWidth(null);

    // defined layout here ---------------------------

    if (currentPage > 1) {
        Button firstLink = new Button("1", new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override//from   w  w  w.  ja  va2 s  .c  o  m
            public void buttonClick(final ClickEvent event) {
                pageChange(1);
            }
        });
        firstLink.addStyleName("buttonPaging");
        pageManagement.addComponent(firstLink);
    }
    if (currentPage >= 5) {
        final Label ss1 = new Label("...");
        ss1.addStyleName("buttonPaging");
        pageManagement.addComponent(ss1);
    }
    if (currentPage > 3) {
        Button previous2 = new Button("" + (currentPage - 2), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                pageChange(currentPage - 2);
            }
        });
        previous2.addStyleName("buttonPaging");
        pageManagement.addComponent(previous2);
    }
    if (currentPage > 2) {
        final Button previous1 = new Button("" + (currentPage - 1), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                pageChange(currentPage - 1);
            }
        });
        previous1.addStyleName("buttonPaging");
        pageManagement.addComponent(previous1);
    }
    // Here add current ButtonLinkLegacy
    final Button current = new Button("" + currentPage, new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            pageChange(currentPage);
        }
    });
    current.addStyleName("buttonPaging");
    current.addStyleName("current");

    pageManagement.addComponent(current);
    final int range = this.totalPage - currentPage;
    if (range >= 1) {
        final Button next1 = new Button("" + (currentPage + 1), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                pageChange(currentPage + 1);
            }
        });
        next1.addStyleName("buttonPaging");
        pageManagement.addComponent(next1);
    }
    if (range >= 2) {
        Button next2 = new Button("" + (currentPage + 2), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                pageChange(currentPage + 2);
            }
        });
        next2.addStyleName("buttonPaging");
        pageManagement.addComponent(next2);
    }
    if (range >= 4) {
        Label ss2 = new Label("...");
        ss2.addStyleName("buttonPaging");
        pageManagement.addComponent(ss2);
    }
    if (range >= 3) {
        Button last = new Button("" + this.totalPage, new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                pageChange(totalPage);
            }
        });
        last.addStyleName("buttonPaging");
        pageManagement.addComponent(last);
    }

    controlBarWrapper.with(pageManagement).withAlign(pageManagement, Alignment.MIDDLE_RIGHT);
    return controlBarWrapper;
}