use of com.revolsys.swing.field.TextField in project com.revolsys.open by revolsys.
the class WebMercatorTileCache method actionAddLayer.
static void actionAddLayer(final BaseMapLayerGroup parent) {
final ValueField dialog = new ValueField();
dialog.setTitle("Add Web Mercator Tile Cache Layer");
SwingUtil.addLabel(dialog, "URL");
final TextField urlField = new TextField("url", 50);
dialog.add(urlField);
GroupLayouts.makeColumns(dialog, 2, true, true);
dialog.setSaveAction(() -> {
final String url = urlField.getText();
if (Property.hasValue(url)) {
final WebMercatorTileCacheLayer layer = new WebMercatorTileCacheLayer();
layer.setUrl(url);
layer.setVisible(true);
parent.addLayer(layer);
}
});
dialog.showDialog();
}
use of com.revolsys.swing.field.TextField in project com.revolsys.open by revolsys.
the class ArcGisRestServer method actionAddTileCacheLayer.
static void actionAddTileCacheLayer(final BaseMapLayerGroup parent) {
final ValueField dialog = new ValueField();
dialog.setTitle("Add ArcGIS Tile Cache");
SwingUtil.addLabel(dialog, "URL");
final TextField urlField = new TextField("url", 50);
dialog.add(urlField);
GroupLayouts.makeColumns(dialog, 2, true, true);
dialog.setSaveAction(() -> {
final String url = urlField.getText();
if (Property.hasValue(url)) {
final ArcGisRestServerTileCacheLayer layer = new ArcGisRestServerTileCacheLayer();
layer.setUrl(url);
layer.setVisible(true);
parent.addLayer(layer);
}
});
dialog.showDialog();
}
use of com.revolsys.swing.field.TextField in project com.revolsys.open by revolsys.
the class WebServiceConnectionTrees method editConnection.
@SuppressWarnings("deprecation")
private static void editConnection(final WebServiceConnection connection) {
final WebServiceConnectionRegistry registry = connection.getRegistry();
final ValueField panel = new ValueField();
panel.setTitle("Edit Web Service Connection");
Borders.titled(panel, "Web Service Connection");
SwingUtil.addLabel(panel, "Name");
final MapEx config = connection.getConfig();
final String oldName = connection.getName();
final TextField nameField = new TextField("name", oldName, 20);
panel.add(nameField);
SwingUtil.addLabel(panel, "Service URL");
String serviceUrl = config.getString("serviceUrl");
final TextField urlField = new TextField("serviceUrl", serviceUrl, 50);
panel.add(urlField);
SwingUtil.addLabel(panel, "Username");
String username = config.getString("username");
final TextField usernameField = new TextField("username", username, 30);
panel.add(usernameField);
SwingUtil.addLabel(panel, "Password");
String password = PasswordUtil.decrypt(config.getString("password"));
final PasswordField passwordField = new PasswordField("password", password, 30);
panel.add(passwordField);
GroupLayouts.makeColumns(panel, 2, true);
panel.showDialog();
if (panel.isSaved()) {
serviceUrl = urlField.getText();
if (serviceUrl != null) {
final String name = nameField.getText();
username = usernameField.getText();
password = passwordField.getText();
config.put("name", name);
config.put("serviceUrl", serviceUrl);
config.put("username", username);
config.put("password", PasswordUtil.encrypt(password));
if (Strings.equals(oldName, name)) {
connection.setProperties(config);
} else {
registry.removeConnection(connection);
registry.newConnection(config);
}
}
}
}
use of com.revolsys.swing.field.TextField 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.TextField in project com.revolsys.open by revolsys.
the class RecordTableCellEditor method stopCellEditing.
@Override
public boolean stopCellEditing() {
boolean stopped = false;
try {
if (this.editorComponent instanceof Field) {
final Field field = (Field) this.editorComponent;
field.updateFieldValue();
}
stopped = super.stopCellEditing();
} catch (final IndexOutOfBoundsException e) {
return true;
} catch (final Throwable t) {
final int result = JOptionPane.showConfirmDialog(this.editorComponent, "<html><p><b>'" + getCellEditorValue() + "' is not a valid " + this.dataType.getValidationName() + ".</b></p><p>Discard changes (Yes) or edit field (No).</p></html>", "Invalid value", JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE);
if (result == JOptionPane.YES_OPTION) {
cancelCellEditing();
return true;
} else {
return false;
}
} finally {
if (stopped) {
if (this.editorComponent != null) {
this.editorComponent.removeMouseListener(this.mouseListeners);
this.editorComponent.removeKeyListener(this);
if (this.editorComponent instanceof JComboBox) {
final JComboBox<?> comboBox = (JComboBox<?>) this.editorComponent;
final ComboBoxEditor editor = comboBox.getEditor();
final Component comboEditorComponent = editor.getEditorComponent();
comboEditorComponent.removeKeyListener(this);
comboEditorComponent.removeMouseListener(this.mouseListeners);
} else if (this.editorComponent instanceof AbstractRecordQueryField) {
final AbstractRecordQueryField queryField = (AbstractRecordQueryField) this.editorComponent;
final TextField searchField = queryField.getSearchField();
searchField.removeKeyListener(this);
searchField.removeMouseListener(this.mouseListeners);
}
if (this.popupMenuListener != null) {
this.popupMenuListener.close();
this.popupMenuListener = null;
}
}
}
}
return stopped;
}
Aggregations