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 |
No real name 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 |
Ed Merks Messages: 33217 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 #407236 is a reply to message #407226] |
Mon, 19 February 2007 17:46 |
No real name 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 lets 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 |
Ed Merks Messages: 33217 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 |
No real name 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 |
Ed Merks Messages: 33217 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 |
Ed Merks Messages: 33217 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/
|
|
| | | |
Goto Forum:
Current Time: Mon Sep 23 11:12:12 GMT 2024
Powered by FUDForum. Page generated in 0.05400 seconds
|