use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.
the class VoManagersTabItem method fillContentUsers.
private Widget fillContentUsers(final GetRichAdminsWithAttributes admins, TabMenu menu) {
admins.clearTableSelectedSet();
// refresh
menu.addWidget(0, UiElements.getRefreshButton(this));
// Events for reloading when finished
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(admins);
CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerToVo(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AddVoManagerTabItem(vo), true);
}
});
if (!session.isVoAdmin(voId))
addButton.setEnabled(false);
menu.addWidget(1, addButton);
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeManagerFromVo());
menu.addWidget(2, removeButton);
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<User> adminsForRemoving = admins.getTableSelectedList();
String text = "Following users won't be VO managers anymore.";
UiElements.showDeleteConfirm(adminsForRemoving, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < adminsForRemoving.size(); i++) {
RemoveAdmin request;
if (i == adminsForRemoving.size() - 1) {
request = new RemoveAdmin(PerunEntity.VIRTUAL_ORGANIZATION, JsonCallbackEvents.disableButtonEvents(removeButton, events));
} else {
request = new RemoveAdmin(PerunEntity.VIRTUAL_ORGANIZATION, JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.removeVoAdmin(vo, adminsForRemoving.get(i));
}
}
});
}
});
// 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();
}
// add a class to the table and wrap it into scroll panel
table.addStyleName("perun-table");
removeButton.setEnabled(false);
if (session.isVoAdmin(voId))
JsonUtils.addTableManagedButton(admins, table, removeButton);
return table;
}
use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.
the class PerunAttributeTableWidget method build.
/**
* Builds the table
*/
public void build() {
ft.clear(true);
if (!dark) {
ft.setStyleName("inputFormFlexTable");
} else {
ft.setStyleName("inputFormFlexTableDark");
}
int nameCol = 0;
int valCol = 1;
int descCol = -1;
if (descriptionShown) {
nameCol = 0;
descCol = 2;
valCol = 1;
}
int row = 0;
final Map<Attribute, PerunAttributeValueCell> valueCells = new HashMap<Attribute, PerunAttributeValueCell>();
// save button
saveButton = TabMenu.getPredefinedButton(ButtonType.SAVE, "Save changes");
saveButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// saving
ArrayList<Attribute> newAttributes = new ArrayList<Attribute>();
// for each find
for (Map.Entry<Attribute, PerunAttributeValueCell> entry : valueCells.entrySet()) {
Attribute attrOld = entry.getKey();
PerunAttributeValueCell valueCell = entry.getValue();
// save the value
Attribute attr = valueCell.getValue(attrOld);
newAttributes.add(attr);
}
save(newAttributes);
}
});
if (displaySaveButton) {
ft.setWidget(row, 0, saveButton);
row++;
}
for (Attribute attr : attributes) {
PerunAttributeNameCell nameCell = new PerunAttributeNameCell();
PerunAttributeValueCell valueCell = new PerunAttributeValueCell();
// name
SafeHtml nameCellHtml = nameCell.getRenderer().render(attr);
ft.setHTML(row, nameCol, nameCellHtml.asString() + "<strong>:</strong>");
ft.getFlexCellFormatter().setStyleName(row, nameCol, "itemName");
// value
SafeHtml valueCellHtml = valueCell.getRenderer().render(attr);
ft.setHTML(row, valCol, valueCellHtml);
valueCells.put(attr, valueCell);
// description
if (descriptionShown) {
PerunAttributeDescriptionCell descCell = new PerunAttributeDescriptionCell();
SafeHtml descCellHtml = descCell.getRenderer().render(attr);
ft.setHTML(row, descCol, descCellHtml);
}
row++;
}
}
use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.
the class VoOverviewTabItem method draw.
public Widget draw() {
// main panel
ScrollPanel scroll = new ScrollPanel();
final VerticalPanel vp2 = new VerticalPanel();
vp2.setStyleName("perun-table");
scroll.setWidget(vp2);
scroll.setStyleName("perun-tableScrollPanel");
vp2.setSpacing(5);
// tools panel
final DisclosurePanel tools = new DisclosurePanel();
tools.setWidth("100%");
tools.setOpen(true);
FlexTable toolsHeader = new FlexTable();
toolsHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.settingToolsIcon()));
toolsHeader.setWidget(0, 1, new HTML("<h3>Quick tools</h3>"));
toolsHeader.setTitle("Click to show/hide VO quick tools");
tools.setHeader(toolsHeader);
// tools panel content
FlexTable toolsLayout = new FlexTable();
toolsLayout.setSize("100%", "100%");
toolsLayout.setCellSpacing(5);
tools.setContent(toolsLayout);
toolsLayout.getFlexCellFormatter().setWidth(0, 0, "220px");
toolsLayout.getFlexCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(1, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(1, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(2, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(2, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(3, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(3, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(4, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(4, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(5, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(5, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(6, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(6, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
CustomButton addMember = new CustomButton(ButtonTranslation.INSTANCE.addMemberButton() + "…", ButtonTranslation.INSTANCE.addMemberToVo(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new AddMemberToVoTabItem(vo), true);
}
});
CustomButton addServiceMember = new CustomButton(ButtonTranslation.INSTANCE.createServiceMemberButton() + "…", ButtonTranslation.INSTANCE.createServiceMember(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new CreateServiceMemberInVoTabItem(vo));
}
});
CustomButton inviteUser = new CustomButton("Invite member…", "Invite person to become member of your Virtual organization.", SmallIcons.INSTANCE.emailAddIcon(), new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new InviteUserTabItem(vo, null));
}
});
CustomButton addManager = new CustomButton(ButtonTranslation.INSTANCE.addManagerButton() + "…", ButtonTranslation.INSTANCE.addManagerToVo(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new AddVoManagerTabItem(vo), true);
}
});
CustomButton createGroup = new CustomButton(ButtonTranslation.INSTANCE.createGroupButton() + "…", ButtonTranslation.INSTANCE.createGroup(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new CreateGroupTabItem(vo));
}
});
CustomButton addToResource = new CustomButton(ButtonTranslation.INSTANCE.addMemberToResourceButton() + "…", ButtonTranslation.INSTANCE.addMemberToResource(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new AddMemberToResourceTabItem(vo), true);
}
});
toolsLayout.setWidget(0, 0, addMember);
toolsLayout.setWidget(1, 0, addServiceMember);
toolsLayout.setWidget(2, 0, inviteUser);
toolsLayout.setWidget(3, 0, addManager);
toolsLayout.setWidget(4, 0, createGroup);
toolsLayout.setWidget(5, 0, addToResource);
if (!session.isVoAdmin(voId))
addMember.setEnabled(false);
if (!session.isVoAdmin(voId))
addServiceMember.setEnabled(false);
if (!session.isVoAdmin(voId))
inviteUser.setEnabled(false);
if (!session.isVoAdmin(voId))
addManager.setEnabled(false);
if (!session.isVoAdmin(voId))
createGroup.setEnabled(false);
if (!session.isVoAdmin(voId))
addToResource.setEnabled(false);
toolsLayout.setHTML(0, 1, "Add new member into your VO. Candidates can be searched for in VO's external sources or among user already existing in Perun.");
toolsLayout.setHTML(1, 1, "Create new member which represent service account (account usually used by more users with separate login and password).");
toolsLayout.setHTML(2, 1, "Invite person to become member of your Virtual organization.");
toolsLayout.setHTML(3, 1, "Add new manager which can manage your VO in Perun.");
toolsLayout.setHTML(4, 1, "Create new group in your VO.");
toolsLayout.setHTML(5, 1, "Add selected member to specific resource (grant some type of access to Facility resources).");
vp2.add(tools);
// statistics - json
// call the request for number of members
final GetMembersCount countMembers = new GetMembersCount(vo.getId(), null);
final GetMembersCount countValidMembers = new GetMembersCount(vo.getId(), PerunStatus.VALID);
final GetMembersCount countInvalidMembers = new GetMembersCount(vo.getId(), PerunStatus.INVALID);
final GetMembersCount countSuspendedMembers = new GetMembersCount(vo.getId(), PerunStatus.SUSPENDED);
final GetMembersCount countExpiredMembers = new GetMembersCount(vo.getId(), PerunStatus.EXPIRED);
final GetMembersCount countDisabledMembers = new GetMembersCount(vo.getId(), PerunStatus.DISABLED);
// call the request for number of resources
final GetResourcesCount countResources = new GetResourcesCount(vo.getId());
// call the request for number of groups
final GetGroupsCount countGroups = new GetGroupsCount(vo.getId());
// statistics
final DisclosurePanel statistics = new DisclosurePanel();
statistics.setWidth("100%");
//statistics.setOpen(true);
FlexTable statHeader = new FlexTable();
statHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.statisticsIcon()));
statHeader.setWidget(0, 1, new HTML("<h3>Statistics</h3>"));
statHeader.setTitle("Click to show/hide VO statistics");
statistics.setHeader(statHeader);
final FlexTable vosTable = new FlexTable();
vosTable.addStyleName("statisticsTable");
statHeader.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (statistics.getContent() == null) {
countMembers.retrieveData();
countValidMembers.retrieveData();
countInvalidMembers.retrieveData();
countSuspendedMembers.retrieveData();
countExpiredMembers.retrieveData();
countDisabledMembers.retrieveData();
countResources.retrieveData();
countGroups.retrieveData();
statistics.setContent(vosTable);
}
}
});
vosTable.setWidget(0, 0, new HTML("<strong>" + "Members" + "</strong>"));
vosTable.setWidget(0, 1, countMembers.getMembersCountLabel());
vosTable.setWidget(1, 0, new HTML(" - valid"));
vosTable.setWidget(1, 1, countValidMembers.getMembersCountLabel());
vosTable.setWidget(2, 0, new HTML(" - invalid"));
vosTable.setWidget(2, 1, countInvalidMembers.getMembersCountLabel());
vosTable.setWidget(3, 0, new HTML(" - suspended"));
vosTable.setWidget(3, 1, countSuspendedMembers.getMembersCountLabel());
vosTable.setWidget(4, 0, new HTML(" - expired"));
vosTable.setWidget(4, 1, countExpiredMembers.getMembersCountLabel());
vosTable.setWidget(5, 0, new HTML(" - disabled"));
vosTable.setWidget(5, 1, countDisabledMembers.getMembersCountLabel());
vosTable.setWidget(6, 0, new HTML("<strong>" + "Resources" + "</strong>"));
vosTable.setWidget(6, 1, countResources.getResourcesCountLabel());
vosTable.setWidget(7, 0, new HTML("<strong>" + "Groups" + "</strong>"));
vosTable.setWidget(7, 1, countGroups.getGroupsCountLabel());
vp2.add(statistics);
session.getUiElements().resizeSmallTabPanel(scroll, 350, this);
contentWidget.setWidget(scroll);
return getWidget();
}
use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.
the class VosSelectTabItem method draw.
public Widget draw() {
// MAIN PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// Get vos request
final GetVos getVos = new GetVos();
getVos.setCheckable(false);
TabMenu tabMenu = new TabMenu();
tabMenu.addWidget(UiElements.getRefreshButton(this));
// add menu to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
if (session.isVoAdmin()) {
// do not display to VO observer
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createVo(), new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new CreateVoTabItem());
}
}));
}
// filter
tabMenu.addFilterWidget(new ExtendedSuggestBox(getVos.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
getVos.filterTable(text);
}
}, buttonTranslation.filterVo());
tabMenu.addWidget(new Image(SmallIcons.INSTANCE.helpIcon()));
tabMenu.addWidget(new HTML("<strong>Please select VO you want to manage.</strong>"));
final TabItem tab = this;
// get the table with custom onclick
CellTable<VirtualOrganization> table = getVos.getTable(new FieldUpdater<VirtualOrganization, VirtualOrganization>() {
@Override
public void update(int i, VirtualOrganization virtualOrganization, VirtualOrganization virtualOrganization2) {
session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
session.getTabManager().closeTab(tab, false);
}
});
// 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 the table to the main panel
firstTabPanel.add(sp);
session.getUiElements().resizePerunTable(sp, 350, 0, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.
the class PreferredShellsWidget method buildWidget.
/**
* Rebuild widget based on current attribute value
*/
public void buildWidget() {
shellList.clear();
customMap.clear();
layout = new FlexTable();
setStyleName("preferredShellWidget");
if (!a.getValue().equalsIgnoreCase("null")) {
for (int i = 0; i < a.getValueAsJsArray().length(); i++) {
final ListBox list = new ListBox();
final ExtendedTextBox customValue = new ExtendedTextBox();
list.setEnabled(a.isWritable());
customValue.getTextBox().setEnabled((a.isWritable()));
customValue.setValidator(new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
// on change calculate value
calculateAttrValue();
return true;
}
});
addRow(list, customValue, a.getValueAsJsArray().get(i));
CustomButton removeButton = new CustomButton("", SmallIcons.INSTANCE.deleteIcon(), new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
shellList.remove(list);
customMap.remove(list);
calculateAttrValue();
buildWidget();
}
});
removeButton.setEnabled(a.isWritable());
// fill table
int rowId = layout.getRowCount();
layout.setWidget(rowId, 0, list);
layout.setWidget(rowId, 1, customValue);
layout.setWidget(rowId, 2, removeButton);
}
}
// button
final int rowId = layout.getRowCount();
final CustomButton addButton = new CustomButton("", SmallIcons.INSTANCE.addIcon(), new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ListBox list = new ListBox();
final ExtendedTextBox customValue = new ExtendedTextBox();
customValue.setValidator(new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
// on change calculate value
calculateAttrValue();
return true;
}
});
// add to values map
addRow(list, customValue, null);
// add to persistent storage
calculateAttrValue();
// rebuild widget
buildWidget();
}
});
addButton.setEnabled(a.isWritable());
layout.setWidget(rowId, 0, addButton);
widget.setWidget(layout);
}
Aggregations