use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.
the class AllAuthorsTabItem method draw.
public Widget draw() {
VerticalPanel vp = new VerticalPanel();
vp.getElement().setAttribute("style", "padding-top: 5px;");
vp.setSize("100%", "100%");
// MENU
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
menu.addWidget(UiElements.getRefreshButton(this));
final FindAllAuthors callback = new FindAllAuthors();
menu.addFilterWidget(new ExtendedSuggestBox(callback.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
callback.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterAuthors());
CellTable<Author> table = callback.getTable(new FieldUpdater<Author, String>() {
public void update(int index, Author object, String value) {
if (session.isPerunAdmin()) {
session.getTabManager().addTab(new UsersPublicationsTabItem(object.getId()));
}
}
});
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel();
sp.add(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
// resize perun table to correct size on screen
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 AttributeDefinitionsTabItem method draw.
public Widget draw() {
// create main panel for content
VerticalPanel mainPage = new VerticalPanel();
mainPage.setWidth("100%");
// create new instance for jsonCall
final GetAttributesDefinition attrDef = new GetAttributesDefinition();
final ExtendedSuggestBox box = new ExtendedSuggestBox(attrDef.getOracle());
// custom events for reloading when created or deleted
final JsonCallbackEvents refreshTabEvents = JsonCallbackEvents.mergeEvents(JsonCallbackEvents.refreshTableEvents(attrDef), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
if (box.getSuggestBox().getValue() != null)
attrDef.filterTable(box.getSuggestBox().getValue());
}
});
// TAB MENU
TabMenu tabMenu = new TabMenu();
tabMenu.addWidget(UiElements.getRefreshButton(this));
// create buttons
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, buttonTranslation.createAttributeDefinition(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new CreateAttributeDefinitionTabItem());
}
}));
// remove button
final CustomButton deleteButton = TabMenu.getPredefinedButton(ButtonType.DELETE, buttonTranslation.deleteAttributeDefinition());
deleteButton.setEnabled(false);
deleteButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<AttributeDefinition> attrDefToBeDeleted = attrDef.getTableSelectedList();
String text = "Following attribute definitions will be deleted.";
UiElements.showDeleteConfirm(attrDefToBeDeleted, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
for (int i = 0; i < attrDefToBeDeleted.size(); i++) {
final int x = i;
DeleteAttribute request = new DeleteAttribute(JsonCallbackEvents.disableButtonEvents(deleteButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// remove deleted attrs from table
attrDef.removeFromBackupTable(attrDefToBeDeleted.get(x));
}
}));
request.deleteAttributeDefinition(attrDefToBeDeleted.get(i).getId());
}
}
});
}
});
tabMenu.addWidget(deleteButton);
// filter box
tabMenu.addFilterWidget(box, new PerunSearchEvent() {
public void searchFor(String text) {
attrDef.filterTable(text);
}
}, buttonTranslation.filterAttributeDefinition());
final CustomButton saveButton = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.saveChangesInAttributes());
saveButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
final ArrayList<AttributeDefinition> list = attrDef.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
for (int i = 0; i < list.size(); i++) {
final int x = i;
UpdateAttribute request = new UpdateAttribute(JsonCallbackEvents.disableButtonEvents(saveButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
attrDef.getSelectionModel().setSelected(list.get(x), false);
}
}));
request.updateAttribute(list.get(i));
}
}
}
});
tabMenu.addWidget(saveButton);
// add menu to page
mainPage.add(tabMenu);
mainPage.setCellHeight(tabMenu, "30px");
CellTable<AttributeDefinition> attrDefTable = attrDef.getTable(new FieldUpdater<AttributeDefinition, String>() {
@Override
public void update(int index, AttributeDefinition object, String value) {
session.getTabManager().addTabToCurrentTab(new AttributeDefinitionDetailTabItem(object), true);
}
});
attrDefTable.setStyleName("perun-table");
ScrollPanel scrollTable = new ScrollPanel(attrDefTable);
scrollTable.addStyleName("perun-tableScrollPanel");
JsonUtils.addTableManagedButton(attrDef, attrDefTable, deleteButton);
// put page into scroll panel
mainPage.add(scrollTable);
session.getUiElements().resizePerunTable(scrollTable, 350, this);
this.contentWidget.setWidget(mainPage);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.
the class GroupApplicationsTabItem method draw.
public Widget draw() {
// request
final GetApplicationsForGroup applicationsRequest = new GetApplicationsForGroup(group.getId());
final JsonCallbackEvents refreshEvent = JsonCallbackEvents.refreshTableEvents(applicationsRequest);
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": " + "applications");
// MAIN PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
firstTabPanel.add(menu);
firstTabPanel.setCellHeight(menu, "30px");
/*
// verify button
final CustomButton verify = TabMenu.getPredefinedButton(ButtonType.VERIFY, ButtonTranslation.INSTANCE.verifyApplication());
verify.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(verify));
request.verifyApplication(list.get(i).getId());
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(verify, refreshEvent));
request.verifyApplication(list.get(i).getId());
}
}
}
}
});
// accept button
final CustomButton approve = TabMenu.getPredefinedButton(ButtonType.APPROVE, ButtonTranslation.INSTANCE.approveApplication());
approve.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(approve));
request.approveApplication(list.get(i));
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(approve, refreshEvent));
request.approveApplication(list.get(i));
}
}
}
}
});
//reject button
final CustomButton reject = TabMenu.getPredefinedButton(ButtonType.REJECT, ButtonTranslation.INSTANCE.rejectApplication());
reject.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
// confirm content
FlexTable content = new FlexTable();
content.setCellSpacing(10);
content.setHTML(0, 0, "Please specify reason of rejection to let user know why was application rejected.");
content.getFlexCellFormatter().setColSpan(0, 0, 2);
final TextArea reason = new TextArea();
reason.setSize("300px", "150px");
content.setHTML(1, 0, "<strong>Reason: </strong>");
content.setWidget(1, 1, reason);
Confirm c = new Confirm("Specify reason", content, new ClickHandler(){
public void onClick(ClickEvent event) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(reject));
request.rejectApplication(list.get(i).getId(), reason.getText());
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(reject, refreshEvent));
request.rejectApplication(list.get(i).getId(), reason.getText());
}
}
}
}, true);
c.show();
}
}
});
// delete button
final CustomButton delete = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteApplication());
delete.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(delete));
request.deleteApplication(list.get(i).getId());
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(delete, refreshEvent));
request.deleteApplication(list.get(i).getId());
}
}
}
}
});
menu.addWidget(verify);
menu.addWidget(approve);
menu.addWidget(reject);
menu.addWidget(delete);
*/
// FILTER
menu.addWidget(new HTML("<strong>State: </strong>"));
// state
final ListBox stateListBox = new ListBox();
stateListBox.addItem(WidgetTranslation.INSTANCE.listboxAll(), "");
stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateNew(), "NEW");
stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateVerified(), "VERIFIED");
stateListBox.addItem("Pending", "NEW,VERIFIED");
stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateApproved(), "APPROVED");
stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateRejected(), "REJECTED");
stateListBox.setSelectedIndex(selectedIndex);
menu.addWidget(stateListBox);
stateListBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
selectedIndex = stateListBox.getSelectedIndex();
applicationsRequest.setState(stateListBox.getValue(stateListBox.getSelectedIndex()));
applicationsRequest.clearTable();
applicationsRequest.retrieveData();
}
});
// FILTER 2
menu.addWidget(new HTML("<strong>Submitted by: </strong>"));
menu.addFilterWidget(new ExtendedSuggestBox(applicationsRequest.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
applicationsRequest.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterApplications());
// TABLE
applicationsRequest.setState(stateListBox.getValue(stateListBox.getSelectedIndex()));
CellTable<Application> table = applicationsRequest.getTable(new FieldUpdater<Application, String>() {
public void update(int index, Application object, String value) {
session.getTabManager().addTabToCurrentTab(new ApplicationDetailTabItem(object), true);
}
});
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizePerunTable(sp, 100);
firstTabPanel.add(sp);
/*
verify.setEnabled(false);
approve.setEnabled(false);
reject.setEnabled(false);
delete.setEnabled(false);
if (session.isGroupAdmin(groupId) || session.isVoAdmin(group.getVoId())) {
JsonUtils.addTableManagedButton(applicationsRequest, table, approve);
JsonUtils.addTableManagedButton(applicationsRequest, table, reject);
JsonUtils.addTableManagedButton(applicationsRequest, table, delete);
if (session.isPerunAdmin()) {
JsonUtils.addTableManagedButton(applicationsRequest, table, verify);
}
} else {
}
*/
applicationsRequest.setCheckable(false);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.
the class FacilityHostsTabItem method draw.
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": Hosts");
// main panel
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
final GetHosts hosts = new GetHosts(facilityId);
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(hosts);
// menu
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addHost(), new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new AddHostsTabItem(facility));
}
}));
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeHosts());
removeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<Host> hostsForRemoving = hosts.getTableSelectedList();
String text = "<span class=\"serverResponseLabelError\"><strong>Removing host(s) won't stop services propagation. For this please remove proper 'Services destinations'.</strong></span><p>Following hosts will be removed from facility.";
UiElements.showDeleteConfirm(hostsForRemoving, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < hostsForRemoving.size(); i++) {
if (i == hostsForRemoving.size() - 1) {
RemoveHosts request = new RemoveHosts(facilityId, JsonCallbackEvents.disableButtonEvents(removeButton, events));
request.removeHost(hostsForRemoving.get(i).getId());
} else {
RemoveHosts request = new RemoveHosts(facilityId, JsonCallbackEvents.disableButtonEvents(removeButton));
request.removeHost(hostsForRemoving.get(i).getId());
}
}
}
});
}
});
menu.addWidget(removeButton);
menu.addFilterWidget(new ExtendedSuggestBox(hosts.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
hosts.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterHosts());
// Hosts table
CellTable<Host> table = hosts.getTable(new FieldUpdater<Host, String>() {
@Override
public void update(int index, Host object, String value) {
session.getTabManager().addTab(new FacilityHostsSettingsTabItem(facility, object));
}
});
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(hosts, table, removeButton);
// 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 FacilityOwnersTabItem method draw.
public Widget draw() {
// TITLE
titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": Owners");
// CONTENT
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// MENU
TabMenu menu = new TabMenu();
// CALLBACK
final GetFacilityOwners jsonCallback = new GetFacilityOwners(facility);
// AUTHZ
vp.add(menu);
vp.setCellHeight(menu, "30px");
menu.addWidget(UiElements.getRefreshButton(this));
// add button
CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addNewOwners());
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AddFacilityOwnerTabItem(facility), true);
}
});
// remove button
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeSelectedOwners());
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<Owner> list = jsonCallback.getTableSelectedList();
UiElements.showDeleteConfirm(list, 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) {
RemoveOwner request = new RemoveOwner(JsonCallbackEvents.disableButtonEvents(removeButton, JsonCallbackEvents.refreshTableEvents(jsonCallback)));
request.removeFacilityOwner(facilityId, list.get(i).getId());
} else {
RemoveOwner request = new RemoveOwner(JsonCallbackEvents.disableButtonEvents(removeButton));
request.removeFacilityOwner(facilityId, list.get(i).getId());
}
}
}
});
}
});
menu.addWidget(addButton);
menu.addWidget(removeButton);
menu.addFilterWidget(new ExtendedSuggestBox(jsonCallback.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
jsonCallback.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterOwners());
// TABLE
CellTable<Owner> table = jsonCallback.getTable();
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(jsonCallback, table, removeButton);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
Aggregations