com.vaadin.server.Sizeable Java Examples
The following examples show how to use
com.vaadin.server.Sizeable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebDialogs.java From cuba with Apache License 2.0 | 6 votes |
@Override public OptionDialogBuilder withHeight(String height) { window.setHeight(height); if (getHeight() < 0) { messageLabel.setHeightUndefined(); layout.setExpandRatio(messageLabel, 0); layout.setHeightUndefined(); } else { messageLabel.setHeight(100, Sizeable.Unit.PERCENTAGE); layout.setHeight(100, Sizeable.Unit.PERCENTAGE); layout.setExpandRatio(messageLabel, 1); } return this; }
Example #2
Source File: ProjectAssetsUtil.java From mycollab with GNU Affero General Public License v3.0 | 6 votes |
public static Component clientLogoComp(Client client, int size) { AbstractComponent wrapper; if (!StringUtils.isBlank(client.getAvatarid())) { wrapper = new Image(null, new ExternalResource(StorageUtils.getEntityLogoPath(AppUI.getAccountId(), client.getAvatarid(), 100))); } else { String clientName = client.getName(); clientName = (clientName.length() > 3) ? clientName.substring(0, 3) : clientName; ELabel projectIcon = new ELabel(clientName).withStyleName(WebThemes.TEXT_ELLIPSIS, "center"); wrapper = new VerticalLayout(); ((VerticalLayout) wrapper).addComponent(projectIcon); ((VerticalLayout) wrapper).setComponentAlignment(projectIcon, Alignment.MIDDLE_CENTER); } wrapper.setWidth(size, Sizeable.Unit.PIXELS); wrapper.setHeight(size, Sizeable.Unit.PIXELS); wrapper.addStyleName(WebThemes.CIRCLE_BOX); wrapper.setDescription(UserUIContext.getMessage(GenericI18Enum.OPT_CHANGE_IMAGE)); return wrapper; }
Example #3
Source File: WebDialogs.java From cuba with Apache License 2.0 | 6 votes |
@Override public MessageDialogBuilder withHeight(String height) { window.setHeight(height); if (getHeight() < 0) { messageLabel.setHeightUndefined(); layout.setExpandRatio(messageLabel, 0); layout.setHeightUndefined(); } else { messageLabel.setHeight(100, Sizeable.Unit.PERCENTAGE); layout.setHeight(100, Sizeable.Unit.PERCENTAGE); layout.setExpandRatio(messageLabel, 1); } return this; }
Example #4
Source File: ProjectAssetsUtil.java From mycollab with GNU Affero General Public License v3.0 | 6 votes |
public static Component projectLogoComp(String projectShortname, Integer projectId, String projectAvatarId, int size) { AbstractComponent wrapper; if (!StringUtils.isBlank(projectAvatarId)) { wrapper = new Image(null, new ExternalResource(StorageUtils.getResourcePath (String.format("%s/%s_%d.png", PathUtils.getProjectLogoPath(AppUI.getAccountId(), projectId), projectAvatarId, size)))); } else { ELabel projectIcon = new ELabel(projectShortname.substring(0, 1)).withStyleName(WebThemes.TEXT_ELLIPSIS, ValoTheme.LABEL_LARGE, "center"); projectIcon.setWidth(size, Sizeable.Unit.PIXELS); projectIcon.setHeight(size, Sizeable.Unit.PIXELS); wrapper = new MVerticalLayout(projectIcon).withAlign(projectIcon, Alignment.MIDDLE_CENTER).withMargin(false); } wrapper.setWidth(size, Sizeable.Unit.PIXELS); wrapper.setHeight(size, Sizeable.Unit.PIXELS); wrapper.addStyleName(WebThemes.CIRCLE_BOX); wrapper.setDescription(UserUIContext.getMessage(GenericI18Enum.OPT_CHANGE_IMAGE)); return wrapper; }
Example #5
Source File: WebFilter.java From cuba with Apache License 2.0 | 6 votes |
@Inject protected void setDelegate(FilterDelegate delegate) { this.delegate = delegate; delegate.setFilter(this); ComponentContainer layout = delegate.getLayout(); layout.setParent(this); component = layout.unwrapComposition(com.vaadin.ui.Component.class); component.setWidth(100, Sizeable.Unit.PERCENTAGE); component.addStyleName(FILTER_STYLENAME); delegate.setExpandedStateChangeListener(e -> fireExpandStateChange(e.isExpanded(), e.isUserOriginated()) ); delegate.setCaptionChangedListener(this::updateCaptions); }
Example #6
Source File: WebScrollBoxLayout.java From cuba with Apache License 2.0 | 6 votes |
protected void applyScrollBarsPolicy(ScrollBarPolicy scrollBarPolicy) { switch (scrollBarPolicy) { case VERTICAL: getContent().setHeightUndefined(); getContent().setWidth(100, Sizeable.Unit.PERCENTAGE); break; case HORIZONTAL: getContent().setHeight(100, Sizeable.Unit.PERCENTAGE); getContent().setWidthUndefined(); break; case BOTH: getContent().setSizeUndefined(); break; case NONE: getContent().setSizeFull(); break; } }
Example #7
Source File: DistributionSetSelectWindow.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
/** * Shows a distribution set select window for the given target filter query * * @param tfqId * target filter query id */ public void showForTargetFilter(final Long tfqId) { this.tfqId = tfqId; final TargetFilterQuery tfq = targetFilterQueryManagement.get(tfqId) .orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, tfqId)); final VerticalLayout verticalLayout = initView(); final DistributionSet distributionSet = tfq.getAutoAssignDistributionSet(); final ActionType actionType = tfq.getAutoAssignActionType(); setInitialControlValues(distributionSet, actionType); // build window after values are set to view elements final CommonDialogWindow window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW) .caption(i18n.getMessage(UIMessageIdProvider.CAPTION_SELECT_AUTO_ASSIGN_DS)).content(verticalLayout) .layout(verticalLayout).i18n(i18n).saveDialogCloseListener(this).buildCommonDialogWindow(); window.setId(UIComponentIdProvider.DIST_SET_SELECT_WINDOW_ID); window.setWidth(40.0F, Sizeable.Unit.PERCENTAGE); UI.getCurrent().addWindow(window); window.setVisible(true); }
Example #8
Source File: DefaultAbsoluteLayoutDropHandler.java From cuba with Apache License 2.0 | 6 votes |
/** * Called when a component changed location within the layout * * @param event * The drag and drop event */ @Override protected void handleComponentReordering(DragAndDropEvent event) { AbsoluteLayoutTargetDetails details = (AbsoluteLayoutTargetDetails) event .getTargetDetails(); DDAbsoluteLayout layout = (DDAbsoluteLayout) details.getTarget(); LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); Component component = transferable.getComponent(); // Get top-left pixel position int leftPixelPosition = details.getRelativeLeft(); int topPixelPosition = details.getRelativeTop(); ComponentPosition position = layout.getPosition(component); position.setLeft((float) leftPixelPosition, Sizeable.UNITS_PIXELS); position.setTop((float) topPixelPosition, Sizeable.UNITS_PIXELS); }
Example #9
Source File: WebPopupButton.java From cuba with Apache License 2.0 | 6 votes |
protected CubaButton createActionButton(Action action) { CubaButton button = new CubaButton(); button.setWidth(100, Sizeable.Unit.PERCENTAGE); button.setPrimaryStyleName(CONTEXT_MENU_BUTTON_STYLENAME); setPopupButtonAction(button, action); AppUI ui = AppUI.getCurrent(); if (ui != null) { if (ui.isTestMode()) { button.setCubaId(action.getId()); } if (ui.isPerformanceTestMode()) { String debugId = getDebugId(); if (debugId != null) { TestIdManager testIdManager = ui.getTestIdManager(); button.setId(testIdManager.getTestId(debugId + "_" + action.getId())); } } } return button; }
Example #10
Source File: WebAbstractTable.java From cuba with Apache License 2.0 | 6 votes |
@Override public void setRowsCount(RowsCount rowsCount) { if (this.rowsCount != null && topPanel != null) { topPanel.removeComponent(this.rowsCount.unwrap(com.vaadin.ui.Component.class)); } this.rowsCount = rowsCount; if (rowsCount != null) { if (topPanel == null) { topPanel = createTopPanel(); topPanel.setWidth(100, Sizeable.Unit.PERCENTAGE); componentComposition.addComponentAsFirst(topPanel); } rowsCount.setWidthAuto(); com.vaadin.ui.Component rc = rowsCount.unwrap(com.vaadin.ui.Component.class); topPanel.addComponent(rc); if (rowsCount instanceof VisibilityChangeNotifier) { ((VisibilityChangeNotifier) rowsCount).addVisibilityChangeListener(event -> updateCompositionStylesTopPanelVisible() ); } } updateCompositionStylesTopPanelVisible(); }
Example #11
Source File: WebAbstractDataGrid.java From cuba with Apache License 2.0 | 5 votes |
@Override public void setRowsCount(RowsCount rowsCount) { if (this.rowsCount != null && topPanel != null) { topPanel.removeComponent(WebComponentsHelper.unwrap(this.rowsCount)); this.rowsCount.setParent(null); } this.rowsCount = rowsCount; if (rowsCount != null) { if (rowsCount.getParent() != null && rowsCount.getParent() != this) { throw new IllegalStateException("Component already has parent"); } if (topPanel == null) { topPanel = createTopPanel(); topPanel.setWidth(100, Sizeable.Unit.PERCENTAGE); componentComposition.addComponentAsFirst(topPanel); } rowsCount.setWidthAuto(); Component rc = WebComponentsHelper.unwrap(rowsCount); topPanel.addComponent(rc); if (rowsCount instanceof VisibilityChangeNotifier) { ((VisibilityChangeNotifier) rowsCount).addVisibilityChangeListener(event -> updateCompositionStylesTopPanelVisible() ); } } updateCompositionStylesTopPanelVisible(); }
Example #12
Source File: WebDialogs.java From cuba with Apache License 2.0 | 5 votes |
@Override public OptionDialogBuilder withWidth(String width) { window.setWidth(width); if (getWidth() < 0) { messageLabel.setWidthUndefined(); layout.setWidthUndefined(); } else { messageLabel.setWidth(100, Sizeable.Unit.PERCENTAGE); layout.setWidth(100, Sizeable.Unit.PERCENTAGE); } return this; }
Example #13
Source File: WebWrapperUtils.java From cuba with Apache License 2.0 | 5 votes |
public static Sizeable.Unit toVaadinUnit(SizeUnit sizeUnit) { checkNotNullArgument(sizeUnit); switch (sizeUnit) { case PIXELS: return Sizeable.Unit.PIXELS; case PERCENTAGE: return Sizeable.Unit.PERCENTAGE; default: throw new UnsupportedOperationException("Unsupported Size Unit"); } }
Example #14
Source File: WebWrapperUtils.java From cuba with Apache License 2.0 | 5 votes |
public static SizeUnit toSizeUnit(Sizeable.Unit units) { checkNotNullArgument(units); switch (units) { case PIXELS: return SizeUnit.PIXELS; case PERCENTAGE: return SizeUnit.PERCENTAGE; default: throw new UnsupportedOperationException("Unsupported Size Unit"); } }
Example #15
Source File: WebDialogWindow.java From cuba with Apache License 2.0 | 5 votes |
protected void setupDefaultSize() { ThemeConstantsManager themeConstantsManager = beanLocator.get(ThemeConstantsManager.NAME); ThemeConstants theme = themeConstantsManager.getConstants(); dialogWindow.setWidth(theme.get("cuba.web.WebWindowManager.dialog.width")); dialogWindow.setHeightUndefined(); component.setWidth(100, Sizeable.Unit.PERCENTAGE); component.setHeightUndefined(); }
Example #16
Source File: WebDialogWindow.java From cuba with Apache License 2.0 | 5 votes |
@Override public void setDialogWidth(String dialogWidth) { dialogWindow.setWidth(WebWrapperUtils.toVaadinSize(dialogWidth)); if (dialogWindow.getWidth() < 0) { component.setWidthUndefined(); } else { component.setWidth(100, Sizeable.Unit.PERCENTAGE); } }
Example #17
Source File: WebDialogWindow.java From cuba with Apache License 2.0 | 5 votes |
@Override public void setDialogHeight(String dialogHeight) { dialogWindow.setHeight(WebWrapperUtils.toVaadinSize(dialogHeight)); if (dialogWindow.getHeight() < 0) { component.setHeightUndefined(); } else { component.setHeight(100, Sizeable.Unit.PERCENTAGE); } }
Example #18
Source File: DistributionSetSelectWindow.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
private void confirmWithConsequencesDialog(final TargetFilterQuery tfq, final Long dsId, final ActionType actionType) { final ConfirmConsequencesDialog dialog = new ConfirmConsequencesDialog(tfq, dsId, accepted -> { if (accepted) { targetFilterQueryManagement.updateAutoAssignDS(entityFactory.targetFilterQuery() .updateAutoAssign(tfq.getId()).ds(dsId).actionType(actionType)); eventBus.publish(this, CustomFilterUIEvent.UPDATED_TARGET_FILTER_QUERY); } }); dialog.setWidth(40.0F, Sizeable.Unit.PERCENTAGE); UI.getCurrent().addWindow(dialog); dialog.setVisible(true); }
Example #19
Source File: ProjectAssetsUtil.java From mycollab with GNU Affero General Public License v3.0 | 5 votes |
public static Component editableProjectLogoComp(String projectShortname, Integer projectId, String projectAvatarId, int size) { MCssLayout wrapper = new MCssLayout(); if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PROJECT)) { wrapper.addStyleName(WebThemes.CURSOR_POINTER); wrapper.setDescription(UserUIContext.getMessage(GenericI18Enum.OPT_CHANGE_IMAGE)); wrapper.addLayoutClickListener((LayoutEvents.LayoutClickListener) layoutClickEvent -> UI.getCurrent().addWindow(new ProjectLogoUploadWindow(projectShortname, projectId, projectAvatarId)) ); } if (!StringUtils.isBlank(projectAvatarId)) { Image image = new Image(null, new ExternalResource(StorageUtils.getResourcePath (String.format("%s/%s_%d.png", PathUtils.getProjectLogoPath(AppUI.getAccountId(), projectId), projectAvatarId, size)))); image.addStyleName(WebThemes.CIRCLE_BOX); wrapper.addComponent(image); } else { ELabel projectIcon = new ELabel(projectShortname.substring(0, 1)).withStyleName(WebThemes.TEXT_ELLIPSIS, ValoTheme.LABEL_LARGE, "center", WebThemes.CIRCLE_BOX).withDescription(projectShortname); projectIcon.setWidth(size, Sizeable.Unit.PIXELS); projectIcon.setHeight(size, Sizeable.Unit.PIXELS); wrapper.addComponent(projectIcon); } wrapper.setWidth(size, Sizeable.Unit.PIXELS); wrapper.setHeight(size, Sizeable.Unit.PIXELS); return wrapper; }
Example #20
Source File: WebWindowImpl.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public void setSize(@Nonnull Size size) { if (size.getWidth() != -1) { getVaadinComponent().setWidth(size.getWidth(), Sizeable.Unit.PIXELS); } if (size.getHeight() != -1) { getVaadinComponent().setHeight(size.getHeight(), Sizeable.Unit.PIXELS); } }
Example #21
Source File: WebAbstractDataGrid.java From cuba with Apache License 2.0 | 5 votes |
@Override public void setButtonsPanel(ButtonsPanel panel) { if (buttonsPanel != null && topPanel != null) { topPanel.removeComponent(WebComponentsHelper.unwrap(buttonsPanel)); buttonsPanel.setParent(null); } buttonsPanel = panel; if (panel != null) { if (panel.getParent() != null && panel.getParent() != this) { throw new IllegalStateException("Component already has parent"); } if (topPanel == null) { topPanel = createTopPanel(); topPanel.setWidth(100, Sizeable.Unit.PERCENTAGE); componentComposition.addComponentAsFirst(topPanel); } Component bp = panel.unwrap(Component.class); topPanel.addComponent(bp); topPanel.setExpandRatio(bp, 1); if (panel instanceof VisibilityChangeNotifier) { ((VisibilityChangeNotifier) panel).addVisibilityChangeListener(event -> updateCompositionStylesTopPanelVisible() ); } panel.setParent(this); } updateCompositionStylesTopPanelVisible(); }
Example #22
Source File: WebFtsField.java From cuba with Apache License 2.0 | 5 votes |
protected void adjustHeight() { if (getHeight() < 0) { searchField.setHeightUndefined(); } else { searchField.setHeight(100, Sizeable.Unit.PERCENTAGE); } }
Example #23
Source File: WebFtsField.java From cuba with Apache License 2.0 | 5 votes |
protected void adjustWidth() { if (getWidth() < 0) { searchField.setWidthUndefined(); } else { searchField.setWidth(100, Sizeable.Unit.PERCENTAGE); } }
Example #24
Source File: WebAbstractTable.java From cuba with Apache License 2.0 | 5 votes |
@Override public void setButtonsPanel(ButtonsPanel panel) { if (buttonsPanel != null && topPanel != null) { topPanel.removeComponent(buttonsPanel.unwrap(Component.class)); buttonsPanel.setParent(null); } buttonsPanel = panel; if (panel != null) { if (panel.getParent() != null && panel.getParent() != this) { throw new IllegalStateException("Component already has parent"); } if (topPanel == null) { topPanel = createTopPanel(); topPanel.setWidth(100, Sizeable.Unit.PERCENTAGE); componentComposition.addComponentAsFirst(topPanel); } Component bp = panel.unwrap(Component.class); topPanel.addComponent(bp); topPanel.setExpandRatio(bp, 1); if (panel instanceof VisibilityChangeNotifier) { ((VisibilityChangeNotifier) panel).addVisibilityChangeListener(event -> updateCompositionStylesTopPanelVisible() ); } panel.setParent(this); } updateCompositionStylesTopPanelVisible(); }
Example #25
Source File: WebComponentsHelper.java From cuba with Apache License 2.0 | 5 votes |
public static void expand(AbstractOrderedLayout layout, Component component, String height, String width) { if (!isHorizontalLayout(layout) && (StringUtils.isEmpty(height) || AUTO_SIZE.equals(height) || height.endsWith("%"))) { component.setHeight(100, Sizeable.Unit.PERCENTAGE); } if (!isVerticalLayout(layout) && (StringUtils.isEmpty(width) || AUTO_SIZE.equals(width) || width.endsWith("%"))) { component.setWidth(100, Sizeable.Unit.PERCENTAGE); } layout.setExpandRatio(component, 1); }
Example #26
Source File: WebTree.java From cuba with Apache License 2.0 | 5 votes |
@Override public void setButtonsPanel(ButtonsPanel panel) { if (buttonsPanel != null && topPanel != null) { topPanel.removeComponent(buttonsPanel.unwrap(com.vaadin.ui.Component.class)); buttonsPanel.setParent(null); } buttonsPanel = panel; if (panel != null) { if (panel.getParent() != null && panel.getParent() != this) { throw new IllegalStateException("Component already has parent"); } if (topPanel == null) { topPanel = createTopPanel(); topPanel.setWidth(100, Sizeable.Unit.PERCENTAGE); componentComposition.addComponentAsFirst(topPanel); } topPanel.addComponent(panel.unwrap(com.vaadin.ui.Component.class)); if (panel instanceof VisibilityChangeNotifier) { ((VisibilityChangeNotifier) panel).addVisibilityChangeListener(event -> updateCompositionStylesTopPanelVisible() ); } panel.setParent(this); } updateCompositionStylesTopPanelVisible(); }
Example #27
Source File: WebAbstractComponent.java From cuba with Apache License 2.0 | 5 votes |
@Override public void setWidth(String width) { // do not try to parse string if constant passed if (Component.AUTO_SIZE.equals(width)) { getComposition().setWidth(-1, Sizeable.Unit.PIXELS); } else if (Component.FULL_SIZE.equals(width)) { getComposition().setWidth(100, Sizeable.Unit.PERCENTAGE); } else { getComposition().setWidth(width); } }
Example #28
Source File: WebAbstractComponent.java From cuba with Apache License 2.0 | 5 votes |
@Override public void setHeight(String height) { // do not try to parse string if constant passed if (Component.AUTO_SIZE.equals(height)) { getComposition().setHeight(-1, Sizeable.Unit.PIXELS); } else if (Component.FULL_SIZE.equals(height)) { getComposition().setHeight(100, Sizeable.Unit.PERCENTAGE); } else { getComposition().setHeight(height); } }
Example #29
Source File: WebDialogs.java From cuba with Apache License 2.0 | 5 votes |
public OptionDialogBuilderImpl() { window = new CubaWindow(); window.setModal(true); window.setClosable(false); window.setResizable(false); messageLabel = new CubaLabel(); messageLabel.setWidth(100, Sizeable.Unit.PERCENTAGE); layout = new VerticalLayout(); layout.setStyleName("c-app-option-dialog"); layout.setMargin(false); layout.setSpacing(true); buttonsContainer = new HorizontalLayout(); buttonsContainer.setMargin(false); buttonsContainer.setSpacing(true); layout.addComponent(messageLabel); layout.addComponent(buttonsContainer); layout.setExpandRatio(messageLabel, 1); layout.setComponentAlignment(buttonsContainer, Alignment.BOTTOM_RIGHT); window.setContent(layout); ThemeConstants theme = ui.getApp().getThemeConstants(); window.setWidth(theme.get("cuba.web.WebWindowManager.optionDialog.width")); }
Example #30
Source File: WebDialogs.java From cuba with Apache License 2.0 | 5 votes |
public MessageDialogBuilderImpl() { window = new CubaWindow(); window.setModal(true); window.setResizable(false); layout = new VerticalLayout(); layout.setStyleName("c-app-message-dialog"); layout.setMargin(false); layout.setSpacing(true); messageLabel = new CubaLabel(); messageLabel.setStyleName("c-app-message-dialog-text"); messageLabel.setWidth(100, Sizeable.Unit.PERCENTAGE); DialogAction action = new DialogAction(DialogAction.Type.OK); okButton = createButton(action); okButton.setClickHandler(me -> { try { action.actionPerform(ui.getTopLevelWindow()); } finally { ui.removeWindow(window); } }); layout.addComponent(messageLabel); layout.addComponent(okButton); layout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT); window.setContent(layout); ThemeConstants theme = ui.getApp().getThemeConstants(); window.setWidth(theme.get("cuba.web.WebWindowManager.messageDialog.width")); }