Example usage for com.vaadin.ui Layout addComponent

List of usage examples for com.vaadin.ui Layout addComponent

Introduction

In this page you can find the example usage for com.vaadin.ui Layout addComponent.

Prototype

public void addComponent(Component c);

Source Link

Document

Adds the component into this container.

Usage

From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.FeedInfoBox.java

License:Open Source License

@SuppressWarnings({ "deprecation", "serial" })
private void addMoreButton(final Layout layout, final Project project, final String userId,
        final HashMap<String, SourceDetails> sourceFilter) {
    final Button moreButton = new Button("more ...");
    moreButton.setStyle(Button.STYLE_LINK);
    moreButton.addListener(new Button.ClickListener() {
        @Override//from  ww w  . ja v a  2  s . c  om
        public void buttonClick(ClickEvent event) {
            maxFeedEntries = maxFeedEntries + 30;
            renderContentPanel(layout, project, userId, sourceFilter);
        }
    });
    layout.addComponent(moreButton);
}

From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ProjectActivityBox.java

License:Open Source License

@Override
public Component getContent(Project project, ExtensionUtil util) {
    Layout layout = new CssLayout();
    layout.addStyleName(STYLE_ACTIVITY_INFOBOX);
    layout.setSizeFull();//from   ww w  .j  a  va 2 s  .  c  o  m

    Label label;
    label = new Label("Latest commit activity (click for details):");
    layout.addComponent(label);
    layout.addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));

    Link imgLink = getActivityGraphicUrl(project, util.getLoggedInUserId());
    Link detailsLink = getActivityDetailsUrl(project, util.getLoggedInUserId());

    Label activityArea = new Label();
    activityArea.setContentMode(Label.CONTENT_XHTML);
    if (imgLink != null) {
        String imgTag = "<img src=\"" + imgLink.getUrl() + "\" " + "title=\"" + imgLink.getLabel() + "\" "
                + "onerror=\"document.getElementById('activityBoxError').style.visibility='visible';"
                + "document.getElementById('activityBoxImage').style.visibility='hidden';\" " + ">";

        String content;
        if (detailsLink != null) {
            content = "<a href=\"" + detailsLink.getUrl() + "\" target=\"_new\">" + imgTag + "</a>";
        } else {
            content = imgTag;
        }
        activityArea.setValue("<span id=\"activityBoxImage\">" + content + "</span>");
        layout.addComponent(activityArea);

        Label errorArea = new Label("<span id=\"activityBoxError\" " + "style=\"visibility:hidden\">"
                + "<i>Currently there is no activity information available.</i>" + "</span>");
        errorArea.setContentMode(Label.CONTENT_XHTML);
        layout.addComponent(errorArea);
    } else if (detailsLink != null) {
        activityArea.setValue("<a href=\"" + detailsLink.getUrl() + "\" target=\"_new\">Show details</a>");
        layout.addComponent(activityArea);
    }

    return layout;
}

From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ProjectLinkGroupsBox.java

License:Open Source License

@Override
public Component getContent(Project project, ExtensionUtil util) {
    Layout layout = new CssLayout();
    layout.addStyleName(SYTLE_LINKGROUPS_INFOBOX);
    layout.setSizeFull();//from ww w . ja  va  2  s  . c  om
    LinkGroupsProjectExt ext = project.getExtension(LinkGroupsProjectExt.class);
    if (ext != null && !ext.getLinkGroups().isEmpty()) {
        for (LinkGroup linkGroup : ext.getLinkGroups()) {
            Label linkGroupHeaderLabel = new Label(linkGroup.getCaption());
            linkGroupHeaderLabel.addStyleName(STYLE_LABEL_GROUP);
            layout.addComponent(linkGroupHeaderLabel);

            for (Link link : linkGroup.getItems()) {
                com.vaadin.ui.Link uiLink = new com.vaadin.ui.Link(link.getLabel(),
                        new ExternalResource(link.getUrl()));
                uiLink.setDescription(link.getUrl());
                uiLink.addStyleName(STYLE_LABEL_LINK);
                uiLink.setTargetName("_blank"); //$NON-NLS-1$
                layout.addComponent(uiLink);
            }
        }
    }
    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();//  w ww .  j a  v a2s .  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>&nbsp;" + 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.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  w w  .jav a2s.  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();// w ww. 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

protected void addCalculatedContent(Project project, Layout layout) {
    SearchService searchService = Services.getService(SearchService.class);
    if (searchService == null) {
        return;//from w  w w .java 2s.c o  m
    }
    SearchResult<Project> relatedProjects = searchService.getRelatedProjects(project, 3);
    if (relatedProjects.getResultCount() == 0) {
        createLabel(layout, HSPACE + "No matches found");
        return;
    }
    for (SearchHit<Project> hit : relatedProjects.getResult()) {
        ExternalResource externalResource = new ExternalResource("/projects/" + hit.getEntity().getProjectId());
        String content = HSPACE + "<a href=" + externalResource.getURL() + ">" + hit.getEntity().getName()
                + "*</a>";
        createLabel(layout, content);
    }
    Label label = new Label(HSPACE + "*calculated based on similarities between the projects",
            Label.CONTENT_XHTML);
    label.setStyleName("light");//$NON-NLS-1$
    layout.addComponent(label);

}

From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.SubprojectsInfoBox.java

License:Open Source License

@Override
public Component getContent(Project project, ExtensionUtil util) {
    Layout layout = new CssLayout();
    layout.addStyleName(STYLE_SUBPROJECTS_INFOBOX);
    layout.setSizeFull();/*from   w w w.  j  a  v a  2  s .  c  o m*/

    UUID uuid = project.getUuid();

    List<Project> parents = projectService.getParentChain(uuid);
    SortedSet<Project> subprojects = project.getSubProjects(new SubprojectComparator(templateService));
    int indent = 0;
    StringBuilder sb = new StringBuilder();

    // render the parents of the project as links in reverse order and
    // with increasing indentation; finally render the project
    // itself (just as emphasized text, no link)
    for (int i = parents.size() - 1; i >= 0; --i) {
        renderProject(sb, parents.get(i), templateService, indent, i > 0);
        indent += DELTA_INDENT;
    }

    // render the subprojects as links in alphabetical order
    // and with same indentation
    for (Project subproject : subprojects) {
        renderProject(sb, subproject, templateService, indent, true);
    }

    Label content = new Label(sb.toString(), Label.CONTENT_XHTML);
    content.setSizeUndefined();
    layout.addComponent(content);
    return layout;
}

From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.TagComponent.java

License:Open Source License

@SuppressWarnings({ "deprecation", "serial" })
private void paintTagView() {
    layout.removeAllComponents();/*  w  ww. j  a  v a2 s . c  om*/

    Set<String> tags = TaggingUtils.getTags(project);
    if (tags != null && tags.size() > 0) {
        Layout tagListLayout = new CssLayout() {
            @Override
            protected String getCss(Component c) {
                if (c instanceof Label) {
                    return "float: left; line-height:18px; padding-right: 3px;";
                } else {
                    return "float: left; padding-right: 5px";
                }
            }
        };
        tagListLayout.setSizeFull();
        Label tagLabel = new Label("Tags:");
        tagLabel.setSizeUndefined();
        tagListLayout.addComponent(tagLabel);

        for (String tag : tags) {
            Button tagButton = new Button(tag, new ClickListener() {
                @Override
                public void buttonClick(ClickEvent event) {
                    String tag = event.getButton().getCaption();
                    util.getNavigator().navigateTagView(tag);
                }
            });
            tagButton.setStyleName(Button.STYLE_LINK);
            tagListLayout.addComponent(tagButton);
        }

        Button editButton = new Button("(edit tags)");
        if (util.getLoggedInUser() != null) {
            editButton.addListener(new ClickListener() {
                @Override
                public void buttonClick(ClickEvent event) {
                    paintTagEdit();
                }
            });
        } else {
            editButton.setEnabled(false);
            editButton.setDescription("Login to tag this project");
        }
        editButton.setStyleName(Button.STYLE_LINK);
        tagListLayout.addComponent(editButton);

        layout.addComponent(tagListLayout);
    } else {
        if (util.getLoggedInUser() != null) {
            Button addTagButton = new Button("(add tags)", new ClickListener() {
                @Override
                public void buttonClick(ClickEvent event) {
                    paintTagEdit();
                }
            });
            addTagButton.setStyleName(Button.STYLE_LINK);
            layout.addComponent(addTagButton);
        }
    }

}

From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.TagComponent.java

License:Open Source License

@SuppressWarnings({ "deprecation", "serial" })
private void paintEditTagList() {
    tagListLayout.removeAllComponents();
    tagListLayout.setWidth("100%"); //$NON-NLS-1$

    Label tagLabel = new Label("Tags:");
    tagLabel.setSizeUndefined();//w  w  w  .  jav  a 2  s . c  om
    tagListLayout.addComponent(tagLabel);

    SortedSet<String> tags = TaggingUtils.getTags(project);
    for (String tag : tags) {
        Layout l = new CssLayout() {
            @Override
            protected String getCss(Component c) {
                if (c instanceof Label) {
                    return "float: left; line-height: 18px; padding-right: 3px"; //$NON-NLS-1$
                } else {
                    return "float: left; line-height: 18px; padding-right: 5px"; //$NON-NLS-1$
                }
            }
        };
        Label label = new Label(tag);
        label.setSizeUndefined();
        l.addComponent(label);

        Button removeButton = new Button("(remove)", new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                String tag = (String) event.getButton().getData();
                TaggingUtils.removeTag(project, tag);
                util.persist(project);
                paintTagEdit();
            }
        });
        removeButton.setStyleName(Button.STYLE_LINK);
        removeButton.setData(tag);
        removeButton.setSizeUndefined();
        l.addComponent(removeButton);
        tagListLayout.addComponent(l);
    }
}