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

项目:material-theme-fw8    文件:ButtonsView.java   
private Component createRaisedButtonVariables(boolean lightTheme) {
    String theme = lightTheme ? RAISED_BUTTONS_LIGHT_THEME : RAISED_BUTTONS_DARK_THEME;
    String prefix = "$" + (lightTheme ? Styles.Buttons.Raised.LIGHT : Styles.Buttons.Raised.DARK);

    MDDataTableLayout dt = new MDDataTableLayout();
    dt.setHeaders("Name", "Information");
    dt.addItem(prefix + "-font-color", createVariableLayout(FONT_COLOR, TYPE_COLOR, theme));
    dt.addItem(prefix + "-bg-color", createVariableLayout(BACKGROUND_COLOR, TYPE_COLOR, theme));
    dt.addItem(prefix + "-focus-bg-color", createVariableLayout(FOCUSED_BACKGROUND_COLOR, TYPE_COLOR, theme));
    dt.addItem(prefix + "-ripple-color", createVariableLayout(RIPPLE_COLOR, TYPE_COLOR, theme));
    dt.addItem(prefix + "-disabled-font-color", createVariableLayout(DISABLED_FONT_COLOR, TYPE_COLOR, theme));
    dt.addItem(prefix + "-disabled-bg-color", createVariableLayout(DISABLED_BACKGROUND_COLOR, TYPE_COLOR, theme));
    dt.setColumnWidth(0, 40, Unit.PERCENTAGE);
    dt.setColumnWidth(1, 60, Unit.PERCENTAGE);
    dt.addStyleName(Margins.Bottom.LARGE);
    return dt;
}
项目:material-theme-fw8    文件:MDDataTableLayout.java   
public void addItem(Object... values) {
    FlexLayout item = new FlexLayout();
    item.setPrimaryStyleName("md-datatable-row");
    item.addStyleName(Spacings.Right.LARGE);
    item.addStyleName(Paddings.Vertical.TABLE);
    for (Object value : values) {
        if (value instanceof String) {
            Label lbl = new Label((String) value);
            lbl.setContentMode(ContentMode.HTML);
            lbl.setPrimaryStyleName(Typography.Dark.Table.Row.PRIMARY);
            item.addComponent(lbl);
        } else if (value instanceof Component) {
            item.addComponent((Component) value);
        }
    }
    items.addComponent(item);
}
项目:bootstrap-formgroup    文件:NativeSelectGroupUI.java   
@Override
public Component getTestComponent() {
    NativeSelectGroup<String> field = new NativeSelectGroup<>();

    field.setCaption("Caption");
    field.setDescription("Description");
    field.getField().setItems("1", "2", "3");

    Button action1 = new Button("Change Mode to Danger");
    action1.setId("action1");
    action1.addClickListener(event -> {
        field.setMode(BootstrapMode.DANGER);
    });

    Button action2 = new Button("Remove Mode");
    action2.setId("action2");
    action2.addClickListener(event -> {
        field.removeMode();
    });

    MyCustomLayout layout = new MyCustomLayout(FormGroupHtml.BASIC, action1, action2);
    layout.addComponent(field, "field");

    return layout;
}
项目:osc-core    文件:BaseSecurityGroupInterfaceWindow.java   
protected Component getPolicy() {
    try {
        this.policy = new ComboBox("Select Policy");
        this.policy.setTextInputAllowed(false);
        this.policy.setNullSelectionAllowed(false);
        this.policy.setImmediate(true);
        this.policy.setRequired(true);
        this.policy.setRequiredError("Policy cannot be empty");
        populatePolicy();

    } catch (Exception e) {
        ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
        log.error("Error populating Policy List combobox", e);
    }

    return this.policy;
}
项目:crawling-framework    文件:HttpSourceStatsWindow.java   
public HttpSourceStatsWindow(String sourceUrl) {
    setModal(true);
    center();
    setCaption(String.format("%s crawling statistics", sourceUrl));
    setWidth(50, Unit.PERCENTAGE);
    setHeight(50, Unit.PERCENTAGE);
    List<DateHistogramValue> urls = ElasticSearch.getUrlOperations().calculateStats(sourceUrl);
    List<DateHistogramValue> documents = ElasticSearch.getDocumentOperations().calculateStats(sourceUrl);
    Component layout = getChart(sourceUrl, urls, documents);
    layout.setWidth(100, Unit.PERCENTAGE);
    setContent(layout);
}
项目:bean-grid    文件:AbstractSummarizer.java   
@Override
public Optional<Component> getComponent() {
    return Optional.of(new AbstractComponent() {
        @Override
        public Object getData() {
            return definition;
        }
    });
}
项目:holon-vaadin7    文件:ContainerViewDisplay.java   
@Override
protected void showViewContent(Component content) {
    container.removeAllComponents();
    if (content != null) {
        container.addComponent(content);
    }
}
项目:textfieldformatter    文件:DefaultNumeralFieldFormatterUsageUI.java   
@Override
public Component getTestComponent() {
    TextField tf = new TextField();
    new NumeralFieldFormatter(tf);
    tf.addValueChangeListener(l -> Notification.show("Value: " + l.getValue()));
    return tf;
}
项目:holon-vaadin7    文件:AbstractCustomField.java   
@Override
protected Component initContent() {
    final Field<?> content = getInternalField();
    if (getWidth() > -1) {
        content.setWidth(100, Unit.PERCENTAGE);
    }
    if (getHeight() > -1) {
        content.setHeight(100, Unit.PERCENTAGE);
    }
    return content;
}
项目:holon-vaadin    文件:DefaultPropertyInputGroup.java   
@SuppressWarnings("unchecked")
@Override
public Stream<PropertyBinding<?, Component>> streamOfComponents() {
    return propertySet.stream().filter(p -> !_propertyConfiguration(p).isHidden())
            .filter(p -> _propertyConfiguration(p).getInput().isPresent())
            .map(p -> PropertyBinding.create(p, _propertyConfiguration(p).getInput().get().getComponent()));
}
项目:holon-vaadin7    文件:DefaultOrderedLayoutConfigurator.java   
@Override
public com.holonplatform.vaadin.components.builders.OrderedLayoutConfigurator.BaseOrderedLayoutConfigurator addAlignAndExpand(
        Component component, Alignment alignment, float expandRatio) {
    getInstance().addComponent(component);
    getInstance().setComponentAlignment(component, alignment);
    getInstance().setExpandRatio(component, expandRatio);
    return builder();
}
项目:holon-vaadin    文件:InputConverterAdapter.java   
/**
 * Build the {@link ValueContext} to be used with the converter.
 * @return the {@link ValueContext}
 */
private ValueContext _valueContext() {
    final Component component = getComponent();
    if (component != null) {
        return new ValueContext(component);
    } else {
        return new ValueContext();
    }
}
项目:esup-ecandidat    文件:RequiredStringCheckBox.java   
/**
 * @see com.vaadin.ui.CustomField#initContent()
 */
@Override
protected Component initContent() {
    if (value==null || value.equals(ConstanteUtils.TYP_BOOLEAN_NO)){
        field.setValue(false);
    }else{
        field.setValue(true);
    }       
    return field;
}
项目:osc-core    文件:ViewUtil.java   
/**
 * @param enabled
 *            either enable or disable all the buttons in the gived Layout
 * @param layout
 *            Layout these buttons belongs to
 * @param ignoreList
 *            Buttons who does not need this state change i.e. Add button
 */
public static void setButtonsEnabled(boolean enabled, HorizontalLayout layout, List<String> ignoreList) {
    if (layout != null) {
        Iterator<Component> iterate = layout.iterator();
        while (iterate.hasNext()) {
            Component c = iterate.next();
            if (c instanceof Button && !ignoreList.contains(c.getId())) {
                c.setEnabled(enabled);
            }
        }
    }
}
项目:osc-core    文件:OSCViewProvider.java   
public OSCViewProvider(String name, Class<T> type, ComponentServiceObjects<T> factory) {
    this.name = Objects.requireNonNull(name, "The view must have a name");
    Objects.requireNonNull(type, "The view must have a type");
    if (!Component.class.isAssignableFrom(type)) {
        throw new IllegalArgumentException("The type must be a Vaadin Component");
    }
    this.type = type;

    this.factory = Objects.requireNonNull(factory, "The view must have a factory");
}
项目:osc-core    文件:ViewUtil.java   
/**
 *
 * @param enabled
 *            either enable or disable given set of buttons
 * @param layout
 *            Layout these buttons belongs to
 * @param itemsToEnable
 *            List of Buttons which needs to be enabled/disabled
 */
public static void enableToolBarButtons(boolean enabled, HorizontalLayout layout, List<String> itemsToEnable) {
    if (layout != null) {
        Iterator<Component> iterate = layout.iterator();
        while (iterate.hasNext()) {
            Component c = iterate.next();
            if (c instanceof Button && itemsToEnable.contains(c.getId())) {
                c.setEnabled(enabled);
            }
        }
    }
}
项目:holon-vaadin    文件:DefaultPropertyListing.java   
@SuppressWarnings("unchecked")
@Override
protected <E extends HasValue<?> & Component> Optional<E> getDefaultPropertyEditor(Property property) {
    try {
        return property.renderIfAvailable(Field.class);
    } catch (Exception e) {
        if (isEditable()) {
            LOGGER.warn("No default property editor available for property [" + property + "]", e);
        }
        return Optional.empty();
    }
}
项目:easybinder    文件:AutoBinder.java   
protected Component createAndBind(Field f, String path) {
    Optional<Component> c = ComponentFactoryRegistry.getInstance().createComponent(f);
    if (!c.isPresent()) {
        throw new RuntimeException("No Component factory matches field, field=<" + f + ">");
    }

    if (c.get() instanceof HasValue<?>) {
        HasValue<?> h = (HasValue<?>) c.get();
        bind(h, path + f.getName());
    }
    return c.get();
}
项目:textfieldformatter    文件:BasicCreditCardFieldFormatterUsageUI.java   
@Override
public Component getTestComponent() {
    TextField tf = new TextField();
    CreditCardFieldFormatter formatter = new CreditCardFieldFormatter(tf);
    formatter.addCreditCardChangedListener(l -> Notification.show("Card type: " + l.getCreditCardType()));
    return tf;
}
项目:easybinder    文件:GridExample.java   
@Override
public Component getTestComponent() {
    Flight flight1 = new Flight();
    FlightId id1 = new FlightId();
    id1.setAirline("XX");
    id1.setFlightNumber(100);
    id1.setFlightSuffix('C');
    id1.setDate(new Date());
    id1.setLegType(LegType.DEPARTURE);
    flight1.setFlightId(id1);
    flight1.setCanceled(false);

    Flight flight2 = new Flight();
    FlightId id2 = new FlightId();
    id2.setAirline("YY");
    id2.setFlightNumber(100);
    id2.setFlightSuffix('C');
    id2.setDate(new Date());
    id2.setLegType(LegType.DEPARTURE);
    flight2.setFlightId(id2);
    flight2.setCanceled(false);

    AutoBinder<Flight> binder = new AutoBinder<>(Flight.class);

    binder.buildAndBind("flightId");

    EGrid<Flight> grid = new EGrid<>(binder);

    grid.setItems(flight1, flight2);

    grid.setWidth("100%");
    grid.getEditor().setEnabled(true);

    return grid;
}
项目:osc-core    文件:SecurityGroupMembershipInfoWindow.java   
public Component getTreeTable() throws Exception {
    VerticalLayout content = new VerticalLayout();
    content.setMargin(new MarginInfo(true, true, false, true));

    this.treeTable = new TreeTable();
    this.treeTable.setPageLength(10);
    this.treeTable.setSelectable(false);
    this.treeTable.setSizeFull();

    this.treeTable.addContainerProperty(PROPERTY_ID_MEMBER_NAME, String.class, "");
    this.treeTable.addContainerProperty(PROPERTY_ID_MEMBER_TYPE, String.class, "");
    this.treeTable.addContainerProperty(PROPERTY_ID_MEMBER_IP, String.class, "");
    this.treeTable.addContainerProperty(PROPERTY_ID_MEMBER_MAC, String.class, "");

    this.treeTable.setColumnHeader(PROPERTY_ID_MEMBER_NAME, VmidcMessages.getString(VmidcMessages_.NAME));
    this.treeTable.setColumnHeader(PROPERTY_ID_MEMBER_TYPE, VmidcMessages.getString(VmidcMessages_.OS_MEMBER_TYPE));
    this.treeTable.setColumnHeader(PROPERTY_ID_MEMBER_MAC, VmidcMessages.getString(VmidcMessages_.GENERAL_MACADDR));
    this.treeTable.setColumnHeader(PROPERTY_ID_MEMBER_IP, VmidcMessages.getString(VmidcMessages_.GENERAL_IPADDR));

    this.treeTable.setColumnWidth(PROPERTY_ID_MEMBER_NAME, NAME_COLUMN_WIDTH);
    this.treeTable.setColumnWidth(PROPERTY_ID_MEMBER_TYPE, TYPE_COLUMN_WIDTH);
    this.treeTable.setColumnWidth(PROPERTY_ID_MEMBER_MAC, MAC_COLUMN_WIDTH);
    this.treeTable.setColumnWidth(PROPERTY_ID_MEMBER_IP, IP_COLUMN_WIDTH);

    populateData();
    content.addComponent(this.treeTable);
    return content;
}
项目:holon-vaadin    文件:DefaultOrderedLayoutConfigurator.java   
@Override
public com.holonplatform.vaadin.components.builders.OrderedLayoutConfigurator.BaseOrderedLayoutConfigurator expand(
        Component component, float expandRatio) {
    getInstance().setExpandRatio(component, expandRatio);
    return builder();
}
项目:holon-vaadin    文件:DefaultPropertyColumn.java   
@SuppressWarnings("unchecked")
@Override
public <E extends HasValue<?> & Component> Optional<E> getEditor() {
    final E hvc = (E) editor;
    return Optional.ofNullable(hvc);
}
项目:holon-vaadin7    文件:ViewFour.java   
@Override
public Component getViewContent() {
    return new Label("FOUR");
}
项目:holon-vaadin7    文件:ExampleView.java   
@Override
public Component getViewContent() { // <3>
    boolean mobile = DeviceInfo.get().map(info -> info.isMobile()).orElse(false);
    return mobile ? buildMobileViewContent() : buildDefaultViewContent();
}
项目:esup-ecandidat    文件:LocalDateTimeField.java   
/**
 * @see com.vaadin.ui.CustomField#initContent()
 */
@Override
protected Component initContent() {
    setDateTimeValue(timeValue);        
    return hlContent;
}
项目:history-api-navigation    文件:OtherView.java   
@Override
public Component getComponent()
{
    return rootLayout;
}
项目:material-theme-fw8    文件:ColorsView.java   
private Component createListItem(String primary, boolean last) {
    SingleLineListItem item = new SingleLineListItem(primary, false);
    if (last) item.addStyleName(Margins.Bottom.LARGE);
    return item;
}
项目:holon-vaadin    文件:StringArea.java   
@Override
public Component getComponent() {
    return this;
}
项目:material-theme-fw8    文件:DataTablesView.java   
private CssLayout createCard(Component... components) {
    FlexLayout card = new FlexLayout(FlexLayout.FlexDirection.COLUMN, components);
    card.addStyleName("card");
    card.setWidth(100, Unit.PERCENTAGE);
    return card;
}
项目:holon-vaadin7    文件:ViewNavigationUtils.java   
/**
 * Build a {@link ViewConfiguration} using given view class
 * @param viewClass View class (not null)
 * @return ViewConfiguration
 * @throws ViewConfigurationException Error building view configuration
 */
public static ViewConfiguration buildViewConfiguration(Class<? extends View> viewClass)
        throws ViewConfigurationException {
    if (viewClass == null) {
        throw new ViewConfigurationException("Null view class");
    }

    // check valid navigation view
    boolean viewContentProvider = false;
    if (ViewContentProvider.class.isAssignableFrom(viewClass)) {
        viewContentProvider = true;
    } else {
        if (!Component.class.isAssignableFrom(viewClass)) {
            throw new ViewConfigurationException(
                    "Invalid navigation view class " + viewClass.getName() + ": View class must be a "
                            + Component.class.getName() + " or a " + ViewContentProvider.class.getName());
        }
    }

    DefaultViewConfiguration cfg = new DefaultViewConfiguration();
    cfg.setViewContentProvider(viewContentProvider);

    cfg.setSubViewContainer(SubViewContainer.class.isAssignableFrom(viewClass));

    SubViewOf sv = viewClass.getAnnotation(SubViewOf.class);
    if (sv != null) {
        String parentViewName = sv.value();
        if (AnnotationUtils.isEmpty(parentViewName)) {
            throw new ViewConfigurationException("Invalid sub view declaration for view class" + viewClass.getName()
                    + ": parent view name must be not null or empty");
        }
        cfg.setParentViewName(parentViewName);
    }

    cfg.setParameters(getViewParameterDefinitions(viewClass));

    List<Method> onShows = getViewOnShowMethods(viewClass);
    cfg.setOnShowMethods(onShows);
    if (onShows != null) {
        for (Method method : onShows) {
            if (method.getAnnotation(OnShow.class).onRefresh()) {
                cfg.setFireOnRefreshMethod(method);
            }
        }
    }

    cfg.setOnLeaveMethods(getViewOnLeaveMethods(viewClass));

    cfg.setContextInjectionFields(getContextInjectionFields(viewClass));

    cfg.setVolatile(viewClass.isAnnotationPresent(VolatileView.class));

    cfg.setAuthentication(viewClass.getAnnotation(Authenticate.class));

    WindowView wv = viewClass.getAnnotation(WindowView.class);
    if (wv != null) {
        cfg.setForceInWindow(true);
        cfg.setWindowConfiguration(wv);
    }

    Caption cpt = viewClass.getAnnotation(Caption.class);
    if (cpt != null) {
        cfg.setCaption(cpt.value());
        cfg.setCaptionMessageCode(cpt.messageCode());
    }

    return cfg;
}
项目:holon-vaadin    文件:AbstractComposableForm.java   
@Override
public Component getContent() {
    return getCompositionRoot();
}
项目:osc-core    文件:CloseButtonModel.java   
@Override
public List<Component> getComponents() {
    return Arrays.asList(this.closeButton);
}
项目:holon-vaadin    文件:AbstractLayoutConfigurator.java   
@Override
public B align(Component component, Alignment alignment) {
    getInstance().setComponentAlignment(component, alignment);
    return builder();
}
项目:osc-core    文件:ApproveCancelButtonModel.java   
@Override
public List<Component> getComponents() {
    return Arrays.asList(this.rejectButton, this.approveButton);
}
项目:holon-vaadin    文件:BooleanField.java   
@Override
public Component getComponent() {
    return this;
}
项目:esup-ecandidat    文件:ComboBoxPresentation.java   
/**
 * @see com.vaadin.ui.CustomField#initContent()
 */
@Override
protected Component initContent() {
    return field;
}
项目:material-theme-fw8    文件:ButtonsView.java   
private Component createCaptionRow(String key, String value) {
    FlexLayout row = new FlexLayout(createCaption(key), createTableRow(value));
    row.setAlignItems(AlignItems.CENTER);
    return row;
}
项目:holon-vaadin7    文件:SecretField.java   
@Override
public Component getComponent() {
    return this;
}
项目:holon-vaadin    文件:DefaultPropertyViewGroup.java   
@Override
public Stream<Component> getComponents() {
    return properties.stream().filter(p -> propertyViews.containsKey(p))
            .map(p -> propertyViews.get(p).getComponent());
}