Search in sources :

Example 6 with OrderedComparator

use of org.eclipse.scout.rt.platform.OrderedComparator 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)

Example 7 with OrderedComparator

use of org.eclipse.scout.rt.platform.OrderedComparator in project scout.rt by eclipse.

the class AbstractListBox method initConfig.

@Override
protected void initConfig() {
    m_fields = CollectionUtility.emptyArrayList();
    m_movedFormFieldsByClass = new HashMap<Class<? extends IFormField>, IFormField>();
    super.initConfig();
    setFilterActiveRows(getConfiguredFilterActiveRows());
    setFilterActiveRowsValue(TriState.TRUE);
    setFilterCheckedRows(getConfiguredFilterCheckedRows());
    setFilterCheckedRowsValue(getConfiguredFilterCheckedRows());
    List<ITable> contributedTables = m_contributionHolder.getContributionsByClass(ITable.class);
    m_table = CollectionUtility.firstElement(contributedTables);
    if (m_table == null) {
        Class<? extends ITable> configuredTable = getConfiguredTable();
        if (configuredTable != null) {
            m_table = ConfigurationUtility.newInnerInstance(this, configuredTable);
        }
    }
    if (m_table != null) {
        if (m_table instanceof AbstractTable) {
            ((AbstractTable) m_table).setContainerInternal(this);
        }
        updateActiveRowsFilter();
        updateCheckedRowsFilter();
        m_table.addTableListener(new TableAdapter() {

            @Override
            public void tableChanged(TableEvent e) {
                switch(e.getType()) {
                    case TableEvent.TYPE_ROWS_SELECTED:
                        {
                            if (!getTable().isCheckable()) {
                                syncTableToValue();
                            }
                            break;
                        }
                    case TableEvent.TYPE_ROWS_CHECKED:
                        {
                            if (getTable().isCheckable()) {
                                syncTableToValue();
                            }
                            break;
                        }
                }
            }
        });
        // default icon
        if (m_table.getDefaultIconId() == null && this.getConfiguredIconId() != null) {
            m_table.setDefaultIconId(this.getConfiguredIconId());
        }
        m_table.setEnabled(isEnabled());
    } else {
        LOG.warn("there is no inner class of type ITable in {}", getClass().getName());
    }
    // lookup call
    Class<? extends ILookupCall<KEY>> lookupCallClass = getConfiguredLookupCall();
    if (lookupCallClass != null) {
        ILookupCall<KEY> 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_table == null) {
                return;
            }
            String name = e.getPropertyName();
            if (PROP_ENABLED_COMPUTED.equals(name)) {
                boolean newEnabled = ((Boolean) e.getNewValue()).booleanValue();
                m_table.setEnabled(newEnabled);
            } else if (PROP_FILTER_CHECKED_ROWS_VALUE.equals(name)) {
                updateCheckedRowsFilter();
            } else if (PROP_FILTER_ACTIVE_ROWS_VALUE.equals(name)) {
                updateActiveRowsFilter();
            }
        }
    });
    // add fields
    List<Class<? extends IFormField>> fieldClasses = getConfiguredFields();
    List<IFormField> contributedFields = m_contributionHolder.getContributionsByClass(IFormField.class);
    List<IFormField> fieldList = new ArrayList<IFormField>(fieldClasses.size() + contributedFields.size());
    for (Class<? extends IFormField> fieldClazz : fieldClasses) {
        IFormField f = ConfigurationUtility.newInnerInstance(this, fieldClazz);
        fieldList.add(f);
    }
    fieldList.addAll(contributedFields);
    Collections.sort(fieldList, new OrderedComparator());
    for (IFormField f : fieldList) {
        f.setParentFieldInternal(this);
    }
    m_fields = fieldList;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) ArrayList(java.util.ArrayList) TableAdapter(org.eclipse.scout.rt.client.ui.basic.table.TableAdapter) IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) AbstractTable(org.eclipse.scout.rt.client.ui.basic.table.AbstractTable) TableEvent(org.eclipse.scout.rt.client.ui.basic.table.TableEvent) OrderedComparator(org.eclipse.scout.rt.platform.OrderedComparator) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable)

Example 8 with OrderedComparator

use of org.eclipse.scout.rt.platform.OrderedComparator in project scout.rt by eclipse.

the class AbstractCode method execCreateChildCodes.

/**
 * @return Creates and returns child codes. Note: {@link #addChildCodeInternal(ICode)} must not be invoked.
 * @since 3.8.3
 */
@ConfigOperation
@SuppressWarnings("unchecked")
protected List<? extends ICode<T>> execCreateChildCodes() {
    List<Class<ICode>> configuredCodes = getConfiguredCodes();
    List<ICode> contributedCodes = m_contributionHolder.getContributionsByClass(ICode.class);
    List<ICode<T>> codes = new ArrayList<ICode<T>>(configuredCodes.size() + contributedCodes.size());
    for (Class<? extends ICode> codeClazz : configuredCodes) {
        ICode<T> code = ConfigurationUtility.newInnerInstance(this, codeClazz);
        codes.add(code);
    }
    for (ICode<?> c : contributedCodes) {
        codes.add((ICode<T>) c);
    }
    Collections.sort(codes, new OrderedComparator());
    return codes;
}
Also used : OrderedComparator(org.eclipse.scout.rt.platform.OrderedComparator) ArrayList(java.util.ArrayList) ConfigOperation(org.eclipse.scout.rt.platform.annotations.ConfigOperation)

Example 9 with OrderedComparator

use of org.eclipse.scout.rt.platform.OrderedComparator in project scout.rt by eclipse.

the class MoveCodesHandler method sortChildren.

@Override
protected void sortChildren(CODE parent) {
    List<? extends ICode<CODE_ID>> childCodes = parent.getChildCodes(false);
    Collections.sort(childCodes, new OrderedComparator());
    int index = 0;
    for (ICode<CODE_ID> code : childCodes) {
        parent.addChildCodeInternal(index, code);
        index++;
    }
}
Also used : OrderedComparator(org.eclipse.scout.rt.platform.OrderedComparator)

Aggregations

OrderedComparator (org.eclipse.scout.rt.platform.OrderedComparator)9 ArrayList (java.util.ArrayList)4 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 PropertyChangeListener (java.beans.PropertyChangeListener)2 IFormField (org.eclipse.scout.rt.client.ui.form.fields.IFormField)2 DeepLinkException (org.eclipse.scout.rt.client.deeplink.DeepLinkException)1 IDeviceTransformationService (org.eclipse.scout.rt.client.transformation.IDeviceTransformationService)1 IEventHistory (org.eclipse.scout.rt.client.ui.IEventHistory)1 ActionFinder (org.eclipse.scout.rt.client.ui.action.ActionFinder)1 IAction (org.eclipse.scout.rt.client.ui.action.IAction)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 AbstractTable (org.eclipse.scout.rt.client.ui.basic.table.AbstractTable)1 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)1 TableAdapter (org.eclipse.scout.rt.client.ui.basic.table.TableAdapter)1 TableEvent (org.eclipse.scout.rt.client.ui.basic.table.TableEvent)1 AbstractTableControl (org.eclipse.scout.rt.client.ui.basic.table.controls.AbstractTableControl)1 AbstractTree (org.eclipse.scout.rt.client.ui.basic.tree.AbstractTree)1 ITree (org.eclipse.scout.rt.client.ui.basic.tree.ITree)1