Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Why ContentOutlineView "steals" focus when my editor is activated?
Why ContentOutlineView "steals" focus when my editor is activated? [message #784533] Fri, 27 January 2012 17:06 Go to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Hi,

I have an editor which is adaptable to IContentOutlinePage. Whenever this editor is opened,
the content outline view is brought to top (which is fine), but it also takes the focus.

I must click inside the editor to take the focus back.

In the Eclipse IDE it has different behavior. Content outline view is not brought to top and the focus
stay to the editor (try to open a .classpath file from the package explorer view).

How Can I combine this two approaches to have content outline view brought to top but leave the focus to my editor?
Re: Why ContentOutlineView "steals" focus when my editor is activated? [message #787296 is a reply to message #784533] Tue, 31 January 2012 12:11 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
On 27.01.2012 18:06, Jan Krakora wrote:
> Hi,
>
> I have an editor which is adaptable to IContentOutlinePage. Whenever
> this editor is opened, the content outline view is brought to top
> (which is fine), but it also takes the focus.
> I must click inside the editor to take the focus back.
>
> In the Eclipse IDE it has different behavior. Content outline view is
> not brought to top and the focus
> stay to the editor (try to open a .classpath file from the package
> explorer view).
>
> How Can I combine this two approaches to have content outline view
> brought to top but leave the focus to my editor?
This should work out of the box. If not, I suggest you file a bug
against Platform IDE together with an example.

Dani
Re: Why ContentOutlineView "steals" focus when my editor is activated? [message #787466 is a reply to message #787296] Tue, 31 January 2012 16:06 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
I got it.

Sometimes I got an exception
java.lang.RuntimeException: WARNING: Prevented recursive attempt to
activate part org.eclipse.ui.views.ContentOutline while still in the
middle of activating part editor"
so I put the setFocus code in my content outline page implementation in Display.asyncExec().
The exception above disappears but it start stealing focus of the editor.
Re: Why ContentOutlineView "steals" focus when my editor is activated? [message #787709 is a reply to message #787466] Tue, 31 January 2012 22:22 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 242
Registered: July 2009
Senior Member
If I understand what you're seeking to do correctly, you should not be calling setFocus() on a widget. Rather your editor should use IWorkbenchPage.showView(IPageLayout.ID_OUTLINE) to raise the outline to the top on activation.

Otherwise please explain what you're trying to accomplish!
Re: Why ContentOutlineView "steals" focus when my editor is activated? [message #788099 is a reply to message #787709] Wed, 01 February 2012 10:51 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
What I'm trying to accomplish is my editor to be adaptable to IContentOutlinePage.
When opened, the Outline View should brought to top and show the content of the editor.

To do so, I have created an implementation of the IContentOutlinePage (it extends from Page) and return it from the getAdapter() of the editor part.
Both, the editor part and the content outline page implementation have setFocus() method where you can set focus on whatever control you want.
So I simply set focus to something in both (in the editor part it's a Canvas and in the outline page it's an ExpandBar).

When I run it, it sometimes throws the runtime exception mentioned in my previous post. Someone advised me to put one of those setFocus code to Display.asyncExec,
so I did it in my outline page. The exception stopped showing, but the content outline starts stealing focus from the editor.

So I move Display.asyncExec from outline page's setFocus() to the editor's setFocus(). Now it works fine.

Sorry about my English, its not my native language.
Re: Why ContentOutlineView "steals" focus when my editor is activated? [message #789068 is a reply to message #788099] Thu, 02 February 2012 15:16 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

What are you using to try and bring the outline view to the top?

As an aside, you should only have code in setFocus() that sets the focus within your part. No other operations are permitted at that time (as setFocus() is not called in all activation scenarios). If you are trying to match a behaviour when your part becomes active, you should use IPartListener2 instead.

PW


Re: Why ContentOutlineView "steals" focus when my editor is activated? [message #789690 is a reply to message #789068] Fri, 03 February 2012 09:24 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
> What are you using to try and bring the outline view to the top?

I don't use anything to bring the outline view to the top. It happens automatically when I open my editor which is adaptable to IContentOutlinePage.

> As an aside, you should only have code in setFocus() that sets the focus within your > part.
> No other operations are permitted at that time (as setFocus() is not called in all activation scenarios).
> If you are trying to match a behaviour when your part becomes active, you should use IPartListener2 instead.

I do that. In setFocus() I call canvas.setFocus() within my editor part and expandBar.setFocus() within my IContentOutlinePage implementation.
But it sometimes throws the exception "Prevented recursive attempt to activate part ..." so I put canvas.setFocus() in Display.asyncExec.
Now it seems to have the correct behavior. Is it alright or do I something wrong?

Re: Why ContentOutlineView "steals" focus when my editor is activated? [message #789849 is a reply to message #789690] Fri, 03 February 2012 13:44 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Could you post that stack trace: "But it sometimes throws the exception "Prevented recursive attempt to activate part..."

PW


Re: Why ContentOutlineView "steals" focus when my editor is activated? [message #792734 is a reply to message #789849] Tue, 07 February 2012 10:48 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
java.lang.RuntimeException: WARNING: Prevented recursive attempt to activate part org.eclipse.ui.views.ContentOutline while still in the middle of activating part cz.tigra.spl.client.modul.slide.editor.PartieEditor
	at org.eclipse.ui.internal.WorkbenchPage.setActivePart(WorkbenchPage.java:3481)
	at org.eclipse.ui.internal.WorkbenchPage.requestActivation(WorkbenchPage.java:3071)
	at org.eclipse.ui.internal.PartPane.requestActivation(PartPane.java:279)
	at org.eclipse.ui.internal.PartPane.handleEvent(PartPane.java:237)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java)
	at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1404)
	at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:2597)
	at org.eclipse.swt.widgets.Widget.wmSetFocus(Widget.java:2282)
	at org.eclipse.swt.widgets.Control.WM_SETFOCUS(Control.java:4573)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4014)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4619)
	at org.eclipse.swt.internal.win32.OS.ShowWindow(Native Method)
	at org.eclipse.swt.widgets.Control.showWidget(Control.java:2563)
	at org.eclipse.swt.widgets.Control.setVisible(Control.java:3365)
	at org.eclipse.ui.part.PageBook.showPage(PageBook.java:118)
	at org.eclipse.ui.part.PageBookView.showPageRec(PageBookView.java:978)
	at org.eclipse.ui.views.contentoutline.ContentOutline.showPageRec(ContentOutline.java:251)
	at org.eclipse.ui.part.PageBookView.partActivated(PageBookView.java:757)
	at org.eclipse.ui.views.contentoutline.ContentOutline.partBroughtToTop(ContentOutline.java:212)
	at org.eclipse.ui.part.PageBookView$4.partBroughtToTop(PageBookView.java:1015)
	at org.eclipse.ui.internal.PartListenerList2$2.run(PartListenerList2.java:85)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.runtime.Platform.run(Platform.java:888)
	at org.eclipse.ui.internal.PartListenerList2.fireEvent(PartListenerList2.java:50)
	at org.eclipse.ui.internal.PartListenerList2.firePartBroughtToTop(PartListenerList2.java:83)
	at org.eclipse.ui.internal.PartService.firePartBroughtToTop(PartService.java:212)
	at org.eclipse.ui.internal.WorkbenchPagePartList.firePartBroughtToTop(WorkbenchPagePartList.java:76)
	at org.eclipse.ui.internal.WorkbenchPagePartList.fireActiveEditorChanged(WorkbenchPagePartList.java:52)
	at org.eclipse.ui.internal.PartList.setActiveEditor(PartList.java:162)
	at org.eclipse.ui.internal.WorkbenchPage.makeActiveEditor(WorkbenchPage.java:1277)
	at org.eclipse.ui.internal.WorkbenchPage.setActivePart(WorkbenchPage.java:3524)
	at org.eclipse.ui.internal.WorkbenchPage.requestActivation(WorkbenchPage.java:3071)
	at org.eclipse.ui.internal.PartPane.requestActivation(PartPane.java:279)
	at org.eclipse.ui.internal.EditorPane.requestActivation(EditorPane.java:98)
	at org.eclipse.ui.internal.PartPane.setFocus(PartPane.java:325)
	at org.eclipse.ui.internal.EditorPane.setFocus(EditorPane.java:127)
	at org.eclipse.ui.internal.PartStack.presentationSelectionChanged(PartStack.java:846)
	at org.eclipse.ui.internal.PartStack.access$1(PartStack.java:829)
	at org.eclipse.ui.internal.PartStack$1.selectPart(PartStack.java:139)
	at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation$1.handleEvent(TabbedStackPresentation.java:133)
	at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:270)
	at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:279)
	at org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder.access$1(DefaultTabFolder.java:1)
	at org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder$2.handleEvent(DefaultTabFolder.java:87)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:770)
	at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3256)
	at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:2045)
	at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:323)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3910)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3503)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at cz.tigra.spl.client.rcp.SplApp.start(SplApp.java:108)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
	at java.lang.reflect.Method.invoke(Method.java:600)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:624)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:579)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1442)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1418)
Re: Why ContentOutlineView "steals" focus when my editor is activated? [message #799146 is a reply to message #792734] Wed, 15 February 2012 13:54 Go to previous message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
I have to apologize to all. Everything works fine.

I just found that one of my colleagues add a PartListener to the part service. When an activated part was adaptable to the IContentOutlinePage, the listener activates the ContentOutline view, so it get also the focus. This was the reason of the exception.
Previous Topic:Loading each object in multiple resources
Next Topic:Change Application text from header/titlebar
Goto Forum:
  


Current Time: Fri Apr 19 19:36:29 GMT 2024

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

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

Back to the top