/** Default constructor */ public GameGamePlayersPropertiesEditionComponent(EObject game, String editing_mode) { if (game instanceof Game) { this.game = (Game) game; if (IPropertiesEditionComponent.LIVE_MODE.equals(editing_mode)) { semanticAdapter = initializeSemanticAdapter(); this.game.eAdapters().add(semanticAdapter); } } this.editing_mode = editing_mode; }
/** Default constructor */ public ComboPropertiesEditionComponent(EObject talk, String editing_mode) { if (talk instanceof Talk) { this.talk = (Talk) talk; if (IPropertiesEditionComponent.LIVE_MODE.equals(editing_mode)) { semanticAdapter = initializeSemanticAdapter(); this.talk.eAdapters().add(semanticAdapter); } } this.editing_mode = editing_mode; }
/** * {@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); } }
/** * {@inheritDoc} * * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validate() */ public Diagnostic validate() { Diagnostic validate = Diagnostic.OK_INSTANCE; if (IPropertiesEditionComponent.BATCH_MODE.equals(editing_mode)) { EObject copy = EcoreUtil.copy(game); copy = getPropertiesEditionObject(copy); validate = EEFRuntimePlugin.getEEFValidator().validate(copy); } else if (IPropertiesEditionComponent.LIVE_MODE.equals(editing_mode)) validate = EEFRuntimePlugin.getEEFValidator().validate(game); // Start of user code for custom validation check // End of user code return validate; }
/** * {@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); } }