use of cz.metacentrum.perun.webgui.widgets.TabMenu in project perun by CESNET.
the class AddVoExtSourceTabItem method draw.
public Widget draw() {
titleWidget.setText("Add external source");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// menu
TabMenu menu = new TabMenu();
final GetExtSources extSources = new GetExtSources();
// remove already assigned ext sources from offering
JsonCallbackEvents localEvents = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// second callback
final GetVoExtSources alreadyAssigned = new GetVoExtSources(voId, new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
JsArray<ExtSource> esToRemove = JsonUtils.jsoAsArray(jso);
for (int i = 0; i < esToRemove.length(); i++) {
extSources.removeFromTable(esToRemove.get(i));
}
}
});
alreadyAssigned.retrieveData();
}
};
extSources.setEvents(localEvents);
extSources.setExtSourceTypeFilter("cz.metacentrum.perun.core.impl.ExtSourceX509");
extSources.setExtSourceTypeFilter("cz.metacentrum.perun.core.impl.ExtSourceKerberos");
extSources.setExtSourceTypeFilter("cz.metacentrum.perun.core.impl.ExtSourceIdp");
final ExtendedSuggestBox box = new ExtendedSuggestBox(extSources.getOracle());
// button
final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedExtSource());
final TabItem tab = this;
assignButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<ExtSource> extSourcesToAdd = extSources.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(extSourcesToAdd)) {
// FIXME - Should have only one callback to core
for (int i = 0; i < extSourcesToAdd.size(); i++) {
final int n = i;
AddExtSource request = new AddExtSource(JsonCallbackEvents.disableButtonEvents(assignButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// unselect added person
extSources.getSelectionModel().setSelected(extSourcesToAdd.get(n), false);
alreadyAddedList.add(extSourcesToAdd.get(n));
rebuildAlreadyAddedWidget();
// clear search
box.getSuggestBox().setText("");
}
}));
request.addExtSource(voId, extSourcesToAdd.get(i).getId());
}
}
}
});
menu.addFilterWidget(box, new PerunSearchEvent() {
@Override
public void searchFor(String text) {
extSources.filterTable(text);
}
}, "Filter by ext source name or type");
menu.addWidget(assignButton);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, !alreadyAddedList.isEmpty());
}
}));
vp.add(menu);
vp.setCellHeight(menu, "30px");
vp.add(alreadyAdded);
CellTable<ExtSource> table = extSources.getTable();
assignButton.setEnabled(false);
JsonUtils.addTableManagedButton(extSources, table, assignButton);
table.addStyleName("perun-table");
table.setWidth("100%");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
// do not use resizePerunTable() when tab is in overlay - wrong width is calculated
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.TabMenu in project perun by CESNET.
the class TestDataGridTabItem method draw.
public Widget draw() {
//contentWidget.setSize("100%", "100%");
DockLayoutPanel ft = new DockLayoutPanel(Style.Unit.PX);
contentWidget.setWidget(ft);
final DataGrid gridTable = new DataGrid();
gridTable.setSize("100%", "100%");
final ArrayList<VirtualOrganization> vosList = new ArrayList<VirtualOrganization>();
final GetVos getVos = new GetVos(new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
vosList.addAll(new TableSorter<VirtualOrganization>().sortByName(JsonUtils.<VirtualOrganization>jsoAsList(jso)));
gridTable.setRowData(vosList);
gridTable.redraw();
}
});
getVos.retrieveData();
gridTable.setSelectionModel(new MultiSelectionModel<VirtualOrganization>(new GeneralKeyProvider<VirtualOrganization>()));
final SelectionModel<VirtualOrganization> selectionModel = gridTable.getSelectionModel();
Column<VirtualOrganization, Boolean> checkBoxColumn = new Column<VirtualOrganization, Boolean>(new CheckboxCell(true, true)) {
@Override
public Boolean getValue(VirtualOrganization object) {
// Get the value from the selection model.
return selectionModel.isSelected(object);
}
};
checkBoxColumn.setFieldUpdater(new FieldUpdater<VirtualOrganization, Boolean>() {
@Override
public void update(int i, VirtualOrganization virtualOrganization, Boolean aBoolean) {
selectionModel.setSelected(virtualOrganization, aBoolean);
}
});
// Checkbox column header
CheckboxCell cb = new CheckboxCell();
Header<Boolean> checkBoxHeader = new Header<Boolean>(cb) {
public Boolean getValue() {
//return true to see a checked checkbox.
return false;
}
};
checkBoxHeader.setUpdater(new ValueUpdater<Boolean>() {
public void update(Boolean value) {
// sets selected to all, if value = true, unselect otherwise
for (VirtualOrganization obj : vosList) {
selectionModel.setSelected(obj, value);
}
}
});
gridTable.addColumn(checkBoxColumn, checkBoxHeader, checkBoxHeader);
gridTable.setColumnWidth(checkBoxColumn, 40.0, Style.Unit.PX);
TextColumn<VirtualOrganization> idColumn = new TextColumn<VirtualOrganization>() {
@Override
public String getValue(VirtualOrganization object) {
return String.valueOf(object.getId());
}
};
gridTable.addColumn(idColumn, "Id", "Id");
gridTable.setColumnWidth(idColumn, "90px");
Column<VirtualOrganization, String> nameColumn = JsonUtils.addColumn(new JsonUtils.GetValue<VirtualOrganization, String>() {
public String getValue(VirtualOrganization object) {
return object.getName();
}
}, new FieldUpdater<VirtualOrganization, String>() {
@Override
public void update(int i, VirtualOrganization virtualOrganization, String s) {
session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
}
});
gridTable.addColumn(nameColumn, "Name", "Name");
TextColumn<VirtualOrganization> shortnameColumn = new TextColumn<VirtualOrganization>() {
@Override
public String getValue(VirtualOrganization object) {
return object.getShortName();
}
};
gridTable.addColumn(shortnameColumn, "Short name", "Short name");
shortnameColumn.setFieldUpdater(new FieldUpdater<VirtualOrganization, String>() {
@Override
public void update(int i, VirtualOrganization virtualOrganization, String s) {
session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
}
});
idColumn.setFieldUpdater(new FieldUpdater<VirtualOrganization, String>() {
@Override
public void update(int i, VirtualOrganization virtualOrganization, String s) {
session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
}
});
nameColumn.setFieldUpdater(new FieldUpdater<VirtualOrganization, String>() {
@Override
public void update(int i, VirtualOrganization virtualOrganization, String s) {
session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
}
});
TabMenu tabMenu = new TabMenu();
// CREATE & DELETE ONLY WITH PERUN ADMIN
if (session.isPerunAdmin()) {
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, ButtonTranslation.INSTANCE.createVo(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new CreateVoTabItem());
}
}));
final cz.metacentrum.perun.webgui.widgets.CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteVo());
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<VirtualOrganization> itemsToRemove = getVos.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(itemsToRemove)) {
VerticalPanel removePanel = new VerticalPanel();
removePanel.add(new Label("These VOs will be removed:"));
for (int i = 0; i < itemsToRemove.size(); i++) {
VirtualOrganization vo = itemsToRemove.get(i);
removePanel.add(new Label(" - " + vo.getName()));
}
// confirmation
Confirm c = new Confirm("Remove VOs", removePanel, new ClickHandler() {
public void onClick(ClickEvent event) {
for (int i = 0; i < itemsToRemove.size(); i++) {
DeleteVo request;
// if last, refresh
if (i == itemsToRemove.size() - 1) {
request = new DeleteVo(JsonCallbackEvents.disableButtonEvents(removeButton));
} else {
request = new DeleteVo(JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.deleteVo(itemsToRemove.get(i).getId(), false);
}
getVos.clearTableSelectedSet();
}
}, true);
c.show();
}
}
});
tabMenu.addWidget(removeButton);
}
// filter
tabMenu.addFilterWidget(new ExtendedSuggestBox(getVos.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
getVos.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterVo());
ft.addNorth(tabMenu, 50);
ft.add(gridTable);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.TabMenu in project perun by CESNET.
the class VoResourcesTabItem method draw.
public Widget draw() {
// set title
titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": resources");
// main panel
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu menu = new TabMenu();
// refresh
menu.addWidget(UiElements.getRefreshButton(this));
// get VO resources
final GetRichResources resources = new GetRichResources(voId);
if (!session.isVoAdmin(voId))
resources.setCheckable(false);
// custom events for viewResource
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(resources);
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteResource());
menu.addWidget(removeButton);
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<RichResource> resourcesForDeleting = resources.getTableSelectedList();
String text = "Following resources will be deleted and VO members won't be able to access them anymore.";
UiElements.showDeleteConfirm(resourcesForDeleting, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < resourcesForDeleting.size(); i++) {
DeleteResource request;
if (i == resourcesForDeleting.size() - 1) {
request = new DeleteResource(JsonCallbackEvents.disableButtonEvents(removeButton, events));
} else {
request = new DeleteResource(JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.deleteResource(resourcesForDeleting.get(i).getId());
}
}
});
}
});
// add menu to the main panel
vp.add(menu);
vp.setCellHeight(menu, "30px");
// filter box
menu.addFilterWidget(new ExtendedSuggestBox(resources.getOracle()), new PerunSearchEvent() {
public void searchFor(String text) {
resources.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterResources());
CellTable<RichResource> table = resources.getTable(new FieldUpdater<RichResource, String>() {
public void update(int index, RichResource object, String value) {
session.getTabManager().addTab(new ResourceDetailTabItem(object, 0));
}
});
removeButton.setEnabled(false);
if (session.isVoAdmin(voId))
JsonUtils.addTableManagedButton(resources, table, removeButton);
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();
}
use of cz.metacentrum.perun.webgui.widgets.TabMenu in project perun by CESNET.
the class VoResourcesTagsTabItem method draw.
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": resources tags");
// MAIN PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu menu = new TabMenu();
// refresh
menu.addWidget(UiElements.getRefreshButton(this));
// members request
final GetAllResourcesTags resTags = new GetAllResourcesTags(PerunEntity.VIRTUAL_ORGANIZATION, voId);
if (!session.isVoAdmin(voId))
resTags.setCheckable(false);
if (session.isVoAdmin(voId))
resTags.setEditable(true);
// Events for reloading when finished
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(resTags);
CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createResourceTag(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new CreateVoResourceTagTabItem(voId));
}
});
menu.addWidget(addButton);
if (!session.isVoAdmin(voId))
addButton.setEnabled(false);
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteResourceTag());
if (!session.isVoAdmin(voId))
removeButton.setEnabled(false);
menu.addWidget(removeButton);
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<ResourceTag> tagsToRemove = resTags.getTableSelectedList();
String text = "Following tags will be deleted and won't be used to tag VO resources.";
UiElements.showDeleteConfirm(tagsToRemove, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < tagsToRemove.size(); i++) {
DeleteResourceTag request;
if (i == tagsToRemove.size() - 1) {
request = new DeleteResourceTag(JsonCallbackEvents.disableButtonEvents(removeButton, events));
} else {
request = new DeleteResourceTag(JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.deleteResourceTag(tagsToRemove.get(i));
}
}
});
}
});
menu.addFilterWidget(new ExtendedSuggestBox(resTags.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
resTags.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterTags());
final CustomButton saveButton = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.updateResourceTag());
menu.addWidget(saveButton);
if (!session.isVoAdmin(voId))
saveButton.setEnabled(false);
saveButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<ResourceTag> tagsToUpdate = resTags.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(tagsToUpdate)) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < tagsToUpdate.size(); i++) {
UpdateResourceTag request;
if (i == tagsToUpdate.size() - 1) {
request = new UpdateResourceTag(JsonCallbackEvents.disableButtonEvents(saveButton, events));
} else {
request = new UpdateResourceTag(JsonCallbackEvents.disableButtonEvents(saveButton));
}
request.updateResourceTag(tagsToUpdate.get(i));
}
}
}
});
// get the table
CellTable<ResourceTag> table = resTags.getTable();
// 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(menu);
firstTabPanel.setCellHeight(menu, "30px");
firstTabPanel.add(sp);
removeButton.setEnabled(false);
if (session.isVoAdmin(voId))
JsonUtils.addTableManagedButton(resTags, table, removeButton);
saveButton.setEnabled(false);
if (session.isVoAdmin(voId))
JsonUtils.addTableManagedButton(resTags, table, saveButton);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.TabMenu in project perun by CESNET.
the class VoSettingsTabItem method draw.
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": settings");
// MAIN PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu menu = new TabMenu();
// refresh
menu.addWidget(UiElements.getRefreshButton(this));
// Get Attributes
final GetAttributesV2 jsonCallback = new GetAttributesV2();
// We want VO attributes
jsonCallback.getVoAttributes(voId);
// get the table
CellTable<Attribute> table = jsonCallback.getTable();
if (!session.isVoAdmin(voId))
jsonCallback.setCheckable(false);
final CustomButton setButton = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.saveChangesInAttributes());
menu.addWidget(setButton);
if (!session.isVoAdmin(voId))
setButton.setEnabled(false);
// refresh table
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(jsonCallback);
// set button event with button disable
final JsonCallbackEvents setButtonEvent = JsonCallbackEvents.disableButtonEvents(setButton, events);
setButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Attribute> list = jsonCallback.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
Map<String, Integer> ids = new HashMap<String, Integer>();
ids.put("vo", voId);
SetAttributes request = new SetAttributes(setButtonEvent);
request.setAttributes(ids, list);
}
}
});
CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.setNewAttributes(), new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Map<String, Integer> ids = new HashMap<String, Integer>();
ids.put("vo", voId);
session.getTabManager().addTabToCurrentTab(new SetNewAttributeTabItem(ids, jsonCallback.getList()), true);
}
});
menu.addWidget(addButton);
if (!session.isVoAdmin(voId))
addButton.setEnabled(false);
// remove attr button
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeAttributes());
menu.addWidget(removeButton);
if (!session.isVoAdmin(voId))
removeButton.setEnabled(false);
// remove button event
final JsonCallbackEvents removeButtonEvent = JsonCallbackEvents.disableButtonEvents(removeButton, events);
removeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
ArrayList<Attribute> list = jsonCallback.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
Map<String, Integer> ids = new HashMap<String, Integer>();
ids.put("vo", voId);
RemoveAttributes request = new RemoveAttributes(removeButtonEvent);
request.removeAttributes(ids, list);
}
}
});
// 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");
if (session.isVoAdmin(voId))
JsonUtils.addTableManagedButton(jsonCallback, table, removeButton);
// add menu and the table to the main panel
firstTabPanel.add(menu);
firstTabPanel.setCellHeight(menu, "30px");
firstTabPanel.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
Aggregations