use of cz.metacentrum.perun.webgui.widgets.TabMenu in project perun by CESNET.
the class FacilityBlacklistTabItem method draw.
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": Blacklist");
// main panel
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
final GetBlacklistWithDescription securityTeams = new GetBlacklistWithDescription(PerunEntity.FACILITY, facilityId);
// menu
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
menu.addFilterWidget(new ExtendedSuggestBox(securityTeams.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
securityTeams.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterSecurityTeam());
CellTable<Pair<User, String>> table;
if (session.isPerunAdmin() || session.isSecurityAdmin()) {
table = securityTeams.getTable(new FieldUpdater<Pair<User, String>, String>() {
@Override
public void update(int index, Pair<User, String> object, String value) {
session.getTabManager().addTab(new UserDetailTabItem(object.getLeft()));
}
});
} else {
table = securityTeams.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);
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 FacilityDestinationsTabItem method draw.
public Widget draw() {
// set title
titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": Destinations");
// main content
final VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// menu
final TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
//callback
final GetAllRichDestinations callback = new GetAllRichDestinations(facility, null);
// do not make callback yet
final CellTable<Destination> table = callback.getTable();
// refresh table events
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(callback);
// style table
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
menu.addWidget(UiElements.getRefreshButton(this));
// buttons
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addDestination(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AddFacilityDestinationTabItem(facility));
}
}));
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeSelectedDestinations());
menu.addWidget(removeButton);
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<Destination> destForRemoving = callback.getTableSelectedList();
String text = "<span class=\"serverResponseLabelError\"><strong>Removing destination will stop propagation of service's configuration for this destination/service.</strong></span><p>Following destinations will be removed.";
UiElements.showDeleteConfirm(destForRemoving, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < destForRemoving.size(); i++) {
if (i == destForRemoving.size() - 1) {
RemoveDestination request = new RemoveDestination(facility.getId(), destForRemoving.get(i).getService().getId(), JsonCallbackEvents.disableButtonEvents(removeButton, events));
request.removeDestination(destForRemoving.get(i).getDestination(), destForRemoving.get(i).getType());
} else {
RemoveDestination request = new RemoveDestination(facility.getId(), destForRemoving.get(i).getService().getId(), JsonCallbackEvents.disableButtonEvents(removeButton));
request.removeDestination(destForRemoving.get(i).getDestination(), destForRemoving.get(i).getType());
}
}
}
});
}
});
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(callback, table, removeButton);
// filter box
menu.addFilterWidget(new ExtendedSuggestBox(callback.getOracle()), new PerunSearchEvent() {
public void searchFor(String text) {
callback.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterDestination());
menu.addWidget(new Image(SmallIcons.INSTANCE.helpIcon()));
menu.addWidget(new HTML("<strong>Destinations define, where service's configuration is propagated.</strong>"));
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.TabMenu 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.TabMenu 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.TabMenu in project perun by CESNET.
the class AddGroupManagerGroupTabItem method draw.
public Widget draw() {
titleWidget.setText("Add manager group");
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
final TabMenu tabMenu = new TabMenu();
final ListBoxWithObjects<VirtualOrganization> box = new ListBoxWithObjects<VirtualOrganization>();
// pass empty items to menu to ensure drawing of rest
tabMenu.addWidget(UiElements.getRefreshButton(this));
tabMenu.addWidget(new HTML(""));
tabMenu.addWidget(new HTML(""));
tabMenu.addWidget(3, new HTML("<strong>Select VO:</strong>"));
tabMenu.addWidget(4, box);
// get the table
final ScrollPanel sp = new ScrollPanel();
sp.addStyleName("perun-tableScrollPanel");
box.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
sp.setWidget(fillGroupsContent(new GetAllGroups(box.getSelectedObject().getId()), tabMenu, box));
}
});
if (box.getAllObjects().isEmpty()) {
GetVos vos = new GetVos(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
box.clear();
ArrayList<VirtualOrganization> list = new TableSorter<VirtualOrganization>().sortByName(JsonUtils.<VirtualOrganization>jsoAsList(jso));
if (list != null && !list.isEmpty()) {
box.addAllItems(list);
sp.setWidget(fillGroupsContent(new GetAllGroups(box.getSelectedObject().getId()), tabMenu, box));
} else {
box.addItem("No VOs found");
}
}
@Override
public void onError(PerunError error) {
box.clear();
box.addItem("Error while loading");
}
@Override
public void onLoadingStart() {
box.clear();
box.addItem("Loading...");
}
});
vos.retrieveData();
}
final TabItem tab = this;
tabMenu.addWidget(2, TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
if (refreshEvents != null)
refreshEvents.onFinished(null);
session.getTabManager().closeTab(tab, false);
}
}));
// add menu and the table to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
firstTabPanel.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
Aggregations