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(String caption, Resource resource, String targetName, int width, int height, BorderStyle border) 

Source Link

Document

Creates a new instance of Link that opens a new window.

Usage

From source file:cirad.cgh.vcf2fasta.view.Vcf2fastaForm.java

License:Open Source License

public void drawResult(List<String[]> links) {
    for (String[] link : links) {
        Link section1Down = new Link(link[0], new ExternalResource(link[1]), "_blank", 0, 0, null);
        section1Down.addStyleName("colored");
        resultLayout.addComponent(section1Down);
    }//from  w ww.  j  ava  2s . c o m
}

From source file:com.ocs.dynamo.ui.component.URLField.java

License:Apache License

/**
 * Updates the field value - renders a clickable URL if the field value is not empty
 * /* www . j  av a 2s  .  co  m*/
 * @param value
 */
private void updateLink(String value) {
    if (bar != null) {
        bar.removeAllComponents();
        if (!StringUtils.isEmpty(value)) {
            String temp = StringUtil.prependProtocol(value);
            link = new Link(temp, new ExternalResource(temp), "_blank", 0, 0, BorderStyle.DEFAULT);
            bar.addComponent(link);
        } else {
            link = null;
        }
    }
}

From source file:nl.amc.biolab.nsg.display.component.ProcessingStatusForm.java

License:Open Source License

private void createSubmissionButtons(final VaadinTestApplication app, final SubmissionIO submissionIO,
        final nl.amc.biolab.datamodel.objects.Error error) {
    final Link statusLink = new Link("download", new StreamResource(new StreamSource() {
        private static final long serialVersionUID = 2010850543250392280L;

        public InputStream getStream() {
            String status;//from  w  ww.ja  v a 2 s  .  co m
            if (error != null) {
                status = error.getCode() + "\n" + error.getMessage() + "\n" + error.getDescription();
            } else {
                status = "No message";
            }
            return new ByteArrayInputStream(status.getBytes());
        }
    }, "status", getApplication()), "", 400, 300, 2);

    viewStatusButton = new NativeButton("Details");
    viewStatusButton.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = -8337533736203519683L;

        @Override
        public void buttonClick(ClickEvent event) {
            app.getMainWindow().addWindow(new Window() {
                private static final long serialVersionUID = 1520192489661790818L;

                {
                    center();
                    setWidth("700px");
                    setHeight("500px");
                    VerticalLayout vl = new VerticalLayout();
                    vl.addComponent(statusLink);
                    String status;
                    if (error != null) {
                        status = error.getCode() + "\n" + error.getMessage() + "\n" + error.getDescription();
                    } else {
                        status = "No message";
                    }
                    //status += "<img src=\"images/prov.png\"";
                    vl.addComponent(new Label(status, Label.CONTENT_PREFORMATTED));
                    addComponent(vl);
                }
            });
        }
    });

    resubmitButton = new NativeButton("Resume");
    resubmitButton.setData(processingStatusForm);
    resubmitButton.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = -6410875548044234734L;

        @Override
        public void buttonClick(ClickEvent event) {
            long dbId = processingStatus.getProcessing().getDbId();
            long liferayID = app.getLiferayId(processingStatus.getProcessing().getUser().getLiferayID());
            processingService.resubmit(dbId, submissionIO.getSubmission().getDbId(),
                    userDataService.getUserId(), liferayID);
            processingStatusForm.attach();
        }
    });

    markFailButton = new NativeButton("Abort");
    markFailButton.setData(processingStatusForm);
    markFailButton.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = -5019762936706219454L;

        @Override
        public void buttonClick(ClickEvent event) {
            app.getMainWindow().addWindow(new Window() {
                private static final long serialVersionUID = 3852384470521127702L;

                {
                    final Window window = this;
                    center();
                    setWidth("500px");
                    setHeight("300px");
                    VerticalLayout vl = new VerticalLayout();

                    final TextField text = new TextField("Remarks to the user");
                    text.setWidth("97%");
                    text.setHeight("150px");
                    vl.addComponent(text);

                    final Button okButton = new NativeButton();
                    okButton.setCaption("Save");
                    okButton.setImmediate(true);
                    okButton.setWidth("-1px");
                    okButton.setHeight("-1px");
                    okButton.addListener(new Button.ClickListener() {
                        private static final long serialVersionUID = 1754437322024958253L;

                        public void buttonClick(ClickEvent event) {
                            long dbId = processingStatus.getProcessing().getDbId();
                            long userID = processingStatus.getProcessing().getUser().getDbId();
                            long liferayID = app
                                    .getLiferayId(processingStatus.getProcessing().getUser().getLiferayID());
                            processingService.markFailed(submissionIO.getSubmission().getDbId(),
                                    (String) text.getValue());
                            processingStatus = processingService.getProcessingStatus(
                                    userDataService.getProcessing(dbId), userID, liferayID, false);
                            refreshButton.setData(processingStatus);
                            processingStatusForm.fireValueChange(false);//fireEvent(new Event(refreshButton));
                            window.getParent().removeWindow(window);
                        }
                    });
                    vl.addComponent(okButton);
                    addComponent(vl);
                }
            });
        }
    });
    //      }

    remarksButton = new NativeButton("Why?");
    remarksButton.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = -267778012100029422L;

        @Override
        public void buttonClick(ClickEvent event) {
            app.getMainWindow().addWindow(new Window() {
                private static final long serialVersionUID = -5026454769214596711L;

                {
                    List<nl.amc.biolab.datamodel.objects.Error> temp = submissionIO.getSubmission().getErrors();

                    center();
                    setWidth("700px");
                    setHeight("500px");
                    VerticalLayout vl = new VerticalLayout();
                    vl.addComponent(
                            new Label(temp.get(temp.size() - 1).getMessage(), Label.CONTENT_PREFORMATTED));
                    addComponent(vl);
                }
            });
        }
    });
}

From source file:org.sensorhub.ui.SOSConfigForm.java

License:Mozilla Public License

@Override
public void build(String title, MyBeanItem<? extends Object> beanItem) {
    super.build(title, beanItem);

    // add link to capabilities
    Property<?> endPointProp = beanItem.getItemProperty(PROP_ENDPOINT);
    if (endPointProp != null) {
        String baseUrl = ((String) endPointProp.getValue()).substring(1);
        String href = baseUrl + "?service=SOS&version=2.0&request=GetCapabilities";
        Link link = new Link("Link to capabilities", new ExternalResource(href), "_blank", 0, 0, null);
        this.addComponent(link, 0);
    }//from   w w  w  . j  a va 2  s . c  o m
}