Search code examples
javaeclipseeclipse-pluginrcp

Enable or disable File->New popup menu based on perspective change


I have created a extension point newWizard and there I have added wizards (Let's say wizard1, wizard2, wizard3). I have created a perspective i.e perspectiv1. and When I create a plugin project all the wizard labels are added in File->New pop up menu right click of the created project. But the issue is if I am changing the perspective to java, then all the wizard labels are showing in my File->New pop up menu right click of the created project.

Can anyone please suggest how to handle the scenario above. I want to restrict those wizard labels to be visible only when I select my own created perspective i.e perspectiv1.

Thank You


Solution

  • I got the solution for the problem. The issue was I was adding all the created wizards in the navigator content to show those in navigator but it was making active in all the perspectives. I have solved it following below steps:

    Step1: First I have removed the commonWizrad option from org.eclipse.ui.navigator.navigatorContent in extensions

    Step2: Added popup:org.eclipse.ui.navigator.ProjectExplorer In the locationURI set the value "popup:org.eclipse.ui.navigator.ProjectExplorer#PopupMenu?after=additions"

    Step 3: Added "menuContribution" on right click of the project explorer extension and in the locationURI set the value "popup:common.new.menu?after=new"

    Step 4: Added "command" on the right click of menuContribution and set commandID ="popup:common.new.menu?after=new"

    Step 5: Right click on the "command" added "parameter" and set the name and value as I have created for the wizard

    Step 6: Right click on the "command" added "visibleWhen", set false This value will be active based on the your perspective. So in the variable set the active woorkbench perspective equals to the perspective you want.

    Thank you