⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 devicetablelabelprovider.java

📁 eclipseme的最新版本的source,欢迎j2me程序员使用
💻 JAVA
字号:
/**
 * Copyright (c) 2003-2005 Craig Setera
 * All Rights Reserved.
 * Licensed under the Eclipse Public License - v 1.0
 * For more information see http://www.eclipse.org/legal/epl-v10.html
 */
package eclipseme.ui.internal.devices;

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

import eclipseme.core.model.API;
import eclipseme.core.model.ILibrary;
import eclipseme.core.model.device.IDevice;

/**
 * Label provider implementation that provides label information
 * for an instance of IDevice.
 * <p />
 * Copyright (c) 2003-2005 Craig Setera<br>
 * All Rights Reserved.<br>
 * Licensed under the Eclipse Public License - v 1.0<p/>
 * <br>
 * $Revision: 1.1 $
 * <br>
 * $Date: 2006/02/11 21:27:11 $
 * <br>
 * @author Craig Setera
 */
public class DeviceTableLabelProvider 
	extends LabelProvider 
	implements ITableLabelProvider 
{
	private static final String TEXT_UNKNOWN = "";
	
	private static final int COL_CHECKBOX = 0;
	private static final int COL_GROUP_NAME = 1;
	private static final int COL_NAME = 2;
	private static final int COL_CONFIGURATION = 3;
	private static final int COL_PROFILE = 4;
	
	/**
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
	 */
	public Image getColumnImage(Object element, int columnIndex) {
		return null;
	}

	/**
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
	 */
	public String getColumnText(Object element, int columnIndex) {
		String text = TEXT_UNKNOWN;
		IDevice device = (IDevice) element;
		
		switch (columnIndex) {
			case COL_CHECKBOX:
				text = "";
				break;
				
			case COL_NAME:
				text = device.getName();
				break;
				
			case COL_GROUP_NAME:
				text = device.getGroupName();
				break;
				
			case COL_CONFIGURATION:
				text = getConfigurationText(device);
				break;
				
			case COL_PROFILE:
				text = getProfileText(device);
				break;
		}
		
		return text;
	}

	/**
	 * Return the text for the device's configuration library.
	 * 
	 * @param device
	 * @return
	 */
	private String getConfigurationText(IDevice device) {
		String text = TEXT_UNKNOWN;

		ILibrary library = device.getConfigurationLibrary();
		if (library != null) {
			API api = library.getConfiguration();
			if (api != null) {
				text = api.toString();
			}
		}
		
		return text;
	}

	/**
	 * Return the text for the device's profile library.
	 * 
	 * @param device
	 * @return
	 */
	private String getProfileText(IDevice device) {
		String text = TEXT_UNKNOWN;

		ILibrary library = device.getProfileLibrary();
		if (library != null) {
			API api = library.getProfile();
			if (api != null) {
				text = api.toString();
			}
		}
		
		return text;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -