List of usage examples for com.vaadin.ui HorizontalLayout addComponent
@Override public void addComponent(Component c)
From source file:com.cavisson.gui.dashboard.components.controls.DateFields.java
License:Apache License
public DateFields() { setMargin(true);// ww w . java 2 s .co m Label h1 = new Label("Date Fields"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); DateField date = new DateField("Default resolution"); setDate(date); row.addComponent(date); date = new DateField("Error"); setDate(date); date.setComponentError(new UserError("Fix it, now!")); row.addComponent(date); date = new DateField("Error, borderless"); setDate(date); date.setComponentError(new UserError("Fix it, now!")); date.addStyleName("borderless"); row.addComponent(date); CssLayout group = new CssLayout(); group.setCaption("Grouped with a Button"); group.addStyleName("v-component-group"); row.addComponent(group); final DateField date2 = new DateField(); group.addComponent(date2); Button today = new Button("Today", new ClickListener() { @Override public void buttonClick(ClickEvent event) { date2.setValue(new Date()); } }); group.addComponent(today); date = new DateField("Default resolution, explicit size"); setDate(date); row.addComponent(date); date.setWidth("260px"); date.setHeight("60px"); date = new DateField("Second resolution"); setDate(date); date.setResolution(Resolution.SECOND); row.addComponent(date); date = new DateField("Minute resolution"); setDate(date); date.setResolution(Resolution.MINUTE); row.addComponent(date); date = new DateField("Hour resolution"); setDate(date); date.setResolution(Resolution.HOUR); row.addComponent(date); date = new DateField("Disabled"); setDate(date); date.setResolution(Resolution.HOUR); date.setEnabled(false); row.addComponent(date); date = new DateField("Day resolution"); setDate(date); date.setResolution(Resolution.DAY); row.addComponent(date); date = new DateField("Month resolution"); setDate(date); date.setResolution(Resolution.MONTH); row.addComponent(date); date = new DateField("Year resolution"); setDate(date); date.setResolution(Resolution.YEAR); row.addComponent(date); date = new DateField("Custom color"); setDate(date); date.setResolution(Resolution.DAY); date.addStyleName("color1"); row.addComponent(date); date = new DateField("Custom color"); setDate(date); date.setResolution(Resolution.DAY); date.addStyleName("color2"); row.addComponent(date); date = new DateField("Custom color"); setDate(date); date.setResolution(Resolution.DAY); date.addStyleName("color3"); row.addComponent(date); date = new DateField("Small"); setDate(date); date.setResolution(Resolution.DAY); date.addStyleName("small"); row.addComponent(date); date = new DateField("Large"); setDate(date); date.setResolution(Resolution.DAY); date.addStyleName("large"); row.addComponent(date); date = new DateField("Borderless"); setDate(date); date.setResolution(Resolution.DAY); date.addStyleName("borderless"); row.addComponent(date); date = new DateField("Week numbers"); setDate(date); date.setResolution(Resolution.DAY); date.setLocale(new Locale("fi", "fi")); date.setShowISOWeekNumbers(true); row.addComponent(date); date = new DateField("US locale"); setDate(date); date.setResolution(Resolution.SECOND); date.setLocale(new Locale("en", "US")); row.addComponent(date); date = new DateField("Custom format"); setDate(date); date.setDateFormat("E dd/MM/yyyy"); row.addComponent(date); date = new DateField("Tiny"); setDate(date); date.setResolution(Resolution.DAY); date.addStyleName("tiny"); row.addComponent(date); date = new DateField("Huge"); setDate(date); date.setResolution(Resolution.DAY); date.addStyleName("huge"); row.addComponent(date); date = new InlineDateField("Date picker"); setDate(date); row.addComponent(date); date = new InlineDateField("Date picker with week numbers"); setDate(date); date.setLocale(new Locale("fi", "fi")); date.setShowISOWeekNumbers(true); row.addComponent(date); }
From source file:com.cavisson.gui.dashboard.components.controls.Forms.java
License:Apache License
public Forms() { setSpacing(true);/*from w ww . ja v a2s . com*/ 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("Montly"); 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.cavisson.gui.dashboard.components.controls.MenuBars.java
License:Apache License
public void init() { Label h1 = new Label("Menu Bars"); h1.addStyleName("h1"); addComponent(h1);//from w w w .j a va 2 s . c om 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.cavisson.gui.dashboard.components.controls.NativeSelects.java
License:Apache License
public NativeSelects() { setMargin(true);/*from w w w . j a va 2 s. c o m*/ Label h1 = new Label("Selects"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); NativeSelect select = new NativeSelect("Drop Down Select"); row.addComponent(select); ListSelect list = new ListSelect("List Select"); list.setNewItemsAllowed(true); row.addComponent(list); TwinColSelect tcs = new TwinColSelect("TwinCol Select"); tcs.setLeftColumnCaption("Left Column"); tcs.setRightColumnCaption("Right Column"); tcs.setNewItemsAllowed(true); row.addComponent(tcs); TwinColSelect tcs2 = new TwinColSelect("Sized TwinCol Select"); tcs2.setLeftColumnCaption("Left Column"); tcs2.setRightColumnCaption("Right Column"); tcs2.setNewItemsAllowed(true); tcs2.setWidth("280px"); tcs2.setHeight("200px"); row.addComponent(tcs2); for (int i = 1; i <= 10; i++) { select.addItem("Option " + i); list.addItem("Option " + i); tcs.addItem("Option " + i); tcs2.addItem("Option " + i); } }
From source file:com.cavisson.gui.dashboard.components.controls.Panels.java
License:Apache License
public Panels() { setMargin(true);/* ww w . ja va 2 s . c om*/ Label h1 = new Label("Panels & Layout panels"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); TestIcon testIcon = new TestIcon(60); Panel panel = new Panel("Normal"); panel.setIcon(testIcon.get()); panel.setContent(panelContent()); row.addComponent(panel); panel = new Panel("Sized"); panel.setIcon(testIcon.get()); panel.setWidth("10em"); panel.setHeight("250px"); panel.setContent(panelContent()); row.addComponent(panel); panel = new Panel("Custom Caption"); panel.setIcon(testIcon.get()); panel.addStyleName("color1"); panel.setContent(panelContent()); row.addComponent(panel); panel = new Panel("Custom Caption"); panel.setIcon(testIcon.get()); panel.addStyleName("color2"); panel.setContent(panelContent()); row.addComponent(panel); panel = new Panel("Custom Caption"); panel.setIcon(testIcon.get()); panel.addStyleName("color3"); panel.setContent(panelContent()); row.addComponent(panel); panel = new Panel("Borderless style"); panel.setIcon(testIcon.get()); panel.addStyleName("borderless"); panel.setContent(panelContent()); row.addComponent(panel); panel = new Panel("Borderless + scroll divider"); panel.setIcon(testIcon.get()); panel.addStyleName("borderless"); panel.addStyleName("scroll-divider"); panel.setContent(panelContentScroll()); panel.setHeight("17em"); row.addComponent(panel); panel = new Panel("Well style"); panel.setIcon(testIcon.get()); panel.addStyleName("well"); panel.setContent(panelContent()); row.addComponent(panel); CssLayout layout = new CssLayout(); layout.setIcon(testIcon.get()); layout.setCaption("Panel style layout"); layout.addStyleName("card"); layout.addComponent(panelContent()); row.addComponent(layout); layout = new CssLayout(); layout.addStyleName("card"); row.addComponent(layout); HorizontalLayout panelCaption = new HorizontalLayout(); panelCaption.addStyleName("v-panel-caption"); panelCaption.setWidth("100%"); // panelCaption.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); Label label = new Label("Panel style layout"); panelCaption.addComponent(label); panelCaption.setExpandRatio(label, 1); Button action = new Button(); action.setIcon(FontAwesome.PENCIL); action.addStyleName("borderless-colored"); action.addStyleName("small"); action.addStyleName("icon-only"); panelCaption.addComponent(action); MenuBar dropdown = new MenuBar(); dropdown.addStyleName("borderless"); dropdown.addStyleName("small"); MenuItem addItem = dropdown.addItem("", FontAwesome.CHEVRON_DOWN, null); addItem.setStyleName("icon-only"); addItem.addItem("Settings", null); addItem.addItem("Preferences", null); addItem.addSeparator(); addItem.addItem("Sign Out", null); panelCaption.addComponent(dropdown); layout.addComponent(panelCaption); layout.addComponent(panelContent()); layout.setWidth("14em"); layout = new CssLayout(); layout.setIcon(testIcon.get()); layout.setCaption("Well style layout"); layout.addStyleName("well"); layout.addComponent(panelContent()); row.addComponent(layout); }
From source file:com.cavisson.gui.dashboard.components.controls.PopupViews.java
License:Apache License
public PopupViews() { setMargin(true);/*from w w w .ja v a 2 s.c o m*/ Label h1 = new Label("Popup Views"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); PopupView pv = new PopupView(new Content() { @Override public Component getPopupComponent() { return new VerticalLayout() { { setMargin(true); setWidth("300px"); addComponent(new Label( "Fictum, deserunt mollit anim laborum astutumque! Magna pars studiorum, prodita quaerimus.")); } }; } @Override public String getMinimizedValueAsHTML() { return "Click to view"; } }); row.addComponent(pv); pv.setHideOnMouseOut(true); pv.setCaption("Hide on mouse-out"); pv = new PopupView(new Content() { int count = 0; @Override public Component getPopupComponent() { try { Thread.sleep(1000); } catch (InterruptedException e) { } return new VerticalLayout() { { setMargin(true); addComponent(new Label("<h3>Thanks for waiting!</h3><p>You've opened this popup <b>" + ++count + " time" + (count > 1 ? "s" : " only") + "</b>.</p>", ContentMode.HTML)); } }; } @Override public String getMinimizedValueAsHTML() { return "Show slow loading content"; } }); row.addComponent(pv); pv.setHideOnMouseOut(false); pv.setCaption("Hide on click-outside"); }
From source file:com.cavisson.gui.dashboard.components.controls.Sliders.java
License:Apache License
public Sliders() { setMargin(true);/* www .j av a 2s .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 (!ValoThemeUI.isTestMode()) { ProgressBar pb3 = new ProgressBar(); pb3.setIndeterminate(true); pb3.setCaption("Indeterminate"); row.addComponent(pb3); } }
From source file:com.cavisson.gui.dashboard.components.controls.SplitPanels.java
License:Apache License
public SplitPanels() { setMargin(true);//from www . jav a2s .c o m Label h1 = new Label("Split Panels"); h1.addStyleName("h1"); addComponent(h1); addComponent(new Label( "Outlines are just to show the areas of the SplitPanels. They are not part of the actual component style.")); HorizontalLayout row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); row.setMargin(new MarginInfo(true, false, false, false)); addComponent(row); HorizontalSplitPanel sp = new HorizontalSplitPanel(); sp.setCaption("Default style"); sp.setWidth("400px"); sp.setHeight(null); sp.setFirstComponent(getContent()); sp.setSecondComponent(getContent()); row.addComponent(sp); VerticalSplitPanel sp2 = new VerticalSplitPanel(); sp2.setCaption("Default style"); sp2.setWidth("300px"); sp2.setHeight("200px"); sp2.setFirstComponent(getContent()); sp2.setSecondComponent(getContent()); row.addComponent(sp2); sp = new HorizontalSplitPanel(); sp.setCaption("Large style"); sp.setWidth("300px"); sp.setHeight("200px"); sp.addStyleName("large"); sp.setFirstComponent(getContent()); sp.setSecondComponent(getContent()); row.addComponent(sp); sp2 = new VerticalSplitPanel(); sp2.setCaption("Large style"); sp2.setWidth("300px"); sp2.setHeight("200px"); sp2.addStyleName("large"); sp2.setFirstComponent(getContent()); sp2.setSecondComponent(getContent()); row.addComponent(sp2); }
From source file:com.cavisson.gui.dashboard.components.controls.Tabsheets.java
License:Apache License
public Tabsheets() { setMargin(true);/*ww w . j a v a2s .c o m*/ Label h1 = new Label("Tabs"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout wrap = new HorizontalLayout(); wrap.setSpacing(true); wrap.addStyleName("wrapping"); addComponent(wrap); final CheckBox closable = new CheckBox("Closable"); closable.setImmediate(true); wrap.addComponent(closable); final CheckBox overflow = new CheckBox("Overflow"); overflow.setImmediate(true); wrap.addComponent(overflow); final CheckBox caption = new CheckBox("Captions", true); caption.setImmediate(true); wrap.addComponent(caption); final CheckBox icon = new CheckBox("Icons"); icon.setImmediate(true); wrap.addComponent(icon); final CheckBox disable = new CheckBox("Disable tabs"); disable.setImmediate(true); wrap.addComponent(disable); Label h3 = new Label("Additional Styles"); h3.addStyleName("h3"); addComponent(h3); wrap = new HorizontalLayout(); wrap.setSpacing(true); wrap.addStyleName("wrapping"); wrap.setMargin(new MarginInfo(false, false, true, false)); addComponent(wrap); final CheckBox framed = new CheckBox("Framed", true); framed.setImmediate(true); wrap.addComponent(framed); final CheckBox centered = new CheckBox("Centered tabs"); centered.setImmediate(true); wrap.addComponent(centered); final CheckBox rightAlign = new CheckBox("Right-aligned tabs"); rightAlign.setImmediate(true); wrap.addComponent(rightAlign); final CheckBox equal = new CheckBox("Equal-width tabs"); equal.setImmediate(true); wrap.addComponent(equal); final CheckBox padded = new CheckBox("Padded tabbar"); padded.setImmediate(true); wrap.addComponent(padded); final CheckBox compact = new CheckBox("Compact"); compact.setImmediate(true); wrap.addComponent(compact); final CheckBox iconsOnTop = new CheckBox("Icons on top"); iconsOnTop.setImmediate(true); wrap.addComponent(iconsOnTop); final CheckBox selectedOnly = new CheckBox("Selected tab closable"); selectedOnly.setImmediate(true); wrap.addComponent(selectedOnly); ValueChangeListener update = new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String style = framed.getValue() ? "framed " : ""; style += centered.getValue() ? " centered-tabs" : ""; style += rightAlign.getValue() ? " right-aligned-tabs" : ""; style += equal.getValue() ? " equal-width-tabs" : ""; style += padded.getValue() ? " padded-tabbar" : ""; style += compact.getValue() ? " compact-tabbar" : ""; style += iconsOnTop.getValue() ? " icons-on-top" : ""; style += selectedOnly.getValue() ? " only-selected-closable" : ""; if (tabs != null) { removeComponent(tabs); } tabs = getTabSheet(caption.getValue(), style.trim(), closable.getValue(), overflow.getValue(), icon.getValue(), disable.getValue()); addComponent(tabs); } }; closable.addValueChangeListener(update); overflow.addValueChangeListener(update); caption.addValueChangeListener(update); icon.addValueChangeListener(update); disable.addValueChangeListener(update); framed.addValueChangeListener(update); centered.addValueChangeListener(update); rightAlign.addValueChangeListener(update); equal.addValueChangeListener(update); padded.addValueChangeListener(update); compact.addValueChangeListener(update); iconsOnTop.addValueChangeListener(update); selectedOnly.addValueChangeListener(update); // Generate initial view icon.setValue(true); }
From source file:com.cavisson.gui.dashboard.components.controls.TextFields.java
License:Apache License
public TextFields() { setMargin(true);//from w ww.ja va2 s. c om Label h1 = new Label("Text Fields"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); TextField tf = new TextField("Normal"); tf.setInputPrompt("First name"); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField("Custom color"); tf.setInputPrompt("Email"); tf.addStyleName("color1"); row.addComponent(tf); tf = new TextField("User Color"); tf.setInputPrompt("Gender"); tf.addStyleName("color2"); row.addComponent(tf); tf = new TextField("Themed"); tf.setInputPrompt("Age"); tf.addStyleName("color3"); row.addComponent(tf); tf = new TextField("Error"); tf.setValue("Somethings wrong"); tf.setComponentError(new UserError("Fix it, now!")); row.addComponent(tf); tf = new TextField("Error, borderless"); tf.setValue("Somethings wrong"); tf.setComponentError(new UserError("Fix it, now!")); tf.addStyleName("borderless"); row.addComponent(tf); tf = new TextField("Read-only"); tf.setInputPrompt("Nationality"); tf.setValue("Finnish"); tf.setReadOnly(true); row.addComponent(tf); tf = new TextField("Small"); tf.setValue("Field value"); tf.addStyleName("small"); row.addComponent(tf); tf = new TextField("Large"); tf.setValue("Field value"); tf.addStyleName("large"); tf.setIcon(testIcon.get(true)); row.addComponent(tf); tf = new TextField("Icon inside"); tf.setInputPrompt("Ooh, an icon"); tf.addStyleName("inline-icon"); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField("Large, Icon inside"); tf.setInputPrompt("Ooh, an icon"); tf.addStyleName("large"); tf.addStyleName("inline-icon"); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField("Small, Icon inside"); tf.setInputPrompt("Ooh, an icon"); tf.addStyleName("small"); tf.addStyleName("inline-icon"); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField("16px supported by default"); tf.setInputPrompt("Image icon"); tf.addStyleName("inline-icon"); tf.setIcon(testIcon.get(true, 16)); row.addComponent(tf); tf = new TextField(); tf.setValue("Font, no caption"); tf.addStyleName("inline-icon"); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField(); tf.setValue("Image, no caption"); tf.addStyleName("inline-icon"); tf.setIcon(testIcon.get(true, 16)); row.addComponent(tf); CssLayout group = new CssLayout(); group.addStyleName("v-component-group"); row.addComponent(group); tf = new TextField(); tf.setInputPrompt("Grouped with a button"); tf.addStyleName("inline-icon"); tf.setIcon(testIcon.get()); tf.setWidth("260px"); group.addComponent(tf); Button button = new Button("Do It"); // button.addStyleName("primary"); group.addComponent(button); tf = new TextField("Borderless"); tf.setInputPrompt("Write here"); tf.addStyleName("inline-icon"); tf.addStyleName("borderless"); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField("Right-aligned"); tf.setValue("1,234"); tf.addStyleName("align-right"); row.addComponent(tf); tf = new TextField("Centered"); tf.setInputPrompt("Guess what?"); tf.addStyleName("align-center"); row.addComponent(tf); PasswordField pwf = new PasswordField("Password"); pwf.setInputPrompt("Secret words"); pwf.addStyleName("inline-icon"); pwf.setIcon(FontAwesome.LOCK); row.addComponent(pwf); pwf = new PasswordField("Password, right-aligned"); pwf.setInputPrompt("Secret words"); pwf.addStyleName("inline-icon"); pwf.addStyleName("align-right"); pwf.setIcon(FontAwesome.LOCK); row.addComponent(pwf); pwf = new PasswordField("Password, centered"); pwf.setInputPrompt("Secret words"); pwf.addStyleName("inline-icon"); pwf.addStyleName("align-center"); pwf.setIcon(FontAwesome.LOCK); row.addComponent(pwf); tf = new TextField("Tiny"); tf.setValue("Field value"); tf.addStyleName("tiny"); row.addComponent(tf); tf = new TextField("Huge"); tf.setValue("Field value"); tf.addStyleName("huge"); row.addComponent(tf); h1 = new Label("Text Areas"); h1.addStyleName("h1"); addComponent(h1); row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); TextArea ta = new TextArea("Normal"); ta.setInputPrompt("Write your comment"); row.addComponent(ta); ta = new TextArea("Inline icon"); ta.setInputPrompt("Inline icon not really working"); ta.addStyleName("inline-icon"); ta.setIcon(testIcon.get()); row.addComponent(ta); ta = new TextArea("Custom color"); ta.addStyleName("color1"); ta.setInputPrompt("Write your comment"); row.addComponent(ta); ta = new TextArea("Custom color, read-only"); ta.addStyleName("color2"); ta.setValue("Field value, spanning multiple lines of text"); ta.setReadOnly(true); row.addComponent(ta); ta = new TextArea("Custom color"); ta.addStyleName("color3"); ta.setValue("Field value, spanning multiple lines of text"); row.addComponent(ta); ta = new TextArea("Small"); ta.addStyleName("small"); ta.setInputPrompt("Write your comment"); row.addComponent(ta); ta = new TextArea("Large"); ta.addStyleName("large"); ta.setInputPrompt("Write your comment"); row.addComponent(ta); ta = new TextArea("Borderless"); ta.addStyleName("borderless"); ta.setInputPrompt("Write your comment"); row.addComponent(ta); ta = new TextArea("Right-aligned"); ta.addStyleName("align-right"); ta.setValue("Field value, spanning multiple lines of text"); row.addComponent(ta); ta = new TextArea("Centered"); ta.addStyleName("align-center"); ta.setValue("Field value, spanning multiple lines of text"); row.addComponent(ta); ta = new TextArea("Tiny"); ta.addStyleName("tiny"); ta.setInputPrompt("Write your comment"); row.addComponent(ta); ta = new TextArea("Huge"); ta.addStyleName("huge"); ta.setInputPrompt("Write your comment"); row.addComponent(ta); RichTextArea rta = new RichTextArea(); rta.setValue("<b>Some</b> <i>rich</i> content"); row.addComponent(rta); rta = new RichTextArea("Read-only"); rta.setValue("<b>Some</b> <i>rich</i> content"); rta.setReadOnly(true); row.addComponent(rta); }