List of usage examples for com.vaadin.ui Link setIcon
@Override public void setIcon(Resource icon)
From source file:annis.gui.AboutWindow.java
License:Apache License
public AboutWindow() { setSizeFull();//from w ww .j a va2s . c om 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 w w w .j a v a 2s. c o 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 . j a va 2 s .c om 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.cavisson.gui.dashboard.components.controls.ButtonsAndLinks.java
License:Apache License
/** * *///from w w w. ja v a 2 s. co m public ButtonsAndLinks() { setMargin(true); Label h1 = new Label("Buttons"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); Button button = new Button("Normal"); row.addComponent(button); button = new Button("Disabled"); button.setEnabled(false); row.addComponent(button); button = new Button("Primary"); button.addStyleName("primary"); row.addComponent(button); button = new Button("Friendly"); button.addStyleName("friendly"); row.addComponent(button); button = new Button("Danger"); button.addStyleName("danger"); row.addComponent(button); TestIcon testIcon = new TestIcon(10); button = new Button("Small"); button.addStyleName("small"); button.setIcon(testIcon.get()); row.addComponent(button); button = new Button("Large"); button.addStyleName("large"); button.setIcon(testIcon.get()); row.addComponent(button); button = new Button("Top"); button.addStyleName("icon-align-top"); button.setIcon(testIcon.get()); row.addComponent(button); button = new Button("Image icon"); button.setIcon(testIcon.get(true, 16)); row.addComponent(button); button = new Button("Image icon"); button.addStyleName("icon-align-right"); button.setIcon(testIcon.get(true)); row.addComponent(button); button = new Button("Photos"); button.setIcon(testIcon.get()); row.addComponent(button); button = new Button(); button.setIcon(testIcon.get()); button.addStyleName("icon-only"); row.addComponent(button); button = new Button("Borderless"); button.setIcon(testIcon.get()); button.addStyleName("borderless"); row.addComponent(button); button = new Button("Borderless, colored"); button.setIcon(testIcon.get()); button.addStyleName("borderless-colored"); row.addComponent(button); button = new Button("Quiet"); button.setIcon(testIcon.get()); button.addStyleName("quiet"); row.addComponent(button); button = new Button("Link style"); button.setIcon(testIcon.get()); button.addStyleName("link"); row.addComponent(button); button = new Button("Icon on right"); button.setIcon(testIcon.get()); button.addStyleName("icon-align-right"); row.addComponent(button); CssLayout group = new CssLayout(); group.addStyleName("v-component-group"); row.addComponent(group); button = new Button("One"); group.addComponent(button); button = new Button("Two"); group.addComponent(button); button = new Button("Three"); group.addComponent(button); button = new Button("Tiny"); button.addStyleName("tiny"); row.addComponent(button); button = new Button("Huge"); button.addStyleName("huge"); row.addComponent(button); NativeButton nbutton = new NativeButton("Native"); row.addComponent(nbutton); h1 = new Label("Links"); h1.addStyleName("h1"); addComponent(h1); row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); Link link = new Link("vaadin.com", new ExternalResource("https://vaadin.com")); row.addComponent(link); link = new Link("Link with icon", new ExternalResource("https://vaadin.com")); link.addStyleName("color3"); link.setIcon(testIcon.get()); row.addComponent(link); link = new Link("Small", new ExternalResource("https://vaadin.com")); link.addStyleName("small"); row.addComponent(link); link = new Link("Large", new ExternalResource("https://vaadin.com")); link.addStyleName("large"); row.addComponent(link); link = new Link(null, new ExternalResource("https://vaadin.com")); link.setIcon(testIcon.get()); link.addStyleName("large"); row.addComponent(link); }
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 a v a2 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.expressui.core.MainApplication.java
License:Open Source License
@Override public void init() { currentInstance.set(this); setTheme(getCustomTheme());//w ww .ja va 2 s . c o m 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.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) { // // }/* ww w . j av a 2 s . 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.hack23.cia.web.impl.ui.application.views.common.pagelinks.impl.PageLinkFactoryImpl.java
License:Apache License
@Override public Link createMainViewPageLink() { final Link pageLink = new Link(MAIN_VIEW_LINK_TEXT, new ExternalResource(LINK_SEPARATOR + CommonsViews.MAIN_VIEW_NAME)); pageLink.setId(ViewAction.VISIT_MAIN_VIEW.name()); pageLink.setIcon(FontAwesome.STAR); return pageLink; }
From source file:com.hack23.cia.web.impl.ui.application.views.common.pagelinks.impl.PageLinkFactoryImpl.java
License:Apache License
@Override public Link createRegisterPageLink() { final Link pageLink = new Link("Register", new ExternalResource( LINK_SEPARATOR + CommonsViews.MAIN_VIEW_NAME + PAGE_SEPARATOR + ApplicationPageMode.REGISTER)); pageLink.setId(ViewAction.VISIT_REGISTER.name()); pageLink.setIcon(FontAwesome.USER_PLUS); return pageLink; }
From source file:com.hack23.cia.web.impl.ui.application.views.common.pagelinks.impl.PageLinkFactoryImpl.java
License:Apache License
@Override public Link createLoginPageLink() { final Link pageLink = new Link("Login", new ExternalResource( LINK_SEPARATOR + CommonsViews.MAIN_VIEW_NAME + PAGE_SEPARATOR + ApplicationPageMode.LOGIN)); pageLink.setId(ViewAction.VISIT_LOGIN.name()); pageLink.setIcon(FontAwesome.SIGN_IN); return pageLink; }