List of usage examples for com.vaadin.server Page getCurrent
public static Page getCurrent()
From source file:com.esofthead.mycollab.module.user.accountsettings.profile.view.ProfilePhotoUploadViewImpl.java
License:Open Source License
@SuppressWarnings("serial") @Override/*from w w w. j av a 2 s . co m*/ public void editPhoto(final byte[] imageData) { this.removeAllComponents(); LOG.debug("Receive avatar upload with size: " + imageData.length); try { originalImage = ImageIO.read(new ByteArrayInputStream(imageData)); } catch (IOException e) { throw new UserInvalidInputException("Invalid image type"); } originalImage = ImageUtil.scaleImage(originalImage, 650, 650); MHorizontalLayout previewBox = new MHorizontalLayout().withSpacing(true) .withMargin(new MarginInfo(false, true, true, false)).withWidth("100%"); Resource defaultPhoto = UserAvatarControlFactory.createAvatarResource(AppContext.getUserAvatarId(), 100); previewImage = new Embedded(null, defaultPhoto); previewImage.setWidth("100px"); previewBox.addComponent(previewImage); previewBox.setComponentAlignment(previewImage, Alignment.TOP_LEFT); VerticalLayout previewBoxRight = new VerticalLayout(); previewBoxRight.setMargin(new MarginInfo(false, true, false, true)); Label lbPreview = new Label( "<p style='margin: 0px;'><strong>To the left is what your profile photo will look like.</strong></p><p style='margin-top: 0px;'>To make adjustment, you can drag around and resize the selection square below. When you are happy with your photo, click the “Accept“ button.</p>", ContentMode.HTML); previewBoxRight.addComponent(lbPreview); MHorizontalLayout controlBtns = new MHorizontalLayout(); controlBtns.setSizeUndefined(); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { EventBusFactory.getInstance() .post(new ProfileEvent.GotoProfileView(ProfilePhotoUploadViewImpl.this, null)); } }); cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK); Button acceptBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ACCEPT), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { if (scaleImageData != null && scaleImageData.length > 0) { try { BufferedImage image = ImageIO.read(new ByteArrayInputStream(scaleImageData)); UserAvatarService userAvatarService = ApplicationContextUtil .getSpringBean(UserAvatarService.class); userAvatarService.uploadAvatar(image, AppContext.getUsername(), AppContext.getUserAvatarId()); Page.getCurrent().getJavaScript().execute("window.location.reload();"); } catch (IOException e) { throw new MyCollabException("Error when saving user avatar", e); } } } }); acceptBtn.setStyleName(UIConstants.THEME_GREEN_LINK); acceptBtn.setIcon(FontAwesome.CHECK); controlBtns.with(acceptBtn, cancelBtn).alignAll(Alignment.MIDDLE_LEFT); previewBoxRight.addComponent(controlBtns); previewBoxRight.setComponentAlignment(controlBtns, Alignment.TOP_LEFT); previewBox.addComponent(previewBoxRight); previewBox.setExpandRatio(previewBoxRight, 1.0f); this.addComponent(previewBox); CssLayout cropBox = new CssLayout(); cropBox.addStyleName(UIConstants.PHOTO_CROPBOX); cropBox.setWidth("100%"); VerticalLayout currentPhotoBox = new VerticalLayout(); Resource resource = new ByteArrayImageResource(ImageUtil.convertImageToByteArray(originalImage), "image/png"); CropField cropField = new CropField(resource); cropField.setImmediate(true); cropField.setSelectionAspectRatio(1.0f); cropField.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { VCropSelection newSelection = (VCropSelection) event.getProperty().getValue(); int x1 = newSelection.getXTopLeft(); int y1 = newSelection.getYTopLeft(); int x2 = newSelection.getXBottomRight(); int y2 = newSelection.getYBottomRight(); if (x2 > x1 && y2 > y1) { BufferedImage subImage = originalImage.getSubimage(x1, y1, (x2 - x1), (y2 - y1)); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); try { ImageIO.write(subImage, "png", outStream); scaleImageData = outStream.toByteArray(); displayPreviewImage(); } catch (IOException e) { LOG.error("Error while scale image: ", e); } } } }); currentPhotoBox.setWidth("650px"); currentPhotoBox.setHeight("650px"); currentPhotoBox.addComponent(cropField); cropBox.addComponent(currentPhotoBox); this.addComponent(previewBox); this.addComponent(cropBox); this.setExpandRatio(cropBox, 1.0f); }
From source file:com.esofthead.mycollab.vaadin.AppContext.java
License:Open Source License
/** * /*from ww w .jav a 2 s . c o m*/ * @param fragement * @param windowTitle */ public static void addFragment(String fragement, String windowTitle) { Page.getCurrent().setUriFragment(fragement, false); Page.getCurrent().setTitle(StringUtils.trim(windowTitle, 150) + " [MyCollab]"); }
From source file:com.esofthead.mycollab.vaadin.ui.NotificationUtil.java
License:Open Source License
public static void showNotification(String caption, String description, Type type) { Notification warnNotif = new Notification(caption, description, type); warnNotif.setHtmlContentAllowed(true); warnNotif.setDelayMsec(3000);//from w w w . ja v a 2 s .c om if (Page.getCurrent() != null) { warnNotif.show(Page.getCurrent()); } else { LOG.error("Current page is null"); } }
From source file:com.esofthead.mycollab.vaadin.ui.ThemeManager.java
License:Open Source License
public static void loadUserTheme(int saccountid) { AccountThemeService themeService = ApplicationContextUtil.getSpringBean(AccountThemeService.class); AccountTheme accountTheme = themeService.getAccountTheme(saccountid); if (accountTheme == null || accountTheme.getId() == null) return;// w ww .j ava2s.co m /* Top Menu */ if (accountTheme.getTopmenubg() != null) { Page.getCurrent().getStyles() .add(".topNavigation { background-color: #" + accountTheme.getTopmenubg() + "; }"); } if (accountTheme.getTopmenubgselected() != null) { Page.getCurrent().getStyles() .add(".topNavigation .service-menu.v-buttongroup .v-button.selected { background-color: #" + accountTheme.getTopmenubgselected() + "; }"); } if (accountTheme.getTopmenutext() != null) { Page.getCurrent().getStyles() .add(".topNavigation .v-button-caption { color: #" + accountTheme.getTopmenutext() + "; }"); } if (accountTheme.getTopmenutextselected() != null) { Page.getCurrent().getStyles().add( ".topNavigation .service-menu.v-buttongroup .v-button.selected .v-button-caption { color: #" + accountTheme.getTopmenutextselected() + "; }"); } /* Vertical Tabsheet */ if (accountTheme.getVtabsheetbg() != null) { Page.getCurrent().getStyles() .add(".verticaltabsheet-fix { background-color: #" + accountTheme.getVtabsheetbg() + "; }"); } if (accountTheme.getVtabsheetbgselected() != null) { Page.getCurrent().getStyles() .add(".vertical-tabsheet .v-button-tab.tab-selected > .v-button-wrap { background-color: #" + accountTheme.getVtabsheetbgselected() + "; }"); } if (accountTheme.getVtabsheettext() != null) { Page.getCurrent().getStyles() .add(".vertical-tabsheet .v-button-tab > .v-button-wrap > .v-button-caption { color: #" + accountTheme.getVtabsheettext() + "; }"); } if (accountTheme.getVtabsheettextselected() != null) { Page.getCurrent().getStyles().add( ".vertical-tabsheet .v-button-tab.tab-selected > .v-button-wrap > .v-button-caption { color: #" + accountTheme.getVtabsheettextselected() + "; }"); } /* Tabsheet */ if (accountTheme.getTabsheetbg() != null) { Page.getCurrent().getStyles().add( ".tab-style3 > .v-tabsheet-tabcontainer > .v-tabsheet-tabs > tbody > tr > .v-tabsheet-tabitemcell > .v-tabsheet-tabitem { background-color: #" + accountTheme.getTabsheetbg() + "; }"); } if (accountTheme.getTabsheetbgselected() != null) { Page.getCurrent().getStyles().add( ".tab-style3 > .v-tabsheet-tabcontainer > .v-tabsheet-tabs > tbody > tr > .v-tabsheet-tabitemcell.v-tabsheet-tabitemcell-selected > .v-tabsheet-tabitem { background-color: #" + accountTheme.getTabsheetbgselected() + "; }"); } if (accountTheme.getTabsheettext() != null) { Page.getCurrent().getStyles().add( ".tab-style3 > .v-tabsheet-tabcontainer > .v-tabsheet-tabs > tbody > tr > .v-tabsheet-tabitemcell > .v-tabsheet-tabitem .v-caption .v-captiontext { color: #" + accountTheme.getTabsheettext() + "; }"); } if (accountTheme.getTabsheettextselected() != null) { Page.getCurrent().getStyles().add( ".tab-style3 > .v-tabsheet-tabcontainer > .v-tabsheet-tabs > tbody > tr > .v-tabsheet-tabitemcell > .v-tabsheet-tabitem.v-tabsheet-tabitem-selected .v-caption .v-captiontext { color: #" + accountTheme.getTabsheettextselected() + "; }"); } /* Horizontal Top Menu */ if (accountTheme.getHtopmenubg() != null) { Page.getCurrent().getStyles().add(".h-sidebar-menu, .projectfeed-hdr-wrapper { background-color: #" + accountTheme.getHtopmenubg() + "; }"); } if (accountTheme.getHtopmenubgselected() != null) { Page.getCurrent().getStyles() .add(".h-sidebar-menu .v-button.v-button-link.isSelected { background-color: #" + accountTheme.getHtopmenubgselected() + "; }"); } if (accountTheme.getHtopmenutext() != null) { Page.getCurrent().getStyles().add( ".h-sidebar-menu .v-button.v-button-link:focus .v-button-caption, .h-sidebar-menu .v-button.v-button-link:active .v-button-caption { color: #" + accountTheme.getHtopmenutext() + "; }"); } if (accountTheme.getHtopmenutextselected() != null) { Page.getCurrent().getStyles().add( ".h-sidebar-menu .v-button.v-button-link.isSelected .v-button-caption, .h-sidebar-menu .v-button.v-button-link.isSelected .v-button-caption:hover { color: #" + accountTheme.getHtopmenutextselected() + "; }"); } /* Action Buttons */ if (accountTheme.getActionbtn() != null) { Page.getCurrent().getStyles() .add(".v-button.v-button-greenbtn, .v-button-greenbtn:focus { background-color: #" + accountTheme.getActionbtn() + "; border-color: #" + getBorderColor(accountTheme.getActionbtn()) + "; }"); } if (accountTheme.getActionbtntext() != null) { Page.getCurrent().getStyles().add(".v-button.v-button-greenbtn, .v-button-greenbtn:focus { color: #" + accountTheme.getActionbtntext() + "; }"); } /* Control Buttons */ if (accountTheme.getControlbtn() != null) { Page.getCurrent().getStyles() .add(".v-button.v-button-brownbtn, .v-button-brownbtn:focus { background-color: #" + accountTheme.getControlbtn() + "; border-color: #" + getBorderColor(accountTheme.getControlbtn()) + "; }"); } if (accountTheme.getControlbtntext() != null) { Page.getCurrent().getStyles().add(".v-button.v-button-brownbtn, .v-button-brownbtn:focus { color: #" + accountTheme.getControlbtntext() + "; }"); } /* Option Buttons */ if (accountTheme.getOptionbtn() != null) { Page.getCurrent().getStyles() .add(".v-button.v-button-graybtn, .v-button-graybtn:focus { background-color: #" + accountTheme.getOptionbtn() + "; border-color: #" + getBorderColor(accountTheme.getOptionbtn()) + "; }"); } if (accountTheme.getOptionbtntext() != null) { Page.getCurrent().getStyles().add(".v-button.v-button-graybtn, .v-button-graybtn:focus { color: #" + accountTheme.getOptionbtntext() + "; }"); } /* Danger Buttons */ if (accountTheme.getDangerbtn() != null) { Page.getCurrent().getStyles() .add(".v-button.v-button-redbtn, .v-button-redbtn:focus { background-color: #" + accountTheme.getDangerbtn() + "; border-color: #" + getBorderColor(accountTheme.getDangerbtn()) + "; }"); } if (accountTheme.getDangerbtntext() != null) { Page.getCurrent().getStyles().add(".v-button.v-button-redbtn, .v-button-redbtn:focus { color: #" + accountTheme.getDangerbtntext() + "; }"); } /* Clear Buttons */ if (accountTheme.getClearbtn() != null) { Page.getCurrent().getStyles() .add(".v-button.v-button-blankbtn, .v-button-blankbtn:focus { background-color: #" + accountTheme.getClearbtn() + "; border-color: #" + getBorderColor(accountTheme.getClearbtn()) + "; }"); } if (accountTheme.getClearbtntext() != null) { Page.getCurrent().getStyles().add(".v-button.v-button-blankbtn, .v-button-blankbtn:focus { color: #" + accountTheme.getClearbtntext() + "; }"); } /* Toggle Buttons */ if (accountTheme.getTogglebtn() != null) { Page.getCurrent().getStyles() .add(".v-buttongroup.toggle-btn-group .v-button { background-color: #" + accountTheme.getTogglebtn() + "; border-color: #" + getBorderColor(accountTheme.getTogglebtn()) + "; }"); } if (accountTheme.getTogglebtntext() != null) { Page.getCurrent().getStyles().add(".v-buttongroup.toggle-btn-group .v-button { color: #" + accountTheme.getTogglebtntext() + "; }"); } if (accountTheme.getTogglebtnselected() != null) { Page.getCurrent().getStyles().add( ".v-button.v-button-bluebtn, .v-button-bluebtn:focus, .v-buttongroup.toggle-btn-group .v-button.active { background-color: #" + accountTheme.getTogglebtnselected() + "; border-color: #" + getBorderColor(accountTheme.getTogglebtnselected()) + "; }"); } if (accountTheme.getTogglebtntextselected() != null) { Page.getCurrent().getStyles().add( ".v-button.v-button-bluebtn, .v-button-bluebtn:focus, .v-buttongroup.toggle-btn-group .v-button.active { color: #" + accountTheme.getTogglebtntextselected() + "; }"); } }
From source file:com.esofthead.mycollab.vaadin.ui.ThemeManager.java
License:Open Source License
public static void loadDemoTheme(AccountTheme accountTheme) { /* Top Menu */ if (accountTheme.getTopmenubg() != null) { Page.getCurrent().getStyles().add( ".example-block .topNavigation { background-color: #" + accountTheme.getTopmenubg() + "; }"); }/*w w w . ja v a 2 s . c o m*/ if (accountTheme.getTopmenubgselected() != null) { Page.getCurrent().getStyles().add( ".example-block .topNavigation .service-menu.v-buttongroup .v-button.selected { background-color: #" + accountTheme.getTopmenubgselected() + "; }"); } if (accountTheme.getTopmenutext() != null) { Page.getCurrent().getStyles().add(".example-block .topNavigation .v-button-caption { color: #" + accountTheme.getTopmenutext() + "; }"); } if (accountTheme.getTopmenutextselected() != null) { Page.getCurrent().getStyles().add( ".example-block .topNavigation .service-menu.v-buttongroup .v-button.selected .v-button-caption { color: #" + accountTheme.getTopmenutextselected() + "; }"); } /* Vertical Tabsheet */ if (accountTheme.getVtabsheetbg() != null) { Page.getCurrent().getStyles().add(".example-block .verticaltabsheet-fix { background-color: #" + accountTheme.getVtabsheetbg() + "; }"); } if (accountTheme.getVtabsheetbgselected() != null) { Page.getCurrent().getStyles().add( ".example-block .vertical-tabsheet .v-button-tab.tab-selected > .v-button-wrap { background-color: #" + accountTheme.getVtabsheetbgselected() + "; }"); } if (accountTheme.getVtabsheettext() != null) { Page.getCurrent().getStyles().add( ".example-block .vertical-tabsheet .v-button-tab > .v-button-wrap > .v-button-caption { color: #" + accountTheme.getVtabsheettext() + "; }"); } if (accountTheme.getVtabsheettextselected() != null) { Page.getCurrent().getStyles().add( ".example-block .vertical-tabsheet .v-button-tab.tab-selected > .v-button-wrap > .v-button-caption { color: #" + accountTheme.getVtabsheettextselected() + "; }"); } /* Tabsheet */ if (accountTheme.getTabsheetbg() != null) { Page.getCurrent().getStyles().add( ".example-block .tab-style3 > .v-tabsheet-tabcontainer > .v-tabsheet-tabs > tbody > tr > .v-tabsheet-tabitemcell > .v-tabsheet-tabitem { background-color: #" + accountTheme.getTabsheetbg() + "; }"); } if (accountTheme.getTabsheetbgselected() != null) { Page.getCurrent().getStyles().add( ".example-block .tab-style3 > .v-tabsheet-tabcontainer > .v-tabsheet-tabs > tbody > tr > .v-tabsheet-tabitemcell.v-tabsheet-tabitemcell-selected > .v-tabsheet-tabitem { background-color: #" + accountTheme.getTabsheetbgselected() + "; }"); } if (accountTheme.getTabsheettext() != null) { Page.getCurrent().getStyles().add( ".example-block .tab-style3 > .v-tabsheet-tabcontainer > .v-tabsheet-tabs > tbody > tr > .v-tabsheet-tabitemcell > .v-tabsheet-tabitem .v-caption .v-captiontext { color: #" + accountTheme.getTabsheettext() + "; }"); } if (accountTheme.getTabsheettextselected() != null) { Page.getCurrent().getStyles().add( ".example-block .tab-style3 > .v-tabsheet-tabcontainer > .v-tabsheet-tabs > tbody > tr > .v-tabsheet-tabitemcell > .v-tabsheet-tabitem.v-tabsheet-tabitem-selected .v-caption .v-captiontext { color: #" + accountTheme.getTabsheettextselected() + "; }"); } /* Horizontal Top Menu */ if (accountTheme.getHtopmenubg() != null) { Page.getCurrent().getStyles().add( ".example-block .h-sidebar-menu, .example-block .projectfeed-hdr-wrapper { background-color: #" + accountTheme.getHtopmenubg() + "; }"); } if (accountTheme.getHtopmenubgselected() != null) { Page.getCurrent().getStyles() .add(".example-block .h-sidebar-menu .v-button.v-button-link.isSelected { background-color: #" + accountTheme.getHtopmenubgselected() + "; }"); } if (accountTheme.getHtopmenutext() != null) { Page.getCurrent().getStyles().add( ".example-block .h-sidebar-menu .v-button.v-button-link:focus .v-button-caption, .example-block .h-sidebar-menu .v-button.v-button-link:active .v-button-caption { color: #" + accountTheme.getHtopmenutext() + "; }"); } if (accountTheme.getHtopmenutextselected() != null) { Page.getCurrent().getStyles().add( ".example-block .h-sidebar-menu .v-button.v-button-link.isSelected .v-button-caption, .example-block .h-sidebar-menu .v-button.v-button-link.isSelected .v-button-caption:hover { color: #" + accountTheme.getHtopmenutextselected() + "; }"); } /* Action Buttons */ if (accountTheme.getActionbtn() != null) { Page.getCurrent().getStyles().add( ".example-block .v-button.v-button-greenbtn, .example-block .v-button-greenbtn:focus { background-color: #" + accountTheme.getActionbtn() + "; border-color: #" + getBorderColor(accountTheme.getActionbtn()) + "; }"); } if (accountTheme.getActionbtntext() != null) { Page.getCurrent().getStyles().add( ".example-block .v-button.v-button-greenbtn, .example-block .v-button-greenbtn:focus { color: #" + accountTheme.getActionbtntext() + "; }"); } /* Control Buttons */ if (accountTheme.getControlbtn() != null) { Page.getCurrent().getStyles().add( ".example-block .v-button.v-button-brownbtn, .example-block .v-button-brownbtn:focus { background-color: #" + accountTheme.getControlbtn() + "; border-color: #" + getBorderColor(accountTheme.getControlbtn()) + "; }"); } if (accountTheme.getControlbtntext() != null) { Page.getCurrent().getStyles().add( ".example-block .v-button.v-button-brownbtn, .example-block .v-button-brownbtn:focus { color: #" + accountTheme.getControlbtntext() + "; }"); } /* Option Buttons */ if (accountTheme.getOptionbtn() != null) { Page.getCurrent().getStyles().add( ".example-block .v-button.v-button-graybtn, .example-block .v-button-graybtn:focus { background-color: #" + accountTheme.getOptionbtn() + "; border-color: #" + getBorderColor(accountTheme.getOptionbtn()) + "; }"); } if (accountTheme.getOptionbtntext() != null) { Page.getCurrent().getStyles().add( ".example-block .v-button.v-button-graybtn, .example-block .v-button-graybtn:focus { color: #" + accountTheme.getOptionbtntext() + "; }"); } /* Danger Buttons */ if (accountTheme.getDangerbtn() != null) { Page.getCurrent().getStyles().add( ".example-block .v-button.v-button-redbtn, .example-block .v-button-redbtn:focus { background-color: #" + accountTheme.getDangerbtn() + "; border-color: #" + getBorderColor(accountTheme.getDangerbtn()) + "; }"); } if (accountTheme.getDangerbtntext() != null) { Page.getCurrent().getStyles().add( ".example-block .v-button.v-button-redbtn, .example-block .v-button-redbtn:focus { color: #" + accountTheme.getDangerbtntext() + "; }"); } /* Clear Buttons */ if (accountTheme.getClearbtn() != null) { Page.getCurrent().getStyles().add( ".example-block .v-button.v-button-blankbtn, .example-block .v-button-blankbtn:focus { background-color: #" + accountTheme.getClearbtn() + "; border-color: #" + getBorderColor(accountTheme.getClearbtn()) + "; }"); } if (accountTheme.getClearbtntext() != null) { Page.getCurrent().getStyles().add( ".example-block .v-button.v-button-blankbtn, .example-block .v-button-blankbtn:focus { color: #" + accountTheme.getClearbtntext() + "; }"); } /* Toggle Buttons */ if (accountTheme.getTogglebtn() != null) { Page.getCurrent().getStyles() .add(".example-block .v-buttongroup.toggle-btn-group .v-button { background-color: #" + accountTheme.getTogglebtn() + "; border-color: #" + getBorderColor(accountTheme.getTogglebtn()) + "; }"); } if (accountTheme.getTogglebtntext() != null) { Page.getCurrent().getStyles().add(".example-block .v-buttongroup.toggle-btn-group .v-button { color: #" + accountTheme.getTogglebtntext() + "; }"); } if (accountTheme.getTogglebtnselected() != null) { Page.getCurrent().getStyles().add( ".example-block .v-button.v-button-bluebtn, .example-block .v-button-bluebtn:focus, .example-block .v-buttongroup.toggle-btn-group .v-button.active { background-color: #" + accountTheme.getTogglebtnselected() + "; border-color: #" + getBorderColor(accountTheme.getTogglebtnselected()) + "; }"); } if (accountTheme.getTogglebtntextselected() != null) { Page.getCurrent().getStyles().add( ".example-block .v-button.v-button-bluebtn, .example-block .v-button-bluebtn:focus, .example-block .v-buttongroup.toggle-btn-group .v-button.active { color: #" + accountTheme.getTogglebtntextselected() + "; }"); } }
From source file:com.esofthead.mycollab.vaadin.ui.VerticalTabsheet.java
License:Open Source License
public void addTab(Component component, String id, int level, String caption, String link, Resource resource) { if (!hasTab(id)) { final ButtonTabImpl button = new ButtonTabImpl(id, level, caption, link); button.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override//from www .ja v a 2s . c o m public void buttonClick(ClickEvent event) { if (!event.isCtrlKey() && !event.isMetaKey()) { if (selectedButton != button) { clearTabSelection(true); selectedButton = button; selectedButton.addStyleName(TAB_SELECTED_STYLENAME); selectedComp = compMap.get(button.getTabId()); } fireTabChangeEvent(new SelectedTabChangeEvent(VerticalTabsheet.this)); } else { Page.getCurrent().open(button.link, "_blank", false); } } }); if (resource == null) { setDefaulButtonIcon(button, false); } else { button.setIcon(resource); } button.setStyleName(TAB_STYLENAME); button.setWidth("100%"); if (button.getLevel() > 0) { int insertIndex = 0; for (int i = 0; i < navigatorContainer.getComponentCount(); i++) { ButtonTabImpl buttonTmp = (ButtonTabImpl) navigatorContainer.getComponent(i); if (buttonTmp.getLevel() > level) { break; } else { insertIndex++; } } navigatorContainer.addComponent(button, insertIndex); } else { navigatorContainer.addComponent(button); } TabImpl tabImpl = new TabImpl(id, caption, component); compMap.put(id, tabImpl); } }
From source file:com.esofthead.mycollab.vaadin.web.ui.QueryParamHandler.java
License:Open Source License
public static ApplicationEventListener<ShellEvent.AddQueryParam> queryParamHandler() { return new ApplicationEventListener<ShellEvent.AddQueryParam>() { @Subscribe//ww w .j av a 2s .co m @Override public void handle(ShellEvent.AddQueryParam event) { List<SearchFieldInfo> searchFieldInfos = (List<SearchFieldInfo>) event.getData(); String query = QueryAnalyzer.toQueryParams(searchFieldInfos); String fragment = Page.getCurrent().getUriFragment(); int index = fragment.indexOf("?"); if (index > 0) { fragment = fragment.substring(0, index); } if (StringUtils.isNotBlank(query)) { fragment += "?" + UrlEncodeDecoder.encode(query); Page.getCurrent().setUriFragment(fragment, false); } } }; }
From source file:com.esofthead.mycollab.vaadin.web.ui.VerticalTabsheet.java
License:Open Source License
public void addTab(Component component, String id, int level, String caption, String link, Resource resource) { if (!hasTab(id)) { final ButtonTabImpl button = new ButtonTabImpl(id, level, caption, link); button.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override// w w w . j ava2s .c om public void buttonClick(ClickEvent event) { if (!event.isCtrlKey() && !event.isMetaKey()) { if (selectedButton != button) { clearTabSelection(true); selectedButton = button; selectedButton.addStyleName(TAB_SELECTED_STYLENAME); selectedComp = compMap.get(button.getTabId()); } fireTabChangeEvent(new SelectedTabChangeEvent(VerticalTabsheet.this)); } else { Page.getCurrent().open(button.link, "_blank", false); } } }); if (resource == null) { setDefaultButtonIcon(button, false); } else { button.setIcon(resource); } button.setStyleName(TAB_STYLENAME); button.addStyleName(UIConstants.TEXT_ELLIPSIS); button.setWidth("90%"); if (button.getLevel() > 0) { int insertIndex = 0; for (int i = 0; i < navigatorContainer.getComponentCount(); i++) { ButtonTabImpl buttonTmp = (ButtonTabImpl) navigatorContainer.getComponent(i); if (buttonTmp.getLevel() > level) { break; } else { insertIndex++; } } navigatorContainer.addComponent(button, insertIndex); navigatorContainer.setComponentAlignment(button, Alignment.MIDDLE_CENTER); } else { navigatorContainer.addComponent(button); navigatorContainer.setComponentAlignment(button, Alignment.MIDDLE_CENTER); } TabImpl tabImpl = new TabImpl(id, caption, component); compMap.put(id, tabImpl); } }
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 ww w. j av a2 s .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.notification.NotificationMainUI.java
public NotificationMainUI() { setSizeFull();/* w w w.j a v a2 s . com*/ setSpacing(true); if (VaadinSession.getCurrent().getAttribute("userId") == null) { Page.getCurrent().setLocation("http://localhost:8080/"); } else { addComponent(populateNoficationTable()); } HorizontalLayout h = new HorizontalLayout(); h.setWidth("950px"); Button sendMsgBtn = new Button("Send Message"); sendMsgBtn.setWidthUndefined(); sendMsgBtn.addStyleName(ValoTheme.BUTTON_SMALL); sendMsgBtn.addStyleName(ValoTheme.BUTTON_PRIMARY); sendMsgBtn.addClickListener((Button.ClickEvent event) -> { Notification.show("Send Message!"); }); h.addComponent(sendMsgBtn); h.setComponentAlignment(sendMsgBtn, Alignment.MIDDLE_RIGHT); addComponent(h); }