threadview.java

来自「一个基于eclipse插件开发的聊天程序」· Java 代码 · 共 60 行

JAVA
60
字号
package talkServer;

import java.io.IOException;

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.Text;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.ViewPart;

import talkServer.business.ListeningThread;

public class ThreadView extends ViewPart {

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

	public Text text;
	
	// THREAD HANDLER
	ListeningThread listeningThread;

	public ThreadView() {
		super();
	}

	public void createPartControl(Composite parent) {
		Composite top = new Composite(parent, SWT.NONE);
		top.setLayout(new GridLayout());
		GridData gridData = new GridData(GridData.FILL_HORIZONTAL
				| GridData.FILL_VERTICAL);
		text = new Text(top,SWT.MULTI | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL);
		text.setLayoutData(gridData);
	}

	public void setFocus() {
	}

	public void init(IViewSite site) throws PartInitException {
		super.init(site);
	}

	public void dispose() {
		super.dispose();
		// STOP THE THREAD
		listeningThread.stop();
		// CLOSE THE LISTENING SOCKET
		try {
			listeningThread.server_sock.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		// listeningThread.destroy();
		System.out.println("Listening end.");
	}

}

⌨️ 快捷键说明

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