com.nextep.designer.dbgm.ui.jface.DomainLabelProvider.java Source code

Java tutorial

Introduction

Here is the source code for com.nextep.designer.dbgm.ui.jface.DomainLabelProvider.java

Source

/*******************************************************************************
 * Copyright (c) 2011 neXtep Software and contributors.
 * All rights reserved.
 *
 * This file is part of neXtep designer.
 *
 * NeXtep designer is free software: you can redistribute it 
 * and/or modify it under the terms of the GNU General Public 
 * License as published by the Free Software Foundation, either 
 * version 3 of the License, or any later version.
 *
 * NeXtep designer is distributed in the hope that it will be 
 * useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Contributors:
 *     neXtep Softwares - initial API and implementation
 *******************************************************************************/
package com.nextep.designer.dbgm.ui.jface;

import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;

import com.nextep.datadesigner.dbgm.model.IDomain;

/**
 * 
 * @author Christophe Fondacci
 */
public class DomainLabelProvider implements ITableLabelProvider {

    @Override
    public Image getColumnImage(Object element, int columnIndex) {
        return null;
    }

    @Override
    public String getColumnText(Object element, int columnIndex) {
        final IDomain d = (IDomain) element;
        switch (columnIndex) {
        case 1:
            return d.getName();
        case 2:
            return d.getDescription();
        case 3:
            return formatExpression(d.getLengthExpr());
        case 4:
            return formatExpression(d.getPrecisionExpr());

        }
        return null;
    }

    private String formatExpression(String expr) {
        if (expr != null && "*".equals(expr.trim())) { //$NON-NLS-1$
            return "* > 0"; //$NON-NLS-1$
        }
        return expr;
    }

    @Override
    public void addListener(ILabelProviderListener listener) {
        // TODO Auto-generated method stub

    }

    @Override
    public void dispose() {
        // TODO Auto-generated method stub

    }

    @Override
    public boolean isLabelProperty(Object element, String property) {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public void removeListener(ILabelProviderListener listener) {
        // TODO Auto-generated method stub

    }

}