Package eu.admire.dispel.expressions

Examples of eu.admire.dispel.expressions.ConnectionExpression


    }
    if (container == null) {
      return Collections.emptyList();
    }
    LinkedList<DispelLinkDescriptor> result = new LinkedList<DispelLinkDescriptor>();
    ConnectionExpression link = container.getExpression();
    if (ConnectionExpressionEditPart.VISUAL_ID != DispelVisualIDRegistry
        .getLinkWithClassVisualID(link)) {
      return result;
    }
    ConnectionEnabledElement dst = link.getValue();
    ConnectionEnabledElement src = link.getChild();
    if (src != source) {
      return result;
    }
    result.add(new DispelLinkDescriptor(src, dst, link,
        DispelElementTypes.ConnectionExpression_4001,
View Full Code Here


    if (!canExecute()) {
      throw new ExecutionException(
          "Invalid arguments in create link command"); //$NON-NLS-1$
    }

    ConnectionExpression newElement = ExpressionsFactory.eINSTANCE
        .createConnectionExpression();

    newElement.setConnectionOperator(OperatorsFactory.eINSTANCE
        .createConnector());

    eu.admire.dispel.containers.Package pck = null;

    if (source.eContainer() instanceof NamedElement) {

      pck = ((NamedElement) source.eContainer()).getContainingPackage();

    }

    EObject container;

    if (getSource() instanceof Output && getTarget() instanceof Input) {

      IdentifierReference src1 = ReferencesFactory.eINSTANCE
          .createIdentifierReference();

      IdentifierReference src2 = ReferencesFactory.eINSTANCE
          .createIdentifierReference();

      src1.setNext(src2);

      src2.setTarget((Output) getSource());

      Output out = (Output) getSource();

      container = out.eContainer();

      if (container instanceof ProcessingElementInstance) {

        ProcessingElementInstance pei = (ProcessingElementInstance) container;

        Collection<LocalVariable> variables = DispelEObjectUtil
            .getObjectsByType(pck.eAllContents(),
                VariablesPackage.eINSTANCE.getLocalVariable());

        for (LocalVariable var : variables) {

          if (var.getValue() != null && var.getValue().equals(pei)) {

            src1.setTarget(var);
          }
        }

      }

      /*******************************/

      IdentifierReference dst1 = ReferencesFactory.eINSTANCE
          .createIdentifierReference();

      IdentifierReference dst2 = ReferencesFactory.eINSTANCE
          .createIdentifierReference();

      dst1.setNext(dst2);

      dst2.setTarget((Input) getTarget());

      Input in = (Input) getTarget();

      container = in.eContainer();

      if (container instanceof ProcessingElementInstance) {

        ProcessingElementInstance pei = (ProcessingElementInstance) container;

        Collection<LocalVariable> variables = DispelEObjectUtil
            .getObjectsByType(pck.eAllContents(),
                VariablesPackage.eINSTANCE.getLocalVariable());

        for (LocalVariable var : variables) {

          if (var.getValue() != null && var.getValue().equals(pei)) {

            dst1.setTarget(var);
          }
        }

      }

      newElement.setChild(src1);
      newElement.setValue(dst1);

    }

    //TODO iFO following might be buggy!   

    if (getSource() instanceof ConnectionInitialization
        && getTarget() instanceof Input) {

      IdentifierReference dst1 = ReferencesFactory.eINSTANCE
          .createIdentifierReference();

      IdentifierReference dst2 = ReferencesFactory.eINSTANCE
          .createIdentifierReference();

      dst1.setNext(dst2);

      dst2.setTarget((Input) getTarget());

      Input in = (Input) getTarget();

      container = in.eContainer();

      if (container instanceof ProcessingElementInstance) {

        ProcessingElementInstance pei = (ProcessingElementInstance) container;

        Collection<LocalVariable> variables = DispelEObjectUtil
            .getObjectsByType(pck.eAllContents(),
                VariablesPackage.eINSTANCE.getLocalVariable());

        for (LocalVariable var : variables) {

          if (var.getValue() != null && var.getValue().equals(pei)) {

            dst1.setTarget(var);
          }
        }

      }

      newElement.setChild(getSource());
      newElement.setValue(dst1);
    }

    if (getSource() instanceof Output
        && getTarget() instanceof LocalVariable) {

      IdentifierReference src1 = ReferencesFactory.eINSTANCE
          .createIdentifierReference();

      IdentifierReference src2 = ReferencesFactory.eINSTANCE
          .createIdentifierReference();

      src1.setNext(src2);

      src2.setTarget((Output) getSource());

      Output out = (Output) getSource();

      container = out.eContainer();

      if (container instanceof ProcessingElementInstance) {

        ProcessingElementInstance pei = (ProcessingElementInstance) container;

        Collection<LocalVariable> variables = DispelEObjectUtil
            .getObjectsByType(pck.eAllContents(),
                VariablesPackage.eINSTANCE.getLocalVariable());

        for (LocalVariable var : variables) {

          if (var.getValue() != null && var.getValue().equals(pei)) {

            src1.setTarget(var);
          }
        }
      }

      IdentifierReference dst1 = ReferencesFactory.eINSTANCE
          .createIdentifierReference();

      dst1.setTarget((LocalVariable) getTarget());

      newElement.setChild(src1);
      newElement.setValue(dst1);

    }

    if (getSource() instanceof LocalVariable
        && getTarget() instanceof Input) {

      IdentifierReference dst1 = ReferencesFactory.eINSTANCE
          .createIdentifierReference();

      IdentifierReference dst2 = ReferencesFactory.eINSTANCE
          .createIdentifierReference();

      dst1.setNext(dst2);

      dst2.setTarget((Input) getTarget());

      Input in = (Input) getTarget();

      container = in.eContainer();

      if (container instanceof ProcessingElementInstance) {

        ProcessingElementInstance pei = (ProcessingElementInstance) container;

        LocalVariable inVar = (LocalVariable) getSource();
        pck = inVar.getContainingPackage();

        Collection<LocalVariable> variables = DispelEObjectUtil
            .getObjectsByType(pck.eAllContents(),
                VariablesPackage.eINSTANCE.getLocalVariable());

        for (LocalVariable var : variables) {

          if (var.getValue() != null && var.getValue().equals(pei)) {

            dst1.setTarget(var);
          }
        }

      }

      ConnectionInitialization src = InstantiationsFactory.eINSTANCE
          .createConnectionInitialization();

      IdentifierReference ir = ReferencesFactory.eINSTANCE
          .createIdentifierReference();
      ir.setTarget((LocalVariable) getSource());

      src.setInitialValue(ir);

      newElement.setChild(src);
      newElement.setValue(dst1);

    }

    if (newElement.getChild() != null && newElement.getValue() != null) {

      CreateElementRequest request = new CreateElementRequest(pck,
          DispelElementTypes.ConnectionStatement_2004);

      ConnectionStatementCreateCommand command = new ConnectionStatementCreateCommand(
View Full Code Here

TOP

Related Classes of eu.admire.dispel.expressions.ConnectionExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.