Search in sources :

Example 21 with BaseTreeNode

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

the class PathTreeNode method getUrl.

@Override
public URL getUrl() {
    final Path path = getPath();
    final BaseTreeNode parent = getParent();
    return getUrl(parent, path);
}
Also used : Path(java.nio.file.Path) BaseTreeNode(com.revolsys.swing.tree.BaseTreeNode)

Example 22 with BaseTreeNode

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

the class PathTreeNode method addPathNode.

public static void addPathNode(final List<BaseTreeNode> children, final Path path, final boolean showHidden) {
    if (showHidden || !Paths.isHidden(path) && Files.exists(path)) {
        final BaseTreeNode child = newTreeNode(path);
        children.add(child);
    }
}
Also used : BaseTreeNode(com.revolsys.swing.tree.BaseTreeNode)

Example 23 with BaseTreeNode

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

the class PathTreeNode method newFileSystemsTreeNode.

public static BaseTreeNode newFileSystemsTreeNode() {
    final BaseTreeNode fileSystems = new FunctionChildrenTreeNode(FileSystems.getDefault(), "File Systems", getIconFolder("drive"), (fileSystem) -> {
        final Iterable<Path> roots = ((FileSystem) fileSystem).getRootDirectories();
        return getPathNodes(roots, true);
    });
    fileSystems.setOpen(true);
    return fileSystems;
}
Also used : Path(java.nio.file.Path) FileSystem(java.nio.file.FileSystem) BaseTreeNode(com.revolsys.swing.tree.BaseTreeNode) FunctionChildrenTreeNode(com.revolsys.swing.tree.node.FunctionChildrenTreeNode)

Example 24 with BaseTreeNode

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

the class LayerGroupTreeNode method propertyChangeDo.

@Override
public void propertyChangeDo(final PropertyChangeEvent e) {
    super.propertyChangeDo(e);
    final Object source = e.getSource();
    final LayerGroup layerGroup = getGroup();
    if (source == layerGroup) {
        final String propertyName = e.getPropertyName();
        if ("layers".equals(propertyName)) {
            if (e instanceof IndexedPropertyChangeEvent) {
                final IndexedPropertyChangeEvent indexedEvent = (IndexedPropertyChangeEvent) e;
                final int index = indexedEvent.getIndex();
                final Layer oldLayer = (Layer) e.getOldValue();
                final Layer newLayer = (Layer) e.getNewValue();
                final List<BaseTreeNode> children = new ArrayList<>(getChildren());
                if (newLayer == null) {
                    if (oldLayer != null) {
                        children.remove(index);
                    }
                } else if (oldLayer == null) {
                    final BaseTreeNode newTreeNode = newTreeNode(newLayer);
                    children.add(index, newTreeNode);
                }
                setChildren(children);
            }
        } else if ("visible".equals(propertyName)) {
            if (isChildrenInitialized()) {
                for (final BaseTreeNode childNode : getChildren()) {
                    if (childNode instanceof LayerTreeNode) {
                        final LayerTreeNode childLayerNode = (LayerTreeNode) childNode;
                        childLayerNode.refreshIcon();
                    }
                }
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) BaseTreeNode(com.revolsys.swing.tree.BaseTreeNode) IndexedPropertyChangeEvent(java.beans.IndexedPropertyChangeEvent) LayerGroup(com.revolsys.swing.map.layer.LayerGroup) Layer(com.revolsys.swing.map.layer.Layer) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer)

Example 25 with BaseTreeNode

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

the class LayerGroupTreeNode method newTreeNode.

protected BaseTreeNode newTreeNode(final Layer layer) {
    BaseTreeNode childNode;
    if (layer instanceof LayerGroup) {
        final LayerGroup childGroup = (LayerGroup) layer;
        childNode = new LayerGroupTreeNode(childGroup);
    } else {
        childNode = new LayerTreeNode(layer);
    }
    return childNode;
}
Also used : BaseTreeNode(com.revolsys.swing.tree.BaseTreeNode) LayerGroup(com.revolsys.swing.map.layer.LayerGroup)

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