List of usage examples for com.google.gwt.dom.client ParagraphElement setInnerText
@Override
public void setInnerText(String text)
From source file:com.palantir.gerrit.gerritci.ui.client.ConfigurationScreen.java
License:Apache License
ConfigurationScreen() {
setStyleName("gerrit-ci");
jenkinsURL = new TextBox();
jenkinsUser = new TextBox();
jenkinsPassword = new TextBox();
gerritUser = new TextBox();
credentialsId = new TextBox();
// initialize with defaults
jenkinsURL.setText("http://localhost:8000");
jenkinsUser.setText(null);/*from w ww .jav a 2s. c om*/
jenkinsPassword.setText(null);
gerritUser.setText("jenkins");
credentialsId.setText("612940dd-cadf-43f0-98dc-e2f02f5e68ec");
// These settings will be the same for all Jenkins servers
HeadingElement gerritSettings = Document.get().createHElement(2);
gerritSettings.setInnerText("Gerrit Settings for Jenkins");
ParagraphElement gerritSettingsDescription = Document.get().createPElement();
gerritSettingsDescription.setClassName("description");
gerritSettingsDescription.setInnerText("The configurations below are similar for all Jenkins instances. "
+ "They describe how Jenkins will connect to Gerrit. For example: 'Gerrit User' "
+ "is Jenkins's username in Gerrit.");
ParagraphElement gerritUserLabel = Document.get().createPElement();
gerritUserLabel.setInnerText("Gerrit User");
gerritUser.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
event.stopPropagation();
}
});
// These settings will be specific for a Jenkins server instance
// when multiple Jenkins servers are supported by gerrit-ci
HeadingElement serverSettings = Document.get().createHElement(2);
serverSettings.setInnerText("Jenkins Settings for Gerrit");
ParagraphElement serverSettingsDescription = Document.get().createPElement();
serverSettingsDescription.setClassName("description");
serverSettingsDescription.setInnerText("The configurations below are specific to each instance of Jenkins."
+ "They describe how Gerrit will connect to a specific instance of Jenkins.");
// create labels
ParagraphElement jenkinsURLLabel = Document.get().createPElement();
jenkinsURLLabel.setInnerText("Jenkins Url");
jenkinsURL.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
event.stopPropagation();
}
});
ParagraphElement jenkinsUserLabel = Document.get().createPElement();
jenkinsUserLabel.setInnerText("Jenkins User");
jenkinsUser.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
event.stopPropagation();
}
});
ParagraphElement jenkinsPasswordLabel = Document.get().createPElement();
jenkinsPasswordLabel.setInnerText("Jenkins Password");
add(HTML.wrap(jenkinsURLLabel));
jenkinsPassword.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
event.stopPropagation();
}
});
ParagraphElement crendentialsIdLabel = Document.get().createPElement();
crendentialsIdLabel.setInnerText("Credentials Id");
credentialsId.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
event.stopPropagation();
}
});
// add to widgets screen
add(HTML.wrap(gerritSettings));
add(HTML.wrap(gerritSettingsDescription));
add(HTML.wrap(gerritUserLabel));
add(gerritUser);
add(HTML.wrap(serverSettings));
add(HTML.wrap(serverSettingsDescription));
add(HTML.wrap(jenkinsURLLabel));
add(jenkinsURL);
add(HTML.wrap(jenkinsUserLabel));
add(jenkinsUser);
add(HTML.wrap(jenkinsPasswordLabel));
add(jenkinsPassword);
add(HTML.wrap(crendentialsIdLabel));
add(credentialsId);
// retrieve values from gerrit-ci.config stored in the plugins config
// file on gerrit
new RestApi("plugins").id("gerrit-ci").view("settings").get(new AsyncCallback<JavaScriptObject>() {
@Override
public void onSuccess(JavaScriptObject jenkinsConfig) {
JenkinsConfig config = (JenkinsConfig) jenkinsConfig;
String jenkinsURLString = config.getJenkinsURL();
String jenkinsUserString = config.getJenkinsUser();
String jenkinsPasswordString = config.getJenkinsPassword();
String gerritUserString = config.getGerritUser();
String credentialIdString = config.getCredentialsId();
if (jenkinsURLString != null) {
jenkinsURL.setText(jenkinsURLString);
}
if (jenkinsUserString != null) {
jenkinsUser.setText(jenkinsUserString);
}
if (jenkinsPasswordString != null) {
jenkinsPassword.setText(jenkinsPasswordString);
}
if (gerritUserString != null) {
gerritUser.setText(gerritUserString);
}
if (credentialIdString != null) {
credentialsId.setText(credentialIdString);
}
}
@Override
public void onFailure(Throwable caught) {
// never invoked
}
});
Button save = new Button("Save");
save.setEnabled(true);
save.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
save();
}
});
add(save);
}