List of usage examples for com.vaadin.ui HorizontalLayout setExpandRatio
public void setExpandRatio(Component component, float ratio)
This method is used to control how excess space in layout is distributed among components.
From source file:org.jumpmind.metl.ui.views.ManageView.java
License:Open Source License
@SuppressWarnings("serial") @PostConstruct/* w w w. j av a 2 s .c o m*/ protected void init() { viewButton = new Button("View Log"); viewButton.setEnabled(false); viewButton.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { viewLog(table.getValue()); } }); VerticalLayout mainTab = new VerticalLayout(); mainTab.setSizeFull(); HorizontalLayout header = new HorizontalLayout(); header.addComponent(viewButton); header.setComponentAlignment(viewButton, Alignment.BOTTOM_RIGHT); statusSelect = new ComboBox("Status"); statusSelect.setNewItemsAllowed(false); statusSelect.setNullSelectionAllowed(false); statusSelect.addItem(ANY); statusSelect.setValue(ANY); for (ExecutionStatus status : ExecutionStatus.values()) { statusSelect.addItem(status.toString()); } ; statusSelect.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { refreshUI(getBackgroundData()); } }); header.addComponent(statusSelect); header.setComponentAlignment(statusSelect, Alignment.BOTTOM_RIGHT); HorizontalLayout limitLayout = new HorizontalLayout(); limitLayout.setSpacing(true); Label limitLabel = new Label("Limit:"); limitLayout.addComponent(limitLabel); limitLayout.setComponentAlignment(limitLabel, Alignment.MIDDLE_CENTER); TextField limitField = new TextField(null, String.valueOf(DEFAULT_LIMIT)); limitField.setWidth("5em"); limitField.setImmediate(true); limitField.setTextChangeEventMode(TextChangeEventMode.LAZY); limitField.setTextChangeTimeout(200); limitField.addTextChangeListener(new TextChangeListener() { public void textChange(TextChangeEvent event) { try { limit = Integer.parseInt(event.getText()); } catch (Exception e) { } refreshUI(getBackgroundData()); } }); limitLayout.addComponent(limitField); limitLayout.setComponentAlignment(limitField, Alignment.BOTTOM_RIGHT); header.addComponent(limitLayout); header.setComponentAlignment(limitLayout, Alignment.BOTTOM_RIGHT); header.setExpandRatio(limitLayout, 1.0f); TextField filterField = new TextField(); filterField.setInputPrompt("Filter"); filterField.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); filterField.setIcon(FontAwesome.SEARCH); filterField.setImmediate(true); filterField.setTextChangeEventMode(TextChangeEventMode.LAZY); filterField.setTextChangeTimeout(200); filterField.addTextChangeListener(new TextChangeListener() { public void textChange(TextChangeEvent event) { executionContainer.removeAllContainerFilters(); if (!StringUtils.isBlank(event.getText())) { executionContainer.addContainerFilter(new MultiPropertyFilter(event.getText(), new String[] { "agentName", "hostName", "flowName", "status", "startTime", "endTime" })); } } }); header.addComponent(filterField); header.setComponentAlignment(filterField, Alignment.BOTTOM_RIGHT); header.setSpacing(true); header.setMargin(true); header.setWidth("100%"); mainTab.addComponent(header); table = new Table(); table.setContainerDataSource(executionContainer); table.setSelectable(true); table.setMultiSelect(false); table.setSizeFull(); table.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { if (event.isDoubleClick()) { viewLog(event.getItemId()); } } }); table.setVisibleColumns( new Object[] { "agentName", "deploymentName", "hostName", "status", "startTime", "endTime" }); table.setColumnHeaders(new String[] { "Agent", "Deployment", "Host", "Status", "Start", "End" }); table.setSortContainerPropertyId("startTime"); table.setSortAscending(false); table.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { viewButton.setEnabled(table.getValue() != null); } }); mainTab.addComponent(table); mainTab.setExpandRatio(table, 1.0f); tabs = new TabbedPanel(); tabs.setMainTab("Executions", Icons.EXECUTION, mainTab); HorizontalSplitPanel split = new HorizontalSplitPanel(); split.setSizeFull(); split.setSplitPosition(AppConstants.DEFAULT_LEFT_SPLIT, Unit.PIXELS, false); manageNavigator = new ManageNavigator(FolderType.AGENT, context); manageNavigator.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { refreshUI(getBackgroundData()); } }); split.setFirstComponent(manageNavigator); VerticalLayout container = new VerticalLayout(); container.setSizeFull(); container.addComponent(tabs); split.setSecondComponent(container); addComponent(split); setSizeFull(); context.getBackgroundRefresherService().register(this); }
From source file:org.jumpmind.vaadin.ui.common.ConfirmDialog.java
License:Open Source License
public ConfirmDialog(String caption, String text, final IConfirmListener confirmListener) { setCaption(caption);/*ww w .ja va 2s. c o m*/ setModal(true); setResizable(true); setWidth(300, Unit.PIXELS); setHeight(200, Unit.PIXELS); setClosable(false); VerticalLayout layout = new VerticalLayout(); layout.setSizeFull(); layout.setSpacing(true); layout.setMargin(true); setContent(layout); if (isNotBlank(text)) { Label textLabel = new Label(text); layout.addComponent(textLabel); layout.setExpandRatio(textLabel, 1); } HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); buttonLayout.setSpacing(true); buttonLayout.setWidth(100, Unit.PERCENTAGE); Label spacer = new Label(" "); buttonLayout.addComponent(spacer); buttonLayout.setExpandRatio(spacer, 1); Button cancelButton = new Button("Cancel"); cancelButton.setClickShortcut(KeyCode.ESCAPE); cancelButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { UI.getCurrent().removeWindow(ConfirmDialog.this); } }); buttonLayout.addComponent(cancelButton); Button okButton = new Button("Ok"); okButton.setStyleName(ValoTheme.BUTTON_PRIMARY); okButton.setClickShortcut(KeyCode.ENTER); okButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { if (confirmListener.onOk()) { UI.getCurrent().removeWindow(ConfirmDialog.this); } } }); buttonLayout.addComponent(okButton); layout.addComponent(buttonLayout); okButton.focus(); }
From source file:org.jumpmind.vaadin.ui.common.NotifyDialog.java
License:Open Source License
public NotifyDialog(String caption, String text, final Throwable ex, Type type) { super(caption); setWidth(400, Unit.PIXELS);//from w w w .j av a 2 s. co m setHeight(300, Unit.PIXELS); final HorizontalLayout messageArea = new HorizontalLayout(); messageArea.addStyleName("v-scrollable"); messageArea.setMargin(true); messageArea.setSpacing(true); messageArea.setSizeFull(); text = isNotBlank(text) ? text : (ex != null ? ex.getMessage() : ""); if (type == Type.ERROR_MESSAGE) { setIcon(FontAwesome.BAN); } final String message = text; final Label textLabel = new Label(message, ContentMode.HTML); messageArea.addComponent(textLabel); messageArea.setExpandRatio(textLabel, 1); content.addComponent(messageArea); content.setExpandRatio(messageArea, 1); final Button detailsButton = new Button("Details"); detailsButton.setVisible(ex != null); detailsButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { detailsMode = !detailsMode; if (detailsMode) { String msg = "<pre>" + ExceptionUtils.getStackTrace(ex).trim() + "</pre>"; msg = msg.replace("\t", " "); textLabel.setValue(msg); detailsButton.setCaption("Message"); messageArea.setMargin(new MarginInfo(false, false, false, true)); setHeight(600, Unit.PIXELS); setWidth(1000, Unit.PIXELS); setPosition(getPositionX() - 300, getPositionY() - 150); } else { textLabel.setValue(message); detailsButton.setCaption("Details"); messageArea.setMargin(true); setWidth(400, Unit.PIXELS); setHeight(300, Unit.PIXELS); setPosition(getPositionX() + 300, getPositionY() + 150); } } }); content.addComponent(buildButtonFooter(detailsButton, buildCloseButton())); }
From source file:org.jumpmind.vaadin.ui.common.PromptDialog.java
License:Open Source License
public PromptDialog(String caption, String text, String defaultValue, final IPromptListener promptListener) { setCaption(caption);//from ww w.ja va2 s.c o m setModal(true); setResizable(false); setSizeUndefined(); setClosable(false); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.setMargin(true); setContent(layout); if (isNotBlank(text)) { layout.addComponent(new Label(text)); } final TextField field = new TextField(); field.setWidth(100, Unit.PERCENTAGE); field.setNullRepresentation(""); field.setValue(defaultValue); if (defaultValue != null) { field.setSelectionRange(0, defaultValue.length()); } layout.addComponent(field); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); buttonLayout.setSpacing(true); buttonLayout.setWidth(100, Unit.PERCENTAGE); Label spacer = new Label(" "); buttonLayout.addComponent(spacer); buttonLayout.setExpandRatio(spacer, 1); Button cancelButton = new Button("Cancel"); cancelButton.setClickShortcut(KeyCode.ESCAPE); cancelButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { UI.getCurrent().removeWindow(PromptDialog.this); } }); buttonLayout.addComponent(cancelButton); Button okButton = new Button("Ok"); okButton.setStyleName(ValoTheme.BUTTON_PRIMARY); okButton.setClickShortcut(KeyCode.ENTER); okButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { if (promptListener.onOk(field.getValue())) { UI.getCurrent().removeWindow(PromptDialog.this); } } }); buttonLayout.addComponent(okButton); layout.addComponent(buttonLayout); field.focus(); }
From source file:org.jumpmind.vaadin.ui.common.ResizableWindow.java
License:Open Source License
protected HorizontalLayout buildButtonFooter(Button[] toTheLeftButtons, Button... toTheRightButtons) { HorizontalLayout footer = new HorizontalLayout(); footer.setWidth("100%"); footer.setSpacing(true);//from w w w . j a v a2 s . com footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); if (toTheLeftButtons != null) { footer.addComponents(toTheLeftButtons); } Label footerText = new Label(""); footerText.setSizeUndefined(); footer.addComponents(footerText); footer.setExpandRatio(footerText, 1); if (toTheRightButtons != null) { footer.addComponents(toTheRightButtons); } return footer; }
From source file:org.jumpmind.vaadin.ui.sqlexplorer.TableSelectionLayout.java
License:Open Source License
protected void createTableSelectionLayout(String titleKey) { this.addComponent(new Label(titleKey)); HorizontalLayout schemaChooserLayout = new HorizontalLayout(); schemaChooserLayout.setWidth(100, Unit.PERCENTAGE); schemaChooserLayout.setSpacing(true); this.addComponent(schemaChooserLayout); catalogSelect = new ComboBox("Catalog"); catalogSelect.setImmediate(true);//from www.j a va 2s. co m CommonUiUtils.addItems(getCatalogs(), catalogSelect); schemaChooserLayout.addComponent(catalogSelect); if (selectedTablesSet.iterator().hasNext()) { catalogSelect.select(selectedTablesSet.iterator().next().getCatalog()); } else { catalogSelect.select(databasePlatform.getDefaultCatalog()); } schemaSelect = new ComboBox("Schema"); schemaSelect.setImmediate(true); CommonUiUtils.addItems(getSchemas(), schemaSelect); schemaChooserLayout.addComponent(schemaSelect); if (selectedTablesSet.iterator().hasNext()) { schemaSelect.select(selectedTablesSet.iterator().next().getSchema()); } else { schemaSelect.select(databasePlatform.getDefaultSchema()); } Label spacer = new Label(); schemaChooserLayout.addComponent(spacer); schemaChooserLayout.setExpandRatio(spacer, 1); filterField = new TextField(); filterField.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); filterField.setIcon(FontAwesome.SEARCH); filterField.setInputPrompt("Filter Tables"); filterField.setNullRepresentation(""); filterField.setImmediate(true); filterField.setTextChangeEventMode(TextChangeEventMode.LAZY); filterField.setTextChangeTimeout(200); filterField.addTextChangeListener(new TextChangeListener() { private static final long serialVersionUID = 1L; public void textChange(TextChangeEvent event) { filterField.setValue(event.getText()); refreshTableOfTables(); } }); schemaChooserLayout.addComponent(filterField); schemaChooserLayout.setComponentAlignment(filterField, Alignment.BOTTOM_RIGHT); listOfTablesTable = CommonUiUtils.createTable(); listOfTablesTable.setImmediate(true); listOfTablesTable.addItemClickListener(new ItemClickListener() { private static final long serialVersionUID = 1L; @Override public void itemClick(ItemClickEvent event) { CheckBox checkBox = (CheckBox) event.getItem().getItemProperty("selected").getValue(); checkBox.setValue(!checkBox.getValue()); } }); listOfTablesTable.addContainerProperty("selected", CheckBox.class, null); listOfTablesTable.setColumnWidth("selected", UiConstants.TABLE_SELECTED_COLUMN_WIDTH); listOfTablesTable.setColumnHeader("selected", ""); listOfTablesTable.addContainerProperty("table", String.class, null); listOfTablesTable.setColumnHeader("table", ""); listOfTablesTable.setSizeFull(); this.addComponent(listOfTablesTable); this.setExpandRatio(listOfTablesTable, 1); schemaSelect.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; public void valueChange(ValueChangeEvent event) { refreshTableOfTables(); } }); catalogSelect.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; public void valueChange(ValueChangeEvent event) { refreshTableOfTables(); } }); refreshTableOfTables(); }
From source file:org.jumpmind.vaadin.ui.sqlexplorer.TabularResultLayout.java
License:Open Source License
private void createMenuBar() { HorizontalLayout resultBar = new HorizontalLayout(); resultBar.setWidth(100, Unit.PERCENTAGE); resultBar.setMargin(new MarginInfo(false, true, false, true)); HorizontalLayout leftBar = new HorizontalLayout(); leftBar.setSpacing(true);/*from w w w. j a v a 2 s . com*/ resultLabel = new Label("", ContentMode.HTML); leftBar.addComponent(resultLabel); final Label sqlLabel = new Label("", ContentMode.TEXT); sqlLabel.setWidth(800, Unit.PIXELS); leftBar.addComponent(sqlLabel); resultBar.addComponent(leftBar); resultBar.setComponentAlignment(leftBar, Alignment.MIDDLE_LEFT); resultBar.setExpandRatio(leftBar, 1); MenuBar rightBar = new MenuBar(); rightBar.addStyleName(ValoTheme.MENUBAR_BORDERLESS); rightBar.addStyleName(ValoTheme.MENUBAR_SMALL); MenuBar.MenuItem refreshButton = rightBar.addItem("", new Command() { private static final long serialVersionUID = 1L; @Override public void menuSelected(MenuBar.MenuItem selectedItem) { listener.reExecute(sql); } }); refreshButton.setIcon(FontAwesome.REFRESH); MenuBar.MenuItem exportButton = rightBar.addItem("", new Command() { private static final long serialVersionUID = 1L; @Override public void menuSelected(MenuBar.MenuItem selectedItem) { new ExportDialog(grid, db.getName(), sql).show(); } }); exportButton.setIcon(FontAwesome.UPLOAD); if (isInQueryGeneralResults) { MenuBar.MenuItem keepResultsButton = rightBar.addItem("", new Command() { private static final long serialVersionUID = 1L; @Override public void menuSelected(com.vaadin.ui.MenuBar.MenuItem selectedItem) { queryPanel.addResultsTab(refreshWithoutSaveButton(), StringUtils.abbreviate(sql, 20), queryPanel.getGeneralResultsTab().getIcon()); queryPanel.resetGeneralResultsTab(); } }); keepResultsButton.setIcon(FontAwesome.CLONE); keepResultsButton.setDescription("Save these results to a new tab"); } if (showSql) { sqlLabel.setValue(StringUtils.abbreviate(sql, 200)); } resultBar.addComponent(rightBar); resultBar.setComponentAlignment(rightBar, Alignment.MIDDLE_RIGHT); this.addComponent(resultBar, 0); }
From source file:org.lucidj.browser.BrowserView.java
License:Apache License
private void build_view() { setMargin(new MarginInfo(true, false, true, false)); build_toolbar();//from ww w . j a va2 s . c o m build_sidebar(); insert_here_cell = new Cell(null); // TODO: THIS BLOCK IS ACTUALLY A FILE HEADER OBJECT //+++ HorizontalLayout header = new HorizontalLayout(); header.setWidth(100, Unit.PERCENTAGE); { CssLayout left_panel = new CssLayout(); left_panel.setWidth(40, Unit.PIXELS); header.addComponent(left_panel); final HorizontalLayout caption = new HorizontalLayout(); caption.setSpacing(true); caption.addStyleName("formula-header"); caption.setWidth(100, Unit.PERCENTAGE); { //caption.addComponent (get_icon ("freepik-saturn.png")); VerticalLayout title_area = new VerticalLayout(); { final TextField title = new TextField(); title.setWidth(100, Unit.PERCENTAGE); title.setValue("Default"); // final ShortcutListener handle_enter = new ShortcutListener // ("EnterShortcut", ShortcutAction.KeyCode.ENTER, null) // { // @Override // public void handleAction (Object o, Object o1) // { // Notification.show ("New title: " + title.getValue()); // unfocus (title); // // } // }; // // title.addFocusListener (new FieldEvents.FocusListener () // { // @Override // public void focus (FieldEvents.FocusEvent focusEvent) // { // title.addShortcutListener (handle_enter); // } // }); // // title.addBlurListener (new FieldEvents.BlurListener () // { // @Override // public void blur (FieldEvents.BlurEvent blurEvent) // { // title.removeShortcutListener (handle_enter); // } // }); title_area.addComponent(title); } caption.addComponent(title_area); caption.setExpandRatio(title_area, 1.0f); } header.addComponent(caption); CssLayout right_panel = new CssLayout(); right_panel.setWidth(36, Unit.PIXELS); header.addComponent(right_panel); header.setExpandRatio(caption, 1.0f); } addComponent(header); //--- content = new VerticalLayout(); content.addStyleName("formula-cells"); addComponent(content); synchronize_cell_view(); // Set focus to first available object update_cell_focus(null, true); }
From source file:org.lucidj.newview.NewView.java
License:Apache License
private Layout form_location_panel() { VerticalLayout rolldown = new VerticalLayout(); rolldown.setCaption("Location"); rolldown.setSpacing(true);/*from w w w . j ava 2 s. c o m*/ HorizontalLayout directory_and_browse = new HorizontalLayout(); directory_and_browse.setSpacing(true); directory_and_browse.setWidth(100, Unit.PERCENTAGE); frm_directory = new TextField(); frm_directory.setValue(projects_dir.toString()); frm_directory.setWidth(100, Unit.PERCENTAGE); directory_and_browse.addComponent(frm_directory); Button confirm = new Button("Save"); confirm.addStyleName(ValoTheme.BUTTON_PRIMARY); confirm.setVisible(false); directory_and_browse.addComponent(confirm); Button change_directory = new Button("Change location..."); directory_and_browse.addComponent(change_directory); directory_and_browse.setExpandRatio(frm_directory, 1.0f); rolldown.addComponent(directory_and_browse); Path projects_home = securityEngine.getSubject().getDefaultUserDir(); frm_directories = rendererFactory.newRenderer(projects_home); frm_directories.setVisible(false); rolldown.addComponent(frm_directories); change_directory.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { if (frm_directories.isVisible()) { change_directory.setCaption("Change location..."); frm_directories.setVisible(false); confirm.setVisible(false); } else { change_directory.setCaption("Cancel change"); frm_directories.setVisible(true); confirm.setVisible(true); } } }); frm_directories.addListener(new Listener() { @Override public void componentEvent(Event event) { if (event instanceof ItemClickEvent) { ItemClickEvent itemClickEvent = (ItemClickEvent) event; File item_id = ((File) itemClickEvent.getItemId()); log.info("CLICK item_path={}", item_id); frm_directory.setValue(item_id.getPath()); } } }); return (rolldown); }