@Override protected void loadValues() { final NodeConnection connection = (NodeConnection) params[0]; if (connection != null) { nameField.setText(connection.getName()); urlField.setText(connection.getUrl()); loginField.setText(connection.getLogin()); passwordField.setText(connection.getPassword()); } }
@Override public void ok() { if (assertNull(nameField, urlField)) { return; } final ModelerSettings settings = ModelerSettings.get(); final Vector<String> connections = new Vector<>(settings.getConnections()); final NodeConnection connection = (NodeConnection) params[0]; final String name = nameField.getText(); if (connections.contains(name)) { if (connection == null || !name.equals(connection.getName())) { SwingUtils.showError($m("ConnectionDialog.2")); return; } } super.ok(); final NavigationTree tree = Application.get().getMainPane().getNavigationTree(); final String url = urlField.getText(); final String login = loginField.getText(); final String password = passwordField.getText(); if (connection != null) { final String old = connection.getName(); final int p = connections.indexOf(old); if (p > -1) { connections.set(p, name); connection.setName(name); connection.setUrl(url); connection.setLogin(login); connection.setPassword(password); settings.setConnectionUrl(old, null); settings.setConnectionLogin(old, null); settings.setConnectionPassword(old, null); } } else { connections.add(name); } settings.setConnections(connections); settings.setConnectionUrl(name, url); settings.setConnectionLogin(name, login); settings.setConnectionPassword(name, password); settings.save(); if (null == connection) { final NodeRoot root = tree.getModel().getRoot(); root.add(new NodeConnection(name, url, login, password)); } tree.updateUI(); }