use of cz.metacentrum.perun.webgui.json.generalServiceManager.RemoveDependency in project perun by CESNET.
the class ViewExecServiceTabItem method getDependencyContent.
public VerticalPanel getDependencyContent() {
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// MAIN MENU
TabMenu tabMenu = new TabMenu();
tabMenu.addWidget(UiElements.getRefreshButton(this));
// callback
final ListExecServicesThisExecServiceDependsOn callback = new ListExecServicesThisExecServiceDependsOn(execServiceId);
// refresh event
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(callback);
// add button
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addDependantExecService(), new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new AddDependencyTabItem(execService));
}
}));
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeSelectedDependantExecServices());
tabMenu.addWidget(removeButton);
removeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<ExecService> dependencyForDeletion = callback.getTableSelectedList();
UiElements.showDeleteConfirm(dependencyForDeletion, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
for (int i = 0; i < dependencyForDeletion.size(); i++) {
if (i == dependencyForDeletion.size() - 1) {
RemoveDependency request = new RemoveDependency(JsonCallbackEvents.disableButtonEvents(removeButton, events));
request.removeDependency(execServiceId, dependencyForDeletion.get(i).getId());
} else {
RemoveDependency request = new RemoveDependency(JsonCallbackEvents.disableButtonEvents(removeButton));
request.removeDependency(execServiceId, dependencyForDeletion.get(i).getId());
}
}
}
});
}
});
vp.add(tabMenu);
vp.setCellHeight(tabMenu, "30px");
// get table
CellTable<ExecService> table = callback.getTable();
// create scroll panel for table
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
sp.setWidth("100%");
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(callback, table, removeButton);
vp.add(sp);
vp.setCellHeight(sp, "100%");
session.getUiElements().resizePerunTable(sp, 250, this);
return vp;
}
Aggregations