List of usage examples for com.vaadin.ui Link setCaption
@Override public void setCaption(String caption)
From source file:annis.gui.EmbeddedVisUI.java
License:Apache License
private void generateVisFromRemoteURL(final String visName, final String rawUri, Map<String, String[]> args) { try {// w ww . ja va 2 s .co m // find the matching visualizer final VisualizerPlugin visPlugin = this.getVisualizer(visName); if (visPlugin == null) { displayMessage("Unknown visualizer \"" + visName + "\"", "This ANNIS instance does not know the given visualizer."); return; } URI uri = new URI(rawUri); // fetch content of the URI Client client = null; AnnisUser user = Helper.getUser(); if (user != null) { client = user.getClient(); } if (client == null) { client = Helper.createRESTClient(); } final WebResource saltRes = client.resource(uri); displayLoadingIndicator(); // copy the arguments for using them later in the callback final Map<String, String[]> argsCopy = new LinkedHashMap<>(args); Background.runWithCallback(new Callable<SaltProject>() { @Override public SaltProject call() throws Exception { return saltRes.get(SaltProject.class); } }, new FutureCallback<SaltProject>() { @Override public void onFailure(Throwable t) { displayMessage("Could not query the result.", t.getMessage()); } @Override public void onSuccess(SaltProject p) { // TODO: allow to display several visualizers when there is more than one document SCorpusGraph firstCorpusGraph = null; SDocument doc = null; if (p.getCorpusGraphs() != null && !p.getCorpusGraphs().isEmpty()) { firstCorpusGraph = p.getCorpusGraphs().get(0); if (firstCorpusGraph.getDocuments() != null && !firstCorpusGraph.getDocuments().isEmpty()) { doc = firstCorpusGraph.getDocuments().get(0); } } if (doc == null) { displayMessage("No documents found in provided URL.", ""); return; } if (argsCopy.containsKey(KEY_INSTANCE)) { Map<String, InstanceConfig> allConfigs = loadInstanceConfig(); InstanceConfig newConfig = allConfigs.get(argsCopy.get(KEY_INSTANCE)[0]); if (newConfig != null) { setInstanceConfig(newConfig); } } // now it is time to load the actual defined instance fonts loadInstanceFonts(); // generate the visualizer VisualizerInput visInput = new VisualizerInput(); visInput.setDocument(doc); if (getInstanceConfig() != null && getInstanceConfig().getFont() != null) { visInput.setFont(getInstanceFont()); } Properties mappings = new Properties(); for (Map.Entry<String, String[]> e : argsCopy.entrySet()) { if (!KEY_SALT.equals(e.getKey()) && e.getValue().length > 0) { mappings.put(e.getKey(), e.getValue()[0]); } } visInput.setMappings(mappings); String[] namespace = argsCopy.get(KEY_NAMESPACE); if (namespace != null && namespace.length > 0) { visInput.setNamespace(namespace[0]); } else { visInput.setNamespace(null); } String baseText = null; if (argsCopy.containsKey(KEY_BASE_TEXT)) { String[] value = argsCopy.get(KEY_BASE_TEXT); if (value.length > 0) { baseText = value[0]; } } List<SNode> segNodes = CommonHelper.getSortedSegmentationNodes(baseText, doc.getDocumentGraph()); if (argsCopy.containsKey(KEY_MATCH)) { String[] rawMatch = argsCopy.get(KEY_MATCH); if (rawMatch.length > 0) { // enhance the graph with match information from the arguments Match match = Match.parseFromString(rawMatch[0]); addMatchToDocumentGraph(match, doc); } } Map<String, String> markedColorMap = new HashMap<>(); Map<String, String> exactMarkedMap = Helper.calculateColorsForMarkedExact(doc); Map<String, Long> markedAndCovered = Helper.calculateMarkedAndCoveredIDs(doc, segNodes, baseText); Helper.calulcateColorsForMarkedAndCovered(doc, markedAndCovered, markedColorMap); visInput.setMarkedAndCovered(markedAndCovered); visInput.setMarkableMap(markedColorMap); visInput.setMarkableExactMap(exactMarkedMap); visInput.setContextPath(Helper.getContext()); String template = Helper.getContext() + "/Resource/" + visName + "/%s"; visInput.setResourcePathTemplate(template); visInput.setSegmentationName(baseText); // TODO: which other thing do we have to provide? Component c = visPlugin.createComponent(visInput, null); // add the styles c.addStyleName("corpus-font"); c.addStyleName("vis-content"); Link link = new Link(); link.setCaption("Show in ANNIS search interface"); link.setIcon(ANNISFontIcon.LOGO); link.setVisible(false); link.addStyleName("dontprint"); link.setTargetName("_blank"); if (argsCopy.containsKey(KEY_SEARCH_INTERFACE)) { String[] interfaceLink = argsCopy.get(KEY_SEARCH_INTERFACE); if (interfaceLink.length > 0) { link.setResource(new ExternalResource(interfaceLink[0])); link.setVisible(true); } } VerticalLayout layout = new VerticalLayout(link, c); layout.setComponentAlignment(link, Alignment.TOP_LEFT); layout.setSpacing(true); layout.setMargin(true); setContent(layout); IDGenerator.assignID(link); } }); } catch (URISyntaxException ex) { displayMessage("Invalid URL", "The provided URL is malformed:<br />" + ex.getMessage()); } catch (LoginDataLostException ex) { displayMessage("LoginData Lost", "No login data available any longer in the session:<br /> " + ex.getMessage()); } catch (UniformInterfaceException ex) { if (ex.getResponse().getStatus() == Response.Status.FORBIDDEN.getStatusCode()) { displayMessage("Corpus access forbidden", "You are not allowed to access this corpus. " + "Please login at the <a target=\"_blank\" href=\"" + Helper.getContext() + "\">main application</a> first and then reload this page."); } else { displayMessage("Service error", ex.getMessage()); } } catch (ClientHandlerException ex) { displayMessage("Could not generate the visualization because the ANNIS service reported an error.", ex.getMessage()); } catch (Throwable ex) { displayMessage("Could not generate the visualization.", ex.getMessage() == null ? ("An unknown error of type " + ex.getClass().getSimpleName()) + " occured." : ex.getMessage()); } }
From source file:com.demo.tutorial.agenda.ui.PersonList.java
public PersonList(MyUI app) { setSizeFull();/*from w w w.j a v a2 s . c o m*/ setContainerDataSource(app.getDataSource()); setVisibleColumns(PersonContainer.NATURAL_COL_ORDER); setColumnHeaders(PersonContainer.COL_HEADERS_ENGLISH); setColumnCollapsingAllowed(true); setColumnReorderingAllowed(true); addGeneratedColumn("codPost", new ColumnGenerator() { public Object generateCell(Table source, Object itemId, Object columnId) { Integer codPost = (Integer) getContainerProperty(itemId, "codPost").getValue(); return codPost; } }); addGeneratedColumn("email", new ColumnGenerator() { public Component generateCell(Table source, Object itemId, Object columnId) { String email = (String) getContainerProperty(itemId, "email").getValue(); Link l = new Link(); l.setResource(new ExternalResource("mailto:" + email)); l.setCaption(email); return l; } }); setSelectable(true); setImmediate(true); //NO PERMITE DE-SELECCIONAR UNA FILA setNullSelectionAllowed(false); addValueChangeListener((Property.ValueChangeListener) app); }
From source file:com.esofthead.mycollab.module.crm.view.lead.LeadTableDisplay.java
License:Open Source License
public LeadTableDisplay(String viewId, TableViewField requiredColumn, List<TableViewField> displayColumns) { super(ApplicationContextUtil.getSpringBean(LeadService.class), SimpleLead.class, viewId, requiredColumn, displayColumns);//from www . java2 s .c o m this.addGeneratedColumn("selected", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public Object generateCell(final Table source, final Object itemId, Object columnId) { final SimpleLead lead = LeadTableDisplay.this.getBeanByIndex(itemId); final CheckBoxDecor cb = new CheckBoxDecor("", lead.isSelected()); cb.setImmediate(true); cb.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { LeadTableDisplay.this.fireSelectItemEvent(lead); fireTableEvent(new TableClickEvent(LeadTableDisplay.this, lead, "selected")); } }); lead.setExtraData(cb); return cb; } }); this.addGeneratedColumn("leadName", new Table.ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { final SimpleLead lead = LeadTableDisplay.this.getBeanByIndex(itemId); LabelLink b = new LabelLink(lead.getLeadName(), CrmLinkBuilder.generateLeadPreviewLinkFull(lead.getId())); if ("Dead".equals(lead.getStatus()) || "Converted".equals(lead.getStatus())) { b.addStyleName(UIConstants.LINK_COMPLETED); } b.setDescription(CrmTooltipGenerator.generateTooltipLead(AppContext.getUserLocale(), lead, AppContext.getSiteUrl(), AppContext.getTimezone())); return b; } }); this.addGeneratedColumn("assignUserFullName", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleLead lead = LeadTableDisplay.this.getBeanByIndex(itemId); UserLink b = new UserLink(lead.getAssignuser(), lead.getAssignUserAvatarId(), lead.getAssignUserFullName()); return b; } }); this.addGeneratedColumn("email", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, Object itemId, Object columnId) { final SimpleLead lead = LeadTableDisplay.this.getBeanByIndex(itemId); Link l = new Link(); l.setResource(new ExternalResource("mailto:" + lead.getEmail())); l.setCaption(lead.getEmail()); return l; } }); this.addGeneratedColumn("website", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, Object itemId, Object columnId) { final SimpleLead lead = LeadTableDisplay.this.getBeanByIndex(itemId); if (lead.getWebsite() != null) { return new UrlLink(lead.getWebsite()); } else { return new Label(""); } } }); this.setWidth("100%"); }
From source file:com.esofthead.mycollab.vaadin.web.ui.field.UrlSocialNetworkLinkViewField.java
License:Open Source License
@Override protected Component initContent() { if (StringUtils.isBlank(caption)) { Label lbl = new Label(" "); lbl.setContentMode(ContentMode.HTML); lbl.setWidth("100%"); return lbl; } else {//w ww.j a va 2 s . com linkAccount = (linkAccount == null) ? "" : linkAccount; final Link link = new Link(); link.setResource(new ExternalResource(linkAccount)); link.setCaption(caption); link.setTargetName("_blank"); link.setWidth(UIConstants.DEFAULT_CONTROL_WIDTH); return link; } }
From source file:com.mycollab.module.crm.view.lead.LeadTableDisplay.java
License:Open Source License
public LeadTableDisplay(String viewId, TableViewField requiredColumn, List<TableViewField> displayColumns) { super(AppContextUtil.getSpringBean(LeadService.class), SimpleLead.class, viewId, requiredColumn, displayColumns);/* w w w . j a v a 2s .com*/ this.addGeneratedColumn("selected", (source, itemId, columnId) -> { final SimpleLead lead = getBeanByIndex(itemId); final CheckBoxDecor cb = new CheckBoxDecor("", lead.isSelected()); cb.setImmediate(true); cb.addValueChangeListener(valueChangeEvent -> { fireSelectItemEvent(lead); fireTableEvent(new TableClickEvent(LeadTableDisplay.this, lead, "selected")); }); lead.setExtraData(cb); return cb; }); this.addGeneratedColumn("leadName", (source, itemId, columnId) -> { final SimpleLead lead = getBeanByIndex(itemId); LabelLink b = new LabelLink(lead.getLeadName(), CrmLinkBuilder.generateLeadPreviewLinkFull(lead.getId())); if ("Dead".equals(lead.getStatus()) || "Converted".equals(lead.getStatus())) { b.addStyleName(WebThemes.LINK_COMPLETED); } b.setDescription(CrmTooltipGenerator.generateTooltipLead(UserUIContext.getUserLocale(), lead, MyCollabUI.getSiteUrl(), UserUIContext.getUserTimeZone())); return b; }); this.addGeneratedColumn("assignUserFullName", (source, itemId, columnId) -> { final SimpleLead lead = getBeanByIndex(itemId); return new UserLink(lead.getAssignuser(), lead.getAssignUserAvatarId(), lead.getAssignUserFullName()); }); this.addGeneratedColumn("email", (source, itemId, columnId) -> { final SimpleLead lead = getBeanByIndex(itemId); Link l = new Link(); l.setResource(new ExternalResource("mailto:" + lead.getEmail())); l.setCaption(lead.getEmail()); return l; }); this.addGeneratedColumn("status", (source, itemId, columnId) -> { final SimpleLead lead = getBeanByIndex(itemId); return ELabel.i18n(lead.getStatus(), LeadStatus.class); }); this.addGeneratedColumn("industry", (source, itemId, columnId) -> { final SimpleLead lead = getBeanByIndex(itemId); return ELabel.i18n(lead.getIndustry(), AccountIndustry.class); }); this.addGeneratedColumn("source", (source, itemId, columnId) -> { final SimpleLead lead = getBeanByIndex(itemId); return ELabel.i18n(lead.getSource(), OpportunityLeadSource.class); }); this.addGeneratedColumn("website", (source, itemId, columnId) -> { final SimpleLead lead = getBeanByIndex(itemId); if (lead.getWebsite() != null) { return new UrlLink(lead.getWebsite()); } else { return new Label(""); } }); this.setWidth("100%"); }
From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultRowEditingFormView.java
License:Apache License
private void updateDownloadLink(ContainerRow row, final ContainerBlob containerBlob, final FileMetadata metadata, Link link) { if (!containerBlob.isEmpty()) { StreamSource streamSource = containerBlob.getStreamSource(); String displayName = metadata.getCurrentDisplayname(row); String fileName = metadata.getCurrentFilename(row); String mimeType = metadata.getCurrentMimetype(row); StreamResource resource = new StreamResource(streamSource, fileName); resource.setMIMEType(mimeType);//from w ww . ja v a 2 s .c o m link.setVisible(true); link.setTargetName("_blank"); link.setCaption(displayName); link.setResource(resource); } }
From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.ui.BLobColumnGenerator.java
License:Apache License
private Link buildBlobLink(ContainerRow row, String columnId, ContainerBlob containerBlob) { StreamSource streamSource = containerBlob.getStreamSource(); FileMetadata metadata = columns.get(columnId).getFileMetadata(); StreamResource resource = new StreamResource(streamSource, metadata.getFileName()); String fileName = metadata.getCurrentDisplayname(row); String mimeType = metadata.getCurrentMimetype(row); resource.setMIMEType(mimeType);/* www . j a v a 2 s . c o m*/ Link link = new Link(); link.setCaption(fileName); link.setResource(resource); link.setTargetName("_blank"); return link; }
From source file:fi.vtt.RVaadin.RContainer.java
License:Apache License
/** * Get a Vaadin Link object associated with a file in the R working * directory./*from w w w. j ava2 s.c o m*/ * * @param linkCaption * @param filename * @return Vaadin link object */ public Link getDownloadLink(String linkCaption, String filename) { Link link = new Link(); /* Open the link in a new window */ link.setTargetName("_blank"); link.setCaption(linkCaption); link.setResource(getDownloadResource(filename)); return link; }
From source file:fr.amapj.view.engine.tools.table.complex.ComplexTableBuilder.java
License:Open Source License
private Link createLink(String msg, int taille, ToGenerator<T> generator, T t) { Link l = LinkCreator.createLink(generator.getGenerator(t)); l.setCaption(msg); l.addStyleName("align-center"); l.setWidth(taille + "px"); l.setImmediate(true);//from w ww . ja v a 2 s.co m return l; }
From source file:fr.amapj.view.views.editionspe.bulletinadhesion.BulletinAdhesionEditorPart.java
License:Open Source License
private void addFieldTest() { // Titre/*from www.j a va2 s.co m*/ setStepTitle("tester le bulletin d'adhsion"); // Searcher s = addSearcher("Priode de cotisation qui servira pour tester", "idPeriodeCotisation", SearcherList.PERIODE_COTISATION, null); s.setBuffered(false); // Link link = LinkCreator.createLink(new PGBulletinAdhesion(null, null, etiquetteDTO)); link.setCaption("Cliquer ici pour tester cette dition"); form.addComponent(link); }