如何在 Eclipse 插件中的任何地方(即文件菜单和上下文菜单)禁用重命名选项?

发布于 2024-12-19 20:21:16 字数 461 浏览 0 评论 0原文

我正在开发一个插件,基本上是创建一个新项目,项目包含多个文件夹,并且该文件夹包含我们自己定制的编辑器。现在我不想允许用户从任何地方重命名项目。我可以在文件菜单、项目资源管理器的上下文菜单、包资源管理器的上下文菜单、导航器的上下文菜单中看到重命名选项。是否可以全局禁用/自定义重命名选项。我尝试使用全局操作处理程序进行重命名操作,这基本上是在重命名操作发生时做我自己的工作。但是,由于我想在插件激活器启动时阻止/禁用重命名选项,因此我可以在激活器类上获取活动视图站点,这似乎对我没有帮助,因为活动视图可能不是有时会出现上述观点。因此,我尝试通过 ltk 的 renameparticipant 扩展使用“重命名参与者”,并编写了自己的类来扩展 RenameParticipant,但即使我在plug-in.xml 文件中给出了正确的类名,该类也永远不会启动。

由于我们的产品是插件

,有人可以告诉我我应该如何进一步进行吗?我希望有人已经走上这条道路,在全球范围内阻止重命名选项。

I am developing a plug-in which is basically create a new project, project contains more than one folder, and the folder contains our own customized editors. Now I dont want to allow the user to rename of the project from anywhere. I can see the rename option in file menu, context menu of project explorer, context menu of package explorer, context menu of navigator. Is it possible to disable/customize the rename option globally. I have tried to use global action handler for rename action,which is basically doing my own job whenever the rename action occurs. But since I want to block/disable the rename option at the time plug-in activator get started, I am able get active view site on the activator class, which doesn't seems to help me because of the active view might be anyother than above mentioned view at sometimes. Hence I tried to using 'Rename Participant' through ltk's renameparticipant extension and I wrote my own class which extending RenameParticipant, but the class never get initiated even I have given the correct class name in plug-in.xml file.

Since our product is plug-in

Could anyone please advise me that how should I proceed further? I hope that someone has already walk on this path to block the rename option globally.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

兮子 2024-12-26 20:21:16

您可以指定自己的处理程序来进行全局重命名 (id="org.eclipse.ui.edit.rename") 和 Java 重命名元素 (id="org.eclipse.jdt.ui. edit.text.java.rename.element") 使用 处理程序 扩展点。但是,无法在 Package Explorer 中禁用上下文菜单项(重构 > 重命名...),因为它是硬编码的。

You can specify your own handler to global rename (id="org.eclipse.ui.edit.rename") and Java Rename element (id="org.eclipse.jdt.ui.edit.text.java.rename.element") commands using Handlers extension point. However, it is not possible to disable the context menu item (Refactor > Rename...) in Package Explorer because it is hard-coded.

半透明的墙 2024-12-26 20:21:16

我使用该类从上下文菜单中删除

public class MoveActionProvider extends RefactorActionProvider  {

    //@Override
    public void fillContextMenu(IMenuManager menu) {}   

}

并将其声明到plugin.xml中

<extension point="org.eclipse.ui.navigator.navigatorContent">
            <actionProvider
                    class="com.totvs.tds.ordinechaos.providers.action.MoveActionProvider"
                    id="com.totvs.tds.ordinechaos.providers.action.MoveActionExtension"
                    overrides="org.eclipse.ui.navigator.resources.actions.RefactorActions"
                    priority="highest">
                <enablement>
                <!-- A hack to allways be enabled -->
                    <not>
                        <systemTest
                                property="MyApp"
                                value="WONT-EVER-BE-SET">
                        </systemTest>
                    </not>
                </enablement>
            </actionProvider>
        </extension>

I removed from context menu using that class

public class MoveActionProvider extends RefactorActionProvider  {

    //@Override
    public void fillContextMenu(IMenuManager menu) {}   

}

and declaring this into the plugin.xml

<extension point="org.eclipse.ui.navigator.navigatorContent">
            <actionProvider
                    class="com.totvs.tds.ordinechaos.providers.action.MoveActionProvider"
                    id="com.totvs.tds.ordinechaos.providers.action.MoveActionExtension"
                    overrides="org.eclipse.ui.navigator.resources.actions.RefactorActions"
                    priority="highest">
                <enablement>
                <!-- A hack to allways be enabled -->
                    <not>
                        <systemTest
                                property="MyApp"
                                value="WONT-EVER-BE-SET">
                        </systemTest>
                    </not>
                </enablement>
            </actionProvider>
        </extension>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文