Each Editor part to uniquely track navigator state [message #1104942] |
Mon, 09 September 2013 02:10  |
Eclipse User |
|
|
|
Using E4.2.2 I would like to have each editor view part track the explorer view part only while each particular editor is in focus(and store the tree state when the editor looses focus).
This is similar to the Edclise IDE when the package view is linked with editor view parts. Each editor 'knowing' which item in the package tree was selected for that editor view part.
One difference is that I have a CheckboxTreeViewer in the 'explorer' view part and will have one or many items selected in the tree, with each separate editor having widgets on screen relating to the treeviwer state at the time that particular editor instance was in focus.
Currently I have dynamic part descriptor which references an editor part and I can create multiple editor parts using a handler with the following code:
MPart part = partService.createPart("com.test.myeditor");
List<MPartStack> stacks = modelService.findElements(application, null,
MPartStack.class, null);
stacks.get(2).getChildren().add(part);
//where '2' is the editor location in the partstack
What I am struggling with is how to have each editor view part store or reference a snapshot of the explorer view parts tree state.
using:
@Inject
@Optional
private void getNotified(@UIEventTopic(TreeNodeEventConstants.TREE_DATAS_DATA_SELECTED) String s) is OK for updating all the instances of the editor view part, but I only want to update the part that is currently in focus.
As there is no @LostFocus in e4.2.2 I can't take a snapshot of the tree, and set a flag not to update the editor part when the tree view is modified while another instance of the editor part is being viewd.
Bit of a long winded explanation.., am I missing something? Does anyone know how to do this?
|
|
|
|
|
|
|
Re: Each Editor part to uniquely track navigator state [message #1107014 is a reply to message #1105671] |
Wed, 11 September 2013 17:49  |
Eclipse User |
|
|
|
Thanks Andrzej, thats clear now.
To note:
Above I was using a 'magic number' in (MPart)stacks.get(2).getSelectedElement() above to get the relevant editor MPart to modify based on CheckboxTreeViewer selection.
The problem with this is the user can drag the editor MPart to any stack and the above would return the wrong MPart or null.
To fix this I will give each MPart a UID on creation ((ObjectType)part.getObject()).setId(UID) then and store the id in a 'editor MPart' placeholder in the eclipse context on each parts @Focus.
Another possible solution would be to prevent drag and drop of MParts outside their stack - I have seen somewhere a mention of global disable of dnd - does anyone know if it is possible to allow dnd within a Part Stack only?
|
|
|
Powered by
FUDForum. Page generated in 0.13375 seconds