Search in sources :

Example 11 with TextField

use of com.revolsys.swing.field.TextField in project com.revolsys.open by revolsys.

the class RecordTableCellEditor method getTableCellEditorComponent.

@Override
public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, int rowIndex, int columnIndex) {
    rowIndex = table.convertRowIndexToModel(rowIndex);
    columnIndex = table.convertColumnIndexToModel(columnIndex);
    this.oldValue = value;
    final AbstractRecordTableModel model = getTableModel();
    this.fieldName = model.getColumnFieldName(rowIndex, columnIndex);
    final RecordDefinition recordDefinition = model.getRecordDefinition();
    this.dataType = recordDefinition.getFieldType(this.fieldName);
    final Field field = newField(this.fieldName);
    this.editorComponent = (JComponent) field;
    if (this.editorComponent instanceof JTextField) {
        final JTextField textField = (JTextField) this.editorComponent;
        textField.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(WebColors.LightSteelBlue), BorderFactory.createEmptyBorder(1, 2, 1, 2)));
    } else if (this.editorComponent instanceof AbstractRecordQueryField) {
        final AbstractRecordQueryField queryField = (AbstractRecordQueryField) this.editorComponent;
        queryField.setSearchFieldBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(WebColors.LightSteelBlue), BorderFactory.createEmptyBorder(1, 2, 1, 2)));
    }
    this.editorComponent.setOpaque(false);
    SwingUtil.setFieldValue(this.editorComponent, value);
    this.rowIndex = rowIndex;
    this.columnIndex = columnIndex;
    this.editorComponent.addKeyListener(this);
    this.editorComponent.addMouseListener(this.mouseListeners);
    if (this.editorComponent instanceof JComboBox) {
        final JComboBox<?> comboBox = (JComboBox<?>) this.editorComponent;
        final ComboBoxEditor editor = comboBox.getEditor();
        final Component comboEditorComponent = editor.getEditorComponent();
        comboEditorComponent.addKeyListener(this);
        comboEditorComponent.addMouseListener(this.mouseListeners);
    } else if (this.editorComponent instanceof AbstractRecordQueryField) {
        final AbstractRecordQueryField queryField = (AbstractRecordQueryField) this.editorComponent;
        final TextField searchField = queryField.getSearchField();
        searchField.addKeyListener(this);
        searchField.addMouseListener(this.mouseListeners);
    }
    this.popupMenuListener = ShowMenuMouseListener.addListener(this.editorComponent, this.popupMenuFactory);
    return this.editorComponent;
}
Also used : JTextField(javax.swing.JTextField) Field(com.revolsys.swing.field.Field) TextField(com.revolsys.swing.field.TextField) AbstractRecordQueryField(com.revolsys.swing.field.AbstractRecordQueryField) AbstractRecordTableModel(com.revolsys.swing.table.record.model.AbstractRecordTableModel) JComboBox(javax.swing.JComboBox) JTextField(javax.swing.JTextField) TextField(com.revolsys.swing.field.TextField) AbstractRecordQueryField(com.revolsys.swing.field.AbstractRecordQueryField) JTextField(javax.swing.JTextField) JComponent(javax.swing.JComponent) Component(java.awt.Component) ComboBoxEditor(javax.swing.ComboBoxEditor) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 12 with TextField

use of com.revolsys.swing.field.TextField in project com.revolsys.open by revolsys.

the class SwingUtil method addReadOnlyTextField.

static void addReadOnlyTextField(final JPanel container, final String fieldName, final Object value, final int length) {
    final TextField field = new TextField(fieldName, value, length);
    field.setEditable(false);
    container.add(field);
}
Also used : NumberTextField(com.revolsys.swing.field.NumberTextField) JTextField(javax.swing.JTextField) TextField(com.revolsys.swing.field.TextField)

Example 13 with TextField

use of com.revolsys.swing.field.TextField in project com.revolsys.open by revolsys.

the class PathTreeNode method actionAddFolderConnection.

private void actionAddFolderConnection() {
    if (isDirectory()) {
        final Path path = getPath();
        final String fileName = getName();
        final ValueField panel = new ValueField();
        panel.setTitle("Add Folder Connection");
        Borders.titled(panel, "Folder Connection");
        SwingUtil.addLabel(panel, "Folder");
        final JLabel fileLabel = new JLabel(path.toString());
        panel.add(fileLabel);
        SwingUtil.addLabel(panel, "Name");
        final TextField nameField = new TextField(20);
        panel.add(nameField);
        nameField.setText(fileName);
        SwingUtil.addLabel(panel, "Folder Connections");
        final List<FolderConnectionRegistry> registries = new ArrayList<>();
        for (final FolderConnectionRegistry registry : FileConnectionManager.get().getVisibleConnectionRegistries()) {
            if (!registry.isReadOnly()) {
                registries.add(registry);
            }
        }
        final ComboBox<FolderConnectionRegistry> registryField = ComboBox.newComboBox("registry", new Vector<>(registries));
        panel.add(registryField);
        GroupLayouts.makeColumns(panel, 2, true);
        panel.showDialog();
        if (panel.isSaved()) {
            final FolderConnectionRegistry registry = registryField.getSelectedItem();
            String connectionName = nameField.getText();
            if (!Property.hasValue(connectionName)) {
                connectionName = fileName;
            }
            registry.addConnection(connectionName, path);
        }
    }
}
Also used : Path(java.nio.file.Path) FolderConnectionRegistry(com.revolsys.io.file.FolderConnectionRegistry) ArrayList(java.util.ArrayList) JLabel(javax.swing.JLabel) TextField(com.revolsys.swing.field.TextField) ValueField(com.revolsys.swing.component.ValueField)

Example 14 with TextField

use of com.revolsys.swing.field.TextField 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);
    }
}
Also used : Path(java.nio.file.Path) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) JLabel(javax.swing.JLabel) RecordStoreConnectionRegistry(com.revolsys.record.io.RecordStoreConnectionRegistry) TextField(com.revolsys.swing.field.TextField) ValueField(com.revolsys.swing.component.ValueField)

Example 15 with TextField

use of com.revolsys.swing.field.TextField in project com.revolsys.open by revolsys.

the class WebServiceConnectionTrees method addWebServiceConnection.

@SuppressWarnings("deprecation")
private static void addWebServiceConnection(final WebServiceConnectionRegistry registry, final String type) {
    final ValueField panel = new ValueField();
    panel.setTitle("Add Web Service Connection");
    Borders.titled(panel, "Web Service Connection");
    SwingUtil.addLabel(panel, "Name");
    final TextField nameField = new TextField(20);
    panel.add(nameField);
    SwingUtil.addLabel(panel, "Service URL");
    final TextField urlField = new TextField(50);
    panel.add(urlField);
    SwingUtil.addLabel(panel, "Username");
    final TextField usernameField = new TextField(30);
    panel.add(usernameField);
    SwingUtil.addLabel(panel, "Password");
    final PasswordField passwordField = new PasswordField(30);
    panel.add(passwordField);
    GroupLayouts.makeColumns(panel, 2, true);
    panel.showDialog();
    if (panel.isSaved()) {
        final String url = urlField.getText();
        if (url != null) {
            final String name = nameField.getText();
            final String username = usernameField.getText();
            final String password = passwordField.getText();
            final MapEx config = new LinkedHashMapEx();
            config.put("j:type", type);
            config.put("name", name);
            config.put("serviceUrl", url);
            config.put("username", username);
            config.put("password", PasswordUtil.encrypt(password));
            registry.newConnection(config);
        }
    }
}
Also used : MapEx(com.revolsys.collection.map.MapEx) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) TextField(com.revolsys.swing.field.TextField) PasswordField(com.revolsys.swing.field.PasswordField) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) ValueField(com.revolsys.swing.component.ValueField)

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