Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Riena » Can the imagepath check for PNG then GIF or tell me if an image exists?
Can the imagepath check for PNG then GIF or tell me if an image exists? [message #489711] Mon, 05 October 2009 16:06 Go to next message
Matt Seashore is currently offline Matt SeashoreFriend
Messages: 58
Registered: July 2009
Member
Hi,

I have a scenario where Navigation tree icons are created based on the
type ID of the navigation node/view (ie. a node Person would be
"Person".gif).

The problem I'm having is that some of the icons are GIF and some are
PNG and it would be nice not to have to add the logic to each node to
have to know whether it's a PNG or GIF. I can't find a way to get Riena
to do this...is it possible to tell Riena to look for PNG and then GIF
in it's image paths?...or is it possible to figure out if a given image
exists on the riena image paths so I can do the right setIcon call myself?

I've looked at the ImageStore class and see it defaults to PNG if no
extension is specified, which is helpful, but it would never find the
GIFs. I also tried ImageStore.getInstance().getImage("Person.png") to
see if I can test and find if a given image exists, but I get an
exception because I'm not running in the UI thread. Before I go and
create a method which does this check through a runnable in the UI
thread, I figured I'd ask if there was a better way :).

Thanks much,

Matt
Re: Can the imagepath check for PNG then GIF or tell me if an image exists? [message #490543 is a reply to message #489711] Fri, 09 October 2009 05:52 Go to previous messageGo to next message
Matt Seashore is currently offline Matt SeashoreFriend
Messages: 58
Registered: July 2009
Member
Just following up with what I ended up doing:

It's not perfect, a warning is still logged when an image isn't found,
but this works reasonably well to check for a png file and then a gif
from a non-UI thread and set the icon accordingly:

final ISubModuleNode result = //create submodule

Display.getDefault().asyncExec(new Runnable(){

@Override
public void run() {

ImageStore store = ImageStore.getInstance();
if(store!=null)
{
String pngIcon = iconName+".png";
String gifIcon = iconName+".gif";

if(store.getImage(pngIcon)!=null)
{
result.setIcon(pngIcon);
}
else if(store.getImage(gifIcon)!=null)
{
result.setIcon(gifIcon);
}
}
}
});

Thanks,

Matt

Matt Seashore wrote:
> Hi,
>
> I have a scenario where Navigation tree icons are created based on the
> type ID of the navigation node/view (ie. a node Person would be
> "Person".gif).
>
> The problem I'm having is that some of the icons are GIF and some are
> PNG and it would be nice not to have to add the logic to each node to
> have to know whether it's a PNG or GIF. I can't find a way to get Riena
> to do this...is it possible to tell Riena to look for PNG and then GIF
> in it's image paths?...or is it possible to figure out if a given image
> exists on the riena image paths so I can do the right setIcon call myself?
>
> I've looked at the ImageStore class and see it defaults to PNG if no
> extension is specified, which is helpful, but it would never find the
> GIFs. I also tried ImageStore.getInstance().getImage("Person.png") to
> see if I can test and find if a given image exists, but I get an
> exception because I'm not running in the UI thread. Before I go and
> create a method which does this check through a runnable in the UI
> thread, I figured I'd ask if there was a better way :).
>
> Thanks much,
>
> Matt
Re: Can the imagepath check for PNG then GIF or tell me if an image exists? [message #490606 is a reply to message #490543] Fri, 09 October 2009 11:26 Go to previous message
Christian Campo is currently offline Christian CampoFriend
Messages: 597
Registered: July 2009
Senior Member
Hi Matt,

sorry we didnt reply earlier, but the Riena team was offline for a few days. If the solution below works for you good.
Still if think it would be even cooler, then it might be good to file a bugreport in bugzilla.

And then we can track it there....

christian campo

Matt Seashore schrieb:
> Just following up with what I ended up doing:
>
> It's not perfect, a warning is still logged when an image isn't found,
> but this works reasonably well to check for a png file and then a gif
> from a non-UI thread and set the icon accordingly:
>
> final ISubModuleNode result = //create submodule
>
> Display.getDefault().asyncExec(new Runnable(){
>
> @Override
> public void run() {
>
> ImageStore store = ImageStore.getInstance();
> if(store!=null)
> {
> String pngIcon = iconName+".png";
> String gifIcon = iconName+".gif";
>
> if(store.getImage(pngIcon)!=null)
> {
> result.setIcon(pngIcon);
> }
> else if(store.getImage(gifIcon)!=null)
> {
> result.setIcon(gifIcon);
> }
> }
> }
> });
>
> Thanks,
>
> Matt
>
> Matt Seashore wrote:
>> Hi,
>>
>> I have a scenario where Navigation tree icons are created based on the
>> type ID of the navigation node/view (ie. a node Person would be
>> "Person".gif).
>>
>> The problem I'm having is that some of the icons are GIF and some are
>> PNG and it would be nice not to have to add the logic to each node to
>> have to know whether it's a PNG or GIF. I can't find a way to get
>> Riena to do this...is it possible to tell Riena to look for PNG and
>> then GIF in it's image paths?...or is it possible to figure out if a
>> given image exists on the riena image paths so I can do the right
>> setIcon call myself?
>>
>> I've looked at the ImageStore class and see it defaults to PNG if no
>> extension is specified, which is helpful, but it would never find the
>> GIFs. I also tried ImageStore.getInstance().getImage("Person.png") to
>> see if I can test and find if a given image exists, but I get an
>> exception because I'm not running in the UI thread. Before I go and
>> create a method which does this check through a runnable in the UI
>> thread, I figured I'd ask if there was a better way :).
>>
>> Thanks much,
>>
>> Matt
Re: Can the imagepath check for PNG then GIF or tell me if an image exists? [message #583922 is a reply to message #489711] Fri, 09 October 2009 05:52 Go to previous message
Matt Seashore is currently offline Matt SeashoreFriend
Messages: 58
Registered: July 2009
Member
Just following up with what I ended up doing:

It's not perfect, a warning is still logged when an image isn't found,
but this works reasonably well to check for a png file and then a gif
from a non-UI thread and set the icon accordingly:

final ISubModuleNode result = //create submodule

Display.getDefault().asyncExec(new Runnable(){

@Override
public void run() {

ImageStore store = ImageStore.getInstance();
if(store!=null)
{
String pngIcon = iconName+".png";
String gifIcon = iconName+".gif";

if(store.getImage(pngIcon)!=null)
{
result.setIcon(pngIcon);
}
else if(store.getImage(gifIcon)!=null)
{
result.setIcon(gifIcon);
}
}
}
});

Thanks,

Matt

Matt Seashore wrote:
> Hi,
>
> I have a scenario where Navigation tree icons are created based on the
> type ID of the navigation node/view (ie. a node Person would be
> "Person".gif).
>
> The problem I'm having is that some of the icons are GIF and some are
> PNG and it would be nice not to have to add the logic to each node to
> have to know whether it's a PNG or GIF. I can't find a way to get Riena
> to do this...is it possible to tell Riena to look for PNG and then GIF
> in it's image paths?...or is it possible to figure out if a given image
> exists on the riena image paths so I can do the right setIcon call myself?
>
> I've looked at the ImageStore class and see it defaults to PNG if no
> extension is specified, which is helpful, but it would never find the
> GIFs. I also tried ImageStore.getInstance().getImage("Person.png") to
> see if I can test and find if a given image exists, but I get an
> exception because I'm not running in the UI thread. Before I go and
> create a method which does this check through a runnable in the UI
> thread, I figured I'd ask if there was a better way :).
>
> Thanks much,
>
> Matt
Re: Can the imagepath check for PNG then GIF or tell me if an image exists? [message #583936 is a reply to message #490543] Fri, 09 October 2009 11:26 Go to previous message
Christian Campo is currently offline Christian CampoFriend
Messages: 597
Registered: July 2009
Senior Member
Hi Matt,

sorry we didnt reply earlier, but the Riena team was offline for a few days. If the solution below works for you good.
Still if think it would be even cooler, then it might be good to file a bugreport in bugzilla.

And then we can track it there....

christian campo

Matt Seashore schrieb:
> Just following up with what I ended up doing:
>
> It's not perfect, a warning is still logged when an image isn't found,
> but this works reasonably well to check for a png file and then a gif
> from a non-UI thread and set the icon accordingly:
>
> final ISubModuleNode result = //create submodule
>
> Display.getDefault().asyncExec(new Runnable(){
>
> @Override
> public void run() {
>
> ImageStore store = ImageStore.getInstance();
> if(store!=null)
> {
> String pngIcon = iconName+".png";
> String gifIcon = iconName+".gif";
>
> if(store.getImage(pngIcon)!=null)
> {
> result.setIcon(pngIcon);
> }
> else if(store.getImage(gifIcon)!=null)
> {
> result.setIcon(gifIcon);
> }
> }
> }
> });
>
> Thanks,
>
> Matt
>
> Matt Seashore wrote:
>> Hi,
>>
>> I have a scenario where Navigation tree icons are created based on the
>> type ID of the navigation node/view (ie. a node Person would be
>> "Person".gif).
>>
>> The problem I'm having is that some of the icons are GIF and some are
>> PNG and it would be nice not to have to add the logic to each node to
>> have to know whether it's a PNG or GIF. I can't find a way to get
>> Riena to do this...is it possible to tell Riena to look for PNG and
>> then GIF in it's image paths?...or is it possible to figure out if a
>> given image exists on the riena image paths so I can do the right
>> setIcon call myself?
>>
>> I've looked at the ImageStore class and see it defaults to PNG if no
>> extension is specified, which is helpful, but it would never find the
>> GIFs. I also tried ImageStore.getInstance().getImage("Person.png") to
>> see if I can test and find if a given image exists, but I get an
>> exception because I'm not running in the UI thread. Before I go and
>> create a method which does this check through a runnable in the UI
>> thread, I figured I'd ask if there was a better way :).
>>
>> Thanks much,
>>
>> Matt
Previous Topic:Can the imagepath check for PNG then GIF or tell me if an image exists?
Next Topic:Unable to resize application
Goto Forum:
  


Current Time: Tue Nov 12 16:49:40 GMT 2024

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

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

Back to the top