List of usage examples for com.vaadin.ui CssLayout CssLayout
public CssLayout()
From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ProjectMailingListBox.java
License:Open Source License
@SuppressWarnings("nls") @Override// w ww. j a v a 2 s . c om public Component getContent(Project project, ExtensionUtil util) { Layout layout = new CssLayout(); layout.addStyleName(STYLE_MAILING_INFOBOX); layout.setSizeFull(); HtmlBuilder html = new HtmlBuilder(); InfoExtension ext = project.getExtension(InfoExtension.class); if (ext != null) { Set<String> mailingLists = ext.getMailingLists(); if (mailingLists.size() > 0) { MailingListMapper mapper = new MailingListMapper(LinkMapper.ALL_PURPOSES); html.append("<ul>"); //$NON-NLS-1$ for (String mailingList : ext.getMailingLists()) { html.append("<li>"); html.appendMailToLink(mailingList); List<Link> mappedLinks = mapper.getMappedLinks(mailingList, util.getLoggedInUserId(), project, configService); if (!mappedLinks.isEmpty()) { html.appendLineBreak(); html.appendLinks(mappedLinks); } html.append("</li>"); } html.append("</ul>"); } } if (html.length() > 0) { createLabel(layout, html.toString()); } else { createLabel(layout, "This project has no mailing lists."); //$NON-NLS-1$ } return layout; }
From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ProjectMavenBox.java
License:Open Source License
@Override public Component getContent(Project project, ExtensionUtil util) { Layout layout = new CssLayout(); layout.addStyleName(STYLE_MAVEN_INFOBOX); layout.setSizeFull();/*from ww w.ja v a 2 s. c o m*/ boolean rendered = false; String groupId = null; MavenReactorProjectExt reactorExt = project.getExtension(MavenReactorProjectExt.class); if (reactorExt != null) { MavenReactor mavenReactor = reactorExt.getMavenReactor(); if (mavenReactor != null) { MavenCoordinate coordinate = mavenReactor.getCoordinate(); groupId = coordinate.getGroupId(); createLabel(layout, "GroupId: <b>" + groupId + "</b>");//$NON-NLS-1$ //$NON-NLS-2$ createLabel(layout, "ArtifactId: <b>" + coordinate.getArtefactId() + "</b>");//$NON-NLS-1$ //$NON-NLS-2$ TreeSet<MavenModule> modules = mavenReactor.getModules(); StringBuilder sb = new StringBuilder(); if (modules.size() > 0) { int lineLength = 0; for (MavenModule module : modules) { //create popup with xml snippet sb.append("<dependency>\n"); sb.append(" <artifactId>" + module.getArtefactId() + "</artifactId>\n"); sb.append(" <groupId>" + module.getGroupId() + "</groupId>\n"); String latestVersion = module.getLatestVersion(); if (StringUtils.isNotBlank(latestVersion)) { sb.append(" <version>" + latestVersion + "</version>\n"); } else { sb.append(" <!--<version>0.0.0</version>-->\n"); } String packaging = module.getPackaging(); if (StringUtils.isNotBlank(packaging)) { sb.append(" <type>" + packaging + "</type>\n"); } sb.append("</dependency>\n"); lineLength = calculateLineLength(module, lineLength); } final Label label = new Label(sb.toString(), Label.CONTENT_PREFORMATTED); //add a buffer 10, as we didn't calculate the length of surrounding strings. label.setWidth(lineLength + 10, Sizeable.UNITS_EM); PopupView.Content content = new PopupView.Content() { private static final long serialVersionUID = -8362267064485433525L; @Override public String getMinimizedValueAsHTML() { return "Modules"; } @Override public Component getPopupComponent() { return label; } }; PopupView popup = new PopupView(content); popup.setHideOnMouseOut(false); popup.addStyleName(STYLE_MODULE_POPUP); layout.addComponent(popup); } rendered = true; } } MavenProjectExt mavenExt = project.getExtension(MavenProjectExt.class); if (mavenExt != null) { if (groupId == null) { groupId = mavenExt.getGroupID(); if (StringUtils.isNotBlank(groupId)) { createLabel(layout, "GroupId: <b> " + groupId + "</b>");//$NON-NLS-1$ //$NON-NLS-2$ rendered = true; } } DevInfProjectExt devInf = project.getExtension(DevInfProjectExt.class); if (devInf != null) { String reactorPomUrl = getReactorPomUrl(project, devInf, mavenExt); if (reactorPomUrl == null) { String reactorPomPath = mavenExt.getReactorPOM(); String caption = MessageFormat.format("Reactor POM Path: {0} (relative to SCM root location)", StringUtils.isNotBlank(reactorPomPath) ? reactorPomPath : "/"); createLabel(layout, caption); } else { createLink(layout, "Reactor POM", reactorPomUrl); } rendered = true; } if (StringUtils.isNotBlank(mavenExt.getSiteUrl())) { createLink(layout, "Project Site", mavenExt.getSiteUrl()); rendered = true; } } if (!rendered) { createLabel(layout, "Maven extension added but no data maintained."); } return layout; }
From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ProjectReviewBox.java
License:Open Source License
@Override public Component getContent(Project project, ExtensionUtil util) { CssLayout layout = new CssLayout() { @Override//from w ww . java2s . com protected String getCss(Component c) { return "padding-left: 3px;"; } }; layout.setMargin(false); layout.setSizeFull(); ReviewProjectExt ext = project.getExtension(ReviewProjectExt.class); if (ext != null) { ReviewComponent reviewComponent = new ReviewComponent(project, DEFAULT_PAGE_LENGH, MAX_PAGE_LENGH, util); layout.addComponent(reviewComponent); } return layout; }
From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ProjectScrumBox.java
License:Open Source License
@Override public Component getContent(Project project, ExtensionUtil util) { Layout layout = new CssLayout(); layout.addStyleName(STYLE_SCRUM_INFOBOX); layout.setSizeFull();/*from w ww . jav a 2 s. c om*/ boolean rendered = false; ScrumProjectExt scrumExt = project.getExtension(ScrumProjectExt.class); if (scrumExt != null) { if (CollectionUtils.isNotBlank(scrumExt.getProductOwners())) { createLabel(layout, "Product Owner", STYLE_TEAMLABEL); Component peopleComponent = PeopleComponent .getPeopleListComponentForMember(scrumExt.getProductOwners()); layout.addComponent(peopleComponent); rendered = true; } if (CollectionUtils.isNotBlank(scrumExt.getScrumMasters())) { createLabel(layout, "Scrum Master", STYLE_TEAMLABEL); Component peopleComponent = PeopleComponent .getPeopleListComponentForMember(scrumExt.getScrumMasters()); layout.addComponent(peopleComponent); rendered = true; } if (StringUtils.isNotBlank(scrumExt.getBacklogUrl())) { createLink(layout, "Scrum Backlog", scrumExt.getBacklogUrl(), DEFAULT_TARGET, STYLE_SCRUM_LOG); rendered = true; } } if (!rendered) { createLabel(layout, "SCRUM extension added but no data maintained.", STYLE_LABEL); } return layout; }
From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ProjectTeamBox.java
License:Open Source License
@Override public Component getContent(Project project, ExtensionUtil util) { Layout layout = new CssLayout(); layout.addStyleName(STYLE_TEAM_INFOBOX); layout.setSizeFull();/*from w w w . j a v a 2 s.c o m*/ PeopleExtension ext = project.getExtension(PeopleExtension.class); if (ext != null) { if (ext.getLeads().size() > 0) { Label projectLeadHeaderLabel = new Label("Project Lead"); projectLeadHeaderLabel.addStyleName(STYLE_TEAMLABEL); layout.addComponent(projectLeadHeaderLabel); Component peopleComponent = PeopleComponent.getPeopleListComponentForMember(ext.getLeads()); peopleComponent.addStyleName(InformationBox.STYLE); layout.addComponent(peopleComponent); } if (ext.getMembers().size() > 0) { Label projectTeamHeaderLabel = new Label("Project Team/Committers"); projectTeamHeaderLabel.addStyleName(STYLE_TEAMLABEL); layout.addComponent(projectTeamHeaderLabel); Component peopleComponent = PeopleComponent.getPeopleListComponentForMember(ext.getMembers()); peopleComponent.addStyleName(InformationBox.STYLE); layout.addComponent(peopleComponent); } String mailToTeamHtml = new MailToTeam(ext).composeMailToTeamLabel(); createLabel(layout, mailToTeamHtml); } return layout; }
From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.RelatedProjectsInfoBox.java
License:Open Source License
@Override public Component getContent(Project project, ExtensionUtil util) { Layout layout = new CssLayout(); layout.addStyleName(STYLE_RELATEDPROJECTS_INFOBOX); layout.setSizeFull();//from w w w . j a va2s .c om RelatedProjectsExt ext = project.getExtension(RelatedProjectsExt.class); if (ext != null) { createLabel(layout, "The following projects might also be of interest to you:"); boolean calculated = ext.getCalculated(); if (calculated) { addCalculatedContent(project, layout); } else { UUIDList ids = ext.getRelatedProjects(); ProjectService projectService = ((ProjectService) EntityServices.getByEntityClass(Project.class)); for (UUID uuid : ids) { Project relatedProject = projectService.getByUUID(uuid); if (relatedProject != null) { //project might have deleted meanwhile ExternalResource externalResource = new ExternalResource( "/projects/" + relatedProject.getProjectId()); String content = HSPACE + "<a href=\"" + externalResource.getURL() + "\">" + relatedProject.getName() + "</a>"; createLabel(layout, content); } } } } return layout; }
From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ReviewComponent.java
License:Open Source License
@SuppressWarnings("serial") public ReviewComponent(Project project, int defaultPageLength, int maxPageLength, ExtensionUtil util) { this.project = project; this.defaultPageLength = defaultPageLength; this.maxPageLength = maxPageLength; this.util = util; extension = project.getExtension(ReviewProjectExt.class); if (extension == null) { extension = new ReviewProjectExt(); extension.setExtensibleEntity(project); project.addExtension(extension); }/*from w w w. j a va 2 s . c o m*/ reviews = extension.getReviews(); ratingStyle = extension.getRatingStyle(); showAll = false; size = reviews.size(); currentPage = 0; currentPageLength = defaultPageLength; lastPage = size / maxPageLength; layout = new CssLayout() { @Override protected String getCss(Component c) { if (c instanceof Button) { return "padding-top:3px;padding-right:15px"; //$NON-NLS-1$ } if (c instanceof Label) { return "padding-bottom:10px"; //$NON-NLS-1$ } return "padding-top:3px"; //$NON-NLS-1$ } }; layout.setSizeFull(); paintReviewButtons(); paintReviewList(); setCompositionRoot(layout); }
From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ReviewComponent.java
License:Open Source License
private void paintReviewGrid() { if (reviewGrid == null) { reviewGrid = new GridLayout(2, currentPageLength); reviewGrid.setSizeFull();/*from w ww. ja v a 2s . c om*/ reviewGrid.setSpacing(true); layout.addComponent(reviewGrid); } else { reviewGrid.removeAllComponents(); } int rows = reviewGrid.getRows(); if (rows != currentPageLength) { reviewGrid.setRows(Math.min(size, currentPageLength)); } int row = 0; List<ReviewEntry> latestReviews = getLatestReviews(currentPage, currentPageLength); for (ReviewEntry review : latestReviews) { ProjectRating rating = review.getRating(); Embedded e = new Embedded(null, getIcon(rating)); e.setDescription(getDescription(rating)); e.setWidth("22px"); //$NON-NLS-1$ e.setHeight("22px"); //$NON-NLS-1$ reviewGrid.addComponent(e, 0, row); StringBuilder sb = new StringBuilder(); sb.append("<span style=\"white-space:normal\">"); //$NON-NLS-1$ sb.append(HtmlUtils.clean(review.getComment())); sb.append("<br>"); //$NON-NLS-1$ sb.append("<span style=\"font-size:x-small\">").append(" posted by "); //$NON-NLS-1$ sb.append(StringEscapeUtils.escapeHtml(review.getVoter())); sb.append(" "); //$NON-NLS-1$ long deltaMillis = System.currentTimeMillis() - review.getTimestamp(); long deltaDays = deltaMillis / MILLIS_PER_DAY; if (deltaDays > 0) { sb.append(deltaDays); sb.append(" days ago"); } else { long deltaHours = deltaMillis / MILLIS_PER_HOUR; if (deltaHours > 0) { sb.append(deltaHours).append(" hours ago"); } else { long deltaMinutes = deltaMillis / MILLIS_PER_MINUTE; if (deltaMinutes > 0) { sb.append(deltaMinutes).append(" minutes ago"); } else { sb.append(" just now"); } } sb.append("</span></span>"); //$NON-NLS-1$ } CssLayout css = new CssLayout(); css.setSizeFull(); Label comment = new Label(sb.toString(), Label.CONTENT_XHTML); comment.setSizeUndefined(); css.addComponent(comment); reviewGrid.addComponent(css, 1, row); reviewGrid.setColumnExpandRatio(1, 1.0f); ++row; } }
From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ReviewComponent.java
License:Open Source License
@SuppressWarnings("serial") private void paintReviewButtons() { reviewButtons = new CssLayout() { @Override/*from w w w. j a v a 2 s.c o m*/ protected String getCss(Component c) { if (c instanceof HorizontalLayout) { return "padding-left: 15px; padding-top: 10px;"; //$NON-NLS-1$ } else { return StringUtils.EMPTY; } } }; reviewButtons.setWidth("300px"); //$NON-NLS-1$ reviewButtons.setHeight(getReviewButtonsHeight()); Label label = new Label("<b>" + getRatingQuestion() + "</b>", Label.CONTENT_XHTML); //$NON-NLS-1$ //$NON-NLS-2$ reviewButtons.addComponent(label); HorizontalLayout hl = new HorizontalLayout(); hl.setSizeUndefined(); final String separatorLabelCaption = "<b>" + HSPACE + "or" + HSPACE + "</b>"; //$NON-NLS-1$ //$NON-NLS-3$ ProjectRating[] ratings = ProjectRating.getRatings(ratingStyle); int i = 0; for (ProjectRating rating : ratings) { if (i > 0) { Label separatorLabel = new Label(separatorLabelCaption, Label.CONTENT_XHTML); hl.addComponent(separatorLabel); hl.setComponentAlignment(separatorLabel, Alignment.MIDDLE_LEFT); } paintReviewButton(hl, rating); ++i; } reviewButtons.addComponent(hl); layout.addComponent(reviewButtons); }
From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ReviewComponent.java
License:Open Source License
@SuppressWarnings("serial") private Window createReviewWindow(final ProjectRating rating) { final Window subwindow = new Window("Rate and Review"); subwindow.setModal(true);//from ww w. j ava2 s .c o m subwindow.setWidth("420px"); //$NON-NLS-1$ subwindow.setHeight("320px"); //$NON-NLS-1$ VerticalLayout vl = (VerticalLayout) subwindow.getContent(); vl.setSpacing(true); vl.setSizeFull(); HorizontalLayout hl = new HorizontalLayout(); hl.setSizeUndefined(); Embedded icon = new Embedded(null, getIcon(rating)); Label iconLabel = new Label("<b>" + HSPACE + getReviewComment(rating) + "</b>", Label.CONTENT_XHTML); //$NON-NLS-1$ //$NON-NLS-2$ String captionTextField = getReviewCommentQuestion(rating); hl.addComponent(icon); hl.addComponent(iconLabel); hl.setComponentAlignment(iconLabel, Alignment.MIDDLE_LEFT); vl.addComponent(hl); final TextField editor = new TextField(captionTextField); editor.setRows(3); editor.setColumns(30); editor.setImmediate(true); vl.addComponent(editor); final User user = util.getLoggedInUser(); final ArrayList<String> userSelects = new ArrayList<String>(2); userSelects.add("I want to vote as " + user.getDisplayName()); if (extension.getAllowAnonymous()) { userSelects.add("I want to vote as Anonymous!"); } final OptionGroup userSelect = new OptionGroup(null, userSelects); userSelect.setNullSelectionAllowed(false); userSelect.select(userSelects.get(0)); vl.addComponent(userSelect); CssLayout css = new CssLayout() { @Override protected String getCss(Component c) { return "margin-left:5px;margin-right:5px;margin-top:10px"; //$NON-NLS-1$ } }; Button okButton = new Button("OK"); okButton.setIcon(ICON_BUTTON_OK); okButton.setDescription("Commit changes"); okButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { String comment = (String) editor.getValue(); if (StringUtils.isBlank(comment)) { comment = "No Comment"; } ((Window) subwindow.getParent()).removeWindow(subwindow); String userName = "Anonymous"; if (userSelects.get(0).equals(userSelect.getValue())) { userName = user.getDisplayName(); } ReviewEntry review = new ReviewEntry(rating, comment, userName, System.currentTimeMillis()); extension.addReview(review); util.persist(project); reviews = extension.getReviews(); size = reviews.size(); currentPage = 0; lastPage = size / currentPageLength; paintReviewList(); } }); css.addComponent(okButton); Button cancelButton = new Button("Cancel"); cancelButton.setIcon(ICON_BUTTON_CANCEL); cancelButton.setDescription("Discard changes"); cancelButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { ((Window) subwindow.getParent()).removeWindow(subwindow); } }); css.addComponent(cancelButton); vl.addComponent(css); vl.setComponentAlignment(css, Alignment.MIDDLE_CENTER); return subwindow; }