/**
   * {@inheritDoc}
   *
   * @see
   *     org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionListener#firePropertiesChanged(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
   */
  public void firePropertiesChanged(IPropertiesEditionEvent event) {
    if (!isInitializing()) {
      Diagnostic valueDiagnostic = validateValue(event);
      if (PropertiesEditionEvent.COMMIT == event.getState()
          && IPropertiesEditionComponent.LIVE_MODE.equals(editing_mode)
          && valueDiagnostic.getSeverity() == Diagnostic.OK) {
        CompoundCommand command = new CompoundCommand();
        if (TarotViewsRepository.GamePlayers.players == event.getAffectedEditor()) {
          if (PropertiesEditionEvent.SET == event.getKind()) {
            Player oldValue = (Player) event.getOldValue();
            Player newValue = (Player) event.getNewValue();
            // TODO: Complete the game update command
            for (EStructuralFeature feature : newValue.eClass().getEAllStructuralFeatures()) {
              if (feature.isChangeable()
                  && !(feature instanceof EReference && ((EReference) feature).isContainer())) {
                command.append(
                    SetCommand.create(
                        liveEditingDomain, oldValue, feature, newValue.eGet(feature)));
              }
            }
          } else if (PropertiesEditionEvent.ADD == event.getKind())
            command.append(
                AddCommand.create(
                    liveEditingDomain,
                    game,
                    TarotPackage.eINSTANCE.getGame_Players(),
                    event.getNewValue()));
          else if (PropertiesEditionEvent.REMOVE == event.getKind())
            command.append(DeleteCommand.create(liveEditingDomain, event.getNewValue()));
          else if (PropertiesEditionEvent.MOVE == event.getKind())
            command.append(
                MoveCommand.create(
                    liveEditingDomain,
                    game,
                    TarotPackage.eINSTANCE.getPlayer(),
                    event.getNewValue(),
                    event.getNewIndex()));
        }

        if (!command.isEmpty() && !command.canExecute()) {
          EEFRuntimePlugin.getDefault().logError("Cannot perform model change command.", null);
        } else {
          liveEditingDomain.getCommandStack().execute(command);
        }
      }
      if (valueDiagnostic.getSeverity() != Diagnostic.OK
          && valueDiagnostic instanceof BasicDiagnostic)
        super.firePropertiesChanged(new PropertiesValidationEditionEvent(event, valueDiagnostic));
      else {
        Diagnostic validate = validate();
        super.firePropertiesChanged(new PropertiesValidationEditionEvent(event, validate));
      }
      super.firePropertiesChanged(event);
    }
  }
  /**
   * @see
   *     org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
   */
  public Object execute(ExecutionEvent event) throws ExecutionException {
    toSelect = new ArrayList<EObject>();
    IEditorPart editor = RequirementUtils.getCurrentEditor();
    IEditorServices services = SupportingEditorsManager.getInstance().getServices(editor);
    CurrentPage page = RequirementHelper.INSTANCE.getCurrentPage();

    if (services != null
        && ((EvaluationContext) event.getApplicationContext()).getDefaultVariable()
            instanceof List<?>) {
      EditingDomain editingDomain = services.getEditingDomain(editor);
      // Get the current selection
      List<?> elements =
          ((List<?>) ((EvaluationContext) event.getApplicationContext()).getDefaultVariable());
      CompoundCommand compoundCmd =
          new CompoundCommand(Messages.getString("AddAttributeHandler.1")); // $NON-NLS-1$
      for (Object currObject : elements) {
        EObject parent = null;
        if (currObject instanceof Attribute) {
          parent = ((Attribute) currObject).eContainer();
          int newIndex = calculateIndex(parent, (EObject) currObject);

          Attribute toDuplicate = null;
          if (currObject instanceof AttributeLink) {
            toDuplicate =
                RequirementHelper.INSTANCE.duplicateAttributeLink((AttributeLink) currObject);
          } else if (currObject instanceof ObjectAttribute) {
            toDuplicate =
                RequirementHelper.INSTANCE.duplicateObjectAttribute((ObjectAttribute) currObject);
          }
          if (parent != null && toDuplicate != null) {
            toSelect.add(toDuplicate);
            compoundCmd.appendIfCanExecute(
                AddCommand.create(
                    editingDomain,
                    parent,
                    RequirementPackage.eINSTANCE.getRequirement_Attribute(),
                    toDuplicate,
                    newIndex));
          }
        }
      }
      if (!compoundCmd.isEmpty() && compoundCmd.canExecute()) {
        editingDomain.getCommandStack().execute(compoundCmd);
        page.setSelection(new StructuredSelection(toSelect));
      }
    }
    return null;
  }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#getPropertiesEditionCommand
  *     (org.eclipse.emf.edit.domain.EditingDomain)
  */
 public CompoundCommand getPropertiesEditionCommand(EditingDomain editingDomain) {
   CompoundCommand cc = new CompoundCommand();
   if ((talk != null) && (basePart != null)) {
     cc.append(
         SetCommand.create(
             editingDomain,
             talk,
             NonregPackage.eINSTANCE.getTalk_Presenter(),
             basePart.getCombo()));
     cc.append(
         SetCommand.create(
             editingDomain,
             talk,
             NonregPackage.eINSTANCE.getTalk_Presenter(),
             basePart.getComboRO()));
   }
   if (!cc.isEmpty()) return cc;
   cc.append(IdentityCommand.INSTANCE);
   return cc;
 }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#getPropertiesEditionCommand
  *     (org.eclipse.emf.edit.domain.EditingDomain)
  */
 public CompoundCommand getPropertiesEditionCommand(EditingDomain editingDomain) {
   CompoundCommand cc = new CompoundCommand();
   if ((game != null) && (gamePlayersPart != null)) {
     List playersToAddFromPlayers = gamePlayersPart.getPlayersToAdd();
     for (Iterator iter = playersToAddFromPlayers.iterator(); iter.hasNext(); )
       cc.append(
           AddCommand.create(
               editingDomain, game, TarotPackage.eINSTANCE.getGame_Players(), iter.next()));
     Map playersToRefreshFromPlayers = gamePlayersPart.getPlayersToEdit();
     for (Iterator iter = playersToRefreshFromPlayers.keySet().iterator(); iter.hasNext(); ) {
       Player nextElement = (Player) iter.next();
       Player players = (Player) playersToRefreshFromPlayers.get(nextElement);
       for (EStructuralFeature feature : nextElement.eClass().getEAllStructuralFeatures()) {
         if (feature.isChangeable()
             && !(feature instanceof EReference && ((EReference) feature).isContainer())) {
           cc.append(
               SetCommand.create(editingDomain, nextElement, feature, players.eGet(feature)));
         }
       }
     }
     List playersToRemoveFromPlayers = gamePlayersPart.getPlayersToRemove();
     for (Iterator iter = playersToRemoveFromPlayers.iterator(); iter.hasNext(); )
       cc.append(DeleteCommand.create(editingDomain, iter.next()));
     List playersToMoveFromPlayers = gamePlayersPart.getPlayersToMove();
     for (Iterator iter = playersToMoveFromPlayers.iterator(); iter.hasNext(); ) {
       org.eclipse.emf.eef.runtime.impl.utils.EMFListEditUtil.MoveElement moveElement =
           (org.eclipse.emf.eef.runtime.impl.utils.EMFListEditUtil.MoveElement) iter.next();
       cc.append(
           MoveCommand.create(
               editingDomain,
               game,
               TarotPackage.eINSTANCE.getPlayer(),
               moveElement.getElement(),
               moveElement.getIndex()));
     }
   }
   if (!cc.isEmpty()) return cc;
   cc.append(IdentityCommand.INSTANCE);
   return cc;
 }
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionListener#firePropertiesChanged(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
   */
  public void firePropertiesChanged(IPropertiesEditionEvent event) {
    if (!isInitializing()) {
      Diagnostic valueDiagnostic = validateValue(event);
      if (PropertiesEditionEvent.COMMIT == event.getState()
          && IPropertiesEditionComponent.LIVE_MODE.equals(editing_mode)
          && valueDiagnostic.getSeverity() == Diagnostic.OK) {
        CompoundCommand command = new CompoundCommand();
        if (NonregViewsRepository.Combo.combo == event.getAffectedEditor())
          command.append(
              SetCommand.create(
                  liveEditingDomain,
                  talk,
                  NonregPackage.eINSTANCE.getTalk_Presenter(),
                  event.getNewValue()));
        if (NonregViewsRepository.Combo.comboRO == event.getAffectedEditor())
          command.append(
              SetCommand.create(
                  liveEditingDomain,
                  talk,
                  NonregPackage.eINSTANCE.getTalk_Presenter(),
                  event.getNewValue()));

        if (!command.isEmpty() && !command.canExecute()) {
          EEFRuntimePlugin.getDefault().logError("Cannot perform model change command.", null);
        } else {
          liveEditingDomain.getCommandStack().execute(command);
        }
      }
      if (valueDiagnostic.getSeverity() != Diagnostic.OK
          && valueDiagnostic instanceof BasicDiagnostic)
        super.firePropertiesChanged(new PropertiesValidationEditionEvent(event, valueDiagnostic));
      else {
        Diagnostic validate = validate();
        super.firePropertiesChanged(new PropertiesValidationEditionEvent(event, validate));
      }
      super.firePropertiesChanged(event);
    }
  }