use of com.vaadin.ui.Component in project cuba by cuba-platform.
the class WebWindowManager method showWindowThisTab.
protected Component showWindowThisTab(final Window window, final String caption, final String description) {
getDialogParams().reset();
WebAppWorkArea workArea = getConfiguredWorkArea(createWorkAreaContext(window));
Layout layout;
if (workArea.getMode() == Mode.TABBED) {
TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
layout = (Layout) tabSheet.getSelectedTab();
} else {
layout = (Layout) workArea.getSingleWindowContainer().getComponent(0);
}
final WindowBreadCrumbs breadCrumbs = tabs.get(layout);
if (breadCrumbs == null) {
throw new IllegalStateException("BreadCrumbs not found");
}
final Window currentWindow = breadCrumbs.getCurrentWindow();
Set<Map.Entry<Window, Integer>> set = windows.entrySet();
boolean pushed = false;
for (Map.Entry<Window, Integer> entry : set) {
if (entry.getKey().equals(currentWindow)) {
windows.remove(currentWindow);
getStack(breadCrumbs).push(new Pair<>(entry.getKey(), entry.getValue()));
pushed = true;
break;
}
}
if (!pushed) {
getStack(breadCrumbs).push(new Pair<>(currentWindow, null));
}
removeFromWindowMap(currentWindow);
layout.removeComponent(WebComponentsHelper.getComposition(currentWindow));
final Component component = WebComponentsHelper.getComposition(window);
component.setSizeFull();
layout.addComponent(component);
breadCrumbs.addWindow(window);
if (workArea.getMode() == Mode.TABBED) {
TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
String tabId = tabSheet.getTab(layout);
String formattedCaption = formatTabCaption(caption, description);
tabSheet.setTabCaption(tabId, formattedCaption);
String formattedDescription = formatTabDescription(caption, description);
if (!Objects.equals(formattedCaption, formattedDescription)) {
tabSheet.setTabDescription(tabId, formattedDescription);
} else {
tabSheet.setTabDescription(tabId, null);
}
tabSheet.setTabIcon(tabId, iconResolver.getIconResource(window.getIcon()));
ContentSwitchMode contentSwitchMode = ContentSwitchMode.valueOf(window.getContentSwitchMode().name());
tabSheet.setContentSwitchMode(tabId, contentSwitchMode);
} else {
layout.markAsDirtyRecursive();
}
return layout;
}
use of com.vaadin.ui.Component in project cuba by cuba-platform.
the class WebDataGrid method setRowsCount.
@Override
public void setRowsCount(RowsCount rowsCount) {
if (this.rowsCount != null && topPanel != null) {
topPanel.removeComponent(WebComponentsHelper.unwrap(this.rowsCount));
this.rowsCount.setParent(null);
}
this.rowsCount = rowsCount;
if (rowsCount != null) {
if (rowsCount.getParent() != null && rowsCount.getParent() != this) {
throw new IllegalStateException("Component already has parent");
}
if (topPanel == null) {
topPanel = createTopPanel();
topPanel.setWidth("100%");
componentComposition.addComponentAsFirst(topPanel);
}
com.vaadin.ui.Component rc = WebComponentsHelper.unwrap(rowsCount);
topPanel.addComponent(rc);
topPanel.setExpandRatio(rc, 1);
topPanel.setComponentAlignment(rc, com.vaadin.ui.Alignment.BOTTOM_RIGHT);
if (rowsCount instanceof VisibilityChangeNotifier) {
((VisibilityChangeNotifier) rowsCount).addVisibilityChangeListener(event -> updateCompositionStylesTopPanelVisible());
}
}
updateCompositionStylesTopPanelVisible();
}
use of com.vaadin.ui.Component in project cuba by cuba-platform.
the class WebFileUploadField method setPasteZone.
@Override
public void setPasteZone(Container pasteZone) {
super.setPasteZone(pasteZone);
if (uploadButton instanceof CubaFileUpload) {
if (pasteZone == null) {
((CubaFileUpload) uploadButton).setPasteZone(null);
} else {
Component vComponent = pasteZone.unwrapComposition(Component.class);
((CubaFileUpload) uploadButton).setPasteZone(vComponent);
}
}
}
use of com.vaadin.ui.Component in project cuba by cuba-platform.
the class WebAbstractTable method addGeneratedColumn.
@Override
public void addGeneratedColumn(String columnId, ColumnGenerator<? super E> generator) {
checkNotNullArgument(columnId, "columnId is null");
checkNotNullArgument(generator, "generator is null for column id '%s'", columnId);
MetaPropertyPath targetCol = getDatasource().getMetaClass().getPropertyPath(columnId);
Object generatedColumnId = targetCol != null ? targetCol : columnId;
Column column = getColumn(columnId);
Column associatedRuntimeColumn = null;
if (column == null) {
Column newColumn = new Column(generatedColumnId);
columns.put(newColumn.getId(), newColumn);
columnsOrder.add(newColumn);
associatedRuntimeColumn = newColumn;
newColumn.setOwner(this);
}
// save column order
Object[] visibleColumns = component.getVisibleColumns();
boolean removeOldGeneratedColumn = component.getColumnGenerator(generatedColumnId) != null;
// replace generator for column if exist
if (removeOldGeneratedColumn) {
component.removeGeneratedColumn(generatedColumnId);
}
component.addGeneratedColumn(generatedColumnId, new CustomColumnGenerator(generator, associatedRuntimeColumn) {
@SuppressWarnings("unchecked")
@Override
public Object generateCell(com.vaadin.ui.Table source, Object itemId, Object columnId) {
Entity entity = getDatasource().getItem(itemId);
com.haulmont.cuba.gui.components.Component component = getColumnGenerator().generateCell(entity);
if (component == null) {
return null;
}
if (component instanceof PlainTextCell) {
return ((PlainTextCell) component).getText();
}
if (component instanceof BelongToFrame) {
BelongToFrame belongToFrame = (BelongToFrame) component;
if (belongToFrame.getFrame() == null) {
belongToFrame.setFrame(getFrame());
}
}
component.setParent(WebAbstractTable.this);
com.vaadin.ui.Component vComponent = component.unwrapComposition(Component.class);
// wrap field for show required asterisk
if ((vComponent instanceof com.vaadin.ui.Field) && (((com.vaadin.ui.Field) vComponent).isRequired())) {
VerticalLayout layout = new VerticalLayout();
layout.addComponent(vComponent);
if (vComponent.getWidth() < 0) {
layout.setWidthUndefined();
}
layout.addComponent(vComponent);
vComponent = layout;
}
return vComponent;
}
});
if (removeOldGeneratedColumn) {
// restore column order
component.setVisibleColumns(visibleColumns);
}
}
use of com.vaadin.ui.Component in project cuba by cuba-platform.
the class WebComponentsHelper method findChildComponent.
@Nullable
protected static com.haulmont.cuba.gui.components.Component findChildComponent(Container container, Component target) {
Component vaadinSource = getVaadinSource(container);
Collection<com.haulmont.cuba.gui.components.Component> components = container.getOwnComponents();
return findChildComponent(components, vaadinSource, target);
}
Aggregations