use of com.revolsys.record.io.RecordStoreConnectionRegistry in project com.revolsys.open by revolsys.
the class ProjectFrame method setConnectionRegistries.
private void setConnectionRegistries() {
final String connectionRegistryName = this.project.getConnectionRegistryName();
final RecordStoreConnectionManager recordStoreConnectionManager = RecordStoreConnectionManager.get();
recordStoreConnectionManager.removeConnectionRegistry(connectionRegistryName);
final RecordStoreConnectionRegistry recordStores = this.project.getRecordStores();
recordStoreConnectionManager.addConnectionRegistry(recordStores);
final FileConnectionManager fileConnectionManager = FileConnectionManager.get();
fileConnectionManager.removeConnectionRegistry(connectionRegistryName);
final FolderConnectionRegistry folderConnections = this.project.getFolderConnections();
fileConnectionManager.addConnectionRegistry(folderConnections);
final WebServiceConnectionManager webServiceConnectionManager = WebServiceConnectionManager.get();
webServiceConnectionManager.removeConnectionRegistry(connectionRegistryName);
final WebServiceConnectionRegistry webServices = this.project.getWebServices();
webServiceConnectionManager.addConnectionRegistry(webServices);
}
use of com.revolsys.record.io.RecordStoreConnectionRegistry in project com.revolsys.open by revolsys.
the class Project method readProject.
public void readProject(final Project rootProject, final Resource resource) {
this.resource = resource;
if (this.resource.exists()) {
String name;
try (final BaseCloseable booleanValueCloseable = eventsDisabled()) {
final RecordStoreConnectionRegistry oldRecordStoreConnections = RecordStoreConnectionRegistry.getForThread();
try {
final boolean readOnly = isReadOnly();
final Resource folderConnectionsDirectory = this.resource.newChildResource("Folder Connections");
this.folderConnections.clear(folderConnectionsDirectory, readOnly);
final Resource recordStoresDirectory = this.resource.newChildResource("Record Stores");
this.recordStores.clear(recordStoresDirectory, readOnly);
final Resource webServicesDirectory = this.resource.newChildResource("Web Services");
this.webServices.clear(webServicesDirectory, readOnly);
if (rootProject == null) {
RecordStoreConnectionRegistry.setForThread(this.recordStores);
} else {
final WebServiceConnectionRegistry rootWebServices = rootProject.getWebServices();
importConnections("Web Service", this, this.webServices, rootWebServices);
final RecordStoreConnectionRegistry rootRecordStores = rootProject.getRecordStores();
rootProject.importConnections("Record Store", this, this.recordStores, rootRecordStores);
final FolderConnectionRegistry rootFolderConnections = rootProject.getFolderConnections();
rootProject.importConnections("Folder Connection", this, this.folderConnections, rootFolderConnections);
}
final Resource layersDir = this.resource.newChildResource("Layers");
final boolean hasLayers = layersDir.exists();
if (hasLayers) {
readProperties(layersDir);
}
if (hasLayers) {
readLayers(rootProject, layersDir);
}
readBaseMapsLayers(rootProject, this.resource);
} finally {
RecordStoreConnectionRegistry.setForThread(oldRecordStoreConnections);
}
name = getName();
setName(null);
}
setName(name);
}
}
use of com.revolsys.record.io.RecordStoreConnectionRegistry in project com.revolsys.open by revolsys.
the class RecordStoreConnectionForm method addHandlers.
public static void addHandlers() {
RecordStoreConnectionManager.setInvalidRecordStoreFunction((connection, exception) -> {
return Invoke.andWait(() -> {
final RecordStoreConnectionRegistry registry = connection.getRegistry();
final RecordStoreConnectionForm form = new RecordStoreConnectionForm(registry, connection, exception);
return form.showDialog();
});
});
RecordStoreConnectionManager.setMissingRecordStoreFunction((name) -> {
final RecordStoreConnectionRegistry registry = RecordStoreConnectionManager.get().getUserConnectionRegistry();
Invoke.andWait(() -> {
final RecordStoreConnectionForm form = new RecordStoreConnectionForm(registry, name);
form.showDialog();
});
final RecordStoreConnection connection = registry.getConnection(name);
if (connection == null) {
return null;
} else {
return connection.getRecordStore();
}
});
}
use of com.revolsys.record.io.RecordStoreConnectionRegistry in project com.revolsys.open by revolsys.
the class PathRecordStoreTreeNode method addRecordStoreConnection.
public void addRecordStoreConnection() {
final Path path = getPath();
final String fileName = Paths.getBaseName(path);
final ValueField panel = new ValueField();
panel.setTitle("Add Record Store Connection");
Borders.titled(panel, "Record Store Connection");
SwingUtil.addLabel(panel, "File");
final JLabel fileLabel = new JLabel(Paths.toPathString(path));
panel.add(fileLabel);
SwingUtil.addLabel(panel, "Name");
final TextField nameField = new TextField(20);
panel.add(nameField);
nameField.setText(fileName);
SwingUtil.addLabel(panel, "Record Store Connections");
final List<RecordStoreConnectionRegistry> registries = new ArrayList<>();
for (final RecordStoreConnectionRegistry registry : RecordStoreConnectionManager.get().getVisibleConnectionRegistries()) {
if (!registry.isReadOnly()) {
registries.add(registry);
}
}
final ComboBox<RecordStoreConnectionRegistry> registryField = ComboBox.newComboBox("registry", registries);
panel.add(registryField);
GroupLayouts.makeColumns(panel, 2, true);
panel.showDialog();
if (panel.isSaved()) {
final RecordStoreConnectionRegistry registry = registryField.getSelectedItem();
String connectionName = nameField.getText();
if (!Property.hasValue(connectionName)) {
connectionName = fileName;
}
final String baseConnectionName = connectionName;
int i = 0;
while (registry.getConnection(connectionName) != null) {
connectionName = baseConnectionName + i;
i++;
}
final Map<String, Object> connection = getRecordStoreConnectionMap();
final Map<String, Object> config = new HashMap<>();
config.put("name", connectionName);
config.put("connection", connection);
registry.newConnection(config);
}
}
use of com.revolsys.record.io.RecordStoreConnectionRegistry in project com.revolsys.open by revolsys.
the class RecordStoreConnectionTrees method editConnection.
private static void editConnection(final RecordStoreConnection connection) {
final RecordStoreConnectionRegistry registry = connection.getRegistry();
final RecordStoreConnectionForm form = new RecordStoreConnectionForm(registry, connection);
form.showDialog();
}
Aggregations