/** * Constructs a new <code>ConnectorHierarchyTreeModel</code> instance. * * @param rootConnector * the connector being the root node of the tree. */ public ConnectorHierarchyTreeModel(ICompositeValueConnector rootConnector) { this.rootConnector = rootConnector; connectorsListener = new TreeConnectorsListener(); checkListenerRegistrationForConnector(rootConnector); addTreeModelListener(this); }
/** * {@inheritDoc} */ public boolean isLeaf(Object node) { if (node == rootConnector) { return false; } return getChildCount(node) == 0; }
IValueConnector connector = evt.getSource(); if (connector == rootConnector) { fireTreeStructureChanged(ConnectorHierarchyTreeModel.this, new TreePath(rootConnector)); return; childIndices[i - oldCollectionSize] = i; fireTreeNodesInserted(ConnectorHierarchyTreeModel.this, connectorPath.getPath(), childIndices, insertedChildren); } else if (newCollectionSize < oldCollectionSize) { fireTreeNodesRemoved(ConnectorHierarchyTreeModel.this, connectorPath.getPath(), childIndices, removedChildrenConnectors.toArray()); fireTreeNodesChanged(ConnectorHierarchyTreeModel.this, getTreePathForConnector(connector).getPath(), null, null); } else if (connector.getConnectorValue() != null) { fireTreeNodesChanged(ConnectorHierarchyTreeModel.this, getTreePathForConnector(parentConnector).getPath(), new int[] {getIndexOfChild(parentConnector, connector)}, new Object[] {connector});
/** * {@inheritDoc} */ public void treeNodesInserted(TreeModelEvent event) { for (Object insertedConnector : event.getChildren()) { checkListenerRegistrationForConnector((IValueConnector) insertedConnector); } }
ConnectorHierarchyTreeModel treeModel = new ConnectorHierarchyTreeModel( connector); viewComponent.getSelectionModel().setSelectionMode(
IValueConnector connector = (IValueConnector) evt.getSource(); if (connector == rootConnector) { fireTreeStructureChanged(ConnectorHierarchyTreeModel.this, new TreePath(rootConnector)); return; childIndices[i - oldCollectionSize] = i; fireTreeNodesInserted(ConnectorHierarchyTreeModel.this, connectorPath.getPath(), childIndices, insertedChildren); } else if (newCollectionSize < oldCollectionSize) { fireTreeNodesRemoved(ConnectorHierarchyTreeModel.this, connectorPath.getPath(), childIndices, removedChildrenConnectors.toArray()); fireTreeNodesChanged(ConnectorHierarchyTreeModel.this, getTreePathForConnector(connector).getPath(), null, null); } else if (connector.getConnectorValue() != null) { fireTreeNodesChanged(ConnectorHierarchyTreeModel.this, getTreePathForConnector(parentConnector).getPath(), new int[] {getIndexOfChild(parentConnector, connector)}, new Object[] {connector});
/** * {@inheritDoc} */ public void treeStructureChanged(TreeModelEvent event) { ICollectionConnectorListProvider changedConnector = (ICollectionConnectorListProvider) event .getTreePath().getLastPathComponent(); checkListenerRegistrationForConnector(changedConnector); }
ConnectorHierarchyTreeModel treeModel = new ConnectorHierarchyTreeModel( connector); viewComponent.getSelectionModel().setSelectionMode(
/** * Constructs a new <code>ConnectorHierarchyTreeModel</code> instance. * * @param rootConnector * the connector being the root node of the tree. */ public ConnectorHierarchyTreeModel(ICompositeValueConnector rootConnector) { this.rootConnector = rootConnector; connectorsListener = new TreeConnectorsListener(); checkListenerRegistrationForConnector(rootConnector); addTreeModelListener(this); }
/** * {@inheritDoc} */ public void treeNodesInserted(TreeModelEvent event) { for (Object insertedConnector : event.getChildren()) { checkListenerRegistrationForConnector((IValueConnector) insertedConnector); } }
/** * {@inheritDoc} */ public boolean isLeaf(Object node) { if (node == rootConnector) { return false; } return getChildCount(node) == 0; }
/** * {@inheritDoc} */ public void treeStructureChanged(TreeModelEvent event) { ICollectionConnectorListProvider changedConnector = (ICollectionConnectorListProvider) event .getTreePath().getLastPathComponent(); checkListenerRegistrationForConnector(changedConnector); }
private void checkListenerRegistrationForConnector(IValueConnector connector) { if (connector != null) { // we can add the listener many times since the backing store listener // collection is a Set. connector.addValueChangeListener(connectorsListener); if (connector instanceof ICompositeValueConnector) { for (String childConnectorId : ((ICompositeValueConnector) connector) .getChildConnectorKeys()) { checkListenerRegistrationForConnector(((ICompositeValueConnector) connector) .getChildConnector(childConnectorId)); } } } }
private void checkListenerRegistrationForConnector(IValueConnector connector) { if (connector != null) { // we can add the listener many times since the backing store listener // collection is a Set. connector.addConnectorValueChangeListener(connectorsListener); if (connector instanceof ICompositeValueConnector) { for (String childConnectorId : ((ICompositeValueConnector) connector) .getChildConnectorKeys()) { checkListenerRegistrationForConnector(((ICompositeValueConnector) connector) .getChildConnector(childConnectorId)); } } } }