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;
}
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);
}
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);
}
}
}
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);
}
}
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);
}
}
}
Aggregations