Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7959501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:35:02+00:00 2026-06-04T04:35:02+00:00

I have problem with changing this image list provider in to thumbnail provider. In

  • 0

I have problem with changing this image list provider in to thumbnail provider. In case of need I will post View for it too.

public Object[] getElements(Object inputElement) {
        if (iDirname == null)
            return null;
        File dir = new File(iDirname);
        FilenameFilter filter = new FilenameFilter() {
            public boolean accept(File directory, String filename) {
                if (filename.endsWith("jpg") || (filename.endsWith("bmp")) || (filename.endsWith("png") || (filename.endsWith("JPG") || (filename.endsWith("BMP")) || (filename.endsWith("PNG")))))
                    return true;
                else
                    return false;
            }
        };
        String[] dirList = null;

        if (dir.isDirectory()) {
            dirList = dir.list(filter);
            for (int i=0; i<dirList.length;++i){

                //dirList2[i] = new Image(device, dirList2[i]); added this to try passing array of Images - failed.
                dirList[i] = iDirname + File.separatorChar + dirList[i];

            }
        }
        return dirList;
    }

And the view

public void createPartControl(Composite parent) {
        iViewer = new ListViewer(parent);
        iViewer.setContentProvider(new DirListProvider());


        getSite().setSelectionProvider(iViewer);
        makeActions();
        hookContextMenu();
        contributeToActionBars();

    }

I don’t know how to change provided path lists to the thumbnail displaying. Should I get the provided content in to Array and iterate through it creating Images? If so how?

Thanks in advance for your help.

EDIT:

I added

ImageDescriptor[] dirList = null;
        if (dir.isDirectory()) {
            String[] dirList2 = dir.list(filter);
            for (int i=0; i<dirList2.length;++i){

                dirList[i] = ImageDescriptor.createFromImageData(new ImageData(iDirname + File.separatorChar + dirList2[i]));
                //dirList[i] = iDirname + File.separatorChar + dirList[i];

            }
        }
        return dirList;

but this is not showing anything at all.

When you are telling me to use Composite, is it my parent variable? I still don’t know how to display the images from paths passed by ListProvider. I am really green in this :/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:35:02+00:00Added an answer on June 4, 2026 at 4:35 am

    What you are missing here is a LabelProvider. You can use a LabelProvider to provide an image for each element in your viewer’s input.

    However, Francis Upton is right, I don’t think ListViewer will really suit your needs as you will end up with a single column of images. Although you won’t be able to add the images directly to your Composite, you will need to set them as the background image of a label.

    There are a couple of other things to consider:

    • You need to dispose() of your Images once you’re done with them as they use up System handles. Therefore you need to keep track of the Images you create in your getElements(Object) method.
    • If the directories you are reading the images from do not already contain thumbnails, you will need to scale the images before presenting them on your UI.

    Remember, the array type you return from your ContentProvider’s getElements(Object) method defines the type that will get passed into your LabelProvider’s methods. So you started off returning an array of strings representing paths to the images. Your LabelProvider would need to load these into images to be returned from the provider’s getImage method – but bear in mind what I said about disposing of these images! Then you switched to returning an Array of image descriptors, in this case you would need to cast your incoming Object to an ImageDescriptor and use that to create the Image in the getImage method. Maybe once you have this working you can think about whether this meets your needs, and then possibly look at doing a different implementation, such as the composite/gridlayout/label approach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a gridview set up with a list of images like this: public
HI! I have a problem with changing the name of a select element. I
I have the following code, and i have a problem regarding changing the ringtone
I have an strange problem with sencha touch. Changing the value in the select
I have problem with fancybox. I want to write a function that will run
I have a problem in creating a Button with text and image on it.
I just have a question regarding changing an Activities layout. Basicly my problem is:
I have another orientation problem. But this one is very tricky. My RootViewController is
I have a problem where I need to combine a DataTrigger and a PropertyTrigger
I have a problem with changing onmouseover and onmouseout attributes on dynamic pictures. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.