Search in sources :

Example 1 with RootNode

use of org.eclipse.scout.rt.client.ui.form.fields.composer.node.RootNode in project scout.rt by eclipse.

the class AbstractComposerField method initConfig.

@Override
protected void initConfig() {
    m_uiFacade = BEANS.get(ModelContextProxy.class).newProxy(new P_UIFacade(), ModelContext.copyCurrent());
    super.initConfig();
    m_dataModel = interceptCreateDataModel();
    // tree
    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) {
        RootNode rootNode = interceptCreateRootNode();
        rootNode.getCellForUpdate().setText(getLabel());
        m_tree.setRootNode(rootNode);
        m_tree.setNodeExpanded(rootNode, true);
        m_tree.setEnabled(isEnabled());
        m_tree.addTreeListener(new TreeAdapter() {

            @Override
            public void treeChanged(TreeEvent e) {
                switch(e.getType()) {
                    case TreeEvent.TYPE_NODES_DELETED:
                    case TreeEvent.TYPE_ALL_CHILD_NODES_DELETED:
                    case TreeEvent.TYPE_NODES_INSERTED:
                    case TreeEvent.TYPE_NODES_UPDATED:
                    case TreeEvent.TYPE_NODES_CHECKED:
                        {
                            checkSaveNeeded();
                            checkEmpty();
                            break;
                        }
                }
            }
        });
        // local enabled listener
        addPropertyChangeListener(PROP_ENABLED_COMPUTED, new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent e) {
                if (m_tree == null) {
                    return;
                }
                boolean newEnabled = ((Boolean) e.getNewValue()).booleanValue();
                m_tree.setEnabled(newEnabled);
            }
        });
    } else {
        LOG.warn("there is no inner class of type ITree in {}", getClass().getName());
    }
}
Also used : TreeEvent(org.eclipse.scout.rt.client.ui.basic.tree.TreeEvent) RootNode(org.eclipse.scout.rt.client.ui.form.fields.composer.node.RootNode) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree) TreeAdapter(org.eclipse.scout.rt.client.ui.basic.tree.TreeAdapter)

Aggregations

PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 ITree (org.eclipse.scout.rt.client.ui.basic.tree.ITree)1 TreeAdapter (org.eclipse.scout.rt.client.ui.basic.tree.TreeAdapter)1 TreeEvent (org.eclipse.scout.rt.client.ui.basic.tree.TreeEvent)1 RootNode (org.eclipse.scout.rt.client.ui.form.fields.composer.node.RootNode)1