use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.
the class AddFacilityOwnerTabItem method draw.
public Widget draw() {
// TITLE
titleWidget.setText("Add owner");
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu tabMenu = new TabMenu();
// CALLBACK
final GetOwners owners = new GetOwners();
CellTable<Owner> table = owners.getTable();
// ADD BUTTON
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addOwners());
// tab to be closed
final TabItem tab = this;
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// get
ArrayList<Owner> list = owners.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < list.size(); i++) {
if (i == list.size() - 1) {
AddOwner request = new AddOwner(JsonCallbackEvents.closeTabDisableButtonEvents(addButton, tab));
request.addOwner(facilityId, list.get(i).getId());
} else {
AddOwner request = new AddOwner(JsonCallbackEvents.disableButtonEvents(addButton));
request.addOwner(facilityId, list.get(i).getId());
}
}
}
}
});
tabMenu.addWidget(addButton);
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
tabMenu.addFilterWidget(new ExtendedSuggestBox(owners.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
owners.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterOwners());
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(owners, table, addButton);
// 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(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
firstTabPanel.add(sp);
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.
the class AssignSecurityTeamTabItem method draw.
public Widget draw() {
// TITLE
titleWidget.setText("Add security team");
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu tabMenu = new TabMenu();
// CALLBACK
final GetSecurityTeams secTeams = new GetSecurityTeams();
secTeams.setEvents(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
if (secTeams.getList().size() == 1) {
secTeams.getSelectionModel().setSelected(secTeams.getList().get(0), true);
}
}
});
secTeams.setForceAll(true);
CellTable<SecurityTeam> table = secTeams.getTable();
// ADD BUTTON
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.assignSecurityTeam());
// tab to be closed
final TabItem tab = this;
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// get
ArrayList<SecurityTeam> list = secTeams.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < list.size(); i++) {
if (i == list.size() - 1) {
AssignSecurityTeam request = new AssignSecurityTeam(JsonCallbackEvents.closeTabDisableButtonEvents(addButton, tab));
request.assignSecurityTeam(facilityId, list.get(i).getId());
} else {
AssignSecurityTeam request = new AssignSecurityTeam(JsonCallbackEvents.disableButtonEvents(addButton));
request.assignSecurityTeam(facilityId, list.get(i).getId());
}
}
}
}
});
tabMenu.addWidget(addButton);
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
tabMenu.addFilterWidget(new ExtendedSuggestBox(secTeams.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
secTeams.filterTable(text);
if (secTeams.getList().size() == 1) {
secTeams.getSelectionModel().setSelected(secTeams.getList().get(0), true);
}
}
}, ButtonTranslation.INSTANCE.filterSecurityTeam());
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(secTeams, table, addButton);
// 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(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
firstTabPanel.add(sp);
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.
the class FacilitiesSelectTabItem method draw.
public Widget draw() {
// MAIN PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// TAB MENU
TabMenu tabMenu = new TabMenu();
// get RICH facilities request
final GetFacilities facilities = new GetFacilities(true);
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(facilities);
// retrieve data (table)
final CellTable<Facility> table = facilities.getTable(new FieldUpdater<Facility, String>() {
public void update(int index, Facility object, String value) {
session.getTabManager().addTab(new FacilityDetailTabItem(object));
}
});
tabMenu.addWidget(UiElements.getRefreshButton(this));
// add new facility button
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createFacility(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTab(new CreateFacilityTabItem(facilities.getFullBackupList(), events));
}
}));
// add delete facilities button
final CustomButton deleteButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteFacilities());
if (session.isPerunAdmin()) {
tabMenu.addWidget(deleteButton);
}
deleteButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<Facility> list = facilities.getTableSelectedList();
String text = "Following facilities will be deleted.";
UiElements.showDeleteConfirm(list, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < list.size(); i++) {
if (i == list.size() - 1) {
DeleteFacility request = new DeleteFacility(JsonCallbackEvents.disableButtonEvents(deleteButton, events));
request.deleteFacility(list.get(i).getId());
} else {
DeleteFacility request = new DeleteFacility(JsonCallbackEvents.disableButtonEvents(deleteButton));
request.deleteFacility(list.get(i).getId());
}
}
}
});
}
});
// filter box
tabMenu.addFilterWidget(new ExtendedSuggestBox(facilities.getOracle()), new PerunSearchEvent() {
public void searchFor(String text) {
facilities.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterFacilities());
tabMenu.addWidget(new Image(SmallIcons.INSTANCE.helpIcon()));
tabMenu.addWidget(new HTML("<strong>Please select Facility you want to manage.</strong>"));
deleteButton.setEnabled(false);
JsonUtils.addTableManagedButton(facilities, table, deleteButton);
// 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(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
firstTabPanel.add(sp);
firstTabPanel.setCellHeight(sp, "100%");
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox 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.ExtendedSuggestBox 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();
}
Aggregations