Filtering Nodes via Transformation Menu

Hi!

I hope the attached screenshot will describe the scenario.

Here's the summary though:

1. Upon pressing Ctrl-Space on a cell (here shown with "Security" as text), I want to limit only those matching the "HMO" project name (highlighted in green, on the left) to be displayed in the list of modules.

2. As of now, the closest I came up with is to say "IGNORE" to those records I want to hide. Somehow returning "null" doesn't work also.

Is there a way to totally hide the unwanted records? Is it still via a Transformation Menu or via some other mechanism?

 

Thank you,

Noli San Jose

 

 

6 comments
Comment actions Permalink

You need to define a scope for the 'module' reference in the constraints aspect, to only return the objects you want to see in the menu.

1
Comment actions Permalink

Sergej,

As usual, you're so fast. :-)

However, I'm totally clueless on what to put here. :( . I mean, what subtype of Scope should be returned? Is a FilteringByConceptScope the correct one? Totally new to scopes unfortunately. I can probably do the comparison/filtering but the return type is my problem.

Thanks!

Noli

0
Comment actions Permalink

It's usually ListScope.forNamedElements([list of elements that should be in scope goes here])

Usually you collect the elements by navigating the model. contextNode.model.rootsIncludingImported(SomeConcept) or .nodesIncludingImported(SomeConcept) are good starting points.

1
Comment actions Permalink

Sergej,

After a few hours of trial and error after reading your notes, I got it working. Thanks a lot!!!

To assist others, I hope you don't mind if I add some notes here for those coming here with the same problem:

1. In your concept (say, A) containing the concept (B) for the reference item,  go to A's Constraints aspect.

2. In the Constraints aspect, look for the <<referent constraints>> section.

- Note: 

--> (i) I made some errors in my interpretation and went initially to the "default scope" section at the bottom (because I was so focus on the "scope" idea. Hahaha).

--> (ii) Another wrong interpretation was going to B and its "default scope" section. Nope. Wrong. Newbie :-)

3. Click Ctrl-Space in the <<referent constraints>> section until you see the subsection "scope", and select "reference scope". Add your code there to produce the nodes that you want.

4. Use the ListScope.forNamedElements function that Sergej mentioned to return the records.

- Notes:

--> (i) It's easy to get lost (again!) when calling this function (ListScope.forNamedElements).

------> WONT WORK:

nList<B> items = <code to produce the nodes>

ListScope.forNamedElements(items)

------> WILL WORK (see attached image):

nList<> items = <code to produce the nodes>  //no concept generic parameter in the nList<>!

ListScope.forNamedElements(items)

I hope this helps also. 

Noli

 

0
Comment actions Permalink

Great step-by-step explanation with all the details and blind alleys! :) I didn’t realize that going into that much detail would have been helpful. I think your point 2.ii above (default scope for B) should have worked as well but it then applies to all references to B that don’t have a scope specified for them in constraints.

Also, I don’t see any attached image but you may have been burned by some typing rules. Does B implement INamedConcept?

0
Comment actions Permalink

Sergej,

 

Thanks on the step-by-step explanation. Yes, I can't help it. I got used to teaching junior developers in my team in my previous company so you have to tell them all the critical blind alleys. Also, I used to be a teacher in college (arts, not programming).

As for the item 2.ii, yes, I think it applies to all references of B but not in a case here where it is inside A. (Separate note: I experienced that if you're in the editor of A, and you have some code in the constraints of A (referring to B), the constraints code in B itself is superseded and won't run. So it behaves like a standard OOP code where the more specific supersedes the general).

As for the image, it's on top of the page of my comment and not in the exact section where I referred to it (I can't seem to place it in the correct location or I just didn't try enough since my concern is to send out the question right away).

As for whether B implement INamedConcept, yes it does.

Thanks,

Noli

 

0

Please sign in to leave a comment.