use of com.revolsys.swing.map.layer.record.RecordStoreLayer in project com.revolsys.open by revolsys.
the class RecordStoreLayerTest method beforeTest.
@Before
public void beforeTest() {
FileUtil.deleteDirectory(testDirectory, false);
final File testFile = new File(testDirectory, "test.gdb");
this.recordStore = FileGdbRecordStoreFactory.newRecordStore(testFile);
this.recordStore.initialize();
this.recordDefinition = //
new RecordDefinitionBuilder(TEST).addField("NAME", DataTypes.STRING, //
50).addField("COUNT", //
DataTypes.INT).addField("GEOMETRY", //
DataTypes.POINT).setGeometryFactory(//
GEOMETRY_FACTORY).getRecordDefinition();
this.recordStore.getRecordDefinition(this.recordDefinition);
this.layer = new RecordStoreLayer(this.recordStore, TEST, true);
this.layer.initialize();
this.layer.setEditable(true);
}
use of com.revolsys.swing.map.layer.record.RecordStoreLayer 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);
}
Aggregations