use of cz.metacentrum.perun.webgui.widgets.ExtendedTextBox in project perun by CESNET.
the class CreateVoTabItem method draw.
public Widget draw() {
VerticalPanel vp = new VerticalPanel();
// textboxes which set the class data when updated
final ExtendedTextBox nameTextBox = new ExtendedTextBox();
final ExtendedTextBox shortNameTextBox = new ExtendedTextBox();
nameTextBox.getTextBox().setMaxLength(128);
shortNameTextBox.getTextBox().setMaxLength(32);
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;
}
}
};
final ExtendedTextBox.TextBoxValidator shortNameValidator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (shortNameTextBox.getTextBox().getText().trim().isEmpty()) {
shortNameTextBox.setError("Short name can't be empty.");
} else if (!shortNameTextBox.getTextBox().getText().trim().matches(Utils.VO_SHORT_NAME_MATCHER)) {
shortNameTextBox.setError("Short name can contain only letters, numbers, dash and underscore.");
} else {
shortNameTextBox.setOk();
return true;
}
return false;
}
};
nameTextBox.setValidator(nameValidator);
shortNameTextBox.setValidator(shortNameValidator);
// 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 createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, buttonTranslation.createVo());
createButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (!nameValidator.validateTextBox())
return;
if (!shortNameValidator.validateTextBox())
return;
CreateVo request = new CreateVo(JsonCallbackEvents.closeTabDisableButtonEvents(createButton, tab, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// new VO must be editable by user in GUI, because it is already in PERUN
VirtualOrganization vo = jso.cast();
session.addEditableVo(vo.getId());
}
}));
request.createVo(nameTextBox.getTextBox().getText().trim(), shortNameTextBox.getTextBox().getText().trim());
}
});
// 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, "Full name:");
layout.setWidget(0, 1, nameTextBox);
layout.setHTML(1, 0, "Short name:");
layout.setWidget(1, 1, shortNameTextBox);
for (int i = 0; i < layout.getRowCount(); i++) {
cellFormatter.addStyleName(i, 0, "itemName");
}
menu.addWidget(createButton);
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 ConnectServiceIdentityTabItem method draw.
public Widget draw() {
titleWidget.setText("Connect identity");
VerticalPanel content = new VerticalPanel();
content.setSize("100%", "100%");
final TabItem tab = this;
// add button
final CustomButton addButton;
if (user.isServiceUser() || user.isSponsoredUser()) {
addButton = new CustomButton("Connect", "Add selected users to this identity", SmallIcons.INSTANCE.addIcon());
} else {
addButton = new CustomButton("Connect", "Add selected identities to user", SmallIcons.INSTANCE.addIcon());
}
TabMenu menu = new TabMenu();
menu.addWidget(addButton);
content.add(menu);
content.setCellHeight(menu, "30px");
final FindCompleteRichUsers call = new FindCompleteRichUsers("", null);
if (user.isServiceUser()) {
call.hideService(true);
}
if (user.isSponsoredUser()) {
call.hideSponsored(true);
call.hideService(true);
}
if (!user.isSpecificUser()) {
call.hidePerson(true);
}
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
// close tab and refresh
session.getTabManager().closeTab(tab, true);
}
}));
// search textbox
ExtendedTextBox searchBox = menu.addSearchWidget(new PerunSearchEvent() {
@Override
public void searchFor(String text) {
call.searchFor(text);
}
}, "");
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
ArrayList<User> list = call.getTableSelectedList();
for (int i = 0; i < list.size(); i++) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
AddSpecificUserOwner req;
if (i == list.size() - 1) {
req = new AddSpecificUserOwner(JsonCallbackEvents.closeTabDisableButtonEvents(addButton, tab));
} else {
req = new AddSpecificUserOwner(JsonCallbackEvents.disableButtonEvents(addButton));
}
if (user.isServiceUser() || user.isSponsoredUser()) {
// service user adds user
req.addSpecificUser(list.get(i), user);
} else {
// user adds service users
req.addSpecificUser(user, list.get(i));
}
}
}
});
FieldUpdater<User, String> fieldUpdater = null;
if (session.isPerunAdmin()) {
fieldUpdater = new FieldUpdater<User, String>() {
public void update(int i, User user, String s) {
session.getTabManager().addTab(new UserDetailTabItem(user));
}
};
}
CellTable<User> table = call.getTable(fieldUpdater);
table.addStyleName("perun-table");
table.setWidth("100%");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(call, table, addButton);
content.add(sp);
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
this.contentWidget.setWidget(new SimplePanel(content));
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedTextBox in project perun by CESNET.
the class InviteUserTabItem method draw.
public Widget draw() {
VerticalPanel vp = new VerticalPanel();
final FlexTable ft = new FlexTable();
ft.setWidth("350px");
ft.setStyleName("inputFormFlexTable");
if (groupId == 0) {
ft.setHTML(0, 0, "Person you are inviting will receive an email with link to VOs application form. You can set up an email template in: Vo manager (advanced) -> Application form -> Notifications.");
} else {
ft.setHTML(0, 0, "Person you are inviting will receive an email with link to groups application form. You can set up an email template in: Group manager (advanced) -> Application form -> Notifications.");
}
ft.getFlexCellFormatter().setColSpan(0, 0, 2);
ft.getFlexCellFormatter().addStyleName(0, 0, "inputFormInlineComment");
ft.setHTML(1, 0, "Name:");
ft.setHTML(2, 0, "Email:");
ft.setHTML(3, 0, "Language:");
ft.getFlexCellFormatter().setStyleName(1, 0, "itemName");
ft.getFlexCellFormatter().setStyleName(2, 0, "itemName");
ft.getFlexCellFormatter().setStyleName(3, 0, "itemName");
final ListBox languages = new ListBox();
languages.setWidth("200px");
//languages.addItem("Czech", "cs");
languages.addItem("English", "en");
languages.setSelectedIndex(1);
if (!Utils.getNativeLanguage().isEmpty()) {
languages.addItem(Utils.getNativeLanguage().get(2), Utils.getNativeLanguage().get(0));
}
final ExtendedTextBox name = new ExtendedTextBox();
final ExtendedTextBox email = new ExtendedTextBox();
final ExtendedTextBox.TextBoxValidator nameValidator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (name.getTextBox().getText().trim().isEmpty()) {
name.setError("Name can't be empty.");
return false;
} else {
name.setOk();
return true;
}
}
};
final ExtendedTextBox.TextBoxValidator emailValidator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (email.getTextBox().getText().trim().isEmpty()) {
email.setError("Email can't be empty.");
return false;
} else if (!JsonUtils.isValidEmail(email.getTextBox().getText().trim())) {
email.setError("Not valid email address format.");
return false;
} else {
email.setOk();
return true;
}
}
};
// Name is now optional
// name.setValidator(nameValidator);
email.setValidator(emailValidator);
ft.setWidget(1, 1, name);
ft.setWidget(2, 1, email);
ft.setWidget(3, 1, languages);
vp.add(ft);
final TabItem tab = this;
final CustomButton sendInvitationButton = new CustomButton("Send invitation", SmallIcons.INSTANCE.emailIcon());
sendInvitationButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
//if (!nameValidator.validateTextBox() || !emailValidator.validateTextBox()) return;
if (!emailValidator.validateTextBox())
return;
SendInvitation invite = new SendInvitation(vo.getId(), groupId, JsonCallbackEvents.closeTabDisableButtonEvents(sendInvitationButton, tab));
invite.inviteUser(email.getTextBox().getText().trim(), name.getTextBox().getText().trim(), languages.getValue(languages.getSelectedIndex()));
}
});
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
menu.addWidget(sendInvitationButton);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedTextBox in project perun by CESNET.
the class AddSecurityTeamManagerTabItem method draw.
public Widget draw() {
titleWidget.setText("Add member");
final CustomButton searchButton = new CustomButton("Search", ButtonTranslation.INSTANCE.searchUsers(), SmallIcons.INSTANCE.findIcon());
this.users = new FindCompleteRichUsers("", null, JsonCallbackEvents.disableButtonEvents(searchButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// if found 1 item, select
ArrayList<User> list = JsonUtils.jsoAsList(jso);
if (list != null && list.size() == 1) {
users.getSelectionModel().setSelected(list.get(0), true);
}
}
}));
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu tabMenu = new TabMenu();
// get the table
final CellTable<User> table;
if (session.isPerunAdmin()) {
table = users.getTable(new FieldUpdater<User, String>() {
public void update(int i, User user, String s) {
session.getTabManager().addTab(new UserDetailTabItem(user));
}
});
} else {
table = users.getTable();
}
rebuildAlreadyAddedWidget();
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedManagersToSecurityTeam());
final TabItem tab = this;
// search textbox
final ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {
@Override
public void searchFor(String text) {
startSearching(text);
searchString = text;
}
}, searchButton);
tabMenu.addWidget(addButton);
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, !alreadyAddedList.isEmpty());
}
}));
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<User> list = users.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i = 0; i < list.size(); i++) {
// FIXME - Should have only one callback to core
final int n = i;
AddAdmin request = new AddAdmin(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// put names to already added
alreadyAddedList.add(list.get(n));
rebuildAlreadyAddedWidget();
// unselect added person
users.getSelectionModel().setSelected(list.get(n), false);
// clear search
searchBox.getTextBox().setText("");
}
}));
request.addSecurityTeamAdmin(securityTeam, list.get(i));
}
}
}
});
// if some text has been searched before
if (!searchString.equals("")) {
searchBox.getTextBox().setText(searchString);
startSearching(searchString);
}
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(users, table, addButton);
// add a class to the table and wrap it into scroll panel
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
// add menu and the table to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
firstTabPanel.add(alreadyAdded);
firstTabPanel.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedTextBox in project perun by CESNET.
the class CreateSecurityTeamTabItem method draw.
public Widget draw() {
VerticalPanel vp = new VerticalPanel();
// textboxes which set the class data when updated
final ExtendedTextBox nameTextBox = new ExtendedTextBox();
final ExtendedTextBox descriptionTextBox = new ExtendedTextBox();
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 createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, buttonTranslation.createSecurityTeam());
createButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (!nameValidator.validateTextBox())
return;
CreateSecurityTeam request = new CreateSecurityTeam(JsonCallbackEvents.closeTabDisableButtonEvents(createButton, tab, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// new SecTeam must be editable by user in GUI, because it is already in PERUN
SecurityTeam team = jso.cast();
session.addEditableSecurityTeam(team.getId());
}
}));
request.createSecurityTeam(nameTextBox.getTextBox().getText().trim(), descriptionTextBox.getTextBox().getText().trim());
}
});
// 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(createButton);
menu.addWidget(cancelButton);
vp.add(layout);
vp.add(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
Aggregations