List of usage examples for com.vaadin.ui Component getWidth
public float getWidth();
From source file:com.foc.vaadin.FocCentralPanel.java
License:Apache License
protected void afterChangeCentralPanelContent(ICentralPanel iCentralPanel) { Component central = (Component) iCentralPanel; if (central != null && central instanceof FocXMLLayout) { FocXMLLayout xmlLayout = (FocXMLLayout) central; if (xmlLayout != null && xmlLayout.getLayouts() != null && xmlLayout.getLayouts().size() > 0) { Component rootComp = (Component) xmlLayout.getLayouts().get(0); if (rootComp != null) { if (centralPanel != null) { centralPanel.setWidth(rootComp.getWidth(), rootComp.getWidthUnits()); // centralPanel.setHeight("-1px"); // centralPanel.setHeight("100%");//NO_PANEL //When the main layout is 100% this means that there will be no vertical srcoll //When the main layout is -1px this means that there will be a vertical srcoll // And then we can use expandRatio to the table or any other component inside if (this instanceof FocWebVaadinWindow) { centralPanel.setHeight(rootComp.getHeight(), rootComp.getHeightUnits()); setHeight("100%");//NO_PANEL } else { centralPanel.setHeight(rootComp.getHeight(), rootComp.getHeightUnits()); setHeight(rootComp.getHeight(), rootComp.getHeightUnits()); //This means we are in a Popup // centralPanel.setHeight("100%"); // setHeight("100%");//NO_PANEL }/*from w w w . j a v a 2 s . c o m*/ } // setWidth(rootComp.getWidth(), rootComp.getWidthUnits()); //setHeight(rootComp.getHeight(), rootComp.getHeightUnits()); // setHeight("-1px"); // setHeight("100%");//NO_PANEL markAsDirty(); // requestRepaint(); } } } }
From source file:com.foc.vaadin.FocCentralPanel.java
License:Apache License
@Override public void addUtilityPanel(IRightPanel utilityPanel) { if (utilityPanel != null) { try {//from w ww . ja v a 2 s .c o m Component utilityPanelAsComponent = (Component) utilityPanel; // Window window = getParent(Window.class); utilityWindow = new Window("Dictionary"); utilityWindow.setSizeFull(); utilityWindow.setWidth(utilityPanelAsComponent.getWidth(), utilityPanelAsComponent.getWidthUnits()); utilityWindow.setHeight(utilityPanelAsComponent.getHeight(), utilityPanelAsComponent.getHeightUnits()); utilityWindow.setContent(utilityPanelAsComponent); getUI().addWindow(utilityWindow); } catch (Exception e) { Globals.logException(e); } } }
From source file:com.haulmont.cuba.web.gui.components.table.EditableColumnFieldWrapper.java
License:Apache License
public EditableColumnFieldWrapper(Component component, com.haulmont.cuba.gui.components.Component columnComponent) { this.component = component; if (component.getWidth() < 0) { setWidthUndefined();//from ww w . j a v a2s. c o m } if (columnComponent instanceof Field) { AbstractComponent vComponent = columnComponent.unwrap(AbstractComponent.class); if (vComponent instanceof Focusable) { setFocusDelegate((Focusable) vComponent); } } }
From source file:com.haulmont.cuba.web.gui.components.WebAbstractTable.java
License:Apache License
@Override public void addGeneratedColumn(String columnId, ColumnGenerator<? super E> generator) { checkNotNullArgument(columnId, "columnId is null"); checkNotNullArgument(generator, "generator is null for column id '%s'", columnId); MetaPropertyPath targetCol = getDatasource().getMetaClass().getPropertyPath(columnId); Object generatedColumnId = targetCol != null ? targetCol : columnId; Column column = getColumn(columnId); Column associatedRuntimeColumn = null; if (column == null) { Column newColumn = new Column(generatedColumnId); columns.put(newColumn.getId(), newColumn); columnsOrder.add(newColumn);/* w w w . j a v a 2s . com*/ associatedRuntimeColumn = newColumn; newColumn.setOwner(this); } // save column order Object[] visibleColumns = component.getVisibleColumns(); boolean removeOldGeneratedColumn = component.getColumnGenerator(generatedColumnId) != null; // replace generator for column if exist if (removeOldGeneratedColumn) { component.removeGeneratedColumn(generatedColumnId); } component.addGeneratedColumn(generatedColumnId, new CustomColumnGenerator(generator, associatedRuntimeColumn) { @SuppressWarnings("unchecked") @Override public Object generateCell(com.vaadin.ui.Table source, Object itemId, Object columnId) { Entity entity = getDatasource().getItem(itemId); com.haulmont.cuba.gui.components.Component component = getColumnGenerator() .generateCell(entity); if (component == null) { return null; } if (component instanceof PlainTextCell) { return ((PlainTextCell) component).getText(); } if (component instanceof BelongToFrame) { BelongToFrame belongToFrame = (BelongToFrame) component; if (belongToFrame.getFrame() == null) { belongToFrame.setFrame(getFrame()); } } component.setParent(WebAbstractTable.this); com.vaadin.ui.Component vComponent = component.unwrapComposition(Component.class); // wrap field for show required asterisk if ((vComponent instanceof com.vaadin.ui.Field) && (((com.vaadin.ui.Field) vComponent).isRequired())) { VerticalLayout layout = new VerticalLayout(); layout.addComponent(vComponent); if (vComponent.getWidth() < 0) { layout.setWidthUndefined(); } layout.addComponent(vComponent); vComponent = layout; } return vComponent; } }); if (removeOldGeneratedColumn) { // restore column order component.setVisibleColumns(visibleColumns); } }
From source file:com.mymita.vaadlets.VaadletsBuilder.java
License:Apache License
private static void setComponentAttributes(final com.vaadin.ui.Component vaadinComponent, final com.mymita.vaadlets.core.Component c) { vaadinComponent.setCaption(c.getCaption()); vaadinComponent.setEnabled(c.isEnabled()); vaadinComponent.setReadOnly(c.isReadonly()); vaadinComponent.setVisible(c.isVisible()); if (c.getHeight() != null) { vaadinComponent.setHeight(c.getHeight()); }//from ww w . j a v a 2s . co m if (c.getWidth() != null) { vaadinComponent.setWidth(c.getWidth()); } if (c.isSizeUndefined() != null && c.isSizeUndefined().booleanValue()) { vaadinComponent.setSizeUndefined(); } if (c.isSizeFull() != null && c.isSizeFull().booleanValue()) { vaadinComponent.setSizeFull(); } }
From source file:info.magnolia.ui.vaadin.richtext.TextAreaStretcher.java
License:Open Source License
public TextAreaStretcher() { registerRpc(new TextAreaStretcherServerRpc() { @Override//from ww w . j ava2 s . c o m public void toggle(int initialWidth, int initialHeight) { getState().isCollapsed = !getState().isCollapsed; final Component parent = (Component) getParent(); if (getState().isCollapsed) { // Restore size info from the state. parent.setWidth(getState().collapsedStateWidth); parent.setHeight(getState().collapsedStateHeight); } else { // We save the initial dimensions and clear size info from the state. getState().collapsedStateHeight = parent.getHeight() + parent.getHeightUnits().toString(); getState().collapsedStateWidth = parent.getWidth() + parent.getWidthUnits().toString(); parent.setWidth(""); parent.setHeight(""); } } }); }
From source file:org.opencms.ui.components.CmsToolBar.java
License:Open Source License
/** * Calculates the width required by the layout components * * @param items the layout/* ww w. j av a 2 s .co m*/ * * @return the width */ private int estimateRequiredWidth(AbstractOrderedLayout items) { int result = 0; if (items != null) { for (Component comp : items) { if (comp == m_foldedButtonsMenu) { continue; } else if ((comp instanceof Button) || (comp instanceof PopupView) || (comp instanceof MenuBar)) { // assume all buttons have a with of 50px result += 50; } else if (comp == m_appIndicator) { // assume app indicator requires 150px result += 50; } else { float compWidth = comp.getWidth(); if ((compWidth > 0) && (comp.getWidthUnits() == Unit.PIXELS)) { // also add 10px margin result += compWidth + 10; } else { result += 200; } } } } return result; }
From source file:org.vaadin.addons.portallayout.portlet.Portlet.java
License:Apache License
private void delegateSizeManagement(boolean initial) { final Component c = getParent(); String width = String.format("%d%s", (int) c.getWidth(), c.getWidthUnits().getSymbol()); if (c.getWidth() >= 0 && !"100%".equals(width)) { c.setWidth("100%"); getState().width = width;/* w w w . j a va2s . c om*/ } String height = String.format("%d%s", (int) c.getHeight(), c.getHeightUnits().getSymbol()); if (c.getHeight() >= 0 && !"100%".equals(height)) { c.setHeight("100%"); getState().height = height; } getParent().beforeClientResponse(initial); }
From source file:songstock.web.SongStockUI.java
License:Open Source License
/** * Shows a modal popup window with the given title and content. * @param title of the popup window//from w w w. jav a 2 s .co m * @param content of the popup window */ public void showPopupWindow(String title, Component content) { // Create a new popup window popupWindow = new Window(title); popupWindow.setModal(true); // Add content to the popup window popupWindow.setContent(content); // Set the height of the popup window popupWindow.setHeight(content.getHeight() + 50, content.getHeightUnits()); // Set the width of the popup window popupWindow.setWidth(content.getWidth(), content.getWidthUnits()); // Add popup window to the app's main window addWindow(popupWindow); }