org.amanzi.splash.views.importbuilder.ImportBuilderLabelProvider.java Source code

Java tutorial

Introduction

Here is the source code for org.amanzi.splash.views.importbuilder.ImportBuilderLabelProvider.java

Source

/* AWE - Amanzi Wireless Explorer
 * http://awe.amanzi.org
 * (C) 2008-2009, AmanziTel AB
 *
 * This library is provided under the terms of the Eclipse Public License
 * as described at http://www.eclipse.org/legal/epl-v10.html. Any use,
 * reproduction or distribution of the library constitutes recipient's
 * acceptance of this agreement.
 *
 * This library is distributed WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */

package org.amanzi.splash.views.importbuilder;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.viewers.ITableLabelProvider;

import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;

/**
 * Label provider for the ImportBuilderTableViewer
 * 
 * @see org.eclipse.jface.viewers.LabelProvider 
 */
public class ImportBuilderLabelProvider extends LabelProvider implements ITableLabelProvider {

    // Names of images used to represent checkboxes
    public static final String CHECKED_IMAGE = "checked";
    public static final String UNCHECKED_IMAGE = "unchecked";

    // For the checkbox images
    private static ImageRegistry imageRegistry = new ImageRegistry();

    /**
     * Note: An image registry owns all of the image objects registered with it,
     * and automatically disposes of them the SWT Display is disposed.
     */
    static {
        String iconPath = "icons/";
        imageRegistry.put(CHECKED_IMAGE,
                ImageDescriptor.createFromFile(ImportBuilderTableViewer.class, iconPath + CHECKED_IMAGE + ".gif"));
        imageRegistry.put(UNCHECKED_IMAGE, ImageDescriptor.createFromFile(ImportBuilderTableViewer.class,
                iconPath + UNCHECKED_IMAGE + ".gif"));
    }

    /**
     * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
     */
    public String getColumnText(Object element, int columnIndex) {
        String result = "";
        ImportBuilderFilter task = (ImportBuilderFilter) element;
        switch (columnIndex) {
        //         case 0:  // COMPLETED_COLUMN
        //            break;
        case 0:
            result = task.getFilterHeading();
            break;
        case 1:
            result = task.getFilterText();
            break;
        default:
            break;
        }
        return result;
    }

    /**
     * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
     */
    public Image getColumnImage(Object element, int columnIndex) {
        return null;
    }

}