[英]How can I open the terminal and run shell commands in custom eclipse plugin like cp or mv?
I am new to eclipse development. 我是蚀开发的新手。 Trying to create a plugin which will copy files from one directory to another.
尝试创建一个将文件从一个目录复制到另一个目录的插件。 Introduced the menu as follows
菜单介绍如下
Now on click of the Copy Files menu I want to copy file/s. 现在,单击“复制文件”菜单,我要复制文件。 For that I want to run the command
为此,我想运行命令
cp file1.txt ../dir/file1.txt
I have handler as follows which will be executed once I click on menu. 我有以下处理程序,单击菜单后将执行以下处理程序。
public class SampleHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
return null;
}
}
How can I run the above command in my handler.execute()
method to copy the files? 如何在我的
handler.execute()
方法中运行以上命令来复制文件?
Consider reading and writing the files in your own code. 考虑用您自己的代码读写文件。 Relying on external shell applications is not portable.
依靠外部外壳应用程序是不可移植的。
PlatformUI
is the starting point to get the IWorkspace
instance and get the source and target IFiles
for your reading and writing. PlatformUI
为出发点,以获得IWorkspace
实例并获得源和目标IFiles
您的阅读和写作。 Use a combination of IFile#getContents()
, IFile#create()
, and IFile#setContents()
to handle the actual I/O. 使用
IFile#getContents()
, IFile#create()
和IFile#setContents()
来处理实际的I / O。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.