Search in sources :

Example 16 with BaseTreeNode

use of com.revolsys.swing.tree.BaseTreeNode in project com.revolsys.open by revolsys.

the class ProjectFrame method newTabLeftCatalogPanel.

protected void newTabLeftCatalogPanel() {
    final BaseTreeNode recordStores = RecordStoreConnectionTrees.newRecordStoreConnectionsTreeNode();
    final BaseTreeNode fileSystems = PathTreeNode.newFileSystemsTreeNode();
    final BaseTreeNode folderConnections = FolderConnectionsTrees.newFolderConnectionsTreeNode();
    final BaseTreeNode webServices = WebServiceConnectionTrees.newWebServiceConnectionsTreeNode();
    final ListTreeNode root = new ListTreeNode("/", recordStores, fileSystems, folderConnections, webServices);
    final BaseTree tree = new BaseTree(root);
    tree.setRootVisible(false);
    recordStores.expandChildren();
    fileSystems.expand();
    folderConnections.expandChildren();
    webServices.expandChildren();
    this.catalogTree = tree;
    final Icon icon = Icons.getIconWithBadge("folder", "tree");
    final TabbedPane tabs = this.leftTabs;
    final Component component = this.catalogTree;
    tabs.addTab(icon, "Catalog", component, true);
}
Also used : BaseTree(com.revolsys.swing.tree.BaseTree) BaseTreeNode(com.revolsys.swing.tree.BaseTreeNode) DnDTabbedPane(com.revolsys.swing.component.DnDTabbedPane) JTabbedPane(javax.swing.JTabbedPane) TabbedPane(com.revolsys.swing.TabbedPane) Icon(javax.swing.Icon) Component(java.awt.Component) JComponent(javax.swing.JComponent) ListTreeNode(com.revolsys.swing.tree.node.ListTreeNode)

Example 17 with BaseTreeNode

use of com.revolsys.swing.tree.BaseTreeNode in project com.revolsys.open by revolsys.

the class TreeTransferHandler method canImport.

@Override
public boolean canImport(final TransferSupport support) {
    final Component component = support.getComponent();
    if (component instanceof JTree) {
        final JTree.DropLocation loc = (JTree.DropLocation) support.getDropLocation();
        final TreePath path = loc.getPath();
        if (path != null) {
            final Object pathItem = path.getLastPathComponent();
            if (pathItem instanceof BaseTreeNode) {
                final BaseTreeNode node = (BaseTreeNode) pathItem;
                return node.isDndCanImport(path, support);
            }
        }
    }
    return false;
}
Also used : JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) BaseTreeNode(com.revolsys.swing.tree.BaseTreeNode) JComponent(javax.swing.JComponent) Component(java.awt.Component)

Example 18 with BaseTreeNode

use of com.revolsys.swing.tree.BaseTreeNode in project com.revolsys.open by revolsys.

the class FunctionChildrenTreeNode method loadChildrenDo.

@Override
protected List<BaseTreeNode> loadChildrenDo() {
    final Object userObject = getUserObject();
    final List<BaseTreeNode> nodes = new ArrayList<>();
    for (final Object child : this.factory.apply(userObject)) {
        final BaseTreeNode node = BaseTreeNode.newTreeNode(child);
        if (node != null) {
            nodes.add(node);
        }
    }
    return nodes;
}
Also used : ArrayList(java.util.ArrayList) BaseTreeNode(com.revolsys.swing.tree.BaseTreeNode)

Example 19 with BaseTreeNode

use of com.revolsys.swing.tree.BaseTreeNode in project com.revolsys.open by revolsys.

the class ListTreeNode method setChildren.

public void setChildren(final List<? extends BaseTreeNode> children) {
    final List<BaseTreeNode> oldChildren = this.children;
    if (children != oldChildren) {
        for (int i = 0; i < oldChildren.size(); ) {
            final BaseTreeNode oldChild = oldChildren.get(i);
            if (children.contains(oldChild)) {
                i++;
            } else {
                oldChildren.remove(i);
                nodeRemoved(i, oldChild);
                oldChild.setParent(null);
            }
        }
        int i = 0;
        while (i < children.size() && i < oldChildren.size()) {
            final BaseTreeNode oldChild = oldChildren.get(i);
            final BaseTreeNode newNode = children.get(i);
            if (!newNode.equals(oldChild)) {
                newNode.setParent(this);
                oldChildren.add(i, newNode);
                nodesInserted(i);
            }
            i++;
        }
        while (i < children.size()) {
            final BaseTreeNode newNode = children.get(i);
            newNode.setParent(this);
            oldChildren.add(i, newNode);
            nodesInserted(i);
            i++;
        }
    }
}
Also used : BaseTreeNode(com.revolsys.swing.tree.BaseTreeNode)

Example 20 with BaseTreeNode

use of com.revolsys.swing.tree.BaseTreeNode in project com.revolsys.open by revolsys.

the class ListTreeNode method removeNode.

public void removeNode(final int index) {
    Invoke.andWait(() -> {
        if (index >= 0 && index < this.children.size()) {
            final BaseTreeNode node = this.children.remove(index);
            node.setParent(null);
            nodeRemoved(index, node);
        }
    });
}
Also used : BaseTreeNode(com.revolsys.swing.tree.BaseTreeNode)

Aggregations

BaseTreeNode (com.revolsys.swing.tree.BaseTreeNode)27 LayerGroup (com.revolsys.swing.map.layer.LayerGroup)5 ArrayList (java.util.ArrayList)5 AbstractLayer (com.revolsys.swing.map.layer.AbstractLayer)4 Layer (com.revolsys.swing.map.layer.Layer)4 TreePath (javax.swing.tree.TreePath)4 Component (java.awt.Component)3 Path (java.nio.file.Path)3 JComponent (javax.swing.JComponent)3 RecordStore (com.revolsys.record.schema.RecordStore)2 RecordStoreSchemaElement (com.revolsys.record.schema.RecordStoreSchemaElement)2 BaseTree (com.revolsys.swing.tree.BaseTree)2 JTree (javax.swing.JTree)2 PathName (com.revolsys.io.PathName)1 FileConnectionManager (com.revolsys.io.file.FileConnectionManager)1 RecordStoreConnectionManager (com.revolsys.record.io.RecordStoreConnectionManager)1 RecordStoreSchema (com.revolsys.record.schema.RecordStoreSchema)1 TabbedPane (com.revolsys.swing.TabbedPane)1 DnDTabbedPane (com.revolsys.swing.component.DnDTabbedPane)1 Project (com.revolsys.swing.map.layer.Project)1