Costumizing Toolbar with ToolbarButton

Oxygen general issues.
Chemo
Posts: 19
Joined: Mon Aug 15, 2011 10:57 am

Costumizing Toolbar with ToolbarButton

Post by Chemo »

Hi.

I am trying to costumize my costum plugin toolbar and it works just fine with the common swing components, like JButton. But I have a problem using ToolbarButton - objects, so that the toolbar fit in the oxygen style.

The ToolbarInfo object provided by the customizeToolbar() function needs a JComponent[] list for it's setComponents() function. But the JComponent[] array won't accept objects of the type ToolbarButton. What am I missing?

Thanks and with kind regards,
Thomas.
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: Costumizing Toolbar with ToolbarButton

Post by alex_jitianu »

Hello Thomas,

The ro.sync.exml.workspace.api.standalone.ui.ToolbarButton is actually an extension of JButton and indirectly a JComponent. So you should be able to add it inside that array of JComponent. We actually use it in one of our sample plugins (oxygen-sample-plugin-workspace-access):

Code: Select all

if("SampleWorkspaceAccessToolbarID".equals(toolbarInfo.getToolbarID())) {
List<JComponent> comps = new ArrayList<JComponent>();
ToolbarButton checkInButton = new ToolbarButton(checkInAction, true);
checkInButton.setText("Check In");
comps.add(checkInButton);
toolbarInfo.setComponents(comps.toArray(new JComponent[0]));
}

Best regards,
Alex
Chemo
Posts: 19
Joined: Mon Aug 15, 2011 10:57 am

Re: Costumizing Toolbar with ToolbarButton

Post by Chemo »

Thank you for your quick reply.

Yes, that's what the API description tells and what I expected.
Nevertheless my eclipse SDK tells me that it's not possible to convert ToolbarButton to JComponent (Type mismatch). I also already tested the example code you mentioned with the same error.

Maybe it's just a eclipse issue, but when I let eclipse show me the type hierarchy of ToolbarButton it has only one ancestor, the "e" class, while Eclipse shows the expected Object-Component-Container-JComponent-AbstractButton-JButton-xf-ColorButton hierarchy for ColorButton and the other ro.sync.exml.workspace.api.standalone.ui.* classes. Only the ToolbarButtons seems to have this weird "e"-ToolbarButton hierarchy.

I am referencing the oxygen 16.1 x64 oxygen.jar library (but also tested the 15.2 x64 library), do not use the oxygen eclipse plugin and running eclipse in version SDK 4.2.2.

Kind regards,
Thomas.
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: Costumizing Toolbar with ToolbarButton

Post by alex_jitianu »

Hello Thomas,

I think you are having a problem with ToolbarButton because it requires an additional jar file (jide-oss-3.5.6.jar). You can get all the required jar files from oxygen-sdk-16.1.2-all.zip. Alternatively, if you could have used the Maven based sample project as a starting point and all the required jar files would have been automatically downloaded.

Best regards,
Alex
Chemo
Posts: 19
Joined: Mon Aug 15, 2011 10:57 am

Re: Costumizing Toolbar with ToolbarButton

Post by Chemo »

Thank you, this was the problem. Everything works fine now.
I didn't expect eclipse to behave this way with missing librarys.

Best Regards,
Thomas.
Post Reply