Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Plugin development - getting icon specific for a givet (custom) Item type

Solution Partner Experimenter Solution Partner Experimenter
Solution Partner Experimenter

Hello everybody,

I'm developing a plugin for Teamcenter Rich Client. One of required functionality is to collect some objects (ItemRevisions of - mostly, but not always - custom types), and display them in a table. There is a need to remove seleceted from the table, but it is not a problem. The problem is, that it is important to display revision with the icon, as it is displayed in e.g. My Teamcenter view. I'm stuck with this task...

 

TC has some extensions installed, which include icons for custom types of revisions. In rich client it works as expected.

Easily I can get the icon name for eachobject (obj):

String iconName = obj.getTypeObject().getConstant("Fnd0Icon");

but I failed with getting a SWT Image object, which is needed to be put in the TableItem...

In  the theory, I couold get the icon file from tcdata\model\icons folder, but icons are stored in ZIP files, with names relating to extensions they come from. Not a nice way for programmer...

 

I have also tried ImageProviderUtil, but it seems (not much documentation, so it is based mostly on my deductions and tries) like it is used for caching images for the session and acces them by simple String key. Potentially I could programatically read all icons from tcdata and store them in this util, but potentially there san my tens of extensions and thousands of icons... Neither elegant nor effective soulution would it be... I'll keep it as a last-resort.

 

In documentation I have also find some "renderers" but these were described as Swing-family objects, and are supposed to be not supported in the future.

 

If anyone has idea woh to solve it - I would be thankful.

Thank You in advance. Best regards - Michal Murawski

4 REPLIES 4

Re: Plugin development - getting icon specific for a givet (custom) Item type

Siemens Genius Siemens Genius
Siemens Genius

There are methods available on class

com.teamcenter.rac.common.TCTypeRenderer

 

e.g.

TCTypeRenderer.getIcon(tccomp)

TCTypeRenderer.getIconForComponent((TCComponent)userObj, expanded)

TCTypeRenderer.getTypeIcon("MY4_PartRevision", "PartRevision"))

 

I'm not sure about SWT resource management for this icons. I usually do not dispose them explicitly.

 

Kind regards

Svatos

Re: Plugin development - getting icon specific for a givet (custom) Item type

Solution Partner Experimenter Solution Partner Experimenter
Solution Partner Experimenter

Hello Svatos,

thank You for the reply.

Perhaps I haven't been detailed enough. I cannot use Swing-related classes, because they are described as not-recommended and are supposed to be not available in future versions of Teamcenter (these notes come from documentation of TC10). Therefore, because of compatibility issues ( I need to provide solution as much version-independent a possible, already considering TC10 and TC11) I cannot use class You proposed. Nevertheless, thank you.

 

Best Regards - Michal Murawski

Re: Plugin development - getting icon specific for a givet (custom) Item type

Siemens Genius Siemens Genius
Siemens Genius

What about

getComponentImage

getTypeImage

of the same class?

 

Kind regards

Svatos

Re: Plugin development - getting icon specific for a givet (custom) Item type

Solution Partner Experimenter Solution Partner Experimenter
Solution Partner Experimenter

Hi Svatos,

you are right - I have focused on "icon" and I did not analyse these methods thoroughly. Here are results:

For ItemRevision (custom):

 

TCComponent comp;

TCTypeRenderer.getImage(comp) - returns icon of REVISION
TCTypeRenderer.getImage(comp.getTypeComponent()) - returns icon of ITEM (not Revision)
TCTypeRenderer.getImage(comp.getTypeObject()) - returns icon fotr ITEM (not Revision)

 

Returned Image class objects are of SWT image, not the Swing, so I can use them freely.

 

Thank You very much, your answers have been very helpful.

Best Regards - Michal Murawski