use of com.google.gwt.cell.client.FieldUpdater in project perun by CESNET.
the class AddAuthorTabItem method draw.
public Widget draw() {
titleWidget.setText("Add author");
this.users = new FindCompleteRichUsers("", null);
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// PUB-INFO
TabMenu info = new TabMenu();
info.addWidget(new HTML("<strong>FULL CITE: </strong>" + publication.getMain()));
firstTabPanel.add(info);
// 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 index, User object, String value) {
session.getTabManager().addTab(new UserDetailTabItem(object));
}
});
} else {
table = users.getTable();
}
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, "Add selected user(s) as author(s) of publication: " + publication.getTitle());
tabMenu.addWidget(addButton);
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(users, table, addButton);
final TabItem tab = this;
addButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
ArrayList<User> list = users.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
// proceed
for (int i = 0; i < list.size(); i++) {
final String name = list.get(i).getFullNameWithTitles();
// add name events
JsonCallbackEvents authorshipEvents = new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
updateAlreadyAdded(name);
}
};
// merge with refresh?
if (i == list.size() - 1 && events != null) {
authorshipEvents = JsonCallbackEvents.mergeEvents(authorshipEvents, events);
}
// call
CreateAuthorship request = new CreateAuthorship(JsonCallbackEvents.disableButtonEvents(addButton, authorshipEvents));
request.createAuthorship(publicationId, list.get(i).getId());
if (i == list.size() - 1) {
users.clearTableSelectedSet();
}
}
}
}
});
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// trigger refresh of sub-tab via event
events.onFinished(null);
session.getTabManager().closeTab(tab, false);
}
}));
tabMenu.addSearchWidget(new PerunSearchEvent() {
@Override
public void searchFor(String text) {
users.searchFor(text);
searchString = text;
}
}, ButtonTranslation.INSTANCE.searchUsers());
// 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 to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
// add already added
firstTabPanel.add(alreadyAddedAuthors);
firstTabPanel.setCellHeight(alreadyAddedAuthors, "30px");
// add table to the main panel
firstTabPanel.add(sp);
// do not resize like perun table to prevent wrong width in inner tab
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of com.google.gwt.cell.client.FieldUpdater in project perun by CESNET.
the class FacilityBlacklistTabItem method draw.
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": Blacklist");
// main panel
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
final GetBlacklistWithDescription securityTeams = new GetBlacklistWithDescription(PerunEntity.FACILITY, facilityId);
// menu
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
menu.addFilterWidget(new ExtendedSuggestBox(securityTeams.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
securityTeams.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterSecurityTeam());
CellTable<Pair<User, String>> table;
if (session.isPerunAdmin() || session.isSecurityAdmin()) {
table = securityTeams.getTable(new FieldUpdater<Pair<User, String>, String>() {
@Override
public void update(int index, Pair<User, String> object, String value) {
session.getTabManager().addTab(new UserDetailTabItem(object.getLeft()));
}
});
} else {
table = securityTeams.getTable();
}
// 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(menu);
firstTabPanel.setCellHeight(menu, "30px");
firstTabPanel.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of com.google.gwt.cell.client.FieldUpdater 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 com.google.gwt.cell.client.FieldUpdater in project perun by CESNET.
the class FacilityManagersTabItem method fillContentUsers.
private Widget fillContentUsers(final GetRichAdminsWithAttributes jsonCallback, TabMenu menu) {
jsonCallback.clearTableSelectedSet();
// get the table
CellTable<User> table;
if (session.isPerunAdmin()) {
table = jsonCallback.getTable(new FieldUpdater<User, String>() {
@Override
public void update(int i, User user, String s) {
session.getTabManager().addTab(new UserDetailTabItem(user));
}
});
} else {
table = jsonCallback.getTable();
}
menu.addWidget(0, UiElements.getRefreshButton(this));
menu.addWidget(1, TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerToFacility(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AddFacilityManagerTabItem(facility), true);
}
}));
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeManagerFromFacility());
menu.addWidget(2, removeButton);
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<User> list = jsonCallback.getTableSelectedList();
String text = "Following users won't be facility managers anymore and won't be able to manage this facility in Perun.";
UiElements.showDeleteConfirm(list, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < list.size(); i++) {
if (i == list.size() - 1) {
RemoveAdmin request = new RemoveAdmin(PerunEntity.FACILITY, JsonCallbackEvents.disableButtonEvents(removeButton, JsonCallbackEvents.refreshTableEvents(jsonCallback)));
request.removeFacilityAdmin(facility, list.get(i));
} else {
RemoveAdmin request = new RemoveAdmin(PerunEntity.FACILITY, JsonCallbackEvents.disableButtonEvents(removeButton));
request.removeFacilityAdmin(facility, list.get(i));
}
}
}
});
}
});
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(jsonCallback, table, removeButton);
table.addStyleName("perun-table");
return table;
}
use of com.google.gwt.cell.client.FieldUpdater 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();
}
Aggregations