use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.
the class TaskResultsTabItem method draw.
public Widget draw() {
this.titleWidget.setText("Tasks results: " + task.getExecService().getService().getName() + " " + task.getExecService().getType());
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
final GetRichTaskResultsByTask callback = new GetRichTaskResultsByTask(task.getId());
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
menu.addFilterWidget(new ExtendedSuggestBox(callback.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
callback.filterTable(text);
}
}, "Filter results by destination");
CellTable<TaskResult> table = callback.getTable();
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(menu);
vp.setCellHeight(menu, "30px");
vp.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.
the class AddGroupExtSourceTabItem method draw.
public Widget draw() {
titleWidget.setText("Add external source");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// menu
TabMenu menu = new TabMenu();
menu.addWidget(new HTML(""));
final GetVoExtSources extSources = new GetVoExtSources(group.getVoId());
// remove already assigned ext sources from offering
JsonCallbackEvents localEvents = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// second callback
final GetGroupExtSources alreadyAssigned = new GetGroupExtSources(groupId, 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);
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.addGroupExtSource(groupId, 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.ExtendedSuggestBox in project perun by CESNET.
the class AddGroupUnionTabItem method draw.
@Override
public Widget draw() {
titleWidget.setText("Add group union");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// menu
TabMenu menu = new TabMenu();
menu.addWidget(new HTML(""));
final GetAllGroups groups = new GetAllGroups(group.getVoId());
groups.setCoreGroupsCheckable(true);
// remove already added union groups from offering
JsonCallbackEvents localEvents = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// second callback
final GetGroupUnions alreadyAssigned = new GetGroupUnions(group, false, new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
JsArray<Group> esToRemove = JsonUtils.jsoAsArray(jso);
for (int i = 0; i < esToRemove.length(); i++) {
groups.removeFromTable(esToRemove.get(i));
}
// remove itself
groups.removeFromTable(group);
}
});
alreadyAssigned.retrieveData();
}
};
groups.setEvents(localEvents);
final ExtendedSuggestBox box = new ExtendedSuggestBox(groups.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<Group> groupsToAdd = groups.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(groupsToAdd)) {
// FIXME - Should have only one callback to core
for (int i = 0; i < groupsToAdd.size(); i++) {
final int n = i;
AddGroupUnion request = new AddGroupUnion(JsonCallbackEvents.disableButtonEvents(assignButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// unselect added person
groups.getSelectionModel().setSelected(groupsToAdd.get(n), false);
alreadyAddedList.add(groupsToAdd.get(n));
rebuildAlreadyAddedWidget();
// clear search
box.getSuggestBox().setText("");
}
}));
request.createGroupUnion(group, groupsToAdd.get(i));
}
}
}
});
menu.addFilterWidget(box, new PerunSearchEvent() {
@Override
public void searchFor(String text) {
groups.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<Group> table = groups.getTable();
assignButton.setEnabled(false);
JsonUtils.addTableManagedButton(groups, table, assignButton);
table.addStyleName("perun-table");
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().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.
the class AssignGroupTabItem method draw.
public Widget draw() {
// set tab name
titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": assign to resource");
// main content
VerticalPanel mainTab = new VerticalPanel();
mainTab.setSize("100%", "100%");
// menu
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
// callback
final GetRichResources callback = new GetRichResources(group.getVoId());
callback.setEvents(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
for (RichResource rr : resources) {
callback.removeFromTable(rr);
}
ArrayList<RichResource> temp = new ArrayList<RichResource>();
temp.addAll(callback.getList());
callback.setList(temp);
}
});
CellTable<RichResource> table = callback.getTable();
// close tab event
final TabItem tab = this;
// filter box
menu.addFilterWidget(new ExtendedSuggestBox(callback.getOracle()), new PerunSearchEvent() {
public void searchFor(String text) {
callback.filterTable(text);
// if single group, select
if (callback.getList().size() == 1) {
callback.getSelectionModel().setSelected(callback.getList().get(0), true);
}
}
}, ButtonTranslation.INSTANCE.filterResources());
// button
final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.assignGroupToSelectedResources());
assignButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<RichResource> toAssign = callback.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(toAssign)) {
AssignGroupToResources request = new AssignGroupToResources(JsonCallbackEvents.disableButtonEvents(assignButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
alreadyAddedList.addAll(toAssign);
for (RichResource r : toAssign) {
callback.getSelectionModel().setSelected(r, false);
}
rebuildAlreadyAddedWidget();
}
}));
request.assignGroupToResources(group, toAssign);
}
}
});
menu.addWidget(assignButton);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
assignButton.setEnabled(false);
JsonUtils.addTableManagedButton(callback, table, assignButton);
// add menu and the table to the main panel
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
// do not use resizePerunTable() in overlay mode - calculated width is wrong
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
mainTab.add(menu);
mainTab.setCellHeight(menu, "30px");
rebuildAlreadyAddedWidget();
mainTab.add(alreadyAdded);
mainTab.add(sp);
this.contentWidget.setWidget(mainTab);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.
the class FacilityResourcesTabItem method draw.
public Widget draw() {
// set title
titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": Resources");
// main panel
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
// get VO resources
final GetAssignedRichResources resources = new GetAssignedRichResources(facility.getId());
// custom events for viewResource
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(resources);
// create resource button
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createResource(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new CreateFacilityResourceTabItem(facility), false);
}
}));
final CustomButton deleteButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteResource());
menu.addWidget(deleteButton);
deleteButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
final ArrayList<RichResource> toDelete = resources.getTableSelectedList();
String text = "Following resources will be deleted.";
UiElements.showDeleteConfirm(toDelete, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < toDelete.size(); i++) {
if (i == toDelete.size() - 1) {
DeleteResource request = new DeleteResource(JsonCallbackEvents.disableButtonEvents(deleteButton, events));
request.deleteResource(toDelete.get(i).getId());
} else {
DeleteResource request = new DeleteResource(JsonCallbackEvents.disableButtonEvents(deleteButton));
request.deleteResource(toDelete.get(i).getId());
}
}
}
});
}
});
menu.addFilterWidget(new ExtendedSuggestBox(resources.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
resources.filterTable(text);
}
}, "Filter resources by name or VO name");
CellTable<RichResource> table = resources.getTable(new FieldUpdater<RichResource, String>() {
public void update(int index, RichResource object, String value) {
session.getTabManager().addTab(new ResourceDetailTabItem(object, facilityId));
}
});
deleteButton.setEnabled(false);
JsonUtils.addTableManagedButton(resources, table, deleteButton);
table.addStyleName("perun-table");
table.setWidth("100%");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizePerunTable(sp, 350, this);
vp.add(menu);
vp.setCellHeight(menu, "30px");
vp.add(sp);
this.contentWidget.setWidget(vp);
return getWidget();
}
Aggregations