Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » properties view sync with multiple tree viewer
properties view sync with multiple tree viewer [message #407217] Sun, 18 February 2007 21:09 Go to next message
No real name is currently offline No real nameFriend
Messages: 22
Registered: July 2009
Junior Member
Hi,
I am trying to create a multi-page editor showing two models, but get
stuck with sync them with the properties view, Here is what I did, I
created an EMF generated multi-page editor by adding a new form page to
it. On this page, there are four JFace Tree Viewers, I use two trees to
display the first model and other two tree to show the second model. This
works fine.
But none of them can sync with the properties view, so I added the
“getSite().setSelectionProvider(…)” right after I created each tree viewer.
Now the properties view only display the content of the 4th tree viewer,
if I comment out above line for the 4th tree viewer, then the properties
view display the content of the 3rd tree viewer, so on so forth.
How can I make the properties view sync with each tree viewer I put on
this page?Thanks in advance.
Re: properties view sync with multiple tree viewer [message #407218 is a reply to message #407217] Sun, 18 February 2007 21:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Jackie,

The default generated editor relies on calls to
setCurrentViewerPane/setCurrentViewer to hook up a selection listener to
the viewer and forward that viewer's selection as the selection for the
overall editor. You'll need to do something to call setCurrentViewer
when each particular viewer is supposed to be active.


Jackie Zhang wrote:
> Hi,
> I am trying to create a multi-page editor showing two models, but get
> stuck with sync them with the properties view, Here is what I did, I
> created an EMF generated multi-page editor by adding a new form page
> to it. On this page, there are four JFace Tree Viewers, I use two
> trees to display the first model and other two tree to show the second
> model. This works fine.
> But none of them can sync with the properties view, so I added the
> �getSite().setSelectionProvider(�)� right after I created each tree
> viewer.
> Now the properties view only display the content of the 4th tree
> viewer, if I comment out above line for the 4th tree viewer, then the
> properties view display the content of the 3rd tree viewer, so on so
> forth. How can I make the properties view sync with each tree viewer I
> put on this page?Thanks in advance.
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: properties view sync with multiple tree viewer [message #407221 is a reply to message #407218] Mon, 19 February 2007 00:16 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 22
Registered: July 2009
Junior Member
Ed, Thanks,
I added the code to call setCurrentViewer(..) like this:
treeViewer.addSelectionChangedListener
(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
currentViewer = treeViewer;
setCurrentViewer(treeViewer);
}
});

The problem now is the properties view is not updated unless i click on
the outline view first then come back to the other treVviewer on the page.

Could you give me some suggestion on it?

Jackie
Re: properties view sync with multiple tree viewer [message #407226 is a reply to message #407221] Mon, 19 February 2007 12:34 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Jackie,

It seems to me that setting the current viewer should be based on the
viewer acquiring focus, not on the selection changing since it's
possible for the viewer to get focus without the selection changing
(e.g., if you use tab to navigate to it) and it's possible for the
selection to change even when the view doesn't have focus (e.g., if the
selected item is deleted).


Jackie wrote:
> Ed, Thanks,
> I added the code to call setCurrentViewer(..) like this:
> treeViewer.addSelectionChangedListener
> (new ISelectionChangedListener() {
> public void selectionChanged(SelectionChangedEvent event) {
> currentViewer = treeViewer;
> setCurrentViewer(treeViewer);
> }
> });
>
> The problem now is the properties view is not updated unless i click
> on the outline view first then come back to the other treVviewer on
> the page.
>
> Could you give me some suggestion on it?
>
> Jackie
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: properties view sync with multiple tree viewer [message #407236 is a reply to message #407226] Mon, 19 February 2007 17:46 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 22
Registered: July 2009
Junior Member
I still stuck with this after using the focusListener, then I discovered
that the setCurrentViewer(..) did not work in the first place, Let me
explain my issue in details.
On the form page let’s say I have only two treeviewers, they both connect
to same 2nd model, the outline view connect the 1st model which is used to
generate this multi-page editor.
1. If I click on the 1st tree, the properties view displays none.
2. I click the outline, the properties view changes to display for the
outline from 1st model.
3. I click back to the first tree, the properties view changes to displays
none.
4. I click the 2nd tree, the properties view changes to display for the
2nd tree from 2nd model.
5. I click the 1st tree again, the properties stay no changes – still show
the element in 2nd tree
6. I click the outline again, the properties view changed to display for
the outline from 1st model.
7. I click the 1st tree again, the properties view changes to display the
selection previous for the 2nd tree.
8. The properties view keeps no changes unless I click the 2nd tree or the
outline, but when I go back to the first tree, it always display the
preious selection in the 2nd tree.
Thanks
Jackie
Re: properties view sync with multiple tree viewer [message #407237 is a reply to message #407236] Mon, 19 February 2007 17:58 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Jackie,

Setting a breakpoint in setCurrentViewer to see exactly when it is
called and what it is setting as the editors selection would probably be
more effective than describing the behavior in the newsgroup. I can't
debug code that I've never seen...


Jackie wrote:
> I still stuck with this after using the focusListener, then I
> discovered that the setCurrentViewer(..) did not work in the first
> place, Let me explain my issue in details.
> On the form page let�s say I have only two treeviewers, they both
> connect to same 2nd model, the outline view connect the 1st model
> which is used to generate this multi-page editor.
> 1. If I click on the 1st tree, the properties view displays none.
> 2. I click the outline, the properties view changes to display for the
> outline from 1st model. 3. I click back to the first tree, the
> properties view changes to displays none.
> 4. I click the 2nd tree, the properties view changes to display for
> the 2nd tree from 2nd model.
> 5. I click the 1st tree again, the properties stay no changes � still
> show the element in 2nd tree
> 6. I click the outline again, the properties view changed to display
> for the outline from 1st model.
> 7. I click the 1st tree again, the properties view changes to display
> the selection previous for the 2nd tree.
> 8. The properties view keeps no changes unless I click the 2nd tree or
> the outline, but when I go back to the first tree, it always display
> the preious selection in the 2nd tree.
> Thanks
> Jackie
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: properties view sync with multiple tree viewer [message #407240 is a reply to message #407237] Mon, 19 February 2007 22:48 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 22
Registered: July 2009
Junior Member
The problem has been solved.
If you have more than one viewers on your page, the
getSite().setSelectionProvider(view) register only the last viewer on the
page, in order to register all your viewers, you need to create a class
like the one in org.eclipse.jdt.ui, the discuss about this can be found at
http://dev.eclipse.org/newslists/news.eclipse.tools/msg39132 .html

StructuredViewer[] trackedViewers = new StructuredViewer[] {
this.inputIfxTreeViewer, this.outputIfxTreeViewer,
this.inputTableTreeViewer, this.outputTableViewer};
ISelectionProvider selectionProvider =
new SelectionProviderMediator(trackedViewers);
getSite().setSelectionProvider(selectionProvider);

The source code of the class SelectionProviderMediator can be found at
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-cor e/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/bro wser/typehierarchy/SelectionProviderMediator.java?revision=1 .1&root=Tools_Project&view=markup

Thanks Ed, and all other people who spend your time to answer the
questions.

Cheers,
Re: properties view sync with multiple tree viewer [message #407244 is a reply to message #407240] Tue, 20 February 2007 11:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010407070500060709090505
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Jackie,

I see. The EMF generated editor sets itself as the selection provider:

public void init(IEditorSite site, IEditorInput editorInput)
{
setSite(site);
setInputWithNotify(editorInput);
setPartName(editorInput.getName());
*site.setSelectionProvider(this);*
site.getPage().addPartListener(partListener);

ResourcesPlugin.getWorkspace().addResourceChangeListener(res ourceChangeListener,
IResourceChangeEvent.POST_CHANGE);
}

And by adding a selection listener to the current viewer (in
setCurrentViewer) its able to forward each viewer's selection as its own
selection...


Jackie Zhang wrote:
> The problem has been solved. If you have more than one viewers on your
> page, the getSite().setSelectionProvider(view) register only the last
> viewer on the page, in order to register all your viewers, you need to
> create a class like the one in org.eclipse.jdt.ui, the discuss about
> this can be found at
> http://dev.eclipse.org/newslists/news.eclipse.tools/msg39132 .html
>
> StructuredViewer[] trackedViewers = new StructuredViewer[] {
> this.inputIfxTreeViewer, this.outputIfxTreeViewer,
> this.inputTableTreeViewer, this.outputTableViewer};
> ISelectionProvider selectionProvider =
> new SelectionProviderMediator(trackedViewers);
> getSite().setSelectionProvider(selectionProvider);
>
> The source code of the class SelectionProviderMediator can be found at
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-cor e/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/bro wser/typehierarchy/SelectionProviderMediator.java?revision=1 .1&root=Tools_Project&view=markup
>
>
> Thanks Ed, and all other people who spend your time to answer the
> questions.
> Cheers,
>
>


--------------010407070500060709090505
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Jackie,<br>
<br>
I see.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: properties view sync with multiple tree viewer [message #407245 is a reply to message #407240] Tue, 20 February 2007 11:19 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000006090808010007000600
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Jackie,

I see. The EMF generated editor sets itself as the selection provider:

public void init(IEditorSite site, IEditorInput editorInput)
{
setSite(site);
setInputWithNotify(editorInput);
setPartName(editorInput.getName());
*site.setSelectionProvider(this);*
site.getPage().addPartListener(partListener);

ResourcesPlugin.getWorkspace().addResourceChangeListener(res ourceChangeListener,
IResourceChangeEvent.POST_CHANGE);
}

And by adding a selection listener to the current viewer (in
setCurrentViewer) its able to forward each viewer's selection as its own
selection...


Jackie Zhang wrote:
> The problem has been solved. If you have more than one viewers on your
> page, the getSite().setSelectionProvider(view) register only the last
> viewer on the page, in order to register all your viewers, you need to
> create a class like the one in org.eclipse.jdt.ui, the discuss about
> this can be found at
> http://dev.eclipse.org/newslists/news.eclipse.tools/msg39132 .html
>
> StructuredViewer[] trackedViewers = new StructuredViewer[] {
> this.inputIfxTreeViewer, this.outputIfxTreeViewer,
> this.inputTableTreeViewer, this.outputTableViewer};
> ISelectionProvider selectionProvider =
> new SelectionProviderMediator(trackedViewers);
> getSite().setSelectionProvider(selectionProvider);
>
> The source code of the class SelectionProviderMediator can be found at
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-cor e/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/bro wser/typehierarchy/SelectionProviderMediator.java?revision=1 .1&root=Tools_Project&view=markup
>
>
> Thanks Ed, and all other people who spend your time to answer the
> questions.
> Cheers,
>
>


--------------000006090808010007000600
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Jackie,<br>
<br>
I see.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: properties view sync with multiple tree viewer [message #916040 is a reply to message #407245] Tue, 18 September 2012 12:50 Go to previous messageGo to next message
Almamy Ndiaye is currently offline Almamy NdiayeFriend
Messages: 16
Registered: May 2012
Junior Member
Hello Ed, can I have more precision about this. I actually have the same problem and I don't know where to call the setCurrentView() to notify my EEF property sheet :S.
Re: properties view sync with multiple tree viewer [message #916065 is a reply to message #916040] Tue, 18 September 2012 13:22 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
The editor itself is the selection provider and if you look in the
generated editor's setCurrentViewer you'll see how the view's selection
is propagated to become the editor's selection.

On 18/09/2012 2:51 PM, Almamy Ndiaye wrote:
> Hello Ed, can I have more precision about this. I actually have the
> same problem and I don't know where to call the setCurrentView() to
> notify my EEF property sheet :S.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: properties view sync with multiple tree viewer [message #916588 is a reply to message #916065] Wed, 19 September 2012 07:49 Go to previous message
Almamy Ndiaye is currently offline Almamy NdiayeFriend
Messages: 16
Registered: May 2012
Junior Member
Ok thanks, I saw the XXEditor class but I don't use it(my post wasn't sorry). Actually I have an external class (not generated) which extends MultiPageEditorPart and implements IResourceChangeListener and IDiagramWorkbenchPart. I also have a customized outline view and editing diagram. When I select an element in the outline, the coresponding element is selected on the diagram but the property view is not refreshed because the outline still be the current view. So my problem is to switch the current view when an element is selected on the Outline but I don't know how to do it. Maybe by getting a reference of my property sheet ?

Previous Topic:[ECORE/Teneo] Persistence clarification
Next Topic:Sharing EMF objects between views
Goto Forum:
  


Current Time: Fri Mar 29 06:10:27 GMT 2024

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

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

Back to the top