List of usage examples for com.vaadin.ui HorizontalLayout setVisible
@Override public void setVisible(boolean visible)
From source file:org.activiti.administrator.ui.UserEditForm.java
License:Apache License
public UserEditForm(AdminApp application) { // Set application reference this.app = application; // Enable buffering so that commit() must be called for the form. setWriteThrough(false);/*from w w w .ja va2 s . co m*/ // Set the form to act immediately on user input. setImmediate(true); // Set form size setSizeFull(); // Setup footer layout HorizontalLayout footer = new HorizontalLayout(); footer.setSpacing(true); footer.setWidth("100%"); footer.setVisible(true); // Add footer setFooter(footer); // Init buttons save = new Button(app.getMessage(Messages.Save), (ClickListener) this); close = new Button(app.getMessage(Messages.Close), (ClickListener) this); reset = new Button(app.getMessage(Messages.Reset), this, "discard"); // Set button grid GridLayout grid = new GridLayout(3, 1); grid.addComponent(save, 0, 0); grid.addComponent(reset, 1, 0); grid.addComponent(close, 2, 0); grid.setSpacing(true); // Add grid to footer footer.addComponent(grid); // Right align buttons in footer footer.setComponentAlignment(grid, Alignment.BOTTOM_RIGHT); // Get all available groups groups = new TwinColSelect(app.getMessage(Messages.Groups), app.getAdminService().getGroups()); // Set column headers groups.setLeftColumnCaption(app.getMessage(Messages.AvailableGroups)); groups.setRightColumnCaption(app.getMessage(Messages.MemberOfGroups)); // Propagate changes directly groups.setImmediate(true); // Max width groups.setWidth("100%"); // Field factory for over riding how fields are created setFormFieldFactory(new DefaultFieldFactory() { private static final long serialVersionUID = 1L; @Override public Field createField(Item item, Object propertyId, Component uiContext) { Field field = super.createField(item, propertyId, uiContext); if (propertyId.equals("id")) { TextField tf = (TextField) field; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); // Set as read-only. Changing the id will create a new user. tf.setReadOnly(true); // Set as required field // tf.setRequired(true); // Set validator example, should not be restricted in the // admin ui // tf.addValidator(new // RegexpValidator("^[a-zA-Z0-9_-]{4,20}", // app.getMessage(Messages.InvalidUsername))); // Set error message tf.setRequiredError(app.getMessage(Messages.UsernameIsMissing)); } else if (propertyId.equals("password")) { TextField tf = (TextField) field; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); // Set as required field tf.setRequired(true); // Set as secret (todo: use password field instead of text // field) tf.setSecret(true); // Set error message tf.setRequiredError(app.getMessage(Messages.PasswordIsMissing)); } else if (propertyId.equals("email")) { TextField tf = (TextField) field; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); // Set as required field, should not be required by default // in the admin ui // tf.setRequired(true); // Set error message // tf.setRequiredError(application.getMessage(Messages.EmailIsMissing)); /* Add a validator for email and make it required */ field.addValidator(new EmailValidator(app.getMessage(Messages.EmailFormatError))); } else if (propertyId.equals("firstName")) { TextField tf = (TextField) field; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); } else if (propertyId.equals("lastName")) { TextField tf = (TextField) field; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); } field.setWidth("100%"); return field; } }); }
From source file:org.axonframework.examples.addressbook.vaadin.ui.ContactForm.java
License:Apache License
private void createAndSetFooter() { HorizontalLayout footer = new HorizontalLayout(); footer.setSpacing(true);//from ww w. j a v a2s. c o m footer.addComponent(save); footer.addComponent(cancel); footer.addComponent(edit); footer.addComponent(delete); footer.setVisible(false); setFooter(footer); }
From source file:org.fossa.vaadin.ui.FossaForm.java
License:Open Source License
public FossaForm() { setWriteThrough(false);/*from www . j a va2s . co m*/ HorizontalLayout footer = new HorizontalLayout(); footer.setSpacing(true); footer.addComponent(save); footer.addComponent(cancel); footer.addComponent(edit); footer.addComponent(close); footer.setVisible(false); setFooter(footer); super.setReadOnly(true); }
From source file:org.jumpmind.metl.ui.views.DeployNavigator.java
License:Open Source License
protected HorizontalLayout buildSearchBar() { HorizontalLayout layout = new HorizontalLayout(); layout.setMargin(new MarginInfo(false, true, true, true)); layout.setWidth(100, Unit.PERCENTAGE); layout.setVisible(false); TextField search = new TextField(); search.setIcon(Icons.SEARCH);/*from ww w .ja va 2 s . co m*/ search.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); search.setWidth(100, Unit.PERCENTAGE); layout.addComponent(search); return layout; }
From source file:org.opennms.features.topology.app.internal.TopologyUI.java
License:Open Source License
/** * Gets a {@link TabSheet} view for all widgets in this manager. * //from ww w.ja v a2s.c o m * @return TabSheet */ private Component getTabSheet(WidgetManager manager, WidgetContext widgetContext) { // Use an absolute layout for the bottom panel AbsoluteLayout bottomLayout = new AbsoluteLayout(); bottomLayout.setSizeFull(); tabSheet = new TabSheet(); tabSheet.setSizeFull(); for (IViewContribution viewContrib : manager.getWidgets()) { // Create a new view instance final Component view = viewContrib.getView(m_applicationContext, widgetContext); try { m_graphContainer.getSelectionManager().addSelectionListener((SelectionListener) view); } catch (ClassCastException e) { } try { ((SelectionNotifier) view).addSelectionListener(m_graphContainer.getSelectionManager()); } catch (ClassCastException e) { } // Icon can be null tabSheet.addTab(view, viewContrib.getTitle(), viewContrib.getIcon()); // If the component supports the HasExtraComponents interface, then add the extra // components to the tab bar try { Component[] extras = ((HasExtraComponents) view).getExtraComponents(); if (extras != null && extras.length > 0) { // For any extra controls, add a horizontal layout that will float // on top of the right side of the tab panel final HorizontalLayout extraControls = new HorizontalLayout(); extraControls.setHeight(32, Unit.PIXELS); extraControls.setSpacing(true); // Add the extra controls to the layout for (Component component : extras) { extraControls.addComponent(component); extraControls.setComponentAlignment(component, Alignment.MIDDLE_RIGHT); } // Add a TabSheet.SelectedTabChangeListener to show or hide the extra controls tabSheet.addSelectedTabChangeListener(new SelectedTabChangeListener() { private static final long serialVersionUID = 6370347645872323830L; @Override public void selectedTabChange(SelectedTabChangeEvent event) { final TabSheet source = (TabSheet) event.getSource(); if (source == tabSheet) { // Bizarrely enough, getSelectedTab() returns the contained // Component, not the Tab itself. // // If the first tab was selected... if (source.getSelectedTab() == view) { extraControls.setVisible(true); } else { extraControls.setVisible(false); } } } }); // Place the extra controls on the absolute layout bottomLayout.addComponent(extraControls, "top:0px;right:5px;z-index:100"); } } catch (ClassCastException e) { } view.setSizeFull(); } // Add the tabsheet to the layout bottomLayout.addComponent(tabSheet, "top: 0; left: 0; bottom: 0; right: 0;"); return bottomLayout; }
From source file:org.opennms.features.vaadin.nodemaps.internal.NodeMapsApplication.java
License:Open Source License
/** * Gets a {@link TabSheet} view for all widgets in this manager. * /*from w w w .j a v a2 s. c o m*/ * @return TabSheet */ private Component getTabSheet() { // Use an absolute layout for the bottom panel AbsoluteLayout bottomLayout = new AbsoluteLayout(); bottomLayout.setSizeFull(); final TabSheet tabSheet = new TabSheet(); tabSheet.setSizeFull(); for (final SelectionAwareTable view : new SelectionAwareTable[] { m_alarmTable, m_nodeTable }) { // Icon can be null tabSheet.addTab(view, (view == m_alarmTable ? "Alarms" : "Nodes"), null); // If the component supports the HasExtraComponents interface, then add the extra // components to the tab bar try { final Component[] extras = ((HasExtraComponents) view).getExtraComponents(); if (extras != null && extras.length > 0) { // For any extra controls, add a horizontal layout that will float // on top of the right side of the tab panel final HorizontalLayout extraControls = new HorizontalLayout(); extraControls.setHeight(32, Unit.PIXELS); extraControls.setSpacing(true); // Add the extra controls to the layout for (final Component component : extras) { extraControls.addComponent(component); extraControls.setComponentAlignment(component, Alignment.MIDDLE_RIGHT); } // Add a TabSheet.SelectedTabChangeListener to show or hide the extra controls tabSheet.addSelectedTabChangeListener(new SelectedTabChangeListener() { @Override public void selectedTabChange(final SelectedTabChangeEvent event) { final TabSheet source = (TabSheet) event.getSource(); if (source == tabSheet) { // Bizarrely enough, getSelectedTab() returns the contained // Component, not the Tab itself. // // If the first tab was selected... if (source.getSelectedTab() == view) { extraControls.setVisible(true); } else { extraControls.setVisible(false); } } } }); // Place the extra controls on the absolute layout bottomLayout.addComponent(extraControls, "top:0px;right:5px;z-index:100"); } } catch (ClassCastException e) { } view.setSizeFull(); } // Add the tabsheet to the layout bottomLayout.addComponent(tabSheet, "top: 0; left: 0; bottom: 0; right: 0;"); return bottomLayout; }
From source file:org.tltv.gantt.demo.DemoUI.java
License:Apache License
private void openStepEditor(AbstractStep step) { final Window win = new Window("Step Editor"); win.setResizable(false);/*from w ww. j a va2s .co m*/ win.center(); final Collection<Component> hidden = new ArrayList<Component>(); BeanItem<AbstractStep> item = new BeanItem<AbstractStep>(step); final FieldGroup group = new FieldGroup(item); group.setBuffered(true); TextField captionField = new TextField("Caption"); captionField.setNullRepresentation(""); group.bind(captionField, "caption"); TextField descriptionField = new TextField("Description"); descriptionField.setNullRepresentation(""); group.bind(descriptionField, "description"); descriptionField.setVisible(false); hidden.add(descriptionField); NativeSelect captionMode = new NativeSelect("Caption Mode"); captionMode.addItem(Step.CaptionMode.TEXT); captionMode.addItem(Step.CaptionMode.HTML); group.bind(captionMode, "captionMode"); captionMode.setVisible(false); hidden.add(captionMode); CheckBox showProgress = new CheckBox("Show progress"); group.bind(showProgress, "showProgress"); showProgress.setVisible(false); hidden.add(showProgress); Slider progress = new Slider("Progress"); progress.setWidth(100, Unit.PERCENTAGE); group.bind(progress, "progress"); progress.setVisible(false); hidden.add(progress); NativeSelect predecessorSelect = new NativeSelect("Predecessor Step"); predecessorSelect.setWidth(100, Unit.PERCENTAGE); fillPredecessorCanditatesToSelect(step, predecessorSelect); predecessorSelect.setEnabled(step instanceof Step); if (step instanceof Step) { group.bind(predecessorSelect, "predecessor"); } predecessorSelect.setVisible(false); hidden.add(predecessorSelect); final NativeSelect parentStepSelect = new NativeSelect("Parent Step"); parentStepSelect.setWidth(100, Unit.PERCENTAGE); parentStepSelect.setEnabled(false); fillParentStepCanditatesToSelect(step, parentStepSelect); parentStepSelect.setVisible(false); hidden.add(parentStepSelect); HorizontalLayout colorLayout = new HorizontalLayout(); colorLayout.setWidth(100, Unit.PERCENTAGE); colorLayout.setVisible(false); hidden.add(colorLayout); final TextField bgField = new TextField("Background color"); bgField.setNullRepresentation(""); group.bind(bgField, "backgroundColor"); bgField.setEnabled(false); final ColorPicker bgColorPicker = new ColorPicker(); bgColorPicker.setPosition(300, 100); bgColorPicker.setColor(new CssColorToColorPickerConverter().convertToModel(step.getBackgroundColor())); bgColorPicker.addColorChangeListener(new ColorChangeListener() { @Override public void colorChanged(ColorChangeEvent event) { bgField.setValue(event.getColor().getCSS()); } }); colorLayout.addComponent(bgField); colorLayout.addComponent(bgColorPicker); colorLayout.setExpandRatio(bgField, 1); colorLayout.setComponentAlignment(bgColorPicker, Alignment.BOTTOM_LEFT); DateField startDate = new DateField("Start date"); startDate.setLocale(gantt.getLocale()); startDate.setTimeZone(gantt.getTimeZone()); startDate.setResolution(Resolution.SECOND); startDate.setConverter(new DateToLongConverter()); group.bind(startDate, "startDate"); DateField endDate = new DateField("End date"); endDate.setLocale(gantt.getLocale()); endDate.setTimeZone(gantt.getTimeZone()); endDate.setResolution(Resolution.SECOND); endDate.setConverter(new DateToLongConverter()); group.bind(endDate, "endDate"); CheckBox showMore = new CheckBox("Show all settings"); showMore.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { for (Component c : hidden) { c.setVisible((Boolean) event.getProperty().getValue()); } win.center(); } }); VerticalLayout content = new VerticalLayout(); content.setMargin(true); content.setSpacing(true); win.setContent(content); content.addComponent(captionField); content.addComponent(captionMode); content.addComponent(descriptionField); content.addComponent(showProgress); content.addComponent(progress); content.addComponent(predecessorSelect); content.addComponent(parentStepSelect); content.addComponent(colorLayout); content.addComponent(startDate); content.addComponent(endDate); content.addComponent(showMore); HorizontalLayout buttons = new HorizontalLayout(); content.addComponent(buttons); Button ok = new Button("Ok", new ClickListener() { @Override public void buttonClick(ClickEvent event) { commit(win, group, parentStepSelect); } }); Button cancel = new Button("Cancel", new ClickListener() { @Override public void buttonClick(ClickEvent event) { cancel(win, group); } }); Button delete = new Button("Delete", new ClickListener() { @Override public void buttonClick(ClickEvent event) { delete(win, group); } }); buttons.addComponent(ok); buttons.addComponent(cancel); buttons.addComponent(delete); win.setClosable(true); getUI().addWindow(win); }
From source file:pt.ist.vaadinframework.ui.PaginatedSorterViewer.java
License:Open Source License
private static Component makeControlsLayout() { HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true);/*from w ww. ja v a 2 s . c om*/ layout.setVisible(false); ControlVisibilityListener controlVisibilityListener = new ControlVisibilityListener(); layout.addListener((ComponentAttachListener) controlVisibilityListener); layout.addListener((ComponentDetachListener) controlVisibilityListener); return layout; }
From source file:pt.ist.vaadinframework.ui.PaginatedSorterViewer.java
License:Open Source License
public void setGrouper(Alignment position, Object[] grouperIds, boolean[] initialAscending, String[] grouperLabels) { HorizontalLayout controls = new HorizontalLayout(); controls.setSpacing(true);// w w w . ja v a2s . c o m if (grouperIds.length > 0) { controls.setVisible(true); controls.addComponent(new Label(VaadinResources.getString(COMMONS_GROUPBY_LABEL) + ":")); currentGrouper = new GroupControl(grouperIds[0], initialAscending[0], grouperLabels[0]); controls.addComponent(currentGrouper); for (int i = 1; i < grouperIds.length; i++) { controls.addComponent(new Label("|")); controls.addComponent(new GroupControl(grouperIds[i], initialAscending[i], grouperLabels[i])); } } else { controls.removeAllComponents(); controls.setVisible(false); } addControls(controls, position); }
From source file:pt.ist.vaadinframework.ui.PaginatedSorterViewer.java
License:Open Source License
public void setSorter(Alignment position, Object[] sorterIds, boolean[] initialAscending, String[] sorterLabels) {// w w w . j a va 2 s . com HorizontalLayout controls = new HorizontalLayout(); controls.setSpacing(true); if (sorterIds.length > 0) { controls.setVisible(true); controls.addComponent(new Label(VaadinResources.getString(COMMONS_SORTBY_LABEL) + ":")); currentSorter = new SorterControl(sorterIds[0], initialAscending[0], sorterLabels[0]); controls.addComponent(currentSorter); for (int i = 1; i < sorterIds.length; i++) { controls.addComponent(new Label("|")); controls.addComponent(new SorterControl(sorterIds[i], initialAscending[i], sorterLabels[i])); } } else { controls.removeAllComponents(); controls.setVisible(false); } addControls(controls, position); }