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:fr.amapj.view.engine.excelgenerator.TelechargerPopup.java

License:Open Source License

private void addLink(VerticalLayout contentLayout, FileInfoDTO fileInfoDTO) {
    String titre = fileInfoDTO.nameToDisplay;
    String fileName = fileInfoDTO.fileName;
    String extension = fileInfoDTO.extension;

    StreamResource streamResource = new StreamResource(new CoreResource(fileInfoDTO.generator),
            fileName + "." + extension);
    streamResource.setCacheTime(1000);/* ww w .  j av  a  2 s .c  o m*/

    Link extractFile = new Link(titre, streamResource);
    extractFile.setIcon(FontAwesome.DOWNLOAD);
    extractFile.setTargetName("_blank");

    contentLayout.addComponent(extractFile);
}

From source file:fr.amapj.view.views.advanced.devtools.PopupAttachementDisplay.java

License:Open Source License

public Link createLink(int pieceNumber, ByteArrayInputStream bais, String fileName) {
    StreamResource streamResource = new StreamResource(() -> bais, fileName);
    streamResource.setCacheTime(1000);/*ww  w  .j a va 2  s.  c  o  m*/

    Link extractFile = new Link("Pice " + pieceNumber + " - " + fileName, streamResource);
    extractFile.setIcon(FontAwesome.DOWNLOAD);
    extractFile.setTargetName("_blank");

    return extractFile;
}

From source file:fr.amapj.view.views.advanced.devtools.PopupHtmlToPdf.java

License:Open Source License

private void addFieldSaisie() {
    setStepTitle("Conversion");

    tf = new TextArea("Contenu html");
    tf.setWidth("90%");
    tf.setHeight(10, Unit.CM);//from w  ww .  j av  a  2  s . c  o  m
    tf.setImmediate(true);
    form.addComponent(tf);

    StreamResource streamResource = new StreamResource(new PdfResource(tf), "test.pdf");
    streamResource.setCacheTime(1000);

    Link extractFile = new Link("Tlcharger le pdf", streamResource);
    extractFile.setIcon(FontAwesome.DOWNLOAD);
    extractFile.setTargetName("_blank");

    form.addComponent(extractFile);
}

From source file:fr.amapj.view.views.appinstance.PopupConnectAppInstance.java

License:Open Source License

private void addFieldConnexion() {
    String nomInstance = appInstanceDTO.nomInstance;
    String session = UI.getCurrent().getSession().getCsrfToken();

    ////from  w w  w.j  a  v a 2  s. c  om
    String sudoKey = SudoManager.addSudoCredential(selected.selected, nomInstance, session);
    String url = selected.selected.url + "&sudo=" + sudoKey;

    // Titre
    setStepTitle("cliquer sur le lien si dessous pour ouvrir l'application");

    // Champ 1
    Link link = new Link("Lien de connexion", new ExternalResource(url));
    link.setTargetName("_blank");
    form.addComponent(link);

}

From source file:fr.amapj.view.views.login.LoginPart.java

License:Open Source License

public void buildLoginView(ValoMenuLayout root, AmapUI ui, String loginFromUrl, String passwordFromUrl,
        String sudo) {//from   w ww  . j  a v  a  2s  .  c o m
    this.ui = ui;
    CssLayout loginAera = root.prepareForLoginPage();

    VerticalLayout loginLayout = new VerticalLayout();
    loginLayout.setSizeFull();

    loginAera.setStyleName("login-backgroundimage");
    loginAera.addComponent(loginLayout);

    // Recuperation des parametres
    String nomAmap = new ParametresService().getParametres().nomAmap;
    ui.getPage().setTitle(nomAmap);

    // Zone de saisie login/password 
    MyLoginForm myLoginForm = new MyLoginForm(loginFromUrl, passwordFromUrl, sudo, nomAmap);
    myLoginForm.addStyleName("login-layout");
    loginLayout.addComponent(myLoginForm);
    loginLayout.setComponentAlignment(myLoginForm, Alignment.MIDDLE_CENTER);
    loginLayout.setExpandRatio(myLoginForm, 10);

    Label l1 = new Label("Application fonctionnant avec AmapJ - ");
    Link link = new Link("Plus d'infos", new ExternalResource("http://amapj.fr"));
    link.setTargetName("_blank");

    HorizontalLayout hL = new HorizontalLayout();
    hL.addComponent(l1);
    hL.setComponentAlignment(l1, Alignment.MIDDLE_CENTER);
    hL.addComponent(link);
    hL.setComponentAlignment(link, Alignment.MIDDLE_CENTER);
    hL.setMargin(true);

    loginLayout.addComponent(hL);
    loginLayout.setComponentAlignment(hL, Alignment.BOTTOM_CENTER);
    loginLayout.setExpandRatio(hL, 1);

    // Si les deux champs ont t remplis on tente une validation automatique
    if ((passwordFromUrl != null) && (loginFromUrl != null)) {
        myLoginForm.login(loginFromUrl, passwordFromUrl);
    }

}

From source file:jp.primecloud.auto.ui.TopBar.java

License:Open Source License

@Override
public void attach() {
    addStyleName("TopBar");
    setWidth("100%");
    setHeight("30px");
    setMargin(false, true, false, false);

    // PrimeCloud
    Label plbl = new Label(IconUtils.createImageTag(getApplication(), Icons.PCCLOGO), Label.CONTENT_XHTML);
    plbl.addStyleName("logo");
    addComponent(plbl);/*from  www .  jav  a 2s .  com*/

    // ??
    String versionProp = Config.getVersionProperty("version");
    if (StringUtils.isNotEmpty(versionProp)) {
        StringBuilder version = new StringBuilder();
        version.append("ver").append(versionProp);
        Label versionNo = new Label("<p>" + version.toString() + "</p>", Label.CONTENT_XHTML);
        versionNo.addStyleName("versionNo");
        addComponent(versionNo);
    } else {
        Label versionNo = new Label("<p></p>", Label.CONTENT_XHTML);
        versionNo.addStyleName("versionNoNone");
        addComponent(versionNo);
    }

    // myCloud?
    Button myCloudButton = new Button(ViewProperties.getCaption("button.myCloudManage"));
    myCloudButton.setDescription(ViewProperties.getCaption("description.myCloudManage"));
    myCloudButton.addStyleName("borderless");
    myCloudButton.addStyleName("mycloud");
    myCloudButton.setIcon(Icons.CLOUDBIG.resource());
    myCloudButton.setVisible(true);
    myCloudButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            showCloudEditWindow();
        }
    });
    addComponent(myCloudButton);

    // (Zabbix)
    String useZabbix = Config.getProperty("zabbix.useZabbix");
    if (useZabbix == null || BooleanUtils.toBoolean(useZabbix)) {
        String url = Config.getProperty("zabbix.display");
        Link zabbix = new Link(ViewProperties.getCaption("link.zabbix"), new ExternalResource(url));
        zabbix.setDescription(ViewProperties.getCaption("description.link.zabbix"));
        zabbix.setIcon(Icons.MNGSYSTEM.resource());
        zabbix.setTargetName("_blank");
        zabbix.addStyleName("zabbix");
        addComponent(zabbix);
    }

    // 
    Button eventLogButton = new Button(ViewProperties.getCaption("link.eventlog"));
    eventLogButton.setDescription(ViewProperties.getCaption("description.link.eventlog"));
    eventLogButton.addStyleName("borderless");
    eventLogButton.addStyleName("eventlog");
    eventLogButton.setIcon(Icons.CUSTOM.resource());
    eventLogButton.setVisible(true);
    eventLogButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            WinLogView window = new WinLogView();
            getApplication().addWindow(window);
            getApplication().getMainWindow().open(new ExternalResource(window.getURL()), "_blank");
        }
    });
    addComponent(eventLogButton);

    // 
    Boolean usePayment = BooleanUtils.toBooleanObject(Config.getProperty("payment.usePayment"));
    if (BooleanUtils.isTrue(usePayment)) {
        String url2 = Config.getProperty("payment.display");
        Link payment = new Link(ViewProperties.getCaption("link.payment"), new ExternalResource(url2));
        payment.setDescription(ViewProperties.getCaption("description.link.payment"));
        payment.setIcon(Icons.PAYSYSTEM.resource());
        payment.setTargetName("_payment");
        payment.addStyleName("payment");
        addComponent(payment);
    }

    // 
    Button logoutButton = new Button(ViewProperties.getCaption("button.logout"));
    logoutButton.setDescription(ViewProperties.getCaption("description.logout"));
    logoutButton.addStyleName("borderless");
    logoutButton.addStyleName("logout");
    logoutButton.setIcon(Icons.LOGOUT.resource());
    logoutButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            DialogConfirm dialog = new DialogConfirm(ViewProperties.getCaption("dialog.dialogConfirm"),
                    ViewMessages.getMessage("IUI-000001"), Buttons.OKCancel);
            Callback callback = new Callback() {
                @Override
                public void onDialogResult(Result result) {
                    if (result == Result.OK) {
                        // ?
                        LoggingUtils.removeContext();
                        ContextUtils.invalidateSession();
                        accountButton.setVisible(false);

                        // ????
                        getApplication().close();
                    }
                }
            };
            dialog.setCallback(callback);
            getApplication().getMainWindow().addWindow(dialog);
        }
    });
    addComponent(logoutButton);

    // ?
    accountButton = new Button(ViewProperties.getCaption("button.account"));
    accountButton.setDescription(ViewProperties.getCaption("description.account"));
    accountButton.addStyleName("borderless");
    accountButton.addStyleName("account");
    accountButton.setIcon(Icons.USER.resource());
    accountButton.setVisible(false);
    addComponent(accountButton);
}

From source file:org.activiti.explorer.ui.content.file.ImageAttachmentRenderer.java

License:Apache License

@Override
public Component getDetailComponent(Attachment attachment) {
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSizeUndefined();/*from   w ww . j  ava2s.co  m*/
    verticalLayout.setSpacing(true);
    verticalLayout.setMargin(true);

    Label description = new Label(attachment.getDescription());
    description.setSizeUndefined();
    verticalLayout.addComponent(description);

    // Image
    TaskService taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();

    String mimeType = extractMineType(attachment.getType());

    InputStream imageStream = ImageUtil.resizeImage(taskService.getAttachmentContent(attachment.getId()),
            mimeType, 900, 550);
    Resource resource = new StreamResource(new InputStreamStreamSource(imageStream),
            attachment.getName() + extractExtention(attachment.getType()), ExplorerApp.get());
    Embedded image = new Embedded(null, resource);
    verticalLayout.addComponent(image);

    // Linke
    HorizontalLayout LinkLayout = new HorizontalLayout();
    LinkLayout.setSpacing(true);
    verticalLayout.addComponent(LinkLayout);
    verticalLayout.setComponentAlignment(LinkLayout, Alignment.MIDDLE_CENTER);

    Label fullSizeLabel = new Label(
            ExplorerApp.get().getI18nManager().getMessage(Messages.RELATED_CONTENT_SHOW_FULL_SIZE));
    LinkLayout.addComponent(fullSizeLabel);

    Link link = null;
    if (attachment.getUrl() != null) {
        link = new Link(attachment.getUrl(), new ExternalResource(attachment.getUrl()));
    } else {
        taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
        Resource res = new StreamResource(
                new InputStreamStreamSource(taskService.getAttachmentContent(attachment.getId())),
                attachment.getName() + extractExtention(attachment.getType()), ExplorerApp.get());

        link = new Link(attachment.getName(), res);
    }

    link.setIcon(Images.RELATED_CONTENT_PICTURE);
    link.setTargetName(ExplorerLayout.LINK_TARGET_BLANK);
    LinkLayout.addComponent(link);

    return verticalLayout;
}

From source file:org.activiti.explorer.ui.content.GenericAttachmentRenderer.java

License:Apache License

public Component getDetailComponent(Attachment attachment) {
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSizeUndefined();// w w w . j a va  2s. c  om
    verticalLayout.setSpacing(true);
    verticalLayout.setMargin(true);

    Label description = new Label(attachment.getDescription());
    description.setSizeUndefined();
    verticalLayout.addComponent(description);

    HorizontalLayout linkLayout = new HorizontalLayout();
    linkLayout.setSpacing(true);
    verticalLayout.addComponent(linkLayout);

    // Image
    linkLayout.addComponent(new Embedded(null, getImage(attachment)));

    // Link
    Link link = null;
    if (attachment.getUrl() != null) {
        link = new Link(attachment.getUrl(), new ExternalResource(attachment.getUrl()));
    } else {
        TaskService taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
        Resource res = new StreamResource(
                new InputStreamStreamSource(taskService.getAttachmentContent(attachment.getId())),
                attachment.getName() + extractExtention(attachment.getType()), ExplorerApp.get());

        link = new Link(attachment.getName(), res);
    }

    // Set generic image and external window 
    link.setTargetName(ExplorerLayout.LINK_TARGET_BLANK);
    linkLayout.addComponent(link);

    return verticalLayout;
}

From source file:org.eclipse.hawkbit.ui.components.SPUIComponentProvider.java

License:Open Source License

/**
 * Method to create a link.//from www.ja  v a 2  s  . c o m
 *
 * @param id
 *            of the link
 * @param name
 *            of the link
 * @param resource
 *            path of the link
 * @param icon
 *            of the link
 * @param targetOpen
 *            specify how the link should be open (f. e. new windows =
 *            _blank)
 * @param style
 *            chosen style of the link. Might be {@code null} if no style
 *            should be used
 * @return a link UI component
 */
public static Link getLink(final String id, final String name, final String resource, final FontAwesome icon,
        final String targetOpen, final String style) {

    final Link link = new Link(name, new ExternalResource(resource));
    link.setId(id);
    link.setIcon(icon);
    link.setDescription(name);

    link.setTargetName(targetOpen);
    if (style != null) {
        link.setStyleName(style);
    }

    return link;

}

From source file:org.eclipse.hawkbit.ui.components.SPUIComponentProvider.java

License:Open Source License

/**
 * Generates help/documentation links from within management UI.
 *
 * @param i18n//from  w w  w .  ja  v a 2  s.co m
 *            the i18n
 * @param uri
 *            to documentation site
 *
 * @return generated link
 */
public static Link getHelpLink(final VaadinMessageSource i18n, final String uri) {

    final Link link = new Link("", new ExternalResource(uri));
    link.setTargetName("_blank");
    link.setIcon(FontAwesome.QUESTION_CIRCLE);
    link.setDescription(i18n.getMessage("tooltip.documentation.link"));
    return link;

}