List of usage examples for com.vaadin.ui FormLayout addStyleName
@Override public void addStyleName(String style)
From source file:my.vaadin.profile.Forms.java
public Forms() { setSpacing(true);/* w ww. j a va 2s . c o m*/ setMargin(true); Label title = new Label("Signup Form"); title.addStyleName("h1"); addComponent(title); final FormLayout form = new FormLayout(); form.setMargin(false); form.setWidth("900px"); form.addStyleName("light"); addComponent(form); Label section = new Label("Personal Info"); section.addStyleName("h2"); section.addStyleName("colored"); form.addComponent(section); //StringGenerator sg = new StringGenerator(); TextField zID = new TextField("zID"); zID.setValue("z123456"); zID.setRequired(true); form.addComponent(zID); TextField name = new TextField("Name"); name.setValue("loreum"); //name.setWidth("50%"); form.addComponent(name); PasswordField pw = new PasswordField("Set Password"); pw.setRequired(true); form.addComponent(pw); DateField birthday = new DateField("Birthday"); birthday.setDateFormat("dd-MM-yyyy"); birthday.setValue(new java.util.Date()); form.addComponent(birthday); OptionGroup gender = new OptionGroup("Gender"); gender.addItem("Male"); gender.addItem("Female"); //sex.select("Male"); gender.addStyleName("horizontal"); form.addComponent(gender); section = new Label("Class Info"); section.addStyleName("h2"); section.addStyleName("colored"); form.addComponent(section); TextField classID = new TextField("Class ID"); classID.setValue("INFS2605"); classID.setRequired(true); //classID.setWidth("50%"); form.addComponent(classID); TextField groupID = new TextField("Group ID"); groupID.setValue("1"); //groupID.setWidth("50%"); groupID.setRequired(true); form.addComponent(groupID); Button confirm = new Button("Confirm"); confirm.addStyleName("primary"); form.addComponent(confirm); HorizontalLayout footer = new HorizontalLayout(); footer.setMargin(new MarginInfo(true, false, true, false)); footer.setSpacing(true); footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); form.addComponent(footer); footer.addComponent(confirm); }
From source file:org.apache.usergrid.chop.webapp.view.chart.layout.ChartLayout.java
License:Apache License
private FormLayout addFormLayout() { FormLayout formLayout = new FormLayout(); formLayout.setWidth("250px"); formLayout.setHeight("250px"); formLayout.addStyleName("outlined"); formLayout.setSpacing(true);/*from w w w . ja va2 s. c om*/ addComponent(formLayout, "left: 10px; top: 10px;"); return formLayout; }
From source file:org.apache.usergrid.chop.webapp.view.user.UserLayout.java
License:Apache License
private FormLayout addFormLayout(int x, int y) { FormLayout formLayout = new FormLayout(); formLayout.setWidth(String.format("%spx", x)); formLayout.setHeight(String.format("%spx", y)); formLayout.addStyleName("outlined"); formLayout.setSpacing(true);/*from w ww .ja v a 2 s .c o m*/ addComponent(formLayout, "left: 350px; top: 50px;"); return formLayout; }
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 ww w .j a v a 2 s . c o 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.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);//w ww . j a v a 2 s.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 v a 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); }
From source file:org.investovator.ui.dataplayback.admin.DataPlaybackEngineAdminDashboard.java
License:Open Source License
public Component setupGameConfigBox() { FormLayout layout = new FormLayout(); layout.setCaption("Game Configuration"); layout.addStyleName("center-caption"); GameTypes config = DataPlaybackEngineStates.gameConfig; //show the game description Label gameDescription = new Label(config.getDescription()); layout.addComponent(gameDescription); gameDescription.setContentMode(ContentMode.HTML); gameDescription.setWidth(320, Unit.PIXELS); gameDescription.setCaption("Game: "); //add the player type Label playerType = new Label(); layout.addComponent(playerType);//www. j a v a2 s .c o m playerType.setCaption("Player Type: "); playerType.setValue(player.getName()); //show the attributes Label attributes = new Label(config.getInterestedAttributes().toString()); layout.addComponent(attributes); attributes.setContentMode(ContentMode.HTML); attributes.setCaption("Attributes: "); //matching attribute Label matchingAttr = new Label(config.getAttributeToMatch().toString()); layout.addComponent(matchingAttr); matchingAttr.setContentMode(ContentMode.HTML); matchingAttr.setCaption("Played On: "); return layout; }
From source file:org.investovator.ui.dataplayback.admin.DataPlaybackEngineAdminDashboard.java
License:Open Source License
public Component setupGameStatsBox() { FormLayout layout = new FormLayout(); layout.setCaption("Game Stats"); layout.addStyleName("center-caption"); //show game runtime final Label runTime = new Label(); //push the changes UI.getCurrent().access(new Runnable() { @Override/*from ww w. j a v a 2 s . c o m*/ public void run() { TimeZone defaultTz = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("GMT")); SimpleDateFormat sDate = new SimpleDateFormat("HH:mm:ss"); runTime.setValue(sDate.format(new Date(player.getGameRuntime()))); TimeZone.setDefault(defaultTz); getUI().push(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } }); runTime.setCaption("Up Time: "); layout.addComponent(runTime); //start the time updating thread new Thread() { public void run() { //update forever while (true) { UI.getCurrent().access(new Runnable() { @Override public void run() { TimeZone defaultTz = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("GMT")); SimpleDateFormat sDate = new SimpleDateFormat("HH:mm:ss"); runTime.setValue(sDate.format(new Date(player.getGameRuntime()))); TimeZone.setDefault(defaultTz); getUI().push(); } }); //wait before updating try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } } }.start(); //show market turnover Label turnover = new Label(Float.toString(player.getMarketTurnover())); turnover.setCaption("Market Turnover: "); layout.addComponent(turnover); //show total trades Label totalTrades = new Label(Integer.toString(player.getTotalTrades())); totalTrades.setCaption("Total Trades: "); layout.addComponent(totalTrades); return layout; }
From source file:org.jpos.qi.QIEntityView.java
License:Open Source License
protected Layout createLayout() { FormLayout layout = new FormLayout(); layout.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); layout.addStyleName("qi-form"); layout.setMargin(new MarginInfo(false)); addFields(layout);//from w ww .ja v a 2 s . co m return layout; }
From source file:org.jumpmind.metl.ui.views.design.PropertySheet.java
License:Open Source License
@SuppressWarnings("unchecked") public void setSource(Object obj) { value = obj;/*from w ww .ja v a 2 s. com*/ editButton.setVisible(hasAdvancedEditor()); FormLayout formLayout = new FormLayout(); formLayout.setWidth(100, Unit.PERCENTAGE); formLayout.setMargin(false); formLayout.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); if (obj != null) { if (obj instanceof List<?>) { List<Object> l = (List<Object>) obj; if (l.size() == 1) { if (l.get(0) instanceof FlowStep) { obj = (FlowStep) l.get(0); } } } if (obj instanceof FlowStep) { obj = ((FlowStep) obj).getComponent(); } if (obj instanceof Component) { Component component = (Component) obj; context.getConfigurationService().refresh(component, true); addComponentProperties(formLayout, component); } if (obj instanceof Resource) { Resource resource = (Resource) obj; addResourceProperties(formLayout, resource); } if (obj instanceof AbstractObjectWithSettings) { List<XMLSetting> settings = buildSettings(obj); if (settings != null) { for (XMLSetting definition : settings) { addSettingField(definition, (AbstractObjectWithSettings) obj, formLayout); } } } if (obj instanceof Component) { Component component = (Component) obj; XMLComponent componentDefintion = context.getComponentDefinitionFactory() .getDefinition(component.getType()); addThreadCount(componentDefintion, formLayout, component); addComponentShared(formLayout, component); } if (obj instanceof List<?>) { addCommonComponentSettings(formLayout, obj); } } panel.setContent(formLayout); }