Search in sources :

Example 1 with SetServerPasswordCommand

use of org.apache.sling.ide.eclipse.core.SetServerPasswordCommand in project sling by apache.

the class ConnectionEditorSection method initialize.

private void initialize() {
    final ISlingLaunchpadConfiguration config = launchpadServer.getConfiguration();
    portText.setText(String.valueOf(config.getPort()));
    debugPortText.setText(String.valueOf(config.getDebugPort()));
    contextPathText.setText(config.getContextPath());
    usernameText.setText(config.getUsername());
    passwordText.setText(config.getPassword());
    ModifyListener listener = new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            if (updating) {
                return;
            }
            updating = true;
            try {
                if (e.getSource() == portText) {
                    try {
                        int port = Integer.parseInt(portText.getText());
                        execute(new SetServerPortCommand(server, port));
                    } catch (NumberFormatException ex) {
                    // shucks
                    }
                } else if (e.getSource() == debugPortText) {
                    try {
                        int debugPort = Integer.parseInt(debugPortText.getText());
                        execute(new SetServerDebugPortCommand(server, debugPort));
                    } catch (NumberFormatException ex) {
                        // shucks
                        ex.printStackTrace();
                    }
                } else if (e.getSource() == contextPathText) {
                    execute(new SetServerContextPathCommand(server, contextPathText.getText()));
                } else if (e.getSource() == usernameText) {
                    execute(new SetServerUsernameCommand(server, usernameText.getText()));
                } else if (e.getSource() == passwordText) {
                    execute(new SetServerPasswordCommand(server, passwordText.getText()));
                }
            } finally {
                updating = false;
            }
        }
    };
    for (Text text : new Text[] { portText, debugPortText, contextPathText, usernameText, passwordText }) {
        text.addModifyListener(listener);
    }
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) SetServerPasswordCommand(org.apache.sling.ide.eclipse.core.SetServerPasswordCommand) ISlingLaunchpadConfiguration(org.apache.sling.ide.eclipse.core.ISlingLaunchpadConfiguration) SetServerDebugPortCommand(org.apache.sling.ide.eclipse.core.SetServerDebugPortCommand) Text(org.eclipse.swt.widgets.Text) SetServerPortCommand(org.apache.sling.ide.eclipse.core.SetServerPortCommand) SetServerUsernameCommand(org.apache.sling.ide.eclipse.core.SetServerUsernameCommand) SetServerContextPathCommand(org.apache.sling.ide.eclipse.core.SetServerContextPathCommand)

Aggregations

ISlingLaunchpadConfiguration (org.apache.sling.ide.eclipse.core.ISlingLaunchpadConfiguration)1 SetServerContextPathCommand (org.apache.sling.ide.eclipse.core.SetServerContextPathCommand)1 SetServerDebugPortCommand (org.apache.sling.ide.eclipse.core.SetServerDebugPortCommand)1 SetServerPasswordCommand (org.apache.sling.ide.eclipse.core.SetServerPasswordCommand)1 SetServerPortCommand (org.apache.sling.ide.eclipse.core.SetServerPortCommand)1 SetServerUsernameCommand (org.apache.sling.ide.eclipse.core.SetServerUsernameCommand)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 Text (org.eclipse.swt.widgets.Text)1