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) 

Source Link

Document

Creates a new instance of Link.

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);/*from  w  w  w.jav a  2s  .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);/*from  w  w w .  jav  a2  s .  co 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);/*w  w w.  java2  s .co  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 ww  . j av  a  2  s.  co  m
    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) {/*  w  w  w.  j ava  2  s. 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:fr.amapj.view.views.logview.LogView.java

License:Open Source License

@Override
protected void drawTable() {
    // Gestion de la liste des colonnes visibles
    cdesTable.setVisibleColumns("sudo", "nom", "prenom", "dbName", "status", "typLog", "ip", "browser",
            "dateIn", "dateOut", "nbError");

    cdesTable.setColumnHeader("sudo", "Sudo");
    cdesTable.setColumnHeader("nom", "Nom");
    cdesTable.setColumnHeader("prenom", "Prnom");
    cdesTable.setColumnHeader("dbName", "Base");
    cdesTable.setColumnHeader("ip", "Ip");
    cdesTable.setColumnHeader("browser", "Browser");
    cdesTable.setColumnHeader("dateIn", "Date connexion");
    cdesTable.setColumnHeader("dateOut", "Date dconnexion");
    cdesTable.setColumnHeader("status", "Etat");
    cdesTable.setColumnHeader("typLog", "Type");
    cdesTable.setColumnHeader("nbError", "Erreur");
    cdesTable.setColumnAlignment("nbError", Align.CENTER);

    cdesTable.setConverter("dateIn", new DateTimeToStringConverter());
    cdesTable.setConverter("dateOut", new DateTimeToStringConverter());

    cdesTable.addGeneratedColumn("Tlcharger ...", new ColumnGenerator() {
        @Override/*from  w ww . j a  v  a  2  s  .  c om*/
        public Object generateCell(final Table source, final Object itemId, Object columnId) {
            LogAccessDTO dto = (LogAccessDTO) itemId;
            if (dto.logFileName == null) {
                Label l = new Label("Pas de fichier");
                return l;
            }
            LogFileResource logFileResource = new LogFileResource(dto.logFileName);

            Link extractFile = new Link("Tlcharger le fichier de log",
                    new StreamResource(logFileResource, dto.logFileName + ".log"));
            return extractFile;
        }
    });
}

From source file:fr.amapj.view.views.logview.TelechargerLogPopup.java

License:Open Source License

protected void createContent(VerticalLayout contentLayout) {
    contentLayout.addComponent(//from  w  ww .ja  v  a2  s .  com
            new Label("Veuillez cliquer sur le lien du fichier que vous souhaitez tlcharger"));

    String name = "global";

    LogFileResource logFileResource = new LogFileResource(name);

    Link extractFile = new Link("Tlcharger le fichier global.log",
            new StreamResource(logFileResource, name + ".log"));

    contentLayout.addComponent(extractFile);
}

From source file:gms.demo.service.presentation.ui.FlatModelInfo.java

License:Open Source License

public Link getMemberName() {
    StringBuilder sb = new StringBuilder("master/");
    sb.append(getGroupName());//from ww  w  .  jav  a  2 s.co  m
    sb.append("/");
    sb.append(getGroupNameSpace());
    sb.append("/");
    return new Link(memberInfo.getMemberName(), new ExternalResource(sb.toString()));
}

From source file:io.fns.calculator.Application.java

License:Apache License

@Override
protected void init(VaadinRequest vaadinRequest) {
    setContent(new CssLayout(new Label("Hello! I'm the root UI!"),
            new Link("Go to other UI", new ExternalResource("anotherUI"))));
}

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);//w w  w. jav a2 s  .  c om

    // ??
    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);
}