Пример #1
0
  public RefOntoUML.Dependency DealDependency(org.eclipse.uml2.uml.Dependency d1) {
    System.out.print("[Dependency] ");
    RefOntoUML.Dependency d2 = myfactory.createDependency();

    DealNamedElement(d1, d2);

    RefOntoUML.NamedElement ne2;

    // clients
    for (org.eclipse.uml2.uml.NamedElement ne1 : d1.getClients()) {
      ne2 = (RefOntoUML.NamedElement) GetElement(ne1);
      d2.getClient().add(ne2);
    }

    // suppliers
    for (org.eclipse.uml2.uml.NamedElement ne1 : d1.getSuppliers()) {
      ne2 = (RefOntoUML.NamedElement) GetElement(ne1);
      d2.getSupplier().add(ne2);
    }

    // They are PackageableElements, don't forget it
    RelateElements(d1, d2);

    return d2;
  }
 /**
  * @see
  *     nexcore.tool.uml.manager.command.DeleteUMLDirectedRelationshipCommand#deleteDirectedAttributes()
  */
 @Override
 protected void deleteDirectedAttributes() {
   Dependency dependency = (Dependency) this.targetElement;
   // this.source = dependency.getSources().get(0);
   // this.target = dependency.getTargets().get(0);
   dependency.getClients().clear();
   dependency.getSuppliers().clear();
 }
Пример #3
0
 public boolean renderObject(
     Dependency dependency, IndentedPrintWriter writer, IRenderingSession context) {
   if (dependency.getSuppliers().isEmpty()) return false;
   writer.write("dependency ");
   writer.write(
       TextUMLRenderingUtils.getQualifiedNameIfNeeded(
           dependency.getSuppliers().get(0), dependency.getNamespace()));
   writer.println(";");
   return true;
 }
  public DependencyRelationship create(Dependency element) {

    EList<NamedElement> suppliers = element.getSuppliers();
    EList<NamedElement> clieents = element.getClients();

    Element client = architecture.findElementById(getModelHelper().getXmiId(clieents.get(0)));
    Element supplier = architecture.findElementById(getModelHelper().getXmiId(suppliers.get(0)));

    if ((client instanceof Class) && (supplier instanceof Interface))
      ((Class) client).addRequiredInterface((Interface) supplier);

    if ((client instanceof Package) && (supplier instanceof Interface))
      ((Package) client).addRequiredInterface((Interface) supplier);

    DependencyRelationship dependency =
        new DependencyRelationship(
            supplier, client, element.getName(), getModelHelper().getXmiId(element));
    dependency.setStereotypes(StereotypeHelper.getAllRelationshipStereotypes(element));

    return dependency;
  }
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 public Dependency getBase_Dependency() {
   if (base_Dependency != null && base_Dependency.eIsProxy()) {
     InternalEObject oldBase_Dependency = (InternalEObject) base_Dependency;
     base_Dependency = (Dependency) eResolveProxy(oldBase_Dependency);
     if (base_Dependency != oldBase_Dependency) {
       if (eNotificationRequired())
         eNotify(
             new ENotificationImpl(
                 this,
                 Notification.RESOLVE,
                 BpmnprofPackage.MESSAGE_FLOW_ASSOCIATION__BASE_DEPENDENCY,
                 oldBase_Dependency,
                 base_Dependency));
     }
   }
   return base_Dependency;
 }
  /**
   *
   *
   * <pre>
   *  The method executes the creation :
   *  - opens a selection dialog to choose a {@link ConnectableElement} reference as a role by the {@link CollaborationUse} type
   *  - created a dependency between the selected role and the {@link ConnectableElement} that will be bind to it
   *
   * {@inheritDoc}
   * </pre>
   */
  @Override
  protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info)
      throws ExecutionException {

    if (!canExecute()) {
      throw new ExecutionException(Messages.RoleBindingCreateCommand_INVALID_ARGS_MSG);
    }

    // Retrieve the graphical source of the binding.
    // This differs from the semantic source of the binding which is a role of the
    // CollaborationUse type.
    CollaborationUse graphicalSource = (CollaborationUse) getSource();

    // Create and open the selection dialog
    ComposedAdapterFactory adapterFactory =
        new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
    Shell currentShell = new Shell(Display.getCurrent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
    ElementTreeSelectionDialog dialog =
        new ElementTreeSelectionDialog(
            currentShell,
            new AdapterFactoryLabelProvider(adapterFactory),
            new CollaborationRoleTreeContentProvider());

    try {
      // Set dialog parameters
      dialog.setTitle(Messages.RoleBindingRoleSelectionDialog_Title);
      dialog.setMessage(Messages.RoleBindingRoleSelectionDialog_Message);
      dialog.setAllowMultiple(false);
      dialog.setHelpAvailable(false);
      // The source CollaborationUse is set as input for the selection dialog,
      // the CollaborationRoleTreeContentProvider provides the roles that can possibly be
      // selected.
      dialog.setInput(graphicalSource);

      dialog.open();
    } finally {
      adapterFactory.dispose();
    }

    // If a ConnectableElement has been selected, complete command execution
    // using selection as the "newly created" element and make the edited
    // Collaboration reference it in the CollaborationRoles eReference.
    if (dialog.getReturnCode() == ElementTreeSelectionDialog.OK) {

      ConnectableElement roleToBind = (ConnectableElement) dialog.getFirstResult();
      // Create a Dependency (the binding) between selected role and a ConnectableElement
      // (the target)
      Dependency newBinding = UMLFactory.eINSTANCE.createDependency();
      getContainer().getPackagedElements().add(newBinding);
      newBinding.getClients().add(roleToBind);
      newBinding.setName("binding_" + roleToBind.getName() + "_" + getTarget().getName());
      newBinding.getSuppliers().add(getTarget());
      graphicalSource.getRoleBindings().add(newBinding);

      doConfigure(newBinding, monitor, info);

      ((CreateElementRequest) getRequest()).setNewElement(newBinding);

      return CommandResult.newOKCommandResult(newBinding);
    }

    // No role selected: abort element creation
    return CommandResult.newCancelledCommandResult();
  }
  /**
   * States if the given object is related to the context {@link Classifier}.
   *
   * @param toFilter the candidate to check for relation
   * @param context the classifier context object.
   * @return <code>true</code> if the given object is related to the context {@link Classifier},
   *     <code>false</code> otherwise.
   */
  public boolean isRelated(EObject toFilter, EObject context) {
    boolean res = false;
    if (toFilter.equals(context)) {
      res = true;
    } else if (context instanceof Classifier) {
      if (toFilter instanceof Generalization) {
        res =
            ((Classifier) context).getGeneralizations().contains(toFilter)
                || ((Generalization) toFilter).getGeneral() == context;
      } else if (toFilter instanceof InterfaceRealization && context instanceof Class) {
        res =
            ((Class) context).getInterfaceRealizations().contains(toFilter)
                || ((InterfaceRealization) toFilter).getContract() == context;
      } else if (toFilter instanceof Association) {
        res = ((Classifier) context).getAssociations().contains(toFilter);
      } else if (toFilter instanceof Artifact && context instanceof ExecutionEnvironment) {
        for (final Deployment deployment : ((ExecutionEnvironment) context).getDeployments()) {
          if (deployment.getSuppliers().contains(toFilter)) {
            res = true;
          }
        }
      } else if (toFilter instanceof ExecutionEnvironment && context instanceof Artifact) {
        for (final Deployment deployment : ((ExecutionEnvironment) toFilter).getDeployments()) {
          if (deployment.getSuppliers().contains(context)) {
            res = true;
          }
        }
      } else if (toFilter instanceof PackageableElement && context instanceof Artifact) {
        res = ((Artifact) context).getManifestations().contains(toFilter);
        for (final Manifestation manifestation : ((Artifact) context).getManifestations()) {
          if (manifestation.getTargets().contains(toFilter)) {
            res = true;
          }
        }
      } else if (toFilter instanceof Artifact && context instanceof PackageableElement) {
        res = ((Artifact) toFilter).getManifestations().contains(context);
        for (final Manifestation manifestation : ((Artifact) toFilter).getManifestations()) {
          if (manifestation.getTargets().contains(context)) {
            res = true;
          }
        }
      } else if (toFilter instanceof Feature) {
        res = isRelated(toFilter.eContainer(), context);
      } else if (toFilter instanceof Classifier) {
        if (context == toFilter) {
          return false;
        }
        res = context == toFilter;

        if (context instanceof EncapsulatedClassifier
            && toFilter instanceof EncapsulatedClassifier) {
          if (!res) {
            if (((EncapsulatedClassifier) context).getOwnedElements().contains(toFilter)) {
              res = true;
            } else {
              for (final Port portContext : ((EncapsulatedClassifier) context).getOwnedPorts()) {
                if (portIsRelated(toFilter, portContext)) {
                  res = true;
                  break;
                }
              }
            }
          }
        }

        if (context instanceof EncapsulatedClassifier && toFilter instanceof Property) {
          if (!res) {
            if (((EncapsulatedClassifier) context).getOwnedAttributes().contains(toFilter)) {
              res = true;
            }
          }
        }

        // is it a generalization end
        if (!res) {
          for (final Generalization generalization : ((Classifier) context).getGeneralizations()) {
            if (generalization.getGeneral() == toFilter) {
              res = true;
              break;
            }
          }
        }
        // is it a generalization opposite end
        if (!res) {
          for (final Generalization generalization : ((Classifier) toFilter).getGeneralizations()) {
            if (generalization.getGeneral() == context) {
              res = true;
              break;
            }
          }
        }
        if (toFilter instanceof NamedElement && context instanceof NamedElement) {
          // is it a dependency end
          if (!res) {
            for (final Dependency dependency : ((NamedElement) context).getClientDependencies()) {
              if (dependency.getClients().contains(toFilter)
                  || dependency.getSuppliers().contains(toFilter)) {
                res = true;
                break;
              }
            }
          }
        }
        if (context instanceof NamedElement && toFilter instanceof NamedElement) {
          // is it a dependency end
          if (!res) {
            for (final Dependency dependency : ((NamedElement) toFilter).getClientDependencies()) {
              if (dependency.getClients().contains(context)
                  || dependency.getSuppliers().contains(context)) {
                res = true;
                break;
              }
            }
          }
        }
        if (toFilter instanceof Interface && context instanceof Class) {
          // is it a realization end
          if (!res) {
            for (final InterfaceRealization realization :
                ((Class) context).getInterfaceRealizations()) {
              if (realization.getContract() == toFilter) {
                res = true;
                break;
              }
            }
          }
        }
        if (context instanceof Interface && toFilter instanceof Class) {
          // is it a realization end
          if (!res) {
            for (final InterfaceRealization realization :
                ((Class) toFilter).getInterfaceRealizations()) {
              if (realization.getContract() == context) {
                res = true;
                break;
              }
            }
          }
        }

        // is it an association end
        if (!res) {
          final List<Association> toFilterAsso = ((Classifier) toFilter).getAssociations();
          final List<Association> contextAsso = ((Classifier) context).getAssociations();
          for (final Association association : toFilterAsso) {
            if (contextAsso.contains(association)) {
              res = true;
              break;
            }
          }
        }
      } else if (toFilter instanceof Package) {
        for (final EObject content : toFilter.eContents()) {
          if (isRelated(content, context)) {
            res = true;
            break;
          }
        }
      }
    } else if (context instanceof Package) {
      if (toFilter instanceof Package) {
        res =
            ((Package) context).getNestedPackages().contains(toFilter)
                || ((Package) context).getImportedPackages().contains(toFilter);
        for (final PackageImport packageImport : ((Package) context).getPackageImports()) {
          if (packageImport.getImportedPackage().equals(toFilter)) {
            res = true;
          }
        }
      } else {
        res = ((Package) context).getOwnedElements().contains(toFilter);
      }
    } else if (context instanceof Port) {
      res = portIsRelated(toFilter, (Port) context);
    }

    return res;
  }