List of usage examples for com.vaadin.ui Component setSizeFull
public void setSizeFull();
From source file:org.jumpmind.vaadin.ui.common.TabbedApplicationPanel.java
License:Open Source License
public void addCloseableTab(String caption, Resource icon, Component component) { Iterator<Component> i = iterator(); while (i.hasNext()) { Component c = i.next();/*from www . ja va2 s . c o m*/ if (getTab(c).getCaption().equals(caption)) { setSelectedTab(c); return; } } component.setSizeFull(); Tab tab = addTab(component, caption, icon, mainTab == null ? 0 : 1); tab.setClosable(true); setSelectedTab(tab); }
From source file:org.jumpmind.vaadin.ui.sqlexplorer.QueryPanel.java
License:Open Source License
protected boolean execute(final boolean runAsScript, String sqlText, final int tabPosition, final boolean forceNewTab) { boolean scheduled = false; if (runnersInProgress == null) { runnersInProgress = new HashSet<SqlRunner>(); }//w w w. j a v a2s. co m if (sqlText == null) { if (!runAsScript) { sqlText = selectSqlToRun(); } else { sqlText = sqlArea.getValue(); } sqlText = sqlText != null ? sqlText.trim() : null; } if (StringUtils.isNotBlank(sqlText)) { final HorizontalLayout executingLayout = new HorizontalLayout(); executingLayout.setMargin(true); executingLayout.setSizeFull(); final Label label = new Label("Executing:\n\n" + StringUtils.abbreviate(sqlText, 250), ContentMode.PREFORMATTED); label.setEnabled(false); executingLayout.addComponent(label); executingLayout.setComponentAlignment(label, Alignment.TOP_LEFT); final String sql = sqlText; final Tab executingTab; if (!forceNewTab && generalResultsTab != null) { replaceGeneralResultsWith(executingLayout, FontAwesome.SPINNER); executingTab = null; } else { executingTab = resultsTabs.addTab(executingLayout, StringUtils.abbreviate(sql, 20), FontAwesome.SPINNER, tabPosition); } if (executingTab != null) { executingTab.setClosable(true); resultsTabs.setSelectedTab(executingTab); } final SqlRunner runner = new SqlRunner(sql, runAsScript, user, db, settingsProvider.get(), this, generalResultsTab != null); runnersInProgress.add(runner); runner.setConnection(connection); runner.setListener(new SqlRunner.ISqlRunnerListener() { private static final long serialVersionUID = 1L; @Override public void writeSql(String sql) { QueryPanel.this.appendSql(sql); } @Override public void reExecute(String sql) { QueryPanel.this.reExecute(sql); } public void finished(final FontAwesome icon, final List<Component> results, final long executionTimeInMs, final boolean transactionStarted, final boolean transactionEnded) { VaadinSession.getCurrent().access(new Runnable() { @Override public void run() { try { if (transactionEnded) { transactionEnded(); } else if (transactionStarted) { rollbackButtonValue = true; commitButtonValue = true; setButtonsEnabled(); sqlArea.setStyleName("transaction-in-progress"); connection = runner.getConnection(); } addToSqlHistory(StringUtils.abbreviate(sql, 1024 * 8), runner.getStartTime(), executionTimeInMs, user); for (Component resultComponent : results) { resultComponent.setSizeFull(); if (forceNewTab || generalResultsTab == null || results.size() > 1) { if (resultComponent instanceof TabularResultLayout) { resultComponent = ((TabularResultLayout) resultComponent) .refreshWithoutSaveButton(); } addResultsTab(resultComponent, StringUtils.abbreviate(sql, 20), icon, tabPosition); } else { replaceGeneralResultsWith(resultComponent, icon); resultsTabs.setSelectedTab(generalResultsTab.getComponent()); } String statusVal; if (canceled) { statusVal = "Sql canceled after " + executionTimeInMs + " ms for " + db.getName() + ". Finished at " + SimpleDateFormat.getTimeInstance().format(new Date()); } else { statusVal = "Sql executed in " + executionTimeInMs + " ms for " + db.getName() + ". Finished at " + SimpleDateFormat.getTimeInstance().format(new Date()); } status.setValue(statusVal); resultStatuses.put(resultComponent, statusVal); canceled = false; } } finally { setButtonsEnabled(); if (executingTab != null) { resultsTabs.removeTab(executingTab); } else if (results.size() > 1) { resetGeneralResultsTab(); } runnersInProgress.remove(runner); runner.setListener(null); } } }); } }); final Button cancel = new Button("Cancel"); cancel.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { log.info("Canceling sql: " + sql); label.setValue("Canceling" + label.getValue().substring(9)); executingLayout.removeComponent(cancel); canceled = true; new Thread(new Runnable() { @Override public void run() { runner.cancel(); } }).start(); } }); executingLayout.addComponent(cancel); scheduled = true; runner.start(); } setButtonsEnabled(); return scheduled; }
From source file:org.lunifera.example.vaadin.osgi.bootstrap.extendable.ExtendableUI.java
License:Apache License
/** * Called by service tracker if a provider was found. *//*from w w w . j a v a 2 s. c o m*/ @Override public IContentProvider addingService(ServiceReference<IContentProvider> reference) { final IContentProvider provider = context.getService(reference); accessSynchronously(new Runnable() { @Override public void run() { Component c = provider.getContent(); c.setSizeFull(); main.addComponent(c); } }); return provider; }
From source file:org.lunifera.runtime.web.ecview.presentation.vaadin.tests.ui.ECViewTestsUI.java
License:Open Source License
protected void handleFragment(String className) { try {/*from ww w . ja v a 2s . c om*/ Class<?> clazz = Activator.getContext().getBundle().loadClass(className); if (Component.class.isAssignableFrom(clazz)) { layout.removeAllComponents(); Component component = (Component) clazz.newInstance(); component.setSizeFull(); layout.addComponent(component); } else { handleError(className); } } catch (ClassNotFoundException e) { handleError(className); } catch (InstantiationException e) { handleError(className); } catch (IllegalAccessException e) { handleError(className); } }
From source file:org.opencms.ui.apps.A_CmsWorkplaceApp.java
License:Open Source License
/** * Opens the requested sub view.<p> * * @param state the state/* w w w . j av a 2s. co m*/ * @param updateState <code>true</code> to update the state URL token */ public void openSubView(String state, boolean updateState) { if (updateState) { CmsAppWorkplaceUi.get().changeCurrentAppState(state); } Component comp = getComponentForState(state); if (comp != null) { comp.setSizeFull(); m_rootLayout.setMainContent(comp); } else { m_rootLayout.setMainContent(new Label("Malformed path, tool not availabel for path: " + state)); } updateSubNav(getSubNavEntries(state)); updateBreadCrumb(getBreadCrumbForState(state)); }
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. * /* ww w .j av a 2 s.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.topology.app.internal.TopologyWidgetTestApplication.java
License:Open Source License
/** * Gets a {@link TabSheet} view for all widgets in this manager. * /*from w ww . ja v a 2s. c om*/ * @return TabSheet */ private TabSheet getTabSheet(WidgetManager manager, WidgetContext widgetContext) { TabSheet tabSheet = new TabSheet(); tabSheet.setSizeFull(); for (IViewContribution viewContrib : manager.getWidgets()) { // Create a new view instance Component view = viewContrib.getView(widgetContext); try { m_selectionManager.addSelectionListener((SelectionListener) view); } catch (ClassCastException e) { } try { ((SelectionNotifier) view).addSelectionListener(m_selectionManager); } catch (ClassCastException e) { } if (viewContrib.getIcon() != null) { tabSheet.addTab(view, viewContrib.getTitle(), viewContrib.getIcon()); } else { tabSheet.addTab(view, viewContrib.getTitle()); } view.setSizeFull(); } return tabSheet; }
From source file:org.opennms.features.vaadin.dashboard.dashlets.BSMConfigurationWindow.java
License:Open Source License
/** * Adds a component to a given vertical layout and applies some sizing and formatting options. * * @param verticalLayout the vertical layout * @param component the component to be added *//*from ww w . j a v a2 s .c o m*/ private void addToComponent(VerticalLayout verticalLayout, Component component) { HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setWidth(100, Unit.PERCENTAGE); Label label = new Label(component.getCaption()); label.setWidth(200, Unit.PIXELS); component.setSizeFull(); component.setCaption(null); horizontalLayout.addComponent(label); horizontalLayout.addComponent(component); horizontalLayout.setExpandRatio(component, 1.0f); verticalLayout.addComponent(horizontalLayout); }
From source file:org.vaadin.addons.core.window.DialogWindow.java
License:Apache License
private VerticalLayout buildContent(String title, VaadinIcons type, Component content, ButtonType[] buttonTypes) {//from w ww. j av a2s .com VerticalLayout root = new VerticalLayout(); root.setMargin(false); root.setSpacing(false); float width = -1; float height = 0; if (title != null) { HorizontalLayout header = new HorizontalLayout(); header.setMargin(true); header.setHeightUndefined(); header.setWidth("100%"); header.addStyleName(ValoTheme.WINDOW_TOP_TOOLBAR); Label l = new Label("<font size=\"4\">" + title + "</font>", ContentMode.HTML); width = l.getWidth(); header.addComponent(l); header.setComponentAlignment(l, Alignment.MIDDLE_LEFT); if (type != null) { Label i = new Label(type.getHtml(), ContentMode.HTML); header.addComponent(i); header.setComponentAlignment(i, Alignment.MIDDLE_RIGHT); } height = header.getHeight(); root.addComponent(header); } if (content != null) { content.setSizeFull(); HorizontalLayout contentRoot = new HorizontalLayout(content); contentRoot.setMargin(true); root.addComponent(contentRoot); height = height + contentRoot.getHeight(); } HorizontalLayout footer = new HorizontalLayout(); footer.setHeightUndefined(); footer.setWidth("100%"); footer.setMargin(true); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); HorizontalLayout buttons = new HorizontalLayout(); if (buttonTypes != null) { Stream.of(buttonTypes).forEach(buttonType -> { Button b = new Button(buttonType.getCaption()); if (buttonType.getIcon() != null) { b.setIcon(buttonType.getIcon()); } if (buttonType.getDescription() != null) { b.setDescription(buttonType.getDescription()); } if (buttonType.getStyle() != null) { b.addStyleName(buttonType.getStyle()); } b.addClickListener(event -> buttonType.getActions().forEach(buttonAction -> { ButtonTypeClickEvent event1 = new ButtonTypeClickEvent(buttonType, DialogWindow.this); buttonAction.getListener().buttonClick(event1); })); buttons.addComponent(b); }); } buttons.setSizeUndefined(); buttons.setMargin(false); buttons.setSpacing(true); footer.addComponent(buttons); footer.setComponentAlignment(buttons, Alignment.MIDDLE_RIGHT); if (buttons.getWidth() > width) { width = buttons.getWidth(); } root.addComponent(footer); root.setComponentAlignment(footer, Alignment.BOTTOM_LEFT); height = height + footer.getHeight(); root.setHeight(height, Unit.PIXELS); root.setWidth(width, Unit.PIXELS); return root; }
From source file:uk.q3c.krail.core.ui.ScopedUI.java
License:Apache License
@Override public void changeView(KrailView toView) { if (log.isDebugEnabled()) { String to = (toView == null) ? "null" : toView.getClass().getSimpleName(); log.debug("changing view to {}", to); }/*ww w.j a v a 2s . c o m*/ Component content = toView.getRootComponent(); translator.translate(toView); content.setSizeFull(); getViewDisplayPanel().setContent(content); this.view = toView; }