use of com.haulmont.cuba.gui.components.AbstractEditor in project cuba by cuba-platform.
the class LinkCellClickListener method onClick.
@Override
public void onClick(Entity rowItem, String columnId) {
Table.Column column = table.getColumn(columnId);
if (column.getXmlDescriptor() != null) {
String invokeMethodName = column.getXmlDescriptor().attributeValue("linkInvoke");
if (StringUtils.isNotEmpty(invokeMethodName)) {
callControllerInvoke(rowItem, columnId, invokeMethodName);
return;
}
}
Entity entity;
Object value = rowItem.getValueEx(columnId);
if (value instanceof Entity) {
entity = (Entity) value;
} else {
entity = rowItem;
}
WindowManager wm;
Window window = ComponentsHelper.getWindow(table);
if (window == null) {
throw new IllegalStateException("Please specify Frame for Table");
} else {
wm = window.getWindowManager();
}
Messages messages = beanLocator.get(Messages.NAME, Messages.class);
if (entity instanceof SoftDelete && ((SoftDelete) entity).isDeleted()) {
wm.showNotification(messages.getMainMessage("OpenAction.objectIsDeleted"), Frame.NotificationType.HUMANIZED);
return;
}
if (window.getFrameOwner() instanceof LegacyFrame) {
LegacyFrame frameOwner = (LegacyFrame) window.getFrameOwner();
DataSupplier dataSupplier = frameOwner.getDsContext().getDataSupplier();
entity = dataSupplier.reload(entity, View.MINIMAL);
} else {
DataManager dataManager = beanLocator.get(DataManager.NAME, DataManager.class);
entity = dataManager.reload(entity, View.MINIMAL);
}
WindowConfig windowConfig = beanLocator.get(WindowConfig.NAME, WindowConfig.class);
String windowAlias = null;
if (column.getXmlDescriptor() != null) {
windowAlias = column.getXmlDescriptor().attributeValue("linkScreen");
}
if (StringUtils.isEmpty(windowAlias)) {
windowAlias = windowConfig.getEditorScreenId(entity.getMetaClass());
}
OpenType screenOpenType = OpenType.THIS_TAB;
if (column.getXmlDescriptor() != null) {
String openTypeAttribute = column.getXmlDescriptor().attributeValue("linkScreenOpenType");
if (StringUtils.isNotEmpty(openTypeAttribute)) {
screenOpenType = OpenType.valueOf(openTypeAttribute);
}
}
AbstractEditor editor = (AbstractEditor) wm.openEditor(windowConfig.getWindowInfo(windowAlias), entity, screenOpenType);
editor.addCloseListener(actionId -> {
// move focus to component
table.focus();
if (Window.COMMIT_ACTION_ID.equals(actionId)) {
Entity editorItem = editor.getItem();
handleEditorCommit(editorItem, rowItem, columnId);
}
});
}
Aggregations