Search in sources :

Example 6 with TextField

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();
}
Also used : TextField(com.revolsys.swing.field.TextField) ValueField(com.revolsys.swing.component.ValueField)

Example 7 with TextField

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();
}
Also used : TextField(com.revolsys.swing.field.TextField) ValueField(com.revolsys.swing.component.ValueField)

Example 8 with TextField

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);
            }
        }
    }
}
Also used : MapEx(com.revolsys.collection.map.MapEx) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) WebServiceConnectionRegistry(com.revolsys.webservice.WebServiceConnectionRegistry) TextField(com.revolsys.swing.field.TextField) PasswordField(com.revolsys.swing.field.PasswordField) ValueField(com.revolsys.swing.component.ValueField)

Example 9 with TextField

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);
        }
    }
}
Also used : Path(java.nio.file.Path) TextField(com.revolsys.swing.field.TextField) FileField(com.revolsys.swing.field.FileField) ValueField(com.revolsys.swing.component.ValueField)

Example 10 with TextField

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;
}
Also used : JTextField(javax.swing.JTextField) Field(com.revolsys.swing.field.Field) TextField(com.revolsys.swing.field.TextField) AbstractRecordQueryField(com.revolsys.swing.field.AbstractRecordQueryField) JComboBox(javax.swing.JComboBox) JTextField(javax.swing.JTextField) TextField(com.revolsys.swing.field.TextField) AbstractRecordQueryField(com.revolsys.swing.field.AbstractRecordQueryField) JComponent(javax.swing.JComponent) Component(java.awt.Component) ComboBoxEditor(javax.swing.ComboBoxEditor)

Aggregations

TextField (com.revolsys.swing.field.TextField)15 JTextField (javax.swing.JTextField)8 ValueField (com.revolsys.swing.component.ValueField)7 Field (com.revolsys.swing.field.Field)5 ColorChooserField (com.revolsys.swing.field.ColorChooserField)4 NumberTextField (com.revolsys.swing.field.NumberTextField)4 JComponent (javax.swing.JComponent)4 DateField (com.revolsys.swing.field.DateField)3 ObjectLabelField (com.revolsys.swing.field.ObjectLabelField)3 Path (java.nio.file.Path)3 ArrayList (java.util.ArrayList)3 LinkedHashMapEx (com.revolsys.collection.map.LinkedHashMapEx)2 MapEx (com.revolsys.collection.map.MapEx)2 AbstractRecordQueryField (com.revolsys.swing.field.AbstractRecordQueryField)2 CheckBox (com.revolsys.swing.field.CheckBox)2 LengthMeasureTextField (com.revolsys.swing.field.LengthMeasureTextField)2 PasswordField (com.revolsys.swing.field.PasswordField)2 Color (java.awt.Color)2 Component (java.awt.Component)2 Dimension (java.awt.Dimension)2