List of usage examples for com.vaadin.ui Link setTargetName
public void setTargetName(String targetName)
From source file:annis.gui.AboutWindow.java
License:Apache License
public AboutWindow() { setSizeFull();//from w w w. j ava 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 ww w . j a va2 s .com*/ // 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();//w ww . ja va2 s .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.constellio.app.ui.pages.base.MainLayoutImpl.java
protected Component buildFooter() { Link poweredByConstellioLink = new Link( $("MainLayout.footerAlt") + " (" + presenter.getCurrentVersion() + ")", new ExternalResource("http://www.constellio.com")); poweredByConstellioLink.setTargetName("_blank"); poweredByConstellioLink.addStyleName(ValoTheme.LINK_LARGE); poweredByConstellioLink.addStyleName("footer"); return poweredByConstellioLink; }
From source file:com.esofthead.mycollab.shell.view.MainView.java
License:Open Source License
private CustomLayout createFooter() { final CustomLayout footer = CustomLayoutExt.createLayout("footer"); Link companyLink = new Link("eSoftHead", new ExternalResource("http://www.esofthead.com")); companyLink.setTargetName("_blank"); footer.addComponent(companyLink, "company-url"); Calendar currentCal = Calendar.getInstance(); Label currentYear = new Label(String.valueOf(currentCal.get(Calendar.YEAR))); currentYear.setSizeUndefined();/* w w w . jav a2 s . c o m*/ footer.addComponent(currentYear, "current-year"); HorizontalLayout footerRight = new HorizontalLayout(); footerRight.setSpacing(true); final Button sendFeedback = new Button("Feedback"); sendFeedback.setStyleName("link"); sendFeedback.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { UI.getCurrent().addWindow(new FeedbackWindow()); } }); Link blogLink = new Link("Blog", new ExternalResource("https://www.mycollab.com/blog")); blogLink.setTargetName("_blank"); Link forumLink = new Link("Forum", new ExternalResource("http://forum.mycollab.com")); forumLink.setTargetName("_blank"); Link wikiLink = new Link("Knowledge Base", new ExternalResource("https://www.mycollab.com/help/")); wikiLink.setTargetName("_blank"); footerRight.addComponent(blogLink); footerRight.addComponent(forumLink); footerRight.addComponent(wikiLink); footerRight.addComponent(sendFeedback); footer.addComponent(footerRight, "footer-right"); return footer; }
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 {// ww w .j ava 2s .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.expressui.core.MainApplication.java
License:Open Source License
@Override public void init() { currentInstance.set(this); setTheme(getCustomTheme());/*w w w .ja v a2 s . c om*/ customizeConfirmDialogStyle(); Window mainWindow = new Window(); setMainWindow(mainWindow); mainWindow.addStyleName("e-main-window"); mainWindow.setCaption(getTypeCaption()); VerticalLayout mainLayout = new VerticalLayout(); String id = StringUtil.generateDebugId("e", this, mainLayout, "mainLayout"); mainLayout.setDebugId(id); mainWindow.setSizeFull(); mainLayout.setSizeFull(); mainWindow.setContent(mainLayout); setLogoutURL(getApplicationProperties().getRestartApplicationUrl()); configureLeftMenuBar(mainMenuBar.getLeftMenuBarRoot()); configureRightMenuBar(mainMenuBar.getRightMenuBarRoot()); mainLayout.addComponent(mainMenuBar); pageLayoutTabSheet = new TabSheet(); id = StringUtil.generateDebugId("e", this, pageLayoutTabSheet, "pageLayoutTabSheet"); pageLayoutTabSheet.setDebugId(id); pageLayoutTabSheet.addStyleName("e-main-page-layout"); pageLayoutTabSheet.setSizeFull(); mainLayout.addComponent(pageLayoutTabSheet); mainLayout.setExpandRatio(pageLayoutTabSheet, 1.0f); Link expressUILink = new Link(uiMessageSource.getMessage("mainApplication.footerMessage"), new ExternalResource(uiMessageSource.getMessage("mainApplication.footerLink"))); expressUILink.setTargetName("_blank"); expressUILink.setIcon(new ThemeResource("../expressui/favicon.png")); expressUILink.setSizeUndefined(); mainLayout.addComponent(expressUILink); mainLayout.setComponentAlignment(expressUILink, Alignment.TOP_CENTER); configureSessionTimeout(mainWindow); postWire(); onDisplay(); }
From source file:com.github.daytron.twaattin.ui.tabledecorator.ScreenNameColumnGenerator.java
License:Open Source License
/** * @param source//from ww w .j a v a 2 s . co m * @param itemId * @param columnId * @return Screen name of the underlying {@link User} as a {@link Link} * component. */ @Override public Object generateCell(Table source, Object itemId, Object columnId) { User user = getUser(source, itemId); ExternalResource resource = new ExternalResource(TWITTER_USER_URL + user.getScreenName()); Link link = new Link('@' + user.getScreenName(), resource); link.setTargetName("screenname"); return link; }
From source file:com.github.daytron.twaattin.ui.tabledecorator.SourceColumnDecorator.java
License:Open Source License
/** * @return Source of the tweet as a {@link Link} component. *//*from w w w . ja v a 2s . c o m*/ @Override public Object generateCell(Table source, Object itemId, Object columnId) { Item item = source.getItem(itemId); @SuppressWarnings("unchecked") Property<String> property = item.getItemProperty(columnId); Document document = Jsoup.parseBodyFragment(property.getValue()); Elements elements = document.getElementsByTag("a"); if (elements.size() > 0) { Element element = elements.get(0); String text = element.text(); String url = element.absUrl("href"); ExternalResource resource = new ExternalResource(url); Link link = new Link(text, resource); link.setTargetName("source"); return link; } return null; }
From source file:com.klwork.explorer.ui.business.social.QQWeiboDisplayPage.java
License:Apache License
/** * ?/* ww w . ja va2s .c om*/ * @param userWeibo * @return */ public Link initUserScreenName(final SocialUserWeibo userWeibo) { Link goToMain = new Link(userWeibo.getUserScreenName() + ":", new ExternalResource(getWeiboMainUrl() + userWeibo.getUserName())); goToMain.setTargetName("_blank"); return goToMain; }