Search in sources :

Example 1 with AbstractLayer

use of com.revolsys.swing.map.layer.AbstractLayer in project com.revolsys.open by revolsys.

the class RecordStoreConnectionTrees method addLayer.

private static void addLayer(final RecordDefinitionImpl recordDefinition) {
    final PathName typePath = recordDefinition.getPathName();
    final RecordStore recordStore = recordDefinition.getRecordStore();
    final Map<String, Object> connection = recordStore.getConnectionProperties();
    final Map<String, Object> layerConfig = new LinkedHashMap<>();
    MapObjectFactory.setType(layerConfig, "recordStoreLayer");
    layerConfig.put("name", recordDefinition.getName());
    layerConfig.put("connection", connection);
    layerConfig.put("typePath", typePath);
    layerConfig.put("showTableView", AbstractLayer.isShowNewLayerTableView());
    final LinkedList<String> path = new LinkedList<>();
    {
        BaseTreeNode node = BaseTree.getMenuNode();
        node = node.getParent();
        while (node != null) {
            final Object nodeValue = node.getUserObject();
            String nodeName = node.getName();
            if (node instanceof PathTreeNode) {
                nodeName = FileUtil.getBaseName(nodeName);
            }
            if (nodeValue instanceof RecordStoreSchemaElement) {
                path.addFirst(nodeName);
                node = node.getParent();
            } else {
                path.addFirst(nodeName);
                node = null;
            }
        }
    }
    final AbstractLayer layer = new RecordStoreLayer(layerConfig);
    LayerGroup layerGroup = Project.get();
    for (final String name : path) {
        try {
            layerGroup = layerGroup.addLayerGroup(name);
        } catch (final IllegalArgumentException e) {
            int i = 1;
            while (layerGroup.hasLayerWithSameName(null, name + i)) {
                i++;
            }
            layerGroup = layerGroup.addLayerGroup(name + i);
        }
    }
    layerGroup.addLayer(layer);
}
Also used : RecordStoreLayer(com.revolsys.swing.map.layer.record.RecordStoreLayer) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer) LayerGroup(com.revolsys.swing.map.layer.LayerGroup) LinkedList(java.util.LinkedList) LinkedHashMap(java.util.LinkedHashMap) PathTreeNode(com.revolsys.swing.tree.node.file.PathTreeNode) RecordStore(com.revolsys.record.schema.RecordStore) BaseTreeNode(com.revolsys.swing.tree.BaseTreeNode) PathName(com.revolsys.io.PathName) RecordStoreSchemaElement(com.revolsys.record.schema.RecordStoreSchemaElement)

Example 2 with AbstractLayer

use of com.revolsys.swing.map.layer.AbstractLayer in project com.revolsys.open by revolsys.

the class LayerTreeNode method addChild.

@Override
public int addChild(final int index, final Object child) {
    if (child instanceof LayerRenderer<?>) {
        final LayerRenderer<?> childRenderer = (LayerRenderer<?>) child;
        final AbstractLayer layer = getLayer();
        return layer.addRenderer(childRenderer, index);
    } else {
        return -1;
    }
}
Also used : AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer) LayerRenderer(com.revolsys.swing.map.layer.LayerRenderer)

Example 3 with AbstractLayer

use of com.revolsys.swing.map.layer.AbstractLayer in project com.revolsys.open by revolsys.

the class LayerTreeNode method addChild.

@Override
public int addChild(final Object child) {
    if (child instanceof LayerRenderer<?>) {
        final LayerRenderer<?> childRenderer = (LayerRenderer<?>) child;
        final AbstractLayer layer = getLayer();
        return layer.addRenderer(childRenderer);
    } else {
        return -1;
    }
}
Also used : AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer) LayerRenderer(com.revolsys.swing.map.layer.LayerRenderer)

Aggregations

AbstractLayer (com.revolsys.swing.map.layer.AbstractLayer)3 LayerRenderer (com.revolsys.swing.map.layer.LayerRenderer)2 PathName (com.revolsys.io.PathName)1 RecordStore (com.revolsys.record.schema.RecordStore)1 RecordStoreSchemaElement (com.revolsys.record.schema.RecordStoreSchemaElement)1 LayerGroup (com.revolsys.swing.map.layer.LayerGroup)1 RecordStoreLayer (com.revolsys.swing.map.layer.record.RecordStoreLayer)1 BaseTreeNode (com.revolsys.swing.tree.BaseTreeNode)1 PathTreeNode (com.revolsys.swing.tree.node.file.PathTreeNode)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1