Example usage for com.vaadin.ui FormLayout setSizeFull

List of usage examples for com.vaadin.ui FormLayout setSizeFull

Introduction

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

Prototype

@Override
    public void setSizeFull() 

Source Link

Usage

From source file:fi.semantum.strategia.Utils.java

License:Open Source License

public static void addView(final Main main, final Strategiakartta map) {

    final Database database = main.getDatabase();

    FormLayout content = new FormLayout();
    content.setSizeFull();

    final TextField tf = new TextField();
    tf.setCaption("Nkymn tunniste:");
    tf.setValue("tunniste");
    tf.setWidth("100%");
    content.addComponent(tf);//from   w  ww .ja  v a 2 s. c  o  m

    final TextField tf2 = new TextField();
    tf2.setCaption("Nkymn nimi:");
    tf2.setValue("Uusi nkym");
    tf2.setWidth("100%");
    content.addComponent(tf2);

    final ComboBox combo = new ComboBox();
    combo.setCaption("Kartan tyyppi:");
    combo.setNullSelectionAllowed(false);
    combo.setWidth("100%");
    content.addComponent(combo);

    Property levelProperty = Property.find(database, Property.LEVEL);
    ObjectType level = database.find((String) levelProperty.getPropertyValue(map));

    Collection<Base> subs = Strategiakartta.availableLevels(database);
    for (Base b : subs) {
        combo.addItem(b.uuid);
        combo.setItemCaption(b.uuid, b.getText(database));
        combo.select(b.uuid);
    }

    final ComboBox combo2 = new ComboBox();
    combo2.setCaption("Aihetunniste:");
    combo2.setNullSelectionAllowed(false);
    combo2.setWidth("100%");
    content.addComponent(combo2);

    for (Tag t : Tag.enumerate(database)) {
        combo2.addItem(t.uuid);
        combo2.setItemCaption(t.uuid, t.getId(database));
        combo2.select(t.uuid);
    }

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setMargin(true);

    Button ok = new Button("Lis");
    buttons.addComponent(ok);

    final Window dialog = Dialogs.makeDialog(main, "450px", "380px", "Lis nkym", "Peruuta", content,
            buttons);
    ok.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 1422158448876521843L;

        public void buttonClick(ClickEvent event) {

            String id = tf.getValue();
            String name = tf2.getValue();
            String typeUUID = (String) combo.getValue();
            Base type = database.find(typeUUID);

            String tagUUID = (String) combo2.getValue();
            Tag tag = (Tag) database.find(tagUUID);

            Strategiakartta newMap = database.newMap(main, main.uiState.current, id, name + " (nkym)", type);
            newMap.generators.add(tag);

            Updates.updateJS(main, true);
            main.removeWindow(dialog);

        }

    });

}

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

License:Apache License

/**
 * Initialise la vue/* w  w  w. ja  v a 2 s .  c  o m*/
 */
@PostConstruct
public void init() {

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

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

            LOG.debug(userController.getCurrentUserName() + " init EtatCivilView");

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

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

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

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

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

            /* Generalites */
            FormLayout formGeneralitesLayout = new FormLayout();
            formGeneralitesLayout.setSpacing(true);
            formGeneralitesLayout.setMargin(true);

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

            String captionNumDossier = applicationContext.getMessage(NAME + ".numdossier.title", null,
                    getLocale());
            Label fieldNumDossier = new Label();
            formatLabel(fieldNumDossier, captionNumDossier, MainUI.getCurrent().getEtudiant().getCod_etu());
            formGeneralitesLayout.addComponent(fieldNumDossier);

            String captionNNE = applicationContext.getMessage(NAME + ".nne.title", null, getLocale());
            Label fieldNNE = new Label();
            formatLabel(fieldNNE, captionNNE, MainUI.getCurrent().getEtudiant().getCod_nne());
            formGeneralitesLayout.addComponent(fieldNNE);

            String captionNom = applicationContext.getMessage(NAME + ".nom.title", null, getLocale());
            Label fieldNom = new Label();
            formatLabel(fieldNom, captionNom, MainUI.getCurrent().getEtudiant().getNom());
            formGeneralitesLayout.addComponent(fieldNom);

            String captionMail = applicationContext.getMessage(NAME + ".mail.title", null, getLocale());
            Label mailLabel = new Label();
            mailLabel.setCaption(captionMail);
            String mail = MainUI.getCurrent().getEtudiant().getEmail();
            if (StringUtils.hasText(mail)) {
                mail = "<a href=\"mailto:" + mail + "\">" + mail + "</a>";
                mailLabel.setValue(mail);
                mailLabel.setContentMode(ContentMode.HTML);
            }
            mailLabel.setSizeFull();
            formGeneralitesLayout.addComponent(mailLabel);

            String captionNationalite = applicationContext.getMessage(NAME + ".nationalite.title", null,
                    getLocale());
            Label fieldNationalite = new Label();
            formatLabel(fieldNationalite, captionNationalite,
                    MainUI.getCurrent().getEtudiant().getNationalite());
            formGeneralitesLayout.addComponent(fieldNationalite);

            String captionDateNaissance = applicationContext.getMessage(NAME + ".naissance.title", null,
                    getLocale());
            Label fieldDateNaissance = new Label();
            formatLabel(fieldDateNaissance, captionDateNaissance,
                    MainUI.getCurrent().getEtudiant().getDatenaissance());
            formGeneralitesLayout.addComponent(fieldDateNaissance);

            String captionLieuNaissance = applicationContext.getMessage(NAME + ".lieunaissance.title", null,
                    getLocale());
            Label fieldLieuNaissance = new Label();
            formatLabel(fieldLieuNaissance, captionLieuNaissance,
                    MainUI.getCurrent().getEtudiant().getLieunaissance());
            formGeneralitesLayout.addComponent(fieldLieuNaissance);

            String captionDepNaissance = applicationContext.getMessage(NAME + ".depnaissance.title", null,
                    getLocale());
            Label fieldDepNaissance = new Label();
            formatLabel(fieldDepNaissance, captionDepNaissance,
                    MainUI.getCurrent().getEtudiant().getDepartementnaissance());
            formGeneralitesLayout.addComponent(fieldDepNaissance);

            panelGeneralites.setContent(formGeneralitesLayout);

            HorizontalLayout generalitesGlobalLayout = new HorizontalLayout();
            generalitesGlobalLayout.setSizeUndefined();
            generalitesGlobalLayout.setStyleName("firstitembox");
            generalitesGlobalLayout.addComponent(panelGeneralites);
            generalitesGlobalLayout.setExpandRatio(panelGeneralites, 1);
            idLayout.addComponent(generalitesGlobalLayout);

            /* Bac */

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

            //Si plusieurs bac
            if (MainUI.getCurrent().getEtudiant().getListeBac() != null
                    && MainUI.getCurrent().getEtudiant().getListeBac().size() > 1) {
                panelBac.setCaption(applicationContext.getMessage(NAME + ".bacs.title", null, getLocale()));
                TabSheet bacTabSheet = new TabSheet();
                VerticalLayout vBacLayout = new VerticalLayout();
                vBacLayout.setSizeFull();
                bacTabSheet.setSizeFull();
                bacTabSheet.addStyleName(ValoTheme.TABSHEET_FRAMED);
                for (BacEtatCivil bec : MainUI.getCurrent().getEtudiant().getListeBac()) {

                    FormLayout tabBacLayout = new FormLayout();
                    tabBacLayout.setSizeFull();
                    tabBacLayout.setMargin(false);
                    ajouterBacToView(tabBacLayout, bec);
                    bacTabSheet.addTab(tabBacLayout, bec.getCod_bac(), FontAwesome.GRADUATION_CAP);

                }
                vBacLayout.addComponent(bacTabSheet);
                panelBac.setContent(vBacLayout);
            } else {
                //Si un seul bac
                FormLayout formBacLayout = new FormLayout();
                formBacLayout.setSizeFull();
                if (MainUI.getCurrent().getEtudiant().getListeBac() != null
                        && MainUI.getCurrent().getEtudiant().getListeBac().size() == 1) {
                    formBacLayout.setSpacing(true);
                    formBacLayout.setMargin(true);
                    ajouterBacToView(formBacLayout, MainUI.getCurrent().getEtudiant().getListeBac().get(0));
                }
                panelBac.setContent(formBacLayout);
            }

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

            /* Info de contact */
            panelContact = new Panel(applicationContext.getMessage(NAME + ".contact.title", null, getLocale()));
            renseignerPanelContact();
            globalLayout.addComponent(panelContact);

            addComponent(globalLayout);

        } else {
            /* Erreur */
            addComponent(new BasicErreurMessageLayout(applicationContext));
        }
    }
}

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

License:Apache License

/**
 * Initialise la vue//from www  .j  a  va  2 s . c  o m
 */
@PostConstruct
public void init() {

    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MdwTouchkitUI && userController.isEnseignant()) {
        removeAllComponents();

        /* Style */
        setSizeFull();

        liste_types_inscrits = new LinkedList<String>();
        liste_types_inscrits.add("ELP");
        liste_types_inscrits.add("VET");

        liste_type_arbo = new LinkedList<String>();
        liste_type_arbo.add("CMP");
        liste_type_arbo.add("VET");

        List<Favoris> lfav = favorisController.getFavoris();

        //NAVBAR
        HorizontalLayout navbar = new HorizontalLayout();
        navbar.setSizeFull();
        navbar.setHeight("40px");
        navbar.setStyleName("navigation-bar");

        //Bouton info
        infoButton = new Button();
        infoButton.setIcon(FontAwesome.INFO);
        infoButton.setStyleName("v-nav-button");
        infoButton.addClickListener(e -> {
            /**
             * NOUVELLE VERSION
             */
            Notification note = new Notification(
                    applicationContext.getMessage("helpWindowMobile.text.enseignant", null, getLocale()), "",
                    Notification.TYPE_TRAY_NOTIFICATION, true);
            note.setPosition(Position.MIDDLE_CENTER);
            note.setDelayMsec(6000);
            note.show(UI.getCurrent().getPage());
            /**
             * ANCIENNE VERSION
             */
            /*
            //afficher message
            HelpMobileWindow hbw = new HelpMobileWindow(applicationContext.getMessage("helpWindowMobile.text.enseignant", null, getLocale()),applicationContext.getMessage("helpWindow.defaultTitle", null, getLocale()),false);
                    
            UI.getCurrent().addWindow(hbw);
            */
        });
        navbar.addComponent(infoButton);
        navbar.setComponentAlignment(infoButton, Alignment.MIDDLE_LEFT);

        //Title
        Label labelFav = new Label(applicationContext.getMessage(NAME + ".title.label", null, getLocale()));
        labelFav.setStyleName("v-label-navbar");
        navbar.addComponent(labelFav);
        navbar.setComponentAlignment(labelFav, Alignment.MIDDLE_CENTER);

        //Bouton Search
        Button searchButton = new Button();
        searchButton.setIcon(FontAwesome.SEARCH);
        searchButton.setStyleName("v-nav-button");
        navbar.addComponent(searchButton);
        navbar.setComponentAlignment(searchButton, Alignment.MIDDLE_RIGHT);
        searchButton.addClickListener(e -> {
            ((MdwTouchkitUI) MdwTouchkitUI.getCurrent()).navigateToRecherche(NAME);
        });
        navbar.setExpandRatio(labelFav, 1);
        addComponent(navbar);

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

        FormLayout labelLayout = new FormLayout();
        labelLayout.setSizeFull();
        labelLayout.setMargin(false);
        labelLayout.setSpacing(false);

        Label infoLabel = new Label(applicationContext.getMessage(NAME + ".info.label", null, getLocale()));
        infoLabel.setStyleName(ValoTheme.LABEL_SMALL);
        infoLabel.setIcon(FontAwesome.INFO_CIRCLE);
        infoLabel.setWidth("100%");

        labelLayout.addComponent(infoLabel);
        globalLayout.addComponent(labelLayout);

        if (lfav != null && lfav.size() > 0) {
            if (favorisContientVet(lfav)) {

                Panel vetPanel = new Panel(
                        applicationContext.getMessage(NAME + ".vetpanel.title", null, getLocale()));
                vetPanel.setStyleName("centertitle-panel");
                vetPanel.addStyleName("v-colored-panel-caption");
                vetPanel.setSizeFull();

                VerticalLayout vetLayout = new VerticalLayout();
                vetLayout.setSizeFull();
                vetLayout.setHeight(null);
                int i = 0;
                for (Favoris fav : lfav) {
                    if (fav.getId().getTypfav().equals(Utils.VET)) {
                        i++;

                        HorizontalLayout favVetLayout = new HorizontalLayout();
                        favVetLayout.setSizeFull();
                        favVetLayout.setMargin(true);
                        favVetLayout.setSpacing(true);
                        favVetLayout.setStyleName("v-layout-multiline");
                        favVetLayout.setWidth("100%");
                        favVetLayout.setHeight("100%");

                        Button codeButton = new Button(fav.getId().getIdfav());
                        codeButton.setCaption(fav.getId().getIdfav());
                        Utils.setButtonStyle(codeButton);
                        codeButton.setWidth("90px");
                        codeButton.addClickListener(e -> {
                            accessToDetail(fav.getId().getIdfav(), fav.getId().getTypfav());
                        });

                        Button libButton = new Button(favorisController.getLibObjFavori(fav.getId().getTypfav(),
                                fav.getId().getIdfav()));
                        Utils.setButtonStyle(libButton);
                        libButton.setHeight("100%");
                        libButton.setWidth("100%");
                        libButton.addClickListener(e -> {
                            accessToDetail(fav.getId().getIdfav(), fav.getId().getTypfav());
                        });

                        favVetLayout.addComponent(codeButton);
                        //favVetLayout.setComponentAlignment(codeButton, Alignment.MIDDLE_CENTER);
                        favVetLayout.addComponent(libButton);
                        favVetLayout.setComponentAlignment(libButton, Alignment.MIDDLE_CENTER);
                        favVetLayout.setExpandRatio(libButton, 1);
                        vetLayout.addComponent(favVetLayout);
                        if (i > 1) {
                            favVetLayout.addStyleName("line-separator");
                        }
                    }
                }
                vetPanel.setContent(vetLayout);
                globalLayout.addComponent(vetPanel);

            }

            if (favorisContientElp(lfav)) {
                Panel elpPanel = new Panel(
                        applicationContext.getMessage(NAME + ".elppanel.title", null, getLocale()));
                elpPanel.setStyleName("centertitle-panel");
                elpPanel.addStyleName("v-colored-panel-caption");
                elpPanel.setSizeFull();

                VerticalLayout elpLayout = new VerticalLayout();
                elpLayout.setSizeFull();
                elpLayout.setHeight(null);
                int i = 0;
                for (Favoris fav : lfav) {
                    if (fav.getId().getTypfav().equals(Utils.ELP)) {
                        i++;
                        HorizontalLayout favElpLayout = new HorizontalLayout();
                        favElpLayout.setSizeFull();
                        favElpLayout.setMargin(true);
                        favElpLayout.setSpacing(true);
                        favElpLayout.setStyleName("v-layout-multiline");
                        favElpLayout.setWidth("100%");
                        favElpLayout.setHeight("100%");

                        Button codeButton = new Button(fav.getId().getIdfav());
                        Utils.setButtonStyle(codeButton);
                        codeButton.setWidth("90px");
                        codeButton.addClickListener(e -> {
                            accessToDetail(fav.getId().getIdfav(), fav.getId().getTypfav());
                        });

                        Button libButton = new Button(favorisController.getLibObjFavori(fav.getId().getTypfav(),
                                fav.getId().getIdfav()));
                        Utils.setButtonStyle(libButton);
                        libButton.setHeight("100%");
                        libButton.setWidth("100%");
                        libButton.addClickListener(e -> {
                            accessToDetail(fav.getId().getIdfav(), fav.getId().getTypfav());
                        });

                        favElpLayout.addComponent(codeButton);
                        favElpLayout.addComponent(libButton);
                        favElpLayout.setComponentAlignment(libButton, Alignment.MIDDLE_CENTER);
                        favElpLayout.setExpandRatio(libButton, 1);
                        elpLayout.addComponent(favElpLayout);
                        if (i > 1) {
                            favElpLayout.addStyleName("line-separator");
                        }
                    }
                }
                elpPanel.setContent(elpLayout);
                globalLayout.addComponent(elpPanel);
            }

        }

        labelAucunFavoriLayout = new HorizontalLayout();
        labelAucunFavoriLayout.setMargin(true);
        labelAucunFavoriLayout.setSizeFull();
        Button aucunFavoris = new Button(
                applicationContext.getMessage(NAME + ".favoris.aucun", null, getLocale()));
        aucunFavoris.setStyleName("v-nav-button");
        aucunFavoris.addStyleName(ValoTheme.BUTTON_LINK);
        aucunFavoris.addClickListener(e -> {
            ((MdwTouchkitUI) MdwTouchkitUI.getCurrent()).navigateToRecherche(NAME);
        });

        labelAucunFavoriLayout.addComponent(aucunFavoris);
        labelAucunFavoriLayout.setVisible(false);
        globalLayout.addComponent(labelAucunFavoriLayout);

        if (lfav == null || lfav.size() == 0) {
            labelAucunFavoriLayout.setVisible(true);
        }

        //addComponent(globalLayout);
        contentLayout.setStyleName("v-scrollableelement");
        contentLayout.addComponent(globalLayout);
        addComponent(contentLayout);
        setExpandRatio(contentLayout, 1);

    }
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.ExecutionStepComponent.java

License:Apache License

private void init() {
    FormLayout layout = new FormLayout();
    setContent(layout);/*from  w  ww .  j av  a2s  .  c om*/
    addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    BeanFieldGroup binder = new BeanFieldGroup(es.getClass());
    binder.setItemDataSource(es);
    FieldGroupFieldFactory defaultFactory = binder.getFieldFactory();
    binder.setFieldFactory(new FieldGroupFieldFactory() {

        @Override
        public <T extends Field> T createField(Class<?> dataType, Class<T> fieldType) {
            if (dataType.isAssignableFrom(VmUser.class)) {
                BeanItemContainer<VmUser> userEntityContainer = new BeanItemContainer<>(VmUser.class);
                userEntityContainer.addBean(es.getAssignee());
                Field field = new TextField(
                        es.getAssignee() == null ? TRANSLATOR.translate("general.not.applicable")
                                : es.getAssignee().getFirstName() + " " + es.getAssignee().getLastName());
                return fieldType.cast(field);
            }

            return defaultFactory.createField(dataType, fieldType);
        }
    });
    layout.addComponent(((VMUI) UI.getCurrent()).createStepHistoryTable(TRANSLATOR.translate("step.detail"),
            Arrays.asList(es.getStepHistory()), false));
    if (es.getResultId() != null) {
        Field<?> result = binder.buildAndBind(TRANSLATOR.translate("general.result"), "resultId.resultName");
        layout.addComponent(result);
    }
    if (es.getComment() != null) {
        TextArea comment = new TextArea(TRANSLATOR.translate("general.comment"));
        binder.bind(comment, "comment");
        layout.addComponent(comment);
    }
    if (es.getAssignee() != null) {
        TextField assignee = new TextField(TRANSLATOR.translate("general.assignee"));
        VmUser u = es.getAssignee();
        assignee.setValue(u.toString());
        assignee.setReadOnly(true);
        layout.addComponent(assignee);
    }
    if (es.getExecutionStart() != null) {
        Field<?> start = binder.buildAndBind(TRANSLATOR.translate("execution.start"), "executionStart");
        layout.addComponent(start);
    }
    if (es.getExecutionEnd() != null) {
        Field<?> end = binder.buildAndBind(TRANSLATOR.translate("execution.end"), "executionEnd");
        layout.addComponent(end);
    }
    if (es.getExecutionTime() != null && es.getExecutionTime() > 0) {
        Field<?> time = binder.buildAndBind(TRANSLATOR.translate("execution.time"), "executionTime");
        layout.addComponent(time);
    }
    if (!es.getHistoryList().isEmpty()) {
        layout.addComponent(((VMUI) UI.getCurrent()).createRequirementHistoryTable(
                TRANSLATOR.translate("related.requirements"), es.getHistoryList(), true));
    }
    Button cancel = new Button(TRANSLATOR.translate("general.cancel"));
    cancel.addClickListener((Button.ClickEvent event) -> {
        binder.discard();
        if (es.getExecutionStepPK() == null) {
            ((VMUI) UI.getCurrent()).displayObject(((VMUI) UI.getCurrent()).getSelectdValue());
        } else {
            ((VMUI) UI.getCurrent()).displayObject(es, false);
        }
    });
    binder.setReadOnly(true);
    binder.bindMemberFields(this);
    layout.setSizeFull();
    setSizeFull();
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.RequirementSpecComponent.java

License:Apache License

private void init() {
    FormLayout layout = new FormLayout();
    setContent(layout);//from w  w w  .  j av  a 2  s. co m
    addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    BeanFieldGroup binder = new BeanFieldGroup(rs.getClass());
    binder.setItemDataSource(rs);
    Field<?> name = binder.buildAndBind(TRANSLATOR.translate("general.name"), "name");
    layout.addComponent(name);
    Field desc = binder.buildAndBind(TRANSLATOR.translate("general.description"), "description",
            TextArea.class);
    desc.setSizeFull();
    layout.addComponent(desc);
    Field<?> date = binder.buildAndBind(TRANSLATOR.translate("general.modification.data"), "modificationDate");
    layout.addComponent(date);
    date.setEnabled(false);
    SpecLevelJpaController controller = new SpecLevelJpaController(DataBaseManager.getEntityManagerFactory());
    List<SpecLevel> levels = controller.findSpecLevelEntities();
    BeanItemContainer<SpecLevel> specLevelContainer = new BeanItemContainer<>(SpecLevel.class, levels);
    ComboBox level = new ComboBox(TRANSLATOR.translate("spec.level"));
    level.setContainerDataSource(specLevelContainer);
    level.getItemIds().forEach(id -> {
        level.setItemCaption(id, TRANSLATOR.translate(((SpecLevel) id).getName()));
    });
    binder.bind(level, "specLevel");
    layout.addComponent(level);
    Button cancel = new Button(TRANSLATOR.translate("general.cancel"));
    cancel.addClickListener((Button.ClickEvent event) -> {
        binder.discard();
        if (rs.getRequirementSpecPK() == null) {
            ((VMUI) UI.getCurrent()).displayObject(rs.getProject());
        } else {
            ((VMUI) UI.getCurrent()).displayObject(rs, false);
        }
    });
    if (edit) {
        if (rs.getRequirementSpecPK() == null) {
            //Creating a new one
            Button save = new Button(TRANSLATOR.translate("general.save"));
            save.addClickListener((Button.ClickEvent event) -> {
                try {
                    rs.setName(name.getValue().toString());
                    rs.setModificationDate(new Date());
                    rs.setSpecLevel((SpecLevel) level.getValue());
                    rs.setProject(((Project) ((VMUI) UI.getCurrent()).getSelectdValue()));
                    rs.setRequirementSpecPK(
                            new RequirementSpecPK(rs.getProject().getId(), rs.getSpecLevel().getId()));
                    new RequirementSpecJpaController(DataBaseManager.getEntityManagerFactory()).create(rs);
                    setVisible(false);
                    //Recreate the tree to show the addition
                    ((VMUI) UI.getCurrent()).updateProjectList();
                    ((VMUI) UI.getCurrent()).buildProjectTree(rs);
                    ((VMUI) UI.getCurrent()).displayObject(rs, true);
                    ((VMUI) UI.getCurrent()).updateScreen();
                } catch (Exception ex) {
                    LOG.log(Level.SEVERE, null, ex);
                    Notification.show(TRANSLATOR.translate("general.error.record.creation"),
                            ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                }
            });
            HorizontalLayout hl = new HorizontalLayout();
            hl.addComponent(save);
            hl.addComponent(cancel);
            layout.addComponent(hl);
        } else {
            //Editing existing one
            Button update = new Button(TRANSLATOR.translate("general.update"));
            update.addClickListener((Button.ClickEvent event) -> {
                try {
                    rs.setName(name.getValue().toString());
                    rs.setModificationDate(new Date());
                    rs.setSpecLevel((SpecLevel) level.getValue());
                    ((VMUI) UI.getCurrent()).handleVersioning(rs, () -> {
                        try {
                            new RequirementSpecJpaController(DataBaseManager.getEntityManagerFactory())
                                    .edit(rs);
                            ((VMUI) UI.getCurrent()).displayObject(rs, true);
                        } catch (NonexistentEntityException ex) {
                            LOG.log(Level.SEVERE, null, ex);
                            Notification.show(TRANSLATOR.translate("general.error.record.update"),
                                    ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                        } catch (Exception ex) {
                            LOG.log(Level.SEVERE, null, ex);
                            Notification.show(TRANSLATOR.translate("general.error.record.update"),
                                    ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                        }
                    });
                } catch (Exception ex) {
                    LOG.log(Level.SEVERE, null, ex);
                    Notification.show(TRANSLATOR.translate("general.error.record.update"),
                            ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                }
            });
            HorizontalLayout hl = new HorizontalLayout();
            hl.addComponent(update);
            hl.addComponent(cancel);
            layout.addComponent(hl);
        }
    }
    binder.setReadOnly(!edit);
    binder.bindMemberFields(this);
    layout.setSizeFull();
    setSizeFull();
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.RequirementSpecNodeComponent.java

License:Apache License

private void init() {
    FormLayout layout = new FormLayout();
    setContent(layout);//from w  w  w  . j  a  va2s  . co  m
    addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    BeanFieldGroup binder = new BeanFieldGroup(rsn.getClass());
    binder.setItemDataSource(rsn);
    Field<?> name = binder.buildAndBind(TRANSLATOR.translate("general.name"), "name");
    layout.addComponent(name);
    Field desc = binder.buildAndBind(TRANSLATOR.translate("general.description"), "description",
            TextArea.class);
    desc.setSizeFull();
    layout.addComponent(desc);
    Field<?> scope = binder.buildAndBind(TRANSLATOR.translate("general.scope"), "scope");
    layout.addComponent(scope);
    Button cancel = new Button(TRANSLATOR.translate("general.cancel"));
    cancel.addClickListener((Button.ClickEvent event) -> {
        binder.discard();
        if (rsn.getRequirementSpecNodePK() == null) {
            ((VMUI) UI.getCurrent()).displayObject(rsn.getRequirementSpec());
        } else {
            ((VMUI) UI.getCurrent()).displayObject(rsn, false);
        }
    });
    if (edit) {
        if (rsn.getRequirementSpecNodePK() == null) {
            //Creating a new one
            Button save = new Button(TRANSLATOR.translate("general.save"));
            save.addClickListener((Button.ClickEvent event) -> {
                try {
                    rsn.setName(name.getValue().toString());
                    rsn.setDescription(desc.getValue().toString());
                    rsn.setScope(scope.getValue().toString());
                    rsn.setRequirementSpec((RequirementSpec) ((VMUI) UI.getCurrent()).getSelectdValue());
                    new RequirementSpecNodeJpaController(DataBaseManager.getEntityManagerFactory()).create(rsn);
                    setVisible(false);
                    //Recreate the tree to show the addition
                    ((VMUI) UI.getCurrent()).updateProjectList();
                    ((VMUI) UI.getCurrent()).buildProjectTree(rsn);
                    ((VMUI) UI.getCurrent()).displayObject(rsn, true);
                    ((VMUI) UI.getCurrent()).updateScreen();
                } catch (Exception ex) {
                    LOG.log(Level.SEVERE, null, ex);
                    Notification.show(TRANSLATOR.translate("general.error.record.creation"),
                            ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                }
            });
            HorizontalLayout hl = new HorizontalLayout();
            hl.addComponent(save);
            hl.addComponent(cancel);
            layout.addComponent(hl);
        } else {
            //Editing existing one
            Button update = new Button(TRANSLATOR.translate("general.update"));
            update.addClickListener((Button.ClickEvent event) -> {
                rsn.setName(name.getValue().toString());
                rsn.setDescription(desc.getValue().toString());
                rsn.setScope(scope.getValue().toString());
                ((VMUI) UI.getCurrent()).handleVersioning(rsn, () -> {
                    try {
                        new RequirementSpecNodeJpaController(DataBaseManager.getEntityManagerFactory())
                                .edit(rsn);
                        ((VMUI) UI.getCurrent()).displayObject(rsn, true);
                    } catch (NonexistentEntityException ex) {
                        LOG.log(Level.SEVERE, null, ex);
                        Notification.show(TRANSLATOR.translate("general.error.record.update"),
                                ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                    } catch (Exception ex) {
                        LOG.log(Level.SEVERE, null, ex);
                        Notification.show(TRANSLATOR.translate("general.error.record.update"),
                                ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                    }
                });
            });
            HorizontalLayout hl = new HorizontalLayout();
            hl.addComponent(update);
            hl.addComponent(cancel);
            layout.addComponent(hl);
        }
    }
    binder.setReadOnly(!edit);
    binder.bindMemberFields(this);
    layout.setSizeFull();
    setSizeFull();
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.StepComponent.java

License:Apache License

private void init() {
    FormLayout layout = new FormLayout();
    setContent(layout);//from   ww  w.  j av a2  s  . c  o m
    addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    BeanFieldGroup binder = new BeanFieldGroup(s.getClass());
    binder.setItemDataSource(s);
    Field<?> sequence = binder.buildAndBind(TRANSLATOR.translate("general.sequence"), "stepSequence");
    layout.addComponent(sequence);
    TextArea text = new TextArea(TRANSLATOR.translate("general.text"));
    text.setConverter(new ByteToStringConverter());
    binder.bind(text, "text");
    layout.addComponent(text);
    TextArea result = new TextArea(TRANSLATOR.translate("expected.result"));
    result.setConverter(new ByteToStringConverter());
    binder.bind(result, "expectedResult");
    layout.addComponent(result);
    Field notes = binder.buildAndBind(TRANSLATOR.translate("general.notes"), "notes", TextArea.class);
    notes.setSizeFull();
    layout.addComponent(notes);
    if (!s.getRequirementList().isEmpty() && !edit) {
        layout.addComponent(((ValidationManagerUI) UI.getCurrent()).getDisplayRequirementList(
                TRANSLATOR.translate("related.requirements"), s.getRequirementList()));
    } else {
        AbstractSelect requirements = ((ValidationManagerUI) UI.getCurrent())
                .getRequirementSelectionComponent();
        //Select the exisitng ones.
        if (s.getRequirementList() != null) {
            s.getRequirementList().forEach((r) -> {
                requirements.select(r);
            });
        }
        requirements.addValueChangeListener(event -> {
            Set<Requirement> selected = (Set<Requirement>) event.getProperty().getValue();
            s.getRequirementList().clear();
            selected.forEach(r -> {
                s.getRequirementList().add(r);
            });
        });
        layout.addComponent(requirements);
    }
    DataEntryComponent fields = new DataEntryComponent(edit);
    binder.bind(fields, "dataEntryList");
    layout.addComponent(fields);
    binder.setReadOnly(edit);
    Button cancel = new Button(TRANSLATOR.translate("general.cancel"));
    cancel.addClickListener((Button.ClickEvent event) -> {
        binder.discard();
        if (s.getStepPK() == null) {
            ((ValidationManagerUI) UI.getCurrent())
                    .displayObject(((ValidationManagerUI) UI.getCurrent()).getTree().getValue());
        } else {
            ((ValidationManagerUI) UI.getCurrent()).displayObject(s, false);
        }
    });
    if (edit) {
        Button add = new Button(TRANSLATOR.translate("add.field"));
        add.addClickListener(listener -> {
            VMWindow w = new VMWindow();
            FormLayout fl = new FormLayout();
            ComboBox newType = new ComboBox(TRANSLATOR.translate("general.type"));
            newType.setNewItemsAllowed(false);
            newType.setTextInputAllowed(false);
            newType.addValidator(new NullValidator(TRANSLATOR.translate("message.required.field.missing")
                    .replaceAll("%f", TRANSLATOR.translate("general.type")), false));
            BeanItemContainer<DataEntryType> container = new BeanItemContainer<>(DataEntryType.class,
                    new DataEntryTypeJpaController(DataBaseManager.getEntityManagerFactory())
                            .findDataEntryTypeEntities());
            newType.setContainerDataSource(container);
            newType.getItemIds().forEach(id -> {
                DataEntryType temp = ((DataEntryType) id);
                newType.setItemCaption(id, TRANSLATOR.translate(temp.getTypeName()));
            });
            fl.addComponent(newType);
            TextField tf = new TextField(TRANSLATOR.translate("general.name"));
            fl.addComponent(tf);
            HorizontalLayout hl = new HorizontalLayout();
            Button a = new Button(TRANSLATOR.translate("general.add"));
            a.addClickListener(l -> {
                DataEntryType det = (DataEntryType) newType.getValue();
                DataEntry de = null;
                switch (det.getId()) {
                case 1:
                    de = DataEntryServer.getStringField(tf.getValue());
                    break;
                case 2:
                    de = DataEntryServer.getNumericField(tf.getValue(), null, null);
                    break;
                case 3:
                    de = DataEntryServer.getBooleanField(tf.getValue());
                    break;
                case 4:
                    de = DataEntryServer.getAttachmentField(tf.getValue());
                    break;
                }
                if (de != null) {
                    s.getDataEntryList().add(de);
                    ((ValidationManagerUI) UI.getCurrent()).displayObject(s);
                }
                UI.getCurrent().removeWindow(w);
            });
            hl.addComponent(a);
            Button c = new Button(TRANSLATOR.translate("general.cancel"));
            c.addClickListener(l -> {
                UI.getCurrent().removeWindow(w);
            });
            hl.addComponent(c);
            fl.addComponent(hl);
            w.setContent(fl);
            UI.getCurrent().addWindow(w);
        });
        if (s.getStepPK() == null) {
            //Creating a new one
            Button save = new Button(TRANSLATOR.translate("general.save"));
            save.addClickListener(listener -> {
                try {
                    s.setExpectedResult(((TextArea) result).getValue().getBytes(encoding));
                    s.setNotes(notes.getValue() == null ? "" : notes.getValue().toString());
                    s.setStepSequence(Integer.parseInt(sequence.getValue().toString()));
                    s.setTestCase((TestCase) ((ValidationManagerUI) UI.getCurrent()).getTree().getValue());
                    s.setText(text.getValue().getBytes(encoding));
                    if (s.getRequirementList() == null) {
                        s.setRequirementList(new ArrayList<>());
                    }
                    new StepJpaController(DataBaseManager.getEntityManagerFactory()).create(s);
                    setVisible(false);
                    //Recreate the tree to show the addition
                    ((ValidationManagerUI) UI.getCurrent()).updateProjectList();
                    ((ValidationManagerUI) UI.getCurrent()).updateScreen();
                    ((ValidationManagerUI) UI.getCurrent()).displayObject(s);
                    ((ValidationManagerUI) UI.getCurrent()).buildProjectTree(s);
                } catch (Exception ex) {
                    LOG.log(Level.SEVERE, null, ex);
                    Notification.show(TRANSLATOR.translate("general.error.record.creation"),
                            ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                }
            });
            HorizontalLayout hl = new HorizontalLayout();
            hl.addComponent(save);
            hl.addComponent(add);
            hl.addComponent(cancel);
            layout.addComponent(hl);
        } else {
            //Editing existing one
            Button update = new Button(TRANSLATOR.translate("general.update"));
            update.addClickListener((Button.ClickEvent event) -> {
                try {
                    s.setExpectedResult(((TextArea) result).getValue().getBytes(encoding));
                    s.setNotes(notes.getValue().toString());
                    s.setStepSequence(Integer.parseInt(sequence.getValue().toString()));
                    s.setText(text.getValue().getBytes(encoding));
                    if (s.getRequirementList() == null) {
                        s.setRequirementList(new ArrayList<>());
                    }
                    ((ValidationManagerUI) UI.getCurrent()).handleVersioning(s, () -> {
                        try {
                            new StepJpaController(DataBaseManager.getEntityManagerFactory()).edit(s);
                        } catch (NonexistentEntityException ex) {
                            LOG.log(Level.SEVERE, null, ex);
                            Notification.show(TRANSLATOR.translate("general.error.record.update"),
                                    ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                        } catch (Exception ex) {
                            LOG.log(Level.SEVERE, null, ex);
                            Notification.show(TRANSLATOR.translate("general.error.record.update"),
                                    ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                        }
                    });
                    ((ValidationManagerUI) UI.getCurrent()).displayObject(s);
                } catch (UnsupportedEncodingException | NumberFormatException ex) {
                    LOG.log(Level.SEVERE, null, ex);
                    Notification.show(TRANSLATOR.translate("general.error.record.creation"),
                            ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                }
            });
            HorizontalLayout hl = new HorizontalLayout();
            hl.addComponent(update);
            hl.addComponent(add);
            hl.addComponent(cancel);
            layout.addComponent(hl);
        }
    }
    binder.setReadOnly(!edit);
    binder.bindMemberFields(this);
    layout.setSizeFull();
    setSizeFull();
}

From source file:org.esn.esobase.view.tab.BookTranslateTab.java

public BookTranslateTab(DBService service) {
    this.service = service;
    this.setSizeFull();
    FilterChangeListener filterChangeListener = new FilterChangeListener();
    bookListlayout = new HorizontalLayout();
    bookListlayout.setWidth(100f, Unit.PERCENTAGE);
    bookTable = new ComboBox("");
    bookTable.setPageLength(20);/*from  w  ww .ja va  2s.c  om*/
    bookTable.setScrollToSelectedItem(true);
    bookTable.setDataProvider(new ListDataProvider<>(books));
    bookTable.addValueChangeListener(new BookSelectListener());

    bookTable.setWidth(100f, Unit.PERCENTAGE);
    locationTable = new ComboBox("?");
    locationTable.setPageLength(15);
    locationTable.setScrollToSelectedItem(true);

    locationTable.setWidth(100f, Unit.PERCENTAGE);
    locationTable.setDataProvider(new ListDataProvider<>(locations));

    locationTable.addValueChangeListener(filterChangeListener);

    subLocationTable = new ComboBox("?");
    subLocationTable.setPageLength(15);
    subLocationTable.setScrollToSelectedItem(true);
    subLocationTable.addValueChangeListener(filterChangeListener);

    subLocationTable.setWidth(100f, Unit.PERCENTAGE);
    subLocationTable.setDataProvider(new ListDataProvider<>(subLocations));

    FormLayout locationAndBook = new FormLayout(locationTable, subLocationTable, bookTable);
    locationAndBook.addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    locationAndBook.setSizeFull();

    bookListlayout.addComponent(locationAndBook);
    translateStatus = new ComboBoxMultiselect("? ",
            Arrays.asList(TRANSLATE_STATUS.values()));
    translateStatus.setClearButtonCaption("?");
    translateStatus.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            LoadFilters();
        }
    });
    noTranslations = new CheckBox("?  ?");
    noTranslations.setValue(Boolean.FALSE);
    noTranslations.addValueChangeListener(filterChangeListener);
    emptyTranslations = new CheckBox("?  ");
    emptyTranslations.setValue(Boolean.FALSE);
    emptyTranslations.addValueChangeListener(filterChangeListener);
    HorizontalLayout checkBoxlayout = new HorizontalLayout(noTranslations, emptyTranslations);
    translatorBox = new ComboBox("");
    translatorBox.setPageLength(15);
    translatorBox.setScrollToSelectedItem(true);
    translatorBox.setDataProvider(new ListDataProvider(service.getSysAccounts()));
    translatorBox.addValueChangeListener(filterChangeListener);
    refreshButton = new Button("");
    refreshButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            LoadFilters();
            LoadBookContent();
        }
    });
    countLabel = new Label();
    searchField = new TextField("?? ?");
    searchField.setSizeFull();
    searchField.setNullRepresentation("");
    searchField.addValueChangeListener(filterChangeListener);

    FormLayout filtersLayout = new FormLayout(translateStatus, translatorBox, checkBoxlayout, searchField);
    filtersLayout.addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    filtersLayout.setSizeFull();
    bookListlayout.addComponent(filtersLayout);
    bookListlayout.addComponent(refreshButton);
    bookListlayout.addComponent(countLabel);
    bookListlayout.setExpandRatio(locationAndBook, 0.4f);
    bookListlayout.setExpandRatio(filtersLayout, 0.4f);
    bookListlayout.setExpandRatio(refreshButton, 0.1f);
    bookListlayout.setExpandRatio(countLabel, 0.1f);
    bookListlayout.setHeight(105f, Unit.PIXELS);

    bookContentLayout = new TabSheet();
    bookContentLayout.setSizeFull();
    bookNameLayout = new HorizontalLayout();
    bookNameLayout.setSizeFull();
    bookNameOrigLayout = new VerticalLayout();
    bookNameEn = new TextField("?");
    bookNameEn.setWidth(500f, Unit.PIXELS);
    bookNameRu = new TextField(" ?");
    bookNameRu.setWidth(500f, Unit.PIXELS);
    bookNameRu.setNullRepresentation("");
    bookNameOrigLayout.addComponent(bookNameEn);
    bookNameOrigLayout.addComponent(bookNameRu);
    bookNameLayout.addComponent(bookNameOrigLayout);
    bookNameTranslationsLayout = new VerticalLayout();
    bookNameTranslationsLayout.setSizeFull();
    bookNameLayout.addComponent(bookNameTranslationsLayout);
    bookContentLayout.addTab(bookNameLayout, "?");

    bookTextLayout = new HorizontalLayout();
    bookTextLayout.setSizeFull();
    bookTextOrigLayout = new HorizontalLayout();
    bookTextOrigLayout.setSizeFull();
    bookTextEn = new TextArea("?");
    bookTextEn.setRows(20);
    bookTextEn.setSizeFull();
    bookTextRu = new TextArea(" ?");
    bookTextRu.setRows(20);
    bookTextRu.setSizeFull();
    bookTextRu.setNullRepresentation("");
    bookTextOrigLayout.addComponent(bookTextEn);
    bookTextOrigLayout.addComponent(bookTextRu);
    bookTextLayout.addComponent(bookTextOrigLayout);
    bookTextTranslationsLayout = new VerticalLayout();
    bookTextTranslationsLayout.setSizeFull();
    bookTextLayout.addComponent(bookTextTranslationsLayout);
    bookTextLayout.setExpandRatio(bookTextOrigLayout, 2f);
    bookTextLayout.setExpandRatio(bookTextTranslationsLayout, 1f);
    bookContentLayout.addTab(bookTextLayout, "?");
    bookNameEn.setReadOnly(true);
    bookNameRu.setReadOnly(true);
    bookTextEn.setReadOnly(true);
    bookTextRu.setReadOnly(true);
    this.addComponent(bookListlayout);
    this.addComponent(bookContentLayout);
    this.bookListlayout.setHeight(105f, Unit.PIXELS);
    this.setExpandRatio(bookContentLayout, 1f);
    new NoAutcompleteComboBoxExtension(locationTable);
    new NoAutcompleteComboBoxExtension(subLocationTable);
    new NoAutcompleteComboBoxExtension(translatorBox);
    LoadFilters();
}

From source file:org.esn.esobase.view.tab.QuestTranslateTab.java

public QuestTranslateTab(DBService service_) {
    this.setSizeFull();
    this.setSpacing(false);
    this.setMargin(false);
    this.service = service_;
    QuestChangeListener questChangeListener = new QuestChangeListener();
    FilterChangeListener filterChangeListener = new FilterChangeListener();
    questListlayout = new HorizontalLayout();
    questListlayout.setWidth(100f, Unit.PERCENTAGE);
    questListlayout.setSpacing(false);/*from  www  .j  a v a  2s .c  om*/
    questListlayout.setMargin(false);
    locationTable = new ComboBox("?");
    locationTable.setPageLength(30);
    locationTable.setScrollToSelectedItem(true);
    locationTable.setWidth(100f, Unit.PERCENTAGE);
    locationTable.addValueChangeListener(filterChangeListener);
    locationTable.setDataProvider(new ListDataProvider<>(locations));
    questTable = new ComboBox("?");
    questTable.setWidth(100f, Unit.PERCENTAGE);
    questTable.setPageLength(15);
    questTable.setScrollToSelectedItem(true);

    questTable.setWidth(100f, Unit.PERCENTAGE);
    questTable.addValueChangeListener(questChangeListener);
    questTable.setDataProvider(new ListDataProvider<>(questList));
    questListlayout.addComponent(questTable);
    FormLayout locationAndQuestLayout = new FormLayout(locationTable, questTable);
    locationAndQuestLayout.addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    locationAndQuestLayout.setSizeFull();
    questListlayout.addComponent(locationAndQuestLayout);
    translateStatus = new ComboBoxMultiselect("? ",
            Arrays.asList(TRANSLATE_STATUS.values()));
    translateStatus.setClearButtonCaption("?");
    translateStatus.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            LoadFilters();
            LoadContent();
        }
    });
    noTranslations = new CheckBox("?  ?");
    noTranslations.setValue(Boolean.FALSE);
    noTranslations.addValueChangeListener(filterChangeListener);
    emptyTranslations = new CheckBox("?  ");
    emptyTranslations.setValue(Boolean.FALSE);
    emptyTranslations.addValueChangeListener(filterChangeListener);
    HorizontalLayout checkBoxlayout = new HorizontalLayout(noTranslations, emptyTranslations);
    checkBoxlayout.setSpacing(false);
    checkBoxlayout.setMargin(false);
    translatorBox = new ComboBox("");
    translatorBox.setPageLength(15);
    translatorBox.setScrollToSelectedItem(true);
    translatorBox.setDataProvider(new ListDataProvider<SysAccount>(service.getSysAccounts()));
    translatorBox.addValueChangeListener(filterChangeListener);
    refreshButton = new Button("");
    refreshButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            LoadFilters();
            LoadContent();
        }
    });
    countLabel = new Label();
    searchField = new TextField("?? ?");
    searchField.setSizeFull();
    searchField.addValueChangeListener(filterChangeListener);

    FormLayout filtersLayout = new FormLayout(translateStatus, translatorBox, checkBoxlayout, searchField);
    filtersLayout.addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    filtersLayout.setSizeFull();
    questListlayout.addComponent(filtersLayout);
    questListlayout.addComponent(refreshButton);
    questListlayout.addComponent(countLabel);
    questListlayout.setExpandRatio(locationAndQuestLayout, 0.4f);
    questListlayout.setExpandRatio(filtersLayout, 0.4f);
    questListlayout.setExpandRatio(refreshButton, 0.1f);
    questListlayout.setExpandRatio(countLabel, 0.1f);
    questListlayout.setHeight(105f, Unit.PIXELS);
    this.addComponent(questListlayout);
    infoLayout = new VerticalLayout();
    infoLayout.setSizeFull();
    infoLayout.setSpacing(false);
    infoLayout.setMargin(false);
    tabSheet = new TabSheet();
    tabSheet.setSizeFull();
    nameLayout = new VerticalLayout();
    nameLayout.setSizeFull();
    nameHLayout = new HorizontalLayout();
    nameHLayout.setSizeFull();
    nameHLayout.setSpacing(false);
    nameHLayout.setMargin(false);
    nameLayout = new VerticalLayout();
    nameLayout.setSizeFull();
    nameLayout.setSpacing(false);
    nameLayout.setMargin(false);
    questNameEnArea = new TextArea("?");
    questNameEnArea.setSizeFull();
    questNameEnArea.setRows(1);
    questNameEnArea.setReadOnly(true);
    questNameRuArea = new TextArea("? Ru");
    questNameRuArea.setSizeFull();
    questNameRuArea.setRows(1);
    questNameRuArea.setReadOnly(true);
    questNameRawEnArea = new TextArea("?  ");
    questNameRawEnArea.setSizeFull();
    questNameRawEnArea.setRows(1);
    questNameRawEnArea.setReadOnly(true);
    questNameRawRuArea = new TextArea("?   Ru");
    questNameRawRuArea.setSizeFull();
    questNameRawRuArea.setRows(1);
    questNameRawRuArea.setReadOnly(true);
    nameLayout.addComponents(questNameEnArea, questNameRuArea, questNameRawEnArea, questNameRawRuArea);
    nameHLayout.addComponent(nameLayout);
    nameTranslateLayout = new VerticalLayout();
    nameTranslateLayout.setSizeFull();
    nameTranslateLayout.setSpacing(false);
    nameTranslateLayout.setMargin(false);
    nameHLayout.addComponent(nameTranslateLayout);
    infoLayout.addComponent(nameHLayout);
    descriptionLayout = new VerticalLayout();
    descriptionLayout.setSizeFull();
    descriptionHLayout = new HorizontalLayout();
    descriptionHLayout.setSizeFull();
    descriptionHLayout.setSpacing(false);
    descriptionHLayout.setMargin(false);
    descriptionLayout = new VerticalLayout();
    descriptionLayout.setSizeFull();
    descriptionLayout.setSpacing(false);
    descriptionLayout.setMargin(false);
    questDescriptionEnArea = new TextArea("?");
    questDescriptionEnArea.setSizeFull();
    questDescriptionEnArea.setRows(4);
    questDescriptionEnArea.setReadOnly(true);
    questDescriptionRuArea = new TextArea("? Ru");
    questDescriptionRuArea.setSizeFull();
    questDescriptionRuArea.setRows(4);
    questDescriptionRuArea.setReadOnly(true);
    questDescriptionRawEnArea = new TextArea("?  ");
    questDescriptionRawEnArea.setSizeFull();
    questDescriptionRawEnArea.setRows(4);
    questDescriptionRawEnArea.setReadOnly(true);
    questDescriptionRawRuArea = new TextArea("?   Ru");
    questDescriptionRawRuArea.setSizeFull();
    questDescriptionRawRuArea.setRows(4);
    questDescriptionRawRuArea.setReadOnly(true);
    descriptionLayout.addComponents(questDescriptionEnArea, questDescriptionRuArea, questDescriptionRawEnArea,
            questDescriptionRawRuArea);
    descriptionHLayout.addComponent(descriptionLayout);
    descriptionTranslateLayout = new VerticalLayout();
    descriptionTranslateLayout.setSizeFull();
    descriptionTranslateLayout.setSpacing(false);
    descriptionTranslateLayout.setMargin(false);
    descriptionHLayout.addComponent(descriptionTranslateLayout);
    infoLayout.addComponent(descriptionHLayout);
    tabSheet.addTab(infoLayout, "?");
    stepsLayout = new VerticalLayout();
    stepsLayout.setSizeFull();
    stepsLayout.setSpacing(false);
    stepsLayout.setMargin(false);
    stepsData = new TreeData();
    stepsGrid = new TreeGrid(new TreeDataProvider(stepsData));
    stepsGrid.setSelectionMode(Grid.SelectionMode.NONE);
    stepsGrid.setRowHeight(250);
    stepsGrid.setHeaderVisible(false);
    stepsGrid.setSizeFull();
    stepsGrid.setItemCollapseAllowedProvider(new ItemCollapseAllowedProvider() {
        @Override
        public boolean test(Object item) {
            return false;
        }
    });
    stepsGrid.addColumn(new ValueProvider() {
        @Override
        public Object apply(Object source) {
            if (source instanceof QuestStep) {
                return "?";
            }
            if (source instanceof QuestDirection) {
                return " - " + ((QuestDirection) source).getDirectionType().name();
            }
            return null;
        }
    }).setId("rowType").setCaption("").setWidth(132).setStyleGenerator(rowStyleGenerator);
    stepsGrid.addComponentColumn(new ValueProvider() {
        @Override
        public Object apply(Object source) {
            VerticalLayout result = new VerticalLayout();
            result.setSpacing(false);
            result.setMargin(false);
            if (source instanceof QuestStep) {

                QuestStep step = (QuestStep) source;
                if (step.getTextEn() != null && !step.getTextEn().isEmpty()) {
                    TextArea textEnArea = new TextArea("?  ");
                    textEnArea.setValue(step.getTextEn());
                    textEnArea.setReadOnly(true);
                    textEnArea.setWidth(100f, Unit.PERCENTAGE);
                    result.addComponent(textEnArea);
                }
                if (step.getTextRu() != null && !step.getTextRu().isEmpty()) {
                    TextArea textRuArea = new TextArea("  ");
                    textRuArea.setValue(step.getTextRu());
                    textRuArea.setReadOnly(true);
                    textRuArea.setWidth(100f, Unit.PERCENTAGE);
                    result.addComponent(textRuArea);
                }
            } else if (source instanceof QuestDirection) {
                QuestDirection d = (QuestDirection) source;
                if (d.getTextEn() != null && !d.getTextEn().isEmpty()) {
                    TextArea textEnArea = new TextArea("?  ");
                    textEnArea.setValue(d.getTextEn());
                    textEnArea.setRows(2);
                    textEnArea.setReadOnly(true);
                    textEnArea.setWidth(100f, Unit.PERCENTAGE);
                    result.addComponent(textEnArea);
                }
                if (d.getTextRu() != null && !d.getTextRu().isEmpty()) {
                    TextArea textRuArea = new TextArea("  ");
                    textRuArea.setValue(d.getTextRu());
                    textRuArea.setRows(2);
                    textRuArea.setReadOnly(true);
                    textRuArea.setWidth(100f, Unit.PERCENTAGE);
                    result.addComponent(textRuArea);
                }

            }
            return result;
        }
    }).setId("ingameText").setStyleGenerator(rowStyleGenerator);
    stepsGrid.addComponentColumn(new ValueProvider() {
        @Override
        public Object apply(Object source) {
            VerticalLayout result = new VerticalLayout();
            result.setSpacing(false);
            result.setMargin(false);
            if (source instanceof QuestStep) {

                QuestStep step = (QuestStep) source;
                if (step.getSheetsJournalEntry() != null) {
                    TextArea textEnRawArea = new TextArea("?  ");
                    textEnRawArea.setValue(step.getSheetsJournalEntry().getTextEn());
                    textEnRawArea.setReadOnly(true);
                    textEnRawArea.setWidth(100f, Unit.PERCENTAGE);
                    result.addComponent(textEnRawArea);
                    if (step.getSheetsJournalEntry().getTextRu() != null && !step.getSheetsJournalEntry()
                            .getTextRu().equals(step.getSheetsJournalEntry().getTextEn())) {
                        TextArea textRuRawArea = new TextArea("    "
                                + step.getSheetsJournalEntry().getTranslator());
                        textRuRawArea.setValue(step.getSheetsJournalEntry().getTextRu());
                        textRuRawArea.setReadOnly(true);
                        textRuRawArea.setWidth(100f, Unit.PERCENTAGE);
                        result.addComponent(textRuRawArea);//, "  " 
                    }
                }

            } else if (source instanceof QuestDirection) {
                QuestDirection d = (QuestDirection) source;
                if (d.getSheetsQuestDirection() != null) {
                    TextArea textEnRawArea = new TextArea("?  ");
                    textEnRawArea.setValue(d.getSheetsQuestDirection().getTextEn());
                    textEnRawArea.setRows(2);
                    textEnRawArea.setReadOnly(true);
                    textEnRawArea.setWidth(100f, Unit.PERCENTAGE);
                    result.addComponent(textEnRawArea);
                    if (d.getSheetsQuestDirection().getTextRu() != null && !d.getSheetsQuestDirection()
                            .getTextRu().equals(d.getSheetsQuestDirection().getTextEn())) {
                        TextArea textRuRawArea = new TextArea("    "
                                + d.getSheetsQuestDirection().getTranslator());
                        textRuRawArea.setValue(d.getSheetsQuestDirection().getTextRu());
                        textRuRawArea.setRows(2);
                        textRuRawArea.setReadOnly(true);
                        textRuRawArea.setWidth(100f, Unit.PERCENTAGE);
                        result.addComponent(textRuRawArea);
                    }
                }
            }
            return result;
        }
    }).setId("rawText").setStyleGenerator(rowStyleGenerator);
    stepsGrid.addComponentColumn(new ValueProvider() {
        @Override
        public Object apply(Object source) {
            Panel panel = new Panel();
            panel.addStyleName(ValoTheme.PANEL_BORDERLESS);
            panel.setWidth(100f, Unit.PERCENTAGE);
            panel.setHeight(245f, Unit.PIXELS);
            final VerticalLayout result = new VerticalLayout();
            result.setSpacing(false);
            result.setMargin(false);
            if (source instanceof QuestStep) {

                Set<TranslatedText> list = new HashSet<>();
                List<SysAccount> accounts = new ArrayList<>();

                QuestStep step = (QuestStep) source;
                list.addAll(step.getSheetsJournalEntry().getTranslatedTexts());

                if (list != null) {
                    for (TranslatedText t : list) {
                        result.addComponent(new TranslationCell(t));
                        accounts.add(t.getAuthor());
                    }
                }
                if (!accounts.contains(SpringSecurityHelper.getSysAccount())
                        && step.getSheetsJournalEntry() != null
                        && SpringSecurityHelper.hasRole("ROLE_TRANSLATE")) {
                    final TranslatedText translatedText = new TranslatedText();
                    translatedText.setAuthor(SpringSecurityHelper.getSysAccount());
                    translatedText.setSpreadSheetsJournalEntry(step.getSheetsJournalEntry());
                    Button addTranslation = new Button(" ",
                            FontAwesome.PLUS_SQUARE);
                    addTranslation.addClickListener(new Button.ClickListener() {

                        @Override
                        public void buttonClick(Button.ClickEvent event) {

                            if (translatedText.getSpreadSheetsJournalEntry() != null) {
                                translatedText.getSpreadSheetsJournalEntry().getTranslatedTexts()
                                        .add(translatedText);
                            }
                            result.addComponent(new TranslationCell(translatedText));
                            event.getButton().setVisible(false);
                        }
                    });
                    result.addComponent(addTranslation);
                }
            } else if (source instanceof QuestDirection) {
                Set<TranslatedText> list = new HashSet<>();
                List<SysAccount> accounts = new ArrayList<>();

                QuestDirection d = (QuestDirection) source;
                list.addAll(d.getSheetsQuestDirection().getTranslatedTexts());

                if (list != null) {
                    for (TranslatedText t : list) {
                        result.addComponent(new TranslationCell(t));
                        accounts.add(t.getAuthor());
                    }
                }
                if (!accounts.contains(SpringSecurityHelper.getSysAccount())
                        && d.getSheetsQuestDirection() != null
                        && SpringSecurityHelper.hasRole("ROLE_TRANSLATE")) {
                    final TranslatedText translatedText = new TranslatedText();
                    translatedText.setAuthor(SpringSecurityHelper.getSysAccount());
                    translatedText.setSpreadSheetsQuestDirection(d.getSheetsQuestDirection());
                    Button addTranslation = new Button(" ");
                    addTranslation.addClickListener(new Button.ClickListener() {

                        @Override
                        public void buttonClick(Button.ClickEvent event) {

                            if (translatedText.getSpreadSheetsQuestDirection() != null) {
                                translatedText.getSpreadSheetsQuestDirection().getTranslatedTexts()
                                        .add(translatedText);
                            }
                            result.addComponent(new TranslationCell(translatedText));
                            event.getButton().setVisible(false);
                        }
                    });
                    result.addComponent(addTranslation);
                }
            }
            panel.setContent(result);
            return panel;
        }
    }).setId("translation").setStyleGenerator(rowStyleGenerator);
    stepsGrid.setColumns("rowType", "ingameText", "rawText", "translation");
    stepsLayout.addComponent(stepsGrid);
    tabSheet.addTab(stepsLayout, "");
    itemsGrid = new Grid(new ListDataProvider(itemList));
    itemsGrid.setSelectionMode(Grid.SelectionMode.NONE);
    itemsGrid.setRowHeight(250);
    itemsGrid.setHeaderVisible(false);
    itemsGrid.setSizeFull();
    itemsGrid.addComponentColumn(new ValueProvider() {
        @Override
        public Object apply(Object source) {
            VerticalLayout result = new VerticalLayout();
            result.setSpacing(false);
            result.setMargin(false);
            if (source instanceof QuestItem) {

                QuestItem item = (QuestItem) source;
                if (item.getName() != null) {
                    TextArea textEnRawArea = new TextArea("?  ");
                    textEnRawArea.setValue(item.getName().getTextEn());
                    textEnRawArea.setReadOnly(true);
                    textEnRawArea.setWidth(100f, Unit.PERCENTAGE);
                    result.addComponent(textEnRawArea);
                    if (item.getName().getTextRu() != null
                            && !item.getName().getTextRu().equals(item.getName().getTextEn())) {
                        TextArea textRuRawArea = new TextArea(
                                " ?    "
                                        + item.getName().getTranslator());
                        textRuRawArea.setValue(item.getName().getTextRu());
                        textRuRawArea.setReadOnly(true);
                        textRuRawArea.setWidth(100f, Unit.PERCENTAGE);
                        result.addComponent(textRuRawArea);//, "  " 
                    }
                }

            }
            return result;
        }
    }).setId("rawName");
    itemsGrid.addComponentColumn(new ValueProvider() {
        @Override
        public Object apply(Object source) {
            VerticalLayout result = new VerticalLayout();
            result.setSpacing(false);
            result.setMargin(false);
            if (source instanceof QuestItem) {

                QuestItem item = (QuestItem) source;
                if (item.getDescription() != null) {
                    TextArea textEnRawArea = new TextArea("?  ");
                    textEnRawArea.setValue(item.getDescription().getTextEn());
                    textEnRawArea.setReadOnly(true);
                    textEnRawArea.setWidth(100f, Unit.PERCENTAGE);
                    result.addComponent(textEnRawArea);
                    if (item.getDescription().getTextRu() != null
                            && !item.getDescription().getTextRu().equals(item.getDescription().getTextEn())) {
                        TextArea textRuRawArea = new TextArea(
                                " ??    "
                                        + item.getDescription().getTranslator());
                        textRuRawArea.setValue(item.getDescription().getTextRu());
                        textRuRawArea.setReadOnly(true);
                        textRuRawArea.setWidth(100f, Unit.PERCENTAGE);
                        result.addComponent(textRuRawArea);//, "  " 
                    }
                }

            }
            return result;
        }
    }).setId("rawDescription");
    itemsGrid.addComponentColumn(new ValueProvider() {
        @Override
        public Object apply(Object source) {
            Panel panel = new Panel();
            panel.addStyleName(ValoTheme.PANEL_BORDERLESS);
            panel.setWidth(100f, Unit.PERCENTAGE);
            panel.setHeight(245f, Unit.PIXELS);
            final VerticalLayout result = new VerticalLayout();
            result.setSpacing(false);
            result.setMargin(false);
            if (source instanceof QuestItem) {

                Set<TranslatedText> list = new HashSet<>();
                List<SysAccount> accounts = new ArrayList<>();

                QuestItem item = (QuestItem) source;
                if (item.getName() != null) {
                    String text = item.getName().getTextEn();
                    list.addAll(item.getName().getTranslatedTexts());

                    if (list != null) {
                        for (TranslatedText t : list) {
                            result.addComponent(new TranslationCell(t));
                            accounts.add(t.getAuthor());
                        }
                    }
                    if (!accounts.contains(SpringSecurityHelper.getSysAccount()) && text != null
                            && !text.isEmpty() && SpringSecurityHelper.hasRole("ROLE_TRANSLATE")) {
                        final TranslatedText translatedText = new TranslatedText();
                        translatedText.setAuthor(SpringSecurityHelper.getSysAccount());
                        translatedText.setSpreadSheetsItemName(item.getName());
                        Button addTranslation = new Button(" ",
                                FontAwesome.PLUS_SQUARE);
                        addTranslation.addClickListener(new Button.ClickListener() {

                            @Override
                            public void buttonClick(Button.ClickEvent event) {

                                if (translatedText.getSpreadSheetsItemName() != null) {
                                    translatedText.getSpreadSheetsItemName().getTranslatedTexts()
                                            .add(translatedText);
                                }
                                result.addComponent(new TranslationCell(translatedText));
                                event.getButton().setVisible(false);
                            }
                        });
                        result.addComponent(addTranslation);
                    }
                }
            }
            panel.setContent(result);
            return panel;
        }
    }).setId("nameTranslation");
    itemsGrid.addComponentColumn(new ValueProvider() {
        @Override
        public Object apply(Object source) {
            Panel panel = new Panel();
            panel.addStyleName(ValoTheme.PANEL_BORDERLESS);
            panel.setWidth(100f, Unit.PERCENTAGE);
            panel.setHeight(245f, Unit.PIXELS);
            final VerticalLayout result = new VerticalLayout();
            result.setSpacing(false);
            result.setMargin(false);
            if (source instanceof QuestItem) {

                Set<TranslatedText> list = new HashSet<>();
                List<SysAccount> accounts = new ArrayList<>();

                QuestItem item = (QuestItem) source;
                if (item.getDescription() != null) {
                    String text = item.getDescription().getTextEn();
                    list.addAll(item.getDescription().getTranslatedTexts());

                    if (list != null) {
                        for (TranslatedText t : list) {
                            result.addComponent(new TranslationCell(t));
                            accounts.add(t.getAuthor());
                        }
                    }
                    if (!accounts.contains(SpringSecurityHelper.getSysAccount()) && text != null
                            && !text.isEmpty() && SpringSecurityHelper.hasRole("ROLE_TRANSLATE")) {
                        final TranslatedText translatedText = new TranslatedText();
                        translatedText.setAuthor(SpringSecurityHelper.getSysAccount());
                        translatedText.setSpreadSheetsItemDescription(item.getDescription());
                        Button addTranslation = new Button(" ",
                                FontAwesome.PLUS_SQUARE);
                        addTranslation.addClickListener(new Button.ClickListener() {

                            @Override
                            public void buttonClick(Button.ClickEvent event) {

                                if (translatedText.getSpreadSheetsItemDescription() != null) {
                                    translatedText.getSpreadSheetsItemDescription().getTranslatedTexts()
                                            .add(translatedText);
                                }
                                result.addComponent(new TranslationCell(translatedText));
                                event.getButton().setVisible(false);
                            }
                        });
                        result.addComponent(addTranslation);
                    }
                }
            }
            panel.setContent(result);
            return panel;
        }
    }).setId("descriptionTranslation");
    itemsGrid.addComponentColumn(new ValueProvider() {
        @Override
        public Object apply(Object source) {
            VerticalLayout result = new VerticalLayout();
            result.setMargin(new MarginInfo(true, false, false, false));
            result.setSpacing(false);
            if (source instanceof QuestItem) {
                GSpreadSheetsItemName name = ((QuestItem) source).getName();
                if (name.getIcon() != null) {
                    Image image = new Image(null, new ExternalResource(
                            "https://elderscrolls.net" + name.getIcon().replaceAll(".dds", ".png")));
                    result.addComponent(image);
                    return result;
                }
            }
            return result;
        }
    }).setId("icon").setWidth(95);
    itemsGrid.setColumns("icon", "rawName", "nameTranslation", "rawDescription", "descriptionTranslation");
    tabSheet.addTab(itemsGrid, "");
    this.addComponent(tabSheet);
    this.setExpandRatio(tabSheet, 1f);
    GridScrollExtension stepsScrollExtension = new GridScrollExtension(stepsGrid);
    GridScrollExtension itemsScrollExtension = new GridScrollExtension(itemsGrid);
    new NoAutcompleteComboBoxExtension(locationTable);
    new NoAutcompleteComboBoxExtension(questTable);
    new NoAutcompleteComboBoxExtension(translatorBox);
    LoadFilters();
}

From source file:org.esn.esobase.view.tab.TranslateTab.java

public void Init() {
    removeAllComponents();/*from w w w  . j a  va  2s . c o m*/
    TopicNpcColumnGenerator topicNpcColumnGenerator = new TopicNpcColumnGenerator();
    TopicPlayerColumnGenerator topicPlayerColumnGenerator = new TopicPlayerColumnGenerator();
    SubtitleColumnGenerator subtitleColumnGenerator = new SubtitleColumnGenerator();
    TranslationColumnGenerator translationColumnGenerator = new TranslationColumnGenerator();
    FilterChangeListener filterChangeListener = new FilterChangeListener();
    this.setSizeFull();
    this.setSpacing(false);
    this.setMargin(false);
    npcListlayout = new HorizontalLayout();
    npcListlayout.setSpacing(false);
    npcListlayout.setMargin(false);
    npcListlayout.setSizeFull();
    npcTable = new ComboBox("NPC");
    npcTable.setPageLength(30);
    npcTable.setScrollToSelectedItem(true);
    npcTable.setWidth(100f, Unit.PERCENTAGE);
    npcTable.addValueChangeListener(new NpcSelectListener());
    npcTable.setScrollToSelectedItem(true);
    npcTable.setEmptySelectionAllowed(true);
    locationTable = new ComboBox("?");
    locationTable.setPageLength(30);
    locationTable.setScrollToSelectedItem(true);
    locationTable.setWidth(100f, Unit.PERCENTAGE);
    locationTable.addValueChangeListener(filterChangeListener);
    locationTable.setDataProvider(new ListDataProvider<>(locations));
    locationTable.setEmptySelectionAllowed(true);

    subLocationTable = new ComboBox("?");
    subLocationTable.setPageLength(30);
    subLocationTable.setScrollToSelectedItem(true);
    subLocationTable.setWidth(100f, Unit.PERCENTAGE);
    subLocationTable.addValueChangeListener(filterChangeListener);
    subLocationTable.setDataProvider(new ListDataProvider<>(subLocations));
    subLocationTable.setEmptySelectionAllowed(true);
    questTable = new ComboBox("?");
    questTable.setPageLength(30);
    questTable.setScrollToSelectedItem(true);

    questTable.setWidth(100f, Unit.PERCENTAGE);
    questTable.addValueChangeListener(filterChangeListener);
    questTable.setDataProvider(new ListDataProvider<>(questList));
    npcTable.setDataProvider(new ListDataProvider<>(npcList));

    FormLayout locationAndNpc = new FormLayout(questTable, locationTable, subLocationTable, npcTable);
    locationAndNpc.addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    locationAndNpc.setSizeFull();

    npcListlayout.addComponent(locationAndNpc);

    translateStatus = new ComboBoxMultiselect("? ",
            Arrays.asList(TRANSLATE_STATUS.values()));
    translateStatus.setClearButtonCaption("?");
    translateStatus.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            LoadFilters();
            LoadNpcContent();
        }
    });
    translateStatus.setPageLength(20);
    noTranslations = new CheckBox("?  ?");
    noTranslations.setValue(Boolean.FALSE);
    noTranslations.addValueChangeListener(new HasValue.ValueChangeListener<Boolean>() {
        @Override
        public void valueChange(HasValue.ValueChangeEvent<Boolean> event) {
            LoadFilters();
            LoadNpcContent();
        }
    });

    emptyTranslations = new CheckBox("?  ");
    emptyTranslations.setValue(Boolean.FALSE);
    emptyTranslations.addValueChangeListener(new HasValue.ValueChangeListener<Boolean>() {
        @Override
        public void valueChange(HasValue.ValueChangeEvent<Boolean> event) {
            LoadFilters();
            LoadNpcContent();
        }
    });
    HorizontalLayout checkBoxlayout = new HorizontalLayout(noTranslations, emptyTranslations);
    translatorBox = new ComboBox("");
    translatorBox.setPageLength(15);
    translatorBox.setScrollToSelectedItem(true);
    translatorBox.setDataProvider(new ListDataProvider(service.getSysAccounts()));
    translatorBox.addValueChangeListener(new HasValue.ValueChangeListener() {
        @Override
        public void valueChange(HasValue.ValueChangeEvent event) {
            LoadFilters();
            LoadNpcContent();
        }
    });
    refreshButton = new Button("");
    refreshButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            LoadFilters();
            LoadNpcContent();
        }
    });
    countLabel = new Label();
    searchField = new TextField("?? ?");
    searchField.setSizeFull();
    searchField.addValueChangeListener(new HasValue.ValueChangeListener<String>() {
        @Override
        public void valueChange(HasValue.ValueChangeEvent<String> event) {
            LoadFilters();
            LoadNpcContent();
        }
    });

    FormLayout questAndWithNewTranslations = new FormLayout(translateStatus, translatorBox, checkBoxlayout,
            searchField);
    questAndWithNewTranslations.addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    questAndWithNewTranslations.setSizeFull();
    npcListlayout.addComponent(questAndWithNewTranslations);
    npcListlayout.addComponent(refreshButton);
    npcListlayout.addComponent(countLabel);
    npcListlayout.setExpandRatio(locationAndNpc, 0.4f);
    npcListlayout.setExpandRatio(questAndWithNewTranslations, 0.4f);
    npcListlayout.setExpandRatio(refreshButton, 0.1f);
    npcListlayout.setExpandRatio(countLabel, 0.1f);
    npcContentLayout = new VerticalLayout();
    npcContentLayout.setSizeFull();
    npcContentLayout.setSpacing(false);
    npcContentLayout.setMargin(false);
    npcTabSheet = new TabSheet();
    npcTabSheet.setSizeFull();
    npcTabLayout = new VerticalLayout();
    locationName = new TextField("? ");
    npcTabLayout.addComponent(locationName);
    locationNameRu = new TextField(" ? ");
    npcTabLayout.addComponent(locationNameRu);
    npcName = new TextField("? NPC");
    npcTabLayout.addComponent(npcName);
    npcNameRu = new TextField("  NPC");
    npcTabLayout.addComponent(npcNameRu);
    npcTab = npcTabSheet.addTab(npcTabLayout, "");
    npcTopicsTable = new Table();
    npcTopicsTable.addStyleName(ValoTheme.TABLE_COMPACT);
    npcTopicsTable.setSizeFull();
    npcTopicsTable.setPageLength(0);
    topicsContainer = new BeanItemContainer<>(Topic.class);
    npcTopicsTable.setContainerDataSource(topicsContainer);
    npcTopicsTable.addGeneratedColumn("npcTextG", topicNpcColumnGenerator);
    npcTopicsTable.addGeneratedColumn("playerTextG", topicPlayerColumnGenerator);
    npcTopicsTable.removeGeneratedColumn("playerTranslations");
    npcTopicsTable.addGeneratedColumn("playerTranslations", translationColumnGenerator);
    npcTopicsTable.removeGeneratedColumn("npcTranslations");
    npcTopicsTable.addGeneratedColumn("npcTranslations", translationColumnGenerator);
    npcTopicsTable.setVisibleColumns(
            new Object[] { "playerTextG", "playerTranslations", "npcTextG", "npcTranslations" });
    npcTopicsTable.setColumnHeaders(new String[] { " ", "",
            " NPC", "" });
    npcTopicsTable.setColumnExpandRatio("playerTextG", 1f);
    npcTopicsTable.setColumnExpandRatio("playerTranslations", 1.5f);
    npcTopicsTable.setColumnExpandRatio("npcTextG", 1.5f);
    npcTopicsTable.setColumnExpandRatio("npcTranslations", 1.5f);
    npcTopicsTable.setColumnWidth("actions", 150);
    npcSubtitlesTable = new Table();
    npcSubtitlesTable.addStyleName(ValoTheme.TABLE_COMPACT);
    npcSubtitlesTable.setSizeFull();
    npcSubtitlesTable.setPageLength(0);
    subtitlesContainer = new BeanItemContainer<>(Subtitle.class);
    npcSubtitlesTable.setContainerDataSource(subtitlesContainer);
    npcSubtitlesTable.addGeneratedColumn("textG", subtitleColumnGenerator);
    npcSubtitlesTable.removeGeneratedColumn("translations");
    npcSubtitlesTable.addGeneratedColumn("translations", translationColumnGenerator);
    npcSubtitlesTable.setVisibleColumns(new Object[] { "textG", "translations" });
    npcSubtitlesTable.setColumnHeaders(new String[] { "", "" });
    npcSubtitlesTable.setColumnExpandRatio("textG", 1f);
    npcSubtitlesTable.setColumnExpandRatio("translations", 1f);
    npcSubtitlesTable.setColumnWidth("actions", 150);

    npcTopicsTab = npcTabSheet.addTab(npcTopicsTable, "");
    npcSubtitlesTab = npcTabSheet.addTab(npcSubtitlesTable, "");
    npcContentLayout.addComponent(npcTabSheet);
    this.addComponent(npcListlayout);
    this.addComponent(npcContentLayout);
    this.npcListlayout.setHeight(105f, Unit.PIXELS);
    this.setExpandRatio(npcContentLayout, 1f);
    LoadFilters();
    new NoAutcompleteComboBoxExtension(questTable);
    new NoAutcompleteComboBoxExtension(locationTable);
    new NoAutcompleteComboBoxExtension(subLocationTable);
    new NoAutcompleteComboBoxExtension(npcTable);
    new NoAutcompleteComboBoxExtension(translatorBox);
}