List of usage examples for com.vaadin.ui Button addStyleName
@Override public void addStyleName(String style)
From source file:com.esofthead.mycollab.vaadin.web.ui.AttachmentPanel.java
License:Open Source License
private void displayFileName(File file, final String fileName) { final MHorizontalLayout fileAttachmentLayout = new MHorizontalLayout().withFullWidth(); Button removeBtn = new Button(null, new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override// w w w. j ava 2 s . c o m public void buttonClick(ClickEvent event) { File file = fileStores.get(fileName); if (file != null) { file.delete(); } fileStores.remove(fileName); AttachmentPanel.this.removeComponent(fileAttachmentLayout); if (multiFileUpload != null) { multiFileUpload.removeAndReInitMultiUpload(); } } }); removeBtn.setIcon(FontAwesome.TRASH_O); removeBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY); removeBtn.setWidthUndefined(); ELabel fileLbl = new ELabel(fileName, ContentMode.HTML).withDescription(fileName) .withStyleName(UIConstants.TEXT_ELLIPSIS); fileAttachmentLayout.with( new ELabel(FileAssetsUtil.getFileIconResource(fileName).getHtml(), ContentMode.HTML) .withWidthUndefined(), fileLbl, new ELabel(" - " + FileUtils.getVolumeDisplay(file.length())) .withStyleName(UIConstants.META_INFO).withWidthUndefined(), removeBtn).expand(fileLbl); this.addComponent(fileAttachmentLayout); }
From source file:com.esofthead.mycollab.vaadin.web.ui.BuildCriterionComponent.java
License:Open Source License
private void buildFilterBox(String queryName) { filterBox.removeAllComponents();//from w ww.j a va 2 s . com SavedSearchResultComboBox filterComboBox = new SavedSearchResultComboBox(); filterBox.addComponent(filterComboBox); Button saveSearchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_NEW_FILTER), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { buildSaveFilterBox(); } }); saveSearchBtn.addStyleName(UIConstants.BUTTON_ACTION); saveSearchBtn.setIcon(FontAwesome.PLUS); filterBox.addComponent(saveSearchBtn); }
From source file:com.esofthead.mycollab.vaadin.web.ui.BuildCriterionComponent.java
License:Open Source License
private void buildSaveFilterBox() { filterBox.removeAllComponents();/*from w w w .j a v a2 s . com*/ final TextField queryTextField = new TextField(); filterBox.addComponent(queryTextField); Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { String queryText = queryTextField.getValue(); saveSearchCriteria(queryText); } }); saveBtn.setStyleName(UIConstants.BUTTON_ACTION); saveBtn.setIcon(FontAwesome.SAVE); filterBox.addComponent(saveBtn); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { buildFilterBox(null); } }); cancelBtn.addStyleName(UIConstants.BUTTON_OPTION); filterBox.addComponent(cancelBtn); }
From source file:com.esofthead.mycollab.vaadin.web.ui.NotificationComponent.java
License:Open Source License
private Component buildComponentFromNotification(AbstractNotification item) { final MHorizontalLayout wrapper = new MHorizontalLayout(); wrapper.setData(item);/*from www .java2 s. c o m*/ wrapper.setDefaultComponentAlignment(Alignment.TOP_LEFT); if (item instanceof NewUpdateAvailableNotification) { final NewUpdateAvailableNotification notification = (NewUpdateAvailableNotification) item; Span spanEl = new Span(); spanEl.appendText( AppContext.getMessage(ShellI18nEnum.OPT_HAVING_NEW_VERSION, notification.getVersion())); Label lbl = new Label(FontAwesome.INFO_CIRCLE.getHtml() + " " + spanEl.write(), ContentMode.HTML); lbl.setWidth("100%"); CssLayout lblWrapper = new CssLayout(); lblWrapper.addComponent(lbl); wrapper.addComponent(lblWrapper); wrapper.expand(lblWrapper); if (AppContext.isAdmin()) { Button upgradeBtn = new Button(AppContext.getMessage(ShellI18nEnum.ACTION_UPGRADE), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { UI.getCurrent().addWindow(new UpgradeConfirmWindow(notification.getVersion(), notification.getManualDownloadLink(), notification.getInstallerFile())); NotificationComponent.this.setPopupVisible(false); } }); upgradeBtn.addStyleName(UIConstants.BUTTON_BLOCK); wrapper.addComponent(upgradeBtn); } } else if (item instanceof RequestUploadAvatarNotification) { wrapper.addComponent(new Label(FontAwesome.EXCLAMATION_TRIANGLE.getHtml() + " " + AppContext.getMessage(ShellI18nEnum.OPT_REQUEST_UPLOAD_AVATAR), ContentMode.HTML)); Button uploadAvatarBtn = new Button(AppContext.getMessage(ShellI18nEnum.ACTION_UPLOAD_AVATAR), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "preview" })); NotificationComponent.this.setPopupVisible(false); } }); uploadAvatarBtn.setStyleName(UIConstants.BUTTON_BLOCK); wrapper.add(uploadAvatarBtn); } else if (item instanceof SmtpSetupNotification) { Button smtpBtn = new Button(AppContext.getMessage(GenericI18Enum.ACTION_SETUP), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "setup" })); NotificationComponent.this.setPopupVisible(false); } }); smtpBtn.setStyleName(UIConstants.BUTTON_BLOCK); Label lbl = new Label(FontAwesome.EXCLAMATION_TRIANGLE.getHtml() + " " + AppContext.getMessage(ShellI18nEnum.ERROR_NO_SMTP_SETTING), ContentMode.HTML); MCssLayout lblWrapper = new MCssLayout(lbl); wrapper.with(lblWrapper, smtpBtn).expand(lblWrapper); } else { LOG.error("Do not render notification " + item); } return wrapper; }
From source file:com.esofthead.mycollab.vaadin.web.ui.OptionPopupContent.java
License:Open Source License
public void addOption(Button btn) { CssLayout wrap = new CssLayout(); btn.setWidth("100%"); btn.setDescription(btn.getCaption()); btn.addStyleName("action"); wrap.addStyleName("action-wrap"); wrap.addComponent(btn);//w ww. java2 s . c o m ((ComponentContainer) this.getCompositionRoot()).addComponent(wrap); }
From source file:com.esofthead.mycollab.vaadin.web.ui.SplitButton.java
License:Open Source License
public SplitButton(Button parentButton) { this.setImmediate(true); HorizontalLayout contentLayout = new HorizontalLayout(); contentLayout.setStyleName("splitbutton"); this.parentButton = parentButton; parentButton.addStyleName("parent-button"); parentButton.setImmediate(true);//from www . ja v a2s. c o m parentButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { fireEvent(new SplitButtonClickEvent(SplitButton.this)); } }); popupButton = new PopupButton(); popupButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { isPopupVisible = !isPopupVisible; fireEvent(new SplitButtonPopupVisibilityEvent(SplitButton.this, isPopupVisible)); } }); contentLayout.addComponent(parentButton); contentLayout.addComponent(popupButton); this.setCompositionRoot(contentLayout); }
From source file:com.esofthead.mycollab.vaadin.web.ui.table.AbstractPagedBeanTable.java
License:Open Source License
private ComponentContainer createPagingControls() { controlBarWrapper = new HorizontalLayout(); controlBarWrapper.setWidth("100%"); controlBarWrapper.setStyleName("listControl"); pageManagement = new MHorizontalLayout(); // defined layout here --------------------------- if (currentPage > 1) { Button firstLink = new Button("1", new ClickListener() { private static final long serialVersionUID = 1L; @Override// w ww . j av a 2 s .c om public void buttonClick(final ClickEvent event) { pageChange(1); } }); firstLink.addStyleName("buttonPaging"); pageManagement.addComponent(firstLink); } if (currentPage >= 5) { 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) { Button previous1 = new Button("" + (currentPage - 1), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { pageChange(currentPage - 1); } }); previous1.addStyleName("buttonPaging"); pageManagement.addComponent(previous1); } // Here add current ButtonLinkLegacy 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 = totalPage - currentPage; if (range >= 1) { 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) { final Label ss2 = new Label("..."); ss2.addStyleName("buttonPaging"); pageManagement.addComponent(ss2); } if (range >= 3) { 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); controlBarWrapper.addComponent(pageManagement); controlBarWrapper.setComponentAlignment(pageManagement, Alignment.MIDDLE_RIGHT); return controlBarWrapper; }
From source file:com.esofthead.mycollab.web.AdWindow.java
License:Open Source License
public AdWindow() { super("Buy MyCollab Pro edition"); this.setWidth("700px"); this.setModal(true); this.setResizable(false); RestTemplate restTemplate = new RestTemplate(); MVerticalLayout content = new MVerticalLayout(); try {//from ww w. j a v a 2 s .co m String result = restTemplate.getForObject("https://api.mycollab.com/api/storeweb", String.class); Label webPage = new Label(result, ContentMode.HTML); webPage.setHeight("600px"); this.setContent(content.with(webPage).withAlign(webPage, Alignment.TOP_CENTER)); } catch (Exception e) { Div informDiv = new Div() .appendText("Can not load the store page. You can check the online edition at ") .appendChild(new A("https://www.mycollab.com/pricing/download/", "_blank").appendText("here")); Label webPage = new Label(informDiv.write(), ContentMode.HTML); this.setContent(content.with(webPage).withAlign(webPage, Alignment.TOP_CENTER)); } LicenseResolver licenseResolver = AppContextUtil.getSpringBean(LicenseResolver.class); if (licenseResolver != null) { Button editLicenseBtn = new Button("Enter license code", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { Window activateWindow = ViewManager.getCacheComponent(AbstractLicenseActivationWindow.class); UI.getCurrent().addWindow(activateWindow); close(); } }); editLicenseBtn.addStyleName(UIConstants.BUTTON_ACTION); content.with(editLicenseBtn).withAlign(editLicenseBtn, Alignment.MIDDLE_CENTER); } }
From source file:com.esofthead.mycollab.web.BuyPremiumSoftwareWindow.java
License:Open Source License
public BuyPremiumSoftwareWindow() { super("Buy MyCollab Pro edition"); this.setWidth("700px"); this.setModal(true); this.setResizable(false); RestTemplate restTemplate = new RestTemplate(); MVerticalLayout content = new MVerticalLayout(); try {/*from w w w. j a va 2 s . c o m*/ String result = restTemplate.getForObject("https://api.mycollab.com/api/linktobuy", String.class); Label webPage = new Label(result, ContentMode.HTML); webPage.setHeight("600px"); this.setContent(content.with(webPage).withAlign(webPage, Alignment.TOP_CENTER)); } catch (Exception e) { String result = FileUtils.readFileAsPlainString("buying.html"); Label webPage = new Label(result, ContentMode.HTML); this.setContent(content.with(webPage).withAlign(webPage, Alignment.TOP_CENTER)); } LicenseResolver licenseResolver = AppContextUtil.getSpringBean(LicenseResolver.class); if (licenseResolver != null) { Button editLicenseBtn = new Button("Enter license code", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { Window activateWindow = ViewManager.getCacheComponent(AbstractLicenseActivationWindow.class); UI.getCurrent().addWindow(activateWindow); close(); } }); editLicenseBtn.addStyleName(UIConstants.BUTTON_ACTION); content.with(editLicenseBtn).withAlign(editLicenseBtn, Alignment.MIDDLE_CENTER); } }
From source file:com.esspl.datagen.ui.ExecutorView.java
License:Open Source License
public ExecutorView(DataGenApplication application) { log.debug("ExecutorView - constructor start"); dataGenApplication = application;/*from www . j av a 2 s . co m*/ setSizeFull(); VerticalLayout vl = new VerticalLayout(); vl.setSizeFull(); setCompositionRoot(vl); splitPanel = new VerticalSplitPanel(); splitPanel.setSizeFull(); //Script TextArea sqlScript = new TextArea(); sqlScript.setSizeFull(); sqlScript.setWordwrap(false); sqlScript.setStyleName("noResizeTextArea"); HorizontalLayout queryOptions = new HorizontalLayout(); queryOptions.setMargin(false, false, false, true); queryOptions.setSpacing(true); queryOptions.setWidth("100%"); queryOptions.setHeight("40px"); Button executeButton = new Button("Execute", new ClickListener() { @Override public void buttonClick(ClickEvent event) { log.info("ExecutorView - Execute Button clicked"); executeScript(sqlScript.getValue().toString()); } }); executeButton.addStyleName("small"); executeButton.setIcon(DataGenConstant.EXECUTOR_ICON); executeButton.setDescription("Press Ctrl+Enter to execute the query"); Button clearQueryButton = new Button("Clear SQL", new ClickListener() { @Override public void buttonClick(ClickEvent event) { log.info("ExecutorView - Clear SQL Button clicked"); sqlScript.setValue(""); } }); clearQueryButton.addStyleName("small"); clearQueryButton.setIcon(DataGenConstant.CLEAR_SMALL); clearQueryButton.setDescription("Clears the Sql"); Button clearConsoleButton = new Button("Clear Console", new ClickListener() { @Override public void buttonClick(ClickEvent event) { log.info("ExecutorView - Clear Console Button clicked"); logText.setValue(""); } }); clearConsoleButton.addStyleName("small"); clearConsoleButton.setIcon(DataGenConstant.CLEAR_SMALL); clearConsoleButton.setDescription("Clears the Console"); maxRowsBox = new ComboBox(null, Arrays.asList(10, 100, 500, 1000, 5000, 10000)); maxRowsBox.setDescription("Max number of rows to retrieve"); maxRowsBox.setWidth(100, UNITS_PIXELS); maxRowsBox.setNewItemsAllowed(false); maxRowsBox.setNullSelectionAllowed(false); maxRowsBox.setValue(100); //Bottom section components resultSheet = new TabSheet(); resultSheet.setSizeFull(); resultSheet.addStyleName(Runo.TABSHEET_SMALL); logText = new Label(); logText.setContentMode(Label.CONTENT_XHTML); logText.setSizeFull(); //Panel to add refresher logPanel = new Panel(); logPanel.setSizeFull(); logPanel.setScrollable(true); logPanel.setStyleName(Runo.PANEL_LIGHT); logPanel.addComponent(logText); //Refresher added to show instant log messages refresher = new Refresher(); logPanel.addComponent(refresher); //Loading image loadingImg = new Embedded("", DataGenConstant.LOADING_ICON); loadingImg.setVisible(false); logPanel.addComponent(loadingImg); resultSheet.addTab(logPanel, "Console"); resultTab = resultSheet.addTab(new Label(), "Results"); queryOptions.addComponent(executeButton); queryOptions.setComponentAlignment(executeButton, Alignment.MIDDLE_LEFT); queryOptions.addComponent(clearQueryButton); queryOptions.setComponentAlignment(clearQueryButton, Alignment.MIDDLE_LEFT); queryOptions.addComponent(clearConsoleButton); queryOptions.setComponentAlignment(clearConsoleButton, Alignment.MIDDLE_LEFT); queryOptions.setExpandRatio(clearConsoleButton, 1); queryOptions.addComponent(maxRowsBox); queryOptions.setComponentAlignment(maxRowsBox, Alignment.MIDDLE_RIGHT); splitPanel.setFirstComponent(sqlScript); splitPanel.setSecondComponent(resultSheet); vl.addComponent(queryOptions); vl.addComponent(splitPanel); vl.setExpandRatio(splitPanel, 1); sqlScript.addShortcutListener(new ShortcutListener("Execute Script", null, ShortcutAction.KeyCode.ENTER, ShortcutAction.ModifierKey.CTRL) { @Override public void handleAction(Object sender, Object target) { executeScript(sqlScript.getValue().toString()); } }); log.debug("ExecutorView - constructor end"); }