List of usage examples for com.vaadin.ui Link setIcon
@Override public void setIcon(Resource icon)
From source file:org.opennms.netmgt.bsm.vaadin.adminpage.BusinessServiceTreeTable.java
License:Open Source License
public BusinessServiceTreeTable(BusinessServiceManager businessServiceManager) { this.businessServiceManager = Objects.requireNonNull(businessServiceManager); setSizeFull();/* w w w.j a va2 s . c o m*/ setContainerDataSource(new BusinessServiceContainer()); // Add the "LINKS" columns addGeneratedColumn("links", new Table.ColumnGenerator() { private static final long serialVersionUID = 7113848887128656685L; @Override public Object generateCell(Table source, Object itemId, Object columnId) { final HorizontalLayout layout = new HorizontalLayout(); final BusinessServiceStateMachine stateMachine = businessServiceManager.getStateMachine(); final BusinessService businessService = getItem(itemId).getBean().getBusinessService(); final Status status = stateMachine.getOperationalStatus(businessService); if (status != null) { // Build the query string final List<BasicNameValuePair> urlParms = Lists.newArrayList( new BasicNameValuePair("focus-vertices", businessService.getId().toString()), new BasicNameValuePair("szl", "1"), new BasicNameValuePair("layout", "Hierarchy Layout"), new BasicNameValuePair("provider", "Business Services")); final String queryString = URLEncodedUtils.format(urlParms, Charset.forName("UTF-8")); // Generate the link final Link link = new Link("View in Topology UI", new ExternalResource(String.format("/opennms/topology?%s", queryString))); link.setIcon(FontAwesome.EXTERNAL_LINK_SQUARE); // This app is typically access in an iframe, so we open the URL in a new window/tab link.setTargetName("_blank"); layout.addComponent(link); layout.setComponentAlignment(link, Alignment.MIDDLE_CENTER); } else { Label label = new Label("N/A"); label.setDescription("Try reloading the daemon and refreshing the table."); label.setWidth(null); layout.addComponent(label); } return layout; } }); // add edit and delete buttons addGeneratedColumn("edit / delete", new Table.ColumnGenerator() { private static final long serialVersionUID = 7113848887128656685L; @Override public Object generateCell(Table source, Object itemId, Object columnId) { HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true); Button editButton = new Button("Edit", FontAwesome.PENCIL_SQUARE_O); editButton.setId("editButton-" + getItem(itemId).getBean().getName()); editButton.addClickListener(UIHelper.getCurrent(TransactionAwareUI.class) .wrapInTransactionProxy((Button.ClickListener) event -> { final Long businessServiceId = getItem(itemId).getBean().getBusinessService().getId(); BusinessService businessService = businessServiceManager .getBusinessServiceById(businessServiceId); final BusinessServiceEditWindow window = new BusinessServiceEditWindow(businessService, businessServiceManager); window.addCloseListener(e -> refresh()); getUI().addWindow(window); })); layout.addComponent(editButton); Button deleteButton = new Button("Delete", FontAwesome.TRASH_O); deleteButton.setId("deleteButton-" + getItem(itemId).getBean().getName()); deleteButton.addClickListener((Button.ClickListener) event -> { final Long businessServiceId = getItem(itemId).getBean().getBusinessService().getId(); BusinessService businessService = businessServiceManager .getBusinessServiceById(businessServiceId); if (businessService.getParentServices().isEmpty() && businessService.getChildEdges().isEmpty()) { UIHelper.getCurrent(TransactionAwareUI.class).runInTransaction(() -> { businessServiceManager.getBusinessServiceById(businessServiceId).delete(); refresh(); }); } else { new org.opennms.netmgt.vaadin.core.ConfirmationDialog() .withOkAction((org.opennms.netmgt.vaadin.core.ConfirmationDialog.Action) UIHelper .getCurrent(TransactionAwareUI.class).wrapInTransactionProxy( new org.opennms.netmgt.vaadin.core.ConfirmationDialog.Action() { @Override public void execute( org.opennms.netmgt.vaadin.core.ConfirmationDialog window) { businessServiceManager .getBusinessServiceById(businessServiceId).delete(); refresh(); } })) .withOkLabel("Delete anyway").withCancelLabel("Cancel").withCaption("Warning") .withDescription( "This entry is referencing or is referenced by other Business Services! Do you really want to delete this entry?") .open(); } }); layout.addComponent(deleteButton); return layout; } }); setColumnExpandRatio("name", 5); setColumnExpandRatio("links", 1); setColumnExpandRatio("edit / delete", 1); }
From source file:org.rubicone.poc.vpush.uil.sending.SendingUI.java
License:Apache License
private Panel createInstructionsPanel() { Panel instructionsPanel = new Panel("instructions"); VerticalLayout instructionsLayout = new VerticalLayout(); instructionsPanel.setContent(instructionsLayout); Label instructionsLabel = new Label( "open another UI receiving notifications from server using following transport:"); instructionsLayout.addComponent(instructionsLabel); Link websocketsUILink = new Link("websockets", new ExternalResource("./receive-messages-websockets")); websocketsUILink.setIcon(VaadinIcons.CHEVRON_RIGHT_SMALL); websocketsUILink.setTargetName("_blank"); instructionsLayout.addComponent(websocketsUILink); Link websocketsXhrUILink = new Link("websockets + XHR", new ExternalResource("./receive-messages-websocketsxhr")); websocketsXhrUILink.setIcon(VaadinIcons.CHEVRON_RIGHT_SMALL); websocketsXhrUILink.setTargetName("_blank"); instructionsLayout.addComponent(websocketsXhrUILink); Link httpLongPollingUILink = new Link("HTTP long polling", new ExternalResource("./receive-messages-httplongpolling")); httpLongPollingUILink.setIcon(VaadinIcons.CHEVRON_RIGHT_SMALL); httpLongPollingUILink.setTargetName("_blank"); instructionsLayout.addComponent(httpLongPollingUILink); Label noteLabel = new Label( "<i>" + VaadinIcons.INFO_CIRCLE_O.getHtml() + " note: you may open several UIs at the same time to receive push notifications</i>", ContentMode.HTML);//from www . j a v a2s.c o m noteLabel.addStyleName(ValoTheme.LABEL_TINY); instructionsLayout.addComponents(noteLabel); return instructionsPanel; }
From source file:org.vaadin.addons.sitekit.viewlet.user.ProfileImageViewlet.java
License:Apache License
@Override public void enter(final String parameters) { final String user = getSite().getSecurityProvider().getUser(); if (user == null) { final VerticalLayout layout = new VerticalLayout(); layout.setMargin(false);// w w w . j a va2 s .com final Link link = new Link(null, new ExternalResource("#!login")); link.setStyleName("gravatar"); link.setIcon(getSite().getIcon("view-icon-login")); link.setWidth(32, UNITS_PIXELS); link.setHeight(32, UNITS_PIXELS); layout.addComponent(link); layout.setComponentAlignment(link, Alignment.MIDDLE_CENTER); this.setCompositionRoot(layout); return; } try { final VerticalLayout layout = new VerticalLayout(); layout.setMargin(false); if (getSite().getSiteContext().getObject("gravatar-url") == null) { getSite().getSiteContext().putObject("gravatar-url", getGravatarUrl(user)); } final URL gravatarUrl = new URL((String) getSite().getSiteContext().getObject("gravatar-url")); //final Embedded embedded = new Embedded(null, new ExternalResource(gravatarUrl)); final Link link = new Link(null, new ExternalResource("http://www.gravatar.com/")); link.setStyleName("gravatar"); link.setIcon(new ExternalResource(gravatarUrl)); link.setWidth(32, UNITS_PIXELS); link.setHeight(32, UNITS_PIXELS); layout.addComponent(link); layout.setComponentAlignment(link, Alignment.MIDDLE_CENTER); this.setCompositionRoot(layout); } catch (final Exception e) { LOGGER.warn("Error reading gravatar image for user: " + user, e); } }
From source file:ubu.digit.ui.components.Footer.java
License:Creative Commons License
/** * Aade la informacin del proyecto./*from w w w . ja v a 2s . c o m*/ */ private void addInformation() { VerticalLayout information = new VerticalLayout(); information.setMargin(false); information.setSpacing(true); Label subtitle = new Label(INFORMACION); subtitle.setStyleName(SUBTITLE_STYLE); Label version2 = new Label("Versin 2.0 creada por Javier de la Fuente Barrios"); Link link2 = new Link("jfb0019@alu.ubu.es", new ExternalResource("mailto:jfb0019@alu.ubu.es")); link2.setIcon(FontAwesome.ENVELOPE); Label version1 = new Label("Versin 1.0 creada por Beatriz Zurera Martnez-Acitores"); Link link1 = new Link("bzm0001@alu.ubu.es", new ExternalResource("mailto:bzm0001@alu.ubu.es")); link1.setIcon(FontAwesome.ENVELOPE); Label tutor = new Label("Tutorizado por Carlos Lpez Nozal"); Link linkT = new Link("clopezno@ubu.es", new ExternalResource("mailto:clopezno@alu.ubu.es")); linkT.setIcon(FontAwesome.ENVELOPE); Label copyright = new Label("Copyright @ LSI"); information.addComponents(subtitle, version2, link2, version1, link1, tutor, linkT, copyright); content.addComponent(information); }
From source file:ubu.digit.ui.components.Footer.java
License:Creative Commons License
/** * Aade la informacin de la licencia del proyecto. *///w ww . ja v a 2 s . c o m private void addLicense() { VerticalLayout license = new VerticalLayout(); license.setMargin(false); license.setSpacing(true); Link ccImage = new Link(null, new ExternalResource("https://creativecommons.org/licenses/by/4.0/")); ccImage.setIcon(new ThemeResource("img/cc.png")); Label licenseText = new Label("This work is licensed under a: "); Link ccLink = new Link("Creative Commons Attribution 4.0 International License.", new ExternalResource("https://creativecommons.org/licenses/by/4.0/")); license.addComponents(ccImage, licenseText, ccLink); if (fileName != null) { String lastModified = getLastModified(fileName); license.addComponent(new Label("Ultima actualizacin: " + lastModified)); } Button login = new Button("Actualizar"); login.addClickListener(new LoginClickListener()); license.addComponent(login); content.addComponent(license); }
From source file:v7cr.ReviewTab.java
License:Open Source License
private Panel getBasicInfo(V7CR v7, Review r, Project proj, String linkUrl) { Panel p = new Panel(v7.getMessage("reviewTab.review")); p.setWidth("600px"); GridLayout grid = new GridLayout(3, 4); grid.setSizeFull();// w w w .j ava2s. c o m p.setContent(grid); grid.setSpacing(true); Locale l = v7.getLocale(); SchemaDefinition sd = r.getSchemaDefinition(); grid.addComponent(new Label(sd.getFieldCaption("s", l)), 0, 0, 1, 0); p.addComponent(new Label("<b>" + LocalizedString .get(sd.getFieldDefinition("s").getPossibleValueMetaData(r.getStatus()), "caption", l) + "</b>", Label.CONTENT_XHTML)); p.addComponent(new Label(sd.getFieldCaption("p", l))); p.addComponent(new Label("[" + proj.getId() + "]")); grid.addComponent(new Label(proj.getName())); p.addComponent(new Label(sd.getFieldCaption("reviewee", l))); p.addComponent(new Label(r.getReviewee().getId())); grid.addComponent(new Label(r.getReviewee().getName())); p.addComponent(new Label(sd.getFieldCaption("t", l))); grid.addComponent(new Label(r.getTitle()), 1, 3, 2, 3); p.addComponent(new Label(v7.getMessage("reviewTab.directLink"))); Link link = new Link(linkUrl, new ExternalResource(linkUrl)); link.setTargetName("_blank"); link.setIcon(new ThemeResource("../runo/icons/16/arrow-right.png")); grid.addComponent(link); return p; }
From source file:v7cr.ReviewTab.java
License:Open Source License
private Panel getSVNPanel(V7CR v7, SchemaDefinition sd, SVNLogEntry svn, Project proj) { if (svn == null) return null; Locale l = v7.getLocale();/*ww w.j a v a 2 s . c o m*/ Panel p = new Panel(v7.getMessage("reviewTab.subversion")); p.setWidth("600px"); GridLayout grid = new GridLayout(4, 4); grid.setSizeFull(); p.setContent(grid); grid.setSpacing(true); p.addComponent(new Label(sd.getFieldCaption("svn.rev", l))); p.addComponent(new Label("" + svn.getRevision())); p.addComponent(new Label(DateFormat.getDateTimeInstance().format(svn.getDate()))); p.addComponent(new Label(svn.getAuthor())); Link link = new Link(v7.getMessage("reviewTab.viewChanges"), new ExternalResource(proj.getChangesetViewUrl(svn.getRevision()))); link.setTargetName("_blank"); link.setIcon(new ThemeResource("../runo/icons/16/arrow-right.png")); p.addComponent(link); grid.addComponent(new Label(svn.getMessage()), 1, 1, 3, 1); Map<String, SVNLogEntryPath> changed = svn.getChangedPaths(); if (changed != null) { Tree changeTree = new Tree(sd.getFieldCaption("svn.changed", l) + "(" + changed.size() + ")"); Set<String> paths = changed.keySet(); for (String s : changed.keySet()) { changeTree.addItem(s); changeTree.setChildrenAllowed(s, false); changeTree.setItemCaption(s, changed.get(s).getType() + " " + s); } if (paths.size() > 5) { compressTree(changeTree, paths); } grid.addComponent(changeTree, 0, 2, 3, 2); } return p; }