use of cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent in project perun by CESNET.
the class MemberAddToGroupTabItem method draw.
public Widget draw() {
this.titleWidget.setText("Add to group(s)");
// main widget panel
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
final GetAllGroups groups = new GetAllGroups(member.getVoId());
menu.addFilterWidget(new ExtendedSuggestBox(groups.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
groups.filterTable(text);
if (groups.getList().size() == 1) {
// select if filtered result is single group
groups.getSelectionModel().setSelected(groups.getList().get(0), true);
}
}
}, "Filter groups by name");
final TabItem tab = this;
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, "Add member to selected group(s)");
addButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
ArrayList<Group> list = groups.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
// TODO - should have only one callback to core
for (int i = 0; i < list.size(); i++) {
final Group g = list.get(i);
AddMember request = new AddMember(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
groups.getSelectionModel().setSelected(g, false);
alreadyAddedList.add(g);
rebuildAlreadyAddedWidget();
}
}));
request.addMemberToGroup(g, member);
}
}
}
});
menu.addWidget(addButton);
addButton.setEnabled(false);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().closeTab(tab, false);
}
}));
CellTable<Group> table = groups.getTable();
JsonUtils.addTableManagedButton(groups, table, addButton);
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizePerunTable(sp, 350, this);
rebuildAlreadyAddedWidget();
vp.add(alreadyAdded);
vp.add(sp);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent in project perun by CESNET.
the class ExtSourcesTabItem method draw.
public Widget draw() {
// create main panel for content
VerticalPanel mainPage = new VerticalPanel();
mainPage.setWidth("100%");
// create new instance for jsonCall getExtSources
final GetExtSources getExtSources = new GetExtSources();
getExtSources.setCheckable(false);
// menu
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
menu.addFilterWidget(new ExtendedSuggestBox(getExtSources.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
getExtSources.filterTable(text);
}
}, "Filter external sources by name or type");
final CustomButton loadButton = new CustomButton("Load ext sources", "Load ext sources definitions from a local file.", SmallIcons.INSTANCE.worldIcon());
loadButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
LoadExtSourcesDefinitions loadCall = new LoadExtSourcesDefinitions(JsonCallbackEvents.disableButtonEvents(loadButton, JsonCallbackEvents.refreshTableEvents(getExtSources)));
loadCall.retrieveData();
}
});
menu.addWidget(loadButton);
// get CellTable from jsonCall
CellTable<ExtSource> extSourcesTable = getExtSources.getTable();
extSourcesTable.setStyleName("perun-table");
ScrollPanel scrollTable = new ScrollPanel(extSourcesTable);
scrollTable.addStyleName("perun-tableScrollPanel");
// put page into scroll panel
mainPage.add(menu);
mainPage.setCellHeight(menu, "30px");
mainPage.add(scrollTable);
session.getUiElements().resizePerunTable(scrollTable, 350, this);
this.contentWidget.setWidget(mainPage);
return getWidget();
}
use of cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent in project perun by CESNET.
the class FacilitiesTabItem method draw.
public Widget draw() {
// MAIN PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// TAB MENU
TabMenu tabMenu = new TabMenu();
tabMenu.addWidget(UiElements.getRefreshButton(this));
// get RICH facilities request
final GetFacilities facilities = new GetFacilities(true);
// retrieve data (table)
final CellTable<Facility> table = facilities.getTable(new FieldUpdater<Facility, String>() {
public void update(int index, Facility object, String value) {
session.getTabManager().addTab(new FacilityDetailTabItem(object));
}
});
// add new facility button
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createFacility(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTab(new CreateFacilityTabItem());
}
}));
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(facilities);
// add delete facilities button
final CustomButton deleteButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteFacilities());
tabMenu.addWidget(deleteButton);
deleteButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<Facility> list = facilities.getTableSelectedList();
String text = "Following facilities will be deleted.";
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) {
DeleteFacility request = new DeleteFacility(JsonCallbackEvents.disableButtonEvents(deleteButton, events));
request.deleteFacility(list.get(i).getId());
} else {
DeleteFacility request = new DeleteFacility(JsonCallbackEvents.disableButtonEvents(deleteButton));
request.deleteFacility(list.get(i).getId());
}
}
}
});
}
});
// filter box
tabMenu.addFilterWidget(new ExtendedSuggestBox(facilities.getOracle()), new PerunSearchEvent() {
public void searchFor(String text) {
facilities.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterFacilities());
deleteButton.setEnabled(false);
JsonUtils.addTableManagedButton(facilities, table, deleteButton);
// 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(sp);
firstTabPanel.setCellHeight(sp, "100%");
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent 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 cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent 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();
}
Aggregations