List of usage examples for com.vaadin.ui HorizontalLayout setSpacing
@Override public void setSpacing(boolean spacing)
From source file:com.etest.valo.ComboBoxes.java
License:Apache License
public ComboBoxes() { setMargin(true);/*from w w w . j a v a2s . c om*/ Label h1 = new Label("Combo Boxes"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); ComboBox combo = new ComboBox("Normal"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(MainUI.generateContainer(200, false)); combo.setNullSelectionAllowed(false); combo.select(combo.getItemIds().iterator().next()); combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(MainUI.ICON_PROPERTY); combo.setItemIcon(combo.getItemIds().iterator().next(), new ThemeResource("../runo/icons/16/document.png")); row.addComponent(combo); CssLayout group = new CssLayout(); group.setCaption("Grouped with a Button"); group.addStyleName("v-component-group"); row.addComponent(group); combo = new ComboBox(); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(MainUI.generateContainer(200, false)); combo.setNullSelectionAllowed(false); combo.select(combo.getItemIds().iterator().next()); combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(MainUI.ICON_PROPERTY); combo.setWidth("240px"); group.addComponent(combo); Button today = new Button("Do It"); group.addComponent(today); combo = new ComboBox("Explicit size"); combo.setInputPrompt("You can type here"); combo.addItem("Option One"); combo.addItem("Option Two"); combo.addItem("Option Three"); combo.setWidth("260px"); combo.setHeight("60px"); row.addComponent(combo); combo = new ComboBox("No text input allowed"); combo.setInputPrompt("You can click here"); combo.addItem("Option One"); combo.addItem("Option Two"); combo.addItem("Option Three"); combo.setTextInputAllowed(false); combo.setNullSelectionAllowed(false); combo.select("Option One"); row.addComponent(combo); combo = new ComboBox("Error"); combo.setInputPrompt("You can type here"); combo.addItem("Option One"); combo.addItem("Option Two"); combo.addItem("Option Three"); combo.setNullSelectionAllowed(false); combo.select("Option One"); combo.setComponentError(new UserError("Fix it, now!")); row.addComponent(combo); combo = new ComboBox("Error, borderless"); combo.setInputPrompt("You can type here"); combo.addItem("Option One"); combo.addItem("Option Two"); combo.addItem("Option Three"); combo.setNullSelectionAllowed(false); combo.select("Option One"); combo.setComponentError(new UserError("Fix it, now!")); combo.addStyleName("borderless"); row.addComponent(combo); combo = new ComboBox("Disabled"); combo.setInputPrompt("You can't type here"); combo.addItem("Option One"); combo.addItem("Option Two"); combo.addItem("Option Three"); combo.setEnabled(false); row.addComponent(combo); combo = new ComboBox("Custom color"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(MainUI.generateContainer(200, false)); combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(MainUI.ICON_PROPERTY); combo.addStyleName("color1"); row.addComponent(combo); combo = new ComboBox("Custom color"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(MainUI.generateContainer(200, false)); combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(MainUI.ICON_PROPERTY); combo.addStyleName("color2"); row.addComponent(combo); combo = new ComboBox("Custom color"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(MainUI.generateContainer(200, false)); combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(MainUI.ICON_PROPERTY); combo.addStyleName("color3"); row.addComponent(combo); combo = new ComboBox("Small"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(MainUI.generateContainer(200, false)); combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(MainUI.ICON_PROPERTY); combo.addStyleName("small"); row.addComponent(combo); combo = new ComboBox("Large"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(MainUI.generateContainer(200, false)); combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(MainUI.ICON_PROPERTY); combo.addStyleName("large"); row.addComponent(combo); combo = new ComboBox("Borderless"); combo.setInputPrompt("You can type here"); combo.addItem("Option One"); combo.addItem("Option Two"); combo.addItem("Option Three"); combo.addStyleName("borderless"); row.addComponent(combo); combo = new ComboBox("Tiny"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(MainUI.generateContainer(200, false)); combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(MainUI.ICON_PROPERTY); combo.addStyleName("tiny"); row.addComponent(combo); combo = new ComboBox("Huge"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(MainUI.generateContainer(200, false)); combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(MainUI.ICON_PROPERTY); combo.addStyleName("huge"); row.addComponent(combo); }
From source file:com.etest.valo.Forms.java
License:Apache License
public Forms() { setSpacing(true);// w w w . j a v a 2 s .c om setMargin(true); Label title = new Label("Forms"); title.addStyleName("h1"); addComponent(title); final FormLayout form = new FormLayout(); form.setMargin(false); form.setWidth("800px"); 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 name = new TextField("Name"); name.setValue(sg.nextString(true) + " " + sg.nextString(true)); name.setWidth("50%"); form.addComponent(name); DateField birthday = new DateField("Birthday"); birthday.setValue(new Date(80, 0, 31)); form.addComponent(birthday); TextField username = new TextField("Username"); username.setValue(sg.nextString(false) + sg.nextString(false)); username.setRequired(true); form.addComponent(username); OptionGroup sex = new OptionGroup("Sex"); sex.addItem("Female"); sex.addItem("Male"); sex.select("Male"); sex.addStyleName("horizontal"); form.addComponent(sex); section = new Label("Contact Info"); section.addStyleName("h3"); section.addStyleName("colored"); form.addComponent(section); TextField email = new TextField("Email"); email.setValue(sg.nextString(false) + "@" + sg.nextString(false) + ".com"); email.setWidth("50%"); email.setRequired(true); form.addComponent(email); TextField location = new TextField("Location"); location.setValue(sg.nextString(true) + ", " + sg.nextString(true)); location.setWidth("50%"); location.setComponentError(new UserError("This address doesn't exist")); form.addComponent(location); TextField phone = new TextField("Phone"); phone.setWidth("50%"); form.addComponent(phone); HorizontalLayout wrap = new HorizontalLayout(); wrap.setSpacing(true); wrap.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); wrap.setCaption("Newsletter"); CheckBox newsletter = new CheckBox("Subscribe to newsletter", true); wrap.addComponent(newsletter); ComboBox period = new ComboBox(); period.setTextInputAllowed(false); period.addItem("Daily"); period.addItem("Weekly"); period.addItem("Monthly"); period.setNullSelectionAllowed(false); period.select("Weekly"); period.addStyleName("small"); period.setWidth("10em"); wrap.addComponent(period); form.addComponent(wrap); section = new Label("Additional Info"); section.addStyleName("h4"); section.addStyleName("colored"); form.addComponent(section); TextField website = new TextField("Website"); website.setInputPrompt("http://"); website.setWidth("100%"); form.addComponent(website); TextArea shortbio = new TextArea("Short Bio"); shortbio.setValue( "Quis aute iure reprehenderit in voluptate velit esse. Cras mattis iudicium purus sit amet fermentum."); shortbio.setWidth("100%"); shortbio.setRows(2); form.addComponent(shortbio); final RichTextArea bio = new RichTextArea("Bio"); bio.setWidth("100%"); bio.setValue( "<div><p><span>Integer legentibus erat a ante historiarum dapibus.</span> <span>Vivamus sagittis lacus vel augue laoreet rutrum faucibus.</span> <span>A communi observantia non est recedendum.</span> <span>Morbi fringilla convallis sapien, id pulvinar odio volutpat.</span> <span>Ab illo tempore, ab est sed immemorabili.</span> <span>Quam temere in vitiis, legem sancimus haerentia.</span></p><p><span>Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Cum sociis natoque penatibus et magnis dis parturient.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Tityre, tu patulae recubans sub tegmine fagi dolor.</span></p><p><span>Curabitur blandit tempus ardua ridiculus sed magna.</span> <span>Phasellus laoreet lorem vel dolor tempus vehicula.</span> <span>Etiam habebis sem dicantur magna mollis euismod.</span> <span>Hi omnes lingua, institutis, legibus inter se differunt.</span></p></div>"); form.addComponent(bio); form.setReadOnly(true); bio.setReadOnly(true); Button edit = new Button("Edit", new ClickListener() { @Override public void buttonClick(ClickEvent event) { boolean readOnly = form.isReadOnly(); if (readOnly) { bio.setReadOnly(false); form.setReadOnly(false); form.removeStyleName("light"); event.getButton().setCaption("Save"); event.getButton().addStyleName("primary"); } else { bio.setReadOnly(true); form.setReadOnly(true); form.addStyleName("light"); event.getButton().setCaption("Edit"); event.getButton().removeStyleName("primary"); } } }); 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(edit); Label lastModified = new Label("Last modified by you a minute ago"); lastModified.addStyleName("light"); footer.addComponent(lastModified); }
From source file:com.etest.valo.MenuBars.java
License:Apache License
public MenuBars() { setMargin(true);// w ww .j ava2 s . c om setSpacing(true); Label h1 = new Label("Menu Bars"); h1.addStyleName("h1"); addComponent(h1); MenuBar menuBar = getMenuBar(); menuBar.setCaption("Normal style"); addComponent(menuBar); menuBar = getMenuBar(); menuBar.setCaption("Small style"); menuBar.addStyleName("small"); addComponent(menuBar); menuBar = getMenuBar(); menuBar.setCaption("Borderless style"); menuBar.addStyleName("borderless"); addComponent(menuBar); menuBar = getMenuBar(); menuBar.setCaption("Small borderless style"); menuBar.addStyleName("borderless"); menuBar.addStyleName("small"); addComponent(menuBar); Label h2 = new Label("Drop Down Button"); h2.addStyleName("h2"); addComponent(h2); HorizontalLayout wrap = new HorizontalLayout(); wrap.addStyleName("wrapping"); wrap.setSpacing(true); addComponent(wrap); wrap.addComponent(getMenuButton("Normal", false)); MenuBar split = getMenuButton("Small", false); split.addStyleName("small"); wrap.addComponent(split); split = getMenuButton("Borderless", false); split.addStyleName("borderless"); wrap.addComponent(split); split = getMenuButton("Themed", false); split.addStyleName("color1"); wrap.addComponent(split); split = getMenuButton("Small", false); split.addStyleName("color1"); split.addStyleName("small"); wrap.addComponent(split); h2 = new Label("Split Button"); h2.addStyleName("h2"); addComponent(h2); wrap = new HorizontalLayout(); wrap.addStyleName("wrapping"); wrap.setSpacing(true); addComponent(wrap); wrap.addComponent(getMenuButton("Normal", true)); split = getMenuButton("Small", true); split.addStyleName("small"); wrap.addComponent(split); split = getMenuButton("Borderless", true); split.addStyleName("borderless"); wrap.addComponent(split); split = getMenuButton("Themed", true); split.addStyleName("color1"); wrap.addComponent(split); split = getMenuButton("Small", true); split.addStyleName("color1"); split.addStyleName("small"); wrap.addComponent(split); }
From source file:com.etest.valo.Sliders.java
License:Apache License
public Sliders() { setMargin(true);//from w w w . j av a 2 s.c o m Label h1 = new Label("Sliders"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); Slider slider = new Slider("Horizontal"); slider.setValue(50.0); row.addComponent(slider); slider = new Slider("Horizontal, sized"); slider.setValue(50.0); slider.setWidth("200px"); row.addComponent(slider); slider = new Slider("Custom handle"); slider.setValue(50.0); slider.setWidth("200px"); slider.addStyleName("color1"); row.addComponent(slider); slider = new Slider("Custom track"); slider.setValue(50.0); slider.setWidth("200px"); slider.addStyleName("color2"); row.addComponent(slider); slider = new Slider("Custom indicator"); slider.setValue(50.0); slider.setWidth("200px"); slider.addStyleName("color3"); row.addComponent(slider); slider = new Slider("No indicator"); slider.setValue(50.0); slider.setWidth("200px"); slider.addStyleName("no-indicator"); row.addComponent(slider); slider = new Slider("With ticks (not in IE8 & IE9)"); slider.setValue(3.0); slider.setWidth("200px"); slider.setMax(4); slider.addStyleName("ticks"); row.addComponent(slider); slider = new Slider("Toggle imitation"); slider.setWidth("50px"); slider.setResolution(0); slider.setMin(0); slider.setMax(1); row.addComponent(slider); slider = new Slider("Vertical"); slider.setValue(50.0); slider.setOrientation(SliderOrientation.VERTICAL); row.addComponent(slider); slider = new Slider("Vertical, sized"); slider.setValue(50.0); slider.setOrientation(SliderOrientation.VERTICAL); slider.setHeight("200px"); row.addComponent(slider); slider = new Slider("Custom handle"); slider.setValue(50.0); slider.setHeight("200px"); slider.addStyleName("color1"); slider.setOrientation(SliderOrientation.VERTICAL); row.addComponent(slider); slider = new Slider("Custom track"); slider.setValue(50.0); slider.setHeight("200px"); slider.addStyleName("color2"); slider.setOrientation(SliderOrientation.VERTICAL); row.addComponent(slider); slider = new Slider("Custom indicator"); slider.setValue(50.0); slider.setHeight("200px"); slider.addStyleName("color3"); slider.setOrientation(SliderOrientation.VERTICAL); row.addComponent(slider); slider = new Slider("No indicator"); slider.setValue(50.0); slider.setHeight("200px"); slider.addStyleName("no-indicator"); slider.setOrientation(SliderOrientation.VERTICAL); row.addComponent(slider); slider = new Slider("With ticks"); slider.setValue(3.0); slider.setHeight("200px"); slider.setMax(4); slider.addStyleName("ticks"); slider.setOrientation(SliderOrientation.VERTICAL); row.addComponent(slider); slider = new Slider("Disabled"); slider.setValue(50.0); slider.setEnabled(false); row.addComponent(slider); h1 = new Label("Progress Bars"); h1.addStyleName("h1"); addComponent(h1); row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); pb = new ProgressBar(); pb.setCaption("Default"); pb.setWidth("300px"); // pb.setValue(0.6f); row.addComponent(pb); pb2 = new ProgressBar(); pb2.setCaption("Point style"); pb2.setWidth("300px"); pb2.addStyleName("point"); // pb2.setValue(0.6f); row.addComponent(pb2); if (!MainUI.isTestMode()) { ProgressBar pb3 = new ProgressBar(); pb3.setIndeterminate(true); pb3.setCaption("Indeterminate"); row.addComponent(pb3); } }
From source file:com.etest.valo.Trees.java
License:Apache License
public Trees() { setMargin(true);/*from ww w . j a v a 2 s .com*/ Label h1 = new Label("Trees"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); Tree tree = new Tree(); tree.setSelectable(true); tree.setMultiSelect(true); Container generateContainer = MainUI.generateContainer(10, true); tree.setContainerDataSource(generateContainer); tree.setDragMode(TreeDragMode.NODE); row.addComponent(tree); tree.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); tree.setItemIconPropertyId(MainUI.ICON_PROPERTY); tree.expandItem(generateContainer.getItemIds().iterator().next()); tree.setDropHandler(new DropHandler() { @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } @Override public void drop(DragAndDropEvent event) { Notification.show(event.getTransferable().toString()); } }); // Add actions (context menu) tree.addActionHandler(MainUI.getActionHandler()); }
From source file:com.etest.view.systemadministration.curriculum.CurriculumFormWindow.java
FormLayout buildForms() { FormLayout form = new FormLayout(); form.setMargin(true);// w w w. ja v a2 s .c o m yearLevel.setWidth("75%"); form.addComponent(yearLevel); subjectField.setWidth("75%"); form.addComponent(subjectField); normCourseOffering.setWidth("75%"); form.addComponent(normCourseOffering); descriptiveTitleField.setWidth("100%"); descriptiveTitleField.setRows(3); descriptiveTitleField.setInputPrompt("Descriptive Title.."); form.addComponent(descriptiveTitleField); Button save = new Button("SAVE"); save.setWidth("100%"); save.setIcon(FontAwesome.SAVE); save.addStyleName(ValoTheme.BUTTON_PRIMARY); save.addStyleName(ValoTheme.BUTTON_SMALL); save.addClickListener(buttonClickListener); Button update = new Button("UPDATE"); update.setWidth("100%"); update.setIcon(FontAwesome.ADJUST); update.addStyleName(ValoTheme.BUTTON_PRIMARY); update.addStyleName(ValoTheme.BUTTON_SMALL); update.addClickListener(buttonClickListener); Button delete = new Button("DELETE"); delete.setWidth("100%"); delete.setIcon(FontAwesome.ERASER); delete.addStyleName(ValoTheme.BUTTON_PRIMARY); delete.addStyleName(ValoTheme.BUTTON_SMALL); delete.addClickListener(buttonClickListener); HorizontalLayout hlayout = new HorizontalLayout(); hlayout.setWidth("100%"); hlayout.setSpacing(true); if (getCurriculumId() != 0) { hlayout.addComponent(update); hlayout.addComponent(delete); Curriculum c = cs.getCurriculumById(getCurriculumId()); yearLevel.setValue(c.getYearLevel()); subjectField.setValue(c.getSubject()); normCourseOffering.setValue(c.getNormCourseOffering()); descriptiveTitleField.setValue(c.getDescriptiveTitle()); if (getButtonCaption().equals("edit")) { delete.setVisible(false); } else { update.setVisible(false); } } else { hlayout.addComponent(save); } form.addComponent(hlayout); return form; }
From source file:com.etest.view.testbank.CellCaseMainUI.java
HorizontalLayout getHlayout() { HorizontalLayout hlayout = new HorizontalLayout(); hlayout.setSpacing(true); subject.setWidth("200px"); subject.addValueChangeListener((new CurriculumPropertyChangeListener(topic))); hlayout.addComponent(subject);/* w w w . ja va 2 s .c o m*/ hlayout.setComponentAlignment(subject, Alignment.MIDDLE_LEFT); topic.setInputPrompt("Select a Topic.."); topic.addStyleName(ValoTheme.COMBOBOX_SMALL); topic.setWidth("500px"); topic.addValueChangeListener((Property.ValueChangeEvent event) -> { if (event.getProperty().getValue() == null) { } else { syllabusId = (int) event.getProperty().getValue(); populateDataTable(); } }); hlayout.addComponent(topic); hlayout.setComponentAlignment(topic, Alignment.MIDDLE_LEFT); Button createCellBtn = new Button("CREATE"); createCellBtn.setWidthUndefined(); createCellBtn.setIcon(FontAwesome.OPENID); createCellBtn.addStyleName(ValoTheme.BUTTON_PRIMARY); createCellBtn.addStyleName(ValoTheme.BUTTON_SMALL); createCellBtn.addClickListener((Button.ClickEvent event) -> { Window sub = new CellCaseWindow(0); if (sub.getParent() == null) { UI.getCurrent().addWindow(sub); } sub.addCloseListener((Window.CloseEvent e) -> { populateDataTable(); }); }); hlayout.addComponent(createCellBtn); hlayout.setComponentAlignment(createCellBtn, Alignment.MIDDLE_LEFT); return hlayout; }
From source file:com.etest.view.testbank.CellCaseWindow.java
FormLayout buildForms() { FormLayout form = new FormLayout(); form.setWidth("100%"); form.setMargin(true);// w w w . ja v a 2s. co m subject.setCaption("Subject: "); subject.setWidth("50%"); subject.addValueChangeListener((new CurriculumPropertyChangeListener(topic))); form.addComponent(subject); topic.setCaption("Topic: "); topic.setWidth("80%"); topic.setInputPrompt("Select a Topic.."); topic.addStyleName(ValoTheme.COMBOBOX_SMALL); form.addComponent(topic); caseTopic = new TextArea(); caseTopic.setCaption("Case: "); caseTopic.setWidth("100%"); caseTopic.setRows(5); form.addComponent(caseTopic); HorizontalLayout hlayout = new HorizontalLayout(); hlayout.setWidth("100%"); hlayout.setSpacing(true); Button save = new Button("SAVE"); save.setWidth("200px"); save.setIcon(FontAwesome.SAVE); save.addStyleName(ValoTheme.BUTTON_PRIMARY); save.addStyleName(ValoTheme.BUTTON_SMALL); save.addClickListener(buttonClickListener); Button modify = new Button("MODIFY"); modify.setWidth("200px"); modify.setIcon(FontAwesome.EDIT); modify.addStyleName(ValoTheme.BUTTON_PRIMARY); modify.addStyleName(ValoTheme.BUTTON_SMALL); modify.addClickListener(buttonClickListener); Button approve = new Button("APPROVE"); approve.setWidth("200px"); approve.setIcon(FontAwesome.THUMBS_UP); approve.addStyleName(ValoTheme.BUTTON_PRIMARY); approve.addStyleName(ValoTheme.BUTTON_SMALL); approve.setEnabled(UserAccess.approve()); approve.addClickListener(buttonClickListener); Button delete = new Button("DELETE"); delete.setWidth("200px"); delete.setIcon(FontAwesome.TRASH_O); delete.addStyleName(ValoTheme.BUTTON_PRIMARY); delete.addStyleName(ValoTheme.BUTTON_SMALL); delete.setEnabled(UserAccess.delete()); delete.addClickListener(buttonClickListener); if (getCellCaseId() != 0) { CellCase cc = ccs.getCellCaseById(getCellCaseId()); subject.setValue(cc.getCurriculumId()); topic.setValue(cc.getSyllabusId()); caseTopic.setValue(cc.getCaseTopic()); approve.setVisible(cc.getApprovalStatus() == 0); hlayout.addComponent(approve); hlayout.setComponentAlignment(approve, Alignment.MIDDLE_RIGHT); hlayout.addComponent(modify); hlayout.setComponentAlignment(modify, Alignment.MIDDLE_RIGHT); hlayout.addComponent(delete); hlayout.setComponentAlignment(delete, Alignment.MIDDLE_RIGHT); } else { hlayout.addComponent(save); hlayout.setComponentAlignment(save, Alignment.MIDDLE_RIGHT); } form.addComponent(hlayout); form.setComponentAlignment(hlayout, Alignment.MIDDLE_RIGHT); return form; }
From source file:com.etest.view.testbank.cellitem.CellItemWindow.java
FormLayout buildForms() { FormLayout form = new FormLayout(); form.setWidth("100%"); form.setMargin(true);//from ww w .j a v a 2 s.c o m form.setSpacing(true); HorizontalLayout hlayout = new HorizontalLayout(); hlayout.setWidth("100%"); Button helpBtn = new Button("HELP"); helpBtn.setWidthUndefined(); helpBtn.setIcon(FontAwesome.TASKS); helpBtn.addStyleName(ValoTheme.BUTTON_PRIMARY); helpBtn.addStyleName(ValoTheme.BUTTON_SMALL); helpBtn.addClickListener((Button.ClickEvent event) -> { Window sub = new MultipleChoiceHelpViewer(); if (sub.getParent() == null) { UI.getCurrent().addWindow(sub); } }); hlayout.addComponent(helpBtn); hlayout.setComponentAlignment(helpBtn, Alignment.MIDDLE_RIGHT); form.addComponent(hlayout); bloomsTaxonomy.setCaption("Blooms Class: "); bloomsTaxonomy.setWidth("30%"); form.addComponent(bloomsTaxonomy); stem = new TextArea("Stem: "); stem.setWidth("100%"); stem.setRows(5); stem.setWordwrap(true); form.addComponent(stem); HorizontalLayout h1 = new HorizontalLayout(); h1.setCaption("Option A:"); h1.setWidth("100%"); h1.setSpacing(true); optionA = new CommonTextField("add option A", null); optionA.setWidth("500px"); h1.addComponent(optionA); Button optionABtn = new CommonButton("OPTION A"); optionABtn.setWidth("120px"); optionABtn.addClickListener(updateOptionAndKeyListerner); h1.addComponent(optionABtn); h1.setComponentAlignment(optionABtn, Alignment.MIDDLE_RIGHT); optionABtn.setVisible(isEdit()); form.addComponent(h1); HorizontalLayout h2 = new HorizontalLayout(); h2.setCaption("Key A:"); h2.setWidth("100%"); h2.setSpacing(true); keyA = new CommonTextField("Enter a Key for Option A", null); keyA.setWidth("500px"); h2.addComponent(keyA); Button keyABtn = new CommonButton("KEY A"); keyABtn.setWidth("120px"); keyABtn.addClickListener(updateOptionAndKeyListerner); h2.addComponent(keyABtn); h2.setComponentAlignment(keyABtn, Alignment.MIDDLE_RIGHT); keyABtn.setVisible(isEdit()); form.addComponent(h2); HorizontalLayout h3 = new HorizontalLayout(); h3.setCaption("Option B:"); h3.setWidth("100%"); h3.setSpacing(true); optionB = new CommonTextField("add option B", null); optionB.setWidth("500px"); h3.addComponent(optionB); Button optionBBtn = new CommonButton("OPTION B"); optionBBtn.setWidth("120px"); optionBBtn.addClickListener(updateOptionAndKeyListerner); h3.addComponent(optionBBtn); h3.setComponentAlignment(optionBBtn, Alignment.MIDDLE_RIGHT); optionBBtn.setVisible(isEdit()); form.addComponent(h3); HorizontalLayout h4 = new HorizontalLayout(); h4.setCaption("Key B:"); h4.setWidth("100%"); h4.setSpacing(true); keyB = new CommonTextField("Enter a Key for Option B", null); keyB.setWidth("500px"); h4.addComponent(keyB); Button keyBBtn = new CommonButton("KEY B"); keyBBtn.setWidth("120px"); keyBBtn.addClickListener(updateOptionAndKeyListerner); h4.addComponent(keyBBtn); h4.setComponentAlignment(keyBBtn, Alignment.MIDDLE_RIGHT); keyBBtn.setVisible(isEdit()); form.addComponent(h4); HorizontalLayout h5 = new HorizontalLayout(); h5.setCaption("Option C:"); h5.setWidth("100%"); h5.setSpacing(true); optionC = new CommonTextField("add option C", null); optionC.setWidth("500px"); h5.addComponent(optionC); Button optionCBtn = new CommonButton("OPTION C"); optionCBtn.setWidth("120px"); optionCBtn.addClickListener(updateOptionAndKeyListerner); h5.addComponent(optionCBtn); h5.setComponentAlignment(optionCBtn, Alignment.TOP_RIGHT); optionCBtn.setVisible(isEdit()); form.addComponent(h5); HorizontalLayout h6 = new HorizontalLayout(); h6.setCaption("Key C:"); h6.setWidth("100%"); h6.setSpacing(true); keyC = new CommonTextField("Enter a Key for Option C", null); keyC.setWidth("500px"); h6.addComponent(keyC); Button keyCBtn = new CommonButton("KEY C"); keyCBtn.setWidth("120px"); keyCBtn.addClickListener(updateOptionAndKeyListerner); h6.addComponent(keyCBtn); h6.setComponentAlignment(keyCBtn, Alignment.MIDDLE_RIGHT); keyCBtn.setVisible(isEdit()); form.addComponent(h6); HorizontalLayout h7 = new HorizontalLayout(); h7.setCaption("Option D:"); h7.setWidth("100%"); h7.setSpacing(true); optionD = new CommonTextField("add option D", null); optionD.setWidth("500px"); h7.addComponent(optionD); Button optionDBtn = new CommonButton("OPTION D"); optionDBtn.setWidth("120px"); optionDBtn.addClickListener(updateOptionAndKeyListerner); h7.addComponent(optionDBtn); h7.setComponentAlignment(optionDBtn, Alignment.MIDDLE_RIGHT); optionDBtn.setVisible(isEdit()); form.addComponent(h7); HorizontalLayout h8 = new HorizontalLayout(); h8.setCaption("Key D:"); h8.setWidth("100%"); h8.setSpacing(true); keyD = new CommonTextField("Enter a Key for Option D", null); keyD.setWidth("500px"); h8.addComponent(keyD); Button keyDBtn = new CommonButton("KEY D"); keyDBtn.setWidth("120px"); keyDBtn.addClickListener(updateOptionAndKeyListerner); h8.addComponent(keyDBtn); h8.setComponentAlignment(keyDBtn, Alignment.MIDDLE_RIGHT); keyDBtn.setVisible(isEdit()); form.addComponent(h8); HorizontalLayout h = new HorizontalLayout(); h.setWidth("100%"); Button save = new Button("SAVE"); save.setWidth("200px"); save.setIcon(FontAwesome.SAVE); save.addStyleName(ValoTheme.BUTTON_PRIMARY); save.addStyleName(ValoTheme.BUTTON_SMALL); save.addClickListener(buttonClickListener); Button remove = new Button("ARCHIVE/REMOVE ITEM?"); remove.setWidth("200px"); remove.setIcon(FontAwesome.ARCHIVE); remove.addStyleName(ValoTheme.BUTTON_PRIMARY); remove.addStyleName(ValoTheme.BUTTON_SMALL); remove.addClickListener(buttonClickListener); Button approve = new Button("APPROVE ITEM?"); approve.setWidth("200px"); approve.setIcon(FontAwesome.THUMBS_O_UP); approve.addStyleName(ValoTheme.BUTTON_PRIMARY); approve.addStyleName(ValoTheme.BUTTON_SMALL); approve.addClickListener(buttonClickListener); Button edit = new Button("UPDATE"); edit.setWidth("200px"); edit.setIcon(FontAwesome.SAVE); edit.addStyleName(ValoTheme.BUTTON_PRIMARY); edit.addStyleName(ValoTheme.BUTTON_SMALL); edit.addClickListener(buttonClickListener); if (getCellItemId() != 0) { CellItem ci = cis.getCellItemById(getCellItemId()); bloomsTaxonomy.setValue(ci.getBloomsClassId()); bloomsTaxonomy.addValueChangeListener((Property.ValueChangeEvent event) -> { isBloomsChanged = true; }); stem.setValue(ci.getItem()); stem.addTextChangeListener((FieldEvents.TextChangeEvent event) -> { if (!stem.getValue().trim().equals(event.getText().trim())) { isStemChanged = true; } }); /** * OPTION A */ optionA.setValue(ci.getOptionA()); isOptionAKeyExist = k.isKeyExist(getCellItemId(), ci.getOptionA()); if (isOptionAKeyExist) { keyA.setValue(k.getItemKey(getCellItemId(), ci.getOptionA())); } keyA.setData(k.getItemKeyId(getCellItemId(), ci.getOptionA())); /** * OPTION B */ optionB.setValue(ci.getOptionB()); isOptionBKeyExist = k.isKeyExist(getCellItemId(), ci.getOptionB()); if (isOptionBKeyExist) { keyB.setValue(k.getItemKey(getCellItemId(), ci.getOptionB())); } keyB.setData(k.getItemKeyId(getCellItemId(), ci.getOptionB())); /** * OPTION C */ optionC.setValue(ci.getOptionC()); isOptionCKeyExist = k.isKeyExist(getCellItemId(), ci.getOptionC()); if (isOptionCKeyExist) { keyC.setValue(k.getItemKey(getCellItemId(), ci.getOptionC())); } keyC.setData(k.getItemKeyId(getCellItemId(), ci.getOptionC())); /** * OPTION D */ optionD.setValue(ci.getOptionD()); isOptionDKeyExist = k.isKeyExist(getCellItemId(), ci.getOptionD()); if (isOptionDKeyExist) { keyD.setValue(k.getItemKey(getCellItemId(), ci.getOptionD())); } keyD.setData(k.getItemKeyId(getCellItemId(), ci.getOptionD())); h.addComponent(remove); h.setComponentAlignment(remove, Alignment.MIDDLE_RIGHT); h.addComponent(approve); h.setComponentAlignment(approve, Alignment.MIDDLE_RIGHT); h.addComponent(edit); h.setComponentAlignment(edit, Alignment.MIDDLE_RIGHT); form.addComponent(h); } else { h.addComponent(save); h.setComponentAlignment(save, Alignment.MIDDLE_RIGHT); form.addComponent(h); } return form; }
From source file:com.etest.view.tq.charts.ItemAnalysisGraphicalViewAll.java
public ItemAnalysisGraphicalViewAll(int curriculumId) { this.curriculumId = curriculumId; setModal(true);/* w ww. j av a 2s . c om*/ setHeight("100%"); VerticalLayout v = new VerticalLayout(); v.setMargin(true); v.setSpacing(true); Label title = new Label(); title.setCaption("Item Analysis of " + cs.getCurriculumById(getCurriculumId()).getSubject()); title.setWidthUndefined(); v.addComponent(title); v.setComponentAlignment(title, Alignment.TOP_CENTER); HorizontalLayout h = new HorizontalLayout(); h.setSpacing(true); h.addComponent(getDiscriminationIndexChart()); h.addComponent(getDifficultIndexChart()); h.setWidthUndefined(); h.setHeightUndefined(); v.addComponent(h); v.setWidthUndefined(); setContent(v); getContent().setWidthUndefined(); // getContent().setHeightUndefined(); center(); }