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

📄 modulebaseterminal.java

📁 一个非常好的ssh客户端实现
💻 JAVA
字号:
/****************************************************************************** * * Copyright (c) 1999-2003 AppGate Network Security AB. All Rights Reserved. *  * This file contains Original Code and/or Modifications of Original Code as * defined in and that are subject to the MindTerm Public Source License, * Version 2.0, (the 'License'). You may not use this file except in compliance * with the License. *  * You should have received a copy of the MindTerm Public Source License * along with this software; see the file LICENSE.  If not, write to * AppGate Network Security AB, Otterhallegatan 2, SE-41118 Goteborg, SWEDEN * *****************************************************************************/package com.mindbright.application;import java.util.Vector;import java.util.Enumeration;import java.awt.Frame;import java.awt.BorderLayout;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import com.mindbright.terminal.TerminalWin;import com.mindbright.terminal.TerminalXTerm;import com.mindbright.terminal.TerminalFrameTitle;import com.mindbright.terminal.TerminalMenuHandler;import com.mindbright.terminal.TerminalMenuListener;import com.mindbright.terminal.GlobalClipboard;import com.mindbright.gui.AWTConvenience;public abstract class ModuleBaseTerminal extends WindowAdapter    implements MindTermModule, Runnable, TerminalMenuListener{    protected MindTermApp mindterm;    protected Thread      myThread;    private Vector instances;    public void init(MindTermApp mindterm) {	this.mindterm = mindterm;    }    protected boolean haveMenus() {	return Boolean.valueOf(mindterm.getProperty("havemenus")).	    booleanValue();    }    protected boolean useChaff() {	return Boolean.valueOf(mindterm.getProperty("key-timing-noise")).	    booleanValue();    }    public void activate(MindTermApp mindterm) {	if(instances == null) {	    instances = new Vector();	}	ModuleBaseTerminal bt = newInstance();	instances.addElement(bt);	bt.init(mindterm);	bt.myThread = new Thread(bt, "Terminal_" + this.getClass());	bt.myThread.start();    }    public void run() {	Frame       frame    = (haveMenus() ?				AWTConvenience.newFrameWithMenuBar() :				new Frame());	TerminalWin terminal = new TerminalWin(frame, new TerminalXTerm(),					       mindterm.getProperties());	mindterm.getRandomSeed().addEntropyGenerator(terminal);	frame.setLayout(new BorderLayout());	frame.add(terminal.getPanelWithScrollbar(), BorderLayout.CENTER);	TerminalFrameTitle frameTitle =	    new TerminalFrameTitle(frame, getTitle());	frameTitle.attach(terminal);	TerminalMenuHandler tmenus = null;	if(haveMenus()) {	    try {		tmenus = (TerminalMenuHandler) Class.forName(	     "com.mindbright.terminal.TerminalMenuHandlerFull").newInstance();		tmenus.setTitleName(mindterm.getAppName());		tmenus.addBasicMenus(terminal, frame);		tmenus.setTerminalMenuListener(this);	    } catch (Throwable t) {		/* no menus... */	    }	} else {	    terminal.setClipboard(GlobalClipboard.getClipboardHandler());	}	frame.addWindowListener(this);	frame.pack();	frame.show();	try {	    runTerminal(mindterm, terminal, frame, frameTitle);	} finally {	    frame.dispose();	    if(haveMenus() && tmenus != null) {		GlobalClipboard.getClipboardHandler().removeMenuHandler(tmenus);	    }	}    }    public void connected(MindTermApp mindterm) {    }    public void disconnected(MindTermApp mindterm) {	if(instances != null) {	    Enumeration e = instances.elements();	    while(e.hasMoreElements()) {		ModuleBaseTerminal bt = (ModuleBaseTerminal)e.nextElement();		if(bt.closeOnDisconnect()) {		    bt.doClose();		    instances.removeElement(bt);		}	    }	}    }    public String description(MindTermApp mindterm) {	return null;    }    public void windowClosing(WindowEvent e) {	doClose();    }    public void close(TerminalMenuHandler originMenu) {	doClose();    }    public void update() {    }    protected abstract void runTerminal(MindTermApp mindterm,					TerminalWin terminal, Frame frame,					TerminalFrameTitle frameTitle);    protected abstract boolean closeOnDisconnect();    protected abstract String getTitle();    protected abstract void doClose();    protected abstract ModuleBaseTerminal newInstance();}

⌨️ 快捷键说明

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