use of cz.metacentrum.perun.webgui.widgets.TabMenu in project perun by CESNET.
the class AddGroupManagerTabItem method draw.
public Widget draw() {
titleWidget.setText("Add manager");
// MAIN PANEL
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// if members or admins group, hide
if (group.isCoreGroup()) {
vp.add(new HTML("<p>Group \"" + group.getName() + "\" can't have managers managed from Group manager section. Please use VO manager section.</p>"));
this.contentWidget.setWidget(vp);
return getWidget();
}
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();
tabMenu.addWidget(UiElements.getRefreshButton(this));
// 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();
}
final TabItem tab = this;
// already added
rebuildAlreadyAddedWidget();
// search textbox
final ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {
@Override
public void searchFor(String text) {
startSearching(text);
searchString = text;
}
}, searchButton);
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedManagersToGroup());
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
final ArrayList<User> list = users.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i = 0; i < list.size(); i++) {
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.addGroupAdmin(group, list.get(i));
}
}
}
});
tabMenu.addWidget(addButton);
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, !alreadyAddedList.isEmpty());
}
}));
// 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.TabMenu in project perun by CESNET.
the class AddGroupUnionTabItem method draw.
@Override
public Widget draw() {
titleWidget.setText("Add group union");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// menu
TabMenu menu = new TabMenu();
menu.addWidget(new HTML(""));
final GetAllGroups groups = new GetAllGroups(group.getVoId());
groups.setCoreGroupsCheckable(true);
// remove already added union groups from offering
JsonCallbackEvents localEvents = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// second callback
final GetGroupUnions alreadyAssigned = new GetGroupUnions(group, false, new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
JsArray<Group> esToRemove = JsonUtils.jsoAsArray(jso);
for (int i = 0; i < esToRemove.length(); i++) {
groups.removeFromTable(esToRemove.get(i));
}
// remove itself
groups.removeFromTable(group);
}
});
alreadyAssigned.retrieveData();
}
};
groups.setEvents(localEvents);
final ExtendedSuggestBox box = new ExtendedSuggestBox(groups.getOracle());
// button
final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedExtSource());
final TabItem tab = this;
assignButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<Group> groupsToAdd = groups.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(groupsToAdd)) {
// FIXME - Should have only one callback to core
for (int i = 0; i < groupsToAdd.size(); i++) {
final int n = i;
AddGroupUnion request = new AddGroupUnion(JsonCallbackEvents.disableButtonEvents(assignButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// unselect added person
groups.getSelectionModel().setSelected(groupsToAdd.get(n), false);
alreadyAddedList.add(groupsToAdd.get(n));
rebuildAlreadyAddedWidget();
// clear search
box.getSuggestBox().setText("");
}
}));
request.createGroupUnion(group, groupsToAdd.get(i));
}
}
}
});
menu.addFilterWidget(box, new PerunSearchEvent() {
@Override
public void searchFor(String text) {
groups.filterTable(text);
}
}, "Filter by ext source name or type");
menu.addWidget(assignButton);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, !alreadyAddedList.isEmpty());
}
}));
vp.add(menu);
vp.setCellHeight(menu, "30px");
vp.add(alreadyAdded);
CellTable<Group> table = groups.getTable();
assignButton.setEnabled(false);
JsonUtils.addTableManagedButton(groups, table, assignButton);
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
// do not use resizePerunTable() when tab is in overlay - wrong width is calculated
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.TabMenu in project perun by CESNET.
the class AssignGroupTabItem method draw.
public Widget draw() {
// set tab name
titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": assign to resource");
// main content
VerticalPanel mainTab = new VerticalPanel();
mainTab.setSize("100%", "100%");
// menu
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
// callback
final GetRichResources callback = new GetRichResources(group.getVoId());
callback.setEvents(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
for (RichResource rr : resources) {
callback.removeFromTable(rr);
}
ArrayList<RichResource> temp = new ArrayList<RichResource>();
temp.addAll(callback.getList());
callback.setList(temp);
}
});
CellTable<RichResource> table = callback.getTable();
// close tab event
final TabItem tab = this;
// filter box
menu.addFilterWidget(new ExtendedSuggestBox(callback.getOracle()), new PerunSearchEvent() {
public void searchFor(String text) {
callback.filterTable(text);
// if single group, select
if (callback.getList().size() == 1) {
callback.getSelectionModel().setSelected(callback.getList().get(0), true);
}
}
}, ButtonTranslation.INSTANCE.filterResources());
// button
final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.assignGroupToSelectedResources());
assignButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<RichResource> toAssign = callback.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(toAssign)) {
AssignGroupToResources request = new AssignGroupToResources(JsonCallbackEvents.disableButtonEvents(assignButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
alreadyAddedList.addAll(toAssign);
for (RichResource r : toAssign) {
callback.getSelectionModel().setSelected(r, false);
}
rebuildAlreadyAddedWidget();
}
}));
request.assignGroupToResources(group, toAssign);
}
}
});
menu.addWidget(assignButton);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
assignButton.setEnabled(false);
JsonUtils.addTableManagedButton(callback, table, assignButton);
// add menu and the table to the main panel
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
// do not use resizePerunTable() in overlay mode - calculated width is wrong
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
mainTab.add(menu);
mainTab.setCellHeight(menu, "30px");
rebuildAlreadyAddedWidget();
mainTab.add(alreadyAdded);
mainTab.add(sp);
this.contentWidget.setWidget(mainTab);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.TabMenu in project perun by CESNET.
the class GroupApplicationFormSettingsTabItem method draw.
public Widget draw() {
// MAIN PANEL
final VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
final TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
final CustomButton save = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.saveApplicationFormSettings());
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addNewAppFormItem());
final CustomButton emailButton = new CustomButton(ButtonTranslation.INSTANCE.emailNotificationsButton() + "…", ButtonTranslation.INSTANCE.emailNotifications(), SmallIcons.INSTANCE.emailIcon());
final CustomButton copyButton = new CustomButton(ButtonTranslation.INSTANCE.copyFromVoButton() + "…", ButtonTranslation.INSTANCE.copyFromVo(), SmallIcons.INSTANCE.copyIcon());
final CustomButton previewButton = TabMenu.getPredefinedButton(ButtonType.PREVIEW, ButtonTranslation.INSTANCE.previewAppForm());
// request
final GetFormItems itemsRequest = new GetFormItems(PerunEntity.GROUP, group.getId(), true, group, new JsonCallbackEvents() {
@Override
public void onError(PerunError error) {
// DISABLE BUTTONS
save.setEnabled(false);
addButton.setEnabled(false);
emailButton.setEnabled(false);
copyButton.setEnabled(false);
previewButton.setEnabled(false);
}
});
sourceList = itemsRequest.getList();
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": " + "application form");
// HORIZONTAL MENU
vp.add(menu);
vp.setCellHeight(menu, "30px");
// refresh table events
final JsonCallbackEvents refreshEvents = new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
itemsRequest.prepareSettings(sourceList);
}
};
// save button
save.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
UpdateFormItems request = new UpdateFormItems(PerunEntity.GROUP, groupId, JsonCallbackEvents.disableButtonEvents(save, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
itemsRequest.retrieveData();
}
}));
// reset item ordnum to correct state defined by list
// keep counter
int counter = 0;
// process
for (int i = 0; i < itemsRequest.getList().size(); i++) {
// if not for deletion
if (!itemsRequest.getList().get(i).isForDelete()) {
// set
itemsRequest.getList().get(i).setOrdnum(counter);
counter++;
}
}
// send request
request.updateFormItems(itemsRequest.getList());
}
});
if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId()))
save.setEnabled(false);
menu.addWidget(save);
// add button
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new CreateFormItemTabItem(sourceList, refreshEvents));
}
});
if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId()))
addButton.setEnabled(false);
menu.addWidget(addButton);
copyButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new CopyFormTabItem(group.getVoId(), groupId));
}
});
if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId()))
copyButton.setEnabled(false);
menu.addWidget(copyButton);
if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId()))
previewButton.setEnabled(false);
menu.addWidget(previewButton);
// AUTO APPROVAL + NOTIFICATIONS
// auto-approval widget already defined
GetApplicationForm form = new GetApplicationForm(PerunEntity.GROUP, groupId, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
final ApplicationForm form = jso.cast();
previewButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTab(new PreviewFormTabItem(form, sourceList), true);
}
});
}
});
form.setHidden(true);
form.retrieveData();
menu.addWidget(form.getApprovalWidget());
emailButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTab(new MailsTabItem(group.getVoId(), group.getId()));
}
});
if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId()))
emailButton.setEnabled(false);
menu.addWidget(emailButton);
// load elements
itemsRequest.retrieveData();
// wrap table to the scroll panel
ScrollPanel sp = new ScrollPanel(itemsRequest.getContents());
sp.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizePerunTable(sp, 100, this);
// add scroll table to the main panel
vp.add(sp);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.TabMenu in project perun by CESNET.
the class PublicationDetailTabItem method loadThanksSubTab.
/**
* Returns thanks management widget for publication
*
* @return widget
*/
private Widget loadThanksSubTab() {
DisclosurePanel dp = new DisclosurePanel();
dp.setWidth("100%");
dp.setOpen(true);
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
dp.setContent(vp);
FlexTable header = new FlexTable();
header.setWidget(0, 0, new Image(LargeIcons.INSTANCE.smallBusinessIcon()));
header.setHTML(0, 1, "<h3>Acknowledgement</h3>");
dp.setHeader(header);
// menu
TabMenu menu = new TabMenu();
// callback
final GetRichThanksByPublicationId thanksCall = new GetRichThanksByPublicationId(publicationId);
thanksCall.setCheckable(false);
if (!publication.getLocked()) {
// editable if not locked
vp.add(menu);
vp.setCellHeight(menu, "30px");
thanksCall.setCheckable(true);
}
CellTable<Thanks> table = thanksCall.getTable();
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, "Add acknowledgement to publication", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new CreateThanksTabItem(publication, JsonCallbackEvents.refreshTableEvents(thanksCall)), true);
}
}));
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, "Remove acknowledgement from publication");
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(thanksCall, table, removeButton);
menu.addWidget(removeButton);
removeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<Thanks> list = thanksCall.getTableSelectedList();
String text = "Following acknowledgements will be removed from publication.";
UiElements.showDeleteConfirm(list, text, new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
for (int i = 0; i < list.size(); i++) {
// calls the request
if (i == list.size() - 1) {
DeleteThanks request = new DeleteThanks(JsonCallbackEvents.disableButtonEvents(removeButton, JsonCallbackEvents.refreshTableEvents(thanksCall)));
request.deleteThanks(list.get(i).getId());
} else {
DeleteThanks request = new DeleteThanks(JsonCallbackEvents.disableButtonEvents(removeButton));
request.deleteThanks(list.get(i).getId());
}
}
}
});
}
});
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel();
sp.add(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
return dp;
}
Aggregations