Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sapphire » Selecting Outline
Selecting Outline [message #727216] Tue, 20 September 2011 16:13 Go to next message
Kamesh Sampath is currently offline Kamesh Sampath
Messages: 213
Registered: July 2009
Senior Member
I have an instance of SapphirePropertyEditor inside my action, the SapphirePropertyEditor is returned by a ListProperty editor (in the details part).

From here i want to select and expand the corresponding node in Outline.

What is the optimal way to achieve this. I followed the Sapphire code for moving up and down but they dont return SapphirePropertyEditor

~Kamesh
Re: Selecting Outline [message #727222 is a reply to message #727216] Tue, 20 September 2011 16:30 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 940
Registered: July 2009
Senior Member
If you have an instance of SapphirePropertyEditor, you can call editor.nearest( MasterDetailsContentNode.class ). That will give you the node part that is the nearest ancestor to your property editor. From there, navigate around the node tree to find the node you want to affect and use setExpanded() and select() API as appropriate.

- Konstantin
Re: Selecting Outline [message #727249 is a reply to message #727222] Tue, 20 September 2011 17:27 Go to previous messageGo to next message
Kamesh Sampath is currently offline Kamesh Sampath
Messages: 213
Registered: July 2009
Senior Member
If i go by your suggestion and my action handler looks like this
final IModelElement element = getModelElement();
		MasterDetailsContentNode contentNode = context.getPart().nearest( MasterDetailsContentNode.class );
		List<MasterDetailsContentNode> childNodes = contentNode.getChildNodes();

		for ( MasterDetailsContentNode childNode : childNodes ) {
		     //print child node to see whats there and it returns my list property model element object	
                     System.out.println( childNode );
		}



I am pretty confused how to know which of child node is selected ? So that i can make then selected node expanded in the Outline Tree?

~Kamesh
Re: Selecting Outline [message #727254 is a reply to message #727249] Tue, 20 September 2011 17:46 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 940
Registered: July 2009
Senior Member
Depends on what you need to do... You can look at the node label, position relative to children, which model element it's associated with, etc. Rather than debugging this with print statement, go into the debugger and explorer the information available.

- Konstantin
Re: Selecting Outline [message #727262 is a reply to message #727254] Tue, 20 September 2011 18:36 Go to previous messageGo to next message
Kamesh Sampath is currently offline Kamesh Sampath
Messages: 213
Registered: July 2009
Senior Member
thats right if we have some information.,I guess i have not explained correctly Sad

my scenario quiet similar to Jump Action, I have a list displayed (backed by our Model Elements) and the user can select a row and then when he clicks one of the buttons i have on the side of the List Property Editor it should jump to the respective node in the Outline.

When i refered to the OutlineNodeMoveUpActionHandler code, i see you are getting
 final MasterDetailsContentNode node = (MasterDetailsContentNode) getPart();
but for me the getPart()is returning a SapphirePropertyEditor and I see it cant be cast to MasterDetailsContentNode

Note sure what I missing

~Kamesh
Re: Selecting Outline [message #727272 is a reply to message #727262] Tue, 20 September 2011 18:52 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 940
Registered: July 2009
Senior Member
You can use nearest() API that I've described previously to locate the node starting with the property editor part. That will give you the immediate parent node holding your property editor. From there, you can navigate, up, down, sideways, etc. until you've found the node you want to select... If you have a more specific question, you will need describe it better as I am not understanding...

Are you trying to get the selection from the list property editor to use in your action? Perhaps to get the model element? There is no API for this at the moment. You would have to dive into SWT-specific code. That would yield some pretty brittle code, so I would recommend that you find a different way to accomplish what you are after...

- Konstantin
Re: Selecting Outline [message #727276 is a reply to message #727272] Tue, 20 September 2011 19:12 Go to previous messageGo to next message
Kamesh Sampath is currently offline Kamesh Sampath
Messages: 213
Registered: July 2009
Senior Member
can we not hook the Sapphire.Jump to jump to the refrenced node ? I have a List which is backed by IPortlet (ModelElement), am now scrolling the list and selected a row , i get jump actions for Java types but can we not make jump happen for the entire row to a node in the outline tree ?
Re: Selecting Outline [message #727279 is a reply to message #727276] Tue, 20 September 2011 19:18 Go to previous messageGo to next message
Kamesh Sampath is currently offline Kamesh Sampath
Messages: 213
Registered: July 2009
Senior Member
dont you think we need to give the users the access to the selected item and its model element from the framework ? How is the Moveup and MoveDown etc., are working ? how are they able to grab the correct selected item ? Can we not do that with our custom action ?
Re: Selecting Outline [message #727282 is a reply to message #727279] Tue, 20 September 2011 19:28 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 940
Registered: July 2009
Senior Member
> dont you think we need to give the users the access to the selected item and its model
> element from the framework

Yes, I think that would be useful. I am simply saying that this API does not exist currently. Or to put it another way, I recommend that you open an enhancement request and try to find another way to solve your current requirements in the meantime.

> How is the Moveup and MoveDown etc., are working ?

The handlers for these actions are implemented in the SWT renderer code, so it has access to Table, selection etc. See DefaultListPropertyEditorRenderer.

- Konstantin
Re: Selecting Outline [message #727287 is a reply to message #727282] Tue, 20 September 2011 19:35 Go to previous messageGo to next message
Kamesh Sampath is currently offline Kamesh Sampath
Messages: 213
Registered: July 2009
Senior Member
great thanks! but i don't think i can achieve my functionality without handle to the selected item Sad, so let me keep it as TODO for my next release and when we have implemented that in Sapphire.
I will open an enhancement request right away.

Thanks for your time.
Re: Selecting Outline [message #727289 is a reply to message #727287] Tue, 20 September 2011 19:39 Go to previous message
Kamesh Sampath is currently offline Kamesh Sampath
Messages: 213
Registered: July 2009
Senior Member
358295 is the Bugzilla enhancement ticket# for the same

[Updated on: Tue, 20 September 2011 19:39]

Report message to a moderator

Previous Topic:Additional Actions
Next Topic:Expanding Child Nodes
Goto Forum:
  


Current Time: Sun Sep 21 02:15:58 GMT 2014

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

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