List of usage examples for com.vaadin.ui HorizontalLayout setWidth
@Override public void setWidth(String width)
From source file:at.peppol.webgui.app.components.ItemPropertyForm.java
License:Mozilla Public License
private void initElements() { final GridLayout grid = new GridLayout(4, 4); final VerticalLayout outerLayout = new VerticalLayout(); hiddenContent = new VerticalLayout(); hiddenContent.setSpacing(true);//from w w w . j av a 2 s. co m hiddenContent.setMargin(true); table = new InvoiceItemPropertyTable(itemPropertyBeanList); table.setSelectable(true); table.setImmediate(true); table.setNullSelectionAllowed(false); table.setHeight(150, UNITS_PIXELS); table.setFooterVisible(false); table.addStyleName("striped strong"); VerticalLayout tableContainer = new VerticalLayout(); tableContainer.addComponent(table); tableContainer.setMargin(false, true, false, false); Button addButton = new Button("Add new"); Button editButton = new Button("Edit selected"); Button deleteButton = new Button("Delete selected"); VerticalLayout buttonsContainer = new VerticalLayout(); buttonsContainer.setSpacing(true); buttonsContainer.addComponent(addButton); buttonsContainer.addComponent(editButton); buttonsContainer.addComponent(deleteButton); InvoiceItemPropertyTableEditor editor = new InvoiceItemPropertyTableEditor(editMode); Label label = new Label("<h3>Adding new item property</h3>", Label.CONTENT_XHTML); addButton.addListener(editor.addButtonListener(editButton, deleteButton, hiddenContent, table, itemPropertyBeanList, label)); label = new Label("<h3>Edit item property</h3>", Label.CONTENT_XHTML); editButton.addListener(editor.editButtonListener(addButton, deleteButton, hiddenContent, table, itemPropertyBeanList, label)); deleteButton.addListener(editor.deleteButtonListener(table)); Panel outerPanel = new Panel(itemPropertyPrefix + " Item Properties"); //outerPanel.setStyleName("light"); // ---- HIDDEN FORM BEGINS ----- VerticalLayout formLayout = new VerticalLayout(); formLayout.addComponent(hiddenContent); hiddenContent.setVisible(false); // ---- HIDDEN FORM ENDS ----- grid.setSizeUndefined(); grid.addComponent(tableContainer, 0, 0); grid.addComponent(buttonsContainer, 1, 0); outerPanel.addComponent(grid); outerPanel.addComponent(formLayout); outerLayout.addComponent(outerPanel); outerPanel.requestRepaintAll(); VerticalLayout mainLayout = new VerticalLayout(); final VerticalLayout showHideContentLayout = new VerticalLayout(); showHideContentLayout.addComponent(outerPanel); HorizontalLayout showHideButtonLayout = new HorizontalLayout(); Button btn = new Button("Show/Hide Additional Item Property", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { // TODO Auto-generated method stub showHideContentLayout.setVisible(!showHideContentLayout.isVisible()); } }); showHideButtonLayout.setWidth("100%"); showHideButtonLayout.addComponent(btn); showHideButtonLayout.setComponentAlignment(btn, Alignment.MIDDLE_RIGHT); //mainLayout.addComponent(showHideButtonLayout); mainLayout.addComponent(showHideContentLayout); //showHideContentLayout.setVisible(false); addComponent(mainLayout); }
From source file:at.peppol.webgui.app.components.TabInvoiceLine.java
License:Mozilla Public License
public Form createGridLayoutInvoiceLineForm() { Form form = new Form() { HorizontalLayout layout = new HorizontalLayout(); Panel pricePanel = new Panel("Price"); FormLayout f1 = new FormLayout(); FormLayout f2 = new FormLayout(); Label label = new Label("<h4>Allowances/Charges</h4>", Label.CONTENT_XHTML); {/*from ww w . j a v a 2 s. c o m*/ layout.setSpacing(true); layout.setMargin(true); setLayout(layout); HorizontalLayout h = new HorizontalLayout(); h.setWidth("50px"); pricePanel.setStyleName("light"); layout.addComponent(f1); layout.addComponent(h); layout.addComponent(pricePanel); pricePanel.addComponent(f2); } @Override protected void attachField(Object propertyId, Field field) { //field.setCaption(null); if ("Line Note".equals(propertyId) || "Invoiced Quantity".equals(propertyId) || "Line Extension Amount".equals(propertyId) || "Accounting Cost".equals(propertyId) || "Tax Total Amount".equals(propertyId) || "Item Description".equals(propertyId) || "Item Name".equals(propertyId) || "Sellers Item ID".equals(propertyId) || "Tax Category ID".equals(propertyId) || "Tax Category Percent".equals(propertyId) || "Standard Item ID".equals(propertyId) || "Tax Scheme ID".equals(propertyId) || "Measurement Unit".equals(propertyId)) { f1.addComponent(field); } else if ("Price Allowance/Charge Indicator".equals(propertyId) || "Price Allowance/Charge Reason".equals(propertyId) || "Price Allowance/Charge Multiplier Factor".equals(propertyId) || "Price Allowance/Charge Amount".equals(propertyId) || "Price Allowance/Charge Base Amount".equals(propertyId)) { if (f2.getComponentIndex(label) == -1) f2.addComponent(label); if ("Price Allowance/Charge Reason".equals(propertyId)) field.setCaption("Reason"); else if ("Price Allowance/Charge Multiplier Factor".equals(propertyId)) field.setCaption("Multiplier Factor"); else if ("Price Allowance/Charge Amount".equals(propertyId)) field.setCaption("Amount"); else if ("Price Allowance/Charge Base Amount".equals(propertyId)) field.setCaption("Base Amount"); f2.addComponent(field); } else { //for price amount and base quantity f2.addComponent(field); } } }; return form; }
From source file:au.org.scoutmaster.views.ContactView.java
@Override protected AbstractLayout getAdvancedSearchLayout() { final VerticalLayout advancedSearchLayout = new VerticalLayout(); advancedSearchLayout.setSpacing(true); final HorizontalLayout tagSearchLayout = new HorizontalLayout(); this.tagSearchField = new TagField("Search Tags", true); tagSearchLayout.addComponent(this.tagSearchField); tagSearchLayout.setSizeFull();/*from w w w . j a v a 2s. c om*/ advancedSearchLayout.addComponent(tagSearchLayout); final HorizontalLayout stringSearchLayout = new HorizontalLayout(); stringSearchLayout.addComponent(this.searchField); stringSearchLayout.setWidth("100%"); advancedSearchLayout.addComponent(stringSearchLayout); final Button searchButton = new Button("Search"); final Action1<ClickEvent> searchClickAction = new SearchClickAction(); ButtonEventSource.fromActionOf(searchButton).subscribe(searchClickAction); advancedSearchLayout.addComponent(searchButton); advancedSearchLayout.setComponentAlignment(searchButton, Alignment.MIDDLE_RIGHT); return advancedSearchLayout; }
From source file:br.com.anteros.mobileserver.app.form.ExecuteForm.java
License:Apache License
private void createForm() { if (actionSynchronism.getItems() != null) { Label lblTitle = new Label("Parmetros de execuo Ao " + actionSynchronism.getName() + " (" + actionSynchronism.getId() + ")"); lblTitle.setStyleName("h2 color"); lblTitle.setImmediate(false);// w w w. ja va 2 s . c om addComponent(lblTitle); setComponentAlignment(lblTitle, Alignment.TOP_LEFT); Synchronism synchronism = actionSynchronism.getItems().iterator().next(); executeForm = new Form(); fields.clear(); ParameterSynchronism[] parameters = null; if (synchronism instanceof TableSynchronism) parameters = ((TableSynchronism) synchronism).getParameters(); if (synchronism instanceof ProcedureSynchronism) parameters = ((ProcedureSynchronism) synchronism).getParameters(); for (ParameterSynchronism param : parameters) { if (param.getParameterType().intValue() == ParameterSynchronism.INPUT || param.getParameterType().intValue() == ParameterSynchronism.SUBSTITUITION) { String value = FieldTypes.getFieldTypes().get(param.getParameterDataType().intValue() + ""); if (value != null) { if (FieldTypes.UNKNOW.equalsIgnoreCase(value)) { TextField field = new TextField(); field.setCaption(param.getName()); field.setWidth("400px"); executeForm.addField(param.getName(), field); fields.add(field); } else if (FieldTypes.INTEGER.equalsIgnoreCase(value)) { TextField field = new TextField(); field.setCaption(param.getName()); field.setWidth("150px"); field.setRequired(true); field.setRequiredError("Informe o valor para o campo " + param.getName()); executeForm.addField(param.getName(), field); fields.add(field); } else if (FieldTypes.VARCHAR.equalsIgnoreCase(value)) { TextField field = new TextField(); field.setCaption(param.getName()); field.setWidth("400px"); field.setRequired(true); field.setRequiredError("Informe o valor para o campo " + param.getName()); executeForm.addField(param.getName(), field); fields.add(field); } else if (FieldTypes.FLOAT.equalsIgnoreCase(value)) { TextField field = new TextField(); field.setCaption(param.getName()); field.setWidth("150px"); field.setRequired(true); field.setRequiredError("Informe o valor para o campo " + param.getName()); executeForm.addField(param.getName(), field); fields.add(field); } else if (FieldTypes.NUMERIC.equalsIgnoreCase(value)) { TextField field = new TextField(); field.setCaption(param.getName()); field.setWidth("150px"); field.setRequired(true); field.setRequiredError("Informe o valor para o campo " + param.getName()); executeForm.addField(param.getName(), field); fields.add(field); } else if (FieldTypes.DATE.equalsIgnoreCase(value)) { PopupDateField field = new PopupDateField(); field.setCaption(param.getName()); field.setWidth("150px"); field.setRequired(true); field.setRequiredError("Informe o valor para o campo " + param.getName()); field.setResolution(PopupDateField.RESOLUTION_DAY); executeForm.addField(param.getName(), field); fields.add(field); } else if (FieldTypes.TIME.equalsIgnoreCase(value)) { TextField field = new TextField(); field.setCaption(param.getName()); field.setWidth("150px"); field.setRequired(true); field.setRequiredError("Informe o valor para o campo " + param.getName()); executeForm.addField(param.getName(), field); fields.add(field); } else if (FieldTypes.TIMESTAMP.equalsIgnoreCase(value)) { TextField field = new TextField(); field.setCaption(param.getName()); field.setWidth("150px"); field.setRequired(true); field.setRequiredError("Informe o valor para o campo " + param.getName()); executeForm.addField(param.getName(), field); fields.add(field); } } } } panelForm = new Panel(); panelForm.setHeight("100%"); panelForm.setWidth("100%"); panelForm.setScrollable(true); addComponent(panelForm); executeForm.setImmediate(true); executeForm.setWidth("100%"); panelForm.addComponent(executeForm); executeCommit = new CheckBox("Executar COMMIT no final do processo?"); addComponent(executeCommit); HorizontalLayout buttons = new HorizontalLayout(); buttons.setImmediate(false); buttons.setWidth("600px"); buttons.setHeight("-1px"); buttons.setMargin(false); buttons.setSpacing(true); addComponent(buttons); btnExecute = new Button(); btnExecute.setCaption("Executar"); btnExecute.setIcon(new ThemeResource("icons/16/run.png")); btnExecute.addListener(clickListener); buttons.addComponent(btnExecute); buttons.setComponentAlignment(btnExecute, Alignment.MIDDLE_RIGHT); buttons.setExpandRatio(btnExecute, 1); btnClose = new Button(); btnClose.setCaption("Fechar"); btnClose.setIcon(new ThemeResource("icons/16/doorOut.png")); btnClose.addListener(clickListener); buttons.addComponent(btnClose); buttons.setComponentAlignment(btnClose, Alignment.MIDDLE_RIGHT); buttons.setMargin(true, false, true, false); addComponent(buttons); pageControl = new TabSheet(); pageControl.setImmediate(true); pageControl.setWidth("100.0%"); pageControl.setHeight("100.0%"); textPanel = new Panel(); textPanel.setImmediate(true); textPanel.setWidth("100%"); textPanel.setHeight("100%"); pageControl.addTab(textPanel, "Resultado", null); addComponent(pageControl); setExpandRatio(pageControl, 1.0f); } }
From source file:br.com.anteros.mobileserver.util.UserMessages.java
License:Apache License
public Window confirm(String title, String message, String okTitle, String cancelTitle, Button.ClickListener listener) { if (title == null) { title = CONFIRM_OK_TITLE;/*from ww w . j a v a 2s . c om*/ } if (cancelTitle == null) { cancelTitle = CONFIRM_CANCEL_TITLE; } if (okTitle == null) { okTitle = CONFIRM_OK_TITLE; } final Window confirm = new Window(title); this.confirm = confirm; win.addWindow(confirm); confirm.addListener(new Window.CloseListener() { private static final long serialVersionUID = 1971800928047045825L; public void windowClose(CloseEvent ce) { Object data = ce.getWindow().getData(); if (data != null) { try { } catch (Exception exception) { error("Unhandled Exception", exception); } } } }); int chrW = 5; int chrH = 15; int txtWidth = Math.max(250, Math.min(350, message.length() * chrW)); int btnHeight = 25; int vmargin = 100; int hmargin = 40; int txtHeight = 2 * chrH * (message.length() * chrW) / txtWidth; confirm.setWidth((txtWidth + hmargin) + "px"); confirm.setHeight((vmargin + txtHeight + btnHeight) + "px"); confirm.getContent().setSizeFull(); confirm.center(); confirm.setModal(true); Label text = new Label(message); text.setWidth("100%"); text.setHeight("100%"); HorizontalLayout buttons = new HorizontalLayout(); buttons.setHeight(btnHeight + 5 + "px"); buttons.setWidth("100%"); buttons.setSpacing(true); buttons.setMargin(false); Button cancel = new Button(cancelTitle, listener); cancel.setIcon(new ThemeResource("icons/16/no.png")); cancel.setData(USER_CONFIRM_CANCEL); cancel.setClickShortcut(KeyCode.ESCAPE); Button ok = new Button(okTitle, listener); ok.setIcon(new ThemeResource("icons/16/yes.png")); ok.setData(USER_CONFIRM_OK); ok.setClickShortcut(KeyCode.ENTER); buttons.addComponent(ok); buttons.setExpandRatio(ok, 1); buttons.setComponentAlignment(ok, Alignment.MIDDLE_RIGHT); buttons.addComponent(cancel); buttons.setComponentAlignment(cancel, Alignment.MIDDLE_RIGHT); confirm.addComponent(text); confirm.addComponent(buttons); ((VerticalLayout) confirm.getContent()).setExpandRatio(text, 1f); confirm.setResizable(false); return confirm; }
From source file:com.aaron.mbpet.views.users.UserEditor.java
License:Apache License
public UserEditor(Item personItem, String lableText, boolean mode) { this.editMode = mode; // this.setModal(true); center();//from w w w .j a va 2s .c om setResizable(true); setClosable(true); setModal(true); // setSizeUndefined(); setWidth(25, Unit.EM); this.currsessionuser = ((MbpetUI) UI.getCurrent()).getSessionUser(); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); this.personItem = personItem; editorForm = new Form(); editorForm.setFormFieldFactory(this); editorForm.setBuffered(true); editorForm.setImmediate(true); editorForm.setItemDataSource(personItem, Arrays.asList("firstname", "lastname", "email", "username", "password", "organization")); //buttons saveButton = new Button("Save", this); saveButton.setClickShortcut(KeyCode.ENTER); cancelButton = new Button("Cancel", this); saveButton.addStyleName(ValoTheme.BUTTON_PRIMARY); HorizontalLayout buttons = new HorizontalLayout(); buttons.setWidth("100%"); buttons.addComponents(saveButton, cancelButton); buttons.setComponentAlignment(saveButton, Alignment.BOTTOM_LEFT); buttons.setComponentAlignment(cancelButton, Alignment.BOTTOM_RIGHT); // editorForm.getFooter().addComponent(buttons); // editorForm.getFooter().addComponent(cancelButton); layout.addComponent(new Label("<h3>" + lableText + "</h3>", ContentMode.HTML)); layout.addComponent(editorForm); layout.setComponentAlignment(editorForm, Alignment.MIDDLE_CENTER); layout.addComponent(buttons); setContent(layout); //editorForm setCaption(buildCaption()); }
From source file:com.application.modules.commercial.ClientListView.java
public void init() { //Recherche TextField rech = new ComboBox("Rechercher un Client :"); this.addComponent(rech); this.setComponentAlignment(rech, Alignment.TOP_RIGHT); //Panels//www.j ava2 s .c o m HorizontalLayout panels = new HorizontalLayout(); panels.setHeight("100%"); panels.setWidth("100%"); Panel panel_liste = new Panel("Liste des Clients"); Panel panel_license = new Panel("Liste des licenses"); panels.addComponent(panel_liste); panels.addComponent(panel_license); this.addComponent(panels); //Intervention Liste table Client_liste = new Table(); Client_liste.setHeight("550px"); License_liste = new Table(); License_liste.setHeight("550px"); Client_liste.setWidth("100%"); License_liste.setWidth("100%"); // selectable Client_liste.setSelectable(true); Client_liste.setMultiSelect(false); Client_liste.setImmediate(true); License_liste.setSelectable(true); License_liste.setMultiSelect(false); License_liste.setImmediate(true); // turn on column reordering and collapsing Client_liste.setColumnReorderingAllowed(true); Client_liste.setColumnCollapsingAllowed(true); License_liste.setColumnReorderingAllowed(true); License_liste.setColumnCollapsingAllowed(true); //Client Table Client_liste.addContainerProperty("Num", String.class, null); Client_liste.addContainerProperty("Nom client", String.class, null); Client_liste.addContainerProperty("Contact", String.class, null); Client_liste.addContainerProperty("Adresse", String.class, null); Client_liste.addContainerProperty("Tlephone", String.class, null); //License Table License_liste.addContainerProperty("Num", String.class, null); License_liste.addContainerProperty("Application", String.class, null); License_liste.addContainerProperty("Date Expiration", Date.class, null); panel_liste.addComponent(Client_liste); panel_license.addComponent(License_liste); rech.setImmediate(true); Property.ValueChangeListener listener = new Property.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { presenter.load_ClientListe(); } }; Client_liste.addListener(new ItemClickEvent.ItemClickListener() { @Override public void itemClick(ItemClickEvent itemClickEvent) { System.out.println(itemClickEvent.getItemId().toString()); presenter.load_LicenseListe(itemClickEvent.getItemId()); } }); rech.addListener(listener); //Class Layout properties this.setWidth("100%"); this.setMargin(true); this.setSpacing(true); presenter.load_ClientListe(); presenter.list_client(); }
From source file:com.cavisson.gui.dashboard.components.controls.Accordions.java
License:Apache License
public Accordions() { setMargin(true);/*ww w . j av a2s.c om*/ Label h1 = new Label("Accordions"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.setSpacing(true); row.setWidth("100%"); addComponent(row); row.addComponent(getAccordion("Normal")); Accordion ac = getAccordion("Borderless"); ac.addStyleName("borderless"); row.addComponent(ac); }
From source file:com.cavisson.gui.dashboard.components.controls.CommonParts.java
License:Apache License
Panel windows() { Panel p = new Panel("Dialogs"); VerticalLayout content = new VerticalLayout() { final Window win = new Window("Window Caption"); String prevHeight = "300px"; boolean footerVisible = true; boolean autoHeight = false; boolean tabsVisible = false; boolean toolbarVisible = false; boolean footerToolbar = false; boolean toolbarLayout = false; String toolbarStyle = null; VerticalLayout windowContent() { VerticalLayout root = new VerticalLayout(); if (toolbarVisible) { MenuBar menuBar = MenuBars.getToolBar(); menuBar.setSizeUndefined(); menuBar.setStyleName(toolbarStyle); Component toolbar = menuBar; if (toolbarLayout) { menuBar.setWidth(null); HorizontalLayout toolbarLayout = new HorizontalLayout(); toolbarLayout.setWidth("100%"); toolbarLayout.setSpacing(true); Label label = new Label("Tools"); label.setSizeUndefined(); toolbarLayout.addComponents(label, menuBar); toolbarLayout.setExpandRatio(menuBar, 1); toolbarLayout.setComponentAlignment(menuBar, Alignment.TOP_RIGHT); toolbar = toolbarLayout; }/*from w w w . j av a2 s .c o m*/ toolbar.addStyleName("v-window-top-toolbar"); root.addComponent(toolbar); } Component content = null; if (tabsVisible) { TabSheet tabs = new TabSheet(); tabs.setSizeFull(); VerticalLayout l = new VerticalLayout(); l.addComponent(new Label( "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>", ContentMode.HTML)); l.setMargin(true); tabs.addTab(l, "Selected"); tabs.addTab(new Label(" ", ContentMode.HTML), "Another"); tabs.addTab(new Label(" ", ContentMode.HTML), "One more"); tabs.addStyleName("padded-tabbar"); tabs.addSelectedTabChangeListener(new SelectedTabChangeListener() { @Override public void selectedTabChange(final SelectedTabChangeEvent event) { try { Thread.sleep(600); } catch (InterruptedException e) { e.printStackTrace(); } } }); content = tabs; } else if (!autoHeight) { Panel p = new Panel(); p.setSizeFull(); p.addStyleName("borderless"); if (!toolbarVisible || !toolbarLayout) { p.addStyleName("scroll-divider"); } VerticalLayout l = new VerticalLayout(); l.addComponent(new Label( "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>", ContentMode.HTML)); l.setMargin(true); p.setContent(l); content = p; } else { content = new Label( "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>", ContentMode.HTML); root.setMargin(true); } root.addComponent(content); if (footerVisible) { HorizontalLayout footer = new HorizontalLayout(); footer.setWidth("100%"); footer.setSpacing(true); footer.addStyleName("v-window-bottom-toolbar"); Label footerText = new Label("Footer text"); footerText.setSizeUndefined(); Button ok = new Button("OK"); ok.addStyleName("primary"); Button cancel = new Button("Cancel"); footer.addComponents(footerText, ok, cancel); footer.setExpandRatio(footerText, 1); if (footerToolbar) { MenuBar menuBar = MenuBars.getToolBar(); menuBar.setStyleName(toolbarStyle); menuBar.setWidth(null); footer.removeAllComponents(); footer.addComponent(menuBar); } root.addComponent(footer); } if (!autoHeight) { root.setSizeFull(); root.setExpandRatio(content, 1); } return root; } { setSpacing(true); setMargin(true); win.setWidth("380px"); win.setHeight(prevHeight); win.setClosable(false); win.setResizable(false); win.setContent(windowContent()); win.setCloseShortcut(KeyCode.ESCAPE, null); Command optionsCommand = new Command() { @Override public void menuSelected(final MenuItem selectedItem) { if (selectedItem.getText().equals("Footer")) { footerVisible = selectedItem.isChecked(); } if (selectedItem.getText().equals("Auto Height")) { autoHeight = selectedItem.isChecked(); if (!autoHeight) { win.setHeight(prevHeight); } else { prevHeight = win.getHeight() + win.getHeightUnits().toString(); win.setHeight(null); } } if (selectedItem.getText().equals("Tabs")) { tabsVisible = selectedItem.isChecked(); } if (selectedItem.getText().equals("Top")) { toolbarVisible = selectedItem.isChecked(); } if (selectedItem.getText().equals("Footer")) { footerToolbar = selectedItem.isChecked(); } if (selectedItem.getText().equals("Top layout")) { toolbarLayout = selectedItem.isChecked(); } if (selectedItem.getText().equals("Borderless")) { toolbarStyle = selectedItem.isChecked() ? "borderless" : null; } win.setContent(windowContent()); } }; MenuBar options = new MenuBar(); options.setCaption("Content"); options.addItem("Auto Height", optionsCommand).setCheckable(true); options.addItem("Tabs", optionsCommand).setCheckable(true); MenuItem option = options.addItem("Footer", optionsCommand); option.setCheckable(true); option.setChecked(true); options.addStyleName("small"); addComponent(options); options = new MenuBar(); options.setCaption("Toolbars"); options.addItem("Footer", optionsCommand).setCheckable(true); options.addItem("Top", optionsCommand).setCheckable(true); options.addItem("Top layout", optionsCommand).setCheckable(true); options.addItem("Borderless", optionsCommand).setCheckable(true); options.addStyleName("small"); addComponent(options); Command optionsCommand2 = new Command() { @Override public void menuSelected(final MenuItem selectedItem) { if (selectedItem.getText().equals("Caption")) { win.setCaption(selectedItem.isChecked() ? "Window Caption" : null); } else if (selectedItem.getText().equals("Closable")) { win.setClosable(selectedItem.isChecked()); } else if (selectedItem.getText().equals("Resizable")) { win.setResizable(selectedItem.isChecked()); } else if (selectedItem.getText().equals("Modal")) { win.setModal(selectedItem.isChecked()); } } }; options = new MenuBar(); options.setCaption("Options"); MenuItem caption = options.addItem("Caption", optionsCommand2); caption.setCheckable(true); caption.setChecked(true); options.addItem("Closable", optionsCommand2).setCheckable(true); options.addItem("Resizable", optionsCommand2).setCheckable(true); options.addItem("Modal", optionsCommand2).setCheckable(true); options.addStyleName("small"); addComponent(options); final Button show = new Button("Open Window", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { getUI().addWindow(win); win.center(); win.focus(); event.getButton().setEnabled(false); } }); show.addStyleName("primary"); addComponent(show); final CheckBox hidden = new CheckBox("Hidden"); hidden.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { win.setVisible(!hidden.getValue()); } }); addComponent(hidden); win.addCloseListener(new CloseListener() { @Override public void windowClose(final CloseEvent e) { show.setEnabled(true); } }); } }; p.setContent(content); return p; }
From source file:com.cavisson.gui.dashboard.components.controls.Panels.java
License:Apache License
public Panels() { setMargin(true);//from w w w . j a v a 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); }