3

Hi I'm trying to add an export wizard, similar to the export wizard available in Eclipse to a standalone RCP Application. I put the following code in plugin.xml:

   <extension
     id="exportScript"
     point="org.eclipse.ui.exportWizards">
  <wizard
        class="com.myApplication.scriptGenerator.ExportWizard"
        id="com.myApplication.scriptGenerator.exid"
        name="Export as Script">
  </wizard>

But no wizard can be seen in the File menu entry.. What am I missing?

thanks :)

Protostome
  • 5,569
  • 5
  • 30
  • 45

4 Answers4

6

You have to do two things:

  • Use org.eclipse.ui.exportWizards extension point (which you already did)

  • In your Applications action bar advisor class first create the standard workbench action for export and then add it in any of your menu.

Code Snippet

// Creating and registering the action 
IWorkbenchAction export = ActionFactory.EXPORT.create(window);
register(export);

 // adding it to standard file menu
fileMenu.add(export);

>>Full Code - ApplicationActionBarAdvisor

package wiztest;

import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.ICoolBarManager;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

    private IWorkbenchAction exitAction;
    private IWorkbenchAction export;

    public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
        super(configurer);
    }

    protected void makeActions(final IWorkbenchWindow window) {

        exitAction = ActionFactory.QUIT.create(window);
        register(exitAction);


        export = ActionFactory.EXPORT.create(window);
        register(export);
    }

    protected void fillMenuBar(IMenuManager menuBar) {
        MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE);

        menuBar.add(fileMenu);
        menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
        fileMenu.add(export);
        fileMenu.add(exitAction);        
    }

    protected void fillCoolBar(ICoolBarManager coolBar) {

    }
}

>>Menu Entry

enter image description here

>>Export Wizard

enter image description here

Favonius
  • 13,959
  • 3
  • 55
  • 95
  • Hi, thanks for the reply :-) Unfortunately, I can't find the ApplicationActionBarAdvisor class. I suspect that the reason for it is that my RCP is actually (should have mentioned it earlier...) a GMF application. Do you have any idea what to do in this case? – Protostome May 03 '11 at 12:57
  • @Protostome: Look for a class extending `org.eclipse.ui.application.ActionBarAdvisor`. The `ApplicationActionBarAdvisor` I have mentioned is from my dummy application. – Favonius May 03 '11 at 13:10
1

You should implement in your Wizard this interface INewWizard, like:

public class LoadDataWizard extends Wizard implements INewWizard{}

and add this extension:

org.eclipse.ui.newWizards

to your plugin.xml

0

1.Create a menu

2.add a listener on the menu

Example :-

mntmExportProject.addSelectionListener(
new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ImportExportWizard wizard = new ImportExportWizard(ImportExportWizard.EXPORT);
            IStructuredSelection selectionToPass = new StructuredSelection(treeViewer.getSelection());

            wizard.init(PlatformUI.getWorkbench(), selectionToPass);
            IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();
            IDialogSettings wizardSettings = workbenchSettings.getSection("ImportExportAction"); //$NON-NLS-1$
            if (wizardSettings == null) {
                wizardSettings = workbenchSettings.addNewSection("ImportExportAction"); //$NON-NLS-1$
            }
            wizard.setDialogSettings(wizardSettings);
            wizard.setForcePreviousAndNextButtons(true);
            Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
            WizardDialog dialog = new WizardDialog(parent, wizard);
            dialog.create();
            dialog.getShell().setSize(Math.max(470, dialog.getShell().getSize().x), 550);
            dialog.open();
        }
    });
V Kash Singh
  • 469
  • 4
  • 4
0

() You have not specified the category of the File in your plugin.xml () If you are not seeing the File->New item itself, you need create them by the ActionFactory.NEW or ActionFactory.NEW_WIZARD_DROP_DOWN actions or by contributing them by commands

Prakash G. R.
  • 4,746
  • 1
  • 24
  • 35