private void initialize()

in eclipse/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ConnectionEditorSection.java [178:229]


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

    }