New XML attribute for create and edit actions open type #PL-1736

This commit is contained in:
Dmitry Kozlov 2013-09-16 14:06:00 +00:00
parent 7bb58d706b
commit 87661d8f0b
2 changed files with 39 additions and 4 deletions

View File

@ -16,6 +16,15 @@
<!-- Enums -->
<xs:simpleType name="openType">
<xs:restriction base="xs:string">
<xs:enumeration value="NEW_TAB"/>
<xs:enumeration value="THIS_TAB"/>
<xs:enumeration value="DIALOG"/>
<xs:enumeration value="NEW_WINDOW"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="operatorEnum">
<xs:restriction base="xs:string">
<xs:enumeration value="STARTS_WITH"/>
@ -399,6 +408,7 @@
<xs:attributeGroup ref="hasCaptionProp"/>
<xs:attributeGroup ref="hasEnableProp"/>
<xs:attributeGroup ref="hasVisibility"/>
<xs:attribute name="openType" type="openType" use="optional"/>
<xs:attribute name="icon" type="xs:string" use="optional"/>
<xs:attribute name="trackSelection" type="xs:boolean" use="optional"/>
<xs:attribute name="invoke" type="xs:string" use="optional"/>

View File

@ -7,11 +7,13 @@ package com.haulmont.cuba.gui.xml.layout.loaders;
import com.haulmont.chile.core.model.MetaClass;
import com.haulmont.chile.core.model.MetaPropertyPath;
import com.haulmont.cuba.core.global.AppBeans;
import com.haulmont.cuba.gui.GuiDevelopmentException;
import com.haulmont.cuba.core.global.MessageTools;
import com.haulmont.cuba.gui.ComponentsHelper;
import com.haulmont.cuba.gui.GuiDevelopmentException;
import com.haulmont.cuba.gui.WindowManager;
import com.haulmont.cuba.gui.components.*;
import com.haulmont.cuba.gui.components.Formatter;
import com.haulmont.cuba.gui.components.actions.CreateAction;
import com.haulmont.cuba.gui.components.actions.EditAction;
import com.haulmont.cuba.gui.components.actions.ListActionType;
import com.haulmont.cuba.gui.data.CollectionDatasource;
import com.haulmont.cuba.gui.data.Datasource;
@ -23,7 +25,9 @@ import org.dom4j.Element;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* @param <T>
@ -404,7 +408,28 @@ public abstract class AbstractTableLoader<T extends Table> extends ComponentLoad
// Try to create a standard list action
for (ListActionType type : ListActionType.values()) {
if (type.getId().equals(id)) {
return type.createAction((ListComponent) actionsHolder);
Action instance = type.createAction((ListComponent) actionsHolder);
if (type != ListActionType.CREATE && type != ListActionType.EDIT) {
return instance;
}
String openType = element.attributeValue("openType");
if (openType == null) {
return instance;
}
try {
WindowManager.OpenType open = WindowManager.OpenType.valueOf(openType);
if (type == ListActionType.CREATE) {
CreateAction create = (CreateAction) instance;
create.setOpenType(open);
} else {
EditAction edit = (EditAction) instance;
edit.setOpenType(open);
}
} catch (IllegalArgumentException e) {
throw new GuiDevelopmentException(
"Unknown open type: '" + openType + "'", context.getFullFrameId());
}
return instance;
}
}
}