www.pudn.com > talk-plugins.rar > IPStateMapView.java


/** 
 * IPStateMapView.java 
 */ 
package talkServer; 
 
import java.util.Iterator; 
import java.util.Set; 
 
import org.eclipse.swt.SWT; 
import org.eclipse.swt.layout.GridData; 
import org.eclipse.swt.layout.GridLayout; 
import org.eclipse.swt.widgets.Composite; 
import org.eclipse.swt.widgets.Display; 
import org.eclipse.swt.widgets.TableColumn; 
import org.eclipse.swt.widgets.TableItem; 
import org.eclipse.ui.part.ViewPart; 
import org.eclipse.swt.widgets.Table; 
 
import talkServer.business.Maps; 
 
/** 
 * @author Xiang Zhou 
 * @date 2006-4-28 
 */ 
public class IPStateMapView extends ViewPart { 
 
	public static final String ID = "talkServer.IPStateMapView"; // TODO Needs to be whatever is mentioned in plugin.xml 
 
	public void createPartControl(Composite parent) { 
        // LOAD DATA 
//		Maps.loadIPStateMap(); 
		 
		System.out.println(Maps.IP_STATE_MAP.get("172.18.80.34")); 
		 
		Composite top = new Composite(parent, SWT.NONE); 
		top.setLayout(new GridLayout()); 
		GridData gridData = new GridData(GridData.FILL_HORIZONTAL 
				| GridData.FILL_VERTICAL); 
		 
		Table mapTable = new Table(top, SWT.SINGLE 
				| SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); 
		mapTable.setLayoutData(gridData); 
		mapTable.setHeaderVisible(true); 
		mapTable.setLinesVisible(true); 
 
		mapTable.setBackground(Display.getCurrent().getSystemColor( 
				SWT.COLOR_WHITE)); 
		 
		TableColumn tc1 = new TableColumn(mapTable, SWT.NONE); 
		tc1.setText("IP"); 
		tc1.setResizable(true); 
		tc1.setWidth(200); 
		 
		TableColumn tc2 = new TableColumn(mapTable, SWT.NONE); 
		tc2.setText("STATE"); 
		tc2.setResizable(true); 
		tc2.setWidth(350); 
		 
		fillData(mapTable); 
	} 
	 
	private void fillData(Table mapTable) { 
		Set dataSet = Maps.getIPStateMapData(); 
		Iterator it = dataSet.iterator(); 
		while(it.hasNext()) { 
			String aMap = it.next().toString(); 
			String[] aMap_arr = aMap.split("="); 
			aMap_arr[0].trim(); 
			aMap_arr[1].trim(); 
			TableItem ti = new TableItem(mapTable, SWT.NONE); 
			ti.setText(aMap_arr); 
		} 
	} 
 
	/* (non-Javadoc) 
	 * @see org.eclipse.ui.part.WorkbenchPart#setFocus() 
	 */ 
	public void setFocus() { 
		// TODO Auto-generated method stub 
 
	} 
}