Example usage for com.vaadin.ui CssLayout CssLayout

List of usage examples for com.vaadin.ui CssLayout CssLayout

Introduction

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

Prototype

public CssLayout() 

Source Link

Document

Constructs an empty CssLayout.

Usage

From source file:org.eclipse.skalli.view.component.PeopleComponent.java

License:Open Source License

protected PeopleComponent(final User user) {
    addStyleName(STYLE);/*from   ww w. jav a2s .c o  m*/

    Layout layout = new CssLayout();
    layout.setSizeFull();
    layout.setMargin(false);

    StringBuilder sb = new StringBuilder();
    sb.append("<span class=\"v-img-peoplecomponent\">"); //$NON-NLS-1$
    sb.append("<img src=\"/VAADIN/themes/simple/icons/people/team.png\" /> "); //$NON-NLS-1$
    sb.append("</span>"); //$NON-NLS-1$

    String userDetailsLink = UserDetailsUtil.getUserDetailsLink(user.getUserId());
    if (userDetailsLink != null) {
        // user details link configured, render a link to user details dialog
        sb.append("<a href=\""); //$NON-NLS-1$
        sb.append(userDetailsLink);
        sb.append("\" target=\"_blank\">"); //$NON-NLS-1$
        sb.append(StringEscapeUtils.escapeHtml(user.getDisplayName()));
        sb.append("</a> "); //$NON-NLS-1$
    } else {
        // not configured, just display the user name
        sb.append(StringEscapeUtils.escapeHtml(user.getDisplayName()));
        sb.append(" "); //$NON-NLS-1$
    }

    sb.append("<span class=\"v-link-peoplecomponent\">"); //$NON-NLS-1$

    if (user.hasEmail()) {
        sb.append("<a class=\"link\" href=\"mailto:"); //$NON-NLS-1$
        sb.append(user.getEmail());
        sb.append("\">"); //$NON-NLS-1$
        sb.append("Mail");
        sb.append("</a> "); //$NON-NLS-1$
    }

    sb.append("<a class=\"link\" href=\""); //$NON-NLS-1$
    sb.append(Consts.URL_PROJECTS_USER);
    sb.append(StringEscapeUtils.escapeHtml(user.getUserId()));
    sb.append("\">"); //$NON-NLS-1$
    sb.append("Projects");
    sb.append("</a> "); //$NON-NLS-1$

    sb.append("</span>"); //$NON-NLS-1$

    Label lbl = new Label();
    lbl.setContentMode(Label.CONTENT_XHTML);
    lbl.setValue(sb.toString());
    layout.addComponent(lbl);

    setCompositionRoot(layout);
}

From source file:org.eclipse.skalli.view.component.RadioSelect.java

License:Open Source License

public RadioSelect(String caption, Collection<Entry> entries) {
    setCaption(caption);/*from   w  w  w.j  a v a 2 s.co  m*/
    this.entries = new ArrayList<Entry>(entries);
    this.selected = 0;

    layout = new CssLayout() {

        private static final long serialVersionUID = 3319052685837527947L;

        @Override
        protected String getCss(Component c) {
            if (c instanceof Button) {
                return "margin-top:10px;margin-right:15px"; //$NON-NLS-1$
            }
            if (c instanceof Label) {
                return "margin-bottom:15px"; //$NON-NLS-1$
            }
            return "margin-top:3px"; //$NON-NLS-1$
        }
    };
    layout.setMargin(true);
    layout.setSizeFull();

    if (entries != null && entries.size() > 0) {
        entriesGrid = new GridLayout(2, entries.size());
        entriesGrid.setSizeFull();
        //entriesGrid.setSpacing(true);
        layout.addComponent(entriesGrid);
        renderEntries();
    }

    setCompositionRoot(layout);
}

From source file:org.eclipse.skalli.view.component.RadioSelect.java

License:Open Source License

private void renderEntries() {
    int row = 0;//  w  w w  .  j  a v a2s. co  m
    radios = new ArrayList<Button>(entries.size());
    for (Entry entry : entries) {
        Button b = new Button();
        b.setIcon(row == selected ? SELECTED : UNSELECTED);
        b.setStyleName(Button.STYLE_LINK);
        b.addListener((Button.ClickListener) this);
        entriesGrid.addComponent(b, 0, row);
        radios.add(b);

        StringBuilder sb = new StringBuilder();
        sb.append("<span style=\"font-weight:bold\">"); //$NON-NLS-1$
        sb.append(StringEscapeUtils.escapeHtml(entry.getCaption()));
        sb.append("</span><br>"); //$NON-NLS-1$
        sb.append("<span style=\"white-space:normal\">"); //$NON-NLS-1$
        sb.append(HtmlUtils.clean(entry.getDescription()));
        sb.append("</span>"); //$NON-NLS-1$

        CssLayout css = new CssLayout() {

            private static final long serialVersionUID = 7370808823922141846L;

            @Override
            protected String getCss(Component c) {
                return "margin-bottom:10px;margin-left:3px"; //$NON-NLS-1$
            }
        };
        css.setSizeFull();
        Label comment = new Label(sb.toString(), Label.CONTENT_XHTML);
        css.addComponent(comment);

        entriesGrid.addComponent(css, 1, row);
        entriesGrid.setColumnExpandRatio(1, 1.0f);
        ++row;
    }
}

From source file:org.eclipse.skalli.view.component.Tray.java

License:Open Source License

private ComponentContainer createContent(String caption, String description, ThemeResource icon,
        boolean isRequired) {
    CssLayout layout = new CssLayout();
    layout.setStyleName(STYLE_TRAY);// www .  j  a  va2 s .  c o  m
    layout.setMargin(true);

    HorizontalLayout header = new HorizontalLayout();
    header.setSpacing(true);
    header.setStyleName(STYLE_TRAY_HEADER);
    header.setWidth("100%");

    this.icon = icon;
    trayIcon = new Embedded(null, icon);
    trayIcon.setStyleName(STYLE_TRAY_HEADER_ICON);
    header.addComponent(trayIcon);
    header.setComponentAlignment(trayIcon, Alignment.MIDDLE_LEFT);
    header.setExpandRatio(trayIcon, 0);

    Label captionLabel = new Label(StringEscapeUtils.escapeHtml(caption), Label.CONTENT_XHTML);
    captionLabel.setStyleName(STYLE_TRAY_HEADER_LABEL);
    header.addComponent(captionLabel);
    header.setExpandRatio(captionLabel, 1);
    header.setComponentAlignment(captionLabel, Alignment.MIDDLE_LEFT);

    this.isRequired = isRequired;
    if (!isRequired) {
        activator = new NativeButton("", new ToggleEnabledListener());
        header.addComponent(activator);
        header.setExpandRatio(activator, 0);
        header.setComponentAlignment(activator, Alignment.MIDDLE_RIGHT);
    }

    opener = new NativeButton("", new ToggleVisibleListener());
    header.addComponent(opener);
    header.setExpandRatio(opener, 0);
    header.setComponentAlignment(opener, Alignment.MIDDLE_RIGHT);

    layout.addComponent(header);

    CssLayout content = new CssLayout();
    Label descriptionLabel = new Label(HtmlUtils.clean(description), Label.CONTENT_XHTML);
    descriptionLabel.setStyleName(STYLE_TRAY_DESCRIPTION);
    content.addComponent(descriptionLabel);

    layout.addComponent(content);
    setCompositionRoot(layout);
    return content;
}

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

License:Open Source License

@Override
public Component getContent(Project project, ExtensionUtil util) {
    List<String> sources = getSources(project);
    if (sources.isEmpty()) {
        return null; // nothing to render
    }/*from   w w w.  jav a2 s.  co m*/

    Layout contentLayout = new CssLayout();
    contentLayout.addStyleName(STYLE_TIMELINE_INFOBOX);
    contentLayout.setSizeFull();

    maxFeedEntries = INITAL_MAX_FEED_ENTRIES;
    HashMap<String, SourceDetails> sourceFilter = new HashMap<String, SourceDetails>();
    Map<String, String> captions = getCaptions(project, sources);
    for (String source : sources) {
        String caption = captions.get(source);
        if (StringUtils.isBlank(caption)) {
            caption = source;
        }
        sourceFilter.put(source, new SourceDetails(true, caption));
    }

    renderContentPanel(contentLayout, project, util.getLoggedInUserId(), sourceFilter);
    return contentLayout;
}

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

License:Open Source License

@Override
public Component getContent(Project project, ExtensionUtil util) {
    CssLayout layout = new CssLayout();
    layout.addStyleName(STYLE_ABOUT_INFOBOX);
    layout.setSizeFull();// www  .j ava2 s.  c o m

    String description = "No description available";
    if (StringUtils.isNotBlank(project.getDescription())) {
        description = HtmlUtils.clean(StringUtils.replace(project.getDescription(), "\n", "<br />")); //$NON-NLS-1$ //$NON-NLS-2$
        createLabel(layout, description, STYLE_ABOUT);
    }

    InfoExtension ext = project.getExtension(InfoExtension.class);
    if (ext != null && StringUtils.isNotBlank(ext.getPageUrl())) {
        createLink(layout, "Project Homepage", ext.getPageUrl(), DEFAULT_TARGET, STYLE_HOMEPAGE);
    }

    TaggingService taggingService = Services.getService(TaggingService.class);
    if (taggingService != null) {
        TagComponent tagComponent = new TagComponent(project, taggingService, util);
        layout.addComponent(tagComponent);
    }

    if (!util.getProjectTemplate().isHidden(Project.class.getName(), Project.PROPERTY_PHASE,
            util.isUserProjectAdmin(project))) {
        createLabel(layout, MessageFormat.format("This project is in the <b>{0}</b> phase.",
                StringEscapeUtils.escapeHtml(project.getPhase())), STYLE_PHASE);
    }

    // for ui testing
    // TODO need to understand why vaadin does not accept the layout to have the id
    // (it then cannot render a second project, throws ISE)
    layout.addComponent(new Label("<div id=" + DEBUG_ID + "></div>", Label.CONTENT_XHTML)); //$NON-NLS-1$ //$NON-NLS-2$

    addLastModifiedInfo(layout, project);

    return layout;
}

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   w  w w  .ja v a 2s  . 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.ProjectDevInfBox.java

License:Open Source License

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

    DevInfProjectExt devInf = project.getExtension(DevInfProjectExt.class);

    HtmlBuilder html = new HtmlBuilder();
    if (devInf != null) {
        // Project Sources
        if (StringUtils.isNotBlank(devInf.getScmUrl())) {
            html.appendIconizedLink(ICON_SOURCES, "Project Sources", devInf.getScmUrl()).appendLineBreak();
        }
        // Bug Tracker
        if (StringUtils.isNotBlank(devInf.getBugtrackerUrl())) {
            Set<String> linkList = new HashSet<String>();
            linkList.add(devInf.getBugtrackerUrl());
            addCreateBugLinks(linkList, util.getLoggedInUserId(), project, devInf);
            html.appendIconizedLinks(ICON_BUGTRACKER, "Bug Tracker", "(Create Issue)", linkList)
                    .appendLineBreak();
        }
        // Code Metrics
        if (StringUtils.isNotBlank(devInf.getMetricsUrl())) {
            html.appendIconizedLink(ICON_METRICS, "Code Metrics", devInf.getMetricsUrl()).appendLineBreak();
        }
        // CI / Build Server
        if (StringUtils.isNotBlank(devInf.getCiUrl())) {
            html.appendIconizedLink(ICON_CI_SERVER, "Continuous Integration / Build Server", devInf.getCiUrl())
                    .appendLineBreak();
        }
        // Code Review
        if (StringUtils.isNotBlank(devInf.getReviewUrl())) {
            html.appendIconizedLink(ICON_REVIEW, "Code Review", devInf.getReviewUrl()).appendLineBreak();
        }
        // Javadoc
        if (CollectionUtils.isNotBlank(devInf.getJavadocs())) {
            html.appendIconizedLinks(ICON_JAVADOC, "Javadoc", "(more Javadoc)", devInf.getJavadocs())
                    .appendLineBreak();
        }

        // SCM Locations
        if (CollectionUtils.isNotBlank(devInf.getScmLocations())) {
            html.appendHeader("Source Locations", 4).append('\n');
            html.append("<ul>\n"); //$NON-NLS-1$
            ScmLocationMapper mapper = new ScmLocationMapper(ScmLocationMapper.ALL_PROVIDERS,
                    ScmLocationMapper.PURPOSE_BROWSE, ScmLocationMapper.PURPOSE_REVIEW);

            for (String scmLocation : devInf.getScmLocations()) {
                html.append("<li>"); //$NON-NLS-1$
                List<String> scmUrls = getScmUrls(scmLocation, util.getLoggedInUserId(), project);
                for (String scmUrl : scmUrls) {
                    html.append(copyToClipboardLink(scmUrl, scmUrl));
                }
                List<Link> mappedScmLinks = mapper.getMappedLinks(scmLocation, util.getLoggedInUserId(),
                        project);
                html.appendLinks(mappedScmLinks);
                html.append("</li>\n"); //$NON-NLS-1$
            }
            html.append("</ul>\n"); //$NON-NLS-1$
        }
    }

    if (html.length() > 0) {
        createLabel(layout, html.toString());
    } else {
        createLabel(layout, "This project has no development information.");
    }
    return layout;
}

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

License:Open Source License

@Override
@SuppressWarnings("nls")
public Component getContent(Project project, ExtensionUtil util) {
    Layout layout = new CssLayout();
    layout.addStyleName(STYLE_ISSUES_INFOBOX);
    layout.setSizeFull();/*from   www.ja  va2  s  .  c  o  m*/

    IssuesService issuesService = Services.getService(IssuesService.class);
    if (issuesService != null) {
        Issues issues = issuesService.loadEntity(Issues.class, project.getUuid());
        StringBuilder sb = new StringBuilder();
        if (issues != null) {
            if (issues.isStale()) {
                sb.append("<ul><li class=\"STALE\">No information about issues available.</li></ul>");
            } else {
                SortedSet<Issue> issueSet = issues.getIssues();
                if (!issueSet.isEmpty()) {
                    sb.append(Issue.asHTMLList(null, issueSet));
                    if (util.isUserProjectAdmin(project)) {
                        sb.append("<p>Click <a href=\"").append(Consts.URL_PROJECTS).append("/")
                                .append(project.getProjectId()).append("?").append(Consts.PARAM_ACTION)
                                .append("=").append(Consts.PARAM_VALUE_EDIT).append("\">here</a> to correct ");
                        sb.append((issueSet.size() == 1) ? "this issue" : "these issues");
                        sb.append(".</p>");
                    }
                }
            }
            if (util.isUserProjectAdmin(project)) {
                sb.append("<p>Click <a href=\"").append(Consts.URL_PROJECTS).append("/");
                sb.append(project.getProjectId()).append("?").append(Consts.PARAM_ACTION).append("=");
                sb.append(Consts.PARAM_VALUE_VALIDATE).append("\">here</a> to validate the project now.</p>");
            }
            createLabel(layout, sb.toString(), STYLE_ISSUES);
        }
    }

    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.  j  av a  2s . c  o  m
    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;
}