public Widget draw() { this.titleWidget.setText( Utils.getStrippedStringWithEllipsis(service.getName()) + ": exec services"); final VerticalPanel vp = new VerticalPanel(); vp.setSize("100%", "100%"); TabMenu menu = new TabMenu(); vp.add(menu); vp.setCellHeight(menu, "30px"); final ListExecServices callback = new ListExecServices(serviceId); CellTable<ExecService> table = callback.getTable( new FieldUpdater<ExecService, String>() { public void update(int index, ExecService object, String value) { // manage details of exec services (dependency, status, update values?) session.getTabManager().addTab(new ViewExecServiceTabItem(object)); } }); // refresh event after deletion final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(callback); menu.addWidget( TabMenu.getPredefinedButton( ButtonType.CREATE, ButtonTranslation.INSTANCE.createExecService(), new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { session.getTabManager().addTabToCurrentTab(new AddExecServiceTabItem(service)); } })); final CustomButton deleteButton = TabMenu.getPredefinedButton( ButtonType.REMOVE, ButtonTranslation.INSTANCE.deleteSelectedExecServices()); menu.addWidget(deleteButton); deleteButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { final ArrayList<ExecService> execToRemove = callback.getTableSelectedList(); UiElements.showDeleteConfirm( execToRemove, new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE for (int i = 0; i < execToRemove.size(); i++) { if (i == execToRemove.size() - 1) { DeleteExecService request = new DeleteExecService( JsonCallbackEvents.disableButtonEvents(deleteButton, events)); request.deleteExecService(execToRemove.get(i).getId()); } else { DeleteExecService request = new DeleteExecService( JsonCallbackEvents.disableButtonEvents(deleteButton)); request.deleteExecService(execToRemove.get(i).getId()); } } } }); } }); table.addStyleName("perun-table"); ScrollPanel sp = new ScrollPanel(table); sp.addStyleName("perun-tableScrollPanel"); session.getUiElements().resizePerunTable(sp, 350, this); final CustomButton enable = TabMenu.getPredefinedButton(ButtonType.ENABLE, "Enable selected exec service(s)"); final CustomButton disable = TabMenu.getPredefinedButton(ButtonType.DISABLE, "Disable selected exec service(s)"); menu.addWidget(enable); menu.addWidget(disable); enable.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { ArrayList<ExecService> list = callback.getTableSelectedList(); for (int i = 0; i < list.size(); i++) { ExecService e = list.get(i); if (i < list.size() - 1) { // any call if (!e.isEnabled()) { UpdateExecService request = new UpdateExecService(JsonCallbackEvents.disableButtonEvents(enable)); e.setEnabled(true); request.updateExecService(e); } } else { // last call if (!e.isEnabled()) { UpdateExecService request = new UpdateExecService(JsonCallbackEvents.disableButtonEvents(enable, events)); e.setEnabled(true); request.updateExecService(e); } } } } }); disable.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { ArrayList<ExecService> list = callback.getTableSelectedList(); for (int i = 0; i < list.size(); i++) { ExecService e = list.get(i); if (i < list.size() - 1) { // any call if (e.isEnabled()) { UpdateExecService request = new UpdateExecService(JsonCallbackEvents.disableButtonEvents(disable)); e.setEnabled(false); request.updateExecService(e); } } else { // last call if (e.isEnabled()) { UpdateExecService request = new UpdateExecService( JsonCallbackEvents.disableButtonEvents(disable, events)); e.setEnabled(false); request.updateExecService(e); } } } } }); deleteButton.setEnabled(false); enable.setEnabled(false); disable.setEnabled(false); JsonUtils.addTableManagedButton(callback, table, deleteButton); JsonUtils.addTableManagedButton(callback, table, enable); JsonUtils.addTableManagedButton(callback, table, disable); vp.add(sp); vp.setCellHeight(sp, "100%"); // add tabs to the main panel this.contentWidget.setWidget(vp); return getWidget(); }
public Widget draw() { this.titleWidget.setText( Utils.getStrippedStringWithEllipsis(group.getName()) + ": " + "ext sources"); // main panel VerticalPanel vp = new VerticalPanel(); vp.setSize("100%", "100%"); // HORIZONTAL MENU TabMenu menu = new TabMenu(); menu.addWidget(UiElements.getRefreshButton(this)); // get VO resources final GetGroupExtSources extSources = new GetGroupExtSources(groupId); // refresh table event final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(extSources); // create ext source button CustomButton addButton = TabMenu.getPredefinedButton( ButtonType.ADD, true, ButtonTranslation.INSTANCE.addExtSource(), new ClickHandler() { public void onClick(ClickEvent event) { session .getTabManager() .addTabToCurrentTab(new AddGroupExtSourceTabItem(groupId), true); } }); if (session.isVoAdmin(voId)) { menu.addWidget(addButton); } final CustomButton removeButton = TabMenu.getPredefinedButton( ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeExtSource()); removeButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { final ArrayList<ExtSource> extSourcesToRemove = extSources.getTableSelectedList(); String text = "Following external sources will be removed from Group. You won't be able to import members from them anymore."; UiElements.showDeleteConfirm( extSourcesToRemove, text, new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !! for (int i = 0; i < extSourcesToRemove.size(); i++) { RemoveExtSource request; if (i == extSourcesToRemove.size() - 1) { request = new RemoveExtSource( JsonCallbackEvents.disableButtonEvents(removeButton, events)); } else { request = new RemoveExtSource( JsonCallbackEvents.disableButtonEvents(removeButton)); } request.removeGroupExtSource(groupId, extSourcesToRemove.get(i).getId()); } } }); } }); if (session.isVoAdmin(voId)) { menu.addWidget(removeButton); } // authorization - enable buttons for vo admin only. if (!session.isVoAdmin(voId)) { addButton.setEnabled(false); removeButton.setEnabled(false); extSources.setCheckable(false); } menu.addFilterWidget( new ExtendedSuggestBox(extSources.getOracle()), new PerunSearchEvent() { @Override public void searchFor(String text) { extSources.filterTable(text); } }, "Filter external sources by name or type"); // add menu to the main panel vp.add(menu); vp.setCellHeight(menu, "30px"); CellTable<ExtSource> table = extSources.getTable(); if (session.isVoAdmin(voId)) { removeButton.setEnabled(false); JsonUtils.addTableManagedButton(extSources, table, removeButton); } table.addStyleName("perun-table"); table.setWidth("100%"); ScrollPanel sp = new ScrollPanel(table); sp.addStyleName("perun-tableScrollPanel"); vp.add(sp); session.getUiElements().resizePerunTable(sp, 350, this); this.contentWidget.setWidget(vp); return getWidget(); }
public Widget draw() { VerticalPanel vp = new VerticalPanel(); vp.setSize("100%", "100%"); final FindAllCategories callback = new FindAllCategories(); final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(callback); TabMenu menu = new TabMenu(); menu.addWidget( TabMenu.getPredefinedButton( ButtonType.ADD, "Add new category", new ClickHandler() { public void onClick(ClickEvent event) { session.getTabManager().addTabToCurrentTab(new CreateCategoryTabItem()); } })); final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, "Delete selected categories"); removeButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { final ArrayList<Category> delete = callback.getTableSelectedList(); String text = "Following categories will be deleted"; UiElements.showDeleteConfirm( delete, text, new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE for (int i = 0; i < delete.size(); i++) { if (i == delete.size() - 1) { DeleteCategory request = new DeleteCategory( JsonCallbackEvents.disableButtonEvents(removeButton, events)); request.deleteCategory(delete.get(i).getId()); } else { DeleteCategory request = new DeleteCategory( JsonCallbackEvents.disableButtonEvents(removeButton)); request.deleteCategory(delete.get(i).getId()); } } } }); } }); menu.addWidget(removeButton); final CustomButton saveButton = TabMenu.getPredefinedButton(ButtonType.SAVE, "Save changes in category ranks"); saveButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { final ArrayList<Category> list = callback.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) { UpdateCategory request = new UpdateCategory( JsonCallbackEvents.disableButtonEvents(saveButton, events)); request.updateCategory(list.get(i)); } else { UpdateCategory request = new UpdateCategory(JsonCallbackEvents.disableButtonEvents(saveButton)); request.updateCategory(list.get(i)); } } } } }); menu.addWidget(saveButton); vp.add(menu); vp.setCellHeight(menu, "30px"); CellTable<Category> table = callback.getTable(); removeButton.setEnabled(false); saveButton.setEnabled(false); JsonUtils.addTableManagedButton(callback, table, removeButton); JsonUtils.addTableManagedButton(callback, table, saveButton); 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(); }