Add Export Wizard to outshine RCP stand-alone application

Hi I am trying to add an export wizard similar to the export wizard available in Eclipse to a standalone RCP application. I paste the following code into the plugin.xml file:

   <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 master can be seen in the File menu entry. What am I missing?

thank:)

+3
source share
4 answers

You need to do two things:

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

               

  • In your application, the action bar advisorclass will first create a standard workbench action for export, and then add it to any of your menus.

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) {

    }
}

β†’ Enter menu

enter image description here

β†’ Export Wizard

enter image description here

+6
source

Wizard INewWizard, :

LoadDataWizard extends INewWizard {}

:

org.eclipse.ui.newWizards

plugin.xml

+1

() You did not specify the file category in your plugin.xml file () If you do not see the File-> New file yourself, you need to create them using the ActionsFactory.NEW or ActionFactory.NEW_WIZARD_DROP_DOWN actions or by adding them to the command with the commands

0
source

1.Create a menu

2.add menu listener

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();
        }
    });
0
source

All Articles