点击一个eclipse上的按钮,就可以复制一段固定的字符串到剪贴板上,比较方便的黏贴各种需要的快捷命令,比如svn、mvn等等。

/**
* The action has been activated. The argument of the
* method represents the 'real' action sitting
* in the workbench UI.
* @see IWorkbenchWindowActionDelegate#run
*/
public void run(IAction action) {
Toolkit toolkit = Toolkit.getDefaultToolkit();
java.awt.datatransfer.Clipboard clipboard = toolkit.getSystemClipboard();
StringSelection stringSel = new StringSelection("mvn clean eclipse:clean eclipse:eclipse -U -DdownloadSources=true");
clipboard.setContents(stringSel, null);
}


上面是eclipse插件的主要添加内容,就是在run方法内增加复制指定的字符串,测试正确。