Example usage for com.vaadin.server FontAwesome CHECK

List of usage examples for com.vaadin.server FontAwesome CHECK

Introduction

In this page you can find the example usage for com.vaadin.server FontAwesome CHECK.

Prototype

FontAwesome CHECK

To view the source code for com.vaadin.server FontAwesome CHECK.

Click Source Link

Usage

From source file:com.mycollab.module.user.ui.components.ImagePreviewCropWindow.java

License:Open Source License

public ImagePreviewCropWindow(final ImageSelectionCommand imageSelectionCommand, final byte[] imageData) {
    super(UserUIContext.getMessage(ShellI18nEnum.OPT_PREVIEW_EDIT_IMAGE));
    MVerticalLayout content = new MVerticalLayout();
    withModal(true).withResizable(false).withWidth("700px").withCenter().withContent(content);

    try {/*from w  w w.j  av a  2  s .  c om*/
        originalImage = ImageIO.read(new ByteArrayInputStream(imageData));
    } catch (IOException e) {
        throw new UserInvalidInputException("Invalid image type");
    }
    originalImage = ImageUtil.scaleImage(originalImage, 650, 650);

    MHorizontalLayout previewBox = new MHorizontalLayout().withMargin(new MarginInfo(false, true, true, false))
            .withFullWidth();

    previewPhoto = new VerticalLayout();
    previewPhoto.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    previewPhoto.setWidth("100px");

    previewBox.with(previewPhoto).withAlign(previewPhoto, Alignment.TOP_LEFT);

    VerticalLayout previewBoxTitle = new VerticalLayout();
    previewBoxTitle.setMargin(new MarginInfo(false, true, false, true));
    previewBoxTitle
            .addComponent(ELabel.html(UserUIContext.getMessage(ShellI18nEnum.OPT_IMAGE_EDIT_INSTRUCTION)));

    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            clickEvent -> close()).withStyleName(WebThemes.BUTTON_OPTION);

    MButton acceptBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_ACCEPT), clickEvent -> {
        if (scaleImageData != null && scaleImageData.length > 0) {
            try {
                BufferedImage image = ImageIO.read(new ByteArrayInputStream(scaleImageData));
                imageSelectionCommand.process(image);
                close();
            } catch (IOException e) {
                throw new MyCollabException("Error when saving user avatar", e);
            }
        }
    }).withIcon(FontAwesome.CHECK).withStyleName(WebThemes.BUTTON_ACTION);

    MHorizontalLayout controlBtns = new MHorizontalLayout(acceptBtn, cancelBtn);

    previewBoxTitle.addComponent(controlBtns);
    previewBoxTitle.setComponentAlignment(controlBtns, Alignment.TOP_LEFT);
    previewBox.with(previewBoxTitle).expand(previewBoxTitle);

    CssLayout cropBox = new CssLayout();
    cropBox.setWidth("100%");
    VerticalLayout currentPhotoBox = new VerticalLayout();
    Resource resource = new ByteArrayImageResource(ImageUtil.convertImageToByteArray(originalImage),
            "image/png");
    CropField cropField = new CropField(resource);
    cropField.setImmediate(true);
    cropField.setSelectionAspectRatio(1.0f);
    cropField.addValueChangeListener(valueChangeEvent -> {
        VCropSelection newSelection = (VCropSelection) valueChangeEvent.getProperty().getValue();
        int x1 = newSelection.getXTopLeft();
        int y1 = newSelection.getYTopLeft();
        int x2 = newSelection.getXBottomRight();
        int y2 = newSelection.getYBottomRight();
        if (x2 > x1 && y2 > y1) {
            BufferedImage subImage = originalImage.getSubimage(x1, y1, (x2 - x1), (y2 - y1));
            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
            try {
                ImageIO.write(subImage, "png", outStream);
                scaleImageData = outStream.toByteArray();
                displayPreviewImage();
            } catch (IOException e) {
                LOG.error("Error while scale image: ", e);
            }
        }
    });
    currentPhotoBox.setWidth("520px");
    currentPhotoBox.setHeight("470px");
    currentPhotoBox.addComponent(cropField);
    cropBox.addComponent(currentPhotoBox);

    content.with(previewBox, ELabel.hr(), cropBox);
    displayPreviewImage();
}

From source file:de.metas.procurement.webui.ui.view.DailyReportingView.java

License:Open Source License

public DailyReportingView() {
    super();//from   w ww . j ava 2s .co m

    addStyleName(STYLE);

    //
    // Top
    {
        final NavigationBar navigationBar = getNavigationBar();
        navigationBar.setCaption(i18n.get("DailyReportingView.caption"));

        final NavigationButton logoutButton = new NavigationButton(i18n.get("Logout.caption"));
        logoutButton.setTargetView(this);
        logoutButton.addClickListener(new NavigationButtonClickListener() {
            @Override
            public void buttonClick(final NavigationButtonClickEvent event) {
                onLogout();
            }
        });
        navigationBar.setRightComponent(logoutButton);
    }

    //
    // Content
    {
        final VerticalLayout content = new VerticalLayout();

        // Date
        {
            datePanel = new DateNavigation();
            datePanel.addDateChangedListener(new PropertyChangeListener() {

                @Override
                public void propertyChange(final PropertyChangeEvent evt) {
                    onDayChanged(datePanel.getDate());
                }
            });

            final VerticalComponentGroup datePanelGroup = new VerticalComponentGroup();
            datePanelGroup.addComponent(datePanel);
            content.addComponent(datePanelGroup);
        }

        // Product buttons
        productButtons = new BeansVerticalComponentGroup<ProductQtyReport>() {
            @Override
            protected Component createItemComponent(final BeanItem<ProductQtyReport> item) {
                final ProductItemButton itemComp = new ProductItemButton();
                itemComp.setItem(item);
                return itemComp;
            };
        };
        content.addComponent(productButtons);

        setContent(content);
    }

    //
    // Toolbar (bottom)
    {
        final Button weekViewButton = new Button(i18n.get("DailyReportingView.weekViewButton"));
        weekViewButton.setStyleName("no-decoration");
        weekViewButton.setIcon(FontAwesome.CALENDAR);
        weekViewButton.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                onWeekView();
            }
        });

        final Button addProductButton = new Button(i18n.get("DailyReportingView.addProductButton"));
        addProductButton.setStyleName("no-decoration");
        addProductButton.setIcon(FontAwesome.PLUS);
        addProductButton.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                onProductAdd();
            }
        });

        final Button rfqButton = new Button(i18n.get("DailyReportingView.rfqButton"));
        rfqButton.setStyleName("no-decoration");
        rfqButton.setIcon(FontAwesome.MONEY);
        rfqButton.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                onRfQ();
            }
        });

        final ISendService sendService = MFProcurementUI.getCurrentMFSession().getSendService();
        final Button sendButton = new Button(i18n.get("DailyReportingView.sendButton"));
        sendButton.setStyleName("no-decoration");
        sendButton.setIcon(FontAwesome.CHECK);
        final TextOverlay sendButtonOverlay = TextOverlay.extend(sendButton);
        sendButtonOverlay.setPropertyDataSource(sendService.getNotSentCounterProperty());
        sendButtonOverlay.setConverter(TextOverlay.CONVERTER_PositiveCounterOrNull);
        sendButton.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                onSend();
            }
        });

        final Button infoButton = new Button(i18n.getWithDefault("InfoMessageView.caption.short", "Info"));
        infoButton.setStyleName("no-decoration");
        infoButton.setIcon(FontAwesome.INFO);
        infoButton.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                onInfo();
            }
        });

        final Toolbar toolbar = new Toolbar();
        toolbar.addComponents(weekViewButton, addProductButton, sendButton, infoButton, rfqButton);
        setToolbar(toolbar);
    }

    //
    // Initialize
    final Date today = DateUtils.getToday();
    final Date date = DateUtils.addDays(today, +1); // tomorrow (FRESH-196)
    datePanel.setDate(date);
}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.DataHandler.java

License:Open Source License

/**
 * //w ww  .  j  a  v  a 2 s. c o m
 * @param statusValues
 * @return
 * @deprecated
 */
public VerticalLayout createProjectStatusComponent(Map<String, Integer> statusValues) {
    VerticalLayout projectStatusContent = new VerticalLayout();

    Iterator<Entry<String, Integer>> it = statusValues.entrySet().iterator();
    int finishedExperiments = 0;

    while (it.hasNext()) {
        Map.Entry<String, Integer> pairs = (Map.Entry<String, Integer>) it.next();

        if ((Integer) pairs.getValue() == 0) {
            Label statusLabel = new Label(pairs.getKey() + ": " + FontAwesome.TIMES.getHtml(),
                    ContentMode.HTML);
            statusLabel.addStyleName("redicon");
            projectStatusContent.addComponent(statusLabel);
        }

        else {
            Label statusLabel = new Label(pairs.getKey() + ": " + FontAwesome.CHECK.getHtml(),
                    ContentMode.HTML);
            statusLabel.addStyleName("greenicon");

            if (pairs.getKey().equals("Project Planned")) {
                projectStatusContent.addComponentAsFirst(statusLabel);
            } else {
                projectStatusContent.addComponent(statusLabel);

            }
            finishedExperiments += (Integer) pairs.getValue();
        }
    }
    // ProgressBar progressBar = new ProgressBar();
    // progressBar.setValue((float) finishedExperiments / statusValues.keySet().size());
    // projectStatusContent.addComponent(progressBar);

    return projectStatusContent;
}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.PatientStatusComponent.java

License:Open Source License

public void updateUI(final ProjectBean currentBean) {
    BeanItemContainer<ExperimentStatusBean> experimentstatusBeans = datahandler
            .computeIvacPatientStatus(currentBean);

    int finishedExperiments = 0;
    status.removeAllComponents();/*  w  ww.ja  va2  s. c o m*/
    status.setWidth(100.0f, Unit.PERCENTAGE);

    // Generate button caption column
    final GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(experimentstatusBeans);
    gpc.addGeneratedProperty("started", new PropertyValueGenerator<String>() {

        @Override
        public Class<String> getType() {
            return String.class;
        }

        @Override
        public String getValue(Item item, Object itemId, Object propertyId) {
            String status = null;

            if ((double) item.getItemProperty("status").getValue() > 0.0) {
                status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.CHECK.getFontFamily()
                        + ";color:" + "#2dd085" + "\">&#x"
                        + Integer.toHexString(FontAwesome.CHECK.getCodepoint()) + ";</span>";
            } else {
                status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.TIMES.getFontFamily()
                        + ";color:" + "#f54993" + "\">&#x"
                        + Integer.toHexString(FontAwesome.TIMES.getCodepoint()) + ";</span>";
            }

            return status.toString();
        }
    });
    gpc.removeContainerProperty("identifier");

    experiments.setContainerDataSource(gpc);
    // experiments.setHeaderVisible(false);
    // experiments.setHeightMode(HeightMode.ROW);
    experiments.setHeightByRows(gpc.size());
    experiments.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS);

    experiments.getColumn("status").setRenderer(new ProgressBarRenderer());
    // experiments.setColumnOrder("started", "code", "description", "status", "download",
    // "runWorkflow");
    experiments.setColumnOrder("started", "code", "description", "status", "workflow");

    experiments.getColumn("workflow").setRenderer(new ButtonRenderer(new RendererClickListener() {
        @Override
        public void click(RendererClickEvent event) {
            ExperimentStatusBean esb = (ExperimentStatusBean) event.getItemId();
            TabSheet parent = (TabSheet) getParent();
            PatientView pv = (PatientView) parent.getParent().getParent();
            WorkflowComponent wp = pv.getWorkflowComponent();

            // TODO WATCH OUT NUMBER OF WORKFLOW TAB IS HARDCODED AT THE MOMENT, NO BETTER SOLUTION
            // FOUND SO FAR, e.g. get Tab by Name ?

            // TODO idea get description of item to navigate to the correct workflow ?!
            if (esb.getDescription().equals("Barcode Generation")) {
                ArrayList<String> message = new ArrayList<String>();
                message.add("clicked");
                message.add(currentBean.getId());
                //TODO navigate to barcode dragon rawwwr
                //          message.add(BarcodeView.navigateToLabel);
                //          state.notifyObservers(message);
            } else if (esb.getDescription().equals("Variant Annotation")) {
                /*
                 * ArrayList<String> message = new ArrayList<String>(); message.add("clicked");
                 * StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType");
                 * sb.append("&"); sb.append("id="); sb.append(currentBean.getId()); sb.append("&");
                 * sb.append("experiment="); sb.append("Q_WF_NGS_VARIANT_ANNOTATION");
                 * message.add(sb.toString()); message.add(WorkflowView.navigateToLabel);
                 * state.notifyObservers(message);
                 */

                Map<String, String> args = new HashMap<String, String>();
                args.put("id", currentBean.getId());
                args.put("type", "workflowExperimentType");
                args.put("experiment", "Q_WF_NGS_VARIANT_ANNOTATION");
                parent.setSelectedTab(9);
                wp.update(args);

            } else if (esb.getDescription().equals("Epitope Prediction")) {
                /*
                 * ArrayList<String> message = new ArrayList<String>(); message.add("clicked");
                 * StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType");
                 * sb.append("&"); sb.append("id="); sb.append(currentBean.getId()); sb.append("&");
                 * sb.append("experiment="); sb.append("Q_WF_NGS_EPITOPE_PREDICTION");
                 * message.add(sb.toString()); message.add(WorkflowView.navigateToLabel);
                 * state.notifyObservers(message);
                 */
                Map<String, String> args = new HashMap<String, String>();
                args.put("id", currentBean.getId());
                args.put("type", "workflowExperimentType");
                args.put("experiment", "Q_WF_NGS_EPITOPE_PREDICTION");
                parent.setSelectedTab(9);
                wp.update(args);
            } else if (esb.getDescription().equals("HLA Typing")) {
                /*
                 * ArrayList<String> message = new ArrayList<String>(); message.add("clicked");
                 * StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType");
                 * sb.append("&"); sb.append("id="); sb.append(currentBean.getId()); sb.append("&");
                 * sb.append("experiment="); sb.append("Q_WF_NGS_HLATYPING"); message.add(sb.toString());
                 * message.add(WorkflowView.navigateToLabel); state.notifyObservers(message);
                 */
                Map<String, String> args = new HashMap<String, String>();
                args.put("id", currentBean.getId());
                args.put("type", "workflowExperimentType");
                args.put("experiment", "Q_WF_NGS_HLATYPING");
                parent.setSelectedTab(9);
                wp.update(args);
            }

            else {
                Notification notif = new Notification("Workflow not (yet) available.", Type.TRAY_NOTIFICATION);
                // Customize it
                notif.setDelayMsec(60000);
                notif.setPosition(Position.MIDDLE_CENTER);
                // Show it in the page
                notif.show(Page.getCurrent());
            }
        }
    }));

    experiments.getColumn("started").setRenderer(new HtmlRenderer());

    ProgressBar progressBar = new ProgressBar();
    progressBar.setCaption("Overall Progress");
    progressBar.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS);
    progressBar.setStyleName("patientprogress");

    status.addComponent(progressBar);
    status.addComponent(experiments);
    status.setComponentAlignment(progressBar, Alignment.MIDDLE_CENTER);
    status.setComponentAlignment(experiments, Alignment.MIDDLE_CENTER);

    /**
     * Defined Experiments for iVac - Barcodes available -> done with project creation (done) -
     * Sequencing done (Status Q_NGS_MEASUREMENT) - Variants annotated (Status
     * Q_NGS_VARIANT_CALLING) - HLA Typing done (STATUS Q_NGS_WF_HLA_TYPING) - Epitope Prediction
     * done (STATUS Q_WF_NGS_EPITOPE_PREDICTION)
     */

    for (Iterator i = experimentstatusBeans.getItemIds().iterator(); i.hasNext();) {
        ExperimentStatusBean statusBean = (ExperimentStatusBean) i.next();

        finishedExperiments += statusBean.getStatus();

        // statusBean.setDownload("Download");
        statusBean.setWorkflow("Run");
    }

    progressBar.setValue((float) finishedExperiments / experimentstatusBeans.size());
}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.PatientView.java

License:Open Source License

void updateProjectStatus() {

    BeanItemContainer<ExperimentStatusBean> experimentstatusBeans = datahandler
            .computeIvacPatientStatus(currentBean);

    int finishedExperiments = 0;
    status.removeAllComponents();/*from www  . ja v  a 2s  .c  o m*/
    status.setWidth(100.0f, Unit.PERCENTAGE);

    // Generate button caption column
    final GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(experimentstatusBeans);
    gpc.addGeneratedProperty("started", new PropertyValueGenerator<String>() {

        @Override
        public Class<String> getType() {
            return String.class;
        }

        @Override
        public String getValue(Item item, Object itemId, Object propertyId) {
            String status = null;

            if ((double) item.getItemProperty("status").getValue() > 0.0) {
                status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.CHECK.getFontFamily()
                        + ";color:" + "#2dd085" + "\">&#x"
                        + Integer.toHexString(FontAwesome.CHECK.getCodepoint()) + ";</span>";
            } else {
                status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.TIMES.getFontFamily()
                        + ";color:" + "#f54993" + "\">&#x"
                        + Integer.toHexString(FontAwesome.TIMES.getCodepoint()) + ";</span>";
            }

            return status.toString();
        }
    });
    gpc.removeContainerProperty("identifier");

    experiments.setContainerDataSource(gpc);
    // experiments.setHeaderVisible(false);
    experiments.setHeightMode(HeightMode.ROW);
    experiments.setHeightByRows(gpc.size());
    experiments.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS);

    experiments.getColumn("status").setRenderer(new ProgressBarRenderer());
    experiments.setColumnOrder("started", "code", "description", "status", "download", "runWorkflow");

    ButtonRenderer downloadRenderer = new ButtonRenderer(new RendererClickListener() {
        @Override
        public void click(RendererClickEvent event) {
            ExperimentStatusBean esb = (ExperimentStatusBean) event.getItemId();

            if (esb.getDescription().equals("Barcode Generation")) {
                new Notification("Download of Barcodes not available.",
                        "<br/>Please create barcodes by clicking 'Run'.", Type.WARNING_MESSAGE, true)
                                .show(Page.getCurrent());
            } else if (esb.getIdentifier() == null || esb.getIdentifier().isEmpty()) {
                new Notification("No data available for download.",
                        "<br/>Please do the analysis by clicking 'Run' first.", Type.WARNING_MESSAGE, true)
                                .show(Page.getCurrent());
            } else {
                ArrayList<String> message = new ArrayList<String>();
                message.add("clicked");
                StringBuilder sb = new StringBuilder("type=");
                sb.append("experiment");
                sb.append("&");
                sb.append("id=");
                // sb.append(currentBean.getId());
                sb.append(esb.getIdentifier());
                message.add(sb.toString());
                message.add(DatasetView.navigateToLabel);
                state.notifyObservers(message);
            }

        }

    });

    experiments.getColumn("download").setRenderer(downloadRenderer);

    experiments.getColumn("runWorkflow").setRenderer(new ButtonRenderer(new RendererClickListener() {
        @Override
        public void click(RendererClickEvent event) {
            ExperimentStatusBean esb = (ExperimentStatusBean) event.getItemId();

            // TODO idea get description of item to navigate to the correct workflow ?!
            if (esb.getDescription().equals("Barcode Generation")) {
                ArrayList<String> message = new ArrayList<String>();
                message.add("clicked");
                message.add(currentBean.getId());
                // TODO link to barcode dragon
                // message.add(BarcodeView.navigateToLabel);
                // state.notifyObservers(message);
            } else {
                ArrayList<String> message = new ArrayList<String>();
                message.add("clicked");
                StringBuilder sb = new StringBuilder("type=");
                sb.append("workflowExperimentType");
                sb.append("&");
                sb.append("id=");
                sb.append("Q_WF_MS_PEPTIDEID");
                sb.append("&");
                sb.append("project=");
                sb.append(currentBean.getId());
                message.add(sb.toString());
                message.add(WorkflowView.navigateToLabel);
                state.notifyObservers(message);
            }
        }
    }));

    experiments.getColumn("started").setRenderer(new HtmlRenderer());

    ProgressBar progressBar = new ProgressBar();
    progressBar.setCaption("Overall Progress");
    progressBar.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS);
    progressBar.setStyleName("patientprogress");

    status.addComponent(progressBar);
    status.addComponent(experiments);
    status.setComponentAlignment(progressBar, Alignment.MIDDLE_CENTER);
    status.setComponentAlignment(experiments, Alignment.MIDDLE_CENTER);

    /**
     * Defined Experiments for iVac - Barcodes available -> done with project creation (done) -
     * Sequencing done (Status Q_NGS_MEASUREMENT) - Variants annotated (Status
     * Q_NGS_VARIANT_CALLING) - HLA Typing done (STATUS Q_NGS_WF_HLA_TYPING) - Epitope Prediction
     * done (STATUS Q_WF_NGS_EPITOPE_PREDICTION)
     */

    for (Iterator i = experimentstatusBeans.getItemIds().iterator(); i.hasNext();) {
        ExperimentStatusBean statusBean = (ExperimentStatusBean) i.next();

        // HorizontalLayout experimentStatusRow = new HorizontalLayout();
        // experimentStatusRow.setSpacing(true);

        finishedExperiments += statusBean.getStatus();

        // statusBean.setDownload("Download");
        statusBean.setWorkflow("Run");

        /*
         * if ((Integer) pairs.getValue() == 0) { Label statusLabel = new Label(pairs.getKey() + ": "
         * + FontAwesome.TIMES.getHtml(), ContentMode.HTML); statusLabel.addStyleName("redicon");
         * experimentStatusRow.addComponent(statusLabel);
         * statusContent.addComponent(experimentStatusRow); }
         * 
         * else {
         * 
         * Label statusLabel = new Label(pairs.getKey() + ": " + FontAwesome.CHECK.getHtml(),
         * ContentMode.HTML); statusLabel.addStyleName("greenicon");
         * experimentStatusRow.addComponent(statusLabel);
         * statusContent.addComponent(experimentStatusRow);
         * 
         * finishedExperiments += (Integer) pairs.getValue(); }
         * experimentStatusRow.addComponent(runWorkflow);
         * 
         * }
         */
    }

    progressBar.setValue((float) finishedExperiments / experimentstatusBeans.size());
}

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

License:Apache License

private void renseignerPanelContact() {

    VerticalLayout contactLayout = new VerticalLayout();

    /* Layout pour afficher les erreurs */
    VerticalLayout erreursLayout = new VerticalLayout();
    contactLayout.addComponent(erreursLayout);
    erreursLayout.setVisible(false);/*from   w ww. j  a v  a  2 s  . co m*/

    /* Layout avec les champ 'Portable' et 'Email personnel' */
    FormLayout formContactLayout = new FormLayout();
    formContactLayout.setSpacing(true);
    formContactLayout.setMargin(true);

    String captionTelPortable = applicationContext.getMessage(NAME + ".portable.title", null, getLocale());
    fieldTelPortable = new TextField(captionTelPortable, MainUI.getCurrent().getEtudiant().getTelPortable());
    formatTextField(fieldTelPortable);
    fieldTelPortable.setMaxLength(15);
    formContactLayout.addComponent(fieldTelPortable);

    if (userController.isEtudiant()) {
        String captionMailPerso = applicationContext.getMessage(NAME + ".mailperso.title", null, getLocale());
        fieldMailPerso = new TextField(captionMailPerso, MainUI.getCurrent().getEtudiant().getEmailPerso());
        formatTextField(fieldMailPerso);
        fieldMailPerso.setMaxLength(200);
        formContactLayout.addComponent(fieldMailPerso);
    }

    contactLayout.addComponent(formContactLayout);

    /* Si user tudiant , modifications autorise des coordonnes de contact
     * et si l'tudiant possde une addresse annuelle, on affiche les boutons de modification */
    if (userController.isEtudiant() && configController.isModificationCoordonneesPersoAutorisee()
            && MainUI.getCurrent().getEtudiant().getAdresseAnnuelle() != null) {
        //Layout pour les boutons de modification
        HorizontalLayout btnLayout = new HorizontalLayout();
        btnLayout.setSizeFull();
        btnLayout.setSpacing(true);
        btnLayout.setMargin(true);

        //Bouton pour valider la modification
        btnValidModifCoordonneesPerso = new Button(
                applicationContext.getMessage(NAME + ".bouton.validercoordonnees", null, getLocale()));
        btnValidModifCoordonneesPerso.setStyleName(ValoTheme.BUTTON_FRIENDLY);
        btnValidModifCoordonneesPerso.setIcon(FontAwesome.CHECK);
        btnValidModifCoordonneesPerso.addClickListener(e -> {
            erreursLayout.removeAllComponents();
            List<String> retour = etudiantController.updateContact(fieldTelPortable.getValue(),
                    fieldMailPerso.getValue(), MainUI.getCurrent().getEtudiant().getCod_etu());
            //si modif ok
            if (retour != null && retour.size() == 1 && retour.get(0).equals("OK")) {
                etudiantController.recupererEtatCivil();
                renseignerPanelContact();
            } else {
                //affichage erreurs
                if (retour != null && retour.size() > 0) {
                    String errorMsg = "";
                    for (String erreur : retour) {
                        if (!errorMsg.equals(""))
                            errorMsg = errorMsg + "<br />";
                        errorMsg = errorMsg + erreur;
                    }
                    Label labelErreur = new Label(errorMsg);
                    labelErreur.setContentMode(ContentMode.HTML);
                    labelErreur.setStyleName(ValoTheme.LABEL_FAILURE);
                    erreursLayout.addComponent(labelErreur);
                }
                erreursLayout.setVisible(true);
            }
        });
        btnValidModifCoordonneesPerso.setVisible(false);
        btnLayout.addComponent(btnValidModifCoordonneesPerso);
        btnLayout.setComponentAlignment(btnValidModifCoordonneesPerso, Alignment.MIDDLE_CENTER);

        //Bouton pour annuler la modification
        btnAnnulerModifCoordonneesPerso = new Button(
                applicationContext.getMessage(NAME + ".bouton.annulercoordonnees", null, getLocale()));
        btnAnnulerModifCoordonneesPerso.setStyleName(ValoTheme.BUTTON_DANGER);
        btnAnnulerModifCoordonneesPerso.setIcon(FontAwesome.TIMES);
        btnAnnulerModifCoordonneesPerso.addClickListener(e -> {
            erreursLayout.removeAllComponents();
            fieldMailPerso.setValue(MainUI.getCurrent().getEtudiant().getEmailPerso());
            fieldMailPerso.setEnabled(false);
            fieldMailPerso.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
            fieldTelPortable.setValue(MainUI.getCurrent().getEtudiant().getTelPortable());
            fieldTelPortable.setEnabled(false);
            fieldTelPortable.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
            btnValidModifCoordonneesPerso.setVisible(false);
            btnAnnulerModifCoordonneesPerso.setVisible(false);
            btnModifCoordonneesPerso.setVisible(true);

        });
        btnAnnulerModifCoordonneesPerso.setVisible(false);
        btnLayout.addComponent(btnAnnulerModifCoordonneesPerso);
        btnLayout.setComponentAlignment(btnAnnulerModifCoordonneesPerso, Alignment.MIDDLE_CENTER);

        //Bouton pour activer la modification des donnes
        btnModifCoordonneesPerso = new Button(
                applicationContext.getMessage(NAME + ".bouton.modifiercoordonnees", null, getLocale()));
        btnModifCoordonneesPerso.setStyleName(ValoTheme.BUTTON_PRIMARY);
        btnModifCoordonneesPerso.setIcon(FontAwesome.EDIT);
        btnModifCoordonneesPerso.addClickListener(e -> {
            fieldMailPerso.setEnabled(true);
            fieldMailPerso.removeStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
            fieldTelPortable.setEnabled(true);
            fieldTelPortable.removeStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
            btnValidModifCoordonneesPerso.setVisible(true);
            btnAnnulerModifCoordonneesPerso.setVisible(true);
            btnModifCoordonneesPerso.setVisible(false);
        });
        btnLayout.addComponent(btnModifCoordonneesPerso);
        btnLayout.setComponentAlignment(btnModifCoordonneesPerso, Alignment.MIDDLE_CENTER);
        contactLayout.addComponent(btnLayout);
    }

    panelContact.setContent(contactLayout);

}

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

License:Apache License

/**
 * Cre une fentre de confirmation//from w w w  .  j  av  a  2 s  .com
 * @param message
 * @param titre
 */
public ConfirmWindow(String message, String titre) {
    /* Style */
    setWidth(400, Unit.PIXELS);
    setModal(true);
    setResizable(false);
    setClosable(false);

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

    /* Titre */
    if (titre == null) {
        titre = applicationContext.getMessage("confirmWindow.defaultTitle", null, getLocale());
    }
    setCaption(titre);

    /* Texte */
    if (message == null) {
        message = applicationContext.getMessage("confirmWindow.defaultQuestion", null, getLocale());
    }
    Label textLabel = new Label(message);
    layout.addComponent(textLabel);

    /* Boutons */
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setSpacing(true);
    layout.addComponent(buttonsLayout);

    btnNon.setCaption(applicationContext.getMessage("confirmWindow.btnNon", null, getLocale()));
    btnNon.setIcon(FontAwesome.TIMES);
    btnNon.addClickListener(e -> close());
    buttonsLayout.addComponent(btnNon);
    buttonsLayout.setComponentAlignment(btnNon, Alignment.MIDDLE_LEFT);

    btnOui.setCaption(applicationContext.getMessage("confirmWindow.btnOui", null, getLocale()));
    btnOui.setIcon(FontAwesome.CHECK);
    btnOui.addStyleName(ValoTheme.BUTTON_PRIMARY);
    btnOui.addClickListener(e -> close());
    buttonsLayout.addComponent(btnOui);
    buttonsLayout.setComponentAlignment(btnOui, Alignment.MIDDLE_RIGHT);

    /* Centre la fentre */
    center();
}

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

License:Apache License

/**
 * Cre une fentre de confirmation//from w  w  w.  j  a v  a 2  s.co  m
 * @param message
 * @param titre
 */
public HelpMobileWindow(String message, String titre, boolean displayCheckBox) {
    // Style 
    setWidth("90%");
    setModal(true);
    setResizable(false);
    setClosable(false);

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

    // Titre 
    if (titre == null) {
        titre = applicationContext.getMessage("helpWindow.defaultTitle", null, getLocale());
    }
    setCaption(titre);

    // Texte 
    Label textLabel = new Label(message, ContentMode.HTML);
    layout.addComponent(textLabel);

    // Boutons
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setSpacing(true);
    layout.addComponent(buttonsLayout);

    if (displayCheckBox) {
        // Checkbox "ne plus afficher ce message"
        checkBox.setCaption(
                applicationContext.getMessage("helpWindow.checkBox.mobile.message", null, getLocale()));
        buttonsLayout.addComponent(checkBox);
        buttonsLayout.setComponentAlignment(checkBox, Alignment.MIDDLE_RIGHT);
    }
    // Bouton "Fermer"
    btnFermer.setIcon(FontAwesome.CHECK);
    btnFermer.setStyleName(ValoTheme.BUTTON_PRIMARY);
    btnFermer.addStyleName("v-popover-button");
    btnFermer.addClickListener(e -> close());
    buttonsLayout.addComponent(btnFermer);
    buttonsLayout.setComponentAlignment(btnFermer, Alignment.MIDDLE_RIGHT);
    if (displayCheckBox) {
        buttonsLayout.setExpandRatio(checkBox, 1);
    }

    // Centre la fentre 
    center();
}

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

License:Apache License

/**
 * Cre une fentre de confirmation//from  w  w  w. ja va2 s .  c om
 * @param message
 * @param titre
 */
public ModificationAdressesWindow(Etudiant etudiant) {
    /* Style */
    //setWidth(900, Unit.PIXELS);
    setModal(true);
    setResizable(false);
    setClosable(false);

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

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

    /* Layout pour afficher les erreurs */
    VerticalLayout erreursLayout = new VerticalLayout();
    layout.addComponent(erreursLayout);
    erreursLayout.setVisible(false);

    HorizontalLayout panelslayout = new HorizontalLayout();
    panelslayout.setMargin(true);
    panelslayout.setSpacing(true);
    layout.addComponent(panelslayout);

    /* Panel adresse annuelle */
    Panel adressesAnnuellePanel = new Panel(
            applicationContext.getMessage(NAME + ".panel.adresseannuelle.title", null, getLocale()) + " "
                    + MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAnnee());

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

    //TypeHebergement
    String captionHebergement = applicationContext.getMessage(NAME + ".typehebergement", null, getLocale());
    TypeHebergementDTO[] hebergements = adresseController.getTypesHebergement();
    lhebergement = new NativeSelect();
    lhebergement.setCaption(captionHebergement);
    lhebergement.setNullSelectionAllowed(false);
    lhebergement.setRequired(true);
    lhebergement.setWidth("326px");
    for (TypeHebergementDTO h : hebergements) {
        lhebergement.addItem(h.getCodTypeHebergement());
        lhebergement.setItemCaption(h.getCodTypeHebergement(), h.getLibWebTypeHebergement());
    }
    lhebergement.setValue(etudiant.getAdresseAnnuelle().getType());
    lhebergement.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            String selectedValue = (String) event.getProperty().getValue();

            //Si un hbergement autre que la Domicile parental a t choisi
            if (!selectedValue.equals(COD_HEBERG_DOMICILE_PARENTAL)) {
                activeFormulaireAdresseAnnuelle();

            } else {
                desactiveFormulaireAdresseAnnuelle();
            }
        }
    });

    formAdresseAnnuelleLayout.addComponent(lhebergement);

    //labelChoixHebergement
    labelChoixHebergement = new Label(
            applicationContext.getMessage(NAME + ".labelhebergement", null, getLocale()));
    formAdresseAnnuelleLayout.addComponent(labelChoixHebergement);

    //AdresseAnnuelle1
    fieldAnnu1 = new TextField(applicationContext.getMessage(NAME + ".annu1", null, getLocale()));
    fieldAnnu1.setValue(etudiant.getAdresseAnnuelle().getAdresse1());
    fieldAnnu1.setNullRepresentation("");
    fieldAnnu1.setWidth("326px");
    fieldAnnu1.setMaxLength(32);
    fieldAnnu1.setRequired(true);
    formAdresseAnnuelleLayout.addComponent(fieldAnnu1);

    //AdresseAnnuelle2
    fieldAnnu2 = new TextField(applicationContext.getMessage(NAME + ".annu2", null, getLocale()));
    fieldAnnu2.setValue(etudiant.getAdresseAnnuelle().getAdresse2());
    fieldAnnu2.setNullRepresentation("");
    fieldAnnu2.setWidth("326px");
    fieldAnnu2.setMaxLength(32);
    formAdresseAnnuelleLayout.addComponent(fieldAnnu2);

    //AdresseAnnuelle3
    fieldAnnu3 = new TextField(applicationContext.getMessage(NAME + ".annu3", null, getLocale()));
    fieldAnnu3.setValue(etudiant.getAdresseAnnuelle().getAdresse3());
    fieldAnnu3.setNullRepresentation("");
    fieldAnnu3.setWidth("326px");
    fieldAnnu3.setMaxLength(32);
    formAdresseAnnuelleLayout.addComponent(fieldAnnu3);

    //Liste des Pays
    String captionPays = applicationContext.getMessage(NAME + ".pays1", null, getLocale());
    PaysDTO[] pays = adresseController.getPays();
    lpays1 = new NativeSelect();
    lpays1.setCaption(captionPays);
    lpays1.setNullSelectionAllowed(false);
    lpays1.setRequired(true);
    lpays1.setWidth("326px");
    for (PaysDTO p : pays) {
        lpays1.addItem(p.getCodePay());
        lpays1.setItemCaption(p.getCodePay(), p.getLibPay());
    }
    lpays1.setValue(etudiant.getAdresseAnnuelle().getCodPays());
    lpays1.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            String selectedValue = (String) event.getProperty().getValue();

            //Si un pays autre que France a t choisi
            if (!selectedValue.equals(COD_PAY_FRANCE)) {
                activerChampPourAdresseAnnuelleEtranger();
            } else {
                activerChampPourAdresseAnnuelleEnFrance();
            }
        }
    });
    formAdresseAnnuelleLayout.addComponent(lpays1);

    //Ville pour adresse  l'tranger
    fieldVilleEtranger1 = new TextField(
            applicationContext.getMessage(NAME + ".villeetranger1", null, getLocale()));
    fieldVilleEtranger1.setValue(etudiant.getAdresseAnnuelle().getAdresseetranger());
    fieldVilleEtranger1.setNullRepresentation("");
    fieldVilleEtranger1.setWidth("326px");
    fieldVilleEtranger1.setMaxLength(5);
    fieldVilleEtranger1.setRequired(true);
    formAdresseAnnuelleLayout.addComponent(fieldVilleEtranger1);

    //codePostal1 pour adresses en france
    fieldCodePostal1 = new TextField(applicationContext.getMessage(NAME + ".codepostal1", null, getLocale()));
    fieldCodePostal1.setValue(etudiant.getAdresseAnnuelle().getCodePostal());
    fieldCodePostal1.setNullRepresentation("");
    fieldCodePostal1.setWidth("326px");
    fieldCodePostal1.setMaxLength(5);
    fieldCodePostal1.setRequired(true);
    //fieldCodePostal1.setTextChangeEventMode(TextChangeEventMode.EAGER);
    fieldCodePostal1.addTextChangeListener(new TextChangeListener() {
        @Override
        public void textChange(TextChangeEvent event) {
            updateListeVillesAnnuelle(event.getText());
        }
    });

    formAdresseAnnuelleLayout.addComponent(fieldCodePostal1);

    //Ville pour adresse en france
    List<CommuneDTO> villes1 = adresseController.getVilles(etudiant.getAdresseAnnuelle().getCodePostal());
    lville1 = new NativeSelect();
    lville1.setCaption(applicationContext.getMessage(NAME + ".ville1", null, getLocale()));
    lville1.setNullSelectionAllowed(false);
    lville1.setRequired(true);
    lville1.setWidth("326px");
    for (CommuneDTO v : villes1) {
        lville1.addItem(v.getLibCommune());
        lville1.setItemCaption(v.getLibCommune(), v.getLibCommune());
    }
    codePostalVillesAnnu = etudiant.getAdresseAnnuelle().getCodePostal();
    lville1.setValue(etudiant.getAdresseAnnuelle().getVille());
    lville1.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            updateCodePostalVilleAnnuelle();
        }
    });
    formAdresseAnnuelleLayout.addComponent(lville1);

    //activation des champs utiles en fonction de l'adresse de l'tudiant avant la modification
    if (etudiant.getAdresseAnnuelle().getCodPays().equals(COD_PAY_FRANCE)) {
        activerChampPourAdresseAnnuelleEnFrance();
    } else {
        activerChampPourAdresseAnnuelleEtranger();
    }

    //Tlphone1
    fieldTelephone1 = new TextField(applicationContext.getMessage(NAME + ".tel1", null, getLocale()));
    fieldTelephone1.setValue(etudiant.getAdresseAnnuelle().getNumerotel());
    fieldTelephone1.setNullRepresentation("");
    fieldTelephone1.setWidth("326px");
    fieldTelephone1.setMaxLength(15);
    fieldTelephone1.setRequired(false);
    formAdresseAnnuelleLayout.addComponent(fieldTelephone1);

    //ajout du panel adresse Annuelle
    adressesAnnuellePanel.setContent(formAdresseAnnuelleLayout);
    panelslayout.addComponent(adressesAnnuellePanel);

    //Si un hbergement autre que la Domicile parental a t choisi
    if (!etudiant.getAdresseAnnuelle().getType().equals(COD_HEBERG_DOMICILE_PARENTAL)) {
        activeFormulaireAdresseAnnuelle();
    } else {
        desactiveFormulaireAdresseAnnuelle();
    }

    /* Panel adresse fixe */
    Panel adressesFixePanel = new Panel(
            applicationContext.getMessage(NAME + ".panel.adressefixe.title", null, getLocale()));

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

    //AdresseFixe1
    fieldFixe1 = new TextField(applicationContext.getMessage(NAME + ".fixe1", null, getLocale()));
    fieldFixe1.setValue(etudiant.getAdresseFixe().getAdresse1());
    fieldFixe1.setNullRepresentation("");
    fieldFixe1.setWidth("326px");
    fieldFixe1.setMaxLength(32);
    fieldFixe1.setRequired(true);
    formAdresseFixeLayout.addComponent(fieldFixe1);

    //AdresseFixe2
    fieldFixe2 = new TextField(applicationContext.getMessage(NAME + ".fixe2", null, getLocale()));
    fieldFixe2.setValue(etudiant.getAdresseFixe().getAdresse2());
    fieldFixe2.setNullRepresentation("");
    fieldFixe2.setWidth("326px");
    fieldFixe2.setMaxLength(32);
    formAdresseFixeLayout.addComponent(fieldFixe2);

    //AdresseFixe3
    fieldFixe3 = new TextField(applicationContext.getMessage(NAME + ".fixe3", null, getLocale()));
    fieldFixe3.setValue(etudiant.getAdresseFixe().getAdresse3());
    fieldFixe3.setNullRepresentation("");
    fieldFixe3.setWidth("326px");
    fieldFixe3.setMaxLength(32);
    formAdresseFixeLayout.addComponent(fieldFixe3);

    //Liste des Pays
    lpays2 = new NativeSelect();
    lpays2.setCaption(captionPays);
    lpays2.setNullSelectionAllowed(false);
    lpays2.setRequired(true);
    lpays2.setWidth("326px");
    for (PaysDTO p : pays) {
        lpays2.addItem(p.getCodePay());
        lpays2.setItemCaption(p.getCodePay(), p.getLibPay());
    }
    lpays2.setValue(etudiant.getAdresseFixe().getCodPays());
    lpays2.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            String selectedValue = (String) event.getProperty().getValue();

            //Si un pays autre que France a t choisi
            if (!selectedValue.equals(COD_PAY_FRANCE)) {
                activerChampPourAdresseFixeEtranger();
            } else {
                activerChampPourAdresseFixeEnFrance();
            }
        }
    });
    formAdresseFixeLayout.addComponent(lpays2);

    //Ville pour adresse  l'tranger
    fieldVilleEtranger2 = new TextField(
            applicationContext.getMessage(NAME + ".villeetranger2", null, getLocale()));
    fieldVilleEtranger2.setValue(etudiant.getAdresseFixe().getAdresseetranger());
    fieldVilleEtranger2.setNullRepresentation("");
    fieldVilleEtranger2.setWidth("326px");
    fieldVilleEtranger2.setMaxLength(5);
    fieldVilleEtranger2.setRequired(true);
    formAdresseFixeLayout.addComponent(fieldVilleEtranger2);

    //codePostal2 pour adresses en france
    fieldCodePostal2 = new TextField(applicationContext.getMessage(NAME + ".codepostal2", null, getLocale()));
    fieldCodePostal2.setValue(etudiant.getAdresseFixe().getCodePostal());
    fieldCodePostal2.setNullRepresentation("");
    fieldCodePostal2.setWidth("326px");
    fieldCodePostal2.setMaxLength(5);
    fieldCodePostal2.setRequired(true);
    //fieldCodePostal1.setTextChangeEventMode(TextChangeEventMode.EAGER);
    fieldCodePostal2.addTextChangeListener(new TextChangeListener() {
        @Override
        public void textChange(TextChangeEvent event) {
            updateListeVillesFixe(event.getText());
        }
    });

    formAdresseFixeLayout.addComponent(fieldCodePostal2);

    //Ville pour adresse en france
    List<CommuneDTO> villes2 = adresseController.getVilles(etudiant.getAdresseFixe().getCodePostal());
    lville2 = new NativeSelect();
    lville2.setCaption(applicationContext.getMessage(NAME + ".ville2", null, getLocale()));
    lville2.setNullSelectionAllowed(false);
    lville2.setRequired(true);
    lville2.setWidth("326px");
    for (CommuneDTO v : villes2) {
        lville2.addItem(v.getLibCommune());
        lville2.setItemCaption(v.getLibCommune(), v.getLibCommune());
    }
    codePostalVillesFixe = etudiant.getAdresseFixe().getCodePostal();
    lville2.setValue(etudiant.getAdresseFixe().getVille());
    lville2.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            updateCodePostalVilleFixe();
        }
    });
    formAdresseFixeLayout.addComponent(lville2);

    //activation des champs utiles en fonction de l'adresse de l'tudiant avant la modification
    if (etudiant.getAdresseFixe().getCodPays().equals(COD_PAY_FRANCE)) {
        activerChampPourAdresseFixeEnFrance();
    } else {
        activerChampPourAdresseFixeEtranger();
    }

    //Tlphone2
    fieldTelephone2 = new TextField(applicationContext.getMessage(NAME + ".tel2", null, getLocale()));
    fieldTelephone2.setValue(etudiant.getAdresseFixe().getNumerotel());
    fieldTelephone2.setNullRepresentation("");
    fieldTelephone2.setWidth("326px");
    fieldTelephone2.setMaxLength(15);
    fieldTelephone2.setRequired(false);
    formAdresseFixeLayout.addComponent(fieldTelephone2);

    //ajout du panel adresse fixe
    adressesFixePanel.setContent(formAdresseFixeLayout);
    panelslayout.addComponent(adressesFixePanel);

    /* Boutons */
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setSpacing(true);

    btnValider.setCaption(applicationContext.getMessage(NAME + ".btnValider", null, getLocale()));
    btnValider.setIcon(FontAwesome.CHECK);
    btnValider.addStyleName(ValoTheme.BUTTON_PRIMARY);
    btnValider.addClickListener(e -> {

        Adresse adresseAnnuelle = new Adresse();
        adresseAnnuelle.setType(lhebergement.getValue().toString());
        adresseAnnuelle.setAdresse1(fieldAnnu1.getValue());
        adresseAnnuelle.setAdresse2(fieldAnnu2.getValue());
        adresseAnnuelle.setAdresse3(fieldAnnu3.getValue());
        adresseAnnuelle.setCodPays(lpays1.getValue().toString());
        adresseAnnuelle.setCodePostal(fieldCodePostal1.getValue());
        adresseAnnuelle.setVille((lville1.getValue() == null) ? null : lville1.getValue().toString());
        adresseAnnuelle.setAdresseetranger(fieldVilleEtranger1.getValue());
        adresseAnnuelle.setNumerotel(fieldTelephone1.getValue());

        Adresse adresseFixe = new Adresse();
        adresseFixe.setAdresse1(fieldFixe1.getValue());
        adresseFixe.setAdresse2(fieldFixe2.getValue());
        adresseFixe.setAdresse3(fieldFixe3.getValue());
        adresseFixe.setCodPays(lpays2.getValue().toString());
        adresseFixe.setCodePostal(fieldCodePostal2.getValue());
        adresseFixe.setVille((lville2.getValue() == null) ? null : lville2.getValue().toString());
        adresseFixe.setAdresseetranger(fieldVilleEtranger2.getValue());
        adresseFixe.setNumerotel(fieldTelephone2.getValue());

        erreursLayout.removeAllComponents();
        List<String> retour = adresseController.majAdresses(adresseAnnuelle, adresseFixe);
        if (retour != null && retour.size() == 1 && retour.get(0).equals("OK")) {
            //ajout maj vue adresse
            etudiantController.recupererAdresses();
            close();
        } else {
            //affichage erreurs
            if (retour != null && retour.size() > 0) {
                String errorMsg = "";
                for (String erreur : retour) {
                    if (!errorMsg.equals(""))
                        errorMsg = errorMsg + "<br />";
                    errorMsg = errorMsg + erreur;
                }
                Label labelErreur = new Label(errorMsg);
                labelErreur.setContentMode(ContentMode.HTML);
                labelErreur.setStyleName(ValoTheme.LABEL_FAILURE);
                erreursLayout.addComponent(labelErreur);
            }
            erreursLayout.setVisible(true);
        }

    });
    buttonsLayout.addComponent(btnValider);
    buttonsLayout.setComponentAlignment(btnValider, Alignment.MIDDLE_CENTER);

    btnAnnuler.setCaption(
            applicationContext.getMessage("modificationAdressesWindow.btnAnnuler", null, getLocale()));
    btnAnnuler.setIcon(FontAwesome.TIMES);
    btnAnnuler.addStyleName(ValoTheme.BUTTON_DANGER);
    btnAnnuler.addClickListener(e -> close());
    buttonsLayout.addComponent(btnAnnuler);
    buttonsLayout.setComponentAlignment(btnAnnuler, Alignment.MIDDLE_CENTER);

    layout.addComponent(buttonsLayout);

    /* Centre la fentre */
    center();
}

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

License:Apache License

/**
 * Cre une fentre/*  w ww  .  j a  va  2s  .  c  o  m*/
 */
public SignificationsMobileWindow(boolean afficherSignificationIndicateurProfondeur) {

    setWidth("95%");
    setHeight("95%");

    setCaption(applicationContext.getMessage("significationsWindow.title", null, getLocale()));
    setModal(true);
    setResizable(false);
    setClosable(false);
    setStyleName("v-popover-blank");

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    setContent(layout);

    VerticalLayout panelLayout = new VerticalLayout();
    panelLayout.setWidth("100%");
    panelLayout.setStyleName("v-scrollableelement");
    panelLayout.setSpacing(true);
    panelLayout.setMargin(true);

    if (MdwTouchkitUI.getCurrent().getEtudiant().isSignificationResultatsUtilisee()) {

        Panel panelSignificationResultats = new Panel();
        panelSignificationResultats.setCaption(
                applicationContext.getMessage(NAME + ".info.significations.resultats", null, getLocale()));
        panelSignificationResultats.addStyleName("significationpanel");
        panelSignificationResultats.setWidth("100%");

        VerticalLayout significationLayout = new VerticalLayout();
        significationLayout.setWidth("100%");
        significationLayout.setMargin(true);
        significationLayout.setSpacing(true);

        Set<String> ss = MdwTouchkitUI.getCurrent().getEtudiant().getSignificationResultats().keySet();
        for (String k : ss) {
            if (k != null && !k.equals("") && !k.equals(" ")) {
                HorizontalLayout signLayout = new HorizontalLayout();
                signLayout.setSizeFull();
                signLayout.setMargin(true);
                signLayout.setSpacing(true);
                Label codeLabel = new Label(k);
                codeLabel.setStyleName(ValoTheme.LABEL_BOLD);
                codeLabel.addStyleName("v-label-align-right");
                signLayout.addComponent(codeLabel);
                Label valueLabel = new Label(
                        "" + MdwTouchkitUI.getCurrent().getEtudiant().getSignificationResultats().get(k));
                signLayout.addComponent(valueLabel);
                significationLayout.addComponent(signLayout);
            }
        }

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

    }

    if (afficherSignificationIndicateurProfondeur) {

        Panel panelSignificationIndicateurs = new Panel();
        panelSignificationIndicateurs.setCaption(
                applicationContext.getMessage(NAME + ".info.significations.indicateurs", null, getLocale()));
        panelSignificationIndicateurs.addStyleName("significationpanel");
        panelSignificationIndicateurs.setWidth("100%");

        VerticalLayout significationLayout = new VerticalLayout();
        significationLayout.setMargin(true);
        significationLayout.setSpacing(true);
        significationLayout.setWidth("100%");

        //1er NIVEAU
        HorizontalLayout levelLayout1 = new HorizontalLayout();
        levelLayout1.setWidth("100%");
        HorizontalLayout levelMainLayout1 = new HorizontalLayout();
        levelMainLayout1.setWidth("100%");
        levelMainLayout1.setSpacing(true);
        levelMainLayout1.setStyleName("level-indicator-layout");
        int k = 0;
        for (int i = 0; i < 1; i++) {
            //Ajout d'un level
            k++;
            Label libLevelLayout = new Label();
            libLevelLayout.setSizeFull();
            libLevelLayout.setHeight("8px");
            libLevelLayout.setStyleName("layout-level-green-indicator");
            levelMainLayout1.addComponent(libLevelLayout);
        }
        //On pense avoir 7 level maxi 
        for (int j = k; j < 8; j++) {
            Label libLevelSpaceLayout = new Label();
            libLevelSpaceLayout.setSizeFull();
            libLevelSpaceLayout.setHeight("8px");
            levelMainLayout1.addComponent(libLevelSpaceLayout);
        }

        levelLayout1.addComponent(levelMainLayout1);
        levelLayout1.addComponent(new Label("1er niveau"));
        significationLayout.addComponent(levelLayout1);

        //2em NIVEAU
        HorizontalLayout levelLayout2 = new HorizontalLayout();
        levelLayout2.setSizeFull();
        HorizontalLayout levelMainLayout2 = new HorizontalLayout();
        levelMainLayout2.setSizeFull();
        levelMainLayout2.setSpacing(true);
        levelMainLayout2.setStyleName("level-indicator-layout");
        k = 0;
        for (int i = 0; i < 2; i++) {
            //Ajout d'un level
            k++;
            Label libLevelLayout = new Label();
            libLevelLayout.setSizeFull();
            libLevelLayout.setHeight("8px");
            libLevelLayout.setStyleName("layout-level-green-indicator");
            levelMainLayout2.addComponent(libLevelLayout);
        }
        //On pense avoir 7 level maxi 
        for (int j = k; j < 8; j++) {
            Label libLevelSpaceLayout = new Label();
            libLevelSpaceLayout.setSizeFull();
            libLevelSpaceLayout.setHeight("8px");
            levelMainLayout2.addComponent(libLevelSpaceLayout);
        }

        levelLayout2.addComponent(levelMainLayout2);
        levelLayout2.addComponent(new Label("2em niveau"));
        significationLayout.addComponent(levelLayout2);

        //3em NIVEAU
        HorizontalLayout levelLayout3 = new HorizontalLayout();
        levelLayout3.setSizeFull();
        HorizontalLayout levelMainLayout3 = new HorizontalLayout();
        levelMainLayout3.setSizeFull();
        levelMainLayout3.setSpacing(true);
        levelMainLayout3.setStyleName("level-indicator-layout");
        k = 0;
        for (int i = 0; i < 3; i++) {
            //Ajout d'un level
            k++;
            Label libLevelLayout = new Label();
            libLevelLayout.setSizeFull();
            libLevelLayout.setHeight("8px");
            libLevelLayout.setStyleName("layout-level-green-indicator");
            levelMainLayout3.addComponent(libLevelLayout);
        }
        //On pense avoir 7 level maxi 
        for (int j = k; j < 8; j++) {
            Label libLevelSpaceLayout = new Label();
            libLevelSpaceLayout.setSizeFull();
            libLevelSpaceLayout.setHeight("8px");
            levelMainLayout3.addComponent(libLevelSpaceLayout);
        }

        levelLayout3.addComponent(levelMainLayout3);
        levelLayout3.addComponent(new Label("3em niveau"));
        significationLayout.addComponent(levelLayout3);

        //4em NIVEAU
        HorizontalLayout levelLayout4 = new HorizontalLayout();
        levelLayout4.setSizeFull();
        HorizontalLayout levelMainLayout4 = new HorizontalLayout();
        levelMainLayout4.setSizeFull();
        levelMainLayout4.setSpacing(true);
        levelMainLayout4.setStyleName("level-indicator-layout");
        k = 0;
        for (int i = 0; i < 4; i++) {
            //Ajout d'un level
            k++;
            Label libLevelLayout = new Label();
            libLevelLayout.setSizeFull();
            libLevelLayout.setHeight("8px");
            libLevelLayout.setStyleName("layout-level-green-indicator");
            levelMainLayout4.addComponent(libLevelLayout);
        }
        //On pense avoir 7 level maxi 
        for (int j = k; j < 8; j++) {
            Label libLevelSpaceLayout = new Label();
            libLevelSpaceLayout.setSizeFull();
            libLevelSpaceLayout.setHeight("8px");
            levelMainLayout4.addComponent(libLevelSpaceLayout);
        }

        levelLayout4.addComponent(levelMainLayout4);
        levelLayout4.addComponent(new Label("4em niveau"));
        significationLayout.addComponent(levelLayout4);

        //ETC
        HorizontalLayout levelLayoutEtc = new HorizontalLayout();
        levelLayoutEtc.setSizeFull();

        levelLayoutEtc.addComponent(new Label("..."));
        levelLayoutEtc.addComponent(new Label(""));
        significationLayout.addComponent(levelLayoutEtc);

        panelSignificationIndicateurs.setContent(significationLayout);
        panelLayout.addComponent(panelSignificationIndicateurs);

    }

    layout.addComponent(panelLayout);

    // close button
    HorizontalLayout bLayout = new HorizontalLayout();
    bLayout.setSizeFull();
    bLayout.setHeight("50px");

    Button closeButton = new Button();
    //closeButton.setCaption(applicationContext.getMessage("significationsWindow.btnFermer", null, getLocale()));
    closeButton.setStyleName(ValoTheme.BUTTON_PRIMARY);
    closeButton.addStyleName("v-popover-button");
    closeButton.setIcon(FontAwesome.CHECK);
    closeButton.addClickListener(e -> {
        close();

    });

    bLayout.addComponent(closeButton);
    bLayout.setComponentAlignment(closeButton, Alignment.MIDDLE_CENTER);
    layout.addComponent(bLayout);

    layout.setExpandRatio(panelLayout, 1);

}