/** * {@inheritDoc} * * @see * org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Class, * int, org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.resource.ResourceSet) */ public void initPart(java.lang.Class key, int kind, EObject elt, ResourceSet allResource) { setInitializing(true); if (gamePlayersPart != null && key == TarotViewsRepository.GamePlayers.class) { ((IPropertiesEditionPart) gamePlayersPart).setContext(elt, allResource); final Game game = (Game) elt; // init values gamePlayersPart.initPlayers(game, null, TarotPackage.eINSTANCE.getGame_Players()); // init filters gamePlayersPart.addFilterToPlayers( new ViewerFilter() { /** * {@inheritDoc} * * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, * java.lang.Object, java.lang.Object) */ public boolean select(Viewer viewer, Object parentElement, Object element) { return (element instanceof Player); } }); // Start of user code for additional businessfilters for players // End of user code } // init values for referenced views // init filters for referenced views setInitializing(false); }
/** * {@inheritDoc} * * @see * org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#getPropertiesEditionObject() */ public EObject getPropertiesEditionObject(EObject source) { if (source instanceof Game) { Game gameToUpdate = (Game) source; gameToUpdate.getPlayers().addAll(gamePlayersPart.getPlayersToAdd()); return gameToUpdate; } else 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 ((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.component.IPropertiesEditionComponent#getTabText(java.lang.String) */ public String getTabText(String p_key) { return gamePlayersPart.getTitle(); }
/** Used to update the views */ protected void runUpdateRunnable(final Notification msg) { if (msg.getFeature() != null && ((EStructuralFeature) msg.getFeature() == TarotPackage.eINSTANCE.getGame_Players())) { gamePlayersPart.updatePlayers(game); } }