use of cz.metacentrum.perun.webgui.widgets.CustomButton in project perun by CESNET.
the class GroupsResourceRequiredAttributesTabItem method draw.
public Widget draw() {
if (groups == null || groups.get(0) == null) {
Window.alert("No groups in list.");
}
if (JsonUtils.isExtendedInfoVisible()) {
columnId = 3;
} else {
columnId = 2;
}
final VerticalPanel mainTab = new VerticalPanel();
mainTab.setSize("100%", "100%");
TabMenu menu = new TabMenu();
mainTab.add(new HTML("<hr size=\"2px\" />"));
// set attributes type to group_resource
final Map<String, Integer> ids = new HashMap<String, Integer>();
ids.put("resourceToGetServicesFrom", resourceId);
ids.put("group", groups.get(0).getId());
// gets all required group attributes for specified group and resource
final GetResourceRequiredAttributesV2 reqAttrs = new GetResourceRequiredAttributesV2(ids);
final CellTable<Attribute> reqAttrsTable = reqAttrs.getTable();
// remove value column
reqAttrsTable.removeColumn(columnId);
// create own value column
Column<Attribute, Attribute> valueColumn = JsonUtils.addColumn(new PerunAttributeValueCell(), "Value", new JsonUtils.GetValue<Attribute, Attribute>() {
public Attribute getValue(Attribute attribute) {
// set empty value
attribute.setValueAsJso(null);
return attribute;
}
}, new FieldUpdater<Attribute, Attribute>() {
public void update(int index, Attribute object, Attribute value) {
object = value;
reqAttrsTable.getSelectionModel().setSelected(object, object.isAttributeValid());
}
});
// add to table
reqAttrsTable.insertColumn(columnId, valueColumn, "Value");
// get all required group_resource attributes too
ids.put("resource", resourceId);
reqAttrs.setIds(ids);
reqAttrs.retrieveData();
reqAttrsTable.addStyleName("perun-table");
final ScrollPanel sp = new ScrollPanel(reqAttrsTable);
sp.addStyleName("perun-tableScrollPanel");
CustomButton saveChangesButton = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.saveChangesInAttributes(), new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Attribute> list = reqAttrs.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
ArrayList<Attribute> groupList = new ArrayList<Attribute>();
ArrayList<Attribute> groupResourceList = new ArrayList<Attribute>();
SetAttributes request = new SetAttributes();
// TODO - use new confirm dialog
if (!Window.confirm("Same values for selected attributes will be set to all groups you are about to assign." + "\n\nDo you want to continue ?")) {
return;
}
// get different attributes
for (Attribute attr : list) {
if (attr.getNamespace().contains("urn:perun:group:")) {
groupList.add(attr);
} else if (attr.getNamespace().contains("urn:perun:group_resource:")) {
groupResourceList.add(attr);
}
}
if (!(groupList.isEmpty())) {
ids.clear();
for (int i = 0; i < groups.size(); i++) {
ids.put("group", groups.get(i).getId());
request.setAttributes(ids, groupList);
}
}
if (!(groupResourceList.isEmpty())) {
ids.clear();
ids.put("resource", resourceId);
for (int i = 0; i < groups.size(); i++) {
ids.put("group", groups.get(i).getId());
request.setAttributes(ids, groupResourceList);
}
}
reqAttrs.clearTableSelectedSet();
}
}
});
menu.addWidget(UiElements.getRefreshButton(this));
menu.addWidget(saveChangesButton);
if (!session.isGroupAdmin() && !session.isVoAdmin())
saveChangesButton.setEnabled(false);
// table content
session.getUiElements().resizePerunTable(sp, 350, this);
mainTab.add(menu);
mainTab.add(sp);
mainTab.setCellHeight(sp, "100%");
mainTab.setCellHeight(menu, "30px");
this.contentWidget.setWidget(mainTab);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.CustomButton in project perun by CESNET.
the class GroupDetailTabItem method draw.
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()));
// main panel
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// The table
AbsolutePanel dp = new AbsolutePanel();
//dp.setStyleName("decoration");
final FlexTable menu = new FlexTable();
menu.setCellSpacing(5);
// Add group information
menu.setWidget(0, 0, new Image(LargeIcons.INSTANCE.groupIcon()));
Label groupName = new Label();
groupName.setText(Utils.getStrippedStringWithEllipsis(group.getName(), 40));
groupName.setStyleName("now-managing");
groupName.setTitle(group.getName());
menu.setWidget(0, 1, groupName);
final JsonCallbackEvents events = new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
new GetEntityById(PerunEntity.RICH_GROUP, groupId, new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
group = jso.cast();
open();
draw();
}
}).retrieveData();
}
};
menu.setHTML(0, 2, " ");
menu.getFlexCellFormatter().setWidth(0, 2, "25px");
int column = 3;
CustomButton change;
if (group.isCoreGroup()) {
change = new CustomButton("", "Core group's name and description can't be changed", SmallIcons.INSTANCE.applicationFormEditIcon());
change.setEnabled(false);
} else {
change = new CustomButton("", ButtonTranslation.INSTANCE.editGroupDetails(), SmallIcons.INSTANCE.applicationFormEditIcon());
}
if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId()))
change.setEnabled(false);
change.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new EditGroupDetailsTabItem(group, events));
}
});
menu.setWidget(0, column, change);
column++;
menu.setHTML(0, column, " ");
menu.getFlexCellFormatter().setWidth(0, column, "25px");
column++;
if (JsonUtils.isExtendedInfoVisible()) {
menu.setHTML(0, column, "<strong>ID:</strong><br/><span class=\"inputFormInlineComment\">" + group.getId() + "</span>");
column++;
menu.setHTML(0, column, " ");
menu.getFlexCellFormatter().setWidth(0, column, "25px");
column++;
}
/*
String text = (((RichGroup)group).isSyncEnabled()) ? "Enabled" : "Disabled";
text += (((RichGroup)group).getAuthoritativeGroup().equals("1")) ? " / Authoritative" : "";
menu.setHTML(0, column, "<strong>Sync:</strong><br/><span class=\"inputFormInlineComment\">"+text+"</span>");
column++;
*/
menu.setHTML(0, column, "<strong>Description:</strong><br/><span class=\"inputFormInlineComment\">" + group.getDescription() + " </span>");
dp.add(menu);
vp.add(dp);
vp.setCellHeight(dp, "30px");
tabPanel.clear();
tabPanel.add(new GroupMembersTabItem(group), "Members");
if (!group.isCoreGroup()) {
tabPanel.add(new SubgroupsTabItem(group), "Subgroups");
tabPanel.add(new GroupRelationsTabItem(group), "Relations");
}
tabPanel.add(new GroupResourcesTabItem(group), "Resources");
if (!group.isCoreGroup()) {
tabPanel.add(new GroupApplicationsTabItem(group), "Applications");
tabPanel.add(new GroupApplicationFormSettingsTabItem(group), "Application form");
}
tabPanel.add(new GroupSettingsTabItem(group), "Settings");
if (!group.isCoreGroup()) {
// core groups can't have managers
tabPanel.add(new GroupManagersTabItem(group), "Managers");
}
if (!group.isCoreGroup()) {
// core groups can't have ext sources
tabPanel.add(new GroupExtSourcesTabItem(group), "External sources");
}
// Resize must be called after page fully displays
Scheduler.get().scheduleDeferred(new Command() {
@Override
public void execute() {
tabPanel.finishAdding();
}
});
vp.add(tabPanel);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.CustomButton 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 cz.metacentrum.perun.webgui.widgets.CustomButton 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 cz.metacentrum.perun.webgui.widgets.CustomButton 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();
}
Aggregations