Java Code Examples for com.vaadin.ui.Component

The following are top voted examples for showing how to use com.vaadin.ui.Component. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: material-theme-fw8   File: ButtonsView.java   View source code 6 votes vote down vote up
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;
}
 
Example 2
Project: material-theme-fw8   File: MDDataTableLayout.java   View source code 6 votes vote down vote up
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);
}
 
Example 3
Project: bootstrap-formgroup   File: NativeSelectGroupUI.java   View source code 6 votes vote down vote up
@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;
}
 
Example 4
Project: osc-core   File: BaseSecurityGroupInterfaceWindow.java   View source code 6 votes vote down vote up
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;
}
 
Example 5
Project: crawling-framework   File: HttpSourceStatsWindow.java   View source code 5 votes vote down vote up
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);
}
 
Example 6
Project: bean-grid   File: AbstractSummarizer.java   View source code 5 votes vote down vote up
@Override
public Optional<Component> getComponent() {
	return Optional.of(new AbstractComponent() {
		@Override
		public Object getData() {
			return definition;
		}
	});
}
 
Example 7
Project: holon-vaadin7   File: ContainerViewDisplay.java   View source code 5 votes vote down vote up
@Override
protected void showViewContent(Component content) {
	container.removeAllComponents();
	if (content != null) {
		container.addComponent(content);
	}
}
 
Example 8
Project: textfieldformatter   File: DefaultNumeralFieldFormatterUsageUI.java   View source code 5 votes vote down vote up
@Override
public Component getTestComponent() {
	TextField tf = new TextField();
	new NumeralFieldFormatter(tf);
	tf.addValueChangeListener(l -> Notification.show("Value: " + l.getValue()));
	return tf;
}
 
Example 9
Project: holon-vaadin7   File: AbstractCustomField.java   View source code 5 votes vote down vote up
@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;
}
 
Example 10
Project: holon-vaadin   File: DefaultPropertyInputGroup.java   View source code 5 votes vote down vote up
@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()));
}
 
Example 11
Project: holon-vaadin7   File: DefaultOrderedLayoutConfigurator.java   View source code 5 votes vote down vote up
@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();
}
 
Example 12
Project: holon-vaadin   File: InputConverterAdapter.java   View source code 5 votes vote down vote up
/**
 * 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();
	}
}
 
Example 13
Project: esup-ecandidat   File: RequiredStringCheckBox.java   View source code 5 votes vote down vote up
/**
 * @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;
}
 
Example 14
Project: osc-core   File: ViewUtil.java   View source code 5 votes vote down vote up
/**
 * @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);
            }
        }
    }
}
 
Example 15
Project: osc-core   File: OSCViewProvider.java   View source code 5 votes vote down vote up
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");
}
 
Example 16
Project: osc-core   File: ViewUtil.java   View source code 5 votes vote down vote up
/**
 *
 * @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);
            }
        }
    }
}
 
Example 17
Project: holon-vaadin   File: DefaultPropertyListing.java   View source code 5 votes vote down vote up
@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();
	}
}
 
Example 18
Project: easybinder   File: AutoBinder.java   View source code 5 votes vote down vote up
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();
}
 
Example 19
Project: textfieldformatter   File: BasicCreditCardFieldFormatterUsageUI.java   View source code 5 votes vote down vote up
@Override
public Component getTestComponent() {
	TextField tf = new TextField();
	CreditCardFieldFormatter formatter = new CreditCardFieldFormatter(tf);
	formatter.addCreditCardChangedListener(l -> Notification.show("Card type: " + l.getCreditCardType()));
	return tf;
}
 
Example 20
Project: easybinder   File: GridExample.java   View source code 5 votes vote down vote up
@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;
}
 
Example 21
Project: osc-core   File: SecurityGroupMembershipInfoWindow.java   View source code 5 votes vote down vote up
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;
}
 
Example 22
Project: holon-vaadin   File: DefaultOrderedLayoutConfigurator.java   View source code 4 votes vote down vote up
@Override
public com.holonplatform.vaadin.components.builders.OrderedLayoutConfigurator.BaseOrderedLayoutConfigurator expand(
		Component component, float expandRatio) {
	getInstance().setExpandRatio(component, expandRatio);
	return builder();
}
 
Example 23
Project: holon-vaadin   File: DefaultPropertyColumn.java   View source code 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public <E extends HasValue<?> & Component> Optional<E> getEditor() {
	final E hvc = (E) editor;
	return Optional.ofNullable(hvc);
}
 
Example 24
Project: holon-vaadin7   File: ViewFour.java   View source code 4 votes vote down vote up
@Override
public Component getViewContent() {
	return new Label("FOUR");
}
 
Example 25
Project: holon-vaadin7   File: ExampleView.java   View source code 4 votes vote down vote up
@Override
public Component getViewContent() { // <3>
	boolean mobile = DeviceInfo.get().map(info -> info.isMobile()).orElse(false);
	return mobile ? buildMobileViewContent() : buildDefaultViewContent();
}
 
Example 26
Project: esup-ecandidat   File: LocalDateTimeField.java   View source code 4 votes vote down vote up
/**
 * @see com.vaadin.ui.CustomField#initContent()
 */
@Override
protected Component initContent() {
	setDateTimeValue(timeValue);		
	return hlContent;
}
 
Example 27
Project: history-api-navigation   File: OtherView.java   View source code 4 votes vote down vote up
@Override
public Component getComponent()
{
    return rootLayout;
}
 
Example 28
Project: material-theme-fw8   File: ColorsView.java   View source code 4 votes vote down vote up
private Component createListItem(String primary, boolean last) {
    SingleLineListItem item = new SingleLineListItem(primary, false);
    if (last) item.addStyleName(Margins.Bottom.LARGE);
    return item;
}
 
Example 29
Project: holon-vaadin   File: StringArea.java   View source code 4 votes vote down vote up
@Override
public Component getComponent() {
	return this;
}
 
Example 30
Project: material-theme-fw8   File: DataTablesView.java   View source code 4 votes vote down vote up
private CssLayout createCard(Component... components) {
    FlexLayout card = new FlexLayout(FlexLayout.FlexDirection.COLUMN, components);
    card.addStyleName("card");
    card.setWidth(100, Unit.PERCENTAGE);
    return card;
}
 
Example 31
Project: holon-vaadin7   File: ViewNavigationUtils.java   View source code 4 votes vote down vote up
/**
 * 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;
}
 
Example 32
Project: holon-vaadin   File: AbstractComposableForm.java   View source code 4 votes vote down vote up
@Override
public Component getContent() {
	return getCompositionRoot();
}
 
Example 33
Project: osc-core   File: CloseButtonModel.java   View source code 4 votes vote down vote up
@Override
public List<Component> getComponents() {
    return Arrays.asList(this.closeButton);
}
 
Example 34
Project: holon-vaadin   File: AbstractLayoutConfigurator.java   View source code 4 votes vote down vote up
@Override
public B align(Component component, Alignment alignment) {
	getInstance().setComponentAlignment(component, alignment);
	return builder();
}
 
Example 35
Project: osc-core   File: ApproveCancelButtonModel.java   View source code 4 votes vote down vote up
@Override
public List<Component> getComponents() {
    return Arrays.asList(this.rejectButton, this.approveButton);
}
 
Example 36
Project: holon-vaadin   File: BooleanField.java   View source code 4 votes vote down vote up
@Override
public Component getComponent() {
	return this;
}
 
Example 37
Project: esup-ecandidat   File: ComboBoxPresentation.java   View source code 4 votes vote down vote up
/**
 * @see com.vaadin.ui.CustomField#initContent()
 */
@Override
protected Component initContent() {
	return field;
}
 
Example 38
Project: material-theme-fw8   File: ButtonsView.java   View source code 4 votes vote down vote up
private Component createCaptionRow(String key, String value) {
    FlexLayout row = new FlexLayout(createCaption(key), createTableRow(value));
    row.setAlignItems(AlignItems.CENTER);
    return row;
}
 
Example 39
Project: holon-vaadin7   File: SecretField.java   View source code 4 votes vote down vote up
@Override
public Component getComponent() {
	return this;
}
 
Example 40
Project: holon-vaadin   File: DefaultPropertyViewGroup.java   View source code 4 votes vote down vote up
@Override
public Stream<Component> getComponents() {
	return properties.stream().filter(p -> propertyViews.containsKey(p))
			.map(p -> propertyViews.get(p).getComponent());
}