?? startthreadaction.java
字號:
/**
* StartThreadAction.java
*/
package talkServer;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import talkServer.business.ListeningThread;
/**
* @author Xiang Zhou
* @date 2006-4-29
*/
public class StartThreadAction extends Action {
private final IWorkbenchWindow window;
private final String viewId;
public StartThreadAction(IWorkbenchWindow window, String label,
String viewId) {
this.window = window;
this.viewId = viewId;
setText(label);
// The id is used to refer to the action in a menu or toolbar
setId(ICommandIds.CMD_START_THREAD);
// Associate the action with a pre-defined command, to allow key
// bindings.
setActionDefinitionId(ICommandIds.CMD_START_THREAD);
setImageDescriptor(talkServer.TalkServerPlugin
.getImageDescriptor("/icons/sample.gif"));
}
public void run() {
if (window != null) {
try {
window.getActivePage().showView(viewId, null,
IWorkbenchPage.VIEW_ACTIVATE);
// START LISTENING
startListening();
} catch (PartInitException e) {
MessageDialog.openError(window.getShell(), "Error",
"Error opening view:" + e.getMessage());
}
}
}
public void startListening() {
if (((ThreadView) window.getActivePage().findView(viewId)).listeningThread == null) {
ListeningThread listeningThread = new ListeningThread(((ThreadView) window.getActivePage().findView(viewId)).text);
// SET FOR REFERENCE
((ThreadView) window.getActivePage().findView(viewId)).listeningThread = listeningThread;
}
if (!((ThreadView) window.getActivePage().findView(viewId)).listeningThread
.isAlive())
((ThreadView) window.getActivePage().findView(viewId)).listeningThread
.start();
((ThreadView) window.getActivePage().findView(viewId)).text.setText("Server started.");
System.out.println("Listening start.");
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -