Example usage for com.vaadin.v7.ui HorizontalLayout HorizontalLayout

List of usage examples for com.vaadin.v7.ui HorizontalLayout HorizontalLayout

Introduction

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

Prototype

public HorizontalLayout() 

Source Link

Document

Constructs an empty HorizontalLayout.

Usage

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);/*w w w .  j  av a2  s.  co m*/
    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.QuestsTab.java

public QuestsTab(DBService service) {
    this.service = service;
    actions = new HorizontalLayout();
    refreshButton = new Button("");
    refreshButton.addClickListener(new Button.ClickListener() {

        @Override//from   w  w  w.j  av a 2 s .co  m
        public void buttonClick(Button.ClickEvent event) {
            LoadTable();
            CloseForm();
        }
    });
    actions.addComponent(refreshButton);
    addButton = new Button("");
    addButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            AddItem();
        }
    });
    actions.addComponent(addButton);
    this.addComponent(actions);
    tableAndForm = new HorizontalLayout();
    tableAndForm.setSizeFull();
    table = new Table();
    table.setSizeFull();
    container = new BeanItemContainer<>(Quest.class);
    table.setContainerDataSource(container);

    table.setVisibleColumns(new Object[] { "name", "nameRu", "progress" });
    table.setColumnHeaders(new String[] { "?", " ?",
            "? " });
    table.setConverter("progress", new Converter<String, BigDecimal>() {

        @Override
        public BigDecimal convertToModel(String value, Class<? extends BigDecimal> targetType, Locale locale)
                throws Converter.ConversionException {
            return null;
        }

        @Override
        public String convertToPresentation(BigDecimal value, Class<? extends String> targetType, Locale locale)
                throws Converter.ConversionException {
            String r = "";
            if (value != null) {
                r = value.multiply(BigDecimal.valueOf(100L).setScale(2, RoundingMode.HALF_DOWN))
                        .setScale(0, RoundingMode.HALF_UP).toString() + "%";
            }
            return r;
        }

        @Override
        public Class<BigDecimal> getModelType() {
            return BigDecimal.class;
        }

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

    });
    table.addItemClickListener(new TableClickListener());
    LoadTable();
    table.sort(new Object[] { "name" }, new boolean[] { true });
    tableAndForm.addComponent(table);
    tableAndForm.setExpandRatio(table, 0.2f);
    form = new FormLayout();
    form.setSizeFull();
    name = new TextField("?");
    name.setNullRepresentation("");
    name.setRequired(true);
    form.addComponent(name);
    nameRu = new TextField(" ?");
    nameRu.setNullRepresentation("");
    nameRu.setRequired(false);
    form.addComponent(nameRu);

    npcs = new TwinColSelect("NPC");
    npcsContainer = new BeanItemContainer<>(Npc.class);
    npcsContainer = service.loadBeanItems(npcsContainer);
    npcsContainer.sort(new Object[] { "name" }, new boolean[] { true });
    npcsContainer.addNestedContainerProperty("location.name");
    npcsContainer.addNestedContainerProperty("location.nameRu");
    npcs.setContainerDataSource(npcsContainer);
    npcs.setWidth(900f, Unit.PIXELS);
    Page.Styles styles = Page.getCurrent().getStyles();
    styles.add(".v-font-size {\n" + "    font-size: 11px;\n" + "}");
    npcs.addStyleName("v-font-size");
    npcFilter = new TextField(" ?? NPC");
    npcFilter.setNullRepresentation("");
    npcFilter.setImmediate(true);
    npcFilter.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.TIMEOUT);
    npcFilter.setTextChangeTimeout(500);
    npcFilter.addTextChangeListener(new FieldEvents.TextChangeListener() {

        @Override
        public void textChange(FieldEvents.TextChangeEvent event) {
            npcsContainer.removeAllContainerFilters();
            if (event.getText() != null && !event.getText().isEmpty()) {
                try {
                    npcsContainer
                            .addContainerFilter(new Or(new Like("name", "%" + event.getText() + "%", false),
                                    new Like("nameRu", "%" + event.getText() + "%", false),
                                    new Like("location.name", "%" + event.getText() + "%", false),
                                    new Like("location.nameRu", "%" + event.getText() + "%", false)));
                } catch (UnsupportedFilterException | PatternSyntaxException ex) {

                }
            }
        }
    });
    form.addComponent(npcFilter);
    form.addComponent(npcs);
    saveButton = new Button("");
    saveButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            SaveForm();
        }
    });
    cancelButton = new Button("");
    cancelButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            CloseForm();
            LoadTable();
        }
    });
    HorizontalLayout actions = new HorizontalLayout(cancelButton, saveButton);
    form.addComponent(actions);
    form.setVisible(false);
    tableAndForm.addComponent(form);
    tableAndForm.setExpandRatio(form, 0.75f);
    this.addComponent(tableAndForm);
}

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

public SpellerTestTab(DBService service_) {
    this.service = service_;
    this.setSizeFull();
    hl = new HorizontalLayout();
    startDate = new DateField();
    startDate.setResolution(Resolution.DAY);
    endDate = new DateField();
    endDate.setResolution(Resolution.DAY);
    hl.addComponent(startDate);/*  ww  w . j  a  va  2s  .  c o m*/
    hl.addComponent(endDate);

    checkButton = new Button("");
    checkButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Date dateEndValue = null;
            if (endDate.getValue() != null) {
                Calendar cal = Calendar.getInstance();
                cal.setTime(endDate.getValue());
                cal.add(Calendar.DAY_OF_YEAR, 1);
                dateEndValue = cal.getTime();
            }
            hc = service.getTextForSpellCheck(startDate.getValue(), dateEndValue, hc);
            try {
                SpellService yservice = new SpellService();
                SpellServiceSoap port = yservice.getSpellServiceSoap12();
                List<Object> parentIds = new ArrayList<>();
                for (Object itemId : hc.getItemIds()) {
                    parentIds.add(itemId);
                }
                for (Object itemId : parentIds) {
                    CheckTextRequest parameters = new CheckTextRequest();
                    parameters.setLang("ru");
                    parameters.setText((String) hc.getItem(itemId).getItemProperty("textRu").getValue());
                    parameters.setFormat("plain");
                    parameters.setOptions(0);
                    CheckTextResponse result = port.checkText(parameters);
                    if (result != null && result.getSpellResult() != null
                            && result.getSpellResult().getError() != null) {
                        for (SpellError error : result.getSpellResult().getError()) {

                            SPELLER_ERROR e = SPELLER_ERROR.valueOf(error.getCode());
                            String word = error.getWord();
                            boolean existSpellerWord = service.isExistSpellerWord(word);
                            if (!((e == SPELLER_ERROR.ERROR_UNKNOWN_WORD) && (existSpellerWord))) {
                                Item item = hc.addItem(error);

                                item.getItemProperty("errorType").setValue(e);
                                item.getItemProperty("word").setValue(error.getWord());
                                item.getItemProperty("s").setValue(error.getS());
                                hc.setParent(error, itemId);
                                hc.setChildrenAllowed(error, false);
                            }

                        }
                    }

                    resultTable.setCollapsed(itemId, false);
                }

                excludeWithoutErrors();

            } catch (Exception ex) {
                LOG.log(Level.INFO, null, ex);
            }

        }
    });
    hl.addComponent(checkButton);
    this.addComponent(hl);
    hc = new HierarchicalContainer();
    hc.addContainerProperty("textEn", String.class, null);
    hc.addContainerProperty("textRu", String.class, null);
    hc.addContainerProperty("catalogType", String.class, null);
    hc.addContainerProperty("translator", String.class, null);
    hc.addContainerProperty("errorType", SPELLER_ERROR.class, null);
    hc.addContainerProperty("word", String.class, null);
    hc.addContainerProperty("s", List.class, null);
    resultTable = new TreeTable();
    resultTable.setContainerDataSource(hc);
    resultTable.setWidth(100f, Unit.PERCENTAGE);

    resultTable.addGeneratedColumn("actionsColumn", new Table.ColumnGenerator() {

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            if (itemId instanceof SpellError) {
                Button b = new Button("  ??");
                b.addClickListener(new WordAddClickListener(service,
                        (String) source.getItem(itemId).getItemProperty("word").getValue(),
                        (SpellError) itemId));
                return b;
            } else {
                Button b = new Button("");
                b.addClickListener(new SaveItemListener(itemId));
                return b;
            }

        }
    });
    resultTable.setVisibleColumns(new Object[] { "textEn", "textRu", "catalogType", "translator", "errorType",
            "word", "s", "actionsColumn" });
    resultTable.setColumnHeaders(new String[] { "", "", " ",
            "", " ", "", "", "" });
    Page.Styles styles = Page.getCurrent().getStyles();
    styles.add(".v-table-cell-wrapper {\n" + "    /* Do not specify any margins, paddings or borders here */\n"
            + "    white-space: normal;\n" + "    /*overflow: hidden;*/\n" + "}");
    resultTable.addStyleName("v-table-cell-wrapper");
    resultTable.setColumnExpandRatio("textEn", 3f);
    resultTable.setColumnExpandRatio("textRu", 3f);
    resultTable.setColumnExpandRatio("catalogType", 1f);
    resultTable.setColumnExpandRatio("translator", 0.7f);
    resultTable.setColumnExpandRatio("errorType", 1f);
    resultTable.setColumnExpandRatio("word", 1f);
    resultTable.setColumnExpandRatio("s", 1f);
    resultTable.setColumnExpandRatio("actionsColumn", 1.2f);
    resultTable.setConverter("s", new Converter<String, List>() {

        @Override
        public List convertToModel(String value, Class<? extends List> targetType, Locale locale)
                throws Converter.ConversionException {
            if (value != null && !value.isEmpty()) {
                String[] split = value.split("\n");
                return new ArrayList(Arrays.asList(split));
            }
            return null;
        }

        @Override
        public String convertToPresentation(List value, Class<? extends String> targetType, Locale locale)
                throws Converter.ConversionException {
            StringBuilder sb = new StringBuilder("");
            if (value != null) {
                for (int i = 0; i < value.size(); i++) {
                    sb.append(value.get(i));
                    if (i != value.size() - 1) {
                        sb.append("\n");
                    }
                }
            }

            String joined = sb.toString();
            return joined;
        }

        @Override
        public Class<List> getModelType() {
            return List.class;
        }

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

    });
    resultTable.setTableFieldFactory(new TableFieldFactory() {

        @Override
        public Field<?> createField(Container container, Object itemId, Object propertyId,
                Component uiContext) {
            Field result = null;
            if (!(itemId instanceof SpellError) && propertyId.equals("textRu")) {
                result = new TextArea();
                result.setPropertyDataSource(container.getItem(itemId).getItemProperty(propertyId));
                result.setSizeFull();
            }
            if (!(itemId instanceof SpellError) && propertyId.equals("textEn")) {
                result = new TextArea();
                result.setPropertyDataSource(container.getItem(itemId).getItemProperty(propertyId));
                result.setReadOnly(true);
                result.setSizeFull();
            }
            return result;
        }
    });
    resultTable.setEditable(true);
    this.addComponent(resultTable);
}

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

public SynchronizationTab(DBService service_) {
    this.setSizeFull();
    this.service = service_;
    TextColumnGenerator textColumnGenerator = new TextColumnGenerator();
    tabs = new TabSheet();
    playerLayout = new VerticalLayout();
    syncPlayerPhrasesActions = new HorizontalLayout();
    syncPlayerPhrasesButton = new Button("");
    syncPlayerPhrasesButton.addClickListener(new Button.ClickListener() {

        @Override//w w w .j  a v a 2 s .  c  om
        public void buttonClick(Button.ClickEvent event) {
            GoogleDocsService docsService = new GoogleDocsService();
            List<GSpreadSheetsPlayerPhrase> playerPhrases = docsService.getPlayerPhrases();
            try {
                playerPhraseDiffContainer = service.getPlayerPhrasesDiff(playerPhrases,
                        playerPhraseDiffContainer);
            } catch (OriginalTextMismatchException ex) {
                Logger.getLogger(SynchronizationTab.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
            }
        }
    });
    syncPlayerPhrasesActions.addComponent(syncPlayerPhrasesButton);
    savePlayerPhrasesButton = new Button("");
    savePlayerPhrasesButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            List<PlayerPhraseDiff> diffs = (List<PlayerPhraseDiff>) playerPhraseDiffContainer.getItemIds();
            List<GSpreadSheetsPlayerPhrase> phrasesToSh = new ArrayList<>();
            List<GSpreadSheetsPlayerPhrase> phrasesToDb = new ArrayList<>();
            for (PlayerPhraseDiff diff : diffs) {
                if (diff.getSyncType() == SYNC_TYPE.TO_SPREADSHEET) {
                    phrasesToSh.add(diff.getDbPhrase());
                } else if (diff.getSyncType() == SYNC_TYPE.TO_DB) {
                    phrasesToDb.add(diff.getSpreadsheetsPhrase());
                }
            }
            GoogleDocsService docsService = new GoogleDocsService();
            docsService.uploadPlayerPhrases(phrasesToSh);
            service.savePlayerPhrases(phrasesToDb);
            playerPhraseDiffContainer.removeAllItems();
        }
    });
    syncPlayerPhrasesActions.addComponent(savePlayerPhrasesButton);
    playerLayout.addComponent(syncPlayerPhrasesActions);
    playerPhraseDiffTable = new Table();
    playerPhraseDiffTable.setSizeFull();
    playerPhraseDiffContainer = new HierarchicalContainer();
    playerPhraseDiffContainer.addContainerProperty("shText", String.class, null);
    playerPhraseDiffContainer.addContainerProperty("shNic", String.class, null);
    playerPhraseDiffContainer.addContainerProperty("shDate", Date.class, null);
    playerPhraseDiffContainer.addContainerProperty("dbText", String.class, null);
    playerPhraseDiffContainer.addContainerProperty("dbNic", String.class, null);
    playerPhraseDiffContainer.addContainerProperty("dbDate", Date.class, null);
    playerPhraseDiffContainer.addContainerProperty("syncType", String.class, null);
    playerPhraseDiffTable.setContainerDataSource(playerPhraseDiffContainer);
    playerPhraseDiffTable.removeGeneratedColumn("shText");
    playerPhraseDiffTable.addGeneratedColumn("shText", textColumnGenerator);
    playerPhraseDiffTable.removeGeneratedColumn("dbText");
    playerPhraseDiffTable.addGeneratedColumn("dbText", textColumnGenerator);
    playerPhraseDiffTable.setVisibleColumns(columns);
    playerPhraseDiffTable.setColumnHeaders(columnHeaders);
    playerLayout.addComponent(playerPhraseDiffTable);
    tabs.addTab(playerLayout, " ");
    npcLayout = new VerticalLayout();
    syncNpcPhrasesActions = new HorizontalLayout();
    syncNpcPhrasesButton = new Button("");
    syncNpcPhrasesButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            GoogleDocsService docsService = new GoogleDocsService();
            try {
                List<GSpreadSheetsNpcPhrase> npcPhrases = docsService.getNpcPhrases();
                npcPhraseDiffContainer = service.getNpcPhrasesDiff(npcPhrases, npcPhraseDiffContainer);
            } catch (Exception ex) {
                Logger.getLogger(SynchronizationTab.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
            }
        }
    });
    syncNpcPhrasesActions.addComponent(syncNpcPhrasesButton);
    saveNpcPhrasesButton = new Button("");
    saveNpcPhrasesButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            List<NpcPhraseDiff> diffs = (List<NpcPhraseDiff>) npcPhraseDiffContainer.getItemIds();
            List<GSpreadSheetsNpcPhrase> phrasesToSh = new ArrayList<>();
            List<GSpreadSheetsNpcPhrase> phrasesToDb = new ArrayList<>();
            for (NpcPhraseDiff diff : diffs) {
                if (diff.getSyncType() == SYNC_TYPE.TO_SPREADSHEET) {
                    phrasesToSh.add(diff.getDbPhrase());
                } else if (diff.getSyncType() == SYNC_TYPE.TO_DB) {
                    phrasesToDb.add(diff.getSpreadsheetsPhrase());
                }
            }
            GoogleDocsService docsService = new GoogleDocsService();
            docsService.uploadNpcPhrases(phrasesToSh);
            service.saveNpcPhrases(phrasesToDb);
            npcPhraseDiffContainer.removeAllItems();
        }
    });
    syncNpcPhrasesActions.addComponent(saveNpcPhrasesButton);
    npcLayout.addComponent(syncNpcPhrasesActions);
    npcPhraseDiffTable = new Table();
    npcPhraseDiffTable.setSizeFull();
    npcPhraseDiffContainer = new HierarchicalContainer();
    npcPhraseDiffContainer.addContainerProperty("shText", String.class, null);
    npcPhraseDiffContainer.addContainerProperty("shNic", String.class, null);
    npcPhraseDiffContainer.addContainerProperty("shDate", Date.class, null);
    npcPhraseDiffContainer.addContainerProperty("dbText", String.class, null);
    npcPhraseDiffContainer.addContainerProperty("dbNic", String.class, null);
    npcPhraseDiffContainer.addContainerProperty("dbDate", Date.class, null);
    npcPhraseDiffContainer.addContainerProperty("syncType", String.class, null);
    npcPhraseDiffTable.setContainerDataSource(npcPhraseDiffContainer);
    npcPhraseDiffTable.removeGeneratedColumn("shText");
    npcPhraseDiffTable.addGeneratedColumn("shText", textColumnGenerator);
    npcPhraseDiffTable.removeGeneratedColumn("dbText");
    npcPhraseDiffTable.addGeneratedColumn("dbText", textColumnGenerator);
    npcPhraseDiffTable.setVisibleColumns(columns);
    npcPhraseDiffTable.setColumnHeaders(columnHeaders);
    npcLayout.addComponent(npcPhraseDiffTable);
    tabs.addTab(npcLayout, " ?");

    npcNamesLayout = new VerticalLayout();
    syncNpcNamesActions = new HorizontalLayout();
    syncNpcNamesButton = new Button("");
    syncNpcNamesButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            GoogleDocsService docsService = new GoogleDocsService();
            List<GSpreadSheetsNpcName> npcNames = docsService.getNpcNames();
            try {
                npcNamesDiffContainer = service.getNpcnamessDiff(npcNames, npcNamesDiffContainer);
            } catch (OriginalTextMismatchException ex) {
                Logger.getLogger(SynchronizationTab.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
            }
        }
    });
    syncNpcNamesActions.addComponent(syncNpcNamesButton);
    saveNpcNamesButton = new Button("");
    saveNpcNamesButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            List<NpcNameDiff> diffs = (List<NpcNameDiff>) npcNamesDiffContainer.getItemIds();
            List<GSpreadSheetsNpcName> namesToSh = new ArrayList<>();
            List<GSpreadSheetsNpcName> namesToDb = new ArrayList<>();
            for (NpcNameDiff diff : diffs) {
                if (diff.getSyncType() == SYNC_TYPE.TO_SPREADSHEET) {
                    namesToSh.add(diff.getDbName());
                } else if (diff.getSyncType() == SYNC_TYPE.TO_DB) {
                    namesToDb.add(diff.getSpreadsheetsName());
                }
            }
            GoogleDocsService docsService = new GoogleDocsService();
            docsService.uploadNpcNames(namesToSh);
            service.saveNpcnames(namesToDb);
            npcNamesDiffContainer.removeAllItems();
        }
    });
    syncNpcNamesActions.addComponent(saveNpcNamesButton);
    npcNamesLayout.addComponent(syncNpcNamesActions);
    npcNamesDiffTable = new Table();
    npcNamesDiffTable.setSizeFull();
    npcNamesDiffContainer = new HierarchicalContainer();
    npcNamesDiffContainer.addContainerProperty("shText", String.class, null);
    npcNamesDiffContainer.addContainerProperty("shNic", String.class, null);
    npcNamesDiffContainer.addContainerProperty("shDate", Date.class, null);
    npcNamesDiffContainer.addContainerProperty("dbText", String.class, null);
    npcNamesDiffContainer.addContainerProperty("dbNic", String.class, null);
    npcNamesDiffContainer.addContainerProperty("dbDate", Date.class, null);
    npcNamesDiffContainer.addContainerProperty("syncType", String.class, null);
    npcNamesDiffTable.setContainerDataSource(npcNamesDiffContainer);
    npcNamesDiffTable.removeGeneratedColumn("shText");
    npcNamesDiffTable.addGeneratedColumn("shText", textColumnGenerator);
    npcNamesDiffTable.removeGeneratedColumn("dbText");
    npcNamesDiffTable.addGeneratedColumn("dbText", textColumnGenerator);
    npcNamesDiffTable.setVisibleColumns(columns);
    npcNamesDiffTable.setColumnHeaders(columnHeaders);
    npcNamesLayout.addComponent(npcNamesDiffTable);
    tabs.addTab(npcNamesLayout, " ?");

    locationsLayout = new VerticalLayout();
    syncLocationsActions = new HorizontalLayout();
    syncLocationsButton = new Button("");
    syncLocationsButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            GoogleDocsService docsService = new GoogleDocsService();
            List<GSpreadSheetsLocationName> locationNames = docsService.getLocationsNames();
            try {
                locationsDiffContainer = service.getLocationNamesDiff(locationNames, locationsDiffContainer);
            } catch (OriginalTextMismatchException ex) {
                Logger.getLogger(SynchronizationTab.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
            }
        }
    });
    syncLocationsActions.addComponent(syncLocationsButton);
    saveLocationsButton = new Button("");
    saveLocationsButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            List<LocationsDiff> diffs = (List<LocationsDiff>) locationsDiffContainer.getItemIds();
            List<GSpreadSheetsLocationName> namesToSh = new ArrayList<>();
            List<GSpreadSheetsLocationName> namesToDb = new ArrayList<>();
            for (LocationsDiff diff : diffs) {
                if (diff.getSyncType() == SYNC_TYPE.TO_SPREADSHEET) {
                    namesToSh.add(diff.getDbName());
                } else if (diff.getSyncType() == SYNC_TYPE.TO_DB) {
                    namesToDb.add(diff.getSpreadsheetsName());
                }
            }
            GoogleDocsService docsService = new GoogleDocsService();
            docsService.uploadLocationNames(namesToSh);
            service.saveLocationNames(namesToDb);
            locationsDiffContainer.removeAllItems();
        }
    });
    syncLocationsActions.addComponent(saveLocationsButton);
    locationsLayout.addComponent(syncLocationsActions);
    locationsDiffTable = new Table();
    locationsDiffTable.setSizeFull();
    locationsDiffContainer = new HierarchicalContainer();
    locationsDiffContainer.addContainerProperty("shText", String.class, null);
    locationsDiffContainer.addContainerProperty("shNic", String.class, null);
    locationsDiffContainer.addContainerProperty("shDate", Date.class, null);
    locationsDiffContainer.addContainerProperty("dbText", String.class, null);
    locationsDiffContainer.addContainerProperty("dbNic", String.class, null);
    locationsDiffContainer.addContainerProperty("dbDate", Date.class, null);
    locationsDiffContainer.addContainerProperty("syncType", String.class, null);
    locationsDiffTable.setContainerDataSource(locationsDiffContainer);
    locationsDiffTable.removeGeneratedColumn("shText");
    locationsDiffTable.addGeneratedColumn("shText", textColumnGenerator);
    locationsDiffTable.removeGeneratedColumn("dbText");
    locationsDiffTable.addGeneratedColumn("dbText", textColumnGenerator);
    locationsDiffTable.setVisibleColumns(columns);
    locationsDiffTable.setColumnHeaders(columnHeaders);
    locationsLayout.addComponent(locationsDiffTable);
    tabs.addTab(locationsLayout, "?? ");

    questNamesLayout = new VerticalLayout();
    syncQuestNamesActions = new HorizontalLayout();
    syncQuestNamesButton = new Button("");
    syncQuestNamesButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            GoogleDocsService docsService = new GoogleDocsService();
            List<GSpreadSheetsQuestName> items = docsService.getQuestNames();
            try {
                questNamesDiffContainer = service.getQuestNamesDiff(items, questNamesDiffContainer);
            } catch (OriginalTextMismatchException ex) {
                Logger.getLogger(SynchronizationTab.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
            }
        }
    });
    syncQuestNamesActions.addComponent(syncQuestNamesButton);
    saveQuestNamesButton = new Button("");
    saveQuestNamesButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            List<QuestNamesDiff> diffs = (List<QuestNamesDiff>) questNamesDiffContainer.getItemIds();
            List<GSpreadSheetsQuestName> itemsToSh = new ArrayList<>();
            List<GSpreadSheetsQuestName> itemsToDb = new ArrayList<>();
            for (QuestNamesDiff diff : diffs) {
                if (diff.getSyncType() == SYNC_TYPE.TO_SPREADSHEET) {
                    itemsToSh.add(diff.getDbName());
                } else if (diff.getSyncType() == SYNC_TYPE.TO_DB) {
                    itemsToDb.add(diff.getSpreadsheetsName());
                }
            }
            GoogleDocsService docsService = new GoogleDocsService();
            docsService.uploadQuestNames(itemsToSh);
            service.saveQuestNames(itemsToDb);
            questNamesDiffContainer.removeAllItems();
        }
    });
    syncQuestNamesActions.addComponent(saveQuestNamesButton);
    questNamesLayout.addComponent(syncQuestNamesActions);
    questNamesDiffTable = new Table();
    questNamesDiffTable.setSizeFull();
    questNamesDiffContainer = new HierarchicalContainer();
    questNamesDiffContainer.addContainerProperty("shText", String.class, null);
    questNamesDiffContainer.addContainerProperty("shNic", String.class, null);
    questNamesDiffContainer.addContainerProperty("shDate", Date.class, null);
    questNamesDiffContainer.addContainerProperty("dbText", String.class, null);
    questNamesDiffContainer.addContainerProperty("dbNic", String.class, null);
    questNamesDiffContainer.addContainerProperty("dbDate", Date.class, null);
    questNamesDiffContainer.addContainerProperty("syncType", String.class, null);
    questNamesDiffTable.setContainerDataSource(questNamesDiffContainer);
    questNamesDiffTable.removeGeneratedColumn("shText");
    questNamesDiffTable.addGeneratedColumn("shText", textColumnGenerator);
    questNamesDiffTable.removeGeneratedColumn("dbText");
    questNamesDiffTable.addGeneratedColumn("dbText", textColumnGenerator);
    questNamesDiffTable.setVisibleColumns(columns);
    questNamesDiffTable.setColumnHeaders(columnHeaders);
    questNamesLayout.addComponent(questNamesDiffTable);
    tabs.addTab(questNamesLayout, "?? ?");

    questDescriptionsLayout = new VerticalLayout();
    syncQuestDescriptionsActions = new HorizontalLayout();
    syncQuestDescriptionsButton = new Button("");
    syncQuestDescriptionsButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            GoogleDocsService docsService = new GoogleDocsService();
            List<GSpreadSheetsQuestDescription> items = docsService.getQuestDescriptions();
            try {
                questDescriptionsDiffContainer = service.getQuestDescriptionsDiff(items,
                        questDescriptionsDiffContainer);
            } catch (OriginalTextMismatchException ex) {
                Logger.getLogger(SynchronizationTab.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
            }
        }
    });
    syncQuestDescriptionsActions.addComponent(syncQuestDescriptionsButton);
    saveQuestDescriptionsButton = new Button("");
    saveQuestDescriptionsButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            List<QuestDescriptionsDiff> diffs = (List<QuestDescriptionsDiff>) questDescriptionsDiffContainer
                    .getItemIds();
            List<GSpreadSheetsQuestDescription> itemsToSh = new ArrayList<>();
            List<GSpreadSheetsQuestDescription> itemsToDb = new ArrayList<>();
            for (QuestDescriptionsDiff diff : diffs) {
                if (diff.getSyncType() == SYNC_TYPE.TO_SPREADSHEET) {
                    itemsToSh.add(diff.getDbName());
                } else if (diff.getSyncType() == SYNC_TYPE.TO_DB) {
                    itemsToDb.add(diff.getSpreadsheetsName());
                }
            }
            GoogleDocsService docsService = new GoogleDocsService();
            docsService.uploadQuestDescriptions(itemsToSh);
            service.saveQuestDescriptions(itemsToDb);
            questDescriptionsDiffContainer.removeAllItems();
        }
    });
    syncQuestDescriptionsActions.addComponent(saveQuestDescriptionsButton);
    questDescriptionsLayout.addComponent(syncQuestDescriptionsActions);
    questDescriptionsDiffTable = new Table();
    questDescriptionsDiffTable.setSizeFull();
    questDescriptionsDiffContainer = new HierarchicalContainer();
    questDescriptionsDiffContainer.addContainerProperty("shText", String.class, null);
    questDescriptionsDiffContainer.addContainerProperty("shNic", String.class, null);
    questDescriptionsDiffContainer.addContainerProperty("shDate", Date.class, null);
    questDescriptionsDiffContainer.addContainerProperty("dbText", String.class, null);
    questDescriptionsDiffContainer.addContainerProperty("dbNic", String.class, null);
    questDescriptionsDiffContainer.addContainerProperty("dbDate", Date.class, null);
    questDescriptionsDiffContainer.addContainerProperty("syncType", String.class, null);
    questDescriptionsDiffTable.setContainerDataSource(questDescriptionsDiffContainer);
    questDescriptionsDiffTable.removeGeneratedColumn("shText");
    questDescriptionsDiffTable.addGeneratedColumn("shText", textColumnGenerator);
    questDescriptionsDiffTable.removeGeneratedColumn("dbText");
    questDescriptionsDiffTable.addGeneratedColumn("dbText", textColumnGenerator);
    questDescriptionsDiffTable.setVisibleColumns(columns);
    questDescriptionsDiffTable.setColumnHeaders(columnHeaders);
    questDescriptionsLayout.addComponent(questDescriptionsDiffTable);
    tabs.addTab(questDescriptionsLayout, "?? ?");

    this.addComponent(tabs);

}

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

public SystemSettingsTab(DBService service_) {
    this.service = service_;

    FormLayout fl = new FormLayout();
    isAutoSyncEnabledBox = new CheckBox("??? ");
    fl.addComponent(isAutoSyncEnabledBox);
    HorizontalLayout hl = new HorizontalLayout();
    Button saveButton = new Button("");
    saveButton.addClickListener(new Button.ClickListener() {

        @Override//from ww  w  .j  a  va  2  s  .co m
        public void buttonClick(Button.ClickEvent event) {
            service.setIsAutoSynchronizationEnabled(isAutoSyncEnabledBox.getValue());
            LoadData();
            Notification notification = new Notification("?? ? ?",
                    Notification.Type.HUMANIZED_MESSAGE);
            notification.setDelayMsec(2000);
            notification.show(isAutoSyncEnabledBox.getUI().getPage());
        }
    });
    Button cancelButton = new Button("");
    cancelButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            LoadData();
        }
    });
    hl.addComponent(cancelButton);
    hl.addComponent(saveButton);
    fl.addComponent(hl);
    this.addComponent(fl);
    LoadData();
}

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

public UsersTab(DBService service) {
    this.service = service;
    actions = new HorizontalLayout();
    refreshButton = new Button("");
    refreshButton.addClickListener(new Button.ClickListener() {

        @Override/*  www.  ja va 2  s . c  o  m*/
        public void buttonClick(Button.ClickEvent event) {
            LoadTable();
        }
    });
    actions.addComponent(refreshButton);
    addButton = new Button("");
    addButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            AddUser();
        }
    });
    actions.addComponent(addButton);
    this.addComponent(actions);
    tableAndForm = new HorizontalLayout();
    tableAndForm.setSizeFull();
    table = new Table();
    table.setSizeFull();
    container = new BeanItemContainer<>(SysAccount.class);
    table.setContainerDataSource(container);
    table.setVisibleColumns(new Object[] { "login", "roles" });
    table.addItemClickListener(new TableClickListener());
    LoadTable();
    tableAndForm.addComponent(table);
    tableAndForm.setExpandRatio(table, 0.5f);
    form = new FormLayout();
    form.setSizeFull();
    login = new TextField("");
    login.setNullRepresentation("");
    login.setRequired(true);
    form.addComponent(login);
    password = new PasswordField("");
    form.addComponent(password);
    passwordRepeat = new PasswordField(" ?");
    passwordRepeat.addValidator(new PasswordValidator(password, passwordRepeat));
    form.addComponent(passwordRepeat);
    roles = new TwinColSelect("");
    BeanItemContainer<SysAccountRole> rolesContainer = new BeanItemContainer<>(SysAccountRole.class);
    rolesContainer = service.loadBeanItems(rolesContainer);
    roles.setContainerDataSource(rolesContainer);
    roles.setWidth(900f, Unit.PIXELS);
    Page.Styles styles = Page.getCurrent().getStyles();
    styles.add(".v-font-size {\n" + "    font-size: 11px;\n" + "}");
    roles.addStyleName("v-font-size");
    form.addComponent(roles);
    isBlocked = new CheckBox("");
    form.addComponent(isBlocked);
    saveButton = new Button("");
    saveButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            SaveForm();
        }
    });
    form.addComponent(saveButton);
    form.setVisible(false);
    tableAndForm.addComponent(form);
    tableAndForm.setExpandRatio(form, 0.5f);
    this.addComponent(tableAndForm);
}

From source file:org.jpos.qi.InfoDialog.java

License:Open Source License

public InfoDialog(String caption, String info) {
    super(caption);
    setWidth("350px");
    setModal(true);//  w ww  . ja va  2s  .com
    setResizable(false);
    close.setStyleName(ValoTheme.BUTTON_SMALL);

    VerticalLayout content = new VerticalLayout();
    content.setMargin(true);
    content.setSpacing(true);
    setContent(content);
    if (info != null) {
        Label l = new Label(info);
        l.setContentMode(ContentMode.HTML);
        content.addComponent(l);
    }
    HorizontalLayout hl = new HorizontalLayout();
    hl.setMargin(new MarginInfo(true, false, false, false));
    hl.setSpacing(true);
    hl.setWidth("100%");
    hl.addComponent(close);
    hl.setComponentAlignment(close, Alignment.BOTTOM_RIGHT);
    content.addComponent(hl);
}