@SuppressWarnings("serial") private void initButtonLinkCcBcc() { btnLinkCc = new Button("Add Cc"); btnLinkCc.setStyleName(UIConstants.BUTTON_LINK); inputLayout.addComponent(btnLinkCc, 1, 0); inputLayout.setComponentAlignment(btnLinkCc, Alignment.MIDDLE_CENTER); btnLinkBcc = new Button("Add Bcc"); btnLinkBcc.setStyleName(UIConstants.BUTTON_LINK); inputLayout.addComponent(btnLinkBcc, 2, 0); inputLayout.setComponentAlignment(btnLinkBcc, Alignment.MIDDLE_CENTER); btnLinkCc.addClickListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { buttonLinkCcClick(event); } }); btnLinkBcc.addClickListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { butonLinkBccClick(event); } }); }
@Override public ComponentContainer constructBody() { MHorizontalLayout layout = new MHorizontalLayout().withMargin(true); nameField = ShortcutExtension.installShortcutAction( new TextField(), new ShortcutListener("OpportunitySearchRequest", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object o, Object o1) { callSearchAction(); } }); nameField.setInputPrompt("Query by opportunity name"); nameField.setWidth(UIConstants.DEFAULT_CONTROL_WIDTH); layout.with(nameField).withAlign(nameField, Alignment.MIDDLE_CENTER); this.myItemCheckbox = new CheckBox(AppContext.getMessage(GenericI18Enum.SEARCH_MYITEMS_CHECKBOX)); layout.with(myItemCheckbox).withAlign(myItemCheckbox, Alignment.MIDDLE_CENTER); Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH)); searchBtn.setStyleName(UIConstants.BUTTON_ACTION); searchBtn.setIcon(FontAwesome.SEARCH); searchBtn.addClickListener( new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { OpportunityBasicSearchLayout.this.callSearchAction(); } }); layout.with(searchBtn).withAlign(searchBtn, Alignment.MIDDLE_LEFT); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLEAR)); cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK); cancelBtn.addClickListener( new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { OpportunityBasicSearchLayout.this.nameField.setValue(""); } }); layout.with(cancelBtn).withAlign(cancelBtn, Alignment.MIDDLE_CENTER); Button advancedSearchBtn = new Button( AppContext.getMessage(GenericI18Enum.BUTTON_ADVANCED_SEARCH), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { OpportunitySearchPanel.this.moveToAdvancedSearchLayout(); } }); advancedSearchBtn.setStyleName(UIConstants.BUTTON_LINK); layout.with(advancedSearchBtn).withAlign(advancedSearchBtn, Alignment.MIDDLE_CENTER); return layout; }
private Component createProfileEditorInvite() { VerticalLayout layout = new VerticalLayout(); layout.setSizeFull(); layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); if (!SettingsManager.get().isSettingsEditorEnabled()) { layout.addComponent( new Label("No connection profiles defined and you are not allowed to create one.")); } else { Button createProfileLink = new Button( "Create profile", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { addProfile(); } }); createProfileLink.setStyleName(ValoTheme.BUTTON_LINK); Label line1 = new Label("No connection profiles defined."); line1.setSizeUndefined(); VerticalLayout inner = new VerticalLayout(); inner.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); inner.addComponents(line1, createProfileLink); layout.addComponents(inner); } return layout; }
@Override public ComponentContainer constructBody() { MHorizontalLayout basicSearchBody = new MHorizontalLayout().withMargin(true); basicSearchBody.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); Label nameLbl = new Label("Name:"); basicSearchBody.with(nameLbl); nameField = new TextField(); nameField.setInputPrompt("Query by version name"); nameField.setWidth(UIConstants.DEFAULT_CONTROL_WIDTH); nameField.addShortcutListener( new ShortcutListener("VersionSearchName", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object o, Object o1) { callSearchAction(); } }); basicSearchBody.with(nameField); Button searchBtn = new Button( AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { callSearchAction(); } }); searchBtn.setStyleName(UIConstants.BUTTON_ACTION); searchBtn.setIcon(FontAwesome.SEARCH); basicSearchBody.with(searchBtn); Button cancelBtn = new Button( AppContext.getMessage(GenericI18Enum.BUTTON_CLEAR), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { nameField.setValue(""); } }); cancelBtn.setStyleName(UIConstants.BUTTON_OPTION); basicSearchBody.with(cancelBtn); return basicSearchBody; }
private void configureComponents() { save.setStyleName(ValoTheme.BUTTON_PRIMARY); save.setClickShortcut(ShortcutAction.KeyCode.ENTER); cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE); variantField.setNullSelectionAllowed(false); variantField.setInvalidAllowed(false); variantField.addItems(Variant.values()); nominal.setNullSelectionAllowed(true); nominal.setInvalidAllowed(false); nominal.addItems(NominalValue.values()); }
private void configureComponents() { /* * Highlight primary actions. * * With Vaadin built-in styles you can highlight the primary save button * and give it a keyboard shortcut for a better UX. */ save.setStyleName(ValoTheme.BUTTON_PRIMARY); save.setClickShortcut(ShortcutAction.KeyCode.ENTER); setVisible(false); }
protected void addNextChartButton() { nextChartButton = UIUtil.addButton(this, "", "left: 750px; top: 120px;", "250px"); nextChartButton.setStyleName(Reindeer.BUTTON_LINK); nextChartButton.addClickListener( new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { config.getLayoutContext().show(config.getNextLayout(), getParams()); } }); }
private Button buildRemoveParameterButton(final HorizontalPanel entry) { Button remButton = new Button(); remButton.setStyleName(removeParamButton.getStyleName()); remButton.setHTML(removeParamButton.getHTML()); remButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { removeParameter(entry); enableSaveButton(); } }); return remButton; }
private void addKeyRemoveButton(final String keyName, int top) { String position = String.format("left: 0px; top: %spx;", top); Button button = UIUtil.addButton(this, "[X]", position, "25px"); button.setStyleName(Reindeer.BUTTON_LINK); button.addClickListener( new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { removeKey(keyName); } }); keyRemoveButtons.add(button); }
public LoginModule() { setMargin(true); setSpacing(true); grid.setSizeFull(); grid.setSpacing(true); final TextField username = new TextField(); username.setValue("username"); username.setWidth("120px"); username.setStyleName("small"); grid.addComponent(username, 0, 0); final PasswordField password = new PasswordField(); password.setValue("password"); password.setWidth("120px"); password.setStyleName("small"); grid.addComponent(password, 0, 1); Button button = new Button("Login"); button.setWidth("120px"); button.setStyleName("small"); button.addListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { login.setUsername(username.getValue().toString()); login.setPassword(password.getValue().toString()); String user = login.getUsername(); String pass = login.getPassword(); // login.setResult(authLog.login(user, pass)); boolean result = authLog.login(user, pass); if (result == true) { label.setCaption("Successfully Login"); } else { label.setCaption("SQL Error"); } } }); grid.addComponent(button, 0, 2); panel.addComponent(grid); addComponent(panel); addComponent(label); }
@Override protected void buildExtraControls() { Button createBtn = new Button( AppContext.getMessage(BugI18nEnum.BUTTON_NEW_VERSION), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { EventBusFactory.getInstance().post(new BugVersionEvent.GotoAdd(this, null)); } }); createBtn.setEnabled( CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.VERSIONS)); createBtn.setStyleName(UIConstants.BUTTON_ACTION); createBtn.setIcon(FontAwesome.PLUS); this.addHeaderRight(createBtn); }
@Override protected void buildExtraControls() { Button createAccountBtn = new Button( AppContext.getMessage(OpportunityI18nEnum.BUTTON_NEW_OPPORTUNITY), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { EventBusFactory.getInstance() .post(new OpportunityEvent.GotoAdd(OpportunitySearchPanel.this, null)); } }); createAccountBtn.setIcon(FontAwesome.PLUS); createAccountBtn.setStyleName(UIConstants.BUTTON_ACTION); createAccountBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_OPPORTUNITY)); addHeaderRight(createAccountBtn); }
@Override public Component generateRow(final SimpleComment comment, int rowIndex) { final MHorizontalLayout layout = new MHorizontalLayout() .withMargin(new MarginInfo(true, true, true, false)) .withWidth("100%") .withStyleName("message"); UserBlock memberBlock = new UserBlock( comment.getCreateduser(), comment.getOwnerAvatarId(), comment.getOwnerFullName()); layout.addComponent(memberBlock); CssLayout rowLayout = new CssLayout(); rowLayout.setStyleName("message-container"); rowLayout.setWidth("100%"); MHorizontalLayout messageHeader = new MHorizontalLayout() .withMargin(new MarginInfo(true, true, false, true)) .withWidth("100%") .withStyleName("message-header"); messageHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); ELabel timePostLbl = new ELabel( AppContext.getMessage( GenericI18Enum.EXT_ADDED_COMMENT, comment.getOwnerFullName(), AppContext.formatPrettyTime(comment.getCreatedtime())), ContentMode.HTML) .withDescription(AppContext.formatDateTime(comment.getCreatedtime())); timePostLbl.setSizeUndefined(); timePostLbl.setStyleName("time-post"); messageHeader.with(timePostLbl).expand(timePostLbl); // Message delete button Button msgDeleteBtn = new Button(); msgDeleteBtn.setIcon(FontAwesome.TRASH_O); msgDeleteBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY); messageHeader.addComponent(msgDeleteBtn); if (hasDeletePermission(comment)) { msgDeleteBtn.setVisible(true); msgDeleteBtn.addClickListener( new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { ConfirmDialogExt.show( UI.getCurrent(), AppContext.getMessage( GenericI18Enum.DIALOG_DELETE_TITLE, AppContext.getSiteName()), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), 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()) { CommentService commentService = ApplicationContextUtil.getSpringBean(CommentService.class); commentService.removeWithSession( comment, AppContext.getUsername(), AppContext.getAccountId()); owner.removeRow(layout); } } }); } }); } else { msgDeleteBtn.setVisible(false); } rowLayout.addComponent(messageHeader); Label messageContent = new SafeHtmlLabel(comment.getComment()); messageContent.setStyleName("message-body"); rowLayout.addComponent(messageContent); List<Content> attachments = comment.getAttachments(); if (!CollectionUtils.isEmpty(attachments)) { MVerticalLayout messageFooter = new MVerticalLayout() .withSpacing(false) .withWidth("100%") .withStyleName("message-footer"); AttachmentDisplayComponent attachmentDisplay = new AttachmentDisplayComponent(attachments); attachmentDisplay.setWidth("100%"); messageFooter.with(attachmentDisplay).withAlign(attachmentDisplay, Alignment.MIDDLE_RIGHT); rowLayout.addComponent(messageFooter); } layout.with(rowLayout).expand(rowLayout); return layout; }
@Override public void displayConvertLeadInfo(final SimpleLead lead) { previewForm.removeAllComponents(); this.lead = lead; Label header = new Label("Conversion Details"); header.addStyleName("h2"); previewForm.addComponent(header); GridFormLayoutHelper layoutHelper = new GridFormLayoutHelper(1, 3); layoutHelper.getLayout().setWidth("100%"); layoutHelper.getLayout().setMargin(false); layoutHelper.getLayout().addStyleName("colored-gridlayout"); LOG.debug("Display associate account"); AccountService accountService = ApplicationContextUtil.getSpringBean(AccountService.class); final SimpleAccount account = accountService.findAccountAssoWithConvertedLead(lead.getId(), AppContext.getAccountId()); if (account != null) { Button accountLink = new Button( account.getAccountname(), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { EventBusFactory.getInstance() .post(new AccountEvent.GotoRead(this, account.getId())); } }); accountLink.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.ACCOUNT)); accountLink.setStyleName("link"); layoutHelper.addComponent(accountLink, "Account", 0, 0); } else { layoutHelper.addComponent(new Label(""), "Account", 0, 0); } LOG.debug("Display associate contact"); ContactService contactService = ApplicationContextUtil.getSpringBean(ContactService.class); final SimpleContact contact = contactService.findContactAssoWithConvertedLead(lead.getId(), AppContext.getAccountId()); if (contact != null) { Button contactLink = new Button( contact.getContactName(), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { EventBusFactory.getInstance() .post(new ContactEvent.GotoRead(this, contact.getId())); } }); contactLink.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CONTACT)); contactLink.setStyleName("link"); layoutHelper.addComponent(contactLink, "Contact", 0, 1); } else { layoutHelper.addComponent(new Label(""), "Contact", 0, 1); } LOG.debug("Display associate opportunity"); OpportunityService opportunityService = ApplicationContextUtil.getSpringBean(OpportunityService.class); final SimpleOpportunity opportunity = opportunityService.findOpportunityAssoWithConvertedLead( lead.getId(), AppContext.getAccountId()); if (opportunity != null) { Button opportunityLink = new Button( opportunity.getOpportunityname(), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { EventBusFactory.getInstance() .post(new OpportunityEvent.GotoRead(this, opportunity.getId())); } }); opportunityLink.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.OPPORTUNITY)); opportunityLink.setStyleName("link"); layoutHelper.addComponent(opportunityLink, "Opportunity", 0, 2); } else { layoutHelper.addComponent(new Label(""), "Opportunity", 0, 2); } previewForm.addComponent(layoutHelper.getLayout()); previewLayout.addBody(previewContent); this.addComponent(previewItemContainer); }
@SuppressWarnings("serial") @Override 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.with(previewImage).withAlign(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.BUTTON_ACTION); 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); }
public TaskDashboardViewImpl() { this.withMargin(new MarginInfo(false, true, true, true)); taskSearchPanel = new TaskSearchPanel(); MHorizontalLayout groupWrapLayout = new MHorizontalLayout(); groupWrapLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); groupWrapLayout.addComponent(new Label("Filter:")); final TaskSavedFilterComboBox savedFilterComboBox = new TaskSavedFilterComboBox(); savedFilterComboBox.addQuerySelectListener( new SavedFilterComboBox.QuerySelectListener() { @Override public void querySelect(SavedFilterComboBox.QuerySelectEvent querySelectEvent) { List<SearchFieldInfo> fieldInfos = querySelectEvent.getSearchFieldInfos(); TaskSearchCriteria criteria = SearchFieldInfo.buildSearchCriteria(TaskSearchCriteria.class, fieldInfos); criteria.setProjectid(new NumberSearchField(CurrentProjectVariables.getProjectId())); EventBusFactory.getInstance() .post(new TaskEvent.SearchRequest(TaskDashboardViewImpl.this, criteria)); } }); groupWrapLayout.addComponent(savedFilterComboBox); groupWrapLayout.addComponent(new Label("Sort:")); final ComboBox sortCombo = new ValueComboBox(false, DESCENDING, ASCENDING); sortCombo.setWidth("100px"); sortCombo.addValueChangeListener( new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { String sortValue = (String) sortCombo.getValue(); if (ASCENDING.equals(sortValue)) { sortDirection = SearchCriteria.ASC; } else { sortDirection = SearchCriteria.DESC; } queryAndDisplayTasks(); } }); sortDirection = SearchCriteria.DESC; groupWrapLayout.addComponent(sortCombo); groupWrapLayout.addComponent(new Label("Group by:")); final ComboBox groupCombo = new ValueComboBox(false, GROUP_DUE_DATE, GROUP_START_DATE, PLAIN_LIST); groupCombo.setWidth("100px"); groupCombo.addValueChangeListener( new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { groupByState = (String) groupCombo.getValue(); queryAndDisplayTasks(); } }); groupByState = GROUP_DUE_DATE; groupWrapLayout.addComponent(groupCombo); taskSearchPanel.addHeaderRight(groupWrapLayout); Button exportBtn = new Button("Export"); final SplitButton exportSplitBtn = new SplitButton(exportBtn); exportBtn.addClickListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { exportSplitBtn.setPopupVisible(true); } }); exportSplitBtn.addStyleName(UIConstants.THEME_GREEN_LINK); OptionPopupContent popupButtonsControl = new OptionPopupContent(); Button exportPdfBtn = new Button("PDF"); exportPdfBtn.setIcon(FontAwesome.FILE_PDF_O); FileDownloader pdfFileDownloder = new FileDownloader(buildStreamSource(ReportExportType.PDF)); pdfFileDownloder.extend(exportPdfBtn); popupButtonsControl.addOption(exportPdfBtn); Button exportExcelBtn = new Button("Excel"); exportExcelBtn.setIcon(FontAwesome.FILE_EXCEL_O); FileDownloader excelFileDownloader = new FileDownloader(buildStreamSource(ReportExportType.EXCEL)); excelFileDownloader.extend(exportExcelBtn); popupButtonsControl.addOption(exportExcelBtn); exportSplitBtn.setContent(popupButtonsControl); groupWrapLayout.with(exportSplitBtn); Button newTaskBtn = new Button( AppContext.getMessage(TaskI18nEnum.BUTTON_NEW_TASK), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { SimpleTask newTask = new SimpleTask(); newTask.setProjectid(CurrentProjectVariables.getProjectId()); UI.getCurrent().addWindow(new TaskAddWindow(newTask)); } }); newTaskBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); newTaskBtn.setIcon(FontAwesome.PLUS); newTaskBtn.setDescription(AppContext.getMessage(TaskI18nEnum.BUTTON_NEW_TASKGROUP)); newTaskBtn.setStyleName(UIConstants.THEME_GREEN_LINK); groupWrapLayout.addComponent(newTaskBtn); Button advanceDisplayBtn = new Button(); advanceDisplayBtn.setWidth("50px"); advanceDisplayBtn.setIcon(FontAwesome.SITEMAP); advanceDisplayBtn.setDescription( AppContext.getMessage(TaskGroupI18nEnum.ADVANCED_VIEW_TOOLTIP)); Button calendarBtn = new Button( null, new Button.ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { EventBusFactory.getInstance() .post(new TaskEvent.GotoCalendarView(TaskDashboardViewImpl.this)); } }); calendarBtn.setWidth("50px"); calendarBtn.setDescription("Calendar View"); calendarBtn.setIcon(FontAwesome.CALENDAR); Button chartDisplayBtn = new Button( null, new Button.ClickListener() { private static final long serialVersionUID = -5707546605789537298L; @Override public void buttonClick(ClickEvent event) { displayGanttChartView(); } }); chartDisplayBtn.setWidth("50px"); chartDisplayBtn.setDescription("Display Gantt chart"); chartDisplayBtn.setIcon(FontAwesome.BAR_CHART_O); Button kanbanBtn = new Button( null, new Button.ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { displayKanbanView(); } }); kanbanBtn.setWidth("50px"); kanbanBtn.setDescription("Kanban View"); kanbanBtn.setIcon(FontAwesome.TH); ToggleButtonGroup viewButtons = new ToggleButtonGroup(); viewButtons.addButton(advanceDisplayBtn); viewButtons.addButton(calendarBtn); viewButtons.addButton(kanbanBtn); viewButtons.addButton(chartDisplayBtn); viewButtons.setDefaultButton(advanceDisplayBtn); groupWrapLayout.addComponent(viewButtons); mainLayout = new MHorizontalLayout().withFullHeight().withFullWidth(); wrapBody = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, false)); rightColumn = new MVerticalLayout() .withWidth("350px") .withMargin(new MarginInfo(true, false, false, false)); mainLayout.with(wrapBody, rightColumn).expand(wrapBody); }
/** @param el */ public BookImage(Books el, String user) { super(); this.Book = el; this.setStyleName("cells"); this.setHeight("250px"); this.setWidth("200px"); rating.setAnimated(true); rating.setCaption(null); rating.setMaxValue(5); rating.setStyleName("rating"); rating.setReadOnly(true); rating_my.setAnimated(true); rating_my.setCaption(null); rating_my.setMaxValue(5); rating_my.setStyleName("rating_my"); IRaitingService iRaitingService = new IRaitingService(); try { double rate = iRaitingService.getRaiting(el.getId()); rating.setReadOnly(false); rating.setValue(rate); rating.setReadOnly(true); double myrate = iRaitingService.getRaiting(user, el.getId()); rating_my.setValue(myrate); } catch (SQLException e) { e.printStackTrace(); } rating_my.addValueChangeListener( e -> { try { Rating rat = iRaitingService.getUser( getUI().getSession().getAttribute("user").toString(), el.getId()); rat.setRaiting(rating_my.getValue()); iRaitingService.update(rat); double rate = iRaitingService.getRaiting(el.getId()); rating.setReadOnly(false); rating.setValue(rate); rating.setReadOnly(true); new Notification(String.valueOf(rate), Notification.Type.TRAY_NOTIFICATION) .show(Page.getCurrent()); } catch (SQLException e1) { e1.printStackTrace(); } }); rating_layout.addComponent(rating); rating_layout.addComponent(rating_my); rating_layout.setComponentAlignment(rating, Alignment.MIDDLE_LEFT); rating_layout.setComponentAlignment(rating_my, Alignment.MIDDLE_LEFT); rating_layout.setStyleName("ratinglayout"); imageEmbedded.setSource(new FileResource(new File(Book.getImage()))); title.setValue(Book.getTitle()); author.setValue(Book.getAuthor()); if (Book.getFile().isEmpty()) buttonDownload.setEnabled(false); buttonDownload.setWidth("80%"); imageEmbedded.setWidth("100%"); imageEmbedded.setHeight("100%"); title.setWidth(null); author.setWidth(null); VerticalLayout bodyLayout = new VerticalLayout(title, author, imageEmbedded); bodyLayout.setExpandRatio(title, 12); bodyLayout.setExpandRatio(author, 8); bodyLayout.setExpandRatio(imageEmbedded, 80); bodyLayout.setSizeFull(); bodyLayout.setComponentAlignment(title, Alignment.MIDDLE_CENTER); bodyLayout.setComponentAlignment(author, Alignment.MIDDLE_CENTER); bodyLayout.setComponentAlignment(imageEmbedded, Alignment.MIDDLE_CENTER); buttonDownload.setStyleName("super-button"); title.setStyleName("name-label"); author.setStyleName("author-label"); this.addComponent(rating_layout); this.addComponent(bodyLayout); this.addComponent(buttonDownload); this.setComponentAlignment(rating_layout, Alignment.TOP_CENTER); this.setComponentAlignment(bodyLayout, Alignment.TOP_CENTER); this.setComponentAlignment(buttonDownload, Alignment.BOTTOM_CENTER); this.setExpandRatio(rating_layout, 5); this.setExpandRatio(bodyLayout, 85); this.setExpandRatio(buttonDownload, 10); StreamResource sr = getStream(); FileDownloader fileDownloader = new FileDownloader(sr); fileDownloader.extend(buttonDownload); bodyLayout.addLayoutClickListener( e -> { BookWin win = new BookWin(this.Book); UI.getCurrent().addWindow(win); }); }
private void initUI() { GridLayout mainLayout = new GridLayout(1, 5); mainLayout.setWidth("100%"); mainLayout.setMargin(true); mainLayout.setSpacing(true); CssLayout inputPanel = new CssLayout(); inputPanel.setWidth("100%"); inputPanel.setStyleName("mail-panel"); inputLayout = new GridLayout(3, 4); inputLayout.setSpacing(true); inputLayout.setWidth("100%"); inputLayout.setColumnExpandRatio(0, 1.0f); inputPanel.addComponent(inputLayout); mainLayout.addComponent(inputPanel); tokenFieldMailTo = new EmailTokenField(); inputLayout.addComponent(createTextFieldMail("To:", tokenFieldMailTo), 0, 0); if (lstMail != null) { for (String mail : lstMail) { if (StringUtils.isNotBlank(mail)) { if (mail.indexOf("<") > -1) { String strMail = mail.substring(mail.indexOf("<") + 1, mail.lastIndexOf(">")); if (strMail != null && !strMail.equalsIgnoreCase("null")) {} } else { } } } } final TextField subject = new TextField(); subject.setRequired(true); subject.setWidth("100%"); subjectField = createTextFieldMail("Subject:", subject); inputLayout.addComponent(subjectField, 0, 1); initButtonLinkCcBcc(); ccField = createTextFieldMail("Cc:", tokenFieldMailCc); bccField = createTextFieldMail("Bcc:", tokenFieldMailBcc); final RichTextArea noteArea = new RichTextArea(); noteArea.setWidth("100%"); noteArea.setHeight("200px"); mainLayout.addComponent(noteArea, 0, 1); mainLayout.setComponentAlignment(noteArea, Alignment.MIDDLE_CENTER); HorizontalLayout controlsLayout = new HorizontalLayout(); controlsLayout.setWidth("100%"); final AttachmentPanel attachments = new AttachmentPanel(); attachments.setWidth("500px"); MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments); uploadExt.addComponent(attachments); controlsLayout.addComponent(uploadExt); controlsLayout.setExpandRatio(uploadExt, 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) { MailFormWindow.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) { if (tokenFieldMailTo.getListRecipient().size() <= 0 || subject.getValue().equals("")) { NotificationUtil.showErrorNotification( "To Email field and Subject field must be not empty! Please fulfil them before sending email."); return; } if (AppContext.getUser().getEmail() != null && AppContext.getUser().getEmail().length() > 0) { ExtMailService systemMailService = ApplicationContextUtil.getSpringBean(ExtMailService.class); List<File> listFile = attachments.files(); List<EmailAttachementSource> emailAttachmentSource = null; if (listFile != null && listFile.size() > 0) { emailAttachmentSource = new ArrayList<>(); for (File file : listFile) { emailAttachmentSource.add(new FileEmailAttachmentSource(file)); } } systemMailService.sendHTMLMail( AppContext.getUser().getEmail(), AppContext.getUser().getDisplayName(), tokenFieldMailTo.getListRecipient(), tokenFieldMailCc.getListRecipient(), tokenFieldMailBcc.getListRecipient(), subject.getValue().toString(), noteArea.getValue().toString(), emailAttachmentSource); MailFormWindow.this.close(); } else { NotificationUtil.showErrorNotification( "Your email is empty value, please fulfil it before sending email!"); } } }); sendBtn.setIcon(FontAwesome.SEND); sendBtn.setStyleName(UIConstants.BUTTON_ACTION); controlsLayout.addComponent(sendBtn); controlsLayout.setComponentAlignment(sendBtn, Alignment.MIDDLE_RIGHT); mainLayout.addComponent(controlsLayout, 0, 2); this.setContent(mainLayout); }
private void constructHeader() { CssLayout headerWrapper = new CssLayout(); headerWrapper.setWidth("100%"); headerWrapper.addStyleName("taskgroup-header"); MHorizontalLayout header = new MHorizontalLayout().withWidth("100%"); Label headerLbl = new Label("All Tasks"); headerLbl.setStyleName("h2"); header.with(headerLbl).withAlign(headerLbl, Alignment.MIDDLE_LEFT).expand(headerLbl); Button backToListBtn = new Button( "Back to dashboard", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { EventBusFactory.getInstance() .post(new TaskListEvent.GotoTaskListScreen(this, null)); } }); backToListBtn.setStyleName(UIConstants.THEME_GREEN_LINK); header.addComponent(backToListBtn); header.setComponentAlignment(backToListBtn, Alignment.MIDDLE_RIGHT); Button saveOrderBtn = new Button( AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { EventBusFactory.getInstance() .post(new TaskListEvent.SaveReoderTaskList(event, changeSet)); } }); saveOrderBtn.setStyleName(UIConstants.THEME_GREEN_LINK); saveOrderBtn.setIcon(FontAwesome.SAVE); header.with(saveOrderBtn).withAlign(saveOrderBtn, Alignment.MIDDLE_RIGHT); headerWrapper.addComponent(header); this.addComponent(headerWrapper); final DDVerticalLayout ddLayout = new DDVerticalLayout(); ddLayout.addStyleName("taskgroup-reorder"); ddLayout.setComponentVerticalDropRatio(0.3f); ddLayout.setDragMode(LayoutDragMode.CLONE); ddLayout.setDropHandler( new DropHandler() { private static final long serialVersionUID = 1L; @Override public AcceptCriterion getAcceptCriterion() { return new Not(VerticalLocationIs.MIDDLE); } @Override public void drop(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable(); DDVerticalLayout.VerticalLayoutTargetDetails details = (DDVerticalLayout.VerticalLayoutTargetDetails) event.getTargetDetails(); TaskListComponent comp = (TaskListComponent) transferable.getComponent(); int currentIndex = ddLayout.getComponentIndex(comp); int newIndex = details.getOverIndex(); ddLayout.removeComponent(comp); if (currentIndex > newIndex && details.getDropLocation() == VerticalDropLocation.BOTTOM) { newIndex++; } SimpleTaskList dropTaskList = comp.getTaskList(); dropTaskList.setGroupindex(newIndex); changeSet.add(dropTaskList); ddLayout.addComponent(comp, newIndex); // change affected task list items for (int i = 0; i < ddLayout.getComponentCount(); i++) { TaskListComponent affectedComp = (TaskListComponent) ddLayout.getComponent(i); SimpleTaskList affectedTaskList = affectedComp.getTaskList(); affectedTaskList.setGroupindex(i); changeSet.add(affectedTaskList); } } }); taskLists = new BeanList<>( null, ApplicationContextUtil.getSpringBean(ProjectTaskListService.class), TaskListRowDisplayHandler.class, ddLayout); this.addComponent(taskLists); }
@Override public ComponentContainer getLayout() { final VerticalLayout layout = new VerticalLayout(); this.informationLayout = GridFormLayoutHelper.defaultFormLayoutHelper(2, 6); layout.addComponent(this.informationLayout.getLayout()); final MHorizontalLayout controlsBtn = new MHorizontalLayout().withMargin(new MarginInfo(true, true, true, false)); layout.addComponent(controlsBtn); final Button approveBtn = new Button( "Approve & Close", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { if (EditForm.this.validateForm()) { // Save bug status and assignee bug.setStatus(BugStatus.Verified.name()); BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class); bugService.updateSelectiveWithSession(bug, AppContext.getUsername()); // Save comment String commentValue = commentArea.getValue(); if (StringUtils.isNotBlank(commentValue)) { CommentWithBLOBs comment = new CommentWithBLOBs(); comment.setComment( Jsoup.clean(commentArea.getValue(), Whitelist.relaxed())); comment.setCreatedtime(new GregorianCalendar().getTime()); comment.setCreateduser(AppContext.getUsername()); comment.setSaccountid(AppContext.getAccountId()); comment.setType(ProjectTypeConstants.BUG); comment.setTypeid("" + bug.getId()); comment.setExtratypeid(CurrentProjectVariables.getProjectId()); CommentService commentService = ApplicationContextUtil.getSpringBean(CommentService.class); commentService.saveWithSession(comment, AppContext.getUsername()); } ApproveInputWindow.this.close(); callbackForm.refreshBugItem(); } } }); approveBtn.setStyleName(UIConstants.THEME_GREEN_LINK); approveBtn.setClickShortcut(ShortcutAction.KeyCode.ENTER); controlsBtn.with(approveBtn).withAlign(approveBtn, Alignment.MIDDLE_LEFT); Button cancelBtn = new Button( AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { ApproveInputWindow.this.close(); } }); cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK); controlsBtn.with(cancelBtn).withAlign(cancelBtn, Alignment.MIDDLE_LEFT); layout.setComponentAlignment(controlsBtn, Alignment.MIDDLE_RIGHT); return layout; }