use of cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent in project perun by CESNET.
the class ServicePackageDetailTabItem method draw.
public Widget draw() {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(servicesPackage.getName()) + ": assigned services");
// create widget for the whole page
HorizontalPanel mainTab = new HorizontalPanel();
mainTab.setSize("100%", "100%");
// get services
final GetServices services = new GetServices();
final GetServicesFromServicesPackage assignedServices = new GetServicesFromServicesPackage(servicePackageId);
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(services);
final JsonCallbackEvents events2 = JsonCallbackEvents.refreshTableEvents(assignedServices);
// get the table of services with custom field updater (lines are clickable and open service details)
CellTable<Service> table = services.getTable(new FieldUpdater<Service, String>() {
// when user click on a row -> open new tab
public void update(int index, Service object, String value) {
session.getTabManager().addTab(new ServiceDetailTabItem(object));
}
});
// get the table of services with custom field updater (lines are clickable and open service details)
CellTable<Service> table2 = assignedServices.getTable(new FieldUpdater<Service, String>() {
// when user click on a row -> open new tab
public void update(int index, Service object, String value) {
session.getTabManager().addTab(new ServiceDetailTabItem(object));
}
});
// add styling to table with services
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
VerticalPanel vp1 = new VerticalPanel();
vp1.setSize("100%", "100%");
TabMenu menu1 = new TabMenu();
menu1.addFilterWidget(new ExtendedSuggestBox(services.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
services.filterTable(text);
}
}, "Filter services by name");
vp1.add(menu1);
vp1.setCellHeight(menu1, "30px");
vp1.add(sp);
mainTab.add(vp1);
mainTab.setCellWidth(vp1, "50%");
// middle content
final CustomButton add = new CustomButton("Add", "Add services to package", SmallIcons.INSTANCE.arrowRightIcon());
add.setImageAlign(true);
add.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<Service> list = services.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
for (int i = 0; i < list.size(); i++) {
AddServiceToServicesPackage request;
final int ii = i;
if (i == list.size() - 1) {
request = new AddServiceToServicesPackage(JsonCallbackEvents.disableButtonEvents(add, JsonCallbackEvents.mergeEvents(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
services.getSelectionModel().setSelected(list.get(ii), false);
}
}, events2)));
} else {
request = new AddServiceToServicesPackage(JsonCallbackEvents.disableButtonEvents(add, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
services.getSelectionModel().setSelected(list.get(ii), false);
}
}));
}
request.addServiceToServicesPackage(servicePackageId, list.get(i).getId());
}
}
}
});
final CustomButton remove = new CustomButton("Remove", "Remove services from package", SmallIcons.INSTANCE.arrowLeftIcon());
remove.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
ArrayList<Service> list = assignedServices.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
for (int i = 0; i < list.size(); i++) {
RemoveServiceFromServicesPackage request;
if (i == list.size() - 1) {
request = new RemoveServiceFromServicesPackage(JsonCallbackEvents.disableButtonEvents(remove, events2));
} else {
request = new RemoveServiceFromServicesPackage(JsonCallbackEvents.disableButtonEvents(remove));
}
request.removeServiceFromServicesPackage(servicePackageId, list.get(i).getId());
}
}
}
});
final TabItem tab = this;
CustomButton close = TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().closeTab(tab);
}
});
FlexTable ft = new FlexTable();
ft.setWidget(0, 0, add);
ft.setWidget(1, 0, remove);
ft.setWidget(2, 0, close);
ft.getFlexCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);
ft.getFlexCellFormatter().setAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);
ft.getFlexCellFormatter().setAlignment(2, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);
ft.setWidth("130px");
ft.setCellSpacing(10);
mainTab.add(ft);
mainTab.setCellVerticalAlignment(ft, HasVerticalAlignment.ALIGN_MIDDLE);
// add styling to table2 with assigned services
table2.addStyleName("perun-table");
ScrollPanel sp2 = new ScrollPanel(table2);
sp2.addStyleName("perun-tableScrollPanel");
VerticalPanel vp2 = new VerticalPanel();
vp2.setSize("100%", "100%");
TabMenu menu2 = new TabMenu();
menu2.addFilterWidget(new ExtendedSuggestBox(assignedServices.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
assignedServices.filterTable(text);
}
}, "Filter services by name");
vp2.add(menu2);
vp2.setCellHeight(menu2, "30px");
vp2.add(sp2);
mainTab.add(vp2);
mainTab.setCellWidth(vp2, "50%");
add.setEnabled(false);
JsonUtils.addTableManagedButton(services, table, add);
remove.setEnabled(false);
JsonUtils.addTableManagedButton(assignedServices, table2, remove);
session.getUiElements().resizeSmallTabPanel(mainTab, 350, this);
session.getUiElements().resizePerunTable(sp, 350, this);
session.getUiElements().resizePerunTable(sp2, 350, this);
this.contentWidget.setWidget(mainTab);
return getWidget();
}
use of cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent in project perun by CESNET.
the class ServicePackagesTabItem method draw.
public Widget draw() {
// create widget for the whole page
VerticalPanel mainTab = new VerticalPanel();
mainTab.setSize("100%", "100%");
// create widget for menu on page
TabMenu tabMenu = new TabMenu();
tabMenu.addWidget(UiElements.getRefreshButton(this));
// get services
final GetServicesPackages services = new GetServicesPackages();
services.setEditable(true);
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(services);
// get the table of services with custom field updater (lines are clickable and open service details)
CellTable<ServicesPackage> table = services.getTable(new FieldUpdater<ServicesPackage, String>() {
// when user click on a row -> open new tab
public void update(int index, ServicesPackage object, String value) {
session.getTabManager().addTabToCurrentTab(new ServicePackageDetailTabItem(object), true);
}
});
// create button
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createServicePackage(), new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new CreateServicePackageTabItem());
}
}));
final CustomButton deleteButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteSelectedServicePackages());
deleteButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// get selected items
final ArrayList<ServicesPackage> itemsToRemove = services.getTableSelectedList();
UiElements.showDeleteConfirm(itemsToRemove, "Following services packages will be deleted.", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
for (int i = 0; i < itemsToRemove.size(); i++) {
DeleteServicePackage request;
if (i == itemsToRemove.size() - 1) {
request = new DeleteServicePackage(JsonCallbackEvents.disableButtonEvents(deleteButton, events));
} else {
request = new DeleteServicePackage(JsonCallbackEvents.disableButtonEvents(deleteButton));
}
request.deleteServicePackage(itemsToRemove.get(i).getId());
}
}
});
}
});
tabMenu.addWidget(deleteButton);
tabMenu.addFilterWidget(new ExtendedSuggestBox(services.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
services.filterTable(text);
}
}, "Filter service package by name");
final CustomButton save = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.saveChangesInServicesPackages());
save.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// get selected items
final ArrayList<ServicesPackage> itemsToUpdate = services.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(itemsToUpdate)) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
for (int i = 0; i < itemsToUpdate.size(); i++) {
UpdateServicePackage request;
if (i == itemsToUpdate.size() - 1) {
request = new UpdateServicePackage(JsonCallbackEvents.disableButtonEvents(save, events));
} else {
request = new UpdateServicePackage(JsonCallbackEvents.disableButtonEvents(save));
}
request.updateServicePackage(itemsToUpdate.get(i));
}
}
}
});
tabMenu.addWidget(save);
// add menu to page itself
mainTab.add(tabMenu);
mainTab.setCellHeight(tabMenu, "30px");
// add styling to table with services
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
mainTab.add(sp);
deleteButton.setEnabled(false);
save.setEnabled(false);
JsonUtils.addTableManagedButton(services, table, deleteButton);
JsonUtils.addTableManagedButton(services, table, save);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(mainTab);
return getWidget();
}
use of cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent in project perun by CESNET.
the class TestDataGridTabItem method draw.
public Widget draw() {
//contentWidget.setSize("100%", "100%");
DockLayoutPanel ft = new DockLayoutPanel(Style.Unit.PX);
contentWidget.setWidget(ft);
final DataGrid gridTable = new DataGrid();
gridTable.setSize("100%", "100%");
final ArrayList<VirtualOrganization> vosList = new ArrayList<VirtualOrganization>();
final GetVos getVos = new GetVos(new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
vosList.addAll(new TableSorter<VirtualOrganization>().sortByName(JsonUtils.<VirtualOrganization>jsoAsList(jso)));
gridTable.setRowData(vosList);
gridTable.redraw();
}
});
getVos.retrieveData();
gridTable.setSelectionModel(new MultiSelectionModel<VirtualOrganization>(new GeneralKeyProvider<VirtualOrganization>()));
final SelectionModel<VirtualOrganization> selectionModel = gridTable.getSelectionModel();
Column<VirtualOrganization, Boolean> checkBoxColumn = new Column<VirtualOrganization, Boolean>(new CheckboxCell(true, true)) {
@Override
public Boolean getValue(VirtualOrganization object) {
// Get the value from the selection model.
return selectionModel.isSelected(object);
}
};
checkBoxColumn.setFieldUpdater(new FieldUpdater<VirtualOrganization, Boolean>() {
@Override
public void update(int i, VirtualOrganization virtualOrganization, Boolean aBoolean) {
selectionModel.setSelected(virtualOrganization, aBoolean);
}
});
// Checkbox column header
CheckboxCell cb = new CheckboxCell();
Header<Boolean> checkBoxHeader = new Header<Boolean>(cb) {
public Boolean getValue() {
//return true to see a checked checkbox.
return false;
}
};
checkBoxHeader.setUpdater(new ValueUpdater<Boolean>() {
public void update(Boolean value) {
// sets selected to all, if value = true, unselect otherwise
for (VirtualOrganization obj : vosList) {
selectionModel.setSelected(obj, value);
}
}
});
gridTable.addColumn(checkBoxColumn, checkBoxHeader, checkBoxHeader);
gridTable.setColumnWidth(checkBoxColumn, 40.0, Style.Unit.PX);
TextColumn<VirtualOrganization> idColumn = new TextColumn<VirtualOrganization>() {
@Override
public String getValue(VirtualOrganization object) {
return String.valueOf(object.getId());
}
};
gridTable.addColumn(idColumn, "Id", "Id");
gridTable.setColumnWidth(idColumn, "90px");
Column<VirtualOrganization, String> nameColumn = JsonUtils.addColumn(new JsonUtils.GetValue<VirtualOrganization, String>() {
public String getValue(VirtualOrganization object) {
return object.getName();
}
}, new FieldUpdater<VirtualOrganization, String>() {
@Override
public void update(int i, VirtualOrganization virtualOrganization, String s) {
session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
}
});
gridTable.addColumn(nameColumn, "Name", "Name");
TextColumn<VirtualOrganization> shortnameColumn = new TextColumn<VirtualOrganization>() {
@Override
public String getValue(VirtualOrganization object) {
return object.getShortName();
}
};
gridTable.addColumn(shortnameColumn, "Short name", "Short name");
shortnameColumn.setFieldUpdater(new FieldUpdater<VirtualOrganization, String>() {
@Override
public void update(int i, VirtualOrganization virtualOrganization, String s) {
session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
}
});
idColumn.setFieldUpdater(new FieldUpdater<VirtualOrganization, String>() {
@Override
public void update(int i, VirtualOrganization virtualOrganization, String s) {
session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
}
});
nameColumn.setFieldUpdater(new FieldUpdater<VirtualOrganization, String>() {
@Override
public void update(int i, VirtualOrganization virtualOrganization, String s) {
session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
}
});
TabMenu tabMenu = new TabMenu();
// CREATE & DELETE ONLY WITH PERUN ADMIN
if (session.isPerunAdmin()) {
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, ButtonTranslation.INSTANCE.createVo(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new CreateVoTabItem());
}
}));
final cz.metacentrum.perun.webgui.widgets.CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteVo());
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<VirtualOrganization> itemsToRemove = getVos.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(itemsToRemove)) {
VerticalPanel removePanel = new VerticalPanel();
removePanel.add(new Label("These VOs will be removed:"));
for (int i = 0; i < itemsToRemove.size(); i++) {
VirtualOrganization vo = itemsToRemove.get(i);
removePanel.add(new Label(" - " + vo.getName()));
}
// confirmation
Confirm c = new Confirm("Remove VOs", removePanel, new ClickHandler() {
public void onClick(ClickEvent event) {
for (int i = 0; i < itemsToRemove.size(); i++) {
DeleteVo request;
// if last, refresh
if (i == itemsToRemove.size() - 1) {
request = new DeleteVo(JsonCallbackEvents.disableButtonEvents(removeButton));
} else {
request = new DeleteVo(JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.deleteVo(itemsToRemove.get(i).getId(), false);
}
getVos.clearTableSelectedSet();
}
}, true);
c.show();
}
}
});
tabMenu.addWidget(removeButton);
}
// filter
tabMenu.addFilterWidget(new ExtendedSuggestBox(getVos.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
getVos.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterVo());
ft.addNorth(tabMenu, 50);
ft.add(gridTable);
return getWidget();
}
use of cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent 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.client.resources.PerunSearchEvent 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();
}
Aggregations