List of usage examples for com.vaadin.ui HorizontalLayout addComponent
@Override public void addComponent(Component c)
From source file:com.peergreen.webconsole.scope.system.internal.service.ServiceViewer.java
License:Open Source License
private void initHeader() { HorizontalLayout header = new HorizontalLayout(); header.setWidth("100%"); header.setSpacing(true);//from w ww .j a v a 2 s . co m header.setMargin(true); Label title = new Label("OSGi Services"); title.addStyleName("h1"); title.setSizeUndefined(); header.addComponent(title); header.setComponentAlignment(title, Alignment.MIDDLE_LEFT); final TextField filter = new TextField(); filter.addTextChangeListener(new FieldEvents.TextChangeListener() { @Override public void textChange(final FieldEvents.TextChangeEvent event) { data.removeAllContainerFilters(); String trimmed = event.getText().trim(); Container.Filter or = new Or(new SimpleStringFilter(SERVICE_ID_COLUMN, trimmed, true, false), new InterfacesFilter(trimmed), new BundleFilter(trimmed), new ServicePropertiesFilter(trimmed)); data.addContainerFilter(or); } }); filter.setInputPrompt("Filter"); filter.addShortcutListener(new ShortcutListener("Clear", ShortcutAction.KeyCode.ESCAPE, null) { @Override public void handleAction(Object sender, Object target) { filter.setValue(""); data.removeAllContainerFilters(); } }); header.addComponent(filter); header.setExpandRatio(filter, 1); header.setComponentAlignment(filter, Alignment.MIDDLE_LEFT); // Store the header in the vertical layout (this) addComponent(header); }
From source file:com.peergreen.webconsole.scope.system.internal.shell.ShellConsoleView.java
License:Open Source License
private void initHeader() { HorizontalLayout header = new HorizontalLayout(); header.setWidth("100%"); header.setSpacing(true);/*w w w . j a v a 2s. c o m*/ header.setMargin(true); Label title = new Label("Shell Console"); title.addStyleName("h1"); title.setSizeUndefined(); header.addComponent(title); header.setComponentAlignment(title, Alignment.MIDDLE_LEFT); // Store the header in the vertical layout (this) addComponent(header); }
From source file:com.peergreen.webconsole.vaadin.DefaultWindow.java
License:Open Source License
/** * Create a default window//from w ww .j a va 2s. c om * @param caption window caption * @param content window content. Vaadin component * @param footerButtons list of buttons in footer */ public DefaultWindow(String caption, Component content, Button... footerButtons) { setCaption(caption); setClosable(false); setResizable(false); addStyleName("edit-dashboard"); VerticalLayout main = new VerticalLayout(); main.setSpacing(true); main.setMargin(true); main.setStyleName("default-window"); content.addStyleName("default-window-content"); main.addComponent(content); HorizontalLayout footer = new HorizontalLayout(); footer.setStyleName("footer"); footer.setWidth("100%"); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.setMargin(true); for (Button button : footerButtons) { buttons.addComponent(button); } footer.addComponent(buttons); footer.setComponentAlignment(buttons, Alignment.MIDDLE_RIGHT); main.addComponent(footer); setContent(main); }
From source file:com.peter.vaadin.components.vaadin.chart.timeline.Monitor.java
public Monitor() { // Create the container ds = new IndexedContainer(); // Add the required property ids, we use the default ones here ds.addContainerProperty(Timeline.PropertyId.TIMESTAMP, Date.class, null); ds.addContainerProperty(Timeline.PropertyId.VALUE, Float.class, 0f); // Create a timeline to display data timeline = new Timeline("Monitor"); timeline.setImmediate(true);//from ww w . ja va 2s.com timeline.addGraphDataSource(ds); timeline.setSizeFull(); timeline.setBrowserSelectionLock(false); timeline.setVerticalAxisRange(0f, 110f); timeline.setZoomLevelsVisible(false); timeline.setDateSelectVisible(false); timeline.setGraphOutlineThickness(4); timeline.setGraphFillColor(ds, new SolidColor(0, 30, 220, 128)); timeline.setGraphOutlineColor(ds, SolidColor.RED); addComponent(timeline); HorizontalLayout controls = new HorizontalLayout(); controls.setSpacing(true); addComponent(controls); ProgressIndicator pi = new ProgressIndicator(); pi.setIndeterminate(true); pi.setPollingInterval(1000); pi.setHeight("0px"); pi.setWidth("0px"); controls.addComponent(pi); final Button start = new Button("Start updates", new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { updateTimer.cancel(); } catch (Exception e) { } updateTimer = new Timer(); updateTimer.scheduleAtFixedRate(new TimerTask() { public void run() { updateDataContainer(); } }, new Date(), 1000L); } }); controls.addComponent(start); Button stop = new Button("Stop updates", new Button.ClickListener() { public void buttonClick(ClickEvent event) { updateTimer.cancel(); } }); controls.addComponent(stop); CheckBox lock = new CheckBox("Selection lock", false); lock.setImmediate(true); lock.addListener(new Property.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { timeline.setBrowserSelectionLock((Boolean) event.getProperty().getValue()); } }); controls.addComponent(lock); setExpandRatio(timeline, 1); }
From source file:com.peter.vaadin.components.vaadin.chart.timeline.MyTimelineDemo.java
public MyTimelineDemo() { timeline = new Timeline("My graph"); timeline.setSizeFull();/*from w w w . j a v a 2s . c o m*/ timeline.setVerticalAxisRange(-1f, 2f); timeline.setZoomLevelsVisible(false); timeline.setDateSelectVisible(false); // Create the data sources firstDataSource = createGraphDataSource(); datasourcesList.add(firstDataSource); final Container.Indexed markerDataSource = createMarkerDataSource(); final Container.Indexed eventDataSource = createEventDataSource(); // Add our data sources timeline.addGraphDataSource(firstDataSource, Timeline.PropertyId.TIMESTAMP, Timeline.PropertyId.VALUE); // Markers and events timeline.setMarkerDataSource(markerDataSource, Timeline.PropertyId.TIMESTAMP, Timeline.PropertyId.CAPTION, Timeline.PropertyId.VALUE); timeline.setEventDataSource(eventDataSource, Timeline.PropertyId.TIMESTAMP, Timeline.PropertyId.CAPTION); // Set the caption of the graph timeline.setGraphLegend(firstDataSource, "Our cool graph"); // Set the color of the graph timeline.setGraphOutlineColor(firstDataSource, SolidColor.RED); // Set the fill color of the graph timeline.setGraphFillColor(firstDataSource, new SolidColor(255, 0, 0, 128)); // Set the width of the graph timeline.setGraphOutlineThickness(1); // Set the color of the browser graph timeline.setBrowserOutlineColor(firstDataSource, SolidColor.BLACK); // Set the fill color of the graph timeline.setBrowserFillColor(firstDataSource, new SolidColor(0, 0, 0, 128)); // Add some zoom levels timeline.addZoomLevel("Day", 86400000L); timeline.addZoomLevel("Week", 7 * 86400000L); timeline.addZoomLevel("Month", 2629743830L); // Listen to click events from events timeline.addListener(new Timeline.EventClickListener() { @Override public void eventClick(EventButtonClickEvent event) { Item item = eventDataSource.getItem(event.getItemIds().iterator().next()); Date sunday = (Date) item.getItemProperty(Timeline.PropertyId.TIMESTAMP).getValue(); SimpleDateFormat formatter = new SimpleDateFormat("EEE, MMM d, ''yy"); Notification.show(formatter.format(sunday)); } }); addComponent(timeline); HorizontalLayout addDateForm = new HorizontalLayout(); final DateField dateField = new DateField(); dateField.setImmediate(true); addDateForm.addComponent(dateField); final TextField valueField = new TextField(); valueField.setImmediate(true); addDateForm.addComponent(valueField); Button addBtn = new Button("Add", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { java.util.Date d = dateField.getValue(); Date date = new Date(d.getTime()); float value = Float.valueOf(valueField.getValue().toString()); // Create a point in time Item item = firstDataSource.addItem(date.getTime()); if (item == null) { item = firstDataSource.getItem(date.getTime()); } // Set the timestamp property item.getItemProperty(Timeline.PropertyId.TIMESTAMP).setValue(date); // Set the value property item.getItemProperty(Timeline.PropertyId.VALUE).setValue(value); } }); addDateForm.addComponent(addBtn); addComponent(addDateForm); Button addGraphDataSource = new Button("Add graph data source", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Container.Indexed ds = createGraphDataSource(); datasourcesList.add(ds); timeline.addGraphDataSource(ds); timeline.setGraphFillColor(ds, SolidColor.BLACK); } }); addComponent(addGraphDataSource); Button removeGraphDataSource = new Button("Remove graph data source", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { if (datasourcesList.size() > 1) { Container.Indexed ds = datasourcesList.get(datasourcesList.size() - 1); timeline.removeGraphDataSource(ds); datasourcesList.remove(ds); } } }); addComponent(removeGraphDataSource); CheckBox stacked = new CheckBox("Stacked graphs", false); stacked.setImmediate(true); stacked.addListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { timeline.setGraphStacking((Boolean) event.getProperty().getValue()); } }); addComponent(stacked); CheckBox lock = new CheckBox("Selection lock", true); lock.setImmediate(true); lock.addListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { timeline.setBrowserSelectionLock((Boolean) event.getProperty().getValue()); } }); addComponent(lock); setExpandRatio(timeline, 1); }
From source file:com.pms.component.ganttchart.DemoUI.java
License:Apache License
private void openStepEditor(AbstractStep step) { final Window win = new Window("Step Editor"); win.setResizable(false);//from w w w.ja v a 2s . c o 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); final NativeSelect parentStepSelect = new NativeSelect("Parent Step"); parentStepSelect.setEnabled(false); if (!gantt.getSteps().contains(step)) { // new step parentStepSelect.setEnabled(true); for (Step parentStepCanditate : gantt.getSteps()) { parentStepSelect.addItem(parentStepCanditate); parentStepSelect.setItemCaption(parentStepCanditate, parentStepCanditate.getCaption()); if (step instanceof SubStep) { if (parentStepCanditate.getSubSteps().contains(step)) { parentStepSelect.setValue(parentStepCanditate); parentStepSelect.setEnabled(false); break; } } } } parentStepSelect.setVisible(false); hidden.add(parentStepSelect); TextField bgField = new TextField("Background color"); bgField.setNullRepresentation(""); group.bind(bgField, "backgroundColor"); bgField.setVisible(false); hidden.add(bgField); 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(parentStepSelect); content.addComponent(bgField); 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) { try { group.commit(); AbstractStep step = ((BeanItem<AbstractStep>) group.getItemDataSource()).getBean(); gantt.markStepDirty(step); if (parentStepSelect.isEnabled() && parentStepSelect.getValue() != null) { SubStep subStep = addSubStep(parentStepSelect, step); step = subStep; } if (step instanceof Step && !gantt.getSteps().contains(step)) { gantt.addStep((Step) step); } if (ganttListener != null && step instanceof Step) { ganttListener.stepModified((Step) step); } win.close(); } catch (CommitException e) { Notification.show("Commit failed", e.getMessage(), Type.ERROR_MESSAGE); e.printStackTrace(); } } private SubStep addSubStep(final NativeSelect parentStepSelect, AbstractStep dataSource) { SubStep subStep = new SubStep(); subStep.setCaption(dataSource.getCaption()); subStep.setCaptionMode(dataSource.getCaptionMode()); subStep.setStartDate(dataSource.getStartDate()); subStep.setEndDate(dataSource.getEndDate()); subStep.setBackgroundColor(dataSource.getBackgroundColor()); subStep.setDescription(dataSource.getDescription()); subStep.setStyleName(dataSource.getStyleName()); ((Step) parentStepSelect.getValue()).addSubStep(subStep); return subStep; } }); Button cancel = new Button("Cancel", new ClickListener() { @Override public void buttonClick(ClickEvent event) { group.discard(); win.close(); } }); Button delete = new Button("Delete", new ClickListener() { @Override public void buttonClick(ClickEvent event) { AbstractStep step = ((BeanItem<AbstractStep>) group.getItemDataSource()).getBean(); if (step instanceof SubStep) { SubStep substep = (SubStep) step; substep.getOwner().removeSubStep(substep); } else { gantt.removeStep((Step) step); if (ganttListener != null) { ganttListener.stepDeleted((Step) step); } } win.close(); } }); buttons.addComponent(ok); buttons.addComponent(cancel); buttons.addComponent(delete); win.setClosable(true); DashboardUI.getCurrent().getUI().addWindow(win); }
From source file:com.purebred.core.view.CrudResults.java
License:Open Source License
@PostConstruct @Override//from w ww.ja va 2 s .c o m public void postConstruct() { super.postConstruct(); getResultsTable().setMultiSelect(true); HorizontalLayout crudButtons = new HorizontalLayout(); crudButtons.setMargin(false); crudButtons.setSpacing(true); newButton = new Button(uiMessageSource.getMessage("entityResults.new"), this, "create"); newButton.setDescription(uiMessageSource.getMessage("entityResults.new.description")); newButton.setIcon(new ThemeResource("icons/16/add.png")); newButton.addStyleName("small default"); crudButtons.addComponent(newButton); viewButton = new Button(uiMessageSource.getMessage("entityResults.view"), this, "view"); viewButton.setDescription(uiMessageSource.getMessage("entityResults.view.description")); viewButton.setIcon(new ThemeResource("icons/16/view.png")); viewButton.setEnabled(false); viewButton.addStyleName("small default"); crudButtons.addComponent(viewButton); editButton = new Button(uiMessageSource.getMessage("entityResults.edit"), this, "edit"); editButton.setDescription(uiMessageSource.getMessage("entityResults.edit.description")); editButton.setIcon(new ThemeResource("icons/16/edit.png")); editButton.setEnabled(false); editButton.addStyleName("small default"); crudButtons.addComponent(editButton); deleteButton = new Button(uiMessageSource.getMessage("entityResults.delete"), this, "delete"); deleteButton.setDescription(uiMessageSource.getMessage("entityResults.delete.description")); deleteButton.setIcon(new ThemeResource("icons/16/delete.png")); deleteButton.setEnabled(false); deleteButton.addStyleName("small default"); crudButtons.addComponent(deleteButton); getResultsTable().addListener(Property.ValueChangeEvent.class, this, "selectionChanged"); // addSelectionChangedListener(this, "selectionChanged"); actionContextMenu.addAction("entityResults.view", this, "view"); actionContextMenu.addAction("entityResults.edit", this, "edit"); actionContextMenu.addAction("entityResults.delete", this, "delete"); applySecurityToCRUDButtons(); getCrudButtons().addComponent(crudButtons, 0); getCrudButtons().setComponentAlignment(crudButtons, Alignment.MIDDLE_LEFT); getResultsTable().addListener(new DoubleClickListener()); getEntityForm().addCancelListener(this, "search"); getEntityForm().addCloseListener(this, "search"); }