public Collection<?> getNewChildDescriptors(Object object, EditingDomain editingDomain) {
    Collection<Object> newChildDescriptors = Lists.newArrayList();

    if (object instanceof EObject) {
      EObject target = (EObject) object;

      if (target instanceof Component || target instanceof NodeType) {

        // Are we in the design view? (The target must have a parent
        // Node).
        Node node = StudioUtils.nodeFor(target);
        if (node != null) {

          if (target.eClass() == LibraryPackage.Literals.NODE_TYPE) {
            // Handled by the Node child creation has NodeType is
            // not visible in the Design view.
          } else if (target.eClass() == LibraryPackage.Literals.EQUIPMENT) {
            if (node.getOriginalNodeTypeRef() != null) {
              NodeType ntRef = node.getOriginalNodeTypeRef();
              Equipment targetEq = (Equipment) target;
              newChildDescriptors =
                  newEquimentDescriptorsForTargetNodeType(editingDomain, ntRef, targetEq);
            } else {
              // No descriptor, if we have no node type.
            }

          } else if (target.eClass() == LibraryPackage.Literals.FUNCTION) {

            // Allow creation of Function object, not from the
            // original type.
            Function function = LibraryFactory.eINSTANCE.createFunction();

            Lifecycle newLC = GenericsFactory.eINSTANCE.createLifecycle();
            newLC.setProposed(NonModelUtils.toXMLDate(NonModelUtils.todayAndNow()));
            function.setLifecycle(newLC);

            newChildDescriptors.add(
                createChildParameter(LibraryPackage.Literals.FUNCTION__FUNCTIONS, function));
          }
        } else {

          if (target instanceof NodeType) {
            Function createFunction =
                newLibraryFunction(
                    editingDomain, target, LibraryPackage.Literals.NODE_TYPE__FUNCTIONS);

            Equipment createEquipment =
                newLibraryEquipment(
                    editingDomain, target, LibraryPackage.Literals.NODE_TYPE__EQUIPMENTS);

            newChildDescriptors.add(
                createChildParameter(LibraryPackage.Literals.NODE_TYPE__FUNCTIONS, createFunction));
            newChildDescriptors.add(
                createChildParameter(
                    LibraryPackage.Literals.NODE_TYPE__EQUIPMENTS, createEquipment));
          } else if (target instanceof Equipment) {

            Equipment createEquipment =
                newLibraryEquipment(
                    editingDomain, target, LibraryPackage.Literals.EQUIPMENT__EQUIPMENTS);

            newChildDescriptors.add(
                createChildParameter(
                    LibraryPackage.Literals.EQUIPMENT__EQUIPMENTS, createEquipment));

          } else if (target instanceof Function) {
            Function createFunction =
                newLibraryFunction(
                    editingDomain, target, LibraryPackage.Literals.FUNCTION__FUNCTIONS);

            newChildDescriptors.add(
                createChildParameter(LibraryPackage.Literals.FUNCTION__FUNCTIONS, createFunction));
          }
        }
      }
    }

    return newChildDescriptors;
  }
Esempio n. 2
0
 /**
  * This returns the label text for the adapted class.
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public String getText(Object object) {
   Node node = (Node) object;
   return getString("_UI_Node_type") + " " + node.isDeleted();
 }