Search in sources :

Example 1 with GeneratorController

use of org.gephi.io.generator.api.GeneratorController in project gephi by gephi.

the class Generate method getMenuPresenter.

@Override
public JMenuItem getMenuPresenter() {
    JMenu menu = new JMenu(NbBundle.getMessage(Generate.class, "CTL_Generate"));
    final GeneratorController generatorController = Lookup.getDefault().lookup(GeneratorController.class);
    if (generatorController != null) {
        for (final Generator gen : generatorController.getGenerators()) {
            String menuName = gen.getName() + "...";
            JMenuItem menuItem = new JMenuItem(new AbstractAction(menuName) {

                @Override
                public void actionPerformed(ActionEvent e) {
                    generatorController.generate(gen);
                }
            });
            menu.add(menuItem);
        }
    }
    return menu;
}
Also used : ActionEvent(java.awt.event.ActionEvent) GeneratorController(org.gephi.io.generator.api.GeneratorController) JMenuItem(javax.swing.JMenuItem) AbstractAction(javax.swing.AbstractAction) JMenu(javax.swing.JMenu) Generator(org.gephi.io.generator.spi.Generator)

Aggregations

ActionEvent (java.awt.event.ActionEvent)1 AbstractAction (javax.swing.AbstractAction)1 JMenu (javax.swing.JMenu)1 JMenuItem (javax.swing.JMenuItem)1 GeneratorController (org.gephi.io.generator.api.GeneratorController)1 Generator (org.gephi.io.generator.spi.Generator)1