Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Setting the selection of child node to parent node.
Setting the selection of child node to parent node. [message #158752] Thu, 08 November 2007 06:23 Go to next message
Eclipse UserFriend
Originally posted by: biju_gopinathan.rediffmail.com

Hi all,

How can we change the selection on clicking a child node to its
parent node. So that I can view the properties of the parent node in the
property view even on selecting child node(which is my requirement).


Thanks, Biju
Re: Setting the selection of child node to parent node. [message #158760 is a reply to message #158752] Thu, 08 November 2007 06:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: biju_gopinathan.rediffmail.com

Hi all,

Got it, I did it by adding a selection listener and changing the
selection in the child edit part, as follows.I am calling the following
method from the createDefaultEditPolicies() function of my child edit
part.

Thanks, Biju

private void addSelectionListener() {
this.getViewer().addSelectionChangedListener(new
ISelectionChangedListener(){
@Override
public void selectionChanged(SelectionChangedEvent selectionEvent) {
if(selectionEvent.getSelection() instanceof StructuredSelection){
StructuredSelection selection=(StructuredSelection)
selectionEvent.getSelection();
if(selection.getFirstElement() instanceof ConveyorSlotEditPart){
getViewer().setSelection(new
StructuredSelection(((ConveyorSlotEditPart)selection.getFirs tElement()).getParent()));
}
}
}
});
}
biju wrote:
> Hi all,
>
> How can we change the selection on clicking a child node to its
> parent node. So that I can view the properties of the parent node in the
> property view even on selecting child node(which is my requirement).
>
>
> Thanks, Biju
Re: Setting the selection of child node to parent node. [message #158864 is a reply to message #158760] Thu, 08 November 2007 11:42 Go to previous messageGo to next message
Boris Blajer is currently offline Boris BlajerFriend
Messages: 217
Registered: July 2009
Senior Member
Hi Biju,

You may use isSelectable() method to control selectability of the node.
If the node is not selectable, the node underneath will get selected
(and normally, it is the parent node).

Another solution is to override method getTargetEditPart in your
(non-)resizable edit policy to return getHost().getParent() as the
target edit part for the REQ_SELECTION request.

Your solution is also ok, but seems to leak deleted edit parts for the
lifetime of the graphical viewer.

Best regards,
Boris

biju wrote:
> Hi all,
>
> Got it, I did it by adding a selection listener and changing the
> selection in the child edit part, as follows.I am calling the following
> method from the createDefaultEditPolicies() function of my child edit
> part.
>
> Thanks, Biju
>
> private void addSelectionListener() {
> this.getViewer().addSelectionChangedListener(new
> ISelectionChangedListener(){
> @Override
> public void selectionChanged(SelectionChangedEvent
> selectionEvent) {
> if(selectionEvent.getSelection() instanceof
> StructuredSelection){
> StructuredSelection selection=(StructuredSelection)
> selectionEvent.getSelection();
> if(selection.getFirstElement() instanceof
> ConveyorSlotEditPart){
> getViewer().setSelection(new
> StructuredSelection(((ConveyorSlotEditPart)selection.getFirs tElement()).getParent()));
>
> }
> }
> }
> });
> }
> biju wrote:
>> Hi all,
>>
>> How can we change the selection on clicking a child node to
>> its parent node. So that I can view the properties of the parent node
>> in the property view even on selecting child node(which is my
>> requirement).
>>
>>
>> Thanks, Biju
Re: Setting the selection of child node to parent node. [message #158918 is a reply to message #158752] Thu, 08 November 2007 12:12 Go to previous messageGo to next message
Sven Krause is currently offline Sven KrauseFriend
Messages: 64
Registered: July 2009
Member
biju wrote:
> Hi all,
>
> How can we change the selection on clicking a child node to
> its parent node. So that I can view the properties of the parent node
> in the property view even on selecting child node(which is my
> requirement).
>
>
> Thanks, Biju
You can use an own SelectionProvider for it to, which is much more
simple than forwarding the selection. I guess the editor itself returns
the selection provider within the getAdapter method.

Sven
Re: Setting the selection of child node to parent node. [message #158970 is a reply to message #158864] Thu, 08 November 2007 13:20 Go to previous message
Eclipse UserFriend
Originally posted by: biju_gopinathan.rediffmail.com

Hi Boris Blajer,

Thanks for your Idea,

Its working better, and is simple, I just override the
isSelectable() of child edit part to return false.

Thanks, Biju
Boris Blajer wrote:
> Hi Biju,
>
> You may use isSelectable() method to control selectability of the node.
> If the node is not selectable, the node underneath will get selected
> (and normally, it is the parent node).
>
> Another solution is to override method getTargetEditPart in your
> (non-)resizable edit policy to return getHost().getParent() as the
> target edit part for the REQ_SELECTION request.
>
> Your solution is also ok, but seems to leak deleted edit parts for the
> lifetime of the graphical viewer.
>
> Best regards,
> Boris
>
> biju wrote:
>> Hi all,
>>
>> Got it, I did it by adding a selection listener and changing
>> the selection in the child edit part, as follows.I am calling the
>> following method from the createDefaultEditPolicies() function of my
>> child edit part.
>>
>> Thanks, Biju
>>
>> private void addSelectionListener() {
>> this.getViewer().addSelectionChangedListener(new
>> ISelectionChangedListener(){
>> @Override
>> public void selectionChanged(SelectionChangedEvent
>> selectionEvent) {
>> if(selectionEvent.getSelection() instanceof
>> StructuredSelection){
>> StructuredSelection
>> selection=(StructuredSelection) selectionEvent.getSelection();
>> if(selection.getFirstElement() instanceof
>> ConveyorSlotEditPart){
>> getViewer().setSelection(new
>> StructuredSelection(((ConveyorSlotEditPart)selection.getFirs tElement()).getParent()));
>>
>> }
>> }
>> }
>> });
>> }
>> biju wrote:
>>> Hi all,
>>>
>>> How can we change the selection on clicking a child node to
>>> its parent node. So that I can view the properties of the parent node
>>> in the property view even on selecting child node(which is my
>>> requirement).
>>>
>>>
>>> Thanks, Biju
Previous Topic:Problem in creating multiple diagram using same type of model elements
Next Topic:Prop Sheet row selection handling
Goto Forum:
  


Current Time: Sat Jul 27 18:30:52 GMT 2024

Powered by FUDForum. Page generated in 0.05015 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top