private void initializeFields()

in application/org.openjdk.jmc.browser/src/main/java/org/openjdk/jmc/browser/wizards/ConnectionWizardPage.java [483:558]


	private void initializeFields() {
		String host = LOCALHOST;
		int port = ConnectionToolkit.getDefaultPort();
		String name = LOCALHOST;
		if (server != null) {
			currentUrl = server.getConnectionUrl();
			name = server.getServerHandle().getServerDescriptor().getDisplayName();
			ICredentials credential = server.getCredentials();
			if (credential != null) {
				try {
					String username = credential.getUsername();
					if (username != null) {
						usernameField.setText(username);
					}
					String password = credential.getPassword();
					if (password != null) {
						passwordField.setText(password);
					}
					if (storePasswordButton != null) {
						storePasswordButton.setSelection(credential.getExportedId() != null);
					}
				} catch (CredentialsNotAvailableException e) {
					// Open dialog and let credentials be overwritten
				} catch (SecurityException e) {
					throw new RuntimeException(e);
				}
			}
		}

		if (currentUrl != null) {
			host = ConnectionToolkit.getHostName(currentUrl);
			port = ConnectionToolkit.getPort(currentUrl);
			try {
				// Used to see what the URL path should look like by default
				String defaultUrlPath = ConnectionToolkit.createServiceURL(host, port).getURLPath();
				if (!(currentUrl.getProtocol().equals(PROTOCOL_RMI)
						&& currentUrl.getURLPath().equals(defaultUrlPath))) {
					// The protocol or URL path does not match defaults,
					// must be custom URL
					customUrlButton.setSelection(true);
				}
			} catch (IOException e) {
				customUrlButton.setSelection(true);
				JVMBrowserPlugin.getDefault().getLogger().log(Level.FINE, e.getMessage(), e);
			}
		}

		connectionNameField.setText(name);
		if (isDiscovered()) {
			String commandLine = ServerToolkit.getJavaCommand(server);
			String jvmArgs = ServerToolkit.getJVMArguments(server);
			javaCommandField.setText(commandLine == null ? "" : commandLine); //$NON-NLS-1$
			jvmArgsField.setText(jvmArgs == null ? "" : jvmArgs); //$NON-NLS-1$
			Integer pid = ServerToolkit.getPid(server.getServerHandle());
			pidField.setText(pid != null ? "" + pid : Messages.ConnectionWizardPage_TEXT_UNKNOWN); //$NON-NLS-1$
			if (hasServiceUrl()) {
				showServiceUrlField();
			}
		} else {
			hostNameField.setText(host);
			portField.setText("" + port); //$NON-NLS-1$
			setInputFieldsShowing(customUrlButton.getSelection());
			hasEditedConnectionName = !name.equals(generateConnectionName());
		}
		if (!isEditable()) {
			connectionNameField.setEditable(false);
			if (!isDiscovered()) {
				hostNameField.setEditable(false);
				portField.setEditable(false);
				passwordField.setEditable(false);
				usernameField.setEditable(false);
				serviceUrlField.setEditable(false);
				storePasswordButton.setEnabled(false);
			}
		}
	}