locked
How to change order or sequence of element by moving item up or down in designer RRS feed

  • Question

  • We have a DSL that is similar in concept to a ClassDesigner language. I'll use concepts from the standard class designer template for clarity.

    In our situation the order or sequence of the attributes (or operations for that matter) is important and we would like to control that from the designer. Our only workaround is to edit the XML file and manually change the order of the elements. Lets just say it's a very frustrating thing.

    Does anyone have any ideas how I could move the items up or down, such that it change the sequence in the backing XML document?

    Ideally I would like to hook the moving up or down of items to a right-click context menu to make it intuitive for the user. Copy and Paste is a big help with 2010, but I cannot control the order with the copy and paste.

    You input would really be appreciated.

    Regards,
    Jaans


    Thursday, May 27, 2010 7:34 AM

Answers

  • Create a custom menu command to do it.

    First get the link (= instance of a domain relationship) from your "class" object to an attribute or operation. I'd guess this is an embedding:

       MyEmbeddingRelationship link = MyEmbeddingRelationship.GetLinks(myClassObject, myAttributeObject).First();

    Then use link.MoveBefore() or link.MoveToIndex() - something like:

       link.MoveToIndex(link.GetDomainRelationship().DomainRoles[0], newIndex);

    Would that work?


    - Alan -MSFT
    Thursday, May 27, 2010 10:13 AM
  • How about

       MyEmbeddingRelationship.GetLinksToOneEnd(theOtherEnd).IndexOf(link)

    Instead of "GetLinksToOneEnd" you'll find your DSL has a method called something derived from your class names.


    - Alan -MSFT
    • Marked as answer by Jaans Sunday, May 30, 2010 5:18 AM
    Saturday, May 29, 2010 11:29 AM

All replies

  • Create a custom menu command to do it.

    First get the link (= instance of a domain relationship) from your "class" object to an attribute or operation. I'd guess this is an embedding:

       MyEmbeddingRelationship link = MyEmbeddingRelationship.GetLinks(myClassObject, myAttributeObject).First();

    Then use link.MoveBefore() or link.MoveToIndex() - something like:

       link.MoveToIndex(link.GetDomainRelationship().DomainRoles[0], newIndex);

    Would that work?


    - Alan -MSFT
    Thursday, May 27, 2010 10:13 AM
  • Yes!

    Allan... that sounds exactly like what I'm after.

    I'm trying to get it to work but I'm stuck with one last / small detail: In order to use the MoveBefore or MoveToIndex, I need either a reference to the item above / below (MoveBefore), or the current index of the item for the "newIndex" - and that's where I'm stuck.

    I'll keep trying to figure it out and will post here if I find a solution - please let me know if you have a way to find what I'm after.

    Many thanks for your help!

    Jaans


    • Edited by Jaans Saturday, May 29, 2010 9:45 AM typos
    Saturday, May 29, 2010 9:35 AM
  • How about

       MyEmbeddingRelationship.GetLinksToOneEnd(theOtherEnd).IndexOf(link)

    Instead of "GetLinksToOneEnd" you'll find your DSL has a method called something derived from your class names.


    - Alan -MSFT
    • Marked as answer by Jaans Sunday, May 30, 2010 5:18 AM
    Saturday, May 29, 2010 11:29 AM
  • I came to the same solution and wasn't sure whether it was the "correct way". Your post confirms that it as a suitable solution.
    It works very nicely now.

    Many thanks again!


    Sunday, May 30, 2010 5:20 AM