//'Remove Contract' item
if(contract.getStatus() == ContractStatus.UNCOMPLETED &&
currentUserId != null && contract.getOwner() != null && contract.getOwner().getId().equals(currentUserId)) {
toolbarActions.add(new ToolbarItem() {
private static final long serialVersionUID = 1L;
@Override
public Component getComponent(String componentId) {
return new LinkPanel(componentId, new ResourceModel(MKEY_CONTRACT_REMOVE)) {
private static final long serialVersionUID = 1L;
@Override
protected void onClick() {
//delete the current contract
Contract contract = getContract();
contractRemover.remove(contract.getId());
//Go to contracts list.
setResponsePage(Collaboration.class);
}
};
}
});
}
//'Accept Contract' item
if(contract.getStatus() == ContractStatus.READY &&
contractStatusInformant.getContractStatus(contract, currentUserId) != ContractStatus.ACCEPTED &&
!isUserDebtExceeded() &&
contractInformant.isUserEffective(contract, currentUserId)) {
toolbarActions.add(new ToolbarItem() {
private static final long serialVersionUID = 1L;
@Override
public Component getComponent(String componentId) {
return new AjaxLinkPanel<Void>(componentId, new ResourceModel(MKEY_CONTRACT_ACCEPT)) {
private static final long serialVersionUID = 1L;
@Override
protected void onClick(AjaxRequestTarget target) {
//Mark the current contract as accepted
Contract contract = getContract();
contract = contractWriter.accept(
authorizedUserService.getCurrentUser(),
contract);
eventsDispatcher.publishEvent(new ContractAccepted(contract,
authorizedUserService.getCurrentUser()));
if(target != null) {
target.add(toolbar.getParent());
target.add(statusSign);
}
}
};
}
});
}
//'Cancel Acceptance' item
if(contractPermissionsInformant.isContractCancelAcceptanceAllowed(
contract)) {
toolbarActions.add(new ToolbarItem() {
private static final long serialVersionUID = 1L;
@Override
public Component getComponent(String componentId) {
return new AjaxLinkPanel<Void>(componentId, new ResourceModel(MKEY_CONTRACT_CANCEL_ACCEPT)) {