playhandler.java

来自「eclise rcp 项目,是非常好的学习源码」· Java 代码 · 共 36 行

JAVA
36
字号
package com.siemens.ct.mp3m.ui.player.handlers;import java.io.FileNotFoundException;import org.eclipse.core.commands.AbstractHandler;import org.eclipse.core.commands.ExecutionEvent;import org.eclipse.core.commands.ExecutionException;import org.eclipse.jface.viewers.StructuredSelection;import org.eclipse.ui.handlers.HandlerUtil;import com.siemens.ct.mp3m.model.physical.Mp3File;import com.siemens.ct.mp3m.ui.player.Mp3Player;/** * A handler to play mp3 files. *  * @see org.eclipse.core.commands.IHandler * @see org.eclipse.core.commands.AbstractHandler */public class PlayHandler extends AbstractHandler {	public Object execute(ExecutionEvent event) throws ExecutionException {		StructuredSelection structuredSelection = (StructuredSelection) HandlerUtil				.getCurrentSelection(event);		if (structuredSelection.getFirstElement() instanceof Mp3File) {			Mp3File file = (Mp3File) structuredSelection.getFirstElement();			try {				Mp3Player.getInstance().play(file.getFullPath());			} catch (FileNotFoundException e) {				e.printStackTrace();			}		}		return null;	}}

⌨️ 快捷键说明

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