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; }
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); }
@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; }
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; }
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); }
@Override public Optional<Component> getComponent() { return Optional.of(new AbstractComponent() { @Override public Object getData() { return definition; } }); }
@Override protected void showViewContent(Component content) { container.removeAllComponents(); if (content != null) { container.addComponent(content); } }
@Override public Component getTestComponent() { TextField tf = new TextField(); new NumeralFieldFormatter(tf); tf.addValueChangeListener(l -> Notification.show("Value: " + l.getValue())); return tf; }
@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; }
@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())); }
@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(); }
/** * 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(); } }
/** * @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; }
/** * @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); } } } }
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"); }
/** * * @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); } } } }
@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(); } }
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(); }
@Override public Component getTestComponent() { TextField tf = new TextField(); CreditCardFieldFormatter formatter = new CreditCardFieldFormatter(tf); formatter.addCreditCardChangedListener(l -> Notification.show("Card type: " + l.getCreditCardType())); return tf; }
@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; }
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; }
@Override public com.holonplatform.vaadin.components.builders.OrderedLayoutConfigurator.BaseOrderedLayoutConfigurator expand( Component component, float expandRatio) { getInstance().setExpandRatio(component, expandRatio); return builder(); }
@SuppressWarnings("unchecked") @Override public <E extends HasValue<?> & Component> Optional<E> getEditor() { final E hvc = (E) editor; return Optional.ofNullable(hvc); }
@Override public Component getViewContent() { return new Label("FOUR"); }
@Override public Component getViewContent() { // <3> boolean mobile = DeviceInfo.get().map(info -> info.isMobile()).orElse(false); return mobile ? buildMobileViewContent() : buildDefaultViewContent(); }
/** * @see com.vaadin.ui.CustomField#initContent() */ @Override protected Component initContent() { setDateTimeValue(timeValue); return hlContent; }
@Override public Component getComponent() { return rootLayout; }
private Component createListItem(String primary, boolean last) { SingleLineListItem item = new SingleLineListItem(primary, false); if (last) item.addStyleName(Margins.Bottom.LARGE); return item; }
@Override public Component getComponent() { return this; }
private CssLayout createCard(Component... components) { FlexLayout card = new FlexLayout(FlexLayout.FlexDirection.COLUMN, components); card.addStyleName("card"); card.setWidth(100, Unit.PERCENTAGE); return card; }
/** * 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; }
@Override public Component getContent() { return getCompositionRoot(); }
@Override public List<Component> getComponents() { return Arrays.asList(this.closeButton); }
@Override public B align(Component component, Alignment alignment) { getInstance().setComponentAlignment(component, alignment); return builder(); }
@Override public List<Component> getComponents() { return Arrays.asList(this.rejectButton, this.approveButton); }
/** * @see com.vaadin.ui.CustomField#initContent() */ @Override protected Component initContent() { return field; }
private Component createCaptionRow(String key, String value) { FlexLayout row = new FlexLayout(createCaption(key), createTableRow(value)); row.setAlignItems(AlignItems.CENTER); return row; }
@Override public Stream<Component> getComponents() { return properties.stream().filter(p -> propertyViews.containsKey(p)) .map(p -> propertyViews.get(p).getComponent()); }