Search in sources :

Example 1 with PasswordField

use of com.revolsys.swing.field.PasswordField 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 2 with PasswordField

use of com.revolsys.swing.field.PasswordField 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

LinkedHashMapEx (com.revolsys.collection.map.LinkedHashMapEx)2 MapEx (com.revolsys.collection.map.MapEx)2 ValueField (com.revolsys.swing.component.ValueField)2 PasswordField (com.revolsys.swing.field.PasswordField)2 TextField (com.revolsys.swing.field.TextField)2 WebServiceConnectionRegistry (com.revolsys.webservice.WebServiceConnectionRegistry)1