Thank you for the response. The thing is that I want to call something like
this:

Image w = new Image(ImageResourceLoader.background());
and this resolves everything... (by URL or by static). All the behavior of
deciding whether the image is customized or not remains inside the
ImageResourceLoader.


I have the Resources interface which declares all the static images. I did
an ImageResourceLoader class that implements the Resources interface.
Implementing the Resources interface ensures all images can be accessed
through the ImageResourceLoader.

An example method of the ImageResourceLoader:

@Override
    public ImageResource backgroundColor() {
        if(isCustomized){
            return createImageResource(new Image(backgroundURL));
        } else {
            return Resources.INSTANCE.backgroundColor();
        }
    }

The only solution I found for the createImageResource method was something
like this:

private ImageResource createImageResource(final Image image){

        return new ImageResource() {

            @Override
            public String getName() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public boolean isAnimated() {
                return true;
            }

            @Override
            public int getWidth() {
                return image.getWidth();
            }

            @Override
            public String getURL() {
                // TODO Auto-generated method stub
                return image.getUrl();
            }

            @Override
            public int getTop() {
                // TODO Auto-generated method stub
                return image.getAbsoluteTop();
            }

            @Override
            public int getLeft() {
                // TODO Auto-generated method stub
                return image.getAbsoluteLeft();
            }

            @Override
            public int getHeight() {
                // TODO Auto-generated method stub
                return image.getHeight();
            }
        };
    }

but I think that the Image would be fetched twice from the server, one in
the backgroundColor method and the other in the line:

Image w = new Image(ImageResourceLoader.background());

Do you have some suggestions?

Thanks!

Juan José


2010/4/14 Viliam Durina <[email protected]>

> I think you should do:
> Image w = isCustomizedImage()
>  ? new Image(getCustomUrl())
>   : new Image(ResourceLoader.INSTANCE.background());
>
> The client bundle must contain only static images that are known at
> compile time, as this is the time when it creates one composite image.
> You must use ClientBundle for static images and use different
> mechanism that loads non-static images.
>
> Viliam
>
> On 12. Apr, 16:54 h., Juan Quito <[email protected]> wrote:
> > Hello, my application has some standard icons like save, new, edit,
> > etc... but the user can customize the icons and specify the images he
> > wants the application to display at runtime. How can I accomplish this
> > using ClientBundle interface (the standard images would be specified
> > in the extended interface) and in runtime the system gets the custom
> > image instead of the standard one by loading from an URL?
> > I don't mind getting all the standard icons even if they won't be used
> > at all. Today my system loads all images by the URL, so the startup of
> > the application is too slow and most of the images are standard.
> >
> > I would like to do something like this:
> >
> > Image w = new Image(ResourceLoader.INSTANCE.background());
> >
> > ResourceLoader looks if there is a customized image for background,
> > and if there is... loads from an URL, if not... calls the Resources
> > interface loading the standard one.
> >
> > interface Resources extends ClientBundle {
> >     Resources INSTANCE = GWT.create(Resources.class);
> >     @Source("images/background.png")
> >     ImageResource background();
> >
> > }
> >
> > Thanks!
> > Juan José Quito
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-web-toolkit%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to