Example usage for com.vaadin.ui Panel Panel

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

Introduction

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

Prototype

public Panel(String caption) 

Source Link

Document

Creates a new empty panel with caption.

Usage

From source file:fi.jasoft.dragdroplayouts.demo.views.DragdropCaptionModeDemo.java

License:Apache License

@Override
public Component getLayout() {
    // start-source
    // Create layout
    DDAbsoluteLayout layout = new DDAbsoluteLayout();

    // Enable dragging components by their caption
    layout.setDragMode(LayoutDragMode.CAPTION);

    // Enable dropping components
    layout.setDropHandler(new DefaultAbsoluteLayoutDropHandler());

    // Add some content to the layout
    layout.addComponent(new Label("This layout uses the LayoutDragMode.CAPTION "
            + "drag mode for dragging the components. This mode is useful "
            + "when you only want users to drag items by their captions. The Panels below are only draggable by their captions (<< Move >>).",
            ContentMode.HTML));//  w  w  w. j  av  a2s.  c om

    Panel chapter1 = new Panel("<< Move >>");
    chapter1.setWidth("300px");
    Label chapter1Content = new Label(new LoremIpsum().getParagraphs(1), ContentMode.TEXT);
    chapter1Content.setCaption("===== Chapter 1 - The beginning ======");
    chapter1.setContent(chapter1Content);
    layout.addComponent(chapter1, "top:50px;left:10px");

    Panel chapter2 = new Panel("<< Move >>");
    chapter2.setWidth("300px");
    Label chapter2Content = new Label(new LoremIpsum().getParagraphs(1), ContentMode.TEXT);
    chapter2Content.setCaption("===== Chapter 2 - The finale ======");
    chapter2.setContent(chapter2Content);
    layout.addComponent(chapter2, "top:50px; left:320px");

    // end-source
    return layout;
}

From source file:fi.jasoft.qrcode.demo.QRCodeDemo.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    VerticalLayout content = new VerticalLayout();
    content.setSizeFull();//w  ww .  j  a v a  2  s  .  c  o m
    setContent(content);

    Label header = new Label("QR Code Generator");
    header.setStyleName(ValoTheme.LABEL_H2);
    content.addComponent(header);

    HorizontalSplitPanel root = new HorizontalSplitPanel();
    root.setSizeFull();
    root.setSplitPosition(50, Unit.PERCENTAGE);
    root.setLocked(true);

    Panel panel = new Panel(root);
    panel.setSizeFull();
    content.addComponent(panel);
    content.setExpandRatio(panel, 1);

    VerticalLayout first = new VerticalLayout();
    first.setSizeFull();
    root.setFirstComponent(first);

    first.addComponent(
            new HorizontalLayout(createPrimaryColorSelect(), createSecondaryColorSelect(), createSizeSelect()));

    code = new QRCode();
    code.setWidth("100px");
    code.setHeight("100px");

    final TextArea text = new TextArea("Text embedded in QR Code");
    text.setPlaceholder("Type the message of the QR code here");
    text.setSizeFull();
    text.setValueChangeMode(ValueChangeMode.LAZY);
    text.addValueChangeListener(e -> {
        code.setValue(e.getValue());
    });

    first.addComponent(text);
    first.setExpandRatio(text, 1);

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

    vl.addComponent(code);
    vl.setComponentAlignment(code, Alignment.MIDDLE_CENTER);

    root.setSecondComponent(vl);
}

From source file:fi.vtt.RVaadin.RUpload.java

License:Apache License

/**
 * Contruct an upload element for R (implemented as Vaadin CustomComponent).
 * /*  w w  w  .  ja  v a2s  .c o m*/
 * @param caption
 *            String caption or null
 * @param R
 *            the corresponding RSession to upload the files to
 */
public RUpload(String caption, RContainer R) {

    /* Create the RUpload custom component */
    super.setSizeUndefined();
    root = new Panel(caption);
    root.setWidth("90ex");

    setCompositionRoot(root);

    HorizontalLayout hbox = new HorizontalLayout();
    hbox.setWidth("100%");

    /* Create the Upload component */
    final Upload upload = new Upload("Choose file", this);
    upload.setButtonCaption("Submit");

    /* Listen for events regarding the success of upload. */
    upload.addSucceededListener(this);
    upload.addFailedListener(this);
    hbox.addComponent(upload);

    Label hfill = new Label();
    hbox.addComponent(hfill);
    hbox.setExpandRatio(hfill, 1.0f);

    remove = new Button("Remove", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            String current = getSelection();

            if (current != null) {
                /* Delete the file */
                delete(current);

                /* Update the lists and the notification area */
                int i = fileNames.indexOf(current);
                fileNames.remove(i);
                mimeTypes.remove(i);
                uploadedFiles.removeItem(current);

                /* Gray out the button, if this was the last item */
                if (fileNames.isEmpty()) {
                    remove.setEnabled(false);
                }
            }
        }
    });

    hbox.addComponent(remove);
    remove.setEnabled(false);
    hbox.setComponentAlignment(remove, Alignment.BOTTOM_RIGHT);

    /* Notification area for already uploaded files */
    uploadedFiles = new ListSelect("Already submitted files");
    uploadedFiles.setMultiSelect(false);
    uploadedFiles.setNullSelectionAllowed(false);
    uploadedFiles.setHeight("4em");
    uploadedFiles.setWidth("100%");

    // Changed for Vaadin 7, not tested!!
    VerticalLayout vbox = new VerticalLayout();
    vbox.addComponent(hbox);
    vbox.addComponent(uploadedFiles);
    root.setContent(vbox);

    /* Bind the component to the given R session */
    this.R = R;
}

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

License:Open Source License

@Override
public void enterIn(ViewChangeEvent event) {
    boolean allowTimeControl = AppConfiguration.getConf().isAllowTimeControl();
    boolean allowMailControl = AppConfiguration.getConf().isAllowMailControl();

    SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");

    addLabel(this, "Outils pour le developpement", "titre");

    // Partie date 
    HorizontalLayout hl = new HorizontalLayout();
    hl.addComponent(new Label("Date et heure courante :"));
    String valDate = df.format(DateUtils.getDate());
    labelDateHeure = new Label(valDate);
    hl.addComponent(labelDateHeure);/*  w  w  w .jav a 2  s  . com*/
    if (allowTimeControl == true) {

        textDateHeure = new TextField();
        textDateHeure.setWidth("200px");
        textDateHeure.setValue(valDate);
        hl.addComponent(textDateHeure);

        Button b = new Button("Control time");
        hl.addComponent(b);
        b.addClickListener(e -> controlTime());
    }

    addComponent(hl);

    //
    addLabel(this, "Nombre d'emails envoys aujourd'hui : " + MailerCounter.getNbMails());

    if (allowMailControl == true) {

        Button b = new Button("Visualiser tous les mails locaux");
        this.addComponent(b);
        b.addClickListener(e -> controlMail());
    }

    Panel devToolsPanel = new Panel("Outils de dveloppement");
    devToolsPanel.addStyleName("action");
    devToolsPanel.setContent(getDevToolsPanel());

    addComponent(devToolsPanel);

}

From source file:fr.amapj.view.views.advanced.maintenance.MaintenanceView.java

License:Open Source License

@Override
public void enterIn(ViewChangeEvent event) {
    boolean adminFull = SessionManager.getSessionParameters().isAdminFull();

    SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");

    addLabel(this, "Maintenance du systme", "titre");

    // Partie date 
    addLabel(this, "Date et heure courante :" + df.format(DateUtils.getDate()));
    addLabel(this, "Version de l'application : " + new MaintenanceService().getVersion());
    addLabel(this, "Nombre d'emails envoys aujourd'hui : " + MailerCounter.getNbMails());

    Panel backupPanel = new Panel("Sauvegarde de la base et envoi par e mail");
    backupPanel.addStyleName("action");
    backupPanel.setContent(getBackupPanel());

    Panel diversPanel = new Panel("Outils d'admin");
    diversPanel.addStyleName("action");
    diversPanel.setContent(getDiversPanel());

    addComponent(backupPanel);/*from ww w .  j  av a 2 s.c  o m*/
    addEmptyLine(this);

    //
    if (adminFull) {
        addComponent(diversPanel);
    }

}

From source file:fr.amapj.view.views.advanced.supervision.SupervisionView.java

License:Open Source License

@Override
public void enterIn(ViewChangeEvent event) {
    SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");

    addLabel(this, "Supervision du systme", "titre");

    addLabel(this, "Date et heure courante :" + df.format(DateUtils.getDate()));
    addLabel(this, "Version de l'application : " + new MaintenanceService().getVersion());
    addLabel(this, "Nombre d'emails envoys aujourd'hui : " + MailerCounter.getNbMails());

    Panel diversPanel = new Panel("Outils d'admin - Experts uniquement !");
    diversPanel.addStyleName("action");
    diversPanel.setContent(getDiversPanel());

    addComponent(diversPanel);/*from  w  w w .  j  a  v  a2 s. c  o  m*/
}

From source file:fr.amapj.view.views.importdonnees.ImportDonneesView.java

License:Open Source License

@Override
public void enterIn(ViewChangeEvent event) {
    addLabelH1(this, "Outil d'import des donnes en masse");

    addLabel(this,
            "Cet outil vous permet d'importer en masse les utilisateurs, les produits et les producteurs");
    addEmptyLine(this);

    Panel utilisateurPanel = new Panel("Importations des utilisateurs");
    utilisateurPanel.addStyleName("action");
    utilisateurPanel.setContent(getUtilisateurPanel());

    Panel produitPanel = new Panel("Importations des produits et des producteurs");
    produitPanel.addStyleName("action");
    produitPanel.setContent(getProduitPanel());

    addComponent(utilisateurPanel);//from  w  ww  .jav  a 2s . c  o m
    addEmptyLine(this);
    addComponent(produitPanel);

}

From source file:fr.amapj.view.views.maintenance.MaintenanceView.java

License:Open Source License

@Override
public void enterIn(ViewChangeEvent event) {
    boolean adminFull = SessionManager.getSessionParameters().isAdminFull();

    SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");

    addLabel(this, "Maintenance du systme", "titre");

    addLabel(this, "Date et heure courante " + df.format(new Date()));
    addLabel(this, "Version de l'application : " + getVersion());
    addLabel(this, "Nombre d'emails envoys aujourd'hui : " + MailerCounter.getNbMails());

    Panel backupPanel = new Panel("Sauvegarde de la base et envoi par e mail");
    backupPanel.addStyleName("action");
    backupPanel.setContent(getBackupPanel());

    Panel suppressionPanel = new Panel("Suppression complte d'un contrat vierge et des contrats associs");
    suppressionPanel.addStyleName("action");
    suppressionPanel.setContent(getSuppressionPanel());

    Panel diversPanel = new Panel("Outils divers");
    diversPanel.addStyleName("action");
    diversPanel.setContent(getDiversPanel());

    addComponent(backupPanel);/*from   w  w  w  .  jav a 2s.  c o m*/
    addEmptyLine(this);
    addComponent(suppressionPanel);
    addEmptyLine(this);

    //
    if (adminFull) {
        addComponent(diversPanel);
    }

}

From source file:fr.amapj.view.views.synthesemulticontrat.SyntheseMultiContratView.java

License:Open Source License

private void addPanel(String titre, VerticalLayout content) {
    Panel utilisateurPanel = new Panel(titre);
    utilisateurPanel.addStyleName("action");
    utilisateurPanel.setContent(content);
    addComponent(utilisateurPanel);/*from w ww.j  a v  a 2s. c om*/
    addEmptyLine(this);

}

From source file:fr.univlorraine.mondossierweb.views.AdressesView.java

License:Apache License

/**
 * Initialise la vue/*from www .ja va2  s . c  o  m*/
 */
@PostConstruct
public void init() {

    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MainUI && (userController.isEnseignant() || userController.isEtudiant())
            && MainUI.getCurrent() != null && MainUI.getCurrent().getEtudiant() != null) {
        removeAllComponents();

        /* Style */
        setMargin(true);
        setSpacing(true);

        /* Titre */
        Label title = new Label(applicationContext.getMessage(NAME + ".title", null, getLocale()));
        title.addStyleName(ValoTheme.LABEL_H1);
        addComponent(title);

        VerticalLayout globalLayout = new VerticalLayout();
        globalLayout.setSizeFull();
        globalLayout.setSpacing(true);

        //Layout avec les infos etatcivil et contact
        CssLayout idLayout = new CssLayout();
        idLayout.setSizeFull();
        idLayout.setStyleName("flexwrap");

        globalLayout.addComponent(idLayout);
        // Enable Responsive CSS selectors for the layout
        Responsive.makeResponsive(idLayout);

        if (MainUI.getCurrent().getEtudiant().getAdresseAnnuelle() != null) {

            FormLayout formAdresseAnnuelleLayout = new FormLayout();
            formAdresseAnnuelleLayout.setSpacing(true);
            formAdresseAnnuelleLayout.setMargin(true);

            Panel panelAdresseAnnuelle = new Panel(
                    applicationContext.getMessage(NAME + ".adresseannuelle.title", null, getLocale()) + " "
                            + MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAnnee());

            String captionAdresseAnnuelle = applicationContext.getMessage(NAME + ".adresse.title", null,
                    getLocale());
            Label fieldAdresseAnnuelle = new Label();
            formatLabel(fieldAdresseAnnuelle, captionAdresseAnnuelle,
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAdresse1());
            formAdresseAnnuelleLayout.addComponent(fieldAdresseAnnuelle);

            String annuelle2 = valuateTextFieldFromMultipleValues(
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAdresse2(),
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAdresse3());
            if (annuelle2 != null) {
                Label fieldAdresseAnnuelle2 = new Label();
                formatLabel(fieldAdresseAnnuelle2, null, annuelle2);
                formAdresseAnnuelleLayout.addComponent(fieldAdresseAnnuelle2);
            }
            String captionVilleAnnuelle = applicationContext.getMessage(NAME + ".ville.title", null,
                    getLocale());
            Label fieldVilleAnnuelle = new Label();
            formatLabel(fieldVilleAnnuelle, captionVilleAnnuelle,
                    valuateTextFieldFromMultipleValues(
                            MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAdresseetranger(),
                            MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getCodePostal(),
                            MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getVille()));
            formAdresseAnnuelleLayout.addComponent(fieldVilleAnnuelle);

            String captionPaysAnnuelle = applicationContext.getMessage(NAME + ".pays.title", null, getLocale());
            Label fieldPaysAnnuelle = new Label();
            formatLabel(fieldPaysAnnuelle, captionPaysAnnuelle,
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getPays());
            formAdresseAnnuelleLayout.addComponent(fieldPaysAnnuelle);

            String captionTelephoneAnnuelle = applicationContext.getMessage(NAME + ".telephone.title", null,
                    getLocale());
            Label fieldTelephoneAnnuelle = new Label();
            formatLabel(fieldTelephoneAnnuelle, captionTelephoneAnnuelle,
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getNumerotel());
            formAdresseAnnuelleLayout.addComponent(fieldTelephoneAnnuelle);

            panelAdresseAnnuelle.setContent(formAdresseAnnuelleLayout);

            HorizontalLayout adresseAnnuelleGlobalLayout = new HorizontalLayout();
            adresseAnnuelleGlobalLayout.setSizeUndefined();
            adresseAnnuelleGlobalLayout.setStyleName("firstitembox");
            adresseAnnuelleGlobalLayout.addComponent(panelAdresseAnnuelle);
            adresseAnnuelleGlobalLayout.setExpandRatio(panelAdresseAnnuelle, 1);
            idLayout.addComponent(adresseAnnuelleGlobalLayout);
        }

        if (MainUI.getCurrent().getEtudiant().getAdresseFixe() != null) {
            FormLayout formAdresseFixeLayout = new FormLayout();
            formAdresseFixeLayout.setSpacing(true);
            formAdresseFixeLayout.setMargin(true);

            Panel panelAdresseFixe = new Panel(
                    applicationContext.getMessage(NAME + ".adressefixe.title", null, getLocale()));

            String captionAdresseFixe = applicationContext.getMessage(NAME + ".adresse.title", null,
                    getLocale());
            Label fieldAdresseFixe = new Label();
            formatLabel(fieldAdresseFixe, captionAdresseFixe,
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getAdresse1());
            formAdresseFixeLayout.addComponent(fieldAdresseFixe);

            String adfixe2 = valuateTextFieldFromMultipleValues(
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getAdresse2(),
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getAdresse3());
            if (adfixe2 != null) {
                Label fieldAdresseFixe2 = new Label();
                formatLabel(fieldAdresseFixe2, null, adfixe2);
                formAdresseFixeLayout.addComponent(fieldAdresseFixe2);
            }

            String captionVilleFixe = applicationContext.getMessage(NAME + ".ville.title", null, getLocale());
            Label fieldVilleFixe = new Label();
            formatLabel(fieldVilleFixe, captionVilleFixe,
                    valuateTextFieldFromMultipleValues(
                            MainUI.getCurrent().getEtudiant().getAdresseFixe().getAdresseetranger(),
                            MainUI.getCurrent().getEtudiant().getAdresseFixe().getCodePostal(),
                            MainUI.getCurrent().getEtudiant().getAdresseFixe().getVille()));
            formAdresseFixeLayout.addComponent(fieldVilleFixe);

            String captionPaysFixe = applicationContext.getMessage(NAME + ".pays.title", null, getLocale());
            Label fieldPaysFixe = new Label();
            formatLabel(fieldPaysFixe, captionPaysFixe,
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getPays());
            formAdresseFixeLayout.addComponent(fieldPaysFixe);

            String captionTelephoneFixe = applicationContext.getMessage(NAME + ".telephone.title", null,
                    getLocale());
            Label fieldTelephoneFixe = new Label();
            formatLabel(fieldTelephoneFixe, captionTelephoneFixe,
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getNumerotel());
            formAdresseFixeLayout.addComponent(fieldTelephoneFixe);

            panelAdresseFixe.setContent(formAdresseFixeLayout);

            HorizontalLayout adresseFixeGlobalLayout = new HorizontalLayout();
            adresseFixeGlobalLayout.setSizeUndefined();
            adresseFixeGlobalLayout.setStyleName("itembox");
            adresseFixeGlobalLayout.addComponent(panelAdresseFixe);
            adresseFixeGlobalLayout.setExpandRatio(panelAdresseFixe, 1);
            idLayout.addComponent(adresseFixeGlobalLayout);

        }

        addComponent(globalLayout);

        if (userController.isEtudiant() && configController.isModificationAdressesAutorisee()
                && MainUI.getCurrent().getEtudiant().getAdresseAnnuelle() != null) {
            HorizontalLayout btnLayout = new HorizontalLayout();
            btnLayout.setSizeFull();
            btnLayout.setSpacing(true);

            Button btnModifAdresses = new Button(
                    applicationContext.getMessage(NAME + ".bouton.modifieradresses", null, getLocale()));
            btnModifAdresses.setStyleName(ValoTheme.BUTTON_PRIMARY);
            btnModifAdresses.setIcon(FontAwesome.EDIT);
            btnModifAdresses.addClickListener(e -> {
                ModificationAdressesWindow maw = new ModificationAdressesWindow(
                        MainUI.getCurrent().getEtudiant());
                maw.addCloseListener(f -> {
                    init();
                });
                UI.getCurrent().addWindow(maw);
            });
            btnLayout.addComponent(btnModifAdresses);
            btnLayout.setComponentAlignment(btnModifAdresses, Alignment.MIDDLE_LEFT);
            addComponent(btnLayout);
        }
    }
}