Example usage for com.vaadin.ui Link setTargetName

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

Introduction

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

Prototype

public void setTargetName(String targetName) 

Source Link

Document

Sets the target window name.

Usage

From source file:org.eclipse.skalli.view.ext.InfoBoxBase.java

License:Open Source License

protected void createLink(Layout layout, String caption, Resource resource, String targetName,
        String styleName) {//from   ww w  .j a va 2  s  .c  om
    Link link = new Link(caption, resource);
    if (StringUtils.isNotBlank(targetName)) {
        link.setTargetName(targetName);
    } else {
        link.setTargetName(DEFAULT_TARGET);
    }
    if (StringUtils.isNotBlank(styleName)) {
        link.addStyleName(styleName);
    } else {
        link.addStyleName(STYLE_LINK);
    }
    layout.addComponent(link);
}

From source file:org.escidoc.browser.elabsmodul.views.helpers.LabsStudyTableHelper.java

License:Open Source License

private static Link createLinkByResourcePath(String inputUrl) {
    Preconditions.checkNotNull(inputUrl, "URL is null");
    String urlString = inputUrl.trim();

    if (!urlString.toLowerCase().startsWith(HTTP) && !urlString.toLowerCase().startsWith(HTTPS)) {
        urlString = HTTP + urlString;/* ww w  .  j a v  a2s .  c  o m*/
    }

    String inputString = urlString;
    String fileFormat;

    while (inputString.endsWith("/")) {
        inputString = inputString.substring(0, inputString.length() - 1);
    }

    fileFormat = inputString.substring(inputString.lastIndexOf(".") + 1).toLowerCase();
    final Link link = new Link(urlString, new ExternalResource(urlString));
    link.setTargetName("_blank");

    if (fileFormat.startsWith("doc")) {
        link.setIcon(ELabsViewContants.ICON_16_DOC_DOC);
    } else if (fileFormat.startsWith("pdf")) {
        link.setIcon(ELabsViewContants.ICON_16_DOC_PDF);
    } else if (fileFormat.startsWith("ppt")) {
        link.setIcon(ELabsViewContants.ICON_16_DOC_PPT);
    } else if (fileFormat.startsWith("txt")) {
        link.setIcon(ELabsViewContants.ICON_16_DOC_TXT);
    } else if (fileFormat.startsWith("jpg") || fileFormat.startsWith("jpeg") || fileFormat.startsWith("png")) {
        link.setIcon(ELabsViewContants.ICON_16_DOC_IMG);
    } else {
        link.setIcon(ELabsViewContants.ICON_16_DOC_WEB);
    }
    return link;
}

From source file:org.escidoc.browser.ui.view.helpers.AdminDescriptorsTable.java

License:Open Source License

private Link buildLink(AdminDescriptor ad) {
    Link mdLink = new Link("View", new ExternalResource(buildUri(ad)));
    mdLink.setTargetName("_blank");
    mdLink.setStyleName(BaseTheme.BUTTON_LINK);
    mdLink.setDescription("Show Admin Descriptor information in a separate window");
    return mdLink;
}

From source file:org.escidoc.browser.ui.view.helpers.ContainerMetadataTable.java

License:Open Source License

private Link buildLink(final MetadataRecord metadataRecord) {
    Link mdLink = new Link("View", new ExternalResource(buildUri(metadataRecord)));
    mdLink.setTargetName("_blank");
    mdLink.setStyleName(BaseTheme.BUTTON_LINK);
    mdLink.setDescription("Show metadata information in a separate window");
    return mdLink;
}

From source file:org.opennms.netmgt.bsm.vaadin.adminpage.BusinessServiceTreeTable.java

License:Open Source License

public BusinessServiceTreeTable(BusinessServiceManager businessServiceManager) {
    this.businessServiceManager = Objects.requireNonNull(businessServiceManager);

    setSizeFull();//from   w w w .  ja  v  a2  s .c  om
    setContainerDataSource(new BusinessServiceContainer());

    // Add the "LINKS" columns
    addGeneratedColumn("links", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 7113848887128656685L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final HorizontalLayout layout = new HorizontalLayout();
            final BusinessServiceStateMachine stateMachine = businessServiceManager.getStateMachine();
            final BusinessService businessService = getItem(itemId).getBean().getBusinessService();
            final Status status = stateMachine.getOperationalStatus(businessService);
            if (status != null) {
                // Build the query string
                final List<BasicNameValuePair> urlParms = Lists.newArrayList(
                        new BasicNameValuePair("focus-vertices", businessService.getId().toString()),
                        new BasicNameValuePair("szl", "1"),
                        new BasicNameValuePair("layout", "Hierarchy Layout"),
                        new BasicNameValuePair("provider", "Business Services"));
                final String queryString = URLEncodedUtils.format(urlParms, Charset.forName("UTF-8"));

                // Generate the link
                final Link link = new Link("View in Topology UI",
                        new ExternalResource(String.format("/opennms/topology?%s", queryString)));
                link.setIcon(FontAwesome.EXTERNAL_LINK_SQUARE);
                // This app is typically access in an iframe, so we open the URL in a new window/tab
                link.setTargetName("_blank");
                layout.addComponent(link);
                layout.setComponentAlignment(link, Alignment.MIDDLE_CENTER);
            } else {
                Label label = new Label("N/A");
                label.setDescription("Try reloading the daemon and refreshing the table.");
                label.setWidth(null);
                layout.addComponent(label);
            }
            return layout;
        }
    });

    // add edit and delete buttons
    addGeneratedColumn("edit / delete", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 7113848887128656685L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            HorizontalLayout layout = new HorizontalLayout();
            layout.setSpacing(true);

            Button editButton = new Button("Edit", FontAwesome.PENCIL_SQUARE_O);
            editButton.setId("editButton-" + getItem(itemId).getBean().getName());

            editButton.addClickListener(UIHelper.getCurrent(TransactionAwareUI.class)
                    .wrapInTransactionProxy((Button.ClickListener) event -> {
                        final Long businessServiceId = getItem(itemId).getBean().getBusinessService().getId();
                        BusinessService businessService = businessServiceManager
                                .getBusinessServiceById(businessServiceId);
                        final BusinessServiceEditWindow window = new BusinessServiceEditWindow(businessService,
                                businessServiceManager);
                        window.addCloseListener(e -> refresh());

                        getUI().addWindow(window);
                    }));
            layout.addComponent(editButton);

            Button deleteButton = new Button("Delete", FontAwesome.TRASH_O);
            deleteButton.setId("deleteButton-" + getItem(itemId).getBean().getName());

            deleteButton.addClickListener((Button.ClickListener) event -> {
                final Long businessServiceId = getItem(itemId).getBean().getBusinessService().getId();
                BusinessService businessService = businessServiceManager
                        .getBusinessServiceById(businessServiceId);
                if (businessService.getParentServices().isEmpty()
                        && businessService.getChildEdges().isEmpty()) {
                    UIHelper.getCurrent(TransactionAwareUI.class).runInTransaction(() -> {
                        businessServiceManager.getBusinessServiceById(businessServiceId).delete();
                        refresh();
                    });
                } else {
                    new org.opennms.netmgt.vaadin.core.ConfirmationDialog()
                            .withOkAction((org.opennms.netmgt.vaadin.core.ConfirmationDialog.Action) UIHelper
                                    .getCurrent(TransactionAwareUI.class).wrapInTransactionProxy(
                                            new org.opennms.netmgt.vaadin.core.ConfirmationDialog.Action() {
                                                @Override
                                                public void execute(
                                                        org.opennms.netmgt.vaadin.core.ConfirmationDialog window) {
                                                    businessServiceManager
                                                            .getBusinessServiceById(businessServiceId).delete();
                                                    refresh();
                                                }
                                            }))
                            .withOkLabel("Delete anyway").withCancelLabel("Cancel").withCaption("Warning")
                            .withDescription(
                                    "This entry is referencing or is referenced by other Business Services! Do you really want to delete this entry?")
                            .open();
                }
            });
            layout.addComponent(deleteButton);

            return layout;
        }
    });

    setColumnExpandRatio("name", 5);
    setColumnExpandRatio("links", 1);
    setColumnExpandRatio("edit / delete", 1);
}

From source file:org.rubicone.poc.vpush.uil.sending.SendingUI.java

License:Apache License

private Panel createInstructionsPanel() {
    Panel instructionsPanel = new Panel("instructions");

    VerticalLayout instructionsLayout = new VerticalLayout();
    instructionsPanel.setContent(instructionsLayout);

    Label instructionsLabel = new Label(
            "open another UI receiving notifications from server using following transport:");
    instructionsLayout.addComponent(instructionsLabel);

    Link websocketsUILink = new Link("websockets", new ExternalResource("./receive-messages-websockets"));
    websocketsUILink.setIcon(VaadinIcons.CHEVRON_RIGHT_SMALL);
    websocketsUILink.setTargetName("_blank");
    instructionsLayout.addComponent(websocketsUILink);

    Link websocketsXhrUILink = new Link("websockets + XHR",
            new ExternalResource("./receive-messages-websocketsxhr"));
    websocketsXhrUILink.setIcon(VaadinIcons.CHEVRON_RIGHT_SMALL);
    websocketsXhrUILink.setTargetName("_blank");
    instructionsLayout.addComponent(websocketsXhrUILink);

    Link httpLongPollingUILink = new Link("HTTP long polling",
            new ExternalResource("./receive-messages-httplongpolling"));
    httpLongPollingUILink.setIcon(VaadinIcons.CHEVRON_RIGHT_SMALL);
    httpLongPollingUILink.setTargetName("_blank");
    instructionsLayout.addComponent(httpLongPollingUILink);

    Label noteLabel = new Label(
            "<i>" + VaadinIcons.INFO_CIRCLE_O.getHtml()
                    + " note: you may open several UIs at the same time to receive push notifications</i>",
            ContentMode.HTML);//w ww  .  ja va  2s .  com
    noteLabel.addStyleName(ValoTheme.LABEL_TINY);
    instructionsLayout.addComponents(noteLabel);

    return instructionsPanel;
}

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

License:Apache License

private void loadTestClasses(TListUi aThis) {
    if (testClassess != null) {
        return;/*  www  .  j  a va  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);
    setContent(table);
}

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

License:Apache License

private void loadTestClasses(TListUi aThis) {
    if (testClassess != null) {
        return;/*w  ww .java2 s  .  c  o m*/
    }
    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;//from   w w  w.  j  a  v  a 2  s  .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  ww .  java2 s .  c om*/
    }
    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);
}