use of cz.metacentrum.perun.webgui.widgets.ExtendedTextBox in project perun by CESNET.
the class EditVoDetailsTabItem method draw.
public Widget draw() {
titleWidget = new Label("Edit VO name");
VerticalPanel vp = new VerticalPanel();
// textboxes which set the class data when updated
final ExtendedTextBox nameTextBox = new ExtendedTextBox();
nameTextBox.getTextBox().setText(vo.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);
// 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 VO name");
saveButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (!nameValidator.validateTextBox())
return;
VirtualOrganization v = JsonUtils.clone(vo).cast();
v.setName(nameTextBox.getTextBox().getText().trim());
UpdateVo request = new UpdateVo(JsonCallbackEvents.closeTabDisableButtonEvents(saveButton, tab, events));
request.updateVo(v);
}
});
// cancel button
final CustomButton cancelButton = TabMenu.getPredefinedButton(ButtonType.CANCEL, "");
cancelButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
});
// Add some standard form options
layout.setHTML(0, 0, "Short name:");
layout.setHTML(0, 1, vo.getShortName());
layout.setHTML(1, 0, "Name:");
layout.setWidget(1, 1, nameTextBox);
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();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedTextBox in project perun by CESNET.
the class CreateCategoryTabItem method draw.
public Widget draw() {
final VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
TabMenu menu = new TabMenu();
final CustomButton addCategory = TabMenu.getPredefinedButton(ButtonType.ADD, "Add category");
menu.addWidget(addCategory);
FlexTable table = new FlexTable();
table.setStyleName("inputFormFlexTable");
// textboxes which set the class data when updated
final ExtendedTextBox nameTextBox = new ExtendedTextBox();
final ExtendedTextBox rankTextBox = new ExtendedTextBox();
final ExtendedTextBox.TextBoxValidator validator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (nameTextBox.getTextBox().getText().trim().isEmpty()) {
nameTextBox.setError("Name can't be empty.");
return false;
}
nameTextBox.setOk();
return true;
}
};
final ExtendedTextBox.TextBoxValidator validator2 = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (rankTextBox.getTextBox().getText().trim().isEmpty()) {
rankTextBox.setError("Rank value can't be empty.");
return false;
} else {
try {
Double.parseDouble(rankTextBox.getTextBox().getText().trim());
} catch (Exception e) {
rankTextBox.setError("Value must be in like: 0.5, 1.0 etc.");
return false;
}
}
rankTextBox.setOk();
return true;
}
};
nameTextBox.setValidator(validator);
rankTextBox.setValidator(validator2);
final TabItem tab = this;
addCategory.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (validator.validateTextBox() && validator2.validateTextBox()) {
CreateCategory request = new CreateCategory(JsonCallbackEvents.closeTabDisableButtonEvents(addCategory, tab));
request.createCategory(nameTextBox.getTextBox().getText().trim(), Double.parseDouble(rankTextBox.getTextBox().getText().trim()));
}
}
});
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().closeTab(tab, false);
}
}));
vp.add(table);
vp.add(menu);
vp.setCellHeight(menu, "30px");
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
table.setHTML(0, 0, "Name:");
table.setWidget(0, 1, nameTextBox);
table.setHTML(1, 0, "Rank:");
table.setWidget(1, 1, rankTextBox);
for (int i = 0; i < table.getRowCount(); i++) {
table.getFlexCellFormatter().setStyleName(i, 0, "itemName");
}
table.setHTML(2, 1, "Values like: 0.0 , 0.5 , 1.2 , etc.");
table.getFlexCellFormatter().setStyleName(2, 1, "inputFormInlineComment");
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedTextBox in project perun by CESNET.
the class AttributeDefinitionDetailTabItem method draw.
public Widget draw() {
titleWidget.setText(def.getName());
final TabItem tab = this;
// create main panel for content
final FlexTable mainPage = new FlexTable();
mainPage.setWidth("100%");
final ExtendedTextBox description = new ExtendedTextBox();
description.setWidth("100%");
description.getTextBox().setText(def.getDescription());
final ExtendedTextBox.TextBoxValidator validator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (description.getTextBox().getText().trim().isEmpty()) {
description.setError("Description can't be empty.");
return false;
}
description.setOk();
return true;
}
};
final ExtendedTextBox displayName = new ExtendedTextBox();
displayName.setWidth("100%");
displayName.getTextBox().setText(def.getDisplayName());
final ExtendedTextBox.TextBoxValidator validatorName = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (displayName.getTextBox().getText().trim().isEmpty()) {
displayName.setError("Display name can't be empty.");
return false;
}
displayName.setOk();
return true;
}
};
description.setValidator(validator);
displayName.setValidator(validatorName);
FlexTable attributeDetailTable = new FlexTable();
attributeDetailTable.setStyleName("inputFormFlexTable");
final CustomButton updateButton = TabMenu.getPredefinedButton(ButtonType.SAVE, "Save attribute details");
updateButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<AttributeRights> list = new ArrayList<AttributeRights>();
for (AttributeRights r : rights) {
if (r.getRole().equalsIgnoreCase("SELF")) {
list.add(getRightsFromWidgets(selfRead, selfWrite, r));
} else if (r.getRole().equalsIgnoreCase("VOADMIN")) {
list.add(getRightsFromWidgets(voRead, voWrite, r));
} else if (r.getRole().equalsIgnoreCase("GROUPADMIN")) {
list.add(getRightsFromWidgets(groupRead, groupWrite, r));
} else if (r.getRole().equalsIgnoreCase("FACILITYADMIN")) {
list.add(getRightsFromWidgets(facilityRead, facilityWrite, r));
}
}
if ((!def.getDescription().equals(description.getTextBox().getText().trim()) || !def.getDisplayName().equals(displayName.getTextBox().getText().trim()))) {
if (!validator.validateTextBox() || !validatorName.validateTextBox())
return;
def.setDescription(description.getTextBox().getText().trim());
def.setDisplayName(displayName.getTextBox().getText().trim());
UpdateAttribute request = new UpdateAttribute(JsonCallbackEvents.disableButtonEvents(updateButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// after update - update rights
SetAttributeRights request = new SetAttributeRights(JsonCallbackEvents.disableButtonEvents(updateButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
enableDisableWidgets(true);
}
@Override
public void onLoadingStart() {
enableDisableWidgets(false);
}
@Override
public void onError(PerunError error) {
enableDisableWidgets(true);
}
}));
request.setAttributeRights(list);
}
}));
request.updateAttribute(def);
} else {
// after update - update rights
SetAttributeRights request = new SetAttributeRights(JsonCallbackEvents.disableButtonEvents(updateButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
enableDisableWidgets(true);
}
@Override
public void onLoadingStart() {
enableDisableWidgets(false);
}
@Override
public void onError(PerunError error) {
enableDisableWidgets(true);
}
}));
request.setAttributeRights(list);
}
}
});
attributeDetailTable.setHTML(0, 0, "Display name:");
attributeDetailTable.setWidget(0, 1, displayName);
attributeDetailTable.setHTML(1, 0, "Description:");
attributeDetailTable.setWidget(1, 1, description);
for (int i = 0; i < attributeDetailTable.getRowCount(); i++) {
attributeDetailTable.getFlexCellFormatter().setStyleName(i, 0, "itemName");
}
final FlexTable rightsTable = new FlexTable();
rightsTable.setStyleName("inputFormFlexTable");
rightsTable.setHTML(0, 1, "<strong>SELF</strong>");
rightsTable.setHTML(0, 2, "<strong>VO</strong>");
rightsTable.setHTML(0, 3, "<strong>GROUP</strong>");
rightsTable.setHTML(0, 4, "<strong>FACILITY</strong>");
rightsTable.setHTML(1, 0, "<strong>READ</strong>");
rightsTable.setHTML(2, 0, "<strong>WRITE</strong>");
rightsTable.setWidget(1, 1, selfRead);
rightsTable.setWidget(2, 1, selfWrite);
rightsTable.setWidget(1, 2, voRead);
rightsTable.setWidget(2, 2, voWrite);
rightsTable.setWidget(1, 3, groupRead);
rightsTable.setWidget(2, 3, groupWrite);
rightsTable.setWidget(1, 4, facilityRead);
rightsTable.setWidget(2, 4, facilityWrite);
rightsTable.addStyleName("centeredTable");
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
menu.addWidget(updateButton);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().closeTab(tab, false);
}
}));
GetAttributeRights rightsCall = new GetAttributeRights(def.getId(), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
rights = JsonUtils.jsoAsList(jso);
for (AttributeRights r : rights) {
if (r.getRole().equalsIgnoreCase("SELF")) {
setRightsToWidgets(selfRead, selfWrite, r);
} else if (r.getRole().equalsIgnoreCase("VOADMIN")) {
setRightsToWidgets(voRead, voWrite, r);
} else if (r.getRole().equalsIgnoreCase("GROUPADMIN")) {
setRightsToWidgets(groupRead, groupWrite, r);
} else if (r.getRole().equalsIgnoreCase("FACILITYADMIN")) {
setRightsToWidgets(facilityRead, facilityWrite, r);
}
}
enableDisableWidgets(true);
rightsTable.setVisible(true);
}
@Override
public void onError(PerunError error) {
enableDisableWidgets(true);
rightsTable.setVisible(false);
}
@Override
public void onLoadingStart() {
enableDisableWidgets(false);
rightsTable.setVisible(false);
}
});
rightsCall.retrieveData();
// create new instance for jsonCall
final GetServicesByAttrDefinition services = new GetServicesByAttrDefinition(def.getId());
services.setCheckable(false);
CellTable<Service> attrDefTable = services.getTable(new FieldUpdater<Service, String>() {
@Override
public void update(int index, Service object, String value) {
session.getTabManager().addTab(new ServiceDetailTabItem(object));
}
});
attrDefTable.setStyleName("perun-table");
ScrollPanel scrollTable = new ScrollPanel(attrDefTable);
scrollTable.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizePerunTable(scrollTable, 350, this);
// set content to page
mainPage.setWidget(0, 0, menu);
mainPage.getFlexCellFormatter().setColSpan(0, 0, 2);
mainPage.setWidget(1, 0, attributeDetailTable);
mainPage.setWidget(1, 1, rightsTable);
mainPage.getFlexCellFormatter().setWidth(1, 0, "50%");
mainPage.getFlexCellFormatter().setWidth(1, 1, "50%");
HTML title = new HTML("<p>Required by service</p>");
title.setStyleName("subsection-heading");
mainPage.setWidget(2, 0, title);
mainPage.getFlexCellFormatter().setColSpan(2, 0, 2);
// put page into scroll panel
mainPage.setWidget(3, 0, scrollTable);
mainPage.getFlexCellFormatter().setColSpan(3, 0, 2);
mainPage.getFlexCellFormatter().setHeight(3, 0, "100%");
this.contentWidget.setWidget(mainPage);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedTextBox in project perun by CESNET.
the class EditGroupDetailsTabItem method draw.
public Widget draw() {
titleWidget = new Label("Edit group");
VerticalPanel vp = new VerticalPanel();
// textboxes which set the class data when updated
final ExtendedTextBox descriptionTextBox = new ExtendedTextBox();
descriptionTextBox.getTextBox().setText(group.getDescription());
final ExtendedTextBox nameTextBox = new ExtendedTextBox();
nameTextBox.getTextBox().setText(group.getShortName());
// disable name change for core groups
nameTextBox.getTextBox().setEnabled(!group.isCoreGroup());
// 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, buttonTranslation.saveGroupDetails());
final ExtendedTextBox.TextBoxValidator validator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (nameTextBox.getTextBox().getText().trim().isEmpty()) {
nameTextBox.setError("Name can't be empty.");
} else if (!nameTextBox.getTextBox().getText().trim().matches(Utils.GROUP_SHORT_NAME_MATCHER)) {
nameTextBox.setError("Name can contain only a-z, A-Z, numbers, spaces, dots, '_' and '-'.");
} else {
nameTextBox.setOk();
return true;
}
return false;
}
};
nameTextBox.setValidator(validator);
saveButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (!validator.validateTextBox())
return;
Group g = JsonUtils.clone(group).cast();
g.setDescription(descriptionTextBox.getTextBox().getText().trim());
String value = nameTextBox.getTextBox().getText().trim();
g.setShortName(value);
int index = g.getName().lastIndexOf(":");
if (index > 0) {
// short name append to base name
String baseName = g.getName().substring(0, index);
baseName += ":" + g.getShortName();
g.setName(baseName);
} else {
// short name is whole name
g.setName(value);
}
;
UpdateGroup request = new UpdateGroup(JsonCallbackEvents.closeTabDisableButtonEvents(saveButton, tab, events));
request.updateGroup(g);
}
});
// cancel button
final CustomButton cancelButton = TabMenu.getPredefinedButton(ButtonType.CANCEL, "");
cancelButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
});
// 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();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedTextBox in project perun by CESNET.
the class EditFacilityDetailsTabItem method draw.
public Widget draw() {
titleWidget = new Label("Edit facility");
VerticalPanel vp = new VerticalPanel();
// textboxes which set the class data when updated
final ExtendedTextBox nameTextBox = new ExtendedTextBox();
nameTextBox.getTextBox().setText(facility.getName());
final TextBox descriptionTextBox = new TextBox();
descriptionTextBox.setText(facility.getDescription());
final ExtendedTextBox.TextBoxValidator validator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (nameTextBox.getTextBox().getText().trim().isEmpty()) {
nameTextBox.setError("Name can't be empty.");
return false;
} else if (!nameTextBox.getTextBox().getText().trim().matches(Utils.FACILITY_NAME_MATCHER)) {
nameTextBox.setError("Name can contain only letters, numbers, dash, dot and underscore.");
return false;
} else {
nameTextBox.setOk();
return true;
}
}
};
nameTextBox.setValidator(validator);
// 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, buttonTranslation.saveFacilityDetails());
saveButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (validator.validateTextBox()) {
Facility fac = JsonUtils.clone(facility).cast();
fac.setName(nameTextBox.getTextBox().getText().trim());
fac.setDescription(descriptionTextBox.getText().trim());
UpdateFacility request = new UpdateFacility(JsonCallbackEvents.closeTabDisableButtonEvents(saveButton, tab, events));
request.updateFacility(fac);
}
}
});
// cancel button
final CustomButton cancelButton = TabMenu.getPredefinedButton(ButtonType.CANCEL, "");
cancelButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
});
// 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