private void initBulkActions( final ExtendedPagedTable<ProcessInstanceSummary> extendedPagedTable) { bulkAbortNavLink = new AnchorListItem(constants.Bulk_Abort()); bulkSignalNavLink = new AnchorListItem(constants.Bulk_Signal()); final ButtonGroup bulkActions = new ButtonGroup() { { add( new org.gwtbootstrap3.client.ui.Button(constants.Bulk_Actions()) { { setDataToggle(Toggle.DROPDOWN); } }); add( new DropDownMenu() { { setPull(Pull.RIGHT); add(bulkAbortNavLink); add(bulkSignalNavLink); } }); } }; bulkAbortNavLink.setIcon(IconType.BAN); bulkAbortNavLink.setIconFixedWidth(true); bulkAbortNavLink.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { presenter.bulkAbort(selectedProcessInstances); selectedProcessInstances.clear(); extendedPagedTable.redraw(); } }); bulkSignalNavLink.setIcon(IconType.BELL); bulkSignalNavLink.setIconFixedWidth(true); bulkSignalNavLink.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { presenter.bulkSignal(selectedProcessInstances); selectedProcessInstances.clear(); extendedPagedTable.redraw(); } }); extendedPagedTable.getRightActionsToolbar().add(bulkActions); controlBulkOperations(); }
private List<? extends MenuItem> getBulkActions() { List<MenuItem> bulkActions = new ArrayList<MenuItem>(2); bulkActions.add( MenuFactory.newSimpleItem(constants.Bulk_Signal()) .respondsWith( new Command() { @Override public void execute() { StringBuffer processIdsParam = new StringBuffer(); if (view.getSelectedProcessInstances() != null) { for (ProcessInstanceSummary selected : view.getSelectedProcessInstances()) { if (selected.getState() != ProcessInstance.STATE_ACTIVE) { view.displayNotification( constants.Signaling_Process_Instance_Not_Allowed() + "(id=" + selected.getId() + ")"); continue; } processIdsParam.append(selected.getId() + ","); view.getProcessInstanceListGrid() .getSelectionModel() .setSelected(selected, false); } // remove last , if (processIdsParam.length() > 0) { processIdsParam.deleteCharAt(processIdsParam.length() - 1); } } else { processIdsParam.append("-1"); } PlaceRequest placeRequestImpl = new DefaultPlaceRequest("Signal Process Popup"); placeRequestImpl.addParameter("processInstanceId", processIdsParam.toString()); placeManager.goTo(placeRequestImpl); view.displayNotification(constants.Signaling_Process_Instance()); } }) .endMenu() .build() .getItems() .get(0)); bulkActions.add( MenuFactory.newSimpleItem(constants.Bulk_Abort()) .respondsWith( new Command() { @Override public void execute() { if (view.getSelectedProcessInstances() != null) { List<Long> ids = new ArrayList<Long>(); for (ProcessInstanceSummary selected : view.getSelectedProcessInstances()) { if (selected.getState() != ProcessInstance.STATE_ACTIVE) { view.displayNotification( constants.Aborting_Process_Instance_Not_Allowed() + "(id=" + selected.getId() + ")"); continue; } ids.add(selected.getId()); view.getProcessInstanceListGrid() .getSelectionModel() .setSelected(selected, false); view.displayNotification( constants.Aborting_Process_Instance() + "(id=" + selected.getId() + ")"); } abortProcessInstance(ids); } } }) .endMenu() .build() .getItems() .get(0)); return bulkActions; }