www.pudn.com > talk-plugins.rar > IPPasswordMapView.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.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.ViewPart;
import talkServer.business.Maps;

public class IPPasswordMapView extends ViewPart {

	public static final String ID = "talkServer.IPPasswordMapView";

	public void createPartControl(Composite parent) {
		
		// LOAD DATA
//		Maps.loadIPPasswordMap();

		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("PASSWORD");
		tc2.setResizable(true);
		tc2.setWidth(350);

		fillData(mapTable);
	}

	private void fillData(Table mapTable) {
		Set dataSet = Maps.getIPPaswordMapData();
		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);
		}
	}

	public void setFocus() {
	}

	public void init(IViewSite site) throws PartInitException {
		// TODO Auto-generated method stub
		super.init(site);
		System.out.println("Init.");
	}
	
	
}