List of usage examples for com.vaadin.ui Link Link
public Link()
From source file:annis.gui.AboutWindow.java
License:Apache License
public AboutWindow() { setSizeFull();//www. j a v a 2 s. c o m layout = new VerticalLayout(); setContent(layout); layout.setSizeFull(); layout.setMargin(true); HorizontalLayout hLayout = new HorizontalLayout(); Embedded logoAnnis = new Embedded(); logoAnnis.setSource(new ThemeResource("images/annis-logo-128.png")); logoAnnis.setType(Embedded.TYPE_IMAGE); hLayout.addComponent(logoAnnis); Embedded logoSfb = new Embedded(); logoSfb.setSource(new ThemeResource("images/sfb-logo.jpg")); logoSfb.setType(Embedded.TYPE_IMAGE); hLayout.addComponent(logoSfb); Link lnkFork = new Link(); lnkFork.setResource(new ExternalResource("https://github.com/korpling/ANNIS")); lnkFork.setIcon( new ExternalResource("https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png")); lnkFork.setTargetName("_blank"); hLayout.addComponent(lnkFork); hLayout.setComponentAlignment(logoAnnis, Alignment.MIDDLE_LEFT); hLayout.setComponentAlignment(logoSfb, Alignment.MIDDLE_RIGHT); hLayout.setComponentAlignment(lnkFork, Alignment.TOP_RIGHT); layout.addComponent(hLayout); layout.addComponent(new Label( "ANNIS is a project of the " + "<a href=\"http://www.sfb632.uni-potsdam.de/\">SFB632</a>.", Label.CONTENT_XHTML)); layout.addComponent(new Label("Homepage: " + "<a href=\"http://corpus-tools.org/annis/\">" + "http://corpus-tools.org/annis/</a>.", Label.CONTENT_XHTML)); layout.addComponent(new Label("Version: " + VersionInfo.getVersion())); layout.addComponent(new Label("Vaadin-Version: " + Version.getFullVersion())); TextArea txtThirdParty = new TextArea(); txtThirdParty.setSizeFull(); StringBuilder sb = new StringBuilder(); sb.append("The ANNIS team wants to thank these third party software that " + "made the ANNIS GUI possible:\n"); File thirdPartyFolder = new File(VaadinService.getCurrent().getBaseDirectory(), "THIRD-PARTY"); if (thirdPartyFolder.isDirectory()) { for (File c : thirdPartyFolder.listFiles((FileFilter) new WildcardFileFilter("*.txt"))) { if (c.isFile()) { try { sb.append(FileUtils.readFileToString(c)).append("\n"); } catch (IOException ex) { log.error("Could not read file", ex); } } } } txtThirdParty.setValue(sb.toString()); txtThirdParty.setReadOnly(true); txtThirdParty.addStyleName("shared-text"); txtThirdParty.setWordwrap(false); layout.addComponent(txtThirdParty); btClose = new Button("Close"); final AboutWindow finalThis = this; btClose.addClickListener(new OkClickListener(finalThis)); layout.addComponent(btClose); layout.setComponentAlignment(hLayout, Alignment.MIDDLE_CENTER); layout.setComponentAlignment(btClose, Alignment.MIDDLE_CENTER); layout.setExpandRatio(txtThirdParty, 1.0f); }
From source file:annis.gui.EmbeddedVisUI.java
License:Apache License
private void generateVisFromRemoteURL(final String visName, final String rawUri, Map<String, String[]> args) { try {//from www . j a v a 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:annis.gui.HelpUsWindow.java
License:Apache License
public HelpUsWindow() { setSizeFull();//from w w w . java 2s . c o m layout = new VerticalLayout(); setContent(layout); layout.setSizeFull(); layout.setMargin(new MarginInfo(false, false, true, false)); HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setSizeFull(); hLayout.setMargin(false); VerticalLayout labelLayout = new VerticalLayout(); labelLayout.setMargin(true); labelLayout.setSizeFull(); Label lblOpenSource = new Label(); lblOpenSource.setValue("<h1>ANNIS is <a href=\"http://opensource.org/osd\">Open Source</a> " + "software.</h1>" + "<p>This means you are free to download the source code and add new " + "features or make other adjustments to ANNIS on your own.<p/>" + "Here are some examples how you can help ANNIS:" + "<ul>" + "<li>Fix or report problems (bugs) you encounter when using the ANNIS software.</li>" + "<li>Add new features.</li>" + "<li>Enhance the documentation</li>" + "</ul>" + "<p>Feel free to visit our GitHub page for more information: <a href=\"https://github.com/korpling/ANNIS\" target=\"_blank\">https://github.com/korpling/ANNIS</a></p>"); lblOpenSource.setContentMode(ContentMode.HTML); lblOpenSource.setStyleName("opensource"); lblOpenSource.setWidth("100%"); lblOpenSource.setHeight("-1px"); labelLayout.addComponent(lblOpenSource); Link lnkFork = new Link(); lnkFork.setResource(new ExternalResource("https://github.com/korpling/ANNIS")); lnkFork.setIcon( new ExternalResource("https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png")); lnkFork.setTargetName("_blank"); hLayout.addComponent(labelLayout); hLayout.addComponent(lnkFork); hLayout.setComponentAlignment(labelLayout, Alignment.TOP_LEFT); hLayout.setComponentAlignment(lnkFork, Alignment.TOP_RIGHT); hLayout.setExpandRatio(labelLayout, 1.0f); layout.addComponent(hLayout); final HelpUsWindow finalThis = this; btClose = new Button("Close"); btClose.addClickListener(new OkClickListener(finalThis)); layout.addComponent(btClose); layout.setComponentAlignment(hLayout, Alignment.MIDDLE_CENTER); layout.setComponentAlignment(btClose, Alignment.MIDDLE_CENTER); layout.setExpandRatio(hLayout, 1.0f); }
From source file:com.cms.ui.PopupImportFileUI.java
public PopupImportFileUI() { mainLayout.setImmediate(true);/*from w w w . ja v a 2 s . c om*/ mainLayout.setCaption(BundleUtils.getString("title.choseFile")); mainLayout.setWidth("100%"); mainLayout.setHeight("-1px"); mainLayout.setMargin(true); mainLayout.setSpacing(true); mainLayout.setStyleName("main-popup"); setWidth("30.0%"); setHeight("-1px"); setModal(true); gridLayout = new GridLayout(); // gridLayout.setCaption(MakeURL.makeURLForGrid(BundleUtils.getString("stone.label.search.info"))); // gridLayout.setCaptionAsHtml(true); gridLayout.setImmediate(false); gridLayout.setWidth("100.0%"); gridLayout.setHeight("-1px"); gridLayout.setMargin(true); gridLayout.setSpacing(true); gridLayout.setColumns(2); gridLayout.setRows(5); gridLayout.setStyleName("custom-feildset"); uploadFile = new Upload(); uploadFile.setImmediate(false); uploadFile.setWidth("100.0%"); uploadFile.setHeight("-1px"); gridLayout.addComponent(uploadFile, 0, 0); linkTemplate = new Link(); linkTemplate.setCaption("Ti file biu mu"); linkTemplate.setImmediate(false); linkTemplate.setWidth("100%"); linkTemplate.setHeight("-1px"); gridLayout.addComponent(linkTemplate, 0, 1); mainLayout.addComponent(gridLayout); setContent(mainLayout); }
From source file:com.demo.tutorial.agenda.ui.PersonList.java
public PersonList(MyUI app) { setSizeFull();//w ww.j av a 2 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 .j a va 2s . 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.AttachmentDisplayComponent.java
License:Open Source License
public void addAttachmentRow(final Content attachment) { String docName = attachment.getPath(); int lastIndex = docName.lastIndexOf("/"); if (lastIndex != -1) { docName = docName.substring(lastIndex + 1, docName.length()); }//from w ww. j av a 2 s .c o m final AbsoluteLayout attachmentLayout = new AbsoluteLayout(); attachmentLayout.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH); attachmentLayout.setHeight(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_HEIGHT); attachmentLayout.setStyleName("attachment-block"); CssLayout thumbnailWrap = new CssLayout(); thumbnailWrap.setSizeFull(); thumbnailWrap.setStyleName("thumbnail-wrap"); Link thumbnail = new Link(); if (StringUtils.isBlank(attachment.getThumbnail())) { thumbnail.setIcon(FileAssetsUtil.getFileIconResource(attachment.getName())); } else { thumbnail.setIcon(VaadinResourceFactory.getInstance().getResource(attachment.getThumbnail())); } if (MimeTypesUtil.isImageType(docName)) { thumbnail.setResource(VaadinResourceFactory.getInstance().getResource(attachment.getPath())); new Fancybox(thumbnail).setPadding(0).setVersion("2.1.5").setEnabled(true).setDebug(true); } Div contentTooltip = new Div().appendChild(new Span().appendText(docName).setStyle("font-weight:bold")); Ul ul = new Ul() .appendChild(new Li().appendText("Size: " + FileUtils.getVolumeDisplay(attachment.getSize()))) .setStyle("line-height:1.5em"); ul.appendChild(new Li().appendText( "Last modified: " + AppContext.formatPrettyTime(attachment.getLastModified().getTime()))); contentTooltip.appendChild(ul); thumbnail.setDescription(contentTooltip.write()); thumbnail.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH); thumbnailWrap.addComponent(thumbnail); attachmentLayout.addComponent(thumbnailWrap, "top: 0px; left: 0px; bottom: 0px; right: 0px; z-index: 0;"); CssLayout attachmentNameWrap = new CssLayout(); attachmentNameWrap.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH); attachmentNameWrap.setStyleName("attachment-name-wrap"); Label attachmentName = new Label(StringUtils.trim(docName, 60, true)); attachmentName.setStyleName("attachment-name"); attachmentNameWrap.addComponent(attachmentName); attachmentLayout.addComponent(attachmentNameWrap, "bottom: 0px; left: 0px; right: 0px; z-index: 1;"); Button trashBtn = new Button(null, new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { ConfirmDialogExt.show(UI.getCurrent(), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, AppContext.getSiteName()), AppContext.getMessage(GenericI18Enum.CONFIRM_DELETE_ATTACHMENT), AppContext.getMessage(GenericI18Enum.BUTTON_YES), AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() { private static final long serialVersionUID = 1L; @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { ResourceService attachmentService = AppContextUtil .getSpringBean(ResourceService.class); attachmentService.removeResource(attachment.getPath(), AppContext.getUsername(), AppContext.getAccountId()); ((ComponentContainer) attachmentLayout.getParent()) .removeComponent(attachmentLayout); } } }); } }); trashBtn.setIcon(FontAwesome.TRASH_O); trashBtn.setStyleName("attachment-control"); attachmentLayout.addComponent(trashBtn, "top: 9px; left: 9px; z-index: 1;"); Button downloadBtn = new Button(); FileDownloader fileDownloader = new FileDownloader( VaadinResourceFactory.getInstance().getStreamResource(attachment.getPath())); fileDownloader.extend(downloadBtn); downloadBtn.setIcon(FontAwesome.DOWNLOAD); downloadBtn.setStyleName("attachment-control"); attachmentLayout.addComponent(downloadBtn, "right: 9px; top: 9px; z-index: 1;"); this.addComponent(attachmentLayout); }
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 {//from ww w. ja v a2s . c o m 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.foc.vaadin.FocWebVaadinWindow.java
License:Apache License
protected Component newLogoEmbedded() { // Button iconButton = new Button(); // setStyleName(BaseTheme.BUTTON_LINK); // iconButton.addClickListener(new ClickListener() { // @Override // public void buttonClick(ClickEvent event) { // // }/*from w w w . ja v a 2s .c o m*/ // }); // iconButton.setIcon(new ThemeResource("img/logo.png")); // iconButton.addStyleName("foc-UpperLogo"); // return iconButton; Link iconLink = new Link(); // iconLink.setIcon(new ThemeResource("img/everpro_logo.png")); iconLink.setIcon(new ThemeResource("img/logo.png")); String logoURL = getLogoURL(); if (logoURL != null) { iconLink.setResource(new ExternalResource(logoURL)); } // iconLink.setStyleName("everproLogo"); iconLink.setStyleName("foc-UpperLogo"); return iconLink; }
From source file:com.github.daytron.twaattin.ui.LoginScreen.java
License:Open Source License
public LoginScreen() { this.twitterLink = new Link(); this.pinField = new TextField(); this.submitButton = new Button("Submit"); setMargin(true);/* w w w . j a v a 2 s . c om*/ setSpacing(true); try { twitterLink.setCaption("Get PIN"); twitterLink.setTargetName("twitterauth"); twitterLink.setResource(new ExternalResource(TwitterService.get().getAuthenticationUrl())); pinField.setInputPrompt("PIN"); addComponent(twitterLink); addComponent(pinField); addComponent(submitButton); submitButton.addClickListener(new LoginBehaviour(pinField)); } catch (TwitterException ex) { Logger.getLogger(LoginScreen.class.getName()).log(Level.SEVERE, null, ex); throw new InstantiationError(); } }