use of com.revolsys.swing.field.FileField in project com.revolsys.open by revolsys.
the class FolderConnectionsTrees method addConnection.
private static void addConnection(final FolderConnectionRegistry registry) {
final ValueField panel = new ValueField();
panel.setTitle("Add Folder Connection");
Borders.titled(panel, "Folder Connection");
SwingUtil.addLabel(panel, "Name");
final TextField nameField = new TextField(20);
panel.add(nameField);
SwingUtil.addLabel(panel, "Folder");
final FileField folderField = new FileField(JFileChooser.DIRECTORIES_ONLY);
panel.add(folderField);
GroupLayouts.makeColumns(panel, 2, true);
panel.showDialog();
if (panel.isSaved()) {
final Path file = folderField.getPath();
if (file != null && Paths.exists(file)) {
final String connectionName = nameField.getText();
registry.addConnection(connectionName, file);
}
}
}
use of com.revolsys.swing.field.FileField in project com.revolsys.open by revolsys.
the class RecordStoreConnectionForm method postSetFieldValues.
@Override
protected void postSetFieldValues(final Map<String, Object> newValues) {
String recordStoreType = (String) newValues.get("recordStoreType");
if (Property.hasValue(recordStoreType)) {
if (this.recordStoreTypes.contains(recordStoreType)) {
refreshUrlFromFieldValues(recordStoreType);
}
return;
}
final String url = (String) newValues.get("url");
if (Property.hasValue(url)) {
for (final RecordStoreFactory recordStoreFactory : this.recordStoreFactoryByName.values()) {
final Map<String, Object> urlFieldValues = recordStoreFactory.parseUrl(url);
if (!urlFieldValues.isEmpty()) {
Maps.retainIfNotEqual(urlFieldValues, newValues);
if (recordStoreFactory instanceof FileRecordStoreFactory) {
final FileRecordStoreFactory fileRecordStoreFactory = (FileRecordStoreFactory) recordStoreFactory;
final FileField fileField = getField("file");
if (fileRecordStoreFactory.isDirectory()) {
fileField.setFileSelectionMode(JFileChooser.FILES_ONLY);
} else {
fileField.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
}
}
setFieldValues(urlFieldValues);
return;
}
}
}
recordStoreType = getFieldValue("recordStoreType");
refreshUrlFromFieldValues(recordStoreType);
}
Aggregations