/**
  * Construct an operation history action for the specified workbench window with the specified
  * undo context.
  *
  * @param site - the workbench part site for the action.
  * @param context - the undo context to be used
  */
 OperationHistoryActionHandler(IWorkbenchPartSite site, IUndoContext context) {
   // string will be reset inside action
   super(""); // $NON-NLS-1$
   this.site = site;
   undoContext = context;
   site.getPage().addPartListener(partListener);
   getHistory().addOperationHistoryListener(historyListener);
   // An update must be forced in case the undo limit is 0.
   // see bug #89707
   update();
 }
  @Override
  public void dispose() {

    IOperationHistory history = getHistory();
    if (history != null) {
      history.removeOperationHistoryListener(historyListener);
    }

    if (isInvalid()) {
      return;
    }

    site.getPage().removePartListener(partListener);
    site = null;
    progressDialog = null;
    // We do not flush the history for our undo context because it may be
    // used elsewhere. It is up to clients to clean up the history
    // appropriately.
    // We do null out the context to signify that this handler is no longer
    // accessing the history.
    undoContext = null;
  }
  /**
   * {@inheritDoc}
   *
   * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String,
   *     java.lang.Object[], java.lang.Object)
   */
  public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
    boolean canGenerateJavaServicesModule = false;

    List<ICompilationUnit> files = new ArrayList<ICompilationUnit>();

    // Compute the compilation unit selected
    if (receiver instanceof IWorkbenchPart) {
      IWorkbenchPart iWorkbenchPart = (IWorkbenchPart) receiver;
      IWorkbenchPartSite site = iWorkbenchPart.getSite();
      IWorkbenchPage page = site.getPage();
      ISelection selection = page.getSelection();
      if (selection instanceof IStructuredSelection) {
        IStructuredSelection iStructuredSelection = (IStructuredSelection) selection;
        List<?> list = iStructuredSelection.toList();
        for (Object object : list) {
          try {
            if (object instanceof ICompilationUnit
                && ((ICompilationUnit) object)
                    .getResource()
                    .getProject()
                    .hasNature(IAcceleoConstants.ACCELEO_NATURE_ID)) {
              files.add((ICompilationUnit) object);
            }
          } catch (CoreException e) {
            AcceleoUIActivator.log(e, true);
          }
        }
      }
    }

    for (ICompilationUnit iCompilationUnit : files) {
      canGenerateJavaServicesModule =
          canGenerateJavaServicesModule
              || JavaServicesUtils.isAcceleoJavaServicesClass(iCompilationUnit);
    }

    // Generate a new module for each Java services
    return canGenerateJavaServicesModule;
  }
 @Override
 public IWorkbenchPage getPage() {
   return partSite.getPage();
 }