Example usage for com.vaadin.ui Button setDescription

List of usage examples for com.vaadin.ui Button setDescription

Introduction

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

Prototype

public void setDescription(String description) 

Source Link

Document

Sets the component's description.

Usage

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

License:Apache License

/**
 * Initialise la vue/*w  w  w .  ja v a  2  s.  com*/
 */
@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) {

        LOG.debug(userController.getCurrentUserName() + " NotesView");

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

        //Test si user enseignant et en vue Enseignant
        if (userController.isEnseignant() && MainUI.getCurrent().isVueEnseignantNotesEtResultats()) {
            //On recupere les notes pour un enseignant
            etudiantController.renseigneNotesEtResultatsVueEnseignant(MainUI.getCurrent().getEtudiant());
        } else {
            //On rcupre les notes pour un tudiant
            etudiantController.renseigneNotesEtResultats(MainUI.getCurrent().getEtudiant());
        }

        /* Titre */
        HorizontalLayout titleLayout = new HorizontalLayout();
        titleLayout.setWidth("100%");
        Label title = new Label(applicationContext.getMessage(NAME + ".title", null, getLocale()));
        title.addStyleName(ValoTheme.LABEL_H1);
        titleLayout.addComponent(title);
        titleLayout.setComponentAlignment(title, Alignment.MIDDLE_LEFT);
        //Test si on a des diplomes ou des etapes
        if ((MainUI.getCurrent().getEtudiant().getDiplomes() != null
                && MainUI.getCurrent().getEtudiant().getDiplomes().size() > 0)
                || (MainUI.getCurrent().getEtudiant().getEtapes() != null
                        && MainUI.getCurrent().getEtudiant().getEtapes().size() > 0)) {
            Button pdfButton = new Button();
            pdfButton.setStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
            pdfButton.addStyleName("button-big-icon");
            pdfButton.addStyleName("red-button-icon");
            pdfButton.setIcon(FontAwesome.FILE_PDF_O);
            pdfButton.setDescription(
                    applicationContext.getMessage(NAME + ".btn.pdf.description", null, getLocale()));
            if (PropertyUtils.isPushEnabled()) {
                MyFileDownloader fd = new MyFileDownloader(noteController.exportPdfResume());
                fd.extend(pdfButton);
            } else {
                FileDownloader fd = new FileDownloader(noteController.exportPdfResume());
                fd.setOverrideContentType(false);
                fd.extend(pdfButton);
            }
            titleLayout.addComponent(pdfButton);
            titleLayout.setComponentAlignment(pdfButton, Alignment.MIDDLE_RIGHT);
        }
        addComponent(titleLayout);

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

        //Test si user enseignant
        if (userController.isEnseignant()) {
            Panel panelVue = new Panel();

            HorizontalLayout vueLayout = new HorizontalLayout();
            vueLayout.setMargin(true);
            vueLayout.setSpacing(true);
            vueLayout.setSizeFull();

            Button changerVueButton = new Button(
                    applicationContext.getMessage(NAME + ".button.vueEnseignant", null, getLocale()));
            changerVueButton.setStyleName(ValoTheme.BUTTON_PRIMARY);
            if (MainUI.getCurrent().isVueEnseignantNotesEtResultats()) {
                changerVueButton.setStyleName(ValoTheme.BUTTON_FRIENDLY);
                changerVueButton.setCaption(
                        applicationContext.getMessage(NAME + ".button.vueEtudiant", null, getLocale()));
            }
            //On change la variable vueEnseignantNotesEtResultats et on recr la vue en cours
            changerVueButton.addClickListener(e -> {
                etudiantController.changerVueNotesEtResultats();
                init();
            });

            Label vueLabel = new Label(
                    applicationContext.getMessage(NAME + ".label.vueEtudiant", null, getLocale()));
            if (MainUI.getCurrent().isVueEnseignantNotesEtResultats()) {
                vueLabel.setValue(
                        applicationContext.getMessage(NAME + ".label.vueEnseignant", null, getLocale()));
            }
            vueLabel.setContentMode(ContentMode.HTML);
            vueLabel.setStyleName(ValoTheme.LABEL_SMALL);

            vueLayout.addComponent(changerVueButton);
            vueLayout.setComponentAlignment(changerVueButton, Alignment.MIDDLE_CENTER);
            vueLayout.addComponent(vueLabel);
            vueLayout.setExpandRatio(vueLabel, 1);

            panelVue.setContent(vueLayout);
            globalLayout.addComponent(panelVue);
        }

        Panel panelNotesDiplomes = new Panel(
                applicationContext.getMessage(NAME + ".table.diplomes", null, getLocale()));
        //panelNotesDiplomes.addStyleName("small-font-element");

        Table notesDiplomesTable = new Table(null,
                new BeanItemContainer<>(Diplome.class, MainUI.getCurrent().getEtudiant().getDiplomes()));
        notesDiplomesTable.setWidth("100%");
        notesDiplomesTable.setVisibleColumns((Object[]) DIPLOMES_FIELDS_ORDER);
        for (String fieldName : DIPLOMES_FIELDS_ORDER) {
            notesDiplomesTable.setColumnHeader(fieldName,
                    applicationContext.getMessage(NAME + ".table.diplomes." + fieldName, null, getLocale()));
        }
        notesDiplomesTable.addGeneratedColumn(
                applicationContext.getMessage(NAME + ".table.diplomes.session", null, getLocale()),
                new SessionColumnGenerator());
        notesDiplomesTable.addGeneratedColumn(
                applicationContext.getMessage(NAME + ".table.diplomes.note", null, getLocale()),
                new NoteColumnGenerator());
        notesDiplomesTable.addGeneratedColumn(
                applicationContext.getMessage(NAME + ".table.diplomes.resultat", null, getLocale()),
                new ResultatColumnGenerator());

        if (MainUI.getCurrent().getEtudiant().isAfficherRang()) {
            notesDiplomesTable.addGeneratedColumn(
                    applicationContext.getMessage(NAME + ".table.diplomes.mention", null, getLocale()),
                    new MentionColumnGenerator());
        }
        if (configController.isAffMentionEtudiant()) {
            notesDiplomesTable.addGeneratedColumn(
                    applicationContext.getMessage(NAME + ".table.diplomes.rang", null, getLocale()),
                    new RangColumnGenerator());
        }

        notesDiplomesTable.setColumnCollapsingAllowed(true);
        notesDiplomesTable.setColumnReorderingAllowed(false);
        notesDiplomesTable.setSelectable(false);
        notesDiplomesTable.setImmediate(true);
        notesDiplomesTable.setStyleName("noscrollabletable");
        notesDiplomesTable.setPageLength(notesDiplomesTable.getItemIds().size());
        panelNotesDiplomes.setContent(notesDiplomesTable);
        globalLayout.addComponent(panelNotesDiplomes);

        Panel panelNotesEtapes = new Panel(
                applicationContext.getMessage(NAME + ".table.etapes", null, getLocale()));
        //panelNotesEtapes.addStyleName("small-font-element");

        Table notesEtapesTable = new Table(null,
                new BeanItemContainer<>(Etape.class, MainUI.getCurrent().getEtudiant().getEtapes()));
        notesEtapesTable.setWidth("100%");
        notesEtapesTable.setVisibleColumns((Object[]) ETAPES_FIELDS_ORDER);
        for (String fieldName : ETAPES_FIELDS_ORDER) {
            notesEtapesTable.setColumnHeader(fieldName,
                    applicationContext.getMessage(NAME + ".table.etapes." + fieldName, null, getLocale()));
        }
        notesEtapesTable.addGeneratedColumn(
                applicationContext.getMessage(NAME + ".table.etapes.codevers", null, getLocale()),
                new CodeEtapeColumnGenerator());
        notesEtapesTable.addGeneratedColumn(
                applicationContext.getMessage(NAME + ".table.etapes.libelle", null, getLocale()),
                new LibelleEtapeColumnGenerator());
        notesEtapesTable.addGeneratedColumn(
                applicationContext.getMessage(NAME + ".table.etapes.session", null, getLocale()),
                new SessionColumnGenerator());
        notesEtapesTable.addGeneratedColumn(
                applicationContext.getMessage(NAME + ".table.etapes.note", null, getLocale()),
                new NoteColumnGenerator());
        notesEtapesTable.addGeneratedColumn(
                applicationContext.getMessage(NAME + ".table.etapes.resultat", null, getLocale()),
                new ResultatColumnGenerator());

        if (MainUI.getCurrent().getEtudiant().isAfficherRang()) {
            notesEtapesTable.addGeneratedColumn(
                    applicationContext.getMessage(NAME + ".table.etapes.mention", null, getLocale()),
                    new MentionColumnGenerator());
        }
        if (configController.isAffMentionEtudiant()) {
            notesEtapesTable.addGeneratedColumn(
                    applicationContext.getMessage(NAME + ".table.etapes.rang", null, getLocale()),
                    new RangColumnGenerator());
        }

        notesEtapesTable.setColumnCollapsingAllowed(true);
        notesEtapesTable.setColumnReorderingAllowed(false);
        notesEtapesTable.setSelectable(false);
        notesEtapesTable.setImmediate(true);
        notesEtapesTable.setStyleName("noscrollabletable");
        notesEtapesTable.setPageLength(notesEtapesTable.getItemIds().size());
        panelNotesEtapes.setContent(notesEtapesTable);
        globalLayout.addComponent(panelNotesEtapes);

        if (MainUI.getCurrent().getEtudiant().isSignificationResultatsUtilisee()) {
            Panel panelSignificationResultats = new Panel(
                    applicationContext.getMessage(NAME + ".info.significations.resultats", null, getLocale()));

            panelSignificationResultats.addStyleName("significationpanel");
            panelSignificationResultats.setIcon(FontAwesome.INFO_CIRCLE);

            VerticalLayout significationLayout = new VerticalLayout();
            significationLayout.setMargin(true);
            significationLayout.setSpacing(true);

            String grilleSignficationResultats = "";
            //grilleSignficationResultats = significationResultats.toString().substring(1,significationResultats.toString().length()-1);
            Set<String> ss = MainUI.getCurrent().getEtudiant().getSignificationResultats().keySet();
            for (String k : ss) {
                if (k != null && !k.equals("") && !k.equals(" ")) {
                    grilleSignficationResultats = grilleSignficationResultats + "<b>" + k + "</b>&#160;:&#160;"
                            + MainUI.getCurrent().getEtudiant().getSignificationResultats().get(k);
                    grilleSignficationResultats = grilleSignficationResultats + "&#160;&#160;&#160;";
                }
            }
            Label mapSignificationLabel = new Label(grilleSignficationResultats);
            mapSignificationLabel.setContentMode(ContentMode.HTML);
            mapSignificationLabel.setStyleName(ValoTheme.LABEL_SMALL);
            significationLayout.addComponent(mapSignificationLabel);

            panelSignificationResultats.setContent(significationLayout);
            globalLayout.addComponent(panelSignificationResultats);
        }

        addComponent(globalLayout);
    }
}

From source file:fr.univlorraine.mondossierweb.views.windows.DetailNotesWindow.java

License:Apache License

private void init() {

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

        /* Style */
        setWidth(80, Unit.PERCENTAGE);/*from ww w  .  ja  v  a 2s  . co m*/
        setHeight(95, Unit.PERCENTAGE);
        setModal(true);
        setResizable(false);

        //Test si user enseignant et en vue Enseignant
        if (userController.isEnseignant() && MainUI.getCurrent().isVueEnseignantNotesEtResultats()) {
            //On recupere les notes pour un enseignant
            etudiantController.renseigneDetailNotesEtResultatsEnseignant(etape);
        } else {
            //On rcupre les notes pour un tudiant
            etudiantController.renseigneDetailNotesEtResultats(etape);
        }

        /* Layout */
        VerticalLayout layout = new VerticalLayout();
        layout.setSizeFull();
        layout.setMargin(true);
        layout.setSpacing(true);

        /* Titre */
        setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale()));

        List<ElementPedagogique> lelp = MainUI.getCurrent().getEtudiant().getElementsPedagogiques();

        //Sous titre avec l'anne
        HorizontalLayout titleLayout = new HorizontalLayout();
        titleLayout.setSizeFull();
        titleLayout.setHeight("20px");
        Label messageLabel = new Label(
                applicationContext.getMessage(NAME + ".label.messageinfo", null, getLocale()));
        messageLabel.setContentMode(ContentMode.HTML);
        messageLabel.setStyleName(ValoTheme.LABEL_SMALL);
        titleLayout.addComponent(messageLabel);
        titleLayout.setExpandRatio(messageLabel, 1);
        titleLayout.setComponentAlignment(messageLabel, Alignment.MIDDLE_LEFT);

        //Test si user enseignant
        if (userController.isEnseignant() && lelp != null && lelp.size() > 0) {
            //Bouton pour afficher les filtres
            btnDisplayFiltres = new Button();
            btnDisplayFiltres.setWidth("52px");
            btnDisplayFiltres.setHeight("32px");
            btnDisplayFiltres.setStyleName(ValoTheme.BUTTON_PRIMARY);
            if (MainUI.getCurrent().isVueEnseignantNotesEtResultats()) {
                btnDisplayFiltres.setStyleName(ValoTheme.BUTTON_FRIENDLY);
            }
            btnDisplayFiltres.setIcon(FontAwesome.FILTER);
            btnDisplayFiltres.setDescription(
                    applicationContext.getMessage(NAME + ".btn.displayFilters", null, getLocale()));
            btnDisplayFiltres.addClickListener(e -> {
                btnDisplayFiltres.setVisible(false);
                panelVue.setVisible(true);
            });
            titleLayout.addComponent(btnDisplayFiltres);
            titleLayout.setComponentAlignment(btnDisplayFiltres, Alignment.MIDDLE_RIGHT);
            //titleLayout.setExpandRatio(btnDisplayFiltres, 1);
            btnDisplayFiltres.setVisible(true);
        }

        if (lelp != null && lelp.size() > 0 && configController.isPdfNotesActive()) {
            Button pdfButton = new Button();
            pdfButton.setStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
            pdfButton.addStyleName("button-icon");
            pdfButton.addStyleName("red-button-icon");
            pdfButton.setIcon(FontAwesome.FILE_PDF_O);
            pdfButton.setDescription(
                    applicationContext.getMessage(NAME + ".btn.pdf.description", null, getLocale()));

            if (PropertyUtils.isPushEnabled()) {
                MyFileDownloader fd = new MyFileDownloader(noteController.exportPdfDetail(etape));
                fd.extend(pdfButton);
            } else {
                FileDownloader fd = new FileDownloader(noteController.exportPdfDetail(etape));
                fd.extend(pdfButton);
            }

            titleLayout.addComponent(pdfButton);
            titleLayout.setComponentAlignment(pdfButton, Alignment.MIDDLE_RIGHT);
        }
        layout.addComponent(titleLayout);

        //Test si user enseignant
        if (userController.isEnseignant() && lelp != null && lelp.size() > 0) {
            panelVue = new Panel();

            HorizontalLayout vueLayout = new HorizontalLayout();
            vueLayout.setMargin(true);
            vueLayout.setSpacing(true);
            vueLayout.setSizeFull();

            Button changerVueButton = new Button(
                    applicationContext.getMessage(NAME + ".button.vueEnseignant", null, getLocale()));
            changerVueButton.setStyleName(ValoTheme.BUTTON_PRIMARY);
            if (MainUI.getCurrent().isVueEnseignantNotesEtResultats()) {
                changerVueButton.setStyleName(ValoTheme.BUTTON_FRIENDLY);
                changerVueButton.setCaption(
                        applicationContext.getMessage(NAME + ".button.vueEtudiant", null, getLocale()));
            }
            //On change la variable vueEnseignantNotesEtResultats et on recr la vue en cours
            changerVueButton.addClickListener(e -> {
                etudiantController.changerVueNotesEtResultats();
                init();
            });

            Label vueLabel = new Label(
                    applicationContext.getMessage(NAME + ".label.vueEtudiant", null, getLocale()));
            if (MainUI.getCurrent().isVueEnseignantNotesEtResultats()) {
                vueLabel.setValue(
                        applicationContext.getMessage(NAME + ".label.vueEnseignant", null, getLocale()));
            }
            vueLabel.setContentMode(ContentMode.HTML);
            vueLabel.setStyleName(ValoTheme.LABEL_SMALL);

            vueLayout.addComponent(changerVueButton);
            vueLayout.setComponentAlignment(changerVueButton, Alignment.MIDDLE_CENTER);
            vueLayout.addComponent(vueLabel);
            vueLayout.setExpandRatio(vueLabel, 1);

            panelVue.setContent(vueLayout);
            layout.addComponent(panelVue);
            panelVue.setVisible(false);
        }

        Panel panelDetailNotes = new Panel(etape.getLibelle() + " - "
                + applicationContext.getMessage(NAME + ".label.anneeuniv", null, getLocale()) + " "
                + etape.getAnnee());
        panelDetailNotes.addStyleName("small-font-element");
        panelDetailNotes.setSizeFull();

        if (lelp != null && lelp.size() > 0) {
            Table detailNotesTable = new Table(null, new BeanItemContainer<>(ElementPedagogique.class, lelp));
            detailNotesTable.setSizeFull();
            detailNotesTable.setVisibleColumns(new String[0]);
            if (contientElpObtenusPrecedemment(lelp)) {
                detailNotesTable.addGeneratedColumn(
                        applicationContext.getMessage(NAME + ".table.elp.annee", null, getLocale()),
                        new AnneeColumnGenerator());
            }
            detailNotesTable.addGeneratedColumn(
                    applicationContext.getMessage(NAME + ".table.elp.code", null, getLocale()),
                    new CodeElpColumnGenerator());
            detailNotesTable.addGeneratedColumn(
                    applicationContext.getMessage(NAME + ".table.elp.libelle", null, getLocale()),
                    new LibelleElpColumnGenerator());
            detailNotesTable.addGeneratedColumn(
                    applicationContext.getMessage(NAME + ".table.elp.notesession1", null, getLocale()),
                    new Session1ColumnGenerator());
            detailNotesTable.addGeneratedColumn(
                    applicationContext.getMessage(NAME + ".table.elp.resultatsession1", null, getLocale()),
                    new ResultatSession1ColumnGenerator());
            detailNotesTable.addGeneratedColumn(
                    applicationContext.getMessage(NAME + ".table.elp.notesession2", null, getLocale()),
                    new Session2ColumnGenerator());
            detailNotesTable.addGeneratedColumn("resultatsession2", new ResultatSession2ColumnGenerator());
            detailNotesTable.setColumnHeader("resultatsession2",
                    applicationContext.getMessage(NAME + ".table.elp.resultatsession2", null, getLocale()));
            if (configController.isAffRangEtudiant() || etudiantController.isAfficherRangElpEpr()) {
                detailNotesTable.addGeneratedColumn(
                        applicationContext.getMessage(NAME + ".table.elp.rang", null, getLocale()),
                        new RangColumnGenerator());
            }
            if (configController.isAffECTSEtudiant()) {
                detailNotesTable.addGeneratedColumn(
                        applicationContext.getMessage(NAME + ".table.elp.ects", null, getLocale()),
                        new ECTSColumnGenerator());
            }
            detailNotesTable.setColumnCollapsingAllowed(true);
            detailNotesTable.setColumnReorderingAllowed(false);
            detailNotesTable.setSelectable(false);
            detailNotesTable.setImmediate(true);
            detailNotesTable.addStyleName("scrollabletable");
            panelDetailNotes.setContent(detailNotesTable);
        } else {
            setHeight(30, Unit.PERCENTAGE);
            HorizontalLayout messageLayout = new HorizontalLayout();
            messageLayout.setSpacing(true);
            messageLayout.setMargin(true);
            Label labelAucunResultat = new Label(
                    applicationContext.getMessage(NAME + ".message.aucuneresultat", null, getLocale()));
            labelAucunResultat.setStyleName(ValoTheme.LABEL_BOLD);
            messageLayout.addComponent(labelAucunResultat);
            panelDetailNotes.setContent(messageLayout);

        }
        layout.addComponent(panelDetailNotes);

        if (lelp != null && lelp.size() > 0
                && MainUI.getCurrent().getEtudiant().isSignificationResultatsUtilisee()) {
            Panel panelSignificationResultats = new Panel(
                    applicationContext.getMessage(NAME + ".info.significations.resultats", null, getLocale()));

            panelSignificationResultats.addStyleName("significationpanel");
            panelSignificationResultats.addStyleName("small-font-element");
            panelSignificationResultats.setIcon(FontAwesome.INFO_CIRCLE);

            VerticalLayout significationLayout = new VerticalLayout();
            significationLayout.setMargin(true);
            significationLayout.setSpacing(true);

            String grilleSignficationResultats = "";
            //grilleSignficationResultats = significationResultats.toString().substring(1,significationResultats.toString().length()-1);
            Set<String> ss = MainUI.getCurrent().getEtudiant().getSignificationResultats().keySet();
            for (String k : ss) {
                if (k != null && !k.equals("") && !k.equals(" ")) {
                    grilleSignficationResultats = grilleSignficationResultats + "<b>" + k + "</b>&#160;:&#160;"
                            + MainUI.getCurrent().getEtudiant().getSignificationResultats().get(k);
                    grilleSignficationResultats = grilleSignficationResultats + "&#160;&#160;&#160;";
                }
            }
            Label mapSignificationLabel = new Label(grilleSignficationResultats);
            mapSignificationLabel.setStyleName(ValoTheme.LABEL_SMALL);
            mapSignificationLabel.setContentMode(ContentMode.HTML);
            significationLayout.addComponent(mapSignificationLabel);

            panelSignificationResultats.setContent(significationLayout);
            layout.addComponent(panelSignificationResultats);

        }

        layout.setExpandRatio(panelDetailNotes, 1);

        setContent(layout);

        /* Centre la fentre */
        center();

    }

}

From source file:info.magnolia.security.app.dialog.field.WebAccessFieldFactory.java

License:Open Source License

private Component createRuleRow(final AbstractOrderedLayout parentContainer,
        final AbstractJcrNodeAdapter ruleItem, final Label emptyLabel) {

    final HorizontalLayout ruleLayout = new HorizontalLayout();
    ruleLayout.setSpacing(true);/*from  www  . j a  v  a  2 s. c  o m*/
    ruleLayout.setWidth("100%");

    NativeSelect accessRights = new NativeSelect();
    accessRights.addItem(Permission.ALL);
    accessRights.setItemCaption(Permission.ALL, i18n.translate("security.web.field.getPost"));
    accessRights.addItem(Permission.READ);
    accessRights.setItemCaption(Permission.READ, i18n.translate("security.web.field.get"));
    accessRights.addItem(Permission.NONE);
    accessRights.setItemCaption(Permission.NONE, i18n.translate("security.web.field.deny"));
    accessRights.setNullSelectionAllowed(false);
    accessRights.setImmediate(true);
    accessRights.setInvalidAllowed(false);
    accessRights.setNewItemsAllowed(false);
    Property permissionsProperty = ruleItem.getItemProperty(PERMISSIONS_PROPERTY_NAME);
    if (permissionsProperty == null) {
        permissionsProperty = new DefaultProperty<Long>(Long.class, Permission.ALL);
        ruleItem.addItemProperty(PERMISSIONS_PROPERTY_NAME, permissionsProperty);
    }
    accessRights.setPropertyDataSource(permissionsProperty);
    ruleLayout.addComponent(accessRights);

    TextField path = new TextField();
    path.setWidth("100%");
    Property pathProperty = ruleItem.getItemProperty(PATH_PROPERTY_NAME);
    if (pathProperty == null) {
        pathProperty = new DefaultProperty<String>(String.class, "/*");
        ruleItem.addItemProperty(PATH_PROPERTY_NAME, pathProperty);
    }
    path.setPropertyDataSource(pathProperty);
    ruleLayout.addComponent(path);
    ruleLayout.setExpandRatio(path, 1.0f);

    final Button deleteButton = new Button();
    deleteButton.setHtmlContentAllowed(true);
    deleteButton.setCaption("<span class=\"" + "icon-trash" + "\"></span>");
    deleteButton.addStyleName("inline");
    deleteButton.setDescription(i18n.translate("security.web.field.delete"));
    deleteButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            parentContainer.removeComponent(ruleLayout);
            ruleItem.getParent().removeChild(ruleItem);
            if (parentContainer.getComponentCount() == 1) {
                parentContainer.addComponent(emptyLabel, 0);
            }
        }
    });
    ruleLayout.addComponent(deleteButton);

    return ruleLayout;
}

From source file:info.magnolia.security.app.dialog.field.WorkspaceAccessFieldFactory.java

License:Open Source License

protected Component createRuleRow(final AbstractOrderedLayout parentContainer,
        final AbstractJcrNodeAdapter ruleItem, final Label emptyLabel) {

    final HorizontalLayout ruleLayout = new HorizontalLayout();
    ruleLayout.setSpacing(true);/*from   www. j  a  v  a2  s  . com*/
    ruleLayout.setWidth("100%");

    NativeSelect accessRights = new NativeSelect();
    accessRights.setNullSelectionAllowed(false);
    accessRights.setImmediate(true);
    accessRights.setInvalidAllowed(false);
    accessRights.setNewItemsAllowed(false);
    accessRights.addItem(Permission.ALL);
    accessRights.setItemCaption(Permission.ALL, i18n.translate("security.workspace.field.readWrite"));
    accessRights.addItem(Permission.READ);
    accessRights.setItemCaption(Permission.READ, i18n.translate("security.workspace.field.readOnly"));
    accessRights.addItem(Permission.NONE);
    accessRights.setItemCaption(Permission.NONE, i18n.translate("security.workspace.field.denyAccess"));
    accessRights.setPropertyDataSource(ruleItem.getItemProperty(AccessControlList.PERMISSIONS_PROPERTY_NAME));
    ruleLayout.addComponent(accessRights);

    NativeSelect accessType = new NativeSelect();
    accessType.setNullSelectionAllowed(false);
    accessType.setImmediate(true);
    accessType.setInvalidAllowed(false);
    accessType.setNewItemsAllowed(false);
    accessType.setWidth("150px");
    accessType.addItem(AccessControlList.ACCESS_TYPE_NODE);
    accessType.setItemCaption(AccessControlList.ACCESS_TYPE_NODE,
            i18n.translate("security.workspace.field.selected"));
    accessType.addItem(AccessControlList.ACCESS_TYPE_CHILDREN);
    accessType.setItemCaption(AccessControlList.ACCESS_TYPE_CHILDREN,
            i18n.translate("security.workspace.field.subnodes"));
    accessType.addItem(AccessControlList.ACCESS_TYPE_NODE_AND_CHILDREN);
    accessType.setItemCaption(AccessControlList.ACCESS_TYPE_NODE_AND_CHILDREN,
            i18n.translate("security.workspace.field.selectedSubnodes"));
    Property accessTypeProperty = ruleItem.getItemProperty(ACCESS_TYPE_PROPERTY_NAME);
    accessType.setPropertyDataSource(accessTypeProperty);
    ruleLayout.addComponent(accessType);

    final TextField path = new TextField();
    path.setWidth("100%");
    path.setPropertyDataSource(ruleItem.getItemProperty(AccessControlList.PATH_PROPERTY_NAME));
    ruleLayout.addComponent(path);
    ruleLayout.setExpandRatio(path, 1.0f);

    Button chooseButton = new Button(i18n.translate("security.workspace.field.choose"));
    chooseButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            openChooseDialog(path);
        }
    });
    ruleLayout.addComponent(chooseButton);

    Button deleteButton = new Button();
    deleteButton.setHtmlContentAllowed(true);
    deleteButton.setCaption("<span class=\"" + "icon-trash" + "\"></span>");
    deleteButton.addStyleName("inline");
    deleteButton.setDescription(i18n.translate("security.workspace.field.delete"));
    deleteButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            parentContainer.removeComponent(ruleLayout);
            ruleItem.getParent().removeChild(ruleItem);
            if (parentContainer.getComponentCount() == 1) {
                parentContainer.addComponent(emptyLabel, 0);
            }
        }
    });
    ruleLayout.addComponent(deleteButton);

    return ruleLayout;
}

From source file:info.magnolia.ui.form.field.MultiField.java

License:Open Source License

/**
 * Create a single element.<br>//w ww.ja  v  a 2 s .c  o  m
 * This single element is composed of:<br>
 * - a configured field <br>
 * - a remove Button<br>
 */
private Component createEntryComponent(Object propertyId, Property<?> property) {

    final HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setHeight(-1, Unit.PIXELS);

    final Field<?> field = createLocalField(fieldDefinition, property, true); // creates property datasource if given property is null
    layout.addComponent(field);

    // bind the field's property to the item
    if (property == null) {
        property = field.getPropertyDataSource();
        ((PropertysetItem) getPropertyDataSource().getValue()).addItemProperty(propertyId, property);
    }
    final Property<?> propertyReference = property;
    // set layout to full width
    layout.setWidth(100, Unit.PERCENTAGE);

    // distribute space in favour of field over delete button
    layout.setExpandRatio(field, 1);
    if (definition.isReadOnly()) {
        return layout;
    }

    // move up Button
    Button moveUpButton = new Button();
    moveUpButton.setHtmlContentAllowed(true);
    moveUpButton.setCaption("<span class=\"" + "icon-arrow2_n" + "\"></span>");
    moveUpButton.addStyleName("inline");
    moveUpButton.setDescription(buttonCaptionMoveUp);
    moveUpButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            onMove(layout, propertyReference, true);
        }
    });

    // move down Button
    Button moveDownButton = new Button();
    moveDownButton.setHtmlContentAllowed(true);
    moveDownButton.setCaption("<span class=\"" + "icon-arrow2_s" + "\"></span>");
    moveDownButton.addStyleName("inline");
    moveDownButton.setDescription(buttonCaptionMoveDown);
    moveDownButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            onMove(layout, propertyReference, false);
        }
    });

    // Delete Button
    Button deleteButton = new Button();
    deleteButton.setHtmlContentAllowed(true);
    deleteButton.setCaption("<span class=\"" + "icon-trash" + "\"></span>");
    deleteButton.addStyleName("inline");
    deleteButton.setDescription(buttonCaptionRemove);
    deleteButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            onDelete(layout, propertyReference);
        }
    });

    layout.addComponents(moveUpButton, moveDownButton, deleteButton);

    // make sure button stays aligned with the field and not with the optional field label when used
    layout.setComponentAlignment(deleteButton, Alignment.BOTTOM_RIGHT);
    layout.setComponentAlignment(moveUpButton, Alignment.BOTTOM_RIGHT);
    layout.setComponentAlignment(moveDownButton, Alignment.BOTTOM_RIGHT);

    return layout;
}

From source file:info.magnolia.ui.form.field.upload.basic.BasicUploadField.java

License:Open Source License

/**
 * Create Delete button.//from   w  w w  .j a  va2  s.c  o m
 */
protected Button createDeleteButton() {
    Button deleteButton = new Button();
    deleteButton.setHtmlContentAllowed(true);
    deleteButton.setCaption("<span class=\"" + "icon-trash" + "\"></span>");
    deleteButton.addStyleName("inline");
    deleteButton.setDescription(i18n.translate(deleteCaption));

    deleteButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            resetDataSource();
            updateDisplay();
        }
    });
    return deleteButton;
}

From source file:io.mateu.ui.vaadin.framework.MyUI.java

License:Apache License

/**
 * construye el menu//  w ww.  ja  v a  2s  .  c o m
 *
 * @param request
 * @return
 */
CssLayout buildMenu(VaadinRequest request) {

    HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName(ValoTheme.MENU_TITLE);
    menu.addComponent(top);
    //menu.addComponent(createThemeSelect());

    Button showMenu = new Button("Menu", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (menu.getStyleName().contains("valo-menu-visible")) {
                menu.removeStyleName("valo-menu-visible");
            } else {
                menu.addStyleName("valo-menu-visible");
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName("valo-menu-toggle");
    showMenu.setIcon(FontAwesome.LIST);
    menu.addComponent(showMenu);

    //Label title = new Label("<h3><strong>" + getApp().getName() + "</strong></h3>", ContentMode.HTML);

    Button title = new Button(getApp().getName(), new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            Page.getCurrent().open("#!",
                    (event.isAltKey() || event.isCtrlKey()) ? "_blank" : Page.getCurrent().getWindowName());
        }
    });
    title.addStyleName(ValoTheme.BUTTON_LINK);
    title.addStyleName("tituloapp");

    title.setSizeUndefined();
    top.addComponent(title);
    top.setExpandRatio(title, 1);

    settings = new MenuBar();
    settings.addStyleName("user-menu");
    settings.addStyleName("mi-user-menu");
    menu.addComponent(settings);

    HorizontalLayout navlinks = new HorizontalLayout();
    navlinks.setSpacing(true);

    {
        Button nav = new Button(VaadinIcons.ARROWS_CROSS, new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                Page.getCurrent().open("#!nav",
                        (event.isAltKey() || event.isCtrlKey()) ? "_blank" : Page.getCurrent().getWindowName());
            }
        });
        nav.addStyleName(ValoTheme.BUTTON_LINK);
        nav.setDescription("Search inside menu");
        nav.addStyleName("navlink");

        navlinks.addComponent(nav);
    }

    if (MateuUI.getApp().isFavouritesAvailable()) {
        Button nav = new Button(VaadinIcons.USER_STAR, new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                Page.getCurrent().open("#!favourites",
                        (event.isAltKey() || event.isCtrlKey()) ? "_blank" : Page.getCurrent().getWindowName());
            }
        });
        nav.addStyleName(ValoTheme.BUTTON_LINK);
        nav.addStyleName("navlink");
        nav.setDescription("My favourites");
        nav.setVisible(MateuUI.getApp().getUserData() != null);

        linkFavoritos = nav;

        navlinks.addComponent(nav);
    }

    if (MateuUI.getApp().isLastEditedAvailable()) {
        Button nav = new Button(VaadinIcons.RECORDS, new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                Page.getCurrent().open("#!lastedited",
                        (event.isAltKey() || event.isCtrlKey()) ? "_blank" : Page.getCurrent().getWindowName());
            }
        });
        nav.addStyleName(ValoTheme.BUTTON_LINK);
        nav.addStyleName("navlink");
        nav.setDescription("Last edited records");
        nav.setVisible(MateuUI.getApp().getUserData() != null);

        linkUltimosRegistros = nav;

        navlinks.addComponent(nav);
    }

    HorizontalLayout aux = new HorizontalLayout(navlinks);
    aux.setSpacing(false);
    aux.addStyleName("contenedoriconosnav");
    menu.addComponent(aux);

    if (MateuUI.getApp().isFavouritesAvailable()) {
        aux = new HorizontalLayout();
        {
            Button nav = new Button(VaadinIcons.STAR, new ClickListener() {
                @Override
                public void buttonClick(ClickEvent event) {
                    System.out.println(Page.getCurrent().getUriFragment());
                    System.out.println(Page.getCurrent().getLocation());
                }
            });
            nav.addStyleName(ValoTheme.BUTTON_LINK);
            nav.addStyleName("navlink");
            nav.setDescription("Add current page to my favourites");
            nav.setVisible(MateuUI.getApp().getUserData() != null);

            linkNuevoFavorito = nav;

            aux.addComponent(nav);
        }
        aux.setSpacing(false);
        aux.addStyleName("contenedoriconosnav");
        menu.addComponent(aux);
    }

    menuItemsLayout.setPrimaryStyleName("valo-menuitems");
    menu.addComponent(menuItemsLayout);

    refreshMenu(null, null);

    return menu;
}

From source file:it.vige.greenarea.bpm.custom.ui.form.GreenareaAbstractFormPropertyRenderer.java

License:Apache License

protected void addButton(String operation, HorizontalLayout buttons, final String item, final Table table) {
    final String finalOperation = operation;
    final Button button = new Button();
    if (operation.equals(MODIFICA.name()))
        button.setIcon(new ThemeResource("img/edit.png"));
    else if (operation.equals(CANCELLAZIONE.name()))
        button.setIcon(new ThemeResource("img/delete.png"));
    else/*from www  . j  a  v  a  2  s  .  co m*/
        button.setIcon(new ThemeResource("img/task-16.png"));
    button.addStyleName(BUTTON_LINK);
    I18nManager i18nManager = get().getI18nManager();
    button.setDescription(i18nManager.getMessage(operation));
    buttons.addComponent(button);
    buttons.setComponentAlignment(button, BOTTOM_RIGHT);
    button.addListener(new ClickListener() {

        private static final long serialVersionUID = -6091586145870618870L;

        public void buttonClick(ClickEvent event) {
            // Extract the submitted values from the form. Throws
            // exception
            // when validation fails.
            try {
                table.select(item);
                Map<String, String> formProperties = greenareaFormPropertiesForm
                        .getGreenareaFormPropertiesComponent().getFormPropertyValues();
                setOperation(formProperties, finalOperation);
                greenareaFormPropertiesForm.getMainTitle()
                        .setPropertyDataSource(new ObjectProperty<String>(
                                greenareaFormPropertiesForm.getMainTitle().getValue() + " > " + finalOperation,
                                String.class));
                FormPropertiesEvent formPropertiesEvent = greenareaFormPropertiesForm.new FormPropertiesEvent(
                        greenareaFormPropertiesForm, TYPE_SUBMIT, formProperties);
                greenareaFormPropertiesForm.fireEvent(formPropertiesEvent);
                button.setComponentError(null);
            } catch (InvalidValueException ive) {
                // Error is presented to user by the form component
            }
        }
    });

}

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

License:Open Source License

MyCloudAdd(Application ap) {
    apl = ap;/*from ww w . java 2s.  com*/

    //
    setIcon(Icons.ADD.resource());
    setCaption(ViewProperties.getCaption("window.myCloudAdd"));
    setModal(true);
    setWidth("550px");

    VerticalLayout layout = (VerticalLayout) getContent();
    layout.setMargin(false, true, false, true);
    layout.setSpacing(true);

    // 
    layout.addComponent(new BasicTab());

    // ??
    HorizontalLayout okbar = new HorizontalLayout();
    okbar.setSpacing(true);
    okbar.setMargin(false, false, true, false);
    //okbar.setWidth("100%");
    layout.addComponent(okbar);
    layout.setComponentAlignment(okbar, Alignment.BOTTOM_RIGHT);

    // Add
    Button addButton = new Button(ViewProperties.getCaption("button.add"));
    addButton.setDescription(ViewProperties.getCaption("description.mycloud.add"));
    addButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            MyCloudAdd.this.addButtonClick(event);
        }
    });
    okbar.addComponent(addButton);

    // Cancel
    Button cancelButton = new Button(ViewProperties.getCaption("button.cancel"));
    cancelButton.setDescription(ViewProperties.getCaption("description.cansel"));
    cancelButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            MyCloudAdd.this.close();
        }
    });
    okbar.addComponent(cancelButton);

    // ??
    initValidation();

    // ???
    initData();

    // 
    showTemplates();
}

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

License:Open Source License

MyCloudEdit(Application apl, Long farmNo) {
    this.apl = apl;
    this.farmNo = farmNo;

    ///*  ww w .ja  va 2 s. c o m*/
    setIcon(Icons.ADD.resource());
    setCaption(ViewProperties.getCaption("window.myCloudEdit"));
    setModal(true);
    setWidth("450px");

    VerticalLayout layout = (VerticalLayout) getContent();
    layout.setMargin(false, true, false, true);
    layout.setSpacing(true);

    // 
    layout.addComponent(new BasicTab());

    // ??
    HorizontalLayout okbar = new HorizontalLayout();
    okbar.setSpacing(true);
    okbar.setMargin(false, false, true, false);
    //okbar.setWidth("100%");
    layout.addComponent(okbar);
    layout.setComponentAlignment(okbar, Alignment.BOTTOM_RIGHT);

    // OK
    Button okButton = new Button(ViewProperties.getCaption("button.ok"));
    okButton.setDescription(ViewProperties.getCaption("description.editCloud.ok"));
    okButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            MyCloudEdit.this.editButtonClick(event);
        }
    });
    okbar.addComponent(okButton);

    // Cancel
    Button cancelButton = new Button(ViewProperties.getCaption("button.cancel"));
    cancelButton.setDescription(ViewProperties.getCaption("description.cancel"));
    cancelButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            MyCloudEdit.this.close();
        }
    });
    okbar.addComponent(cancelButton);

    //???
    initData();

    // ??
    initValidation();

}