use of cz.metacentrum.perun.webgui.widgets.ExtendedTextBox in project perun by CESNET.
the class CreateServiceTabItem method draw.
public Widget draw() {
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
final ExtendedTextBox serviceName = new ExtendedTextBox();
final ExtendedTextBox scriptPath = new ExtendedTextBox();
final CheckBox enabled = new CheckBox();
final ExtendedTextBox delay = new ExtendedTextBox();
final ExtendedTextBox.TextBoxValidator validator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (serviceName.getTextBox().getText().trim().isEmpty()) {
serviceName.setError("Name can't be empty");
return false;
} else if (!serviceName.getTextBox().getText().trim().matches(Utils.SERVICE_NAME_MATCHER)) {
serviceName.setError("Name can contain only letters, numbers and underscore.");
return false;
} else {
serviceName.setOk();
// fill script path on service name change
scriptPath.getTextBox().setValue("./" + serviceName.getTextBox().getText().trim().toLowerCase().replaceAll(Utils.SERVICE_NAME_TO_SCRIP_PATH_MATCHER, "_"));
return true;
}
}
};
serviceName.setValidator(validator);
enabled.setText("Enabled / Disabled");
enabled.setValue(true);
delay.getTextBox().setText(DEFAULT_DELAY);
final ExtendedTextBox.TextBoxValidator delayValidator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (!JsonUtils.checkParseInt(delay.getTextBox().getText().trim())) {
delay.setError("Delay must be a number (time in minutes) !");
return false;
} else {
delay.setOk();
return true;
}
}
};
delay.setValidator(delayValidator);
final ExtendedTextBox.TextBoxValidator scriptValidator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (scriptPath.getTextBox().getText().trim().isEmpty()) {
scriptPath.setError("Script path can't be empty !");
return false;
} else {
scriptPath.setOk();
return true;
}
}
};
scriptPath.setValidator(scriptValidator);
// prepares layout
FlexTable layout = new FlexTable();
layout.setStyleName("inputFormFlexTable");
FlexTable.FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
// close tab events
final TabItem tab = this;
TabMenu menu = new TabMenu();
// fill form
layout.setHTML(0, 0, "Name:");
layout.setHTML(1, 0, "Status:");
layout.setHTML(2, 0, "Delay:");
layout.setHTML(3, 0, "Script path:");
layout.setWidget(0, 1, serviceName);
layout.setWidget(1, 1, enabled);
layout.setWidget(2, 1, delay);
layout.setWidget(3, 1, scriptPath);
for (int i = 0; i < layout.getRowCount(); i++) {
cellFormatter.addStyleName(i, 0, "itemName");
}
// create button
final CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, ButtonTranslation.INSTANCE.createService());
createButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (validator.validateTextBox() && delayValidator.validateTextBox() && scriptValidator.validateTextBox()) {
CreateCompleteService request = new CreateCompleteService(JsonCallbackEvents.closeTabDisableButtonEvents(createButton, tab));
request.createCompleteService(serviceName.getTextBox().getText().trim(), scriptPath.getTextBox().getText().trim(), Integer.parseInt(delay.getTextBox().getText().trim()), enabled.getValue());
}
}
});
// cancel button
final CustomButton cancelButton = TabMenu.getPredefinedButton(ButtonType.CANCEL, "");
cancelButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
});
menu.addWidget(createButton);
menu.addWidget(cancelButton);
vp.add(layout);
vp.add(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
// add tabs to the main panel
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedTextBox in project perun by CESNET.
the class EditExecServiceTabItem method draw.
public Widget draw() {
titleWidget = new Label("Edit ExecService");
VerticalPanel vp = new VerticalPanel();
final CheckBox enabled = new CheckBox();
enabled.setText("Enabled / Disabled");
enabled.setValue(execService.isEnabled());
final ExtendedTextBox delay = new ExtendedTextBox();
delay.getTextBox().setText("" + execService.getDefaultDelay());
final ExtendedTextBox.TextBoxValidator delayValidator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (!JsonUtils.checkParseInt(delay.getTextBox().getText().trim())) {
delay.setError("Delay must be a number (time in minutes) !");
return false;
} else {
delay.setOk();
return true;
}
}
};
delay.setValidator(delayValidator);
final ExtendedTextBox scriptPath = new ExtendedTextBox();
scriptPath.getTextBox().setValue(execService.getScriptPath());
final ExtendedTextBox.TextBoxValidator scriptValidator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (scriptPath.getTextBox().getText().trim().isEmpty()) {
scriptPath.setError("Script path can't be empty !");
return false;
} else {
scriptPath.setOk();
return true;
}
}
};
scriptPath.setValidator(scriptValidator);
// 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 ExecService");
saveButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (!scriptValidator.validateTextBox() && !delayValidator.validateTextBox())
return;
ExecService es = JsonUtils.clone(execService).cast();
es.setEnabled(enabled.getValue());
es.setDefaultDelay(Integer.parseInt(delay.getTextBox().getValue().trim()));
es.setScriptPath(scriptPath.getTextBox().getValue().trim());
UpdateExecService request = new UpdateExecService(JsonCallbackEvents.closeTabDisableButtonEvents(saveButton, tab, events));
request.updateExecService(es);
}
});
// 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, "Enabled:");
layout.setWidget(0, 1, enabled);
layout.setHTML(1, 0, "Script path:");
layout.setWidget(1, 1, scriptPath);
layout.setHTML(2, 0, "Delay:");
layout.setWidget(2, 1, delay);
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 AddLoginTabItem method draw.
public Widget draw() {
titleWidget.setText("Add login");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
final ExtendedTextBox userLogin = new ExtendedTextBox();
final ListBox namespace = new ListBox();
final CustomButton createLogin = TabMenu.getPredefinedButton(ButtonType.ADD, "Add login in selected namespace");
final Label notice = new Label("Your login will be automatically generated.");
notice.setVisible(false);
// offer only available namespaces.
ArrayList<String> logins = new ArrayList<String>();
for (Attribute a : usersLogins) {
logins.add(a.getFriendlyNameParameter());
}
for (String s : Utils.getSupportedPasswordNamespaces()) {
if (!logins.contains(s)) {
namespace.addItem(s.toUpperCase(), s);
}
}
final ExtendedTextBox.TextBoxValidator loginValidator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (userLogin.getTextBox().getValue().trim().isEmpty()) {
userLogin.setError("Login can't be empty!");
return false;
}
RegExp regExp = RegExp.compile(Utils.LOGIN_VALUE_MATCHER);
boolean match = regExp.test(userLogin.getTextBox().getValue().trim());
if (!match) {
userLogin.setError("Invalid format!");
return false;
}
if (userLogin.isProcessing() || userLogin.isHardError()) {
return false;
}
userLogin.setOk();
return true;
}
};
userLogin.setValidator(loginValidator);
final FlexTable layout = new FlexTable();
layout.addStyleName("inputFormFlexTable");
layout.setHTML(0, 0, "Namespace:");
layout.setHTML(1, 0, "Login:");
for (int i = 0; i < layout.getRowCount(); i++) {
layout.getFlexCellFormatter().addStyleName(i, 0, "itemName");
}
layout.setWidget(0, 1, namespace);
layout.setWidget(1, 1, userLogin);
layout.getFlexCellFormatter().setColSpan(2, 0, 2);
layout.setWidget(2, 0, notice);
layout.getFlexCellFormatter().addStyleName(2, 0, "inputFormInlineComment");
TabMenu menu = new TabMenu();
menu.addWidget(createLogin);
final TabItem tab = this;
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().closeTab(tab, false);
}
}));
// user can't add new login
if (namespace.getItemCount() == 0) {
vp.add(new HTML("<p><strong>You already have login in all supported namespaces!</strong></p>"));
createLogin.setEnabled(false);
} else {
// user can add new login
vp.add(layout);
// check login availability
userLogin.getTextBox().addKeyUpHandler(new KeyUpHandler() {
@Override
public void onKeyUp(KeyUpEvent keyUpEvent) {
if (keyUpEvent.isDownArrow() || keyUpEvent.isUpArrow() || keyUpEvent.isLeftArrow() || keyUpEvent.isRightArrow()) {
// do not trigger when no text input
return;
}
final String value = userLogin.getTextBox().getValue().trim();
// trigger new validation on checked input or if previously was hard error
if ((!value.isEmpty() && RegExp.compile(Utils.LOGIN_VALUE_MATCHER).test(value)) || userLogin.isHardError()) {
new IsLoginAvailable(namespace.getValue(namespace.getSelectedIndex()), userLogin.getTextBox().getValue().trim(), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
if (value.equals(userLogin.getTextBox().getValue().trim())) {
BasicOverlayType bo = jso.cast();
userLogin.setProcessing(false);
if (!bo.getBoolean()) {
userLogin.setHardError("Login is already in use!");
} else {
userLogin.removeHardError();
loginValidator.validateTextBox();
}
}
}
@Override
public void onLoadingStart() {
if (value.equals(userLogin.getTextBox().getValue().trim())) {
userLogin.removeHardError();
userLogin.setProcessing(true);
}
}
@Override
public void onError(PerunError error) {
if (value.equals(userLogin.getTextBox().getValue().trim())) {
userLogin.setProcessing(false);
userLogin.setHardError("Unable to check if login is available!");
}
}
}).retrieveData();
}
}
});
namespace.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent changeEvent) {
if (namespace.getSelectedValue().equals("mu")) {
userLogin.getTextBox().setValue("");
userLogin.removeHardError();
userLogin.setOk();
userLogin.getTextBox().setEnabled(false);
notice.setVisible(true);
} else {
userLogin.getTextBox().setEnabled(true);
notice.setVisible(false);
final String value = userLogin.getTextBox().getValue().trim();
// trigger new validation on checked input or if previously was hard error
if ((!value.isEmpty() && RegExp.compile(Utils.LOGIN_VALUE_MATCHER).test(value)) || userLogin.isHardError()) {
new IsLoginAvailable(namespace.getValue(namespace.getSelectedIndex()), userLogin.getTextBox().getValue().trim(), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
if (value.equals(userLogin.getTextBox().getValue().trim())) {
BasicOverlayType bo = jso.cast();
userLogin.setProcessing(false);
if (!bo.getBoolean()) {
userLogin.setError("Login is already in use!");
} else {
userLogin.removeHardError();
loginValidator.validateTextBox();
}
}
}
@Override
public void onLoadingStart() {
if (value.equals(userLogin.getTextBox().getValue().trim())) {
userLogin.removeHardError();
userLogin.setProcessing(true);
}
}
@Override
public void onError(PerunError error) {
if (value.equals(userLogin.getTextBox().getValue().trim())) {
userLogin.setProcessing(false);
userLogin.setHardError("Error while loading.");
}
}
}).retrieveData();
}
}
}
});
createLogin.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if (namespace.getSelectedValue().equals("mu")) {
session.getTabManager().addTabToCurrentTab(new SelfPasswordTabItem(user, namespace.getValue(namespace.getSelectedIndex()), userLogin.getTextBox().getValue().trim(), SelfPasswordTabItem.Actions.CREATE));
} else {
if (!loginValidator.validateTextBox())
return;
SetLogin request = new SetLogin(JsonCallbackEvents.disableButtonEvents(createLogin, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
session.getTabManager().addTabToCurrentTab(new SelfPasswordTabItem(user, namespace.getValue(namespace.getSelectedIndex()), userLogin.getTextBox().getValue().trim(), SelfPasswordTabItem.Actions.CREATE));
}
}));
request.setLogin(user, namespace.getValue(namespace.getSelectedIndex()), userLogin.getTextBox().getValue().trim());
}
}
});
}
if (namespace.getSelectedValue().equals("mu")) {
userLogin.getTextBox().setValue("");
userLogin.removeHardError();
userLogin.setOk();
userLogin.getTextBox().setEnabled(false);
notice.setVisible(true);
}
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 VoMembersTabItem method draw.
public Widget draw() {
// SET TAB NAME
titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": members");
// MAIN PANEL
final VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// MENU
TabMenu tabMenu = new TabMenu();
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
// DISABLED CHECKBOX
final CheckBox disabled = new CheckBox(WidgetTranslation.INSTANCE.showDisabledMembers());
disabled.setTitle(WidgetTranslation.INSTANCE.showDisabledMembersTitle());
disabled.setValue(wasDisabled);
disabled.setVisible(false);
// CALLBACKS
final GetCompleteRichMembers members = new GetCompleteRichMembers(PerunEntity.VIRTUAL_ORGANIZATION, voId, null);
final FindCompleteRichMembers findMembers = new FindCompleteRichMembers(PerunEntity.VIRTUAL_ORGANIZATION, voId, "", null);
members.excludeDisabled(!wasDisabled);
final CustomButton searchButton = TabMenu.getPredefinedButton(ButtonType.SEARCH, ButtonTranslation.INSTANCE.searchMemberInVo());
final CustomButton listAllButton = TabMenu.getPredefinedButton(ButtonType.LIST_ALL_MEMBERS, ButtonTranslation.INSTANCE.listAllMembersInVo());
if (!session.isVoAdmin(voId))
findMembers.setCheckable(false);
final CellTable<RichMember> table = findMembers.getEmptyTable(new FieldUpdater<RichMember, RichMember>() {
// when user click on a row -> open new tab
public void update(int index, RichMember object, RichMember value) {
session.getTabManager().addTab(new MemberDetailTabItem(object.getId(), 0));
}
});
// refresh
tabMenu.addWidget(UiElements.getRefreshButton(this));
// ADD
CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addMemberToVo(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AddMemberToVoTabItem(voId), true);
}
});
if (!session.isVoAdmin(voId))
addButton.setEnabled(false);
tabMenu.addWidget(addButton);
// REMOVE
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeMemberFromVo());
if (!session.isVoAdmin(voId))
removeButton.setEnabled(false);
tabMenu.addWidget(removeButton);
/*
final CustomButton addServiceButton = new CustomButton(ButtonTranslation.INSTANCE.createServiceMemberButton(), ButtonTranslation.INSTANCE.createServiceMember(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new CreateServiceMemberInVoTabItem(vo));
}
});
if (!session.isVoAdmin(voId)) addServiceButton.setEnabled(false);
tabMenu.addWidget(addServiceButton);
*/
// refreshMembers
final JsonCallbackEvents refreshEvent = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
if (search) {
findMembers.searchFor(searchString);
} else {
findMembers.clearTable();
members.retrieveData();
}
}
};
// add click handler for remove button
removeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// state specific events
final ArrayList<RichMember> membersForRemoving = findMembers.getTableSelectedList();
String text = "Following members will be removed from VO and their settings will be lost.<p>You can consider changing their status to \"DISABLED\", which will prevent them from accessing VO resources.";
UiElements.showDeleteConfirm(membersForRemoving, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < membersForRemoving.size(); i++) {
DeleteMember request;
if (i == membersForRemoving.size() - 1) {
request = new DeleteMember(JsonCallbackEvents.disableButtonEvents(removeButton, refreshEvent));
} else {
request = new DeleteMember(JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.deleteMember(membersForRemoving.get(i).getId());
}
}
});
}
});
final ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {
public void searchFor(String text) {
searchString = text;
search = true;
findMembers.searchFor(text);
}
}, searchButton);
searchBox.getTextBox().setText(searchString);
// checkbox click handler
disabled.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
wasDisabled = disabled.getValue();
if (search) {
// case when update but not triggered by button
searchString = searchBox.getTextBox().getText();
members.excludeDisabled(!disabled.getValue());
} else {
members.excludeDisabled(!disabled.getValue());
members.retrieveData();
}
}
});
findMembers.setEvents(JsonCallbackEvents.mergeEvents(JsonCallbackEvents.disableButtonEvents(searchButton, JsonCallbackEvents.disableCheckboxEvents(disabled)), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
searchBox.getTextBox().setEnabled(true);
listAllButton.setEnabled(true);
}
@Override
public void onError(PerunError error) {
searchBox.getTextBox().setEnabled(true);
listAllButton.setEnabled(true);
}
@Override
public void onLoadingStart() {
searchBox.getTextBox().setEnabled(false);
listAllButton.setEnabled(false);
disabled.setVisible(false);
}
}));
members.setEvents(JsonCallbackEvents.mergeEvents(JsonCallbackEvents.disableButtonEvents(listAllButton, JsonCallbackEvents.disableCheckboxEvents(disabled)), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// pass data to table handling callback
findMembers.onFinished(jso);
((AjaxLoaderImage) table.getEmptyTableWidget()).setEmptyResultMessage("VO has no members.");
searchBox.getTextBox().setEnabled(true);
searchButton.setEnabled(true);
}
@Override
public void onError(PerunError error) {
// pass data to table handling callback
findMembers.onError(error);
searchBox.getTextBox().setEnabled(true);
searchButton.setEnabled(true);
}
@Override
public void onLoadingStart() {
searchBox.getTextBox().setEnabled(false);
searchButton.setEnabled(false);
disabled.setVisible(true);
// to show progress when reloading
((AjaxLoaderImage) table.getEmptyTableWidget()).loadingStart();
}
}));
// LIST ALL BUTTON
listAllButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
search = false;
searchString = "";
searchBox.getTextBox().setText("");
findMembers.clearTable();
members.retrieveData();
}
});
tabMenu.addWidget(listAllButton);
tabMenu.addWidget(disabled);
/* WHEN TAB RELOADS, CHECK THE STATE */
if (search) {
findMembers.searchFor(searchString);
} else {
members.excludeDisabled(!disabled.getValue());
members.retrieveData();
}
ScrollPanel tableWrapper = new ScrollPanel();
table.addStyleName("perun-table");
tableWrapper.setWidget(table);
tableWrapper.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizePerunTable(tableWrapper, 350, this);
// add menu and the table to the main panel
firstTabPanel.add(tableWrapper);
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(findMembers, table, removeButton);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedTextBox in project perun by CESNET.
the class AddVoManagerTabItem method draw.
public Widget draw() {
titleWidget.setText("Add manager");
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.addSelectedManagersToVo());
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.addVoAdmin(vo, 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();
}
Aggregations