List of usage examples for com.vaadin.ui VerticalLayout addComponent
@Override public void addComponent(Component c)
From source file:com.esofthead.mycollab.module.user.ui.components.ImagePreviewCropWindow.java
License:Open Source License
public ImagePreviewCropWindow(final ImageSelectionCommand imageSelectionCommand, final byte[] imageData) { super("Preview and modify image"); setModal(true);/*w w w. jav a 2 s. c o m*/ setResizable(false); setWidth("700px"); center(); MVerticalLayout content = new MVerticalLayout(); setContent(content); 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)).withFullWidth(); previewPhoto = new VerticalLayout(); previewPhoto.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); previewPhoto.setWidth("100px"); previewBox.with(previewPhoto).withAlign(previewPhoto, Alignment.TOP_LEFT); VerticalLayout previewBoxTitle = new VerticalLayout(); previewBoxTitle.setMargin(new MarginInfo(false, true, false, true)); Label lbPreview = new Label("<p style='margin: 0px;'><strong>To the bottom 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); previewBoxTitle.addComponent(lbPreview); MHorizontalLayout controlBtns = new MHorizontalLayout(); controlBtns.setSizeUndefined(); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { close(); } }); cancelBtn.setStyleName(UIConstants.BUTTON_OPTION); Button acceptBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ACCEPT), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (scaleImageData != null && scaleImageData.length > 0) { try { BufferedImage image = ImageIO.read(new ByteArrayInputStream(scaleImageData)); imageSelectionCommand.process(image); close(); } catch (IOException e) { throw new MyCollabException("Error when saving user avatar", e); } } } }); acceptBtn.setStyleName(UIConstants.BUTTON_ACTION); acceptBtn.setIcon(FontAwesome.CHECK); controlBtns.with(acceptBtn, cancelBtn).alignAll(Alignment.MIDDLE_LEFT); previewBoxTitle.addComponent(controlBtns); previewBoxTitle.setComponentAlignment(controlBtns, Alignment.TOP_LEFT); previewBox.with(previewBoxTitle).expand(previewBoxTitle); CssLayout cropBox = new CssLayout(); 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("520px"); currentPhotoBox.setHeight("470px"); currentPhotoBox.addComponent(cropField); cropBox.addComponent(currentPhotoBox); content.with(previewBox, ELabel.hr(), cropBox); displayPreviewImage(); }
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//from w ww .jav a2s . 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'>>></div>"); } else { if (AppContext.isAdmin()) { informLbl.setValue("<div class='informBlock'>TRIAL ENDING<br>" + (30 - daysLeft) + " DAYS LEFT</div><div class='informBlock'>>></div>"); } else { informLbl.setValue("<div class='informBlock'>TRIAL ENDING<br>" + (30 - daysLeft) + " DAYS LEFT</div><div class='informBlock'>>></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.vaadin.ui.BeanList.java
License:Open Source License
public void loadItems(List<T> currentListData) { contentLayout.removeAllComponents(); try {/*from w w w . j av a2 s. c om*/ if (CollectionUtils.isEmpty(currentListData) && isDisplayEmptyListText) { Label noItemLbl = new Label(AppContext.getMessage(GenericI18Enum.EXT_NO_ITEM)); final VerticalLayout widgetFooter = new VerticalLayout(); widgetFooter.addStyleName("widget-footer"); widgetFooter.setWidth("100%"); widgetFooter.addComponent(noItemLbl); widgetFooter.setComponentAlignment(noItemLbl, Alignment.MIDDLE_CENTER); contentLayout.addComponent(widgetFooter); } else { int i = 0; for (T item : currentListData) { RowDisplayHandler<T> rowHandler = constructRowDisplayHandler(); Component row = rowHandler.generateRow(item, i); if (row != null) { row.setWidth("100%"); contentLayout.addComponent(row); } i++; } } } catch (Exception e) { LOG.error("Error while generate column display", e); } }
From source file:com.esofthead.mycollab.vaadin.ui.FeedbackWindow.java
License:Open Source License
private void initUI() { GridLayout mainLayout = new GridLayout(2, 5); mainLayout.setMargin(true);/*w w w. j a v a 2 s . com*/ mainLayout.setSpacing(true); emailNameTextField = new TextField(); emailNameTextField.setWidth("500px"); Label emailName = new Label("Your name: "); mainLayout.addComponent(emailName, 0, 0); mainLayout.addComponent(emailNameTextField, 1, 0); emailTextField = new TextField(); emailTextField.setWidth("500px"); emailTextField.setRequired(true); Label emailLbl = new Label("Your email: "); mainLayout.addComponent(emailLbl, 0, 1); mainLayout.addComponent(emailTextField, 1, 1); subjectTextField = new TextField(); subjectTextField.setWidth("500px"); subjectTextField.setRequired(true); Label subjectLbl = new Label("Subject: "); mainLayout.addComponent(subjectLbl, 0, 2); mainLayout.addComponent(subjectTextField, 1, 2); final RichTextArea contentArea = new RichTextArea(); contentArea.setImmediate(true); contentArea.setWidth(500, Sizeable.Unit.PIXELS); contentArea.setHeight(200, Sizeable.Unit.PIXELS); Label contentLbl = new Label("Your feedback: "); mainLayout.addComponent(contentLbl, 0, 3); mainLayout.addComponent(contentArea, 1, 3); initDefaultData(); HorizontalLayout controlsLayout = new HorizontalLayout(); controlsLayout.setWidth("100%"); final AttachmentPanel attachments = new AttachmentPanel(); attachments.setWidth("350px"); MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments); uploadExt.addComponent(attachments); // Panel attachedFilepanel = new Panel(); VerticalLayout contentLayout = new VerticalLayout(); contentLayout.setHeight("80px"); contentLayout.setStyleName("noneBorder-panel"); contentLayout.setSizeUndefined(); contentLayout.addComponent(uploadExt); // attachedFilepanel.setContent(contentLayout); controlsLayout.addComponent(contentLayout); controlsLayout.setComponentAlignment(contentLayout, Alignment.BOTTOM_LEFT); controlsLayout.setExpandRatio(contentLayout, 1.0f); controlsLayout.setSpacing(true); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { FeedbackWindow.this.close(); } }); cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK); controlsLayout.addComponent(cancelBtn); controlsLayout.setComponentAlignment(cancelBtn, Alignment.MIDDLE_RIGHT); Button sendBtn = new Button("Send", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { String email = emailTextField.getValue().toString().trim(); String subject = subjectTextField.getValue().toString().trim(); if (!StringUtils.isValidEmail(email)) { NotificationUtil.showWarningNotification("The email is not valid, please check it again!"); return; } if (!email.equals("") && !subject.equals("")) { ExtMailService systemMailService = ApplicationContextUtil.getSpringBean(ExtMailService.class); List<File> listFile = attachments.getListFile(); List<EmailAttachementSource> emailAttachmentSource = null; if (CollectionUtils.isNotEmpty(listFile)) { emailAttachmentSource = new ArrayList<EmailAttachementSource>(); for (File file : listFile) { emailAttachmentSource.add(new FileEmailAttachmentSource(file)); } } String nameEmailFrom = emailNameTextField.getValue().toString().trim(); nameEmailFrom = nameEmailFrom.equals("") ? email : nameEmailFrom; String toEmail = SiteConfiguration.getSendErrorEmail(); FeedbackWindow.this.close(); systemMailService.sendHTMLMail(email, nameEmailFrom, Arrays.asList(new MailRecipientField(toEmail, toEmail)), null, null, subject, contentArea.getValue().toString(), emailAttachmentSource); } else { NotificationUtil.showWarningNotification( "The email field and subject field must be not empty! Please fulfil them before pressing enter button."); } } }); sendBtn.setStyleName(UIConstants.THEME_GREEN_LINK); controlsLayout.addComponent(sendBtn); controlsLayout.setComponentAlignment(sendBtn, Alignment.MIDDLE_RIGHT); mainLayout.addComponent(controlsLayout, 0, 4, 1, 4); this.setContent(mainLayout); }
From source file:com.esofthead.mycollab.vaadin.ui.NotPresentedView.java
License:Open Source License
public NotPresentedView() { this.setHeight("370px"); this.setWidth("100%"); VerticalLayout layoutWapper = new VerticalLayout(); layoutWapper.setWidth("100%"); VerticalLayout layout = new VerticalLayout(); final Label titleIcon = new Label(FontAwesome.EXCLAMATION_CIRCLE.getHtml(), ContentMode.HTML); titleIcon.setStyleName("warning-icon"); titleIcon.setSizeUndefined();//from w w w . j ava 2s .c o m layout.addComponent(titleIcon); layout.setComponentAlignment(titleIcon, Alignment.MIDDLE_CENTER); Label label = new Label("The feature is not presented for this edition"); label.setStyleName("h2_community"); layout.addComponent(label); layout.setComponentAlignment(label, Alignment.MIDDLE_CENTER); layoutWapper.addComponent(layout); layoutWapper.setComponentAlignment(layout, Alignment.MIDDLE_CENTER); this.addComponent(layoutWapper); this.setComponentAlignment(layoutWapper, Alignment.MIDDLE_CENTER); }
From source file:com.esofthead.mycollab.vaadin.ui.SelectionOptionButton.java
License:Open Source License
@SuppressWarnings("serial") public SelectionOptionButton( @SuppressWarnings("rawtypes") final HasSelectableItemHandlers selectableItemHandlers) { super();//from w ww .j a v a2 s. c om this.selectableItemHandlers = selectableItemHandlers; addStyleName(UIConstants.THEME_BLUE_LINK); addStyleName(UIConstants.BUTTON_SMALL_PADDING); setIcon(FontAwesome.SQUARE_O); addClickListener(new SplitButtonClickListener() { @Override public void splitButtonClick(final SplitButtonClickEvent event) { toggleChangeOption(); } }); addPopupVisibilityListener(new SplitButtonPopupVisibilityListener() { @Override public void splitButtonPopupVisibilityChange(final SplitButtonPopupVisibilityEvent event) { if (event.isPopupVisible()) { selectAllBtn.setCaption("Select All (" + SelectionOptionButton.this.selectableItemHandlers.totalItemsCount() + ")"); selectThisPageBtn.setCaption("Select This Page (" + SelectionOptionButton.this.selectableItemHandlers.currentViewCount() + ")"); } } }); final VerticalLayout selectContent = new VerticalLayout(); selectContent.setWidth("150px"); selectAllBtn = new ButtonLink("", new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { isSelectAll = true; SelectionOptionButton.this.setIcon(FontAwesome.CHECK_SQUARE_O); fireSelectAll(); SelectionOptionButton.this.setPopupVisible(false); } }); selectContent.addComponent(selectAllBtn); selectThisPageBtn = new ButtonLink("", new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { isSelectAll = false; SelectionOptionButton.this.setIcon(FontAwesome.CHECK_SQUARE_O); fireSelectCurrentPage(); SelectionOptionButton.this.setPopupVisible(false); } }); selectContent.addComponent(selectThisPageBtn); Button deSelectBtn = new ButtonLink("Deselect All", new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { isSelectAll = false; SelectionOptionButton.this.setIcon(FontAwesome.SQUARE_O); fireDeselect(); SelectionOptionButton.this.setPopupVisible(false); } }); selectContent.addComponent(deSelectBtn); setContent(selectContent); }
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);// w w w. j av a 2 s . co 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.field.AttachmentUploadField.java
License:Open Source License
@Override protected Component initContent() { final VerticalLayout layout = new VerticalLayout(); MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachmentPanel); uploadExt.addComponent(attachmentPanel); layout.addComponent(uploadExt); return layout; }
From source file:com.esspl.datagen.DataGenApplication.java
License:Open Source License
private void buildMainLayout() { log.debug("DataGenApplication - buildMainLayout() start"); VerticalLayout rootLayout = new VerticalLayout(); final Window root = new Window("DATA Gen", rootLayout); root.setStyleName("tData"); setMainWindow(root);/*from ww w .j a va2s . co m*/ rootLayout.setSizeFull(); rootLayout.setMargin(false, true, false, true); // Top area, containing logo and header HorizontalLayout top = new HorizontalLayout(); top.setWidth("100%"); root.addComponent(top); // Create the placeholders for all the components in the top area HorizontalLayout header = new HorizontalLayout(); // Add the components and align them properly top.addComponent(header); top.setComponentAlignment(header, Alignment.TOP_LEFT); top.setStyleName("top"); top.setHeight("75px"); // Same as the background image height // header controls Embedded logo = new Embedded(); logo.setSource(DataGenConstant.LOGO); logo.setWidth("100%"); logo.setStyleName("logo"); header.addComponent(logo); header.setSpacing(false); //Show which connection profile is connected connectedString = new Label("Connected to - Oracle"); connectedString.setStyleName("connectedString"); connectedString.setWidth("500px"); connectedString.setVisible(false); top.addComponent(connectedString); //Toolbar toolbar = new ToolBar(this); top.addComponent(toolbar); top.setComponentAlignment(toolbar, Alignment.TOP_RIGHT); listing = new Table(); listing.setHeight("240px"); listing.setWidth("100%"); listing.setStyleName("dataTable"); listing.setImmediate(true); // turn on column reordering and collapsing listing.setColumnReorderingAllowed(true); listing.setColumnCollapsingAllowed(true); listing.setSortDisabled(true); // Add the table headers listing.addContainerProperty("Sl No.", Integer.class, null); listing.addContainerProperty("Column Name", TextField.class, null); listing.addContainerProperty("Data Type", Select.class, null); listing.addContainerProperty("Format", Select.class, null); listing.addContainerProperty("Examples", Label.class, null); listing.addContainerProperty("Additional Data", HorizontalLayout.class, null); listing.setColumnAlignments(new String[] { Table.ALIGN_CENTER, Table.ALIGN_CENTER, Table.ALIGN_CENTER, Table.ALIGN_CENTER, Table.ALIGN_CENTER, Table.ALIGN_CENTER }); //From the starting create 5 rows addRow(5); //Add different style for IE browser WebApplicationContext context = ((WebApplicationContext) getMainWindow().getApplication().getContext()); WebBrowser browser = context.getBrowser(); //Create a TabSheet tabSheet = new TabSheet(); tabSheet.setSizeFull(); if (!browser.isIE()) { tabSheet.setStyleName("tabSheet"); } //Generator Tab content start generator = new VerticalLayout(); generator.setMargin(true, true, false, true); generateTypeHl = new HorizontalLayout(); generateTypeHl.setMargin(false, false, false, true); generateTypeHl.setSpacing(true); List<String> generateTypeList = Arrays.asList(new String[] { "Sql", "Excel", "XML", "CSV" }); generateType = new OptionGroup("Generation Type", generateTypeList); generateType.setNullSelectionAllowed(false); // user can not 'unselect' generateType.select("Sql"); // select this by default generateType.setImmediate(true); // send the change to the server at once generateType.addListener(this); // react when the user selects something generateTypeHl.addComponent(generateType); //SQL Options sqlPanel = new Panel("SQL Options"); sqlPanel.setHeight("180px"); if (browser.isIE()) { sqlPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanelIE"); } else { sqlPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanel"); } VerticalLayout vl1 = new VerticalLayout(); vl1.setMargin(false); Label lb1 = new Label("DataBase"); database = new Select(); database.addItem("Oracle"); database.addItem("Sql Server"); database.addItem("My Sql"); database.addItem("Postgress Sql"); database.addItem("H2"); database.select("Oracle"); database.setWidth("160px"); database.setNullSelectionAllowed(false); HorizontalLayout dbBar = new HorizontalLayout(); dbBar.setMargin(false, false, false, false); dbBar.setSpacing(true); dbBar.addComponent(lb1); dbBar.addComponent(database); vl1.addComponent(dbBar); Label tblLabel = new Label("Table Name"); tblName = new TextField(); tblName.setWidth("145px"); tblName.setStyleName("mandatory"); HorizontalLayout tableBar = new HorizontalLayout(); tableBar.setMargin(true, false, false, false); tableBar.setSpacing(true); tableBar.addComponent(tblLabel); tableBar.addComponent(tblName); vl1.addComponent(tableBar); createQuery = new CheckBox("Include CREATE TABLE query"); createQuery.setValue(true); HorizontalLayout createBar = new HorizontalLayout(); createBar.setMargin(true, false, false, false); createBar.addComponent(createQuery); vl1.addComponent(createBar); sqlPanel.addComponent(vl1); generateTypeHl.addComponent(sqlPanel); generator.addComponent(generateTypeHl); //CSV Option csvPanel = new Panel("CSV Options"); csvPanel.setHeight("130px"); if (browser.isIE()) { csvPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanelIE"); } else { csvPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanel"); } Label delimiter = new Label("Delimiter Character(s)"); VerticalLayout vl2 = new VerticalLayout(); vl2.setMargin(false); csvDelimiter = new TextField(); HorizontalLayout csvBar = new HorizontalLayout(); csvBar.setMargin(true, false, false, false); csvBar.setSpacing(true); csvBar.addComponent(delimiter); csvBar.addComponent(csvDelimiter); vl2.addComponent(csvBar); csvPanel.addComponent(vl2); //XML Options xmlPanel = new Panel("XML Options"); xmlPanel.setHeight("160px"); if (browser.isIE()) { xmlPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanelIE"); } else { xmlPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanel"); } VerticalLayout vl3 = new VerticalLayout(); vl3.setMargin(false); Label lb4 = new Label("Root node name"); rootNode = new TextField(); rootNode.setWidth("125px"); rootNode.setStyleName("mandatory"); HorizontalLayout nodeBar = new HorizontalLayout(); nodeBar.setMargin(true, false, false, false); nodeBar.setSpacing(true); nodeBar.addComponent(lb4); nodeBar.addComponent(rootNode); vl3.addComponent(nodeBar); Label lb5 = new Label("Record node name"); recordNode = new TextField(); recordNode.setWidth("112px"); recordNode.setStyleName("mandatory"); HorizontalLayout recordBar = new HorizontalLayout(); recordBar.setMargin(true, false, false, false); recordBar.setSpacing(true); recordBar.addComponent(lb5); recordBar.addComponent(recordNode); vl3.addComponent(recordBar); xmlPanel.addComponent(vl3); HorizontalLayout noOfRowHl = new HorizontalLayout(); noOfRowHl.setSpacing(true); noOfRowHl.setMargin(true, false, false, true); noOfRowHl.addComponent(new Label("Number of Results")); resultNum = new TextField(); resultNum.setImmediate(true); resultNum.setNullSettingAllowed(false); resultNum.setStyleName("mandatory"); resultNum.addValidator(new IntegerValidator("Number of Results must be an Integer")); resultNum.setWidth("5em"); resultNum.setMaxLength(5); resultNum.setValue(50); noOfRowHl.addComponent(resultNum); generator.addComponent(noOfRowHl); HorizontalLayout addRowHl = new HorizontalLayout(); addRowHl.setMargin(true, false, true, true); addRowHl.setSpacing(true); addRowHl.addComponent(new Label("Add")); rowNum = new TextField(); rowNum.setImmediate(true); rowNum.setNullSettingAllowed(true); rowNum.addValidator(new IntegerValidator("Row number must be an Integer")); rowNum.setWidth("4em"); rowNum.setMaxLength(2); rowNum.setValue(1); addRowHl.addComponent(rowNum); rowsBttn = new Button("Row(s)"); rowsBttn.setIcon(DataGenConstant.ADD); rowsBttn.addListener(ClickEvent.class, this, "addRowButtonClick"); // react to clicks addRowHl.addComponent(rowsBttn); generator.addComponent(addRowHl); //Add the Grid generator.addComponent(listing); //Generate Button Button bttn = new Button("Generate"); bttn.setDescription("Generate Gata"); bttn.addListener(ClickEvent.class, this, "generateButtonClick"); // react to clicks bttn.setIcon(DataGenConstant.VIEW); bttn.setStyleName("generate"); generator.addComponent(bttn); //Generator Tab content end //Executer Tab content start - new class created to separate execution logic executor = new ExecutorView(this); //Executer Tab content end //Explorer Tab content start - new class created to separate execution logic explorer = new ExplorerView(this, databaseSessionManager); //explorer.setMargin(true); //Explorer Tab content end //About Tab content start VerticalLayout about = new VerticalLayout(); about.setMargin(true); Label aboutRichText = new Label(DataGenConstant.ABOUT_CONTENT); aboutRichText.setContentMode(Label.CONTENT_XHTML); about.addComponent(aboutRichText); //About Tab content end //Help Tab content start VerticalLayout help = new VerticalLayout(); help.setMargin(true); Label helpText = new Label(DataGenConstant.HELP_CONTENT); helpText.setContentMode(Label.CONTENT_XHTML); help.addComponent(helpText); Embedded helpScreen = new Embedded(); helpScreen.setSource(DataGenConstant.HELP_SCREEN); help.addComponent(helpScreen); Label helpStepsText = new Label(DataGenConstant.HELP_CONTENT_STEPS); helpStepsText.setContentMode(Label.CONTENT_XHTML); help.addComponent(helpStepsText); //Help Tab content end //Add the respective contents to the tab sheet tabSheet.addTab(generator, "Generator", DataGenConstant.HOME_ICON); executorTab = tabSheet.addTab(executor, "Executor", DataGenConstant.EXECUTOR_ICON); explorerTab = tabSheet.addTab(explorer, "Explorer", DataGenConstant.EXPLORER_ICON); tabSheet.addTab(about, "About", DataGenConstant.ABOUT_ICON); tabSheet.addTab(help, "Help", DataGenConstant.HELP_ICON); HorizontalLayout content = new HorizontalLayout(); content.setSizeFull(); content.addComponent(tabSheet); rootLayout.addComponent(content); rootLayout.setExpandRatio(content, 1); log.debug("DataGenApplication - buildMainLayout() end"); }
From source file:com.esspl.datagen.ui.ExecutorView.java
License:Open Source License
public ExecutorView(DataGenApplication application) { log.debug("ExecutorView - constructor start"); dataGenApplication = application;// w w w . j av a 2 s . c om 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"); }