use of cz.metacentrum.perun.webgui.json.securityTeamsManager.UpdateSecurityTeam in project perun by CESNET.
the class EditSecurityTeamDetailsTabItem method draw.
public Widget draw() {
titleWidget = new Label("Edit Security Team");
VerticalPanel vp = new VerticalPanel();
// textboxes which set the class data when updated
final ExtendedTextBox nameTextBox = new ExtendedTextBox();
nameTextBox.getTextBox().setText(team.getName());
nameTextBox.getTextBox().setMaxLength(128);
final ExtendedTextBox.TextBoxValidator nameValidator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (!nameTextBox.getTextBox().getText().trim().isEmpty()) {
nameTextBox.setOk();
return true;
} else {
nameTextBox.setError("Name can't be empty.");
return false;
}
}
};
nameTextBox.setValidator(nameValidator);
final ExtendedTextBox descriptionTextBox = new ExtendedTextBox();
descriptionTextBox.getTextBox().setText(team.getDescription());
// prepares layout
FlexTable layout = new FlexTable();
layout.setStyleName("inputFormFlexTable");
FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
// close tab events
final TabItem tab = this;
TabMenu menu = new TabMenu();
// send button
final CustomButton saveButton = TabMenu.getPredefinedButton(ButtonType.SAVE, "Save changes of Security team name");
saveButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (!nameValidator.validateTextBox())
return;
SecurityTeam team2 = JsonUtils.clone(team).cast();
team2.setName(nameTextBox.getTextBox().getText().trim());
team2.setDescription(descriptionTextBox.getTextBox().getText().trim());
UpdateSecurityTeam request = new UpdateSecurityTeam(JsonCallbackEvents.closeTabDisableButtonEvents(saveButton, tab, true, events));
request.updateSecurityTeam(team2);
}
});
// cancel button
final CustomButton cancelButton = TabMenu.getPredefinedButton(ButtonType.CANCEL, "");
cancelButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, isRefreshParentOnClose());
}
});
// Add some standard form options
layout.setHTML(0, 0, "Name:");
layout.setWidget(0, 1, nameTextBox);
layout.setHTML(1, 0, "Description:");
layout.setWidget(1, 1, descriptionTextBox);
for (int i = 0; i < layout.getRowCount(); i++) {
cellFormatter.addStyleName(i, 0, "itemName");
}
menu.addWidget(saveButton);
menu.addWidget(cancelButton);
vp.add(layout);
vp.add(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
Aggregations