Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » @Focus in Eclipse 4.3 M3
@Focus in Eclipse 4.3 M3 [message #986413] Tue, 20 November 2012 11:00 Go to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Hi,

today I installed Eclipse 4.3 M3. On trying to run the application I migrated to Eclipse 4 I noticed a different behaviour for @Focus. It seems the call stack has changed and @Focus is called before @PostConstruct. This leads to a NPE if I'm trying to do something like this (got this from some well known tutorials):

private TableViewer viewer;

@PostConstruct
public void createPart(Composite parent) {
	viewer = new TableViewer(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
}

@Focus
public void setFocus() {
	viewer.getTable().setFocus();
}


This code works with 4.2.1. So the question is, is the new behaviour intended or a bug?

Greez,
Dirk
Re: @Focus in Eclipse 4.3 M3 [message #986415 is a reply to message #986413] Tue, 20 November 2012 11:03 Go to previous messageGo to next message
Eclipse UserFriend
https://bugs.eclipse.org/bugs/show_bug.cgi?id=394327
Re: @Focus in Eclipse 4.3 M3 [message #986416 is a reply to message #986415] Tue, 20 November 2012 11:12 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Thanks Sopot, that's it. Again I searched with the wrong parameters. Sad
Re: @Focus in Eclipse 4.3 M3 [message #986758 is a reply to message #986416] Wed, 21 November 2012 14:46 Go to previous messageGo to next message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

Dirk, I just pushed Wims change. Would be great if you could test the fix and perhaps comment on the bug.
Re: @Focus in Eclipse 4.3 M3 [message #986761 is a reply to message #986758] Wed, 21 November 2012 14:59 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
As far as I understand, the fix is to add the dependency to javax.annotation on creating a new project. So for existing projects, this wouldn't fix anything. There needs to be a documentation on what to do on moving from 4.2 to 4.3.

Or did I missunderstand the fix?
Re: @Focus in Eclipse 4.3 M3 [message #986771 is a reply to message #986761] Wed, 21 November 2012 15:15 Go to previous messageGo to next message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

Just change your MANIFEST.MF dependency to a package dependency for javax.annotation and re-run.
Re: @Focus in Eclipse 4.3 M3 [message #986774 is a reply to message #986771] Wed, 21 November 2012 15:25 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Yes I did that already after Sopot linked to the bug. Smile And yes then it works. Nevertheless this needs to be documented as a migration issue for existing Eclipse 4 applications.
Re: @Focus in Eclipse 4.3 M3 [message #986775 is a reply to message #986774] Wed, 21 November 2012 15:27 Go to previous messageGo to next message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

Nevertheless this needs to be documented as a migration issue for existing Eclipse 4 applications.

-> Sure, go ahead. Smile
Re: @Focus in Eclipse 4.3 M3 [message #988798 is a reply to message #986413] Mon, 03 December 2012 09:25 Go to previous messageGo to next message
Marco Descher is currently offline Marco DescherFriend
Messages: 197
Registered: October 2010
Location: Austria
Senior Member
I just stumbled upon this problem, and could fix it by adding the proposed @Inject after the @PostConstruct

If I execute the code on 4.3 it at least works, if I execute it on 4.2 now, however, the user interface elements get shown doubled!!

I don't get this, what is now the official solution? I am using the latest 4.3 I and 4.2 and I don't seem to be able to create a version that runs flawless on both?!
Re: @Focus in Eclipse 4.3 M3 [message #988799 is a reply to message #988798] Mon, 03 December 2012 09:35 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
As Lars explained, you need to add the depencency to javax.annotation package to your MANIFEST.MF. You don't need to have @Inject and @PostConstruct at the same time.
Re: @Focus in Eclipse 4.3 M3 [message #988810 is a reply to message #988799] Mon, 03 December 2012 10:13 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Am 03.12.12 10:35, schrieb Dirk Fauth:
> As Lars explained, you need to add the depencency to javax.annotation
> package to your MANIFEST.MF. You don't need to have @Inject and
> @PostConstruct at the same time.

Don't need is the wrong term! MUST NOT is the correct one.

In the end the real problem is that equinox by default exports all the
bootclasspath-packages. If you'd have pure OSGi you'd import each and
every package no matter if it is provided as part of the JDK (=exported
by the system.bundle) or another bundle and PDE replicates this :-(

It would be nice to put PDE into a strict OSGi-mode where it tells you
that you need to import the bits from the JRE as well.

Tom
Re: @Focus in Eclipse 4.3 M3 [message #988823 is a reply to message #988799] Mon, 03 December 2012 10:58 Go to previous messageGo to next message
Marco Descher is currently offline Marco DescherFriend
Messages: 197
Registered: October 2010
Location: Austria
Senior Member
I already have that dependency, it does not help!
Re: @Focus in Eclipse 4.3 M3 [message #988828 is a reply to message #988823] Mon, 03 December 2012 11:08 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Please note that it should be a package-import and not a require-bundle.

Tom

Am 03.12.12 11:58, schrieb Marco Descher:
> I already have that dependency, it does not help!
Re: @Focus in Eclipse 4.3 M3 [message #988830 is a reply to message #988828] Mon, 03 December 2012 11:19 Go to previous message
Marco Descher is currently offline Marco DescherFriend
Messages: 197
Registered: October 2010
Location: Austria
Senior Member
That did it, thanks a lot Smile
Previous Topic:Mechanism to provide IAdapterFactory for classes, not instances?
Next Topic:Contacts Demo not working properly
Goto Forum:
  


Current Time: Tue Apr 16 12:47:47 GMT 2024

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

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

Back to the top