com.vaadin.ui.Component Java Examples
The following examples show how to use
com.vaadin.ui.Component.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConfigurableFieldFactory.java From jdal with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public Field createField(Item item, Object propertyId, Component uiContext) { BeanItem<?> beanItem = (BeanItem<?>) item; Field f = getField(propertyId, beanItem.getBean().getClass()); if (f != null) { f.setCaption(createCaptionByPropertyId(propertyId)); } else { // fail back to default f = super.createField(item, propertyId, uiContext); } applyFieldProcessors(f, propertyId); return f; }
Example #2
Source File: DDTabSheet.java From cuba with Apache License 2.0 | 6 votes |
protected TabSheetTargetDetails(Map<String, Object> rawDropData) { super(rawDropData, DDTabSheet.this); // Get over which component (if any) the drop was made and the // index of it if (rawDropData.get(Constants.DROP_DETAIL_TO) != null) { Object to = rawDropData.get(Constants.DROP_DETAIL_TO); index = Integer.valueOf(to.toString()); } if (index >= 0 && index < getComponentCount()) { Iterator<Component> iter = getComponentIterator(); int counter = 0; while (iter.hasNext()) { over = iter.next(); if (counter == index) { break; } counter++; } } else { over = DDTabSheet.this; } }
Example #3
Source File: DefaultCssLayoutDropHandler.java From cuba with Apache License 2.0 | 6 votes |
@Override protected void handleComponentReordering(DragAndDropEvent event) { // Component re-ordering LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); CssLayoutTargetDetails details = (CssLayoutTargetDetails) event .getTargetDetails(); DDCssLayout layout = (DDCssLayout) details.getTarget(); Component comp = transferable.getComponent(); int idx = details.getOverIndex(); // Detach from old source Component source = transferable.getSourceComponent(); if (source instanceof ComponentContainer) { ((ComponentContainer) source).removeComponent(comp); } else if (source instanceof SingleComponentContainer) { ((SingleComponentContainer) source).setContent(null); } // Add component if (idx >= 0 && idx < layout.getComponentCount()) { layout.addComponent(comp, idx); } else { layout.addComponent(comp); } }
Example #4
Source File: GridCellWrapper.java From mycollab with GNU Affero General Public License v3.0 | 6 votes |
public void addField(Component field) { if (field instanceof HasValue && ((HasValue)field).isRequiredIndicatorVisible() && captionComp!= null) { captionComp.addStyleName(WebThemes.REQUIRED_FIELD_INDICATOR); } fieldWrapper.removeAllComponents(); field.setCaption(null); if (field.getWidth() != -1) { // continue } else if (field instanceof MultiSelectComp || field instanceof DateField) { field.setWidth(WebThemes.FORM_CONTROL_WIDTH); } else { field.setWidth("100%"); } fieldWrapper.withComponent(field); }
Example #5
Source File: MButtonClickListeners.java From viritin with Apache License 2.0 | 6 votes |
@Override public Component getTestComponent() { MButton b = new MButton("Say hola"); // And the same without lambdas as the project is 1.6 compatible b.addClickListener(new MClickListener() { @Override public void onClick() { sayHola(); } }); b.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 5019806363620874205L; @Override public void buttonClick(ClickEvent event) { sayHolaOldSchool(event); } }); return new MVerticalLayout(b); }
Example #6
Source File: WebComponentsHelper.java From cuba with Apache License 2.0 | 6 votes |
/** * Tests if component visible and its container visible. * * @param child component * @return component visibility */ public static boolean isComponentVisible(Component child) { if (child.getParent() instanceof TabSheet) { TabSheet tabSheet = (TabSheet) child.getParent(); TabSheet.Tab tab = tabSheet.getTab(child); if (!tab.isVisible()) { return false; } } if (child.getParent() instanceof CubaGroupBox) { // ignore groupbox content container visibility return isComponentVisible(child.getParent()); } return child.isVisible() && (child.getParent() == null || isComponentVisible(child.getParent())); }
Example #7
Source File: JobLogTable.java From chipster with MIT License | 6 votes |
public Component generateCell(Table source, final Object itemId, Object columnId) { Property<?> prop = source.getItem(itemId).getItemProperty(columnId); if (prop != null && prop.getType() != null && prop.getType().equals(Integer.class)) { Integer wallClockTime = (Integer) prop.getValue(); if (wallClockTime != null) { return new Label(StringUtils.formatMinutes(wallClockTime)); } else { return new Label(); } } return null; }
Example #8
Source File: AbstractBeanPagedList.java From mycollab with GNU Affero General Public License v3.0 | 6 votes |
public void setCurrentDataList(List<T> list) { this.currentListData = list; this.removeAllComponents(); if (currentListData.size() != 0) { int i = 0; for (T item : currentListData) { Component row = rowDisplayHandler.generateRow(this, item, i); this.addComponent(row); i++; } } else { String msg = stringWhenEmptyList(); if (msg != null) { this.addComponent(msgWhenEmptyList()); } } }
Example #9
Source File: GridLazyLoading.java From viritin with Apache License 2.0 | 6 votes |
@Override public Component getTestComponent() { MGrid<Person> g = new MGrid<>( new LazyList.PagingProvider<Person>() { private static final long serialVersionUID = -9072230332041322210L; @Override public List<Person> findEntities(int firstRow) { return Service.findAll(firstRow, LazyList.DEFAULT_PAGE_SIZE); } }, new LazyList.CountProvider() { private static final long serialVersionUID = -6915320247020779461L; @Override public int size() { return (int) Service.count(); } } ); return g; }
Example #10
Source File: WebAppWorkArea.java From cuba with Apache License 2.0 | 6 votes |
@Override public void setInitialLayout(VBoxLayout initialLayout) { checkNotNullArgument(initialLayout); if (state == State.WINDOW_CONTAINER) { throw new IllegalStateException("Unable to change AppWorkArea initial layout in WINDOW_CONTAINER state"); } if (this.initialLayout != null) { component.removeComponent(this.initialLayout.unwrapComposition(com.vaadin.ui.Component.class)); } this.initialLayout = initialLayout; initialLayout.setParent(this); initialLayout.setSizeFull(); Component vInitialLayout = initialLayout.unwrapComposition(com.vaadin.ui.Component.class); vInitialLayout.addStyleName(INITIAL_LAYOUT_STYLENAME); component.addComponent(vInitialLayout); }
Example #11
Source File: FilterTablePerson.java From viritin with Apache License 2.0 | 6 votes |
@Override public Component getTestComponent() { final FilterableTable<Person> table = new FilterableTable<>(); table.withProperties("firstName", "lastName", "age"); table.setBeans(Service.getListOfPersons(200)); final MTextField search = new MTextField(); search.setInputPrompt("Filter on last name..."); search.addTextChangeListener(new FieldEvents.TextChangeListener() { @Override public void textChange(FieldEvents.TextChangeEvent event) { table.removeAllFilters(); if(StringUtils.isNotEmpty(event.getText())) { table.addFilter(new SimpleStringFilter("lastName", event.getText(), true, true)); } } }); return new MVerticalLayout() .withFullWidth() .add(search) .expand(table); }
Example #12
Source File: WebAbstractDataGrid.java From cuba with Apache License 2.0 | 6 votes |
protected void updateCompositionStylesTopPanelVisible() { if (topPanel != null) { boolean hasChildren = topPanel.getComponentCount() > 0; boolean anyChildVisible = false; for (Component childComponent : topPanel) { if (childComponent.isVisible()) { anyChildVisible = true; break; } } boolean topPanelVisible = hasChildren && anyChildVisible; if (!topPanelVisible) { componentComposition.removeStyleName(HAS_TOP_PANEL_STYLE_NAME); internalStyles.remove(HAS_TOP_PANEL_STYLE_NAME); } else { componentComposition.addStyleName(HAS_TOP_PANEL_STYLE_NAME); if (!internalStyles.contains(HAS_TOP_PANEL_STYLE_NAME)) { internalStyles.add(HAS_TOP_PANEL_STYLE_NAME); } } } }
Example #13
Source File: DefaultGridLayoutDropHandler.java From cuba with Apache License 2.0 | 6 votes |
@Override protected void handleComponentReordering(DragAndDropEvent event) { GridLayoutTargetDetails details = (GridLayoutTargetDetails) event .getTargetDetails(); DDGridLayout layout = (DDGridLayout) details.getTarget(); LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); Component comp = transferable.getComponent(); int row = details.getOverRow(); int column = details.getOverColumn(); if (layout.getComponent(column, row) == null) { layout.removeComponent(comp); addComponent(event, comp, column, row); } }
Example #14
Source File: AbstractHawkbitLoginUI.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
protected Component buildLoginForm() { final VerticalLayout loginPanel = new VerticalLayout(); loginPanel.setSizeUndefined(); loginPanel.setSpacing(true); loginPanel.addStyleName("login-panel"); Responsive.makeResponsive(loginPanel); loginPanel.addComponent(buildFields()); if (isDemo) { loginPanel.addComponent(buildDisclaimer()); } loginPanel.addComponent(buildLinks()); checkBrowserSupport(loginPanel); return loginPanel; }
Example #15
Source File: CommonDialogWindow.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
private static Object getCurrentValue(final Component currentChangedComponent, final Object newValue, final AbstractField<?> field) { Object currentValue = field.getValue(); if (field instanceof Table) { currentValue = ((Table) field).getContainerDataSource().getItemIds(); } if (field.equals(currentChangedComponent)) { currentValue = newValue; } return currentValue; }
Example #16
Source File: WebAbstractDataGrid.java From cuba with Apache License 2.0 | 5 votes |
protected CubaEditorField createCustomField(final Field columnComponent) { if (!(columnComponent instanceof Buffered)) { throw new IllegalArgumentException("Editor field must implement " + "com.haulmont.cuba.gui.components.Buffered"); } Component content = WebComponentsHelper.getComposition(columnComponent); //noinspection unchecked CubaEditorField wrapper = new DataGridEditorCustomField(columnComponent) { @Override protected Component initContent() { return content; } }; if (content instanceof Component.Focusable) { wrapper.setFocusDelegate((Component.Focusable) content); } wrapper.setReadOnly(!columnComponent.isEditable()); wrapper.setRequiredIndicatorVisible(columnComponent.isRequired()); //noinspection unchecked columnComponent.addValueChangeListener(event -> wrapper.markAsDirty()); return wrapper; }
Example #17
Source File: MainLayout.java From designer-tutorials with Apache License 2.0 | 5 votes |
private void adjustStyleByData(Component component, Object data) { if (component instanceof Button) { if (data != null && data.equals(((Button) component).getData())) { component.addStyleName(STYLE_SELECTED); } else { component.removeStyleName(STYLE_SELECTED); } } }
Example #18
Source File: HtmlAttributesExtension.java From cuba with Apache License 2.0 | 5 votes |
public static HtmlAttributesExtension get(Component component) { for (Extension e : component.getExtensions()) { if (e instanceof HtmlAttributesExtension) { return (HtmlAttributesExtension) e; } } return new HtmlAttributesExtension((AbstractClientConnector) component); }
Example #19
Source File: UrlLinkViewField.java From mycollab with GNU Affero General Public License v3.0 | 5 votes |
@Override protected Component initContent() { if (StringUtils.isBlank(url) || StringUtils.isBlank(caption)) { return ELabel.html(" "); } else { final A link = new A(url).appendText(caption).setTarget("_blank"); return ELabel.html(link.write()).withStyleName(WebThemes.TEXT_ELLIPSIS); } }
Example #20
Source File: WebThreeComponentSplitLayoutImpl.java From consulo with Apache License 2.0 | 5 votes |
private void reset(@Nullable Connector connector) { if (connector != null) { Component component = (Component)connector; component.setParent(null); } }
Example #21
Source File: WebDriverExampleDemo.java From vaadinator with Apache License 2.0 | 5 votes |
@Override public Component getTestComponent() { MainPresenter mpres; mpres = obtainPresenterFactory().createMainPresenter(); MainView mview = mpres.getView(); // and go mpres.startPresenting(); return (Component) mview.getComponent(); }
Example #22
Source File: WebFilterHelper.java From cuba with Apache License 2.0 | 5 votes |
@Override public void setInternalDebugId(com.haulmont.cuba.gui.components.Component component, String id) { AppUI ui = AppUI.getCurrent(); if (ui != null && ui.isTestMode()) { component.unwrap(Component.class).setCubaId(id); } }
Example #23
Source File: WebAppWorkArea.java From cuba with Apache License 2.0 | 5 votes |
protected ShortcutListener createPreviousWindowTabShortcut(RootWindow topLevelWindow) { Configuration configuration = beanLocator.get(Configuration.NAME); ClientConfig clientConfig = configuration.getConfig(ClientConfig.class); String previousTabShortcut = clientConfig.getPreviousTabShortcut(); KeyCombination combination = KeyCombination.create(previousTabShortcut); return new ShortcutListenerDelegate("onPreviousTab", combination.getKey().getCode(), KeyCombination.Modifier.codes(combination.getModifiers()) ).withHandler((sender, target) -> { TabSheetBehaviour tabSheet = getTabbedWindowContainer().getTabSheetBehaviour(); if (tabSheet != null && !hasModalWindow() && tabSheet.getComponentCount() > 1) { com.vaadin.ui.Component selectedTabComponent = tabSheet.getSelectedTab(); String selectedTabId = tabSheet.getTab(selectedTabComponent); int tabPosition = tabSheet.getTabPosition(selectedTabId); int newTabPosition = (tabSheet.getComponentCount() + tabPosition - 1) % tabSheet.getComponentCount(); String newTabId = tabSheet.getTab(newTabPosition); tabSheet.setSelectedTab(newTabId); moveFocus(tabSheet, newTabId); } }); }
Example #24
Source File: ReadableTicketRowRenderer.java From mycollab with GNU Affero General Public License v3.0 | 5 votes |
private Component buildStartdateComp(ProjectTicket ticket) { if (ticket.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 ELabel.html(divHint.write()).withDescription(UserUIContext.getMessage(GenericI18Enum.FORM_START_DATE)) .withStyleName(WebThemes.META_INFO, WebThemes.MARGIN_LEFT_HALF); } else { Div startDateDiv = new Div().appendText(String.format(" %s %s", VaadinIcons.TIME_FORWARD.getHtml(), UserUIContext.formatDate(ticket.getStartDate()))); return ELabel.html(startDateDiv.write()).withDescription(UserUIContext.getMessage(GenericI18Enum.FORM_START_DATE)) .withStyleName(WebThemes.META_INFO, WebThemes.MARGIN_LEFT_HALF); } }
Example #25
Source File: WebAppWorkArea.java From cuba with Apache License 2.0 | 5 votes |
/** * Used by {@link Screens}. * * @param state new state */ @Override public void switchTo(State state) { if (this.state != state) { component.getUI().focus(); component.removeAllComponents(); if (state == State.WINDOW_CONTAINER) { if (mode == Mode.SINGLE) { component.addComponent(singleContainer); } else { component.addComponent(tabbedContainer); } component.addStyleName(STATE_WINDOWS_STYLENAME); component.removeStyleName(STATE_INITIAL_STYLENAME); } else { component.addComponent(initialLayout.unwrapComposition(com.vaadin.ui.Component.class)); component.removeStyleName(STATE_WINDOWS_STYLENAME); component.addStyleName(STATE_INITIAL_STYLENAME); } this.state = state; // init global tab shortcuts if (!this.shortcutsInitialized && getState() == State.WINDOW_CONTAINER) { initTabShortcuts(); this.shortcutsInitialized = true; } if (hasSubscriptions(StateChangeEvent.class)) { publish(StateChangeEvent.class, new StateChangeEvent(this, state)); } } }
Example #26
Source File: StorageAdminPanel.java From sensorhub with Mozilla Public License 2.0 | 5 votes |
protected void buildDataPanel(GridLayout form, IRecordStorageModule<?> storage) { // measurement outputs int i = 1; if (storage.isEnabled()) { for (IRecordStoreInfo dsInfo: storage.getRecordStores().values()) { Panel panel = newPanel("Stream #" + i++); GridLayout panelLayout = ((GridLayout)panel.getContent()); panelLayout.setSpacing(true); // stored time period double[] timeRange = storage.getRecordsTimeRange(dsInfo.getName()); Label l = new Label("<b>Time Range:</b> " + new DateTimeFormat().formatIso(timeRange[0], 0) + " / " + new DateTimeFormat().formatIso(timeRange[1], 0)); l.setContentMode(ContentMode.HTML); panelLayout.addComponent(l, 0, 0, 1, 0); // time line panelLayout.addComponent(buildGantt(storage, dsInfo), 0, 1, 1, 1); // data structure DataComponent dataStruct = dsInfo.getRecordDescription(); Component sweForm = new SWECommonForm(dataStruct); panelLayout.addComponent(sweForm); // data table panelLayout.addComponent(buildTable(storage, dsInfo)); if (oldPanel != null) form.replaceComponent(oldPanel, panel); else form.addComponent(panel); oldPanel = panel; } } }
Example #27
Source File: RootImpl.java From serverside-elements with Apache License 2.0 | 5 votes |
@Override public void fetchDom(Runnable callback, Component... connectorsToInlcude) { assert callback != null; Integer id = Integer.valueOf(fetchCallbackSequence++); fetchDomCallbacks.put(id, callback); fetchDomComponents.put(id, connectorsToInlcude); owner.markAsDirty(); }
Example #28
Source File: ContractApplicationExampleUI.java From vaadinator with Apache License 2.0 | 5 votes |
@Override protected void init(VaadinRequest request) { NavigationManager m = new NavigationManager(); m.setMaintainBreadcrumb(true); FirstPagePresenter fpres; fpres = obtainPresenterFactory(request.getContextPath()).createFirstPagePresenter(); FirstPageView fview = (FirstPageView) fpres.getView(); m.setCurrentComponent((Component) fview.getComponent()); setContent(m); // and go fpres.startPresenting(); }
Example #29
Source File: ProjectMembersWidget.java From mycollab with GNU Affero General Public License v3.0 | 5 votes |
@Override public Component generateRow(IBeanList<SimpleProjectMember> host, SimpleProjectMember member, int rowIndex) { MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withStyleName("list-row"); Image userAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(member.getMemberAvatarId(), 48); userAvatar.addStyleName(WebThemes.CIRCLE_BOX); layout.addComponent(userAvatar); MVerticalLayout content = new MVerticalLayout().withMargin(false); content.addComponent(ELabel.html(buildAssigneeValue(member)).withStyleName(WebThemes.TEXT_ELLIPSIS)); layout.with(content).expand(content); CssLayout footer = new CssLayout(); String roleVal = member.getRoleName() + " "; ELabel memberRole = ELabel.html(roleVal).withDescription(UserUIContext.getMessage(ProjectRoleI18nEnum.SINGLE)) .withStyleName(WebThemes.META_INFO); footer.addComponent(memberRole); String memberWorksInfo = ProjectAssetsManager.getAsset(ProjectTypeConstants.TASK).getHtml() + new Span().appendText("" + member.getNumOpenTasks()).setTitle(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_OPEN_TASKS)) + " " + ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG).getHtml() + new Span().appendText("" + member.getNumOpenBugs()).setTitle(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_OPEN_BUGS)) + " " + VaadinIcons.MONEY.getHtml() + " " + new Span().appendText("" + NumberUtils.roundDouble(2, member.getTotalBillableLogTime())).setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_BILLABLE_HOURS)) + " " + VaadinIcons.GIFT.getHtml() + new Span().appendText("" + NumberUtils.roundDouble(2, member.getTotalNonBillableLogTime())) .setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_NON_BILLABLE_HOURS)); ELabel memberWorkStatus = ELabel.html(memberWorksInfo).withStyleName(WebThemes.META_INFO); footer.addComponent(memberWorkStatus); content.addComponent(footer); return layout; }
Example #30
Source File: EditableColumnFieldWrapper.java From cuba with Apache License 2.0 | 5 votes |
@Override public void setHeight(float height, Unit unit) { super.setHeight(height, unit); if (component != null) { if (height < 0) { component.setHeight(com.haulmont.cuba.gui.components.Component.AUTO_SIZE); } else { component.setHeight(100, Unit.PERCENTAGE); } } }