views:

9

answers:

1

Actions in the Run menu such as Toggle Break Point, Toggle Line Break Point etc.. will be enabled when a .java file is opened and will be disabled for any other type of files. similarly the step over, step into etc will be enabled when we are debugging a java program and will be disabled otherwise.

So i wanted to know how enabling and disabling of these actions are being controlled.

thanks.

+1  A: 

This is possible via plugin.xml. When you add a command to a menu or toolbar you can add a visibleWhen element. This allows you to define constraints when the corresponding commands will be shown.

An example we use in our application is that certain icons in the toolbar should only be visible when a particular editor is open and focused. We achieve this with (of course you can use the editor on the Extensions tab; the XML is better suited here):

<visibleWhen checkEnabled="true">
    <with variable="activeEditorId">
        <equals value="our.editor.id">
        </equals>
    </with>
</visibleWhen>

There is an overview over the possible variable names in the Eclipse wiki.

musiKk