Example usage for com.vaadin.ui Link Link

List of usage examples for com.vaadin.ui Link Link

Introduction

In this page you can find the example usage for com.vaadin.ui Link Link.

Prototype

public Link() 

Source Link

Document

Creates a new link.

Usage

From source file:org.vaadin.addon.leaflet.demoandtestapp.util.TListUi.java

License:Apache License

private void loadTestClasses(TListUi aThis) {
    if (testClassess != null) {
        return;/* w w  w .j  a va  2  s  .  com*/
    }
    testClassess = listTestClasses();
    Table table = new Table("Test cases", testClassess);
    table.addGeneratedColumn("name", new Table.ColumnGenerator() {
        public Object generateCell(Table source, Object itemId, Object columnId) {
            String name = (String) source.getItem(itemId).getItemProperty(columnId).getValue();
            Link link = new Link();
            link.setResource(new ExternalResource("/" + name));
            link.setCaption(name);
            link.setTargetName("_new");
            return link;
        }
    });
    table.addGeneratedColumn("description", new Table.ColumnGenerator() {
        public Object generateCell(Table source, Object itemId, Object columnId) {
            String description = (String) source.getItem(itemId).getItemProperty(columnId).getValue();
            return new Label(description);
        }
    });
    table.setSizeFull();
    table.setColumnExpandRatio("description", 1);
    setContent(table);
}

From source file:org.vaadin.addon.levelindicator.demoandtestapp.TListUi.java

License:Apache License

private void loadTestClasses(TListUi aThis) {
    if (testClassess != null) {
        return;/*from  ww  w  .j  ava2s  .c  om*/
    }
    testClassess = listTestClasses();
    Table table = new Table("Test cases", testClassess);
    table.addGeneratedColumn("name", new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            String name = (String) source.getItem(itemId).getItemProperty(columnId).getValue();
            Link link = new Link();
            link.setResource(new ExternalResource("/" + name));
            link.setCaption(name);
            link.setTargetName("_new");
            return link;
        }
    });
    table.addGeneratedColumn("description", new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            String description = (String) source.getItem(itemId).getItemProperty(columnId).getValue();
            return new Label(description);
        }
    });
    table.setSizeFull();
    table.setColumnExpandRatio("description", 1);
    setContent(table);
}

From source file:org.vaadin.addon.touchkitstuff.demoandtestapp.TListUi.java

License:Apache License

private void loadTestClasses(TListUi aThis) {
    if (testClassess != null) {
        return;/*w  ww.jav a 2s.  c  o  m*/
    }
    testClassess = listTestClasses();
    Table table = new Table("Test cases", testClassess);
    table.addGeneratedColumn("name", new Table.ColumnGenerator() {
        public Object generateCell(Table source, Object itemId, Object columnId) {
            String name = (String) source.getItem(itemId).getItemProperty(columnId).getValue();
            Link link = new Link();
            link.setResource(new ExternalResource("/" + name));
            link.setCaption(name);
            link.setTargetName("_new");
            return link;
        }
    });
    table.addGeneratedColumn("description", new Table.ColumnGenerator() {
        public Object generateCell(Table source, Object itemId, Object columnId) {
            String description = (String) source.getItem(itemId).getItemProperty(columnId).getValue();
            return new Label(description);
        }
    });
    table.setSizeFull();
    table.setColumnExpandRatio("description", 1);
    VerticalLayout verticalLayout = new VerticalLayout();
    TextField filter = new TextField();
    filter.addTextChangeListener(new TextChangeListener() {
        @Override
        public void textChange(TextChangeEvent event) {
            String text = event.getText();
            testClassess.removeAllContainerFilters();
            testClassess.addContainerFilter("name", text, true, false);
        }
    });
    verticalLayout.addComponent(filter);
    filter.focus();
    verticalLayout.addComponent(table);
    setContent(verticalLayout);
}

From source file:org.vaadin.addonhelpers.TListUi.java

License:Apache License

private void loadTestClasses(TListUi aThis) {
    if (testClassess != null) {
        return;/*from w  w w  .  j  a v  a  2 s. c o  m*/
    }
    testClassess = listTestClasses();
    Table table = new Table("Test cases", testClassess);
    table.setVisibleColumns("name", "description");
    table.addGeneratedColumn("name", new Table.ColumnGenerator() {
        public Object generateCell(Table source, Object itemId, Object columnId) {
            String name = (String) source.getItem(itemId).getItemProperty(columnId).getValue();
            Class clazz = (Class) source.getItem(itemId).getItemProperty("clazz").getValue();
            Link link = new Link();
            link.setResource(new ExternalResource("/" + clazz.getName()));
            link.setCaption(name);
            link.setTargetName("_new");
            return link;
        }
    });
    table.addGeneratedColumn("description", new Table.ColumnGenerator() {
        public Object generateCell(Table source, Object itemId, Object columnId) {
            String description = (String) source.getItem(itemId).getItemProperty(columnId).getValue();
            return new Label(description);
        }
    });
    table.setSizeFull();
    table.setColumnExpandRatio("description", 1);
    VerticalLayout verticalLayout = new VerticalLayout();
    TextField filter = new TextField();
    filter.setInputPrompt("Filter list");
    filter.addTextChangeListener(new TextChangeListener() {
        @Override
        public void textChange(TextChangeEvent event) {
            String text = event.getText();
            testClassess.removeAllContainerFilters();
            testClassess.addContainerFilter("name", text, true, false);
        }
    });
    verticalLayout.addComponent(filter);
    filter.focus();
    verticalLayout.addComponent(table);
    verticalLayout.setSizeFull();
    verticalLayout.setExpandRatio(table, 1);
    verticalLayout.setMargin(true);
    setContent(verticalLayout);
}

From source file:ru.codeinside.gses.activiti.ftarchive.AttachmentField.java

License:Mozilla Public License

Component createDownloadLink(final FileValue fileValue) {
    final Link result = new Link();
    result.setCaption(fileValue.getFileName());
    result.setTargetName("_top");
    result.setImmediate(true);/*from   w ww.  j av a  2  s .com*/
    result.setDescription("");
    StreamResource.StreamSource streamSource = new StreamResource.StreamSource() {
        public InputStream getStream() {
            return new ByteArrayInputStream(fileValue.getContent());
        }
    };
    StreamResource resource = new StreamResource(streamSource, fileValue.getFileName(), Flash.app()) {
        public DownloadStream getStream() {
            final StreamSource ss = getStreamSource();
            if (ss == null) {
                return null;
            }
            final DownloadStream ds = new DownloadStream(ss.getStream(), getMIMEType(), getFilename());
            ds.setCacheTime(0);
            try {
                WebBrowser browser = (WebBrowser) result.getWindow().getTerminal();
                if (browser.isIE()) {
                    URI uri = new URI(null, null, fileValue.getFileName(), null);
                    ds.setParameter("Content-Disposition", "attachment; filename=" + uri.toASCIIString());
                } else {
                    ds.setParameter("Content-Disposition", "attachment; filename=\""
                            + MimeUtility.encodeWord(fileValue.getFileName(), "utf-8", "Q") + "\"");
                }
            } catch (Exception e) {
                ds.setParameter("Content-Disposition", "attachment; filename=" + fileValue.getFileName());
            }
            return ds;
        }
    };
    resource.setMIMEType(fileValue.getMimeType());
    result.setResource(resource);
    return result;
}

From source file:ru.codeinside.gses.webui.utils.Components.java

License:Mozilla Public License

@Deprecated
public static Link createAttachShowButton(final FileValue attachment, final Application appl) {
    if (attachment == null) {
        return null;
    }/*from   w w  w .  jav  a2 s. c o m*/
    final Link result = new Link();
    result.setCaption(attachment.getFileName());
    result.setTargetName("_top");
    result.setImmediate(true);
    //String description = attachment.getDescription();
    result.setDescription("");
    StreamSource streamSource = new StreamSource() {

        private static final long serialVersionUID = 456334952891567271L;

        public InputStream getStream() {
            return new ByteArrayInputStream(attachment.getContent());
        }
    };
    StreamResource resource = new StreamResource(streamSource, attachment.getFileName(), appl) {

        private static final long serialVersionUID = -3869546661105572851L;

        public DownloadStream getStream() {
            final StreamSource ss = getStreamSource();
            if (ss == null) {
                return null;
            }
            final DownloadStream ds = new DownloadStream(ss.getStream(), getMIMEType(), getFilename());
            ds.setBufferSize(getBufferSize());
            ds.setCacheTime(0);
            try {
                WebBrowser browser = (WebBrowser) result.getWindow().getTerminal();
                if (browser.isIE()) {
                    URI uri = new URI(null, null, attachment.getFileName(), null);
                    ds.setParameter("Content-Disposition", "attachment; filename=" + uri.toASCIIString());
                } else {
                    ds.setParameter("Content-Disposition", "attachment; filename=\""
                            + MimeUtility.encodeWord(attachment.getFileName(), "utf-8", "Q") + "\"");
                }
            } catch (Exception e) {
                ds.setParameter("Content-Disposition", "attachment; filename=" + attachment.getFileName());
            }
            return ds;
        }
    };
    String type = attachment.getMimeType();
    if (type != null) {
        resource.setMIMEType(type);
    }
    result.setResource(resource);
    return result;
}