use of cz.metacentrum.perun.webgui.model.VirtualOrganization in project perun by CESNET.
the class GetAllowedVos method getTable.
/**
* Returns table widget with allowed Vos
*
* @return table widget
*/
public CellTable<VirtualOrganization> getTable() {
retrieveData();
// Table data provider.
dataProvider = new ListDataProvider<VirtualOrganization>(list);
// Cell table
table = new PerunTable<VirtualOrganization>(list);
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<VirtualOrganization> columnSortHandler = new ListHandler<VirtualOrganization>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<VirtualOrganization>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
// checkbox column column
if (checkable == true) {
table.addCheckBoxColumn();
}
VoColumnProvider columnProvider = new VoColumnProvider(table, null);
// FIXME we need field updater
IsClickableCell<GeneralObject> authz = VoColumnProvider.getDefaultClickableAuthz();
columnProvider.addIdColumn(authz, 100);
columnProvider.addShortNameColumn(authz, 200);
columnProvider.addNameColumn(authz, 0);
return table;
}
use of cz.metacentrum.perun.webgui.model.VirtualOrganization in project perun by CESNET.
the class VosTabItem method draw.
public Widget draw() {
// MAIN PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// Get vos request
final GetVos getVos = new GetVos();
// Events for reloading when finished
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(getVos);
// create new VO button
TabMenu tabMenu = new TabMenu();
tabMenu.addWidget(UiElements.getRefreshButton(this));
// add menu to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, buttonTranslation.createVo(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new CreateVoTabItem());
}
}));
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, buttonTranslation.deleteVo());
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<VirtualOrganization> itemsToRemove = getVos.getTableSelectedList();
UiElements.showDeleteConfirm(itemsToRemove, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < itemsToRemove.size(); i++) {
DeleteVo request;
if (i == itemsToRemove.size() - 1) {
request = new DeleteVo(JsonCallbackEvents.disableButtonEvents(removeButton, events));
} else {
request = new DeleteVo(JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.deleteVo(itemsToRemove.get(i).getId(), false);
}
}
});
}
});
tabMenu.addWidget(removeButton);
// filter
tabMenu.addFilterWidget(new ExtendedSuggestBox(getVos.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
getVos.filterTable(text);
}
}, buttonTranslation.filterVo());
// get the table with custom onclick
CellTable<VirtualOrganization> table = getVos.getTable(new FieldUpdater<VirtualOrganization, VirtualOrganization>() {
@Override
public void update(int index, VirtualOrganization object, VirtualOrganization value) {
session.getTabManager().addTab(new VoDetailTabItem(object));
}
});
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(getVos, table, removeButton);
// 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 cz.metacentrum.perun.webgui.model.VirtualOrganization in project perun by CESNET.
the class CopyFormTabItem method draw.
public Widget draw() {
final FlexTable content = new FlexTable();
content.setStyleName("inputFormFlexTable");
// boxes
final ListBoxWithObjects<VirtualOrganization> vosBox = new ListBoxWithObjects<VirtualOrganization>();
final ListBoxWithObjects<Group> groupsBox = new ListBoxWithObjects<Group>();
final CustomButton save;
final TabItem tab = this;
VerticalPanel vp = new VerticalPanel();
TabMenu menu = new TabMenu();
titleWidget.setText("Copy form items from VO / group");
save = TabMenu.getPredefinedButton(ButtonType.OK, ButtonTranslation.INSTANCE.copyFromVo());
// get them
final GetVos vos = new GetVos(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
vosBox.clear();
ArrayList<VirtualOrganization> vos = JsonUtils.jsoAsList(jso);
vos = new TableSorter<VirtualOrganization>().sortByName(vos);
vosBox.addAllItems(vos);
// get them
GetAllGroups getGroups = new GetAllGroups(voId, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
groupsBox.clear();
ArrayList<Group> groups = JsonUtils.jsoAsList(jso);
groups = new TableSorter<Group>().sortByName(groups);
groupsBox.addNotSelectedOption();
groupsBox.addAllItems(groups);
save.setEnabled(true);
}
@Override
public void onError(PerunError error) {
groupsBox.removeNotSelectedOption();
groupsBox.clear();
groupsBox.addItem("Error while loading");
save.setEnabled(false);
}
@Override
public void onLoadingStart() {
groupsBox.removeNotSelectedOption();
groupsBox.clear();
groupsBox.addItem("Loading...");
save.setEnabled(false);
}
});
getGroups.retrieveData();
}
@Override
public void onError(PerunError error) {
vosBox.addItem("Error while loading");
save.setEnabled(false);
}
@Override
public void onLoadingStart() {
vosBox.addItem("Loading...");
save.setEnabled(false);
}
});
vos.retrieveData();
vosBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
if (vosBox.getSelectedObject() != null) {
// get them
GetAllGroups getGroups = new GetAllGroups(vosBox.getSelectedObject().getId(), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
groupsBox.clear();
ArrayList<Group> groups = JsonUtils.jsoAsList(jso);
groups = new TableSorter<Group>().sortByName(groups);
groupsBox.addNotSelectedOption();
groupsBox.addAllItems(groups);
save.setEnabled(true);
}
@Override
public void onError(PerunError error) {
groupsBox.removeNotSelectedOption();
groupsBox.clear();
groupsBox.addItem("Error while loading");
save.setEnabled(false);
}
@Override
public void onLoadingStart() {
groupsBox.removeNotSelectedOption();
groupsBox.clear();
groupsBox.addItem("Loading...");
save.setEnabled(false);
}
});
getGroups.retrieveData();
}
}
});
content.setHTML(0, 0, "Source VO:");
content.getFlexCellFormatter().setStyleName(0, 0, "itemName");
content.setWidget(0, 1, vosBox);
content.setHTML(1, 0, "Source group:");
content.getFlexCellFormatter().setStyleName(1, 0, "itemName");
content.setWidget(1, 1, groupsBox);
save.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
CopyForm request = null;
if (groupsBox.getSelectedIndex() != 0 && voId != 0 && groupId == 0) {
// from group to VO
request = new CopyForm(PerunEntity.GROUP, groupsBox.getSelectedObject().getId(), PerunEntity.VIRTUAL_ORGANIZATION, voId, JsonCallbackEvents.closeTabDisableButtonEvents(save, tab));
} else if (groupsBox.getSelectedIndex() != 0 && voId != 0 && groupId != 0) {
// from group to group
request = new CopyForm(PerunEntity.GROUP, groupsBox.getSelectedObject().getId(), PerunEntity.GROUP, groupId, JsonCallbackEvents.closeTabDisableButtonEvents(save, tab));
} else if (groupsBox.getSelectedIndex() == 0 && voId != 0 && groupId == 0) {
// from VO to VO
request = new CopyForm(PerunEntity.VIRTUAL_ORGANIZATION, vosBox.getSelectedObject().getId(), PerunEntity.VIRTUAL_ORGANIZATION, voId, JsonCallbackEvents.closeTabDisableButtonEvents(save, tab));
} else if (groupsBox.getSelectedIndex() == 0 && voId != 0 && groupId != 0) {
// from VO to group
request = new CopyForm(PerunEntity.VIRTUAL_ORGANIZATION, vosBox.getSelectedObject().getId(), PerunEntity.GROUP, groupId, JsonCallbackEvents.closeTabDisableButtonEvents(save, tab));
}
request.copyForm();
}
});
content.setHTML(2, 0, "All form items will be added to yours.");
content.getFlexCellFormatter().setStyleName(2, 0, "inputFormInlineComment");
content.getFlexCellFormatter().setColSpan(2, 0, 2);
menu.addWidget(save);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
vp.add(content);
vp.add(menu);
vp.setCellHeight(menu, "30px");
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.model.VirtualOrganization in project perun by CESNET.
the class CopyMailsTabItem method draw.
public Widget draw() {
final FlexTable content = new FlexTable();
content.setStyleName("inputFormFlexTable");
// boxes
final ListBoxWithObjects<VirtualOrganization> vosBox = new ListBoxWithObjects<VirtualOrganization>();
final ListBoxWithObjects<Group> groupsBox = new ListBoxWithObjects<Group>();
final CustomButton save;
final TabItem tab = this;
VerticalPanel vp = new VerticalPanel();
TabMenu menu = new TabMenu();
titleWidget.setText("Copy form items from VO / group");
save = TabMenu.getPredefinedButton(ButtonType.OK, ButtonTranslation.INSTANCE.copyFromVo());
// get them
final GetVos vos = new GetVos(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
vosBox.clear();
ArrayList<VirtualOrganization> vos = JsonUtils.jsoAsList(jso);
vos = new TableSorter<VirtualOrganization>().sortByName(vos);
vosBox.addAllItems(vos);
// get them
GetAllGroups getGroups = new GetAllGroups(voId, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
groupsBox.clear();
ArrayList<Group> groups = JsonUtils.jsoAsList(jso);
groups = new TableSorter<Group>().sortByName(groups);
groupsBox.addNotSelectedOption();
groupsBox.addAllItems(groups);
save.setEnabled(true);
}
@Override
public void onError(PerunError error) {
groupsBox.removeNotSelectedOption();
groupsBox.clear();
groupsBox.addItem("Error while loading");
save.setEnabled(false);
}
@Override
public void onLoadingStart() {
groupsBox.removeNotSelectedOption();
groupsBox.clear();
groupsBox.addItem("Loading...");
save.setEnabled(false);
}
});
getGroups.retrieveData();
}
@Override
public void onError(PerunError error) {
vosBox.addItem("Error while loading");
save.setEnabled(false);
}
@Override
public void onLoadingStart() {
vosBox.addItem("Loading...");
save.setEnabled(false);
}
});
vos.retrieveData();
vosBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
if (vosBox.getSelectedObject() != null) {
// get them
GetAllGroups getGroups = new GetAllGroups(vosBox.getSelectedObject().getId(), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
groupsBox.clear();
ArrayList<Group> groups = JsonUtils.jsoAsList(jso);
groups = new TableSorter<Group>().sortByName(groups);
groupsBox.addNotSelectedOption();
groupsBox.addAllItems(groups);
save.setEnabled(true);
}
@Override
public void onError(PerunError error) {
groupsBox.removeNotSelectedOption();
groupsBox.clear();
groupsBox.addItem("Error while loading");
save.setEnabled(false);
}
@Override
public void onLoadingStart() {
groupsBox.removeNotSelectedOption();
groupsBox.clear();
groupsBox.addItem("Loading...");
save.setEnabled(false);
}
});
getGroups.retrieveData();
}
}
});
content.setHTML(0, 0, "Source VO:");
content.getFlexCellFormatter().setStyleName(0, 0, "itemName");
content.setWidget(0, 1, vosBox);
content.setHTML(1, 0, "Source group:");
content.getFlexCellFormatter().setStyleName(1, 0, "itemName");
content.setWidget(1, 1, groupsBox);
save.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
CopyMails request = null;
if (groupsBox.getSelectedIndex() != 0 && voId != 0 && groupId == 0) {
// from group to VO
request = new CopyMails(PerunEntity.GROUP, groupsBox.getSelectedObject().getId(), PerunEntity.VIRTUAL_ORGANIZATION, voId, JsonCallbackEvents.closeTabDisableButtonEvents(save, tab));
} else if (groupsBox.getSelectedIndex() != 0 && voId != 0 && groupId != 0) {
// from group to group
request = new CopyMails(PerunEntity.GROUP, groupsBox.getSelectedObject().getId(), PerunEntity.GROUP, groupId, JsonCallbackEvents.closeTabDisableButtonEvents(save, tab));
} else if (groupsBox.getSelectedIndex() == 0 && voId != 0 && groupId == 0) {
// from VO to VO
request = new CopyMails(PerunEntity.VIRTUAL_ORGANIZATION, vosBox.getSelectedObject().getId(), PerunEntity.VIRTUAL_ORGANIZATION, voId, JsonCallbackEvents.closeTabDisableButtonEvents(save, tab));
} else if (groupsBox.getSelectedIndex() == 0 && voId != 0 && groupId != 0) {
// from VO to group
request = new CopyMails(PerunEntity.VIRTUAL_ORGANIZATION, vosBox.getSelectedObject().getId(), PerunEntity.GROUP, groupId, JsonCallbackEvents.closeTabDisableButtonEvents(save, tab));
}
request.copyMails();
}
});
content.setHTML(2, 0, "All mail definitions will be added to yours.");
content.getFlexCellFormatter().setStyleName(2, 0, "inputFormInlineComment");
content.getFlexCellFormatter().setColSpan(2, 0, 2);
menu.addWidget(save);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
vp.add(content);
vp.add(menu);
vp.setCellHeight(menu, "30px");
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.model.VirtualOrganization in project perun by CESNET.
the class GroupsTabItem method draw.
public Widget draw() {
// main panel
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// Horizontal menu
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
//call
ArrayList<String> attrNames = new ArrayList<>();
attrNames.add("urn:perun:group:attribute-def:def:synchronizationEnabled");
attrNames.add("urn:perun:group:attribute-def:def:synchronizationInterval");
attrNames.add("urn:perun:group:attribute-def:def:lastSynchronizationState");
attrNames.add("urn:perun:group:attribute-def:def:lastSuccessSynchronizationTimestamp");
attrNames.add("urn:perun:group:attribute-def:def:lastSynchronizationTimestamp");
attrNames.add("urn:perun:group:attribute-def:def:authoritativeGroup");
final GetAllRichGroups groups = new GetAllRichGroups(voId, attrNames);
groups.setCheckable(false);
// listbox
final ListBoxWithObjects<VirtualOrganization> vos = new ListBoxWithObjects<VirtualOrganization>();
menu.addWidget(new HTML("<strong>Selected VO: </strong>"));
menu.addWidget(vos);
menu.addFilterWidget(new ExtendedSuggestBox(groups.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
groups.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterGroup());
menu.addWidget(new Image(SmallIcons.INSTANCE.helpIcon()));
menu.addWidget(new HTML("<strong>Select VO to see groups that you can manage.</strong>"));
final TabItem tab = this;
// groups table
CellTable<RichGroup> table = groups.getEmptyTable(new FieldUpdater<RichGroup, String>() {
public void update(int index, RichGroup group, String value) {
session.getTabManager().addTab(new GroupDetailTabItem(group));
// close group selection tab when group is selected
session.getTabManager().closeTab(tab, false);
}
});
// listbox change => load vo's groups
vos.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
groups.setVoId(vos.getSelectedObject().getId());
groups.clearTable();
groups.retrieveData();
}
});
// initial fill listbox and trigger groups loading
GetVos vosCall = new GetVos(new JsonCallbackEvents() {
public void onLoadingStart() {
vos.clear();
vos.addItem("Loading...");
}
public void onFinished(JavaScriptObject jso) {
vos.clear();
ArrayList<VirtualOrganization> returnedVos = JsonUtils.jsoAsList(jso);
returnedVos = new TableSorter<VirtualOrganization>().sortByName(returnedVos);
if (returnedVos == null || returnedVos.isEmpty()) {
vos.addItem("No VO available");
return;
}
// put and set selected
for (int i = 0; i < returnedVos.size(); i++) {
vos.addItem(returnedVos.get(i));
if (voId == returnedVos.get(i).getId()) {
vos.setSelected(returnedVos.get(i), true);
}
}
// trigger loading of groups for selected VO
groups.setVoId(vos.getSelectedObject().getId());
groups.clearTable();
groups.retrieveData();
}
public void onError(PerunError error) {
vos.clear();
vos.addItem("Error while loading");
}
;
});
vosCall.retrieveData();
// set width to 100%
table.setWidth("100%");
// add menu and table to the main panel
vp.add(menu);
vp.setCellHeight(menu, "30px");
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