类com.vaadin.server.Sizeable源码实例Demo

下面列出了怎么用com.vaadin.server.Sizeable的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: cuba   文件: WebDialogs.java
@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;
}
 
源代码2 项目: cuba   文件: WebDialogs.java
@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;
}
 
源代码3 项目: cuba   文件: WebScrollBoxLayout.java
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;
    }
}
 
源代码4 项目: cuba   文件: WebAbstractTable.java
@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();
}
 
源代码5 项目: cuba   文件: WebFilter.java
@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);
}
 
源代码6 项目: cuba   文件: WebPopupButton.java
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;
}
 
源代码7 项目: cuba   文件: DefaultAbsoluteLayoutDropHandler.java
/**
 * 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);
}
 
源代码8 项目: hawkbit   文件: DistributionSetSelectWindow.java
/**
 * 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);
}
 
源代码9 项目: mycollab   文件: ProjectAssetsUtil.java
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;
}
 
源代码10 项目: mycollab   文件: ProjectAssetsUtil.java
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;
}
 
源代码11 项目: cuba   文件: WebDialogs.java
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"));
}
 
源代码12 项目: cuba   文件: WebDialogs.java
@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;
}
 
源代码13 项目: cuba   文件: WebDialogs.java
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"));
}
 
源代码14 项目: cuba   文件: WebDialogs.java
@Override
public MessageDialogBuilder 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;
}
 
源代码15 项目: cuba   文件: WebScrollBoxLayout.java
public WebScrollBoxLayout() {
    component = new CubaScrollBoxLayout();
    component.setWidth(100, Sizeable.Unit.PERCENTAGE);
    component.setPrimaryStyleName(SCROLLBOX_STYLENAME);

    CubaVerticalActionsLayout content = new CubaVerticalActionsLayout();
    content.setWidth(100, Sizeable.Unit.PERCENTAGE);
    content.setStyleName(SCROLLBOX_CONTENT_STYLENAME);
    component.addComponent(content);

    getContent().setMargin(false);
}
 
源代码16 项目: cuba   文件: WebAbstractComponent.java
@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);
    }
}
 
源代码17 项目: cuba   文件: WebAbstractComponent.java
@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);
    }
}
 
源代码18 项目: cuba   文件: WebTree.java
@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();
}
 
源代码19 项目: cuba   文件: WebComponentsHelper.java
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);
}
 
源代码20 项目: cuba   文件: WebAbstractTable.java
@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();
}
 
源代码21 项目: cuba   文件: WebFtsField.java
protected void adjustWidth() {
    if (getWidth() < 0) {
        searchField.setWidthUndefined();
    } else {
        searchField.setWidth(100, Sizeable.Unit.PERCENTAGE);
    }
}
 
源代码22 项目: cuba   文件: WebFtsField.java
protected void adjustHeight() {
    if (getHeight() < 0) {
        searchField.setHeightUndefined();
    } else {
        searchField.setHeight(100, Sizeable.Unit.PERCENTAGE);
    }
}
 
源代码23 项目: cuba   文件: WebAbstractDataGrid.java
@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();
}
 
源代码24 项目: cuba   文件: WebAbstractDataGrid.java
@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();
}
 
源代码25 项目: cuba   文件: WebWrapperUtils.java
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");
    }
}
 
源代码26 项目: cuba   文件: WebWrapperUtils.java
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");
    }
}
 
源代码27 项目: cuba   文件: WebDialogWindow.java
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();
}
 
源代码28 项目: cuba   文件: WebDialogWindow.java
@Override
public void setDialogWidth(String dialogWidth) {
    dialogWindow.setWidth(WebWrapperUtils.toVaadinSize(dialogWidth));

    if (dialogWindow.getWidth() < 0) {
        component.setWidthUndefined();
    } else {
        component.setWidth(100, Sizeable.Unit.PERCENTAGE);
    }
}
 
源代码29 项目: cuba   文件: WebDialogWindow.java
@Override
public void setDialogHeight(String dialogHeight) {
    dialogWindow.setHeight(WebWrapperUtils.toVaadinSize(dialogHeight));

    if (dialogWindow.getHeight() < 0) {
        component.setHeightUndefined();
    } else {
        component.setHeight(100, Sizeable.Unit.PERCENTAGE);
    }
}
 
源代码30 项目: hawkbit   文件: DistributionSetSelectWindow.java
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);
}