List of usage examples for com.vaadin.ui Layout addStyleName
public void addStyleName(String style);
From source file:com.haulmont.cuba.web.WebWindowManager.java
License:Apache License
protected Layout createNewTabLayout(final Window window, final boolean multipleOpen, WindowBreadCrumbs breadCrumbs, Component... additionalComponents) { Layout layout = new CssLayout(); layout.setPrimaryStyleName("c-app-window-wrap"); layout.setSizeFull();//from ww w. j a va 2s . c om layout.addComponent(breadCrumbs); if (additionalComponents != null) { for (final Component c : additionalComponents) { layout.addComponent(c); } } final Component component = WebComponentsHelper.getComposition(window); component.setSizeFull(); layout.addComponent(component); WebAppWorkArea workArea = getConfiguredWorkArea(createWorkAreaContext(window)); if (workArea.getMode() == Mode.TABBED) { layout.addStyleName("c-app-tabbed-window"); TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour(); String tabId; Integer hashCode = getWindowHashCode(window); ComponentContainer tab = null; if (hashCode != null) { tab = findTab(hashCode); } if (tab != null && !multipleOpen) { tabSheet.replaceComponent(tab, layout); tabSheet.removeComponent(tab); tabs.put(layout, breadCrumbs); tabId = tabSheet.getTab(layout); } else { tabs.put(layout, breadCrumbs); tabId = "tab_" + uuidSource.createUuid(); tabSheet.addTab(layout, tabId); if (ui.isTestMode()) { String id = "tab_" + window.getId(); tabSheet.setTabTestId(tabId, ui.getTestIdManager().getTestId(id)); tabSheet.setTabCubaId(tabId, id); } } String windowContentSwitchMode = window.getContentSwitchMode().name(); ContentSwitchMode contentSwitchMode = ContentSwitchMode.valueOf(windowContentSwitchMode); tabSheet.setContentSwitchMode(tabId, contentSwitchMode); String formattedCaption = formatTabCaption(window.getCaption(), window.getDescription()); tabSheet.setTabCaption(tabId, formattedCaption); String formattedDescription = formatTabDescription(window.getCaption(), window.getDescription()); if (!Objects.equals(formattedCaption, formattedDescription)) { tabSheet.setTabDescription(tabId, formattedDescription); } else { tabSheet.setTabDescription(tabId, null); } tabSheet.setTabIcon(tabId, WebComponentsHelper.getIcon(window.getIcon())); tabSheet.setTabClosable(tabId, true); tabSheet.setTabCloseHandler(layout, (targetTabSheet, tabContent) -> { //noinspection SuspiciousMethodCalls WindowBreadCrumbs breadCrumbs1 = tabs.get(tabContent); if (!canWindowBeClosed(breadCrumbs1.getCurrentWindow())) { return; } Runnable closeTask = new TabCloseTask(breadCrumbs1); closeTask.run(); // it is needed to force redraw tabsheet if it has a lot of tabs and part of them are hidden targetTabSheet.markAsDirty(); }); tabSheet.setSelectedTab(layout); } else { tabs.put(layout, breadCrumbs); layout.addStyleName("c-app-single-window"); VerticalLayout mainLayout = workArea.getSingleWindowContainer(); mainLayout.removeAllComponents(); mainLayout.addComponent(layout); } return layout; }
From source file:jp.primecloud.auto.ui.DialogConfirm.java
License:Open Source License
public DialogConfirm(String caption, String message, Buttons buttons, Layout optionLayout) { super(caption); setModal(true);//from w w w. ja va2 s . c om setResizable(false); setClosable(false); setWidth("380px"); addStyleName("dialog-confirm"); setIcon(Icons.DLGWARNING.resource()); VerticalLayout layout = (VerticalLayout) getContent(); layout.setWidth("100%"); layout.setMargin(false, true, false, true); layout.setSpacing(false); if (message != null && message.length() > 0) { // ?"\n"?"\t"???????"PREFORMATTED"?? Label lbl; if (message.indexOf("\n") != -1 || message.indexOf("\t") != -1) { lbl = new Label(message, Label.CONTENT_PREFORMATTED); } else { lbl = new Label(message, Label.CONTENT_TEXT); } lbl.addStyleName("dialog-message"); layout.addComponent(lbl); } // ???? if (optionLayout != null) { optionLayout.addStyleName("dialog-confirm-option"); addComponent(optionLayout); layout.setComponentAlignment(optionLayout, Alignment.MIDDLE_CENTER); } HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); // okButton = new Button(ViewProperties.getCaption("button.ok"), this, "buttonClick"); okButton.setDescription(ViewProperties.getCaption("description.ok")); okButton.setData(Result.OK); // [Enter]?okButton okButton.setClickShortcut(KeyCode.ENTER); okButton.focus(); cancelButton = new Button(ViewProperties.getCaption("button.cancel"), this, "buttonClick"); cancelButton.setDescription(ViewProperties.getCaption("description.cancel")); cancelButton.setData(Result.Cancel); switch (buttons) { case OK: hl.addComponent(okButton); break; case OKCancel: hl.addComponent(okButton); hl.addComponent(cancelButton); break; case OKCancelConfirm: hl.addComponent(okButton); hl.addComponent(cancelButton); okButton.setEnabled(false); confirm = new ComboBox(); confirm.setWidth("200px"); confirm.setImmediate(true); confirm.addStyleName("dialog-confirm"); confirm.setInputPrompt(ViewProperties.getCaption("description.dialogConfirmComboBox")); confirm.addItem(ViewProperties.getCaption("field.dialogConfirmComboBox")); confirm.addListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (confirm.getValue() != null) { okButton.setEnabled(true); } else { okButton.setEnabled(false); } } }); layout.addComponent(confirm); layout.setComponentAlignment(confirm, Alignment.MIDDLE_CENTER); break; default: break; } layout.addComponent(hl); layout.setComponentAlignment(hl, Alignment.BOTTOM_CENTER); }
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 }/*w w w .j av a 2 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.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. j ava2s. co m Label label; label = new Label("Latest commit activity (click for details):"); layout.addComponent(label); layout.addComponent(new Label(" ", 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 ww . j ava 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();/* ww w .java 2s . 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();// www . j a v a 2 s . com 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.ProjectMailingListBox.java
License:Open Source License
@SuppressWarnings("nls") @Override// w w w. j a v a 2s . 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 w w w . j av a2 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.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 . j a va2 s . c o m*/ 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; }