Search in sources :

Example 26 with ITreeNode

use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.

the class AbstractTreeBox method loadChildNodes.

@Override
public final void loadChildNodes(ITreeNode parentNode) {
    if (m_tree != null) {
        try {
            m_valueTreeSyncActive = true;
            m_tree.setTreeChanging(true);
            // 
            interceptLoadChildNodes(parentNode);
            // when tree is non-incremental, mark all leaf cadidates as leafs
            if (!isLoadIncremental()) {
                ITreeVisitor v = new ITreeVisitor() {

                    @Override
                    public boolean visit(ITreeNode node) {
                        if (node.getChildNodeCount() == 0) {
                            node.setLeafInternal(true);
                        } else {
                            node.setLeafInternal(false);
                        }
                        return true;
                    }
                };
                getTree().visitNode(getTree().getRootNode(), v);
            }
            // auto-expand all
            if (isAutoExpandAll()) {
                m_tree.expandAll(parentNode);
            }
        } finally {
            m_tree.setTreeChanging(false);
            m_valueTreeSyncActive = false;
        }
        syncValueToTree();
    }
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) ITreeVisitor(org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)

Example 27 with ITreeNode

use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.

the class AbstractTreeBox method checkAllKeys.

@Override
public void checkAllKeys() {
    final Set<T> keySet = new HashSet<T>();
    ITreeVisitor v = new ITreeVisitor() {

        @SuppressWarnings("unchecked")
        @Override
        public boolean visit(ITreeNode node) {
            if (node.getPrimaryKey() != null) {
                keySet.add((T) node.getPrimaryKey());
            }
            return true;
        }
    };
    m_tree.visitNode(m_tree.getRootNode(), v);
    checkKeys(keySet);
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) HashSet(java.util.HashSet) ITreeVisitor(org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)

Example 28 with ITreeNode

use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.

the class AbstractTreeField method doSave.

@Override
public void doSave() {
    if (m_tree != null && !m_treeExternallyManaged) {
        try {
            m_tree.setTreeChanging(true);
            // 
            // 1. batch
            interceptSave(m_tree.getInsertedNodes(), m_tree.getUpdatedNodes(), m_tree.getDeletedNodes());
            // deleted nodes
            for (ITreeNode iTreeNode : m_tree.getDeletedNodes()) {
                interceptSaveDeletedNode(iTreeNode);
            }
            m_tree.clearDeletedNodes();
            // inserted nodes
            for (ITreeNode insertedNode : m_tree.getInsertedNodes()) {
                interceptSaveInsertedNode(insertedNode);
                insertedNode.setStatusInternal(ITreeNode.STATUS_NON_CHANGED);
                m_tree.updateNode(insertedNode);
            }
            // updated rows
            for (ITreeNode updatedNode : m_tree.getUpdatedNodes()) {
                interceptSaveUpdatedNode(updatedNode);
                updatedNode.setStatusInternal(ITreeNode.STATUS_NON_CHANGED);
                m_tree.updateNode(updatedNode);
            }
        } finally {
            m_tree.setTreeChanging(false);
        }
    }
    markSaved();
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)

Example 29 with ITreeNode

use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.

the class IncrementalTreeBuilder method createParentMap.

/**
 * Creates a map containing every key in the tree and its parent tree node
 */
public Map<LOOKUP_KEY, ILookupRow<LOOKUP_KEY>> createParentMap(ITree tree) {
    final Map<LOOKUP_KEY, ILookupRow<LOOKUP_KEY>> map = new HashMap<>();
    tree.visitTree(new ITreeVisitor() {

        @Override
        public boolean visit(ITreeNode node) {
            ITreeNode parent = node.getParentNode();
            ILookupRow<LOOKUP_KEY> row = getLookupRow(node);
            if (row != null) {
                LOOKUP_KEY key = row.getKey();
                m_keyCache.put(key, row);
                map.put(key, getLookupRow(parent));
            }
            return true;
        }
    });
    return map;
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) HashMap(java.util.HashMap) ITreeVisitor(org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)

Example 30 with ITreeNode

use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.

the class DefaultSearchFilterService method applySearchDelegate.

@Override
public void applySearchDelegate(IFormField field, SearchFilter search, boolean includeChildren) {
    String label = field.getLabel();
    if (field.getParentField() instanceof ISequenceBox && field.getParentField() instanceof AbstractFormField) {
        AbstractFormField range = (AbstractFormField) field.getParentField();
        if (range.getInitialLabel() != null) {
            label = range.getInitialLabel() + (StringUtility.isNullOrEmpty(label) ? "" : " " + label);
        }
    }
    // composer
    if (field instanceof AbstractComposerField) {
        AbstractComposerField composerField = (AbstractComposerField) field;
        ITreeNode rootNode = composerField.getTree().getRootNode();
        if (rootNode != null) {
            StringBuilder buf = new StringBuilder();
            new ComposerDisplayTextBuilder().build(rootNode, buf, "");
            String s = buf.toString();
            if (StringUtility.hasText(s)) {
                search.addDisplayText(s);
            }
        }
        return;
    }
    // list box
    if (field instanceof AbstractListBox<?>) {
        AbstractListBox<?> valueField = (AbstractListBox<?>) field;
        if (!valueField.getValue().isEmpty()) {
            search.addDisplayText(label + " " + TEXTS.get("LogicIn") + " " + valueField.getDisplayText());
        }
        return;
    }
    // tree box
    if (field instanceof AbstractTreeBox<?>) {
        AbstractTreeBox<?> valueField = (AbstractTreeBox<?>) field;
        if (!valueField.getValue().isEmpty()) {
            search.addDisplayText(label + " " + TEXTS.get("LogicIn") + " " + valueField.getDisplayText());
        }
        return;
    }
    // string, html, label field
    if (field instanceof AbstractStringField || field instanceof AbstractHtmlField || field instanceof AbstractLabelField) {
        AbstractValueField<?> valueField = (AbstractValueField<?>) field;
        if (valueField.getValue() != null) {
            search.addDisplayText(label + " " + TEXTS.get("LogicLike") + " " + valueField.getDisplayText());
        }
        return;
    }
    // boolean field
    if (field instanceof AbstractBooleanField) {
        AbstractBooleanField valueField = (AbstractBooleanField) field;
        if (valueField.getValue() != null && valueField.getValue()) {
            search.addDisplayText(label);
        }
        return;
    }
    // radiobuttongroup field
    if (field instanceof AbstractRadioButtonGroup<?>) {
        AbstractRadioButtonGroup<?> valueField = (AbstractRadioButtonGroup<?>) field;
        if (valueField.getValue() != null) {
            IButton selectedButton = valueField.getSelectedButton();
            search.addDisplayText(label + " = " + (selectedButton != null ? selectedButton.getLabel() : ""));
        }
        return;
    }
    // value field
    if (field instanceof AbstractValueField<?>) {
        AbstractValueField<?> valueField = (AbstractValueField<?>) field;
        if (valueField.getValue() != null) {
            search.addDisplayText(label + " " + TEXTS.get("LogicEQ") + " " + valueField.getDisplayText());
        }
        return;
    }
    if (includeChildren) {
        applySearchDelegateForChildren(field, search);
    }
}
Also used : AbstractFormField(org.eclipse.scout.rt.client.ui.form.fields.AbstractFormField) AbstractHtmlField(org.eclipse.scout.rt.client.ui.form.fields.htmlfield.AbstractHtmlField) AbstractStringField(org.eclipse.scout.rt.client.ui.form.fields.stringfield.AbstractStringField) ISequenceBox(org.eclipse.scout.rt.client.ui.form.fields.sequencebox.ISequenceBox) ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) AbstractValueField(org.eclipse.scout.rt.client.ui.form.fields.AbstractValueField) AbstractLabelField(org.eclipse.scout.rt.client.ui.form.fields.labelfield.AbstractLabelField) IButton(org.eclipse.scout.rt.client.ui.form.fields.button.IButton) AbstractRadioButtonGroup(org.eclipse.scout.rt.client.ui.form.fields.radiobuttongroup.AbstractRadioButtonGroup) AbstractListBox(org.eclipse.scout.rt.client.ui.form.fields.listbox.AbstractListBox) AbstractComposerField(org.eclipse.scout.rt.client.ui.form.fields.composer.AbstractComposerField) ComposerDisplayTextBuilder(org.eclipse.scout.rt.client.ui.form.fields.composer.internal.ComposerDisplayTextBuilder) AbstractBooleanField(org.eclipse.scout.rt.client.ui.form.fields.booleanfield.AbstractBooleanField) AbstractTreeBox(org.eclipse.scout.rt.client.ui.form.fields.treebox.AbstractTreeBox)

Aggregations

ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)95 Test (org.junit.Test)34 ITree (org.eclipse.scout.rt.client.ui.basic.tree.ITree)29 ArrayList (java.util.ArrayList)23 ITreeVisitor (org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)16 JSONObject (org.json.JSONObject)14 TreeNode (org.eclipse.scout.rt.ui.html.json.tree.fixtures.TreeNode)12 JsonEvent (org.eclipse.scout.rt.ui.html.json.JsonEvent)11 JSONArray (org.json.JSONArray)10 HashSet (java.util.HashSet)9 IPage (org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage)6 EitherOrNode (org.eclipse.scout.rt.client.ui.form.fields.composer.node.EitherOrNode)6 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)5 TreeEvent (org.eclipse.scout.rt.client.ui.basic.tree.TreeEvent)5 IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)5 LinkedList (java.util.LinkedList)4 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)4 IDesktop (org.eclipse.scout.rt.client.ui.desktop.IDesktop)4 ITreeNodeFilter (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNodeFilter)3 StyleField (org.eclipse.scout.rt.client.ui.form.fields.smartfield.SmartFieldTest.TestForm.MainBox.StyleField)3