use of org.eclipse.scout.rt.client.ui.form.fields.tabbox.ITabBox in project scout.rt by eclipse.
the class FormFieldVisibilityTest method createFixture.
private ICompositeField createFixture() {
ICompositeField result = new P_GroupBox();
// verify structure
Assert.assertEquals(2, result.getFieldCount());
Assert.assertTrue(result.getFields().get(0) instanceof IRadioButtonGroup<?>);
Assert.assertEquals(2, ((IRadioButtonGroup<?>) result.getFields().get(0)).getFieldCount());
Assert.assertTrue(result.getFields().get(1) instanceof ITabBox);
ITabBox tabbox = (ITabBox) result.getFields().get(1);
Assert.assertEquals(2, tabbox.getFieldCount());
IGroupBox tab1 = (IGroupBox) tabbox.getFields().get(0);
IGroupBox tab2 = (IGroupBox) tabbox.getFields().get(1);
Assert.assertEquals(1, tab1.getFieldCount());
Assert.assertEquals(1, tab2.getFieldCount());
ITreeBox<?> treebox = (ITreeBox<?>) tab1.getFields().get(0);
IListBox<?> listbox = (IListBox<?>) tab2.getFields().get(0);
Assert.assertEquals(2, /*treebox filter box is included as well*/
treebox.getFieldCount());
Assert.assertEquals(2, /*listbox filter box is included as well*/
listbox.getFieldCount());
return result;
}
use of org.eclipse.scout.rt.client.ui.form.fields.tabbox.ITabBox in project scout.rt by eclipse.
the class AbstractForm method loadFromXml.
@Override
public void loadFromXml(Element root) {
String formId = getFormId();
String xmlId = root.getAttribute("formId");
if (!formId.equals(xmlId)) {
throw new ProcessingException("xml id='{}' does not match form id='{}'", xmlId, formId);
}
// load properties
Element xProps = XmlUtility.getFirstChildElement(root, "properties");
if (xProps != null) {
Map<String, Object> props = loadPropertiesFromXml(xProps);
BeanUtility.setProperties(this, props, true, null);
// load extension properties
for (Element xExtension : XmlUtility.getChildElements(xProps, "extension")) {
String extensionId = xExtension.getAttribute("extensionId");
String extensionQname = xExtension.getAttribute("extensionQname");
IFormExtension<? extends AbstractForm> extension = findFormExtensionById(extensionQname, extensionId);
if (extension == null) {
continue;
}
Map<String, Object> extensionProps = loadPropertiesFromXml(xExtension);
BeanUtility.setProperties(extension, extensionProps, true, null);
}
}
// load fields
Element xFields = XmlUtility.getFirstChildElement(root, "fields");
if (xFields != null) {
for (Element xField : XmlUtility.getChildElements(xFields, "field")) {
List<String> xmlFieldIds = new LinkedList<String>();
// add enclosing field path to xml field IDs
for (Element element : XmlUtility.getChildElements(xField, "enclosingField")) {
xmlFieldIds.add(element.getAttribute("fieldId"));
}
xmlFieldIds.add(xField.getAttribute("fieldId"));
FindFieldByXmlIdsVisitor v = new FindFieldByXmlIdsVisitor(xmlFieldIds.toArray(new String[xmlFieldIds.size()]));
visitFields(v);
IFormField f = v.getField();
if (f != null) {
f.loadFromXml(xField);
}
}
}
// in all tabboxes select the first tab that contains data, iff the current
// tab has no values set
getRootGroupBox().visitFields(new IFormFieldVisitor() {
@Override
public boolean visitField(IFormField field, int level, int fieldIndex) {
if (field instanceof ITabBox) {
ITabBox tabBox = (ITabBox) field;
IGroupBox selbox = tabBox.getSelectedTab();
if (selbox == null || !selbox.isSaveNeeded()) {
for (IGroupBox g : tabBox.getGroupBoxes()) {
if (g.isSaveNeeded()) {
tabBox.setSelectedTab(g);
break;
}
}
}
}
return true;
}
});
}
use of org.eclipse.scout.rt.client.ui.form.fields.tabbox.ITabBox in project scout.rt by eclipse.
the class JsonTabBox method initJsonProperties.
@Override
protected void initJsonProperties(TAB_BOX model) {
super.initJsonProperties(model);
putJsonProperty(new JsonAdapterProperty<ITabBox>(ITabBox.PROP_SELECTED_TAB, model, getUiSession()) {
@Override
protected IGroupBox modelValue() {
return getModel().getSelectedTab();
}
@Override
protected JsonAdapterPropertyConfig createConfig() {
return new JsonAdapterPropertyConfigBuilder().disposeOnChange(false).build();
}
});
}
use of org.eclipse.scout.rt.client.ui.form.fields.tabbox.ITabBox in project scout.rt by eclipse.
the class ValidateFormFieldDescriptor method activateProblemLocation.
@Override
public void activateProblemLocation() {
// make sure the field is showing (activate parent tabs)
IGroupBox groupBox = m_field.getParentGroupBox();
IForm form = m_field.getForm();
while (groupBox != null) {
if (groupBox.getParentField() instanceof ITabBox) {
ITabBox t = (ITabBox) groupBox.getParentField();
if (t.getSelectedTab() != groupBox) {
t.setSelectedTab(groupBox);
}
}
groupBox = groupBox.getParentGroupBox();
// in that case we must go further up starting from the wrapped form field
if (groupBox == null) {
IFormField outerFormField = form.getOuterFormField();
if (outerFormField != null) {
groupBox = outerFormField.getParentGroupBox();
form = outerFormField.getForm();
}
}
}
m_field.requestFocus();
}
use of org.eclipse.scout.rt.client.ui.form.fields.tabbox.ITabBox in project scout.rt by eclipse.
the class FormFieldEnabledTest method createFixture.
private ICompositeField createFixture() {
ICompositeField result = new P_GroupBox();
// verify structure
Assert.assertEquals(2, result.getFieldCount());
Assert.assertTrue(result.getFields().get(0) instanceof IRadioButtonGroup<?>);
Assert.assertEquals(2, ((IRadioButtonGroup<?>) result.getFields().get(0)).getFieldCount());
Assert.assertTrue(result.getFields().get(1) instanceof ITabBox);
ITabBox tabbox = (ITabBox) result.getFields().get(1);
Assert.assertEquals(2, tabbox.getFieldCount());
IGroupBox tab1 = (IGroupBox) tabbox.getFields().get(0);
IGroupBox tab2 = (IGroupBox) tabbox.getFields().get(1);
Assert.assertEquals(1, tab1.getFieldCount());
Assert.assertEquals(1, tab2.getFieldCount());
ITreeBox<?> treebox = (ITreeBox<?>) tab1.getFields().get(0);
IListBox<?> listbox = (IListBox<?>) tab2.getFields().get(0);
Assert.assertEquals(2, /*treebox filter box is included as well*/
treebox.getFieldCount());
Assert.assertEquals(2, /*listbox filter box is included as well*/
listbox.getFieldCount());
return result;
}
Aggregations