コード例 #1
0
  /**
   * @see
   *     org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
   * @param event
   * @return null
   * @throws ExecutionException
   */
  public Object execute(ExecutionEvent event) throws ExecutionException {
    EObject selectedObject = getSelectedElement();

    // test if this is a constraint
    if (selectedObject instanceof Constraint) {
      Constraint constraint = (Constraint) selectedObject;

      // test if this is an opaqueExpression
      if (constraint.getSpecification() instanceof OpaqueExpression) {
        OpaqueExpression opaqueExpression = ((OpaqueExpression) constraint.getSpecification());

        // look for the good body named OCL
        int indexOfOCLBody = -1;
        for (int i = 0; i < opaqueExpression.getLanguages().size() && indexOfOCLBody == -1; i++) {
          if (opaqueExpression.getLanguages().get(i).equals("OCL")) {
            indexOfOCLBody = i;
          }
        }
        if (indexOfOCLBody != -1) {
          try {
            OCLEvaluationView view =
                (OCLEvaluationView)
                    HandlerUtil.getActiveWorkbenchWindow(event)
                        .getActivePage()
                        .showView(OCLEvaluationView.ID);
            view.compute(constraint.getContext(), opaqueExpression.getBodies().get(indexOfOCLBody));
          } catch (PartInitException e) {
            e.printStackTrace();
          }
        }
      }
    }

    return null;
  }
コード例 #2
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor,
   * org.eclipse.core.runtime.IAdaptable)
   */
  @Override
  protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
      throws ExecutionException {
    if (diagramEP != null && getEditingDomain() != null) {
      diagramEP.refresh();
      Namespace context = constraint.getContext();
      Collection<EditPart> allTopSemanticEditPart =
          DiagramEditPartsUtil.getAllTopSemanticEditPart(diagramEP);
      EditPart constraintEditPart = getEditPart(constraint, allTopSemanticEditPart);
      EditPart contextEditPart = getEditPart(context, allTopSemanticEditPart);

      if (constraintEditPart != null && contextEditPart != null) {
        Collection<EditPart> constraintAndContext = new ArrayList<EditPart>();
        constraintAndContext.add(constraintEditPart);
        constraintAndContext.add(contextEditPart);
        final Request request =
            new ShowHideRelatedLinkRequest(
                constraintAndContext, ShowHideKind.SHOW_ALL_LINK_BETWEEN_SELECTED_ELEMENT);
        final Command cmd = diagramEP.getCommand(request);
        if (cmd != null) {
          cmd.execute();
        }
      }
    }
    return null;
  }
コード例 #3
0
 /** @generated */
 public boolean canCreateConstraintContext_8500(Constraint source, Namespace target) {
   if (source != null) {
     if (source.getContext() != null) {
       return false;
     }
   }
   if (target != null && (target.getOwnedRules().contains(target))) {
     return false;
   }
   return canExistConstraintContext_8500(source, target);
 }