List of usage examples for com.vaadin.ui HorizontalLayout setSpacing
@Override public void setSpacing(boolean spacing)
From source file:com.peergreen.webconsole.scope.home.HomeScope.java
License:Open Source License
public HomeScope() { setSizeFull();/* ww w. ja va 2 s. c om*/ addStyleName("dashboard-view"); HorizontalLayout top = new HorizontalLayout(); top.setWidth("100%"); top.setSpacing(true); addComponent(top); Label title = new Label("Welcome to Peergreen Administration Console"); title.addStyleName("h1"); top.addComponent(title); top.setComponentAlignment(title, Alignment.MIDDLE_LEFT); top.setExpandRatio(title, 1); HorizontalLayout row1 = new HorizontalLayout(); row1.setSizeFull(); row1.setMargin(new MarginInfo(true, true, true, true)); row1.setSpacing(true); row1.addStyleName("row"); addComponent(row1); setExpandRatio(row1, 4); HorizontalLayout row2 = new HorizontalLayout(); row2.setSizeFull(); row2.setMargin(new MarginInfo(true, true, true, true)); row2.setSpacing(true); row2.addStyleName("row"); addComponent(row2); setExpandRatio(row2, 4); topLeftFrame = new FrameView(); row1.addComponent(topLeftFrame); topRightFrame = new FrameView(); row1.addComponent(topRightFrame); bottomLeftFrame = new FrameView(); row2.addComponent(bottomLeftFrame); bottomRightFrame = new FrameView(); row2.addComponent(bottomRightFrame); }
From source file:com.peergreen.webconsole.scope.system.internal.bundle.BundleTab.java
License:Open Source License
private void init() { setMargin(true);/*from www .j av a 2s .c om*/ setSpacing(true); // ---------------------------------------------------- // Title // ---------------------------------------------------- HorizontalLayout header = new HorizontalLayout(); header.setSpacing(true); header.setMargin(true); Label title = new Label(format("Bundle %d: %s (%s)", bundle.getBundleId(), getHeader(bundle, Constants.BUNDLE_NAME), bundle.getVersion())); title.addStyleName("h1"); header.addComponent(title); header.setComponentAlignment(title, Alignment.MIDDLE_LEFT); addComponent(header); // ---------------------------------------------------- // Action(s) Bar // ---------------------------------------------------- HorizontalLayout actions = new HorizontalLayout(); if (BundleHelper.isState(bundle, Bundle.INSTALLED) || BundleHelper.isState(bundle, Bundle.RESOLVED)) { Button changeState = new Button(); changeState.addClickListener(new StartBundleClickListener(bundle, notifierService)); //changeState.addStyleName("no-padding"); changeState.setCaption("Start"); changeState.setIcon(new ClassResource(getClass(), "/images/32x32/go-next.png")); actions.addComponent(changeState); } if (BundleHelper.isState(bundle, Bundle.ACTIVE)) { Button changeState = new Button(); changeState.addClickListener(new StopBundleClickListener(bundle, notifierService)); //changeState.addStyleName("no-padding"); changeState.setCaption("Stop"); changeState.setIcon(new ClassResource(getClass(), "/images/32x32/media-record.png")); actions.addComponent(changeState); } // Update Button update = new Button(); update.addClickListener(new UpdateBundleClickListener(bundle, notifierService)); //update.addStyleName("no-padding"); update.setCaption("Update"); update.setIcon(new ClassResource(getClass(), "/images/32x32/view-refresh.png")); actions.addComponent(update); // Trash Button trash = new Button(); trash.addClickListener(new UninstallBundleClickListener(bundle, notifierService)); //trash.addStyleName("no-padding"); trash.setCaption("Remove"); trash.setIcon(new ClassResource(getClass(), "/images/32x32/user-trash-full.png")); actions.addComponent(trash); addComponent(actions); setComponentAlignment(actions, Alignment.MIDDLE_RIGHT); // ---------------------------------------------------- // Standard Section // ---------------------------------------------------- Table table = new Table(); table.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN); table.setWidth("100%"); Section mainSection = new Section("Standard", table); addComponent(mainSection); table.addContainerProperty("label", Label.class, null); table.addContainerProperty("value", Label.class, null); table.addItem(new Object[] { label("Bundle ID"), label(String.valueOf(bundle.getBundleId())) }, "bundle.id"); for (Map.Entry<String, String> entry : HEADERS.entrySet()) { String value = getHeader(bundle, entry.getKey()); if (value != null) { table.addItem(new Object[] { label(entry.getValue()), label(value) }, entry.getKey()); } } table.addItem(new Object[] { label("Location"), label(bundle.getLocation()) }, "bundle.location"); Date date = new Date(bundle.getLastModified()); table.addItem(new Object[] { label("Last Modified"), label(date.toString()) }, "last.modified"); // ---------------------------------------------------- // Packages Section // ---------------------------------------------------- FilteredPackageTable exported = new FilteredPackageTable("Exported"); FilteredPackageTable imported = new FilteredPackageTable("Imported"); GridLayout packages = new GridLayout(2, 1); packages.addComponent(exported); packages.addComponent(imported); packages.setSpacing(true); packages.setWidth("100%"); Section packagesSection = new Section("Packages", packages); addComponent(packagesSection); BundleWiring wiring = bundle.adapt(BundleWiring.class); if (wiring != null) { for (BundleCapability capability : wiring.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE)) { String name = (String) capability.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE); Version version = (Version) capability.getAttributes() .get(PackageNamespace.CAPABILITY_VERSION_ATTRIBUTE); exported.addPackage(format("%s (%s)", name, version)); } for (BundleRequirement requirement : wiring.getRequirements(PackageNamespace.PACKAGE_NAMESPACE)) { String filter = requirement.getDirectives().get(PackageNamespace.REQUIREMENT_FILTER_DIRECTIVE); imported.addPackage(filter); } } // ---------------------------------------------------- // Services Section // ---------------------------------------------------- FilteredServiceTable registered = new FilteredServiceTable("Registered"); FilteredServiceTable used = new FilteredServiceTable("Used Services"); VerticalLayout services = new VerticalLayout(registered, used); services.setSpacing(true); services.setWidth("100%"); ServiceReference<?>[] registeredServices = bundle.getRegisteredServices(); if (registeredServices != null) { for (ServiceReference<?> reference : registeredServices) { registered.addService(reference); } } ServiceReference<?>[] inUseServices = bundle.getServicesInUse(); if (inUseServices != null) { for (ServiceReference<?> reference : inUseServices) { used.addService(reference); } } if (!registered.isEmpty() || !used.isEmpty()) { Section servicesSection = new Section("Services", services); addComponent(servicesSection); } // ---------------------------------------------------- // Raw Manifest Section // ---------------------------------------------------- Page.Styles styles = Page.getCurrent().getStyles(); styles.add(".monospaced-font {font-family: monospace !important; }"); Table manifest = new Table(); manifest.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN); manifest.setWidth("100%"); manifest.addStyleName("monospaced-font"); manifest.setPageLength(15); manifest.addContainerProperty("name", String.class, null); manifest.addContainerProperty("value", String.class, null); Dictionary<String, String> headers = bundle.getHeaders(); for (String key : Collections.list(headers.keys())) { manifest.addItem(new Object[] { key, headers.get(key) }, null); } Section manifestSection = new Section("Manifest", manifest); addComponent(manifestSection); }
From source file:com.peergreen.webconsole.scope.system.internal.bundle.BundleView.java
License:Open Source License
@PostConstruct public void createView() { setMargin(true);//www. ja v a 2s . c o m setSpacing(true); /* Page.Styles styles = Page.getCurrent().getStyles(); styles.add(".no-padding {padding: 0em 0em 0em 0em !important; }"); */ HorizontalLayout header = new HorizontalLayout(); // header.setWidth("100%"); header.setSpacing(true); header.setMargin(true); Label title = new Label("OSGi Bundles"); 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(BUNDLE_ID_COLUMN, trimmed, true, false), new SimpleStringFilter(BUNDLE_NAME_COLUMN, trimmed, true, false), new SimpleStringFilter(BUNDLE_SYMBOLICNAME_COLUMN, trimmed, true, false), new SimpleStringFilter(VERSION_COLUMN, trimmed, true, false), new SimpleStringFilter(PRETTY_STATE_COLUMN, trimmed, true, false)); 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); addComponent(tabSheet); table = new Table(); table.setContainerDataSource(data); table.setSizeFull(); table.setSortContainerPropertyId(BUNDLE_ID_COLUMN); table.setSortAscending(true); table.setImmediate(true); table.setColumnHeader(BUNDLE_ID_COLUMN, "Bundle ID"); table.setColumnHeader(PRETTY_NAME_COLUMN, "Bundle Name"); table.setColumnHeader(VERSION_COLUMN, "Version"); table.setColumnHeader(PRETTY_STATE_COLUMN, "State"); table.setColumnHeader("actions", "Actions"); table.setColumnWidth(BUNDLE_ID_COLUMN, 100); table.setColumnAlignment(BUNDLE_ID_COLUMN, Table.Align.CENTER); table.setColumnAlignment(PRETTY_STATE_COLUMN, Table.Align.CENTER); table.setColumnAlignment(VERSION_COLUMN, Table.Align.CENTER); table.addGeneratedColumn("actions", new Table.ColumnGenerator() { @Override public Object generateCell(final Table source, final Object itemId, final Object columnId) { HorizontalLayout layout = new HorizontalLayout(); BeanItem<BundleItem> item = (BeanItem<BundleItem>) source.getContainerDataSource().getItem(itemId); Bundle bundle = item.getBean().getBundle(); if (BundleHelper.isState(bundle, Bundle.INSTALLED) || BundleHelper.isState(bundle, Bundle.RESOLVED)) { Button changeState = new Button(); changeState.addClickListener(new StartBundleClickListener(bundle, notifierService)); //changeState.addStyleName("no-padding"); changeState.setCaption("Start"); //changeState.setIcon(new ClassResource(BundleViewer.class, "/images/go-next.png")); if (!securityManager.isUserInRole("admin")) { changeState.setDisableOnClick(true); } layout.addComponent(changeState); } if (BundleHelper.isState(bundle, Bundle.ACTIVE)) { Button changeState = new Button(); changeState.addClickListener(new StopBundleClickListener(bundle, notifierService)); //changeState.addStyleName("no-padding"); changeState.setCaption("Stop"); if (!securityManager.isUserInRole("admin")) { changeState.setDisableOnClick(true); } //changeState.setIcon(new ClassResource(BundleViewer.class, "/images/media-record.png")); layout.addComponent(changeState); } // Update Button update = new Button(); update.addClickListener(new UpdateBundleClickListener(bundle, notifierService)); //update.addStyleName("no-padding"); update.setCaption("Update"); if (!securityManager.isUserInRole("admin")) { update.setDisableOnClick(true); } //update.setIcon(new ClassResource(BundleViewer.class, "/images/view-refresh.png")); layout.addComponent(update); // Trash Button trash = new Button(); trash.addClickListener(new UninstallBundleClickListener(bundle, notifierService)); //trash.addStyleName("no-padding"); trash.setCaption("Delete"); if (!securityManager.isUserInRole("admin")) { trash.setDisableOnClick(true); } //trash.setIcon(new ClassResource(BundleViewer.class, "/images/user-trash-full.png")); layout.addComponent(trash); return layout; } }); table.setVisibleColumns(BUNDLE_ID_COLUMN, PRETTY_NAME_COLUMN, VERSION_COLUMN, PRETTY_STATE_COLUMN, "actions"); table.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override public void itemClick(final ItemClickEvent event) { if (event.isDoubleClick()) { BeanItem<BundleItem> item = (BeanItem<BundleItem>) table.getContainerDataSource() .getItem(event.getItemId()); Bundle bundle = item.getBean().getBundle(); showBundle(bundle); } } }); createBundleTracker(); tabSheet.setSizeFull(); selectedTabListener = new SelectedTabListener(uiContext.getViewNavigator()); selectedTabListener.addLocation(table, uiContext.getViewNavigator().getLocation(this.getClass().getName())); tabSheet.addSelectedTabChangeListener(selectedTabListener); tabSheet.addTab(table, "Bundles", new ClassResource(BundleView.class, "/images/22x22/user-home.png")); setExpandRatio(tabSheet, 1.5f); tabSheet.setCloseHandler(new TabSheet.CloseHandler() { @Override public void onTabClose(TabSheet tabsheet, Component tabContent) { for (Map.Entry<Long, Component> tab : openTabs.entrySet()) { if (tabContent.equals(tab.getValue())) { openTabs.remove(tab.getKey()); } } tabsheet.removeComponent(tabContent); selectedTabListener.removeLocation(tabContent); } }); }
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); header.setMargin(true);/*w w w. j a v a2s . c om*/ 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); header.setMargin(true);/*from w w w .j av a 2 s .co m*/ 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 w w . j a v a 2s . co m * @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 w w w .j ava 2 s . co m 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.piccritic.website.user.UserForm.java
public void buildLayout() { setSizeFull();/* ww w. j av a 2 s.com*/ setMargin(true); HorizontalLayout buttons = new HorizontalLayout(save, cancel); buttons.setSpacing(true); addComponents(handle, firstName, lastName, bio, password, confirmPass, license, buttons); }
From source file:com.purebred.core.view.CrudResults.java
License:Open Source License
@PostConstruct @Override/* www . j ava2s.c om*/ 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"); }
From source file:com.purebred.core.view.EntityForm.java
License:Open Source License
/** * Created the footer buttons: cancel, refresh, save * * @param footerLayout horizontal layout containing buttons */// w w w . j av a 2s. com @Override protected void createFooterButtons(HorizontalLayout footerLayout) { footerLayout.setSpacing(true); footerLayout.setMargin(true); Button cancelButton = new Button(uiMessageSource.getMessage("entityForm.cancel"), this, "cancel"); cancelButton.setDescription(uiMessageSource.getMessage("entityForm.cancel.description")); cancelButton.setIcon(new ThemeResource("icons/16/cancel.png")); cancelButton.addStyleName("small default"); footerLayout.addComponent(cancelButton); refreshButton = new Button(uiMessageSource.getMessage("entityForm.refresh"), this, "refresh"); refreshButton.setDescription(uiMessageSource.getMessage("entityForm.refresh.description")); refreshButton.setIcon(new ThemeResource("icons/16/refresh.png")); refreshButton.addStyleName("small default"); footerLayout.addComponent(refreshButton); saveAndStayOpenButton = new Button(uiMessageSource.getMessage("entityForm.saveAndStayOpen"), this, "saveAndStayOpen"); saveAndStayOpenButton.setDescription(uiMessageSource.getMessage("entityForm.save.description")); saveAndStayOpenButton.setIcon(new ThemeResource("icons/16/save.png")); saveAndStayOpenButton.addStyleName("small default"); footerLayout.addComponent(saveAndStayOpenButton); saveAndCloseButton = new Button(uiMessageSource.getMessage("entityForm.saveAndClose"), this, "saveAndClose"); saveAndCloseButton.setDescription(uiMessageSource.getMessage("entityForm.save.description")); saveAndCloseButton.setIcon(new ThemeResource("icons/16/save.png")); saveAndCloseButton.addStyleName("small default"); footerLayout.addComponent(saveAndCloseButton); }