@Override protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { if (!getEditPartFromEditPartAdapter()) { if (!allChildren.isEmpty()) { getEditPartFromViewAdapter(allChildren.get(0)); } } if (mainEditPart != null) { createdNotificationConfigurator = new ArrayList<ChooseChildrenNotificationConfigurator>(); NotificationConfigurator configurator = PendingGroupNotificationsManager.getInstanceForDiagram(diagramPart) .getChooseChildrenPendingNotification(mainEditPart); ChooseChildrenNotificationConfigurator notificationConfigurator = null; if (configurator == null) { // If there is no a pending notification for this main edit part then it create one if (!allChildren.isEmpty() && isChildrenToChoose()) { notificationConfigurator = new ChooseChildrenNotificationConfigurator( mainEditPart, allChildren, automaticChildren, host, manager); notificationConfigurator.runConfigurator(); } } else { // Else update the old one if needed TODO TODO // 1 - Compare if there is any modification TODO if (configurator instanceof ChooseChildrenNotificationConfigurator) { notificationConfigurator = (ChooseChildrenNotificationConfigurator) configurator; if (notificationConfigurator.isThereAnyModification( mainEditPart, allChildren, automaticChildren, host)) { // 2 - There are some update the old notification TODO notificationConfigurator.closeNotification(); if (!allChildren.isEmpty() && isChildrenToChoose()) { notificationConfigurator = new ChooseChildrenNotificationConfigurator( mainEditPart, allChildren, automaticChildren, host, manager); notificationConfigurator.runConfigurator(); } } } } if (notificationConfigurator != null) { createdNotificationConfigurator.add(notificationConfigurator); } return CommandResult.newOKCommandResult(); } return CommandResult.newErrorCommandResult( "The editPart of the adaptable element has not been found"); //$NON-NLS-1$ }
/** * Construct the command for asking to choose graphical children of a adapter Constructor. * * @param domain * @see {@link AbstractTransactionalCommand} * @param label * @see {@link AbstractTransactionalCommand} * @param _allChildren * @see {@link #allChildren} * @param _automaticChildren * @see {@link #automaticChildren} * @param _adapter * @see {@link #adapter} */ public ChooseChildrenNotificationCommand( TransactionalEditingDomain domain, String label, List<IGraphicalEditPart> _allChildren, List<IGraphicalEditPart> _automaticChildren, IAdaptable _adapter, IGraphicalEditPart getHost, DiagramEditPart _diagramPart) { super(domain, label, null); this.allChildren = _allChildren; this.automaticChildren = _automaticChildren; this.adapter = _adapter; this.host = getHost; this.diagramPart = _diagramPart; this.manager = PendingGroupNotificationsManager.getInstanceForDiagram( DiagramEditPartsUtil.getDiagramEditPart(getHost)); }