use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class WebEntityLinkField method openEntityEditor.
protected void openEntityEditor() {
Object value = getValue();
Entity entity;
if (value instanceof Entity) {
entity = (Entity) value;
} else {
entity = datasource.getItem();
}
if (entity == null) {
return;
}
WindowManager wm;
Window window = ComponentsHelper.getWindow(this);
if (window == null) {
throw new IllegalStateException("Please specify Frame for EntityLinkField");
} else {
wm = window.getWindowManager();
}
if (screenOpenType.getOpenMode() == OpenMode.DIALOG && screenDialogParams != null) {
wm.getDialogParams().copyFrom(screenDialogParams);
}
if (entity instanceof SoftDelete && ((SoftDelete) entity).isDeleted()) {
Messages messages = AppBeans.get(Messages.NAME);
wm.showNotification(messages.getMainMessage("OpenAction.objectIsDeleted"), Frame.NotificationType.HUMANIZED);
return;
}
DataSupplier dataSupplier = window.getDsContext().getDataSupplier();
entity = dataSupplier.reload(entity, View.MINIMAL);
String windowAlias = screen;
WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
if (windowAlias == null) {
windowAlias = windowConfig.getEditorScreenId(entity.getMetaClass());
}
final Window.Editor editor = wm.openEditor(windowConfig.getWindowInfo(windowAlias), entity, screenOpenType, screenParams != null ? screenParams : Collections.<String, Object>emptyMap());
editor.addCloseListener(actionId -> {
// move focus to component
component.focus();
if (Window.COMMIT_ACTION_ID.equals(actionId)) {
Entity item = editor.getItem();
afterCommitOpenedEntity(item);
}
if (screenCloseListener != null) {
screenCloseListener.windowClosed(editor, actionId);
}
});
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class DataGridLoader method loadButtonsPanel.
protected void loadButtonsPanel(DataGrid component) {
if (buttonsPanelLoader != null) {
// noinspection unchecked
buttonsPanelLoader.loadComponent();
ButtonsPanel panel = (ButtonsPanel) buttonsPanelLoader.getResultComponent();
Window window = ComponentsHelper.getWindowImplementation(component);
String alwaysVisible = panelElement.attributeValue("alwaysVisible");
panel.setVisible(!(window instanceof Window.Lookup) || "true".equals(alwaysVisible));
}
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class WebAbstractTable method setEditable.
@Override
public void setEditable(boolean editable) {
if (this.editable != editable) {
this.editable = editable;
component.disableContentBufferRefreshing();
if (datasource != null) {
com.vaadin.data.Container ds = component.getContainerDataSource();
@SuppressWarnings("unchecked") final Collection<MetaPropertyPath> propertyIds = (Collection<MetaPropertyPath>) ds.getContainerPropertyIds();
if (editable) {
MetaClass metaClass = datasource.getMetaClass();
final List<MetaPropertyPath> editableColumns = new ArrayList<>(propertyIds.size());
for (final MetaPropertyPath propertyId : propertyIds) {
if (!security.isEntityAttrUpdatePermitted(metaClass, propertyId.toString())) {
continue;
}
final Table.Column column = getColumn(propertyId.toString());
if (BooleanUtils.isTrue(column.isEditable())) {
com.vaadin.ui.Table.ColumnGenerator generator = component.getColumnGenerator(column.getId());
if (generator != null) {
if (generator instanceof SystemTableColumnGenerator) {
// remove default generator
component.removeGeneratedColumn(propertyId);
} else {
// do not edit generated columns
continue;
}
}
editableColumns.add(propertyId);
}
}
setEditableColumns(editableColumns);
} else {
setEditableColumns(Collections.emptyList());
Window window = ComponentsHelper.getWindowImplementation(this);
boolean isLookup = window instanceof Window.Lookup;
// restore generators for some type of attributes
for (MetaPropertyPath propertyId : propertyIds) {
final Table.Column column = columns.get(propertyId);
if (column != null) {
final String isLink = column.getXmlDescriptor() == null ? null : column.getXmlDescriptor().attributeValue("link");
if (component.getColumnGenerator(column.getId()) == null) {
if (propertyId.getRange().isClass()) {
if (!isLookup && StringUtils.isNotEmpty(isLink)) {
setClickListener(propertyId.toString(), new LinkCellClickListener());
}
} else if (propertyId.getRange().isDatatype()) {
if (!isLookup && !StringUtils.isEmpty(isLink)) {
setClickListener(propertyId.toString(), new LinkCellClickListener());
} else {
if (column.getMaxTextLength() != null) {
addGeneratedColumn(propertyId, new AbbreviatedColumnGenerator(column));
}
}
}
}
}
}
}
}
component.setEditable(editable);
component.enableContentBufferRefreshing(true);
}
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class WebAccordion method initComponentTabChangeListener.
private void initComponentTabChangeListener() {
// after all lazy tabs listeners
if (!componentTabChangeListenerInitialized) {
component.addSelectedTabChangeListener(event -> {
if (context != null) {
context.executeInjectTasks();
context.executePostWrapTasks();
context.executeInitTasks();
}
// Fire GUI listener
fireTabChanged();
// We suppose that context.executePostInitTasks() executes a task once and then remove it from task list.
if (context != null) {
context.executePostInitTasks();
}
Window window = ComponentsHelper.getWindow(WebAccordion.this);
if (window != null) {
((DsContextImplementation) window.getDsContext()).resumeSuspended();
} else {
LoggerFactory.getLogger(WebAccordion.class).warn("Please specify Frame for Accordion");
}
});
componentTabChangeListenerInitialized = true;
}
}
Aggregations