use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.
the class GroupManagersTabItem method fillContentGroups.
private Widget fillContentGroups(final GetAdminGroups admins, TabMenu menu) {
admins.clearTableSelectedSet();
boolean isMembersGroup = group.isCoreGroup();
menu.addWidget(0, UiElements.getRefreshButton(this));
// Events for reloading when finished
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(admins);
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeManagerGroupFromGroup());
if (!isMembersGroup) {
CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerGroupToGroup(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AddGroupManagerGroupTabItem(group, events), true);
}
});
if (!session.isVoAdmin(group.getVoId()) && !session.isGroupAdmin(group.getId()))
addButton.setEnabled(false);
menu.addWidget(1, addButton);
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<Group> itemsToRemove = admins.getTableSelectedList();
String text = "Members of following groups won't be group managers anymore.";
UiElements.showDeleteConfirm(itemsToRemove, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < itemsToRemove.size(); i++) {
RemoveAdmin request;
if (i == itemsToRemove.size() - 1) {
request = new RemoveAdmin(PerunEntity.GROUP, JsonCallbackEvents.disableButtonEvents(removeButton, events));
} else {
request = new RemoveAdmin(PerunEntity.GROUP, JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.removeGroupAdminGroup(group, itemsToRemove.get(i));
}
}
});
}
});
menu.addWidget(2, removeButton);
} else {
// is core group
menu.addWidget(1, new Image(SmallIcons.INSTANCE.helpIcon()));
Anchor a = new Anchor("<strong>To edit VO managers use VO manager section in menu.</strong>", true);
a.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().addTab(new VoManagersTabItem(group.getVoId()));
}
});
menu.addWidget(2, a);
}
// get the table
CellTable<Group> table = admins.getTable(new FieldUpdater<Group, String>() {
public void update(int i, Group grp, String s) {
session.getTabManager().addTab(new GroupDetailTabItem(grp));
}
});
removeButton.setEnabled(false);
if (session.isVoAdmin(group.getVoId()) || session.isGroupAdmin(group.getId())) {
JsonUtils.addTableManagedButton(admins, table, removeButton);
}
table.setStyleName("perun-table");
return table;
}
use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.
the class GroupManagersTabItem method fillContentUsers.
private Widget fillContentUsers(final GetRichAdminsWithAttributes admins, TabMenu menu) {
admins.clearTableSelectedSet();
boolean isMembersGroup = group.isCoreGroup();
menu.addWidget(0, UiElements.getRefreshButton(this));
// Events for reloading when finished
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(admins);
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeManagerFromGroup());
if (!isMembersGroup) {
CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerToGroup(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AddGroupManagerTabItem(group), true);
}
});
if (!session.isVoAdmin(group.getVoId()) && !session.isGroupAdmin(group.getId()))
addButton.setEnabled(false);
menu.addWidget(1, addButton);
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<User> itemsToRemove = admins.getTableSelectedList();
String text = "Following users won't be group managers anymore.";
UiElements.showDeleteConfirm(itemsToRemove, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < itemsToRemove.size(); i++) {
RemoveAdmin request;
if (i == itemsToRemove.size() - 1) {
request = new RemoveAdmin(PerunEntity.GROUP, JsonCallbackEvents.disableButtonEvents(removeButton, events));
} else {
request = new RemoveAdmin(PerunEntity.GROUP, JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.removeGroupAdmin(group, itemsToRemove.get(i));
}
}
});
}
});
menu.addWidget(2, removeButton);
} else {
// is core group
menu.addWidget(1, new Image(SmallIcons.INSTANCE.helpIcon()));
Anchor a = new Anchor("<strong>To edit VO managers use VO manager section in menu.</strong>", true);
a.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().addTab(new VoManagersTabItem(group.getVoId()));
}
});
menu.addWidget(2, a);
}
// get the table
CellTable<User> table;
if (session.isPerunAdmin()) {
table = admins.getTable(new FieldUpdater<User, String>() {
public void update(int i, User user, String s) {
session.getTabManager().addTab(new UserDetailTabItem(user));
}
});
} else {
table = admins.getTable();
}
removeButton.setEnabled(false);
if (session.isVoAdmin(group.getVoId()) || session.isGroupAdmin(group.getId())) {
JsonUtils.addTableManagedButton(admins, table, removeButton);
}
table.setStyleName("perun-table");
return table;
}
use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.
the class GroupRelationsTabItem method draw.
@Override
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": unions");
// main panel
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// if members group, hide
if (group.isCoreGroup()) {
vp.add(new HTML("<h2>Members group cannot have unions.</h2>"));
this.contentWidget.setWidget(vp);
return getWidget();
}
final GetGroupUnions unions = new GetGroupUnions(group, false);
// Events for reloading when group is created
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(unions);
// menu
TabMenu menu = new TabMenu();
final CheckBox subGroupsCheckBox = new CheckBox("Show sub-groups");
final ListBox reverseDropdown = new ListBox();
reverseDropdown.addItem("Normal");
reverseDropdown.addItem("Reverse");
reverseDropdown.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
switch(reverseDropdown.getSelectedIndex()) {
case 1:
unions.setReverseAndRefresh(true);
subGroupsCheckBox.setVisible(false);
break;
default:
unions.setReverseAndRefresh(false);
subGroupsCheckBox.setVisible(true);
}
}
});
menu.addWidget(UiElements.getRefreshButton(this));
CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addGroupUnion(), new ClickHandler() {
public void onClick(ClickEvent event) {
// creates a new form
session.getTabManager().addTabToCurrentTab(new AddGroupUnionTabItem(group), true);
}
});
if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId())) {
createButton.setEnabled(false);
unions.setCheckable(false);
}
menu.addWidget(createButton);
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeGroupUnion());
removeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<Group> itemsToRemove = unions.getTableSelectedList();
String text = "Following group unions will be deleted.";
UiElements.showDeleteConfirm(itemsToRemove, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
RemoveGroupUnions request = new RemoveGroupUnions(JsonCallbackEvents.disableButtonEvents(removeButton, events));
if (unions.isReverse()) {
request.deleteGroupUnions(itemsToRemove, group);
} else {
request.deleteGroupUnions(group, itemsToRemove);
}
}
});
}
});
menu.addWidget(removeButton);
// filter box
final ExtendedSuggestBox box = new ExtendedSuggestBox(unions.getOracle());
menu.addFilterWidget(box, new PerunSearchEvent() {
public void searchFor(String text) {
unions.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterGroup());
subGroupsCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
unions.setShowSubgroupsAndRefresh(valueChangeEvent.getValue(), box.getSuggestBox().getText());
}
});
menu.addWidget(new HTML("<strong>Direction: </strong>"));
menu.addWidget(reverseDropdown);
menu.addWidget(subGroupsCheckBox);
// add menu to the main panel
vp.add(menu);
vp.setCellHeight(menu, "30px");
CellTable<Group> table = unions.getTable(new FieldUpdater<Group, String>() {
@Override
public void update(int arg0, Group group, String arg2) {
if (session.isGroupAdmin(group.getId()) || session.isVoAdmin(group.getId())) {
session.getTabManager().addTab(new GroupDetailTabItem(group.getId()));
} else {
UiElements.generateInfo("Not privileged", "You are not manager of selected group or its VO.");
}
}
});
removeButton.setEnabled(false);
if (session.isGroupAdmin(groupId) || session.isVoAdmin(group.getVoId()))
JsonUtils.addTableManagedButton(unions, table, removeButton);
// adds the table into the panel
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.
the class CreateFacilityResourceTabItem method draw.
public Widget draw() {
titleWidget.setText("Create resource");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// form inputs
final ExtendedTextBox nameTextBox = new ExtendedTextBox();
final TextBox descriptionTextBox = new TextBox();
final ListBoxWithObjects<VirtualOrganization> vosDropDown = new ListBoxWithObjects<VirtualOrganization>();
// send button
final CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, ButtonTranslation.INSTANCE.createResource());
// local events fills the listbox of Vos and Slds
JsonCallbackEvents event = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// fill VOs listbox
vosDropDown.clear();
ArrayList<VirtualOrganization> vos = JsonUtils.jsoAsList(jso);
vos = new TableSorter<VirtualOrganization>().sortByName(vos);
for (VirtualOrganization vo : vos) {
vosDropDown.addItem(vo);
}
if (!vos.isEmpty())
createButton.setEnabled(true);
}
@Override
public void onLoadingStart() {
vosDropDown.clear();
vosDropDown.addItem("Loading...");
createButton.setEnabled(false);
}
@Override
public void onError(PerunError error) {
vosDropDown.clear();
vosDropDown.addItem("Error while loading");
createButton.setEnabled(false);
}
};
// load available VOs
final GetVos vos = new GetVos(event);
vos.setForceAll(true);
vos.retrieveData();
// layout
FlexTable layout = new FlexTable();
layout.setStyleName("inputFormFlexTable");
FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
// Add some standard form options
layout.setHTML(0, 0, "On facility:");
layout.setHTML(0, 1, facility.getName());
layout.setHTML(1, 0, "For VO:");
layout.setWidget(1, 1, vosDropDown);
layout.setHTML(2, 0, "Name:");
layout.setWidget(2, 1, nameTextBox);
layout.setHTML(3, 0, "Description:");
layout.setWidget(3, 1, descriptionTextBox);
for (int i = 0; i < layout.getRowCount(); i++) {
cellFormatter.addStyleName(i, 0, "itemName");
}
layout.setWidth("350px");
TabMenu menu = new TabMenu();
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;
}
};
nameTextBox.setValidator(validator);
createButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// loads new tab when creating successful, also disable button
JsonCallbackEvents localEvents = new JsonCallbackEvents() {
public void onLoadingStart() {
(JsonCallbackEvents.disableButtonEvents(createButton)).onLoadingStart();
}
public void onFinished(JavaScriptObject jso) {
(JsonCallbackEvents.disableButtonEvents(createButton)).onFinished(jso);
Resource res = (Resource) jso;
session.getTabManager().addTabToCurrentTab(new CreateFacilityResourceManageServicesTabItem(facility, res), true);
}
public void onError(PerunError error) {
(JsonCallbackEvents.disableButtonEvents(createButton)).onError(error);
}
};
if (validator.validateTextBox()) {
// request
CreateResource request = new CreateResource(localEvents);
request.createResource(nameTextBox.getTextBox().getText().trim(), descriptionTextBox.getText().trim(), facility.getId(), vosDropDown.getSelectedObject().getId());
}
}
});
menu.addWidget(createButton);
final TabItem tab = this;
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
vp.add(layout);
vp.add(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.
the class ResourceAssignedGroupsTabItem method draw.
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(resource.getName()) + ": manage assigned groups");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
final GetAssignedGroups resourceGroups = new GetAssignedGroups(resourceId);
final JsonCallbackEvents localEvents = JsonCallbackEvents.refreshTableEvents(resourceGroups);
CustomButton assignGroupButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.assignGroupToResource(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AssignGroupTabItem(resource), true);
}
});
final CustomButton removeGroupButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeGroupFromResource());
removeGroupButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<Group> groupsForRemoving = resourceGroups.getTableSelectedList();
String text = "Following groups will be removed from resource.";
UiElements.showDeleteConfirm(groupsForRemoving, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
RemoveGroupsFromResource request = new RemoveGroupsFromResource(JsonCallbackEvents.disableButtonEvents(removeGroupButton, localEvents));
request.removeGroupsFromResource(groupsForRemoving, resource);
}
});
}
});
if (!session.isVoAdmin(resource.getVoId())) {
resourceGroups.setCheckable(false);
assignGroupButton.setEnabled(false);
}
menu.addWidget(assignGroupButton);
menu.addWidget(removeGroupButton);
menu.addFilterWidget(new ExtendedSuggestBox(resourceGroups.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
resourceGroups.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterGroup());
// display menu to vo admin only
if (session.isVoAdmin(resource.getVoId())) {
resourceGroups.setCheckable(true);
vp.add(menu);
vp.setCellHeight(menu, "30px");
} else {
resourceGroups.setCheckable(false);
}
// table with field updater which leads to group detail
CellTable<Group> table = resourceGroups.getTable(new FieldUpdater<Group, String>() {
public void update(int index, Group object, String value) {
session.getTabManager().addTab(new GroupDetailTabItem(object));
}
});
removeGroupButton.setEnabled(false);
if (session.isVoAdmin(resource.getVoId()))
JsonUtils.addTableManagedButton(resourceGroups, table, removeGroupButton);
table.addStyleName("perun-table");
table.setWidth("100%");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
Aggregations