[英]Changing pop-ups dynamically in eclipse plugin
I have a plugin where for a particular type of file i will enable some options to perform. 我有一个插件,对于特定类型的文件,我将启用一些选项。 so now i have requirement where i need to decide the type of a file dynamically and apply a particular options for that type of file. 因此,现在我有了要求,我需要动态地决定文件的类型并为该文件类型应用特定的选项。
Is it possible to do that? 有可能这样做吗? if yes, need some help about the same. 如果是,则需要同样的帮助。
Thanks. 谢谢。
So I guess you want to show the context menu for something that represents a file in a view. 因此,我想您想为表示视图中文件的内容显示上下文菜单。 Determine the file type based on custom rules (file extension is the easiest rule, looking inside the file the most complex) and create the popup or distribute content to an existing one. 根据自定义规则确定文件类型(文件扩展名是最简单的规则,在文件内部查找最复杂的规则),然后创建弹出窗口或将内容分发到现有的弹出窗口中。
If it's your own view, maybe a list or tree that shows a folder structure, then you have to register the Viewer as a SelectionProvider, listen to selection events, evaluate the selection (maybe a String or a File object) and create the popup menu. 如果是您自己的视图,可能是显示文件夹结构的列表或树,则必须将查看器注册为SelectionProvider,侦听选择事件,评估选择(可能是String或File对象)并创建弹出菜单。
Contributing actions to existing popup menus (like the navigator view context menus) is possible as well but a bit more challenging. 也可以向现有的弹出菜单(例如导航器视图上下文菜单)进行操作,但是更具挑战性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.