예제 #1
0
 private void assertRGOReference(
     NonRootModelElement rgo, NonRootModelElement rto, boolean defaultReference) {
   Method defaultMethod;
   try {
     defaultMethod = getDefaultReferenceMethod(rgo, rto);
     Object result = defaultMethod.invoke(rgo, new Object[0]);
     if (defaultReference) {
       assertTrue(
           "After a cut the RGO of type "
               + rgo.getClass().getSimpleName()
               + " was not referring to default RTO.",
           ((Boolean) result).booleanValue());
     } else {
       assertFalse(
           "After a paste the RGO of type "
               + rgo.getClass().getSimpleName()
               + " was referring to default RTO.",
           ((Boolean) result).booleanValue());
     }
   } catch (SecurityException e) {
     fail(e.getMessage());
   } catch (NoSuchMethodException e) {
     fail(e.getMessage());
   } catch (IllegalArgumentException e) {
     fail(e.getMessage());
   } catch (IllegalAccessException e) {
     fail(e.getMessage());
   } catch (InvocationTargetException e) {
     fail(e.getMessage());
   }
 }
예제 #2
0
  private NonRootModelElement getDestination(NonRootModelElement rto) {
    if (rto instanceof InterfaceReference_c && getMethodName().contains("C1")) {
      // need the package for the parent component
      return rto.getFirstParentComponent().getFirstParentPackage();
    }
    if (rto instanceof Port_c && getMethodName().contains("C1")) {
      // need the package for the parent component
      return rto.getFirstParentComponent().getFirstParentPackage();
    }
    if (getMethodName().contains("C1")) {
      return rto.getFirstParentPackage();
    } else if (getMethodName().contains("C2")) {
      return Package_c.getOneEP_PKGOnR1401(inscopeOtherProject);
    } else if (getMethodName().contains("C3")) {
      return Package_c.getOneEP_PKGOnR1401(
          m_sys,
          new ClassQueryInterface_c() {

            @Override
            public boolean evaluate(Object candidate) {
              Package_c pkg = (Package_c) candidate;
              PackageableElement_c pe = PackageableElement_c.getOnePE_PEOnR8001(pkg);
              if (pe.getVisibility() == Visibility_c.Private) {
                return true;
              }
              return false;
            }
          });
    } else {
      return Package_c.getOneEP_PKGOnR1401(outOfScopeOtherProject);
    }
  }
예제 #3
0
 private Method getDefaultReferenceMethod(NonRootModelElement rgo, NonRootModelElement rto)
     throws SecurityException, NoSuchMethodException {
   return rgo.getClass()
       .getMethod(
           "Isreferringtodefault"
               + rto.getClass().getSimpleName().replaceAll("_c", "").toLowerCase(),
           new Class<?>[0]);
 }
 private boolean isSynchronized(Object element) {
   if (element instanceof NonRootModelElement) {
     NonRootModelElement nrme = (NonRootModelElement) element;
     if (nrme.Issynchronized()) {
       // check children as well
       return childrenAreSynchronized(nrme);
     } else {
       return false;
     }
   }
   return true;
 }
  private IMarker[] parseModel(NonRootModelElement testElement) throws CoreException {
    BaseTest.dispatchEvents(0);
    try {
      Bundle ui_text = Platform.getBundle("org.xtuml.bp.ui.text"); // $NON-NLS-1$
      Class<?> factoryClass =
          ui_text.loadClass("org.xtuml.bp.ui.text.activity.AllActivityModifier"); // $NON-NLS-1$

      // find the constructor that takes package and monitor as parameters
      Class<?>[] arg_types = new Class[] {testElement.getClass(), IProgressMonitor.class};
      Constructor<?> ctor = factoryClass.getDeclaredConstructor(arg_types);

      // invoke the constructor to create an instance
      Object[] args = new Object[] {testElement, new NullProgressMonitor()};
      IAllActivityModifier aam = (IAllActivityModifier) ctor.newInstance(args);

      aam.processAllActivities(IAllActivityModifier.PARSE);
    } catch (ClassNotFoundException cnf) {
      CorePlugin.logError("Problem loading activity parser ", cnf);
    } catch (IllegalAccessException i) {
      CorePlugin.logError("Problem loading activity parser ", i);
    } catch (InstantiationException i) {
      CorePlugin.logError("Problem loading activity parser ", i);
    } catch (InvocationTargetException e) {
      CorePlugin.logError("Problem running activity parser ", e);
    } catch (SecurityException e) {
      CorePlugin.logError("Problem running activity parser ", e);
    } catch (NoSuchMethodException e) {
      CorePlugin.logError("Problem running activity parser ", e);
    }
    return collectParseErrors(testElement);
  }
 private boolean childrenAreSynchronized(NonRootModelElement element) {
   boolean result = true;
   result = element.Issynchronized();
   if (result) {
     List<?> children = new ArrayList<Object>();
     element.Collectreferencesforsynchronization(children, Synchronizationtype_c.Pull);
     for (Object child : children) {
       if (((NonRootModelElement) child).getModelRoot() instanceof Ooaofooa) {
         result = childrenAreSynchronized((NonRootModelElement) child);
         if (!result) {
           return result;
         }
       }
     }
   }
   return result;
 }
예제 #7
0
  /* (non-Javadoc)
   * @see org.eclipse.ui.IPersistableElement#saveState(org.eclipse.ui.IMemento)
   */
  public void saveState(IMemento memento) {
    String root_id = m_input.getModelRoot().getId();
    Ooaofooa modelRoot = Ooaofooa.getInstance(root_id, false);

    memento.putString(GraphicalEditorFactory.TAG_MODELROOTID, m_input.getModelRoot().getId());
    memento.putString(GraphicalEditorFactory.TAG_OOAID, m_input.getOoa_id().toString());
    memento.putInteger(GraphicalEditorFactory.TAG_OOATYPE, m_input.getOoa_type());
    memento.putInteger(GraphicalEditorFactory.TAG_MODELTYPE, m_input.getModel_type());
    NonRootModelElement nrme = (NonRootModelElement) m_input.getRepresents();
    if (nrme == null) {
      nrme =
          (NonRootModelElement)
              Cl_c.Getinstancefromooa_id(modelRoot, m_input.getOoa_id(), m_input.getOoa_type());
    }

    // if there's no way to get a component path, then don't save the tag
    // CanvasFactory.createElement() will check for the tag's existence
    // before doing anything
    if (nrme != null) {
      memento.putString(GraphicalEditorFactory.TAG_COMPONENTPATH, nrme.getContent());
    }
  }
예제 #8
0
 private Method getAccessorMethod(NonRootModelElement rgo, NonRootModelElement rto) {
   String association = ElementMap.getAssociationFor(getMethodName().replaceAll("test", ""));
   Method[] methods = rto.getClass().getMethods();
   for (Method method : methods) {
     if (method.getName().matches("getOne.*OnR" + association)) {
       if (method.getParameterTypes().length == 1
           && method.getParameterTypes()[0].isInstance(rgo)) {
         return method;
       }
     }
   }
   return null;
 }
예제 #9
0
  private Object[] getCuttableElements(NonRootModelElement rto) {
    List<Object> elements = new ArrayList<Object>();
    if (rto instanceof InterfaceReference_c) {
      // need to include self and the parent component
      elements.add(rto.getFirstParentComponent());
      // and add the provision or requirement
      Provision_c pro = Provision_c.getOneC_POnR4009((InterfaceReference_c) rto);
      Requirement_c req = Requirement_c.getOneC_ROnR4009((InterfaceReference_c) rto);
      if (pro != null) {
        elements.add(pro);
      } else {
        elements.add(req);
      }
    }

    if (rto instanceof Port_c) {
      // need to include self and the parent component
      elements.add(rto.getFirstParentComponent());
      // and add the provision or requirement
      Provision_c pro =
          Provision_c.getOneC_POnR4009(InterfaceReference_c.getOneC_IROnR4016((Port_c) rto));
      Requirement_c req =
          Requirement_c.getOneC_ROnR4009(InterfaceReference_c.getOneC_IROnR4016((Port_c) rto));
      if (pro != null) {
        elements.add(pro);
      } else {
        elements.add(req);
      }
    } else if (rto instanceof ExecutableProperty_c) {
      // need to cut the interface
      Interface_c iface = Interface_c.getOneC_IOnR4003((ExecutableProperty_c) rto);
      elements.add(iface);
    } else {
      elements.add(getSelectableElement(rto));
    }
    return elements.toArray();
  }
예제 #10
0
 private void configureRGOReference(NonRootModelElement rgo, NonRootModelElement rto) {
   TransactionManager manager = TransactionManager.getSingleton();
   Transaction transaction = null;
   String association = ElementMap.getAssociationFor(getMethodName().replaceAll("test", ""));
   NonRootModelElement newRto =
       getElement(getMethodName().replaceAll("test", ""), rto.getClass(), true);
   try {
     transaction =
         manager.startTransaction("Adjust RGO", new Ooaofooa[] {Ooaofooa.getDefaultInstance()});
     if (rgo instanceof ProvidedExecutableProperty_c) {
       // need to reassign the provision
       Interface_c iface = Interface_c.getOneC_IOnR4003((ExecutableProperty_c) newRto);
       Provision_c provision = Provision_c.getOneC_POnR4501((ProvidedExecutableProperty_c) rgo);
       provision.Unformalize(false);
       provision.Formalize(iface.getId(), false);
       this.rgo = ProvidedExecutableProperty_c.getOneSPR_PEPOnR4501(provision);
     } else if (rgo instanceof RequiredExecutableProperty_c) {
       // need to reassign the requirement
       Interface_c iface = Interface_c.getOneC_IOnR4003((ExecutableProperty_c) newRto);
       Requirement_c requirement =
           Requirement_c.getOneC_ROnR4500((RequiredExecutableProperty_c) rgo);
       requirement.Unformalize(false);
       requirement.Formalize(iface.getId(), false);
       // need to reset the RGO
       this.rgo = RequiredExecutableProperty_c.getOneSPR_REPOnR4500(requirement);
     } else {
       Method getMethod = getAccessorMethod(rgo, rto);
       NonRootModelElement existing =
           (NonRootModelElement) getMethod.invoke(rto, new Object[] {rgo});
       Method method = getUnrelateMethod(association, existing, rgo);
       method.invoke(existing, new Object[] {rgo});
       method = getRelateMethod(association, newRto, rgo);
       method.invoke(newRto, new Object[] {rgo});
     }
   } catch (Exception e) {
     fail(e.getMessage());
     if (transaction != null) {
       manager.cancelTransaction(transaction);
     }
   } finally {
     if (transaction != null) {
       manager.endTransaction(transaction);
       rgoUpdateSuccessful = true;
     }
   }
   BaseTest.dispatchEvents(0);
 }
예제 #11
0
 public static String getCanvasEditorPostTitle(
     final NonRootModelElement element, boolean checkElementToEdit) {
   ModelSpecification_c[] modelSpecs =
       ModelSpecification_c.ModelSpecificationInstances(Ooaofgraphics.getDefaultInstance());
   Class clazz = element.getClass();
   if (checkElementToEdit) {
     Object elementToEdit = EditorUtil.getElementToEdit(element);
     if (elementToEdit.getClass() != clazz) {
       clazz = elementToEdit.getClass();
     }
   }
   for (int i = 0; i < modelSpecs.length; i++) {
     if (modelSpecs[i].getRepresents() == clazz) {
       return ": " + modelSpecs[i].getName();
     }
   }
   return "";
 }
예제 #12
0
  public static PersistableModelComponent getComponentOfElementInResize(
      final NonRootModelElement me) {
    Model_c model = null;
    if (me instanceof ElementInResize_c) {
      final ElementInResize_c elementInResize = (ElementInResize_c) me;
      model =
          Model_c.ModelInstance(
              me.getModelRoot(),
              new ClassQueryInterface_c() {
                public boolean evaluate(Object candidate) {
                  return ((Model_c) candidate)
                      .getDiagramid()
                      .equals(elementInResize.getDiagramidCachedValue());
                }
              },
              false);
    }

    if (model != null) return model.getPersistableComponent();
    else return null;
  }
예제 #13
0
  /*
   * Recursively traverse bottom-up building the "-" separated list of names
   * of the parent elements.
   */
  public static String getContainerList(NonRootModelElement elem, int ooaType) {
    String rVal = "";
    Object parent = null;
    ModelInspector inspector = new ModelInspector();
    IModelClassInspector classInspector = null;

    if (ooaType == Ooatype_c.DataTypePackage) {
      classInspector = inspector.getInspector(DataTypePackage_c.class);
      parent = classInspector.getParent(elem);
    } else if (ooaType == Ooatype_c.ExternalEntityPackage) {
      classInspector = inspector.getInspector(ExternalEntityPackage_c.class);
      parent = classInspector.getParent(elem);
    } else if (ooaType == Ooatype_c.FunctionPackage) {
      classInspector = inspector.getInspector(FunctionPackage_c.class);
      parent = classInspector.getParent(elem);
    } else if (ooaType == Ooatype_c.Subsystem) {
      Subsystem_c subsystemParent =
          Subsystem_c.getOneS_SSOnR41(SubsystemInSubsystem_c.getOneS_SISOnR42((Subsystem_c) elem));
      if (subsystemParent != null) {
        parent = subsystemParent;
      } else {
        classInspector = inspector.getInspector(Subsystem_c.class);
        parent = classInspector.getParent(elem);
      }
    } else if (ooaType == Ooatype_c.Sequence) {
      classInspector = inspector.getInspector(Sequence_c.class);
      parent = classInspector.getParent(elem);
    } else if (ooaType == Ooatype_c.Communication) {
      classInspector = inspector.getInspector(Communication_c.class);
      parent = classInspector.getParent(elem);
    } else if (ooaType == Ooatype_c.UseCaseDiagram) {
      classInspector = inspector.getInspector(UseCaseDiagram_c.class);
      parent = classInspector.getParent(elem);
    } else if (ooaType == Ooatype_c.Activity) {
      classInspector = inspector.getInspector(Activity_c.class);
      parent = classInspector.getParent(elem);
    } else if (ooaType == Ooatype_c.StateMachine) {
      ModelClass_c obj = null;
      Class eClass = elem.getClass();
      if (eClass == ClassStateMachine_c.class) {
        obj = ModelClass_c.getOneO_OBJOnR519((ClassStateMachine_c) elem);
      }
      if (obj == null) {
        obj = ModelClass_c.getOneO_OBJOnR518((InstanceStateMachine_c) elem);
      }
      if (obj != null) {
        classInspector = inspector.getInspector(ModelClass_c.class);
        parent = classInspector.getParent(obj);
      }
    } else if (ooaType == Ooatype_c.Domain) {
      classInspector = inspector.getInspector(Domain_c.class);
      parent = classInspector.getParent(elem);
    } else if (ooaType == Ooatype_c.Component) {
      classInspector = inspector.getInspector(Component_c.class);
      parent = classInspector.getParent(elem);
    } else if (ooaType == Ooatype_c.ComponentPackage) {
      classInspector = inspector.getInspector(ComponentPackage_c.class);
      parent = classInspector.getParent(elem);
    } else if (ooaType == Ooatype_c.InterfacePackage) {
      classInspector = inspector.getInspector(InterfacePackage_c.class);
      parent = classInspector.getParent(elem);
    } else if (ooaType == Ooatype_c.Package) {
      classInspector = inspector.getInspector(Package_c.class);
      parent = classInspector.getParent(elem);
    }

    if (parent != null) {
      NonRootModelElement parentElem = (NonRootModelElement) parent;
      Class parentClass = parent.getClass();
      if (parentClass == DataTypePackage_c.class) {
        rVal =
            getContainerList(parentElem, Ooatype_c.DataTypePackage)
                + parentElem.getName()
                + "-"; //$NON-NLS-1$
      } else if (parentClass == ExternalEntityPackage_c.class) {
        rVal =
            getContainerList(parentElem, Ooatype_c.ExternalEntityPackage)
                + parentElem.getName()
                + "-"; //$NON-NLS-1$
      } else if (parentClass == FunctionPackage_c.class) {
        rVal =
            getContainerList(parentElem, Ooatype_c.FunctionPackage)
                + parentElem.getName()
                + "-"; //$NON-NLS-1$
      } else if (parentClass == Subsystem_c.class) {
        rVal =
            getContainerList(parentElem, Ooatype_c.Subsystem)
                + parentElem.getName()
                + "-"; //$NON-NLS-1$
      } else if (parentClass == Sequence_c.class) {
        rVal =
            getContainerList(parentElem, Ooatype_c.Sequence)
                + parentElem.getName()
                + "-"; //$NON-NLS-1$
      } else if (parentClass == Communication_c.class) {
        rVal =
            getContainerList(parentElem, Ooatype_c.Communication)
                + parentElem.getName()
                + "-"; //$NON-NLS-1$
      } else if (parentClass == UseCaseDiagram_c.class) {
        rVal =
            getContainerList(parentElem, Ooatype_c.UseCaseDiagram)
                + parentElem.getName()
                + "-"; //$NON-NLS-1$
      } else if (parentClass == Activity_c.class) {
        rVal =
            getContainerList(parentElem, Ooatype_c.Activity)
                + parentElem.getName()
                + "-"; //$NON-NLS-1$
      } else if (parentClass == Domain_c.class) {
        rVal =
            getContainerList(parentElem, Ooatype_c.Domain)
                + parentElem.getName()
                + "-"; //$NON-NLS-1$
      } else if (parentClass == Component_c.class) {
        rVal =
            getContainerList(parentElem, Ooatype_c.Component)
                + parentElem.getName()
                + "-"; //$NON-NLS-1$
      } else if (parentClass == ComponentPackage_c.class) {
        rVal =
            getContainerList(parentElem, Ooatype_c.ComponentPackage)
                + parentElem.getName()
                + "-"; //$NON-NLS-1$
      } else if (parentClass == InterfacePackage_c.class) {
        rVal =
            getContainerList(parentElem, Ooatype_c.InterfacePackage)
                + parentElem.getName()
                + "-"; //$NON-NLS-1$
      } else if (parentClass == Package_c.class) {
        rVal =
            getContainerList(parentElem, Ooatype_c.Package)
                + parentElem.getName()
                + "-"; //$NON-NLS-1$
      } else {
        rVal = parentElem.getName() + "-";
      }
    }
    return rVal;
  }
예제 #14
0
 private Method getUnrelateMethod(
     String association, NonRootModelElement rto, NonRootModelElement rgo)
     throws SecurityException, NoSuchMethodException {
   return rto.getClass()
       .getMethod("unrelateAcrossR" + association + "From", new Class<?>[] {rgo.getClass()});
 }
예제 #15
0
 private NonRootModelElement getElement(String key, Class<?> elementType, boolean nonDefault) {
   NonRootModelElement element = null;
   String name = elementType.getSimpleName();
   if (key.startsWith("A")) {
     name = name + "_RTO";
   } else {
     name = name + "_RGO";
   }
   if (elementType == ImportedReference_c.class) {
     // name will match RTO
     name = "InterfaceReference_c_RTO";
   }
   if (elementType == PortReference_c.class && rto instanceof Port_c) {
     name = "Port_c_RTO";
   }
   if (elementType == InterfaceReference_c.class && rto instanceof Port_c) {
     // name will match RTO
     name = "PortReference_c_RTO";
   }
   if (elementType == InterfaceReference_c.class && rto instanceof Interface_c) {
     // name will match RTO
     name = "Interface_c_RTO";
   }
   if (elementType == ComponentReference_c.class) {
     // name will match RTO
     name = "Component_c_RTO";
   }
   if (elementType == ProvidedExecutableProperty_c.class) {
     // need to locate the Provided Operation
     elementType = ProvidedOperation_c.class;
     // also the name will be ExecutableProperty_c_RTO
     name = "ExecutableProperty_c_RTO";
   }
   if (elementType == RequiredExecutableProperty_c.class) {
     // need to locate the Provided Operation
     elementType = RequiredOperation_c.class;
     // also the name will be ExecutableProperty_c_RTO
     name = "ExecutableProperty_c_RTO";
   }
   if (nonDefault) {
     name = name + "_ND";
   }
   Ooaofooa[] instances = Ooaofooa.getInstances();
   for (Ooaofooa ooa : instances) {
     InstanceList list = ooa.getInstanceList(elementType);
     for (Object elem : list) {
       NonRootModelElement test = (NonRootModelElement) elem;
       if (test.isProxy()) {
         continue;
       }
       if (test.getName().contains(name) && (!nonDefault && !test.getName().contains("ND"))) {
         element = test;
         break;
       }
       if (test.getName().contains(name) && (nonDefault && test.getName().contains("ND"))) {
         element = test;
         break;
       }
     }
     if (element != null) {
       break;
     }
   }
   if (elementType == ProvidedOperation_c.class) {
     return ProvidedExecutableProperty_c.getOneSPR_PEPOnR4503((ProvidedOperation_c) element);
   }
   if (elementType == RequiredOperation_c.class) {
     return RequiredExecutableProperty_c.getOneSPR_REPOnR4502((RequiredOperation_c) element);
   }
   assertNotNull(
       "Missing test element with details : Type->" + elementType + " Name->" + name, element);
   return element;
 }
 private IMarker[] collectParseErrors(NonRootModelElement testPkg) throws CoreException {
   IContainer parent = testPkg.getFile().getParent();
   return parent.findMarkers(Marker.PROBLEM, false, IResource.DEPTH_INFINITE);
 }