/* D-RexGxt - D-RexGxt - GUI Design Tool for GWT
 * Copyright (c) 2008,  KPS Corporation
 * All rights reserved.
 *
 * Open Source License
 * ------------------------------------------------------------------------------------------
 * D-RexGxt is licensed under the terms of the Open Source GPL 3.0 license.
 *
 * http://www.gnu.org/licenses/gpl.html
 *
 * --
 *
 * This library 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.
 */
package jp.co.kpscorp.gwt.client.design.gxt.common;

import java.util.List;

import com.extjs.gxt.ui.client.data.BaseListLoadConfig;
import com.extjs.gxt.ui.client.data.BeanModelReader;
import com.extjs.gxt.ui.client.data.ModelData;

public class GxtUtil {
	public static List<ModelData> toModelDataList(List<Object> list) {
		BeanModelReader<BaseListLoadConfig> reader = new BeanModelReader<BaseListLoadConfig>();
		List<ModelData> data = reader.read(new BaseListLoadConfig(), list)
				.getData();
		return data;
	}

	public static String prop2Label(String prop, String[][] labels) {
		for (int i = 0; i < labels.length; i++) {
			String[] el = labels[i];
			if (el[0].equals(prop)) {
				return el[1];
			}
		}
		return null;
	}
}
