Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » How to create ToolControl in Eclipse 4.x(How to create ToolControl in Eclipse 4.x)
How to create ToolControl in Eclipse 4.x [message #1066602] Wed, 03 July 2013 08:08 Go to next message
sumit singh is currently offline sumit singh
Messages: 131
Registered: October 2012
Location: Bangalore
Senior Member

I'm working on eclipse kepler RCP application.
I want to contribute to trimbar through ToolControl.
With E4 tool i got following option:

index.php/fa/15464/0/

In above image My problem is:

1. Which class I have to add it here.?
Is this call needs to implement some interface or extend any class. I tried alot on internet but cruelness to find any thing.

What i tried yet Created class with following combination.

1. by extending WorkbenchWindowControlContribution class
2. by extending ToolControlImpl class

In 1st case constructor is called but createControl(Composite parent) is not called.
In 2nd nothing is called.


Please tell me what i'm missing here.

Thanks.

[Updated on: Wed, 03 July 2013 08:08]

Report message to a moderator

Re: How to create ToolControl in Eclipse 4.x [message #1066606 is a reply to message #1066602] Wed, 03 July 2013 08:16 Go to previous messageGo to next message
Bastian Wagenfeld is currently offline Bastian Wagenfeld
Messages: 162
Registered: January 2013
Senior Member
Hi,

the class does not have to extend anything. But it has to have a method annotated with @PostConstruct, for example @PostConstruct public void createControl(Composite parent). You have to import the package javax.annotation, too.

Best regards
Bastian
Re: How to create ToolControl in Eclipse 4.x [message #1066609 is a reply to message #1066606] Wed, 03 July 2013 08:30 Go to previous messageGo to next message
sumit singh is currently offline sumit singh
Messages: 131
Registered: October 2012
Location: Bangalore
Senior Member

Thanks a lot Bastian Wagenfeld, I already tried with method annotated with @PostConstruct but i forget Why isn't my @Inject-able/@PostConstruct methods being injected? problem.

Yeah after explicitly added
Import-Package: javax.inject;version="1.0.0",javax.annotation; version="1.0.0"
its working expected now.

Thanks again Smile
Re: How to create ToolControl in Eclipse 4.x [message #1066690 is a reply to message #1066609] Wed, 03 July 2013 14:26 Go to previous messageGo to next message
Jo Jaquinta is currently offline Jo Jaquinta
Messages: 40
Registered: January 2013
Location: Boston
Member

I've got the same problem, but this doesn't solve it.
I'm upgrading my team to 4.3. In my test environment I've updated to the latest tools (Thanks Sopot) but my ToolControl (and other things) have ceased to work. Frustratingly it works OK if I generate a new application using the template. But even when I change all my dependencies to be the exact same as in the temple, my ToolControl will not load.
Any suggestions of what I should be looking for?


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jo Grant, Senior Software Engineer
Admin and Config Console Architect
OpenPages, IBM
Re: How to create ToolControl in Eclipse 4.x [message #1066711 is a reply to message #1066690] Wed, 03 July 2013 18:38 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 597
Registered: December 2010
Senior Member

So your @PostConstruct is not being called even if you specify the javax.annotation package import? Do you have something in the log?

Mind that in the migration to 4.3 you have to add the handler processing addon https://bugs.eclipse.org/bugs/show_bug.cgi?id=397837 for the handled things to work. It used to be a ugly hard-coded code which I extracted as an addon.
Re: How to create ToolControl in Eclipse 4.x [message #1066739 is a reply to message #1066711] Thu, 04 July 2013 03:46 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5284
Registered: July 2009
Senior Member
it's important that the import is versioned so it has to be
javax.annotation;1.0.0!

Tom

On 04.07.13 00:38, Sopot Cela wrote:
> So your @PostConstruct is not being called even if you specify the
> javax.annotation package import? Do you have something in the log?
>
> Mind that in the migration to 4.3 you have to add the handler processing
> addon https://bugs.eclipse.org/bugs/show_bug.cgi?id=397837 for the
> handled things to work. It used to be a ugly hard-coded code which I
> extracted as an addon.
Re: How to create ToolControl in Eclipse 4.x [message #1067447 is a reply to message #1066739] Mon, 08 July 2013 14:24 Go to previous messageGo to next message
Jo Jaquinta is currently offline Jo Jaquinta
Messages: 40
Registered: January 2013
Location: Boston
Member

Thanks for the ideas. I've got the handler there, and all versions appear to be set to 1.0.0. Nothing appears in the log. >_<
Trying to go step by step from the generated application...
Driving me crazy here. I now have it so the exact same class gets @PostConstruct called correctly when in the same plugin as the sample application, but @PostConstruct is not called when it is loaded from another plugin.
I thought I had it when I noticed that my plugin used Import-Package: javax.inject;bundle-version="1.0.0", and the sample used Require-Bundle: javax.inject;bundle-version="1.0.0". But they now both use the same and it still fails. (cries)
I'm pretty sure it's a version thing, like you say. I started printing PostConstruct.class.hashCode() and they are different. When I get the package and print the details, it is VERY different. I'm really confused now.
This is what I've reduced my class to:

import javax.annotation.PostConstruct;

public class PerspectiveTabs
{
    public PerspectiveTabs()
    {
        System.out.println(getClass().getName()+" - constructor");
        System.out.println("  "+PostConstruct.class.getName()+" - "+PostConstruct.class.hashCode());
        Package pkg = PostConstruct.class.getPackage();
        System.out.println("  Package - "+pkg.getName());
        System.out.println("  Implementation - "+pkg.getImplementationTitle()+", "+pkg.getImplementationVendor()+", "+pkg.getImplementationVersion());
        System.out.println("  Specification - "+pkg.getSpecificationTitle()+", "+pkg.getSpecificationVendor()+", "+pkg.getSpecificationVersion());
    }

    @PostConstruct
    public void createUI()
    {
        System.out.println(getClass().getSimpleName()+" - postconstruct");
    }
}


And this is the output I get:

com.ibm.openpages.config.ui.e43.ctrl.PerspectiveTabs - constructor
  javax.annotation.PostConstruct - 1635287180
  Package - javax.annotation
  Implementation - null, null, null
  Specification - null, null, null
PerspectiveTabs - postconstruct
com.ibm.openpages.config.ui.ctrl.PerspectiveTabs - constructor
  javax.annotation.PostConstruct - 2062082543
  Package - javax.annotation
  Implementation - Java Runtime Environment, Oracle Corporation, 1.7.0_11
  Specification - Java Platform API Specification, Oracle Corporation, 1.7


The first is the ToolControl that points to the class declared in the generated sample's plugin (which works). The second is in the identical class in my pre-existing plugin (which doesn't). Am I correct that a different hashCode() on the .class object means they are definitely different classes? Or would the Eclipse plugin model load them uniquely per plugin, and those values can't be compared. But, even if that was the case, why would the package versions be different?
I've gone through their MANIFEST.MF line by line, and all overlaps have the exact same version dependencies.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jo Grant, Senior Software Engineer
Admin and Config Console Architect
OpenPages, IBM
Re: How to create ToolControl in Eclipse 4.x [message #1067526 is a reply to message #1067447] Tue, 09 July 2013 04:45 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 597
Registered: December 2010
Senior Member

It's a bit hard to deduce your configuration here, at least for me. Try to attach the plugin.xml, manifest.mf of the plugin containing your POJO and .product file you use to run your app.
Re: How to create ToolControl in Eclipse 4.x [message #1067643 is a reply to message #1067526] Tue, 09 July 2013 15:09 Go to previous messageGo to next message
Jo Jaquinta is currently offline Jo Jaquinta
Messages: 40
Registered: January 2013
Location: Boston
Member

The program is a shipping product, so there's a lot going on. I can't include all of that here. It works fine on 4.2, I'm just having difficulty getting to work on 4.3.
The core product plugin was "com.ibm.openpages.config.ui", but that had the problem that PostConsturct was not being called. So I generated a new plugin from the template called "com.ibm.openpages.config.ui.e43". I put a ToolControl in this and it successfully called PostConstruct. So I made this the primary plugin and loaded com.ibm.openpages.config.ui as a secondary one, and attempted to load a ToolControl from there. This does not call PostConstruct.
So, in the attached files, the primary_ files are the com.ibm.openpages.config.ui.e43 plugin, from which PostConstruct is called correctly, and the secondary_ files are the com.ibm.openpages.config.ui plugin, from which PostConstuct is not called correctly.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jo Grant, Senior Software Engineer
Admin and Config Console Architect
OpenPages, IBM
Re: How to create ToolControl in Eclipse 4.x [message #1067649 is a reply to message #1067643] Tue, 09 July 2013 15:49 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 597
Registered: December 2010
Senior Member

From an initial quick look the secondary manifest, the import of the javax.annotation is followed by 'bundle-version blablabla'. Package imports don't normally have 'bundle-version's but just 'version's so it should be 'Import-Package: javax.annotation;version="1.0.0" ' (without the bundle-). HTH.
Re: How to create ToolControl in Eclipse 4.x [message #1067650 is a reply to message #1067649] Tue, 09 July 2013 15:52 Go to previous messageGo to next message
Jo Jaquinta is currently offline Jo Jaquinta
Messages: 40
Registered: January 2013
Location: Boston
Member

Sheesh. You stare at something long enough and you stop seeing the obvious. The PostConstruct is now being called correctly. Onto my next porting problem!
Many, many thanks.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jo Grant, Senior Software Engineer
Admin and Config Console Architect
OpenPages, IBM
Re: How to create ToolControl in Eclipse 4.x [message #1067651 is a reply to message #1067650] Tue, 09 July 2013 15:59 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 597
Registered: December 2010
Senior Member

You're welcome. If it's an issue for you I can delete your attachments.
Re: How to create ToolControl in Eclipse 4.x [message #1067808 is a reply to message #1067651] Wed, 10 July 2013 12:21 Go to previous message
Jo Jaquinta is currently offline Jo Jaquinta
Messages: 40
Registered: January 2013
Location: Boston
Member

It's OK. I vetted them before I posted. It can be grey what is and is not confidential info, but I think I'm clear.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jo Grant, Senior Software Engineer
Admin and Config Console Architect
OpenPages, IBM
Previous Topic:ICommandService and ExecutionEvent
Next Topic:Need clarification of extending E4 app by fragments
Goto Forum:
  


Current Time: Fri Aug 22 12:02:45 EDT 2014

Powered by FUDForum. Page generated in 0.02922 seconds