use of cz.metacentrum.perun.webgui.model.ResourceTag in project perun by CESNET.
the class AssignTagTabItem method draw.
public Widget draw() {
titleWidget.setText("Add tag");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// menu
TabMenu menu = new TabMenu();
final GetAllResourcesTags tags = new GetAllResourcesTags(PerunEntity.VIRTUAL_ORGANIZATION, resource.getVoId());
final CellTable<ResourceTag> table = tags.getTable();
final TabItem tab = this;
// button
final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.assignSelectedTagsToResource());
assignButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<ResourceTag> tagsToAssign = tags.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(tagsToAssign)) {
for (int i = 0; i < tagsToAssign.size(); i++) {
if (i != tagsToAssign.size() - 1) {
// call json normaly
AssignResourceTag request = new AssignResourceTag(resourceId, JsonCallbackEvents.disableButtonEvents(assignButton));
request.assignResourceTag(tagsToAssign.get(i));
} else {
// last change - call json with update
AssignResourceTag request = new AssignResourceTag(resourceId, JsonCallbackEvents.closeTabDisableButtonEvents(assignButton, tab));
request.assignResourceTag(tagsToAssign.get(i));
}
}
}
}
});
menu.addWidget(assignButton);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
menu.addFilterWidget(new ExtendedSuggestBox(tags.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
tags.filterTable(text);
// if single group, select
if (tags.getList().size() == 1) {
table.getSelectionModel().setSelected(tags.getList().get(0), true);
}
}
}, ButtonTranslation.INSTANCE.filterGroup());
vp.add(menu);
vp.setCellHeight(menu, "30px");
assignButton.setEnabled(false);
JsonUtils.addTableManagedButton(tags, table, assignButton);
tags.retrieveData();
table.addStyleName("perun-table");
table.setWidth("100%");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.model.ResourceTag in project perun by CESNET.
the class GetAssignedRichResources method insertToTable.
public void insertToTable(int index, RichResource object) {
list.add(index, object);
oracle.add(object.getName());
for (ResourceTag rt : object.getResourceTags()) {
oracle.add(rt.getName() + " (tag)");
}
dataProvider.flush();
dataProvider.refresh();
}
use of cz.metacentrum.perun.webgui.model.ResourceTag in project perun by CESNET.
the class GetAssignedRichResources method addToTable.
/**
* Add object as new row to table
*
* @param object Resource to be added as new row
*/
public void addToTable(RichResource object) {
list.add(object);
oracle.add(object.getName());
for (ResourceTag rt : object.getResourceTags()) {
oracle.add(rt.getName() + " (tag)");
}
dataProvider.flush();
dataProvider.refresh();
}
use of cz.metacentrum.perun.webgui.model.ResourceTag 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.model.ResourceTag in project perun by CESNET.
the class ResourceTagsTabItem method draw.
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(resource.getName()) + ": manage assigned tags");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
final GetAllResourcesTags tags = new GetAllResourcesTags(PerunEntity.RESOURCE, resourceId);
final JsonCallbackEvents localEvents = JsonCallbackEvents.refreshTableEvents(tags);
CustomButton assignTagsButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.assignTagsToResource(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AssignTagTabItem(resource), true);
}
});
final CustomButton removeTagsButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeSelectedTagsFromResource());
removeTagsButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<ResourceTag> tagsToRemove = tags.getTableSelectedList();
String text = "Following groups will be removed from resource.";
UiElements.showDeleteConfirm(tagsToRemove, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD USE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < tagsToRemove.size(); i++) {
if (i == tagsToRemove.size() - 1) {
RemoveResourceTag request = new RemoveResourceTag(resource.getId(), JsonCallbackEvents.disableButtonEvents(removeTagsButton, localEvents));
request.removeResourceTag(tagsToRemove.get(i));
} else {
RemoveResourceTag request = new RemoveResourceTag(resource.getId(), JsonCallbackEvents.disableButtonEvents(removeTagsButton));
request.removeResourceTag(tagsToRemove.get(i));
}
}
}
});
}
});
if (!session.isVoAdmin(resource.getVoId())) {
assignTagsButton.setEnabled(false);
removeTagsButton.setEnabled(false);
tags.setCheckable(false);
}
menu.addWidget(assignTagsButton);
menu.addWidget(removeTagsButton);
menu.addFilterWidget(new ExtendedSuggestBox(tags.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
tags.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterTags());
// display menu to vo admin only
vp.add(menu);
vp.setCellHeight(menu, "30px");
// table with field updater which leads to group detail
CellTable<ResourceTag> table = tags.getTable();
removeTagsButton.setEnabled(false);
JsonUtils.addTableManagedButton(tags, table, removeTagsButton);
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();
}
Aggregations