简体   繁体   中英

How to disable the rename option from everywhere (i.e, from file menu & context menu) in eclipse plugin?

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.

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.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM