Java 类com.vaadin.ui.AbstractComponent 实例源码

项目:holon-vaadin    文件:AbstractFieldBuilder.java   
@Override
public B dragSource(Consumer<DragSourceExtension<? extends AbstractComponent>> configurator) {
    final DragSourceExtension<I> extension = new DragSourceExtension<>(getInstance());
    if (configurator != null) {
        configurator.accept(extension);
    }
    return builder();
}
项目:bean-grid    文件:AbstractStringToNumberConverterBean.java   
/**
 * Returns the format used by
 * {@link #convertToPresentation(Object, ValueContext)} and
 * {@link #convertToModel(Object, ValueContext)}.
 *
 * @param context
 *            value context to use
 * @return A NumberFormat instance
 */
protected NumberFormat getFormat(ValueContext context) {
    String pattern = null;

    Object data = context.getComponent().map(AbstractComponent.class::cast).map(component -> component.getData())
            .orElse(null);
    if (data instanceof ColumnDefinition) {
        pattern = ((ColumnDefinition) data).getFormat()
                .orElse(configurationProvider.getNumberFormatPattern().orElse(null));
    }

    Locale locale = context.getLocale().orElse(configurationProvider.getLocale());

    if (pattern == null) {
        return NumberFormat.getNumberInstance(locale);
    }

    return new DecimalFormat(pattern, new DecimalFormatSymbols(locale));
}
项目:dungeonstory-java    文件:SubSetSelectorDraggable.java   
@SuppressWarnings("unchecked")
private void addDropTarget(VerticalLayout layout, boolean remove) {
    // make the layout accept drops
    DropTargetExtension<VerticalLayout> dropTarget = new DropTargetExtension<>(layout);

    // the drop effect must match the allowed effect in the drag source for a successful drop
    dropTarget.setDropEffect(DropEffect.MOVE);

    // catch the drops
    dropTarget.addDropListener(event -> {
        // if the drag source is in the same UI as the target
        Optional<AbstractComponent> dragSource = event.getDragSourceComponent();
        if (dragSource.isPresent() && dragSource.get() instanceof SubSetSelectorDraggable.DraggableButton) {
            if (remove) {
                event.getDragData().ifPresent(data -> removeSelectedOption((ET) data));
            } else {
                event.getDragData().ifPresent(data -> addSelectedOption((ET) data));
            }
        }
    });
}
项目:cuba    文件:WebLayoutAnalyzerContextMenuProvider.java   
@Override
public void initContextMenu(Window window, Component contextMenuTarget) {
    ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
    if (clientConfig.getLayoutAnalyzerEnabled()) {
        ContextMenu contextMenu = new ContextMenu(contextMenuTarget.unwrap(AbstractComponent.class), true);
        MenuItem menuItem = contextMenu.addItem(messages.getMainMessage("actions.analyzeLayout"), c -> {
            LayoutAnalyzer analyzer = new LayoutAnalyzer();
            List<LayoutTip> tipsList = analyzer.analyze(window);

            if (tipsList.isEmpty()) {
                window.showNotification("No layout problems found", Frame.NotificationType.HUMANIZED);
            } else {
                window.openWindow("layoutAnalyzer", WindowManager.OpenType.DIALOG,
                        ParamsMap.of("tipsList", tipsList)
                );
            }
        });
        menuItem.setStyleName("c-cm-item");
    }
}
项目:cuba    文件:InvalidValueExceptionHandler.java   
@Override
public boolean handle(ErrorEvent event, App app) {
    boolean handled = super.handle(event, app);

    //noinspection ThrowableResultOfMethodCallIgnored
    if (handled && event.getThrowable() != null) {
        // Finds the original source of the error/exception
        AbstractComponent component = DefaultErrorHandler.findAbstractComponent(event);
        if (component != null) {
            component.markAsDirty();
        }

        if (component instanceof Component.Focusable) {
            ((Component.Focusable) component).focus();
        }

        //noinspection ThrowableResultOfMethodCallIgnored
        if (event.getThrowable() instanceof Validator.InvalidValueException) {
            app.getAppUI().discardAccumulatedEvents();
        }
    }
    return handled;
}
项目:VaadHL    文件:Action.java   
/**
 * Sets visibility of the object attached to.
 * 
 * @param o
 * @param visible
 */
protected void setVisible(Object o, boolean visible) {
    if (attached == null)
        return;
    if (o instanceof AbstractComponent) {
        ((AbstractComponent) o).setVisible(visible);
    } else if (o instanceof MenuItem) {
        ((MenuItem) o).setVisible(visible);
    } else if (o instanceof ContextMenuItem) {
        ((ContextMenuItem) o).setEnabled(enabled); // not possible to hide
    } else {
        throw new WrongObjectTypeException(
                "VHL-014: Cannot control visibility state of the object type:"
                        + o.getClass().getName());
    }
}
项目:Vaadin-Prime-Count    文件:PrimeCountUserStory.java   
public PrimeCountUserStory(final AbstractComponent vaadinParent)
{
    super(vaadinParent, null, CAPTION);

    this.outcomeUserStory = new OutcomeOfUserStory(this);
    this.userStoryToolbar = new UserStoryToolbar(this);
    this.inUserStory = new InUserStory(this, new UserStoryCleaner(this));
    defineWithin(super.layout);

    SimpleEventManager.getInstance().attach(new AbstractEventHandler<PrimeCountResultReady>(PrimeCountResultReady.class)
    {
        @Override
        public void handle(final PrimeCountResultReady event)
        {
            assert null != event : "Parameter 'event' of method 'handle' must not be null";

            final IPrototypeComponentVisitor visitor = new UserStoryOutputFeeder(event.getController());
            accept(visitor);
        }
    });
}
项目:context-menu    文件:ContextMenu.java   
/**
 * @param parentComponent
 *            The component to whose lifecycle the context menu is tied to.
 * @param setAsMenuForParentComponent
 *            Determines if this menu will be shown for the parent
 *            component.
 */
public ContextMenu(AbstractComponent parentComponent,
        boolean setAsMenuForParentComponent) {
    extend(parentComponent);

    registerRpc(new ContextMenuServerRpc() {
        @Override
        public void itemClicked(int itemId, boolean menuClosed) {
            menu.itemClicked(itemId);
        }
    });

    if (setAsMenuForParentComponent) {
        setAsContextMenuOf(parentComponent);
    }
}
项目:metl    文件:PluginsPanelAddDialog.java   
protected HorizontalLayout buildButtonFooter(AbstractComponent... toTheRightButtons) {
    HorizontalLayout footer = new HorizontalLayout();

    footer.setWidth("100%");
    footer.setSpacing(true);
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);

    Label footerText = new Label("");
    footerText.setSizeUndefined();

    footer.addComponents(footerText);
    footer.setExpandRatio(footerText, 1);

    if (toTheRightButtons != null) {
        footer.addComponents(toTheRightButtons);
    }

    return footer;
}
项目:mycollab    文件:AbstractEditItemComp.java   
@Override
public AbstractComponent getLayout() {
    final AddViewLayout formAddLayout = new AddViewLayout(initFormHeader(), initFormIconResource());

    final ComponentContainer buttonControls = createButtonControls();
    if (buttonControls != null) {
        formAddLayout.addHeaderRight(buttonControls);
    }

    formAddLayout.setTitle(initFormTitle());
    wrappedLayoutFactory = initFormLayoutFactory();
    formAddLayout.addBody(wrappedLayoutFactory.getLayout());

    final ComponentContainer bottomPanel = createBottomPanel();
    if (bottomPanel != null) {
        formAddLayout.addBottom(bottomPanel);
    }

    return formAddLayout;
}
项目:abstractform    文件:NumericPropertyFieldValueAccessor.java   
@Override
public Object getFieldValue(FormInstance formInstance, AbstractComponent field) {
    Property prop = (Property) field;
    Object value = prop.getValue();

    if (value != null && !numberClass.isAssignableFrom(value.getClass())) {
        try {

            // Gets the string constructor
            final Constructor<? extends Number> constr = numberClass.getConstructor(new Class[] { String.class });

            // Creates new object from the string
            value = constr.newInstance(new Object[] { value.toString() });
        } catch (final java.lang.Exception e) {
            throw new Property.ConversionException(e);
        }
    }
    return value;
}
项目:abstractform    文件:VaadinFormToolkit.java   
@Override
public VaadinFormInstance buildForm(Form form, Map<String, Object> extraObjects) {
    VerticalLayout layout = new VerticalLayout();
    Map<String, AbstractComponent> mapComponents = new HashMap<String, AbstractComponent>();
    List<String> fieldIdList = new ArrayList<String>();
    layout.setSpacing(true);
    layout.setSizeFull();
    for (Component part : form.getChildList()) {
        ComponentContainer container = buildComponent(part, mapComponents, fieldIdList, extraObjects);
        if (container != null) {
            layout.addComponent(container);
        }
    }
    addComponent(mapComponents, form, layout);
    VaadinFormInstance formInstance = new VaadinFormInstanceImpl(layout, Collections.unmodifiableMap(mapComponents),
            Collections.unmodifiableList(fieldIdList));

    //build SelectorProviders
    buildSelectorProviders(mapComponents, formInstance);
    return formInstance;
}
项目:abstractform    文件:VaadinFormToolkit.java   
protected void buildSelectorProviders(Map<String, AbstractComponent> mapComponents, VaadinFormInstance formInstance) {
    for (AbstractComponent component : mapComponents.values()) {
        if (component.getData() instanceof VaadinDataObject) {
            VaadinDataObject dataObject = (VaadinDataObject) component.getData();
            Field field = dataObject.getField();
            if (field.getType().equals(SelectorConstants.TYPE_SELECTOR)) {
                if (component instanceof Container.Viewer) {
                    Container.Viewer viewer = (Container.Viewer) component;
                    SelectorProviderFactory factory = (SelectorProviderFactory) field
                            .getExtra(SelectorConstants.EXTRA_SELECTOR_PROVIDER_FACTORY);
                    viewer.setContainerDataSource(new VaadinSelectorContainer(factory.createSelectorProvider(formInstance)));
                }
            }
        }
    }

}
项目:abstractform    文件:VaadinFormToolkit.java   
private ComponentContainer buildComponent(Component component, Map<String, AbstractComponent> mapComponents,
        List<String> fieldIdList, Map<String, Object> extraObjects) {
    AbstractComponentContainer container;
    if (component instanceof Drawer) {
        container = buildDrawer((Drawer) component, mapComponents, fieldIdList, extraObjects);
    } else if (component instanceof Section) {
        container = buildSection((Section) component, mapComponents, fieldIdList, extraObjects);
    } else if (component instanceof SubForm) {
        container = buildSubForm((SubForm) component, mapComponents, fieldIdList, extraObjects);
    } else if (component instanceof TabSheet) {
        container = buildTabSheet((TabSheet) component, mapComponents, fieldIdList, extraObjects);
    } else {
        throw new UnsupportedOperationException();
    }
    addComponent(mapComponents, component, container);
    return container;
}
项目:abstractform    文件:VaadinFormToolkit.java   
private AbstractComponentContainer buildTabSheet(TabSheet part, Map<String, AbstractComponent> mapComponents,
        List<String> fieldIdList, Map<String, Object> extraObjects) {
    com.vaadin.ui.TabSheet tabSheet = new com.vaadin.ui.TabSheet();
    for (Component component : part.getChildList()) {
        if (component instanceof Tab) {
            Tab tab = (Tab) component;
            VerticalLayout layout = new VerticalLayout();
            layout.setMargin(true);
            for (Component child : tab.getChildList()) {
                layout.addComponent(buildComponent(child, mapComponents, fieldIdList, extraObjects));
            }
            tabSheet.addTab(layout, tab.getName());
        } else {
            throw new UnsupportedOperationException();
        }
    }
    tabSheet.setSizeFull();
    return tabSheet;
}
项目:abstractform    文件:VaadinFormToolkit.java   
private AbstractComponentContainer buildSubForm(SubForm subForm, Map<String, AbstractComponent> mapComponents,
        List<String> fieldIdList, Map<String, Object> extraObjects) {
    //panel.setCaption(formEditor.getName());
    GridLayout layout = new GridLayout(subForm.getColumns(), subForm.getRows());
    layout.setWidth("100%");
    layout.setSpacing(true);
    for (int row = 0; row < subForm.getRows(); row++) {
        for (int column = 0; column < subForm.getColumns(); column++) {
            Component component = subForm.getField(row, column);
            if (component == null) {
                layout.addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));
            } else if (component instanceof Field) {
                Field editor = (Field) component;
                if (editor != null) {
                    layout.addComponent(buildField(editor, mapComponents, fieldIdList, extraObjects));
                }
            } else {
                buildComponent(component, mapComponents, fieldIdList, extraObjects);
            }
        }
    }
    return layout;
}
项目:vaadinator    文件:DefaultFieldInitializer.java   
@Override
public void initializeField(Component component, Component view) {
    if (view instanceof EagerValidatableView) {
        EagerValidatableView eagerValidatableView = (EagerValidatableView) view;
        if (component instanceof Field<?>) {
            ((AbstractComponent) component).setImmediate(true);
            ((Field<?>) component).addValueChangeListener(eagerValidatableView);
            if (component instanceof EagerValidateable) {
                ((EagerValidateable) component).setEagerValidation(true);
            }
            if (component instanceof TextChangeNotifier) {
                final TextChangeNotifier abstractTextField = (TextChangeNotifier) component;
                abstractTextField.addTextChangeListener(eagerValidatableView);
            }
        }
    }
}
项目:ilves    文件:AbstractValoView.java   
/**
 * Instantiates component for given slot.
 * @param slot The slot component will be placed to.
 * @return The instantiated component
 */
public final AbstractComponent getComponent(final String slot) {
    try {
        final ViewletDescriptor viewletDescriptor = slotViewletDescriptorMap.get(slot);
        if (viewletDescriptor != null) {
            final Class<?> componentClass = Class.forName(viewletDescriptor.getComponentClass());
            final AbstractComponent component = (AbstractComponent) componentClass.newInstance();
            //component.setDescription(viewletDescriptor.getDescription());
            if (component instanceof Viewlet) {
                ((Viewlet) component).setViewletDescriptor(viewletDescriptor);
            }
            slotComponentMap.put(slot, component);
            return component;
        } else {
            return null;
        }
    } catch (final Exception e) {
        throw new SiteException("Error instantiating viewlet for page: " + pageVersion.getTitle()
                + " version: " + pageVersion.getVersion() + " slot: "
                + slot, e);
    }
}
项目:mycollab    文件:MilestoneComponentFactoryImpl.java   
@Override
public AbstractComponent createStartDatePopupField(SimpleMilestone milestone) {
    if (milestone.getStartdate() == null) {
        Div divHint = new Div().setCSSClass("nonValue");
        divHint.appendText(VaadinIcons.TIME_FORWARD.getHtml());
        divHint.appendChild(new Span().appendText(UserUIContext.getMessage(GenericI18Enum.OPT_UNDEFINED)).setCSSClass("hide"));
        return new MetaFieldBuilder().withCaption(divHint.write())
                .withDescription(UserUIContext.getMessage(ShellI18nEnum.OPT_UPGRADE_PRO_INTRO,
                        UserUIContext.getMessage(GenericI18Enum.FORM_START_DATE))).build();
    } else {
        return new MetaFieldBuilder().withCaption(String.format(" %s %s", VaadinIcons.TIME_FORWARD.getHtml(),
                UserUIContext.formatDate(milestone.getStartdate())))
                .withDescription(UserUIContext.getMessage(ShellI18nEnum.OPT_UPGRADE_PRO_INTRO,
                        UserUIContext.getMessage(GenericI18Enum.FORM_START_DATE))).build();
    }
}
项目:mycollab    文件:MilestoneComponentFactoryImpl.java   
@Override
public AbstractComponent createEndDatePopupField(SimpleMilestone milestone) {
    if (milestone.getEnddate() == null) {
        Div divHint = new Div().setCSSClass("nonValue");
        divHint.appendText(VaadinIcons.TIME_BACKWARD.getHtml());
        divHint.appendChild(new Span().appendText(UserUIContext.getMessage(GenericI18Enum.OPT_UNDEFINED)).setCSSClass("hide"));
        return new MetaFieldBuilder().withCaption(divHint.write())
                .withDescription(UserUIContext.getMessage(ShellI18nEnum.OPT_UPGRADE_PRO_INTRO,
                        UserUIContext.getMessage(GenericI18Enum.FORM_END_DATE))).build();
    } else {
        return new MetaFieldBuilder().withCaption(String.format(" %s %s", VaadinIcons.TIME_BACKWARD.getHtml(),
                UserUIContext.formatDate(milestone.getEnddate())))
                .withDescription(UserUIContext.getMessage(ShellI18nEnum.OPT_UPGRADE_PRO_INTRO,
                        UserUIContext.getMessage(GenericI18Enum.FORM_END_DATE))).build();
    }
}
项目:mycollab    文件:TaskComponentFactoryImpl.java   
@Override
public AbstractComponent createPercentagePopupField(SimpleTask task) {
    if (task.getPercentagecomplete() != null && task.getPercentagecomplete() > 0) {
        return new MetaFieldBuilder().withCaptionAndIcon(VaadinIcons.CALENDAR_CLOCK,
                String.format(" %s%%", task.getPercentagecomplete()))
                .withDescription(UserUIContext.getMessage(ShellI18nEnum.OPT_UPGRADE_PRO_INTRO,
                        UserUIContext.getMessage(TaskI18nEnum.FORM_PERCENTAGE_COMPLETE))).build();
    } else {
        Div divHint = new Div().setCSSClass("nonValue");
        divHint.appendText(VaadinIcons.CALENDAR_CLOCK.getHtml());
        divHint.appendChild(new Span().appendText(UserUIContext.getMessage(GenericI18Enum.OPT_UNDEFINED)).setCSSClass("hide"));
        return new MetaFieldBuilder().withCaption(divHint.write())
                .withDescription(UserUIContext.getMessage(ShellI18nEnum.OPT_UPGRADE_PRO_INTRO,
                        UserUIContext.getMessage(TaskI18nEnum.FORM_PERCENTAGE_COMPLETE))).build();
    }
}
项目:mycollab    文件:TaskComponentFactoryImpl.java   
@Override
public AbstractComponent createDeadlinePopupField(SimpleTask task) {
    if (task.getDeadlineRoundPlusOne() == null) {
        Div divHint = new Div().setCSSClass("nonValue");
        divHint.appendText(FontAwesome.CLOCK_O.getHtml());
        divHint.appendChild(new Span().appendText(UserUIContext.getMessage(GenericI18Enum.OPT_UNDEFINED)).setCSSClass("hide"));
        return new MetaFieldBuilder().withCaption(divHint.write())
                .withDescription(UserUIContext.getMessage(ShellI18nEnum.OPT_UPGRADE_PRO_INTRO,
                        UserUIContext.getMessage(GenericI18Enum.FORM_DUE_DATE))).build();
    } else {
        return new MetaFieldBuilder().withCaption(String.format(" %s %s", FontAwesome.CLOCK_O.getHtml(),
                UserUIContext.formatPrettyTime(task.getDeadlineRoundPlusOne())))
                .withDescription(UserUIContext.getMessage(ShellI18nEnum.OPT_UPGRADE_PRO_INTRO,
                        UserUIContext.getMessage(GenericI18Enum.FORM_DUE_DATE))).build();
    }
}
项目:mycollab    文件:TaskComponentFactoryImpl.java   
@Override
public AbstractComponent createStartDatePopupField(SimpleTask task) {
    if (task.getStartdate() == null) {
        Div divHint = new Div().setCSSClass("nonValue");
        divHint.appendText(VaadinIcons.TIME_FORWARD.getHtml());
        divHint.appendChild(new Span().appendText(UserUIContext.getMessage(GenericI18Enum.OPT_UNDEFINED)).setCSSClass("hide"));
        return new MetaFieldBuilder().withCaption(divHint.write())
                .withDescription(UserUIContext.getMessage(ShellI18nEnum.OPT_UPGRADE_PRO_INTRO,
                        UserUIContext.getMessage(GenericI18Enum.FORM_START_DATE))).build();
    } else {
        return new MetaFieldBuilder().withCaption(String.format(" %s %s", VaadinIcons.TIME_FORWARD.getHtml(),
                UserUIContext.formatDate(task.getStartdate())))
                .withDescription(UserUIContext.getMessage(ShellI18nEnum.OPT_UPGRADE_PRO_INTRO,
                        UserUIContext.getMessage(GenericI18Enum.FORM_START_DATE))).build();
    }
}
项目:mycollab    文件:TaskComponentFactoryImpl.java   
@Override
public AbstractComponent createEndDatePopupField(SimpleTask task) {
    if (task.getEnddate() == null) {
        Div divHint = new Div().setCSSClass("nonValue");
        divHint.appendText(VaadinIcons.TIME_BACKWARD.getHtml());
        divHint.appendChild(new Span().appendText(UserUIContext.getMessage(GenericI18Enum.OPT_UNDEFINED)).setCSSClass("hide"));
        return new MetaFieldBuilder().withCaption(divHint.write())
                .withDescription(UserUIContext.getMessage(ShellI18nEnum.OPT_UPGRADE_PRO_INTRO,
                        UserUIContext.getMessage(GenericI18Enum.FORM_END_DATE))).build();
    } else {
        return new MetaFieldBuilder().withCaption(String.format(" %s %s", VaadinIcons.TIME_BACKWARD.getHtml(),
                UserUIContext.formatDate(task.getEnddate())))
                .withDescription(UserUIContext.getMessage(ShellI18nEnum.OPT_UPGRADE_PRO_INTRO,
                        UserUIContext.getMessage(GenericI18Enum.FORM_END_DATE))).build();
    }
}
项目:mycollab    文件:MeetingFormLayoutFactory.java   
@Override
public AbstractComponent getLayout() {
    AddViewLayout2 meetingLayout = new AddViewLayout2(title, CrmAssetsManager.getAsset(CrmTypeConstants.MEETING));

    Layout topPanel = createTopPanel();
    if (topPanel != null) {
        meetingLayout.addControlButtons(topPanel);
    }
    wrappedLayoutFactory = new DefaultDynaFormLayout(CrmTypeConstants.MEETING, MeetingDefaultFormLayoutFactory.getForm());
    VerticalLayout body = new VerticalLayout();
    body.setStyleName(WebThemes.BOX);
    body.addComponent(wrappedLayoutFactory.getLayout());
    meetingLayout.addBody(body);

    return meetingLayout;
}
项目:mycollab    文件:TicketComponentFactoryImpl.java   
@Override
public AbstractComponent createStartDatePopupField(ProjectTicket assignment) {
    if (assignment.getStartDate() == null) {
        Div divHint = new Div().setCSSClass("nonValue");
        divHint.appendText(VaadinIcons.TIME_FORWARD.getHtml());
        divHint.appendChild(new Span().appendText(UserUIContext.getMessage(GenericI18Enum.OPT_UNDEFINED)).setCSSClass("hide"));
        return new MetaFieldBuilder().withCaption(divHint.write())
                .withDescription(UserUIContext.getMessage(ShellI18nEnum.OPT_UPGRADE_PRO_INTRO,
                        UserUIContext.getMessage(GenericI18Enum.FORM_START_DATE))).build();
    } else {
        return new MetaFieldBuilder().withCaption(String.format(" %s %s", VaadinIcons.TIME_FORWARD.getHtml(),
                UserUIContext.formatDate(assignment.getStartDate())))
                .withDescription(UserUIContext.getMessage(ShellI18nEnum.OPT_UPGRADE_PRO_INTRO,
                        UserUIContext.getMessage(GenericI18Enum.FORM_START_DATE))).build();
    }
}
项目:holon-vaadin7    文件:AbstractCustomField.java   
/**
 * Initialize and configure the internal wrapped field
 */
protected void init() {
    // build internal field
    this.internalField = buildInternalField(getType());

    // use this field as data source for internal field
    if (this.internalField instanceof AbstractComponent) {
        ((AbstractComponent) this.internalField).setImmediate(true);
    }
    this.internalField.setBuffered(false);
    this.internalField.setPropertyDataSource(this);
}
项目:tinypounder    文件:TinyPounderMainUI.java   
private TextArea getConsole(String key) throws NoSuchElementException {
  for (Component console : consoles) {
    if (key.equals(((AbstractComponent) console).getData())) {
      return (TextArea) console;
    }
  }
  throw new NoSuchElementException("No console found for " + key);
}
项目:vaadin-016-helloworld-14    文件:TestbenchFunctions.java   
static Function<Class<? extends AbstractComponent>, Optional<Class<? extends AbstractElement>>> conv() {
  return (componentClass) -> {
    final Predicate<Class<? extends AbstractComponent>> is = componentClass::isAssignableFrom;

    if (is.test(Button.class)) return Optional.of(ButtonElement.class);
    if (is.test(TextField.class)) return Optional.of(TextFieldElement.class);

    return Optional.empty();
  };
}
项目:holon-vaadin    文件:AbstractComposableForm.java   
/**
 * Setup the {@link Component} associated with given {@link Property}.
 * @param property Property
 * @param component Component
 * @param fullWidth whether to set the Component to 100% width according to {@link #getComponentsWidthMode()}
 */
protected void setupPropertyComponent(Property<?> property, Component component, boolean fullWidth) {
    if (fullWidth) {
        component.setWidth(100, Unit.PERCENTAGE);
    }
    // check configurator
    getPropertyComponentConfigurator(property).ifPresent(consumer -> {
        if (!(component instanceof AbstractComponent)) {
            throw new TypeMismatchException("Cannot configure Component of type [" + component.getClass().getName()
                    + "] using the ComponentConfigurator associated with property [" + property
                    + "]: the Component must extend AbstractComponent");
        }
        consumer.accept(BaseComponentConfigurator.create((AbstractComponent) component));
    });
}
项目:holon-vaadin    文件:AbstractComponentBuilder.java   
@Override
public B dragSource(Consumer<DragSourceExtension<? extends AbstractComponent>> configurator) {
    final DragSourceExtension<I> extension = new DragSourceExtension<>(getInstance());
    if (configurator != null) {
        configurator.accept(extension);
    }
    return builder();
}
项目:bean-grid    文件:AbstractSummarizer.java   
@Override
public Optional<Component> getComponent() {
    return Optional.of(new AbstractComponent() {
        @Override
        public Object getData() {
            return definition;
        }
    });
}
项目:businesshorizon2    文件:ScenarioViewImpl.java   
public void updateLabels() {
    int number = 1;

    for(HashMap<String, AbstractComponent> scenarioComponents : this.scenarios) {
        ((Label) scenarioComponents.get("label")).setValue("<strong>Szenario " + number + "</strong>");
        number++;
    }
}
项目:businesshorizon2    文件:ScenarioScreenViewImpl.java   
public void updateLabels() {
    int number = 1;

    for(HashMap<String, AbstractComponent> scenarioComponents : this.scenarios) {
        ((Label) scenarioComponents.get("label")).setValue("<strong>Szenario " + number + "</strong>");
        number++;
    }
}
项目:cuba    文件:MenuBuilder.java   
protected void assignShortcut(Window webWindow, AppMenu.MenuItem menuItem, MenuItem item) {
    KeyCombination itemShortcut = item.getShortcut();
    if (itemShortcut != null) {
        ShortcutListener shortcut = new MenuShortcutAction(menuItem, "shortcut_" + item.getId(), item.getShortcut());

        AbstractComponent windowImpl = webWindow.unwrap(AbstractComponent.class);
        windowImpl.addShortcutListener(shortcut);

        appMenu.setMenuItemShortcutCaption(menuItem, itemShortcut.format());
    }
}
项目:cuba    文件:SideMenuBuilder.java   
protected void assignShortcut(Window webWindow, SideMenu.MenuItem menuItem, MenuItem item) {
    KeyCombination itemShortcut = item.getShortcut();
    if (itemShortcut != null) {
        ShortcutListener shortcut = new SideMenuShortcutListener(menuItem, item);

        AbstractComponent windowImpl = webWindow.unwrap(AbstractComponent.class);
        windowImpl.addShortcutListener(shortcut);

        if (Strings.isNullOrEmpty(menuItem.getBadgeText())) {
            menuItem.setDescription(itemShortcut.format());
        }
    }
}
项目:cuba    文件:CubaTable.java   
@Override
public void showCustomPopup(Component popupComponent) {
    if (getState().customPopup != null) {
        ((AbstractComponent) getState().customPopup).setParent(null);
    }

    getState().customPopup = popupComponent;
    getRpcProxy(CubaTableClientRpc.class).showCustomPopup();

    popupComponent.setParent(this);
}
项目:cuba    文件:WebAbstractComponent.java   
@Override
public boolean isResponsive() {
    com.vaadin.ui.Component composition = getComposition();
    if (composition instanceof AbstractComponent) {
        return ((AbstractComponent) composition).isResponsive();
    }
    return false;
}
项目:cuba    文件:WebAbstractComponent.java   
@Override
public void setResponsive(boolean responsive) {
    com.vaadin.ui.Component composition = getComposition();

    if (composition instanceof AbstractComponent) {
        ((AbstractComponent) composition).setResponsive(true);
    }
}
项目:cuba    文件:WebAbstractComponent.java   
protected boolean hasValidationError() {
    if (getComposition() instanceof AbstractComponent) {
        AbstractComponent composition = (AbstractComponent) getComposition();
        return composition.getComponentError() instanceof UserError;
    }
    return false;
}