List of usage examples for com.vaadin.ui HorizontalLayout setMargin
@Override public void setMargin(boolean enabled)
From source file:eu.eco2clouds.portal.component.apwizard.TrendWindow.java
License:Apache License
private void render() { this.center(); this.setModal(true); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true);/* w w w . j a v a 2s. c o m*/ hl.setMargin(true); hl.setSizeFull(); final InlineDateField datePicker = new InlineDateField(); datePicker.setValue(new Date()); datePicker.setImmediate(true); datePicker.setTimeZone(TimeZone.getTimeZone("UTC")); datePicker.setLocale(Locale.US); datePicker.setResolution(Resolution.MINUTE); hl.addComponent(datePicker); this.chart = new CO2PredictionChart(); chart.update(new Date(), fr_power, uk_power, de_power, duration); datePicker.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { chart.update(datePicker.getValue(), fr_power, uk_power, de_power, duration); } }); chart.addListener(new Timeline.EventClickListener() { @Override public void eventClick(Timeline.EventButtonClickEvent event) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); hl.addComponent(this.chart); hl.setComponentAlignment(datePicker, Alignment.TOP_LEFT); hl.setComponentAlignment(chart, Alignment.TOP_LEFT); hl.setExpandRatio(datePicker, 1.0f); hl.setExpandRatio(chart, 3.0f); this.setContent(hl); }
From source file:eu.eco2clouds.portal.component.EcoReport.java
License:Apache License
private void renderold() { this.setSpacing(true); this.setMargin(true); HorizontalLayout tables = new HorizontalLayout(); tables.setSpacing(true);/*w w w.j a v a 2 s .c o m*/ tables.setMargin(false); tables.addComponent(new ReducedResourceTable()); tables.addComponent(new MetricTable()); HorizontalLayout charts = new HorizontalLayout(); charts.setSpacing(true); charts.setMargin(false); TimeLineChart chart1 = new TimeLineChart(); chart1.show(this.generate()); TimeLineChart chart2 = new TimeLineChart(); chart2.show(this.generate()); charts.addComponent(chart1); charts.addComponent(chart2); this.addComponent(tables); this.addComponent(charts); }
From source file:eu.eco2clouds.portal.page.APWizardLayout.java
License:Apache License
private void render() { this.setSpacing(true); this.setMargin(true); this.setSizeFull(); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true);/*from w w w . j a v a 2 s . co m*/ hl.setMargin(false); hl.setSizeFull(); menu = new APWizardMenu(this); hl.addComponent(menu); hl.addComponent(aptext); hl.setExpandRatio(menu, 1.0f); this.addComponent(hl); Label space = new Label(""); this.addComponent(space); Label version = new Label("<hr/>ECO2Clouds Portal v." + E2CPortal.VERSION + " - (c) ECO2Clouds project 2012-2014 (<a href='http://www.eco2clouds.eu' target='_blank'>http://www.eco2clouds.eu</a>)", ContentMode.HTML); this.addComponent(version); this.setExpandRatio(hl, 1.0f); }
From source file:eu.lod2.DeleteGraphs.java
License:Apache License
public DeleteGraphs(LOD2DemoState st) { // The internal state state = st;/* w ww. j a v a 2 s . co m*/ panel = new VerticalLayout(); Label intro = new Label( "A tabular view to ease the removal of graphs. Note: data is fetched in parts to allow dealing with " + "endpoints that have very many graphs. If the component is fetching data, a spinner is " + "shown below.", Label.CONTENT_XHTML); panel.addComponent(intro); indicator = new ProgressIndicator(); indicator.setIndeterminate(true); indicator.setPollingInterval(200); indicator.setEnabled(false); panel.addComponent(indicator); Button hideButton = new Button("Hide selected graphs", new ClickListener() { public void buttonClick(ClickEvent event) { hidegraphs(event); } }); Button markButton = new Button("Mark selected graphs", new ClickListener() { public void buttonClick(ClickEvent event) { markgraphs(event); } }); Button deleteButton = new Button("Delete marked graphs", new ClickListener() { public void buttonClick(ClickEvent event) { deletegraphs(event); } }); Button invertSelection = new Button("Invert current selection", new ClickListener() { public void buttonClick(ClickEvent clickEvent) { invertSelection(); } }); Button resetButton = new Button("Restore original view", new ClickListener() { public void buttonClick(ClickEvent event) { resetTable(); } }); HorizontalLayout buttons = new HorizontalLayout(); buttons.addComponent(markButton); buttons.addComponent(deleteButton); buttons.addComponent(hideButton); buttons.addComponent(invertSelection); buttons.addComponent(resetButton); buttons.setSpacing(true); buttons.setMargin(true); panel.addComponent(buttons); HorizontalLayout searcher = new HorizontalLayout(); searcher.addComponent(new Label("Filter: ")); final TextField filter = new TextField(); filter.setWidth("400px"); filter.setInputPrompt("Enter a filter"); searcher.addComponent(filter); filter.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.LAZY); filter.setTextChangeTimeout(200); filter.setImmediate(true); filter.addListener(new FieldEvents.TextChangeListener() { public void textChange(FieldEvents.TextChangeEvent event) { String text = event.getText(); filter.setValue(text); } }); Button filterAction = new Button("Apply filter to table"); Button filterFetchAction = new Button("Fetch matching graphs"); filterAction.addListener(new ClickListener() { public void buttonClick(ClickEvent clickEvent) { selectByFilter((String) filter.getValue(), false); } }); filterFetchAction.addListener(new ClickListener() { public void buttonClick(ClickEvent clickEvent) { fetchByFilter((String) filter.getValue()); } }); searcher.addComponent(filterFetchAction); searcher.addComponent(filterAction); searcher.setSpacing(true); searcher.setMargin(true); panel.addComponent(searcher); table = new Table(""); table.setDebugId(this.getClass().getSimpleName() + "_table"); table.setWidth("100%"); table.setSelectable(true); table.setMultiSelect(true); table.setImmediate(true); table.setColumnReorderingAllowed(true); table.setColumnCollapsingAllowed(true); this.resetTable(); panel.addComponent(table); // The composition root MUST be set setCompositionRoot(panel); }
From source file:facs.components.Settings.java
License:Open Source License
private Component newDeviceGrid() { VerticalLayout devicesLayout = new VerticalLayout(); devicesLayout.setCaption("Devices"); HorizontalLayout buttonLayout = new HorizontalLayout(); Button add = new Button("Add"); add.setIcon(FontAwesome.PLUS);/*w w w.j av a2 s . co m*/ // there will now be space around the test component // components added to the test component will now not stick together but have space between // them devicesLayout.setMargin(true); devicesLayout.setSpacing(true); buttonLayout.setMargin(true); buttonLayout.setSpacing(true); add.addClickListener(new ClickListener() { /** * */ private static final long serialVersionUID = 1920052856393517754L; @Override public void buttonClick(ClickEvent event) { addNewDevice(); } }); buttonLayout.addComponent(add); BeanItemContainer<DeviceBean> devices = getDevices(); GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(devices); gpc.addGeneratedProperty("delete", new PropertyValueGenerator<String>() { /** * */ private static final long serialVersionUID = 4398909257922492690L; @Override public String getValue(Item item, Object itemId, Object propertyId) { // return FontAwesome.TRASH_O.getHtml(); // The caption return "Delete"; // The caption } @Override public Class<String> getType() { return String.class; } }); devicesGrid = new Grid(gpc); // Create a grid // devicesGrid.setWidth("100%"); devicesGrid.setSizeFull(); devicesGrid.setSelectionMode(SelectionMode.SINGLE); devicesGrid.getColumn("delete").setRenderer(new HtmlRenderer()); // Render a button that deletes the data row (item) devicesGrid.getColumn("delete") .setRenderer(new ButtonRenderer(new ClickableRenderer.RendererClickListener() { /** * */ private static final long serialVersionUID = 1217127696779125401L; @Override public void click(RendererClickEvent event) { removeDevice((DeviceBean) event.getItemId()); } })); // devicesGrid.setEditorEnabled(true); devicesLayout.addComponent(buttonLayout); devicesLayout.addComponent(devicesGrid); // TODO filtering // HeaderRow filterRow = devicesGrid.prependHeaderRow(); return devicesLayout; }
From source file:facs.components.Settings.java
License:Open Source License
private void addNewDevice() { final Window subWindow = new Window("Add Device"); FormLayout form = new FormLayout(); form.setMargin(true);/*from w w w . ja va2 s . c o m*/ final TextField name = new TextField(); name.setImmediate(true); name.addValidator(new StringLengthValidator("The name must be 1-85 letters long (Was {0}).", 1, 85, true)); name.setCaption("Name of new device"); form.addComponent(name); final TextArea description = new TextArea(); description.setImmediate(true); description.addValidator( new StringLengthValidator("The name must be 1-255 letters long (Was {0}).", 1, 255, true)); description.setCaption("Description"); form.addComponent(description); final OptionGroup restricted = new OptionGroup("Is Device restricted by operators?"); restricted.addItem("yes"); restricted.setMultiSelect(true); form.addComponent(restricted); HorizontalLayout buttons = new HorizontalLayout(); Button save = new Button("save"); buttons.addComponent(save); Button discard = new Button("discard"); discard.setDescription("discarding will abort the process of adding a new device into the databse."); buttons.addComponent(discard); buttons.setSpacing(true); form.addComponent(buttons); subWindow.setContent(form); form.setMargin(true); form.setSpacing(true); buttons.setMargin(true); buttons.setSpacing(true); // Center it in the browser window subWindow.center(); subWindow.setModal(true); subWindow.setWidth("50%"); // Open it in the UI UI.getCurrent().addWindow(subWindow); discard.addClickListener(new ClickListener() { /** * */ private static final long serialVersionUID = -5808910314649620731L; @Override public void buttonClick(ClickEvent event) { subWindow.close(); } }); save.addClickListener(new ClickListener() { /** * */ private static final long serialVersionUID = 3748395242651585005L; @Override public void buttonClick(ClickEvent event) { if (name.isValid() && description.isValid()) { Set<String> restr = (Set<String>) restricted.getValue(); int deviceId = DBManager.getDatabaseInstance().addDevice(name.getValue(), description.getValue(), (restr.size() == 1)); DeviceBean bean = new DeviceBean(deviceId, name.getValue(), description.getValue(), (restr.size() == 1)); devicesGrid.addRow(bean); } else { Notification.show("Failed to add device to database."); } } }); // DeviceBean db = new DeviceBean(0, "Device 1","some description1", false); // TODO // add to database /* * boolean added = false;//DBManager.getDatabaseInstance().addDevice(db); //TODO test //add to * grid if(added){ devicesGrid.addRow(db); }else{ //TODO log failed operation * Notification.show("Failed to add device to database.", Type.ERROR_MESSAGE); } */ }
From source file:fi.aalto.drumbeat.drumbeatUI.DrumbeatinterfaceUI.java
License:Open Source License
@SuppressWarnings("deprecation") private void createTab_Datasets() { VerticalLayout tab_datasets = new VerticalLayout(); tab_datasets.setCaption("Data sets"); tabsheet.addTab(tab_datasets);/*ww w .j a va 2s .c o m*/ tab_datasets.addComponent(datasets_tree); Link void_link = new Link("Void description of the data sets", new ExternalResource("http://drumbeat.cs.hut.fi/void.ttl")); tab_datasets.addComponent(void_link); Panel p_model = new Panel("Upload and convert an IFC file"); p_model.setWidth("900"); tab_datasets.addComponent(p_model); HorizontalLayout hor1 = new HorizontalLayout(); hor1.setSizeFull(); // Use all available space hor1.setMargin(true); p_model.setContent(hor1); VerticalLayout upload_selections = new VerticalLayout(); hor1.addComponent(upload_selections); upload_selections.addComponent(sites_tree_4upload); VerticalLayout upload_panels = new VerticalLayout(); hor1.addComponent(upload_panels); Panel p_model_file = new Panel("Upload a file"); p_model_file.setWidth("400"); upload_panels.addComponent(p_model_file); Panel p_model_url = new Panel("Upload from a URL"); p_model_url.setWidth("400"); upload_panels.addComponent(p_model_url); // Create the upload with a caption and set receiver later Upload upload = new Upload("Select a file and press Upload", drumbeat_fileReceiver); upload.addSucceededListener(drumbeat_fileReceiver); upload.addFailedListener(drumbeat_fileReceiver); p_model_file.setContent(upload); url_textField.setImmediate(true); Button button = new Button("Upload from the URL", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { drumbeat_fileReceiver.receiveFileFromURL(url_textField.getValue()); } }); HorizontalLayout url_upload = new HorizontalLayout(); url_upload.setSizeUndefined(); url_upload.addComponent(url_textField); url_upload.addComponent(button); url_upload.setSpacing(true); p_model_url.setContent(url_upload); bim_projects_selection.setInvalidAllowed(false); bim_projects_selection.setNullSelectionAllowed(false); bim_projects_selection.setNewItemsAllowed(false); bim_projects_selection.setWidth("400"); final VerticalLayout project_browser = new VerticalLayout(); bim_projects_selection.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -5188369735622627751L; public void valueChange(ValueChangeEvent event) { if (bim_projects_selection.getValue() != null) { htmlView_BIMProject(project_browser, bim_projects.get(bim_projects_selection.getValue())); } } }); tab_datasets.addComponent(bim_projects_selection); tab_datasets.addComponent(project_browser); }
From source file:fi.csc.pathway.TutkaUI.java
License:Creative Commons License
/** * Pohjelma, joka luo kyttliittymn.// www. j av a 2 s .com */ @Override protected void init(VaadinRequest request) { final String portletContextName = getPortletContextName(request); final VerticalLayout vasenpalkki = new VerticalLayout(); final HorizontalLayout layout = new HorizontalLayout(); //main final HorizontalLayout karttapalkki = new HorizontalLayout(); final HorizontalLayout lkmnext = new HorizontalLayout(); final Label hr = new Label(" ____________________", ContentMode.HTML); final Label aika = new Label("Time", ContentMode.HTML); final Label lkm = new Label("0", ContentMode.HTML); final Button next = new Button("Next"); final OptionGroup tyyppi = new OptionGroup("Type"); final OptionGroup tutka = new OptionGroup("Radar"); final OptionGroup kulma = new OptionGroup("Angle"); final OptionGroup krjet = new OptionGroup("Min vertices"); final Googlekartta gma = new Googlekartta(aika, tutka, kulma, tyyppi, krjet, portletContextName, lkm); final Tutkat tutkat = new Tutkat(); final PopupDateField enddate = new PopupDateField("To:"); final PopupDateField startdate = new PopupDateField("From:"); final GoogleMap oldComponent = gma.getOrigMap(); final GridLayout parametrit = new GridLayout(2, 2); tutkat.alusta(tutka, krjet, oldComponent); parametrit.addComponent(tutka); parametrit.addComponent(krjet); Ilmiot ilmio = new Ilmiot(tyyppi, tutka); kulma.addItem("1.5"); kulma.addItem("0.7"); kulma.addItem(Tutkat.LOW); //luostolla ei ole matalampaa kuin 0.7 kulma.setValue("1.5"); parametrit.addComponent(kulma); parametrit.addComponent(ilmio.getTyyppi()); vasenpalkki.addComponent(parametrit); Tarkista tarkista = new Tarkista(enddate, startdate); vasenpalkki.addComponent(tarkista.getstartdate()); vasenpalkki.addComponent(tarkista.getenddate()); next.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = -8146345475859196611L; public void buttonClick(ClickEvent event) { if (gma.updateMap()) { next.setEnabled(false); } } }); final Button button = new Button("Query"); button.addClickListener(new Button.ClickListener() { //Component oldC = oldComponent; private static final long serialVersionUID = -8146345475859196612L; public void buttonClick(ClickEvent event) { if (gma.getMap(startdate.getValue(), enddate.getValue(), tutka.getValue())) { // tm ei ole kaunista, mutta uudelleen lisminen ei haittaa vasenpalkki.addComponent(hr); vasenpalkki.addComponent(aika); lkmnext.addComponent(lkm); next.setEnabled(true); lkmnext.addComponent(next); vasenpalkki.addComponent(lkmnext); } } }); vasenpalkki.addComponent(button); layout.addComponent(vasenpalkki); karttapalkki.setHeight(600, Sizeable.Unit.PIXELS); karttapalkki.addComponent(oldComponent); layout.addComponent(karttapalkki); layout.setMargin(true); setContent(layout); }
From source file:fi.jasoft.dragdroplayouts.demo.views.DragdropDragCaptionDemo.java
License:Apache License
@Override public Component getLayout() { // start-source HorizontalLayout layout = new HorizontalLayout(); layout.setSizeFull();//from w w w . j a v a 2 s . c o m layout.setMargin(true); layout.setSpacing(true); DDPanel panel1 = new DDPanel("Source"); panel1.setWidth("200px"); panel1.setHeight("200px"); panel1.setDragMode(LayoutDragMode.CLONE); panel1.setDropHandler(new DefaultPanelDropHandler()); panel1.setDragCaptionProvider(component -> new DragCaption( "<u>Custom drag caption:</u><br/>" + component.getClass().getSimpleName(), VaadinIcons.AIRPLANE, ContentMode.HTML)); layout.addComponent(panel1); Button content = new Button("Drag me!"); content.setSizeFull(); panel1.setContent(content); DDPanel panel2 = new DDPanel("Destination"); panel2.setWidth("200px"); panel2.setHeight("200px"); panel2.setDragMode(LayoutDragMode.CLONE); panel2.setDropHandler(new DefaultPanelDropHandler()); panel2.setDragCaptionProvider(component -> new DragCaption( "Drag caption goes back! " + component.getClass().getSimpleName(), VaadinIcons.AIRPLANE)); layout.addComponent(panel2); // end-source Label label = new Label("In this demo you can drag the button." + "\nYou will see custom drag caption(with icon) provided by DragCaptionProvider"); label.setContentMode(ContentMode.PREFORMATTED); return new VerticalLayout(label, layout); }
From source file:fi.jasoft.dragdroplayouts.demo.views.DragdropHorizontalSplitPanelDemo.java
License:Apache License
@Override public Component getLayout() { // start-source CssLayout root = new CssLayout(); root.setSizeFull();// w w w . j a va 2 s . com Label lbl = new Label("To the left are some buttons, and to the right is a horizontal split panel. " + "Try dragging the buttons on to the splitpanel. If a component already exists in the SplitPanel it is replaced with the dragged one."); root.addComponent(lbl); // Wrapping components in a horizontal layout HorizontalLayout inner = new HorizontalLayout(); inner.setMargin(true); inner.setSizeFull(); inner.setSpacing(true); root.addComponent(inner); // Add some buttons to a vertical layout with dragging enabled final DDVerticalLayout btns = new DDVerticalLayout(); btns.setDragMode(LayoutDragMode.CLONE); btns.setSizeUndefined(); btns.setSpacing(true); String caption = "Button "; btns.addComponent(new Button(caption + buttonCount++)); btns.addComponent(new Button(caption + buttonCount++)); btns.addComponent(new Button(caption + buttonCount++)); btns.addComponent(new Button(caption + buttonCount++)); btns.addComponent(new Button(caption + buttonCount++)); inner.addComponent(btns); // Create a drag & drop horizontal split panel final DDHorizontalSplitPanel panel = new DDHorizontalSplitPanel(); panel.setSizeFull(); inner.addComponent(panel); inner.setExpandRatio(panel, 1); // Enable dragging panel.setDragMode(LayoutDragMode.CLONE); // Enable dropping panel.setDropHandler(new DefaultHorizontalSplitPanelDropHandler()); // end-source return root; }