Search in sources :

Example 1 with IGroupBox

use of org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox in project scout.rt by eclipse.

the class AbstractForm method initConfig.

protected void initConfig() {
    m_uiFacade = BEANS.get(ModelContextProxy.class).newProxy(new P_UIFacade(), ModelContext.copyCurrent().withForm(this));
    m_timerFutureMap = new HashMap<>();
    setShowOnStart(getConfiguredShowOnStart());
    m_contributionHolder = new ContributionComposite(this);
    // prepare injected fields
    List<Class<IFormField>> fieldArray = getConfiguredInjectedFields();
    DefaultFormFieldInjection injectedFields = null;
    IGroupBox rootBox = getRootGroupBox();
    try {
        if (fieldArray.size() > 0) {
            injectedFields = new DefaultFormFieldInjection(this);
            injectedFields.addFields(fieldArray);
            FormFieldInjectionThreadLocal.push(injectedFields);
        }
        // add mainbox if getter returns null
        if (rootBox == null) {
            List<IGroupBox> contributedFields = m_contributionHolder.getContributionsByClass(IGroupBox.class);
            rootBox = CollectionUtility.firstElement(contributedFields);
            if (rootBox == null) {
                Class<? extends IGroupBox> mainBoxClass = getConfiguredMainBox();
                if (mainBoxClass != null) {
                    rootBox = ConfigurationUtility.newInnerInstance(this, mainBoxClass);
                }
            }
            m_mainBox = rootBox;
        }
    } finally {
        if (injectedFields != null) {
            m_fieldReplacements = injectedFields.getReplacementMapping();
            FormFieldInjectionThreadLocal.pop(injectedFields);
        }
    }
    if (rootBox != null) {
        rootBox.setFormInternal(this);
        rootBox.setMainBox(true);
        rootBox.updateKeyStrokes();
        if (rootBox.isScrollable().isUndefined()) {
            rootBox.setScrollable(true);
        }
    }
    // move form fields
    new MoveFormFieldsHandler(this).moveFields();
    // 
    if (getConfiguredCloseTimer() > 0) {
        setCloseTimer(getConfiguredCloseTimer());
    }
    if (getConfiguredCustomTimer() > 0) {
        setTimer("custom", getConfiguredCustomTimer());
    }
    if (getConfiguredCancelVerificationText() != null) {
        setCancelVerificationText(getConfiguredCancelVerificationText());
    }
    if (getConfiguredTitle() != null) {
        setTitle(getConfiguredTitle());
    }
    if (getConfiguredSubTitle() != null) {
        setSubTitle(getConfiguredSubTitle());
    }
    setMinimizeEnabled(getConfiguredMinimizeEnabled());
    setMaximizeEnabled(getConfiguredMaximizeEnabled());
    setMinimized(getConfiguredMinimized());
    setMaximized(getConfiguredMaximized());
    setCacheBounds(getConfiguredCacheBounds());
    setAskIfNeedSave(getConfiguredAskIfNeedSave());
    setIconId(getConfiguredIconId());
    setCssClass((getConfiguredCssClass()));
    // Set 'modality' as preferred value if not 'auto'.
    int modalityHint = getConfiguredModalityHint();
    if (modalityHint != MODALITY_HINT_AUTO) {
        m_modal.set(modalityHint == MODALITY_HINT_MODAL, true);
    }
    // Set 'displayParent' as preferred value if not null; must precede setting of the 'displayHint'.
    IDisplayParent displayParent = getConfiguredDisplayParent();
    if (displayParent != null) {
        m_displayParent.set(displayParent, true);
    } else {
        m_displayParent.set(getDesktop(), false);
    }
    setDisplayHint(getConfiguredDisplayHint());
    setDisplayViewId(getConfiguredDisplayViewId());
    setClosable(getConfiguredClosable());
    setSaveNeededVisible(getConfiguredSaveNeededVisible());
    // visit all system buttons and attach observer
    // is auto-detaching
    m_systemButtonListener = new P_SystemButtonListener();
    IFormFieldVisitor v2 = new IFormFieldVisitor() {

        @Override
        public boolean visitField(IFormField field, int level, int fieldIndex) {
            if (field instanceof IButton) {
                final IButton button = (IButton) field;
                if (button.getSystemType() != IButton.SYSTEM_TYPE_NONE) {
                    button.addButtonListener(m_systemButtonListener);
                }
            }
            return true;
        }
    };
    visitFields(v2);
    getRootGroupBox().addPropertyChangeListener(new P_MainBoxPropertyChangeProxy());
    setButtonsArmed(true);
}
Also used : ContributionComposite(org.eclipse.scout.rt.shared.extension.ContributionComposite) IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) MoveFormFieldsHandler(org.eclipse.scout.rt.client.extension.ui.form.MoveFormFieldsHandler) IButton(org.eclipse.scout.rt.client.ui.form.fields.button.IButton) IGroupBox(org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox) IDisplayParent(org.eclipse.scout.rt.client.ui.IDisplayParent)

Example 2 with IGroupBox

use of org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox 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;
}
Also used : IListBox(org.eclipse.scout.rt.client.ui.form.fields.listbox.IListBox) ITreeBox(org.eclipse.scout.rt.client.ui.form.fields.treebox.ITreeBox) IGroupBox(org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox) ITabBox(org.eclipse.scout.rt.client.ui.form.fields.tabbox.ITabBox)

Example 3 with IGroupBox

use of org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox 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;
        }
    });
}
Also used : IHtmlListElement(org.eclipse.scout.rt.platform.html.IHtmlListElement) Element(org.w3c.dom.Element) FindFieldByXmlIdsVisitor(org.eclipse.scout.rt.client.ui.form.internal.FindFieldByXmlIdsVisitor) LinkedList(java.util.LinkedList) IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) IGroupBox(org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox) IExtensibleObject(org.eclipse.scout.rt.shared.extension.IExtensibleObject) ITabBox(org.eclipse.scout.rt.client.ui.form.fields.tabbox.ITabBox) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Example 4 with IGroupBox

use of org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox in project scout.rt by eclipse.

the class JsonTabBox method handleUiPropertyChange.

@Override
protected void handleUiPropertyChange(String propertyName, JSONObject data) {
    if (ITabBox.PROP_SELECTED_TAB.equals(propertyName)) {
        String tabId = data.optString("selectedTab");
        IGroupBox selectedTab = getGroupBoxForId(tabId);
        addPropertyEventFilterCondition(ITabBox.PROP_SELECTED_TAB, selectedTab);
        getModel().getUIFacade().setSelectedTabFromUI(selectedTab);
    } else {
        super.handleUiPropertyChange(propertyName, data);
    }
}
Also used : IGroupBox(org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox)

Example 5 with IGroupBox

use of org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox 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();
        }
    });
}
Also used : JsonAdapterPropertyConfigBuilder(org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterPropertyConfigBuilder) JsonAdapterPropertyConfig(org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterPropertyConfig) IGroupBox(org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox) ITabBox(org.eclipse.scout.rt.client.ui.form.fields.tabbox.ITabBox)

Aggregations

IGroupBox (org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox)13 ITabBox (org.eclipse.scout.rt.client.ui.form.fields.tabbox.ITabBox)7 IFormField (org.eclipse.scout.rt.client.ui.form.fields.IFormField)4 IListBox (org.eclipse.scout.rt.client.ui.form.fields.listbox.IListBox)3 ITreeBox (org.eclipse.scout.rt.client.ui.form.fields.treebox.ITreeBox)3 IForm (org.eclipse.scout.rt.client.ui.form.IForm)2 IButton (org.eclipse.scout.rt.client.ui.form.fields.button.IButton)2 JSONArray (org.json.JSONArray)2 JSONObject (org.json.JSONObject)2 Test (org.junit.Test)2 LinkedList (java.util.LinkedList)1 IClientSession (org.eclipse.scout.rt.client.IClientSession)1 MoveFormFieldsHandler (org.eclipse.scout.rt.client.extension.ui.form.MoveFormFieldsHandler)1 IDisplayParent (org.eclipse.scout.rt.client.ui.IDisplayParent)1 IKeyStroke (org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke)1 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)1 IViewButton (org.eclipse.scout.rt.client.ui.action.view.IViewButton)1 CalendarComponent (org.eclipse.scout.rt.client.ui.basic.calendar.CalendarComponent)1 ICalendar (org.eclipse.scout.rt.client.ui.basic.calendar.ICalendar)1 IFileChooser (org.eclipse.scout.rt.client.ui.basic.filechooser.IFileChooser)1