Search in sources :

Example 51 with IFormField

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

the class AbstractRadioButtonGroup method initConfig.

@Override
protected void initConfig() {
    m_fields = CollectionUtility.emptyArrayList();
    m_movedFormFieldsByClass = new HashMap<Class<? extends IFormField>, IFormField>();
    m_fieldPropertyChangeListener = new P_FieldPropertyChangeListenerEx();
    m_grid = createGrid();
    super.initConfig();
    // Configured CodeType
    if (getConfiguredCodeType() != null) {
        setCodeTypeClass(getConfiguredCodeType());
    }
    // Configured LookupCall
    Class<? extends ILookupCall<T>> lookupCallClass = getConfiguredLookupCall();
    if (lookupCallClass != null) {
        ILookupCall<T> call = BEANS.get(lookupCallClass);
        setLookupCall(call);
    }
    // add fields
    List<Class<? extends IFormField>> configuredFields = getConfiguredFields();
    List<IFormField> contributedFields = m_contributionHolder.getContributionsByClass(IFormField.class);
    OrderedCollection<IFormField> fields = new OrderedCollection<IFormField>();
    for (Class<? extends IFormField> fieldClazz : configuredFields) {
        fields.addOrdered(ConfigurationUtility.newInnerInstance(this, fieldClazz));
    }
    fields.addAllOrdered(contributedFields);
    injectFieldsInternal(fields);
    for (IFormField f : fields) {
        f.setParentFieldInternal(this);
    }
    m_fields = fields.getOrderedList();
    // attach a proxy controller to each child field in the group for: visible, saveNeeded
    for (IFormField f : m_fields) {
        f.addPropertyChangeListener(m_fieldPropertyChangeListener);
    }
    // extract buttons from field subtree
    List<IRadioButton<T>> buttonList = new ArrayList<IRadioButton<T>>();
    for (IFormField f : m_fields) {
        IRadioButton<T> b = findFirstButtonInFieldTree(f);
        if (b != null) {
            buttonList.add(b);
        }
    }
    m_radioButtons = buttonList;
    // decorate radio buttons
    for (IRadioButton b : m_radioButtons) {
        b.addPropertyChangeListener(new P_ButtonPropertyChangeListener());
    }
    handleFieldVisibilityChanged();
}
Also used : ArrayList(java.util.ArrayList) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection) IRadioButton(org.eclipse.scout.rt.client.ui.form.fields.button.IRadioButton) IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField)

Example 52 with IFormField

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

the class AbstractSequenceBox method getFullyQualifiedLabel.

@Override
public String getFullyQualifiedLabel(String separator) {
    StringBuilder b = new StringBuilder();
    IFormField p = getParentField();
    if (p != null) {
        String s = p.getFullyQualifiedLabel(separator);
        if (s != null) {
            b.append(s);
        }
    }
    String s = m_labelBase;
    if (s != null) {
        if (b.length() > 0) {
            b.append(separator);
        }
        b.append(s);
    }
    return b.toString();
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField)

Example 53 with IFormField

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

the class SequenceBoxGrid method layoutStatic.

private void layoutStatic(List<IFormField> fields) {
    int x = 0;
    for (IFormField field : fields) {
        GridData data = GridDataBuilder.createFromHints(field, 1);
        data.x = x;
        data.y = 0;
        if (data.weightX < 0) {
            if (field instanceof IButton) {
                data.useUiWidth = true;
                data.weightX = 0;
            } else {
                data.weightX = data.w;
            }
        }
        field.setGridDataInternal(data);
        x = x + data.w;
        m_gridRows = Math.max(m_gridRows, data.h);
    }
    m_gridColumns = x;
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) IButton(org.eclipse.scout.rt.client.ui.form.fields.button.IButton) GridData(org.eclipse.scout.rt.client.ui.form.fields.GridData)

Example 54 with IFormField

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

the class SequenceBoxGrid method validate.

@Override
public void validate(ISequenceBox sequenceBox) {
    // reset
    m_gridColumns = 0;
    m_gridRows = 0;
    List<IFormField> list = new ArrayList<IFormField>();
    // filter
    for (IFormField f : sequenceBox.getFields()) {
        if (f.isVisible()) {
            list.add(f);
        } else {
            GridData data = GridDataBuilder.createFromHints(f, 1);
            f.setGridDataInternal(data);
        }
    }
    layoutStatic(list);
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) ArrayList(java.util.ArrayList) GridData(org.eclipse.scout.rt.client.ui.form.fields.GridData)

Example 55 with IFormField

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

the class AbstractTreeBox method initConfig.

@SuppressWarnings("unchecked")
@Override
protected void initConfig() {
    m_fields = CollectionUtility.emptyArrayList();
    m_movedFormFieldsByClass = new HashMap<Class<? extends IFormField>, IFormField>();
    super.initConfig();
    setFilterActiveNodes(getConfiguredFilterActiveNodes());
    setFilterActiveNodesValue(TriState.TRUE);
    setFilterCheckedNodes(getConfiguredFilterCheckedNodes());
    setFilterCheckedNodesValue(getConfiguredFilterCheckedNodes());
    setAutoExpandAll(getConfiguredAutoExpandAll());
    setLoadIncremental(getConfiguredLoadIncremental());
    List<ITree> contributedTrees = m_contributionHolder.getContributionsByClass(ITree.class);
    m_tree = CollectionUtility.firstElement(contributedTrees);
    if (m_tree == null) {
        Class<? extends ITree> configuredTree = getConfiguredTree();
        if (configuredTree != null) {
            m_tree = ConfigurationUtility.newInnerInstance(this, configuredTree);
        }
    }
    if (m_tree != null) {
        if (m_tree instanceof AbstractTree) {
            ((AbstractTree) m_tree).setContainerInternal(this);
        }
        m_tree.setRootNode(getTreeNodeBuilder().createTreeNode(new LookupRow(null, "Root"), ITreeNode.STATUS_NON_CHANGED, false));
        m_tree.setAutoDiscardOnDelete(false);
        updateActiveNodesFilter();
        updateCheckedNodesFilter();
        m_tree.addTreeListener(new TreeAdapter() {

            @Override
            public void treeChanged(TreeEvent e) {
                switch(e.getType()) {
                    case TreeEvent.TYPE_NODES_SELECTED:
                        {
                            if (!getTree().isCheckable()) {
                                syncTreeToValue();
                            }
                            break;
                        }
                    case TreeEvent.TYPE_NODES_CHECKED:
                        {
                            if (getTree().isCheckable()) {
                                syncTreeToValue();
                            }
                            break;
                        }
                }
            }
        });
        m_tree.setEnabled(isEnabled());
        // default icon
        if (this.getConfiguredIconId() != null) {
            m_tree.setDefaultIconId(this.getConfiguredIconId());
        }
    } else {
        LOG.warn("there is no inner class of type ITree in {}", getClass().getName());
    }
    getTree().setAutoCheckChildNodes(getConfiguredAutoCheckChildNodes());
    Class<? extends ILookupCall<T>> lookupCallClass = getConfiguredLookupCall();
    if (lookupCallClass != null) {
        ILookupCall<T> call = BEANS.get(lookupCallClass);
        setLookupCall(call);
    }
    // code type
    if (getConfiguredCodeType() != null) {
        setCodeTypeClass(getConfiguredCodeType());
    }
    // local property listener
    addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            if (m_tree == null) {
                return;
            }
            String name = e.getPropertyName();
            if (PROP_ENABLED_COMPUTED.equals(name)) {
                boolean newEnabled = ((Boolean) e.getNewValue()).booleanValue();
                m_tree.setEnabled(newEnabled);
            } else if (PROP_FILTER_CHECKED_NODES_VALUE.equals(name)) {
                updateCheckedNodesFilter();
            } else if (PROP_FILTER_ACTIVE_NODES_VALUE.equals(name)) {
                updateActiveNodesFilter();
            }
        }
    });
    // add fields
    List<Class<? extends IFormField>> configuredFields = getConfiguredFields();
    List<IFormField> contributedFields = m_contributionHolder.getContributionsByClass(IFormField.class);
    List<IFormField> fieldList = new ArrayList<IFormField>(configuredFields.size() + contributedFields.size());
    for (Class<? extends IFormField> fieldClazz : configuredFields) {
        fieldList.add(ConfigurationUtility.newInnerInstance(this, fieldClazz));
    }
    fieldList.addAll(contributedFields);
    Collections.sort(fieldList, new OrderedComparator());
    for (IFormField f : fieldList) {
        f.setParentFieldInternal(this);
    }
    m_fields = fieldList;
}
Also used : ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) LookupRow(org.eclipse.scout.rt.shared.services.lookup.LookupRow) PropertyChangeEvent(java.beans.PropertyChangeEvent) AbstractTree(org.eclipse.scout.rt.client.ui.basic.tree.AbstractTree) PropertyChangeListener(java.beans.PropertyChangeListener) ArrayList(java.util.ArrayList) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree) TreeAdapter(org.eclipse.scout.rt.client.ui.basic.tree.TreeAdapter) TreeEvent(org.eclipse.scout.rt.client.ui.basic.tree.TreeEvent) IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) OrderedComparator(org.eclipse.scout.rt.platform.OrderedComparator)

Aggregations

IFormField (org.eclipse.scout.rt.client.ui.form.fields.IFormField)60 Test (org.junit.Test)19 ArrayList (java.util.ArrayList)13 GridData (org.eclipse.scout.rt.client.ui.form.fields.GridData)12 IButton (org.eclipse.scout.rt.client.ui.form.fields.button.IButton)5 PlatformError (org.eclipse.scout.rt.platform.exception.PlatformError)5 PropertyChangeEvent (java.beans.PropertyChangeEvent)4 PropertyChangeListener (java.beans.PropertyChangeListener)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 IColumn (org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn)4 IGroupBox (org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox)4 IExtensibleObject (org.eclipse.scout.rt.shared.extension.IExtensibleObject)4 Map (java.util.Map)3 PlatformExceptionTranslator (org.eclipse.scout.rt.platform.exception.PlatformExceptionTranslator)3 LinkedList (java.util.LinkedList)2 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)2 ICompositeField (org.eclipse.scout.rt.client.ui.form.fields.ICompositeField)2 IValueField (org.eclipse.scout.rt.client.ui.form.fields.IValueField)2 FindFieldByFormDataIdVisitor (org.eclipse.scout.rt.client.ui.form.internal.FindFieldByFormDataIdVisitor)2