Search in sources :

Example 1 with IPluginInterface

use of com.google.security.zynamics.binnavi.api2.IPluginInterface in project binnavi by google.

the class CModuleNodeMenuBuilder method addPluginMenus.

/**
   * Adds the plugin-generated menus to the context menu.
   *
   * @param menu The context menu where the menu items are added.
   */
private void addPluginMenus(final JComponent menu) {
    final List<IModuleMenuPlugin> plugins = new ArrayList<>();
    for (final IPlugin<IPluginInterface> plugin : PluginInterface.instance().getPluginRegistry()) {
        if (plugin instanceof IModuleMenuPlugin) {
            plugins.add((IModuleMenuPlugin) plugin);
        }
    }
    boolean addedSeparator = false;
    for (final IModuleMenuPlugin plugin : plugins) {
        try {
            final List<JComponent> menuItems = plugin.extendModuleMenu(getPluginModules());
            if (menuItems != null) {
                for (final JComponent menuItem : menuItems) {
                    if (!addedSeparator) {
                        menu.add(new JSeparator());
                        addedSeparator = true;
                    }
                    menu.add(menuItem);
                }
            }
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
            final String innerMessage = "E00093: " + "Plugin caused an unexpected exception";
            final String innerDescription = CUtilityFunctions.createDescription(String.format("The plugin %s caused an unexpected exception.", plugin.getName()), new String[] { "The plugin contains a bug." }, new String[] { "The plugin probably behaves erroneously from this point on but it remains active" });
            NaviErrorDialog.show(getParent(), innerMessage, innerDescription, exception);
        }
    }
}
Also used : IPluginInterface(com.google.security.zynamics.binnavi.api2.IPluginInterface) IModuleMenuPlugin(com.google.security.zynamics.binnavi.API.plugins.IModuleMenuPlugin) ArrayList(java.util.ArrayList) JComponent(javax.swing.JComponent) JSeparator(javax.swing.JSeparator)

Example 2 with IPluginInterface

use of com.google.security.zynamics.binnavi.api2.IPluginInterface in project binnavi by google.

the class CGraphWindowMenuBar method dipose.

/**
   * Frees allocated resources.
   */
public void dipose() {
    m_synchronizer.dispose();
    m_selectionMenu.dispose();
    final List<IGraphMenuPlugin> plugins = Lists.newArrayList();
    for (final IPlugin<IPluginInterface> plugin : PluginInterface.instance().getPluginRegistry()) {
        if (plugin instanceof IGraphMenuPlugin) {
            plugins.add((IGraphMenuPlugin) plugin);
        }
    }
    for (final IGraphMenuPlugin plugin : plugins) {
        try {
            plugin.closed(m_model.getGraphFrame());
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
            final String innerMessage = "E00106: " + "Plugin caused an unexpected exception";
            final String innerDescription = CUtilityFunctions.createDescription(String.format("The plugin %s caused an unexpected exception.", plugin.getName()), new String[] { "The plugin contains a bug." }, new String[] { "The plugin probably behaves erroneously from this point on but it remains active" });
            NaviErrorDialog.show(m_model.getParent(), innerMessage, innerDescription, exception);
        }
    }
    m_pluginsMenu.dispose();
}
Also used : IPluginInterface(com.google.security.zynamics.binnavi.api2.IPluginInterface) IGraphMenuPlugin(com.google.security.zynamics.binnavi.API.plugins.IGraphMenuPlugin)

Example 3 with IPluginInterface

use of com.google.security.zynamics.binnavi.api2.IPluginInterface in project binnavi by google.

the class CProjectContainerNodeMenuBuilder method createMenu.

@Override
protected void createMenu(final JComponent menu) {
    menu.add(new JMenuItem(CActionProxy.proxy(new CCreateProjectAction(getParent(), database, new CNodeSelectionUpdater(getProjectTree(), findNode())))));
    final List<IProjectFolderMenuPlugin> plugins = new ArrayList<IProjectFolderMenuPlugin>();
    for (final IPlugin<IPluginInterface> plugin : PluginInterface.instance().getPluginRegistry()) {
        if (plugin instanceof IProjectFolderMenuPlugin) {
            plugins.add((IProjectFolderMenuPlugin) plugin);
        }
    }
    if (!plugins.isEmpty()) {
        menu.add(new JSeparator());
        for (final IProjectFolderMenuPlugin plugin : plugins) {
            try {
                final List<JComponent> menuItems = plugin.extendProjectFolderMenu(getPluginDatabase());
                if (menuItems != null) {
                    for (final JComponent menuItem : menuItems) {
                        menu.add(menuItem);
                    }
                }
            } catch (final Exception exception) {
                CUtilityFunctions.logException(exception);
                final String innerMessage = "E00089: " + "Plugin caused an unexpected exception";
                final String innerDescription = CUtilityFunctions.createDescription(String.format("The plugin %s caused an unexpected exception.", plugin.getName()), new String[] { "The plugin contains a bug." }, new String[] { "The plugin probably behaves erroneously from this point on but it remains active" });
                NaviErrorDialog.show(getParent(), innerMessage, innerDescription, exception);
            }
        }
    }
}
Also used : IPluginInterface(com.google.security.zynamics.binnavi.api2.IPluginInterface) ArrayList(java.util.ArrayList) JComponent(javax.swing.JComponent) CCreateProjectAction(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Actions.CCreateProjectAction) JSeparator(javax.swing.JSeparator) IProjectFolderMenuPlugin(com.google.security.zynamics.binnavi.API.plugins.IProjectFolderMenuPlugin) CNodeSelectionUpdater(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Updaters.CNodeSelectionUpdater) JMenuItem(javax.swing.JMenuItem)

Example 4 with IPluginInterface

use of com.google.security.zynamics.binnavi.api2.IPluginInterface in project binnavi by google.

the class PluginLoader method getPlugins.

@Override
public Collection<IPlugin<IPluginInterface>> getPlugins() {
    final List<IPlugin<IPluginInterface>> plugins = Lists.newArrayList();
    plugins.add(new PathfinderPlugin());
    plugins.add(new CallResolverPlugin());
    plugins.add(new LoopSelectionCriteriumPlugin());
    plugins.add(new VisualCoveragePlugin());
    // Plugins below this line are not supposed to be shipped.
    return plugins;
}
Also used : LoopSelectionCriteriumPlugin(com.google.security.zynamics.binnavi.standardplugins.criterium.LoopSelectionCriteriumPlugin) PathfinderPlugin(com.google.security.zynamics.binnavi.standardplugins.pathfinder.PathfinderPlugin) VisualCoveragePlugin(com.google.security.zynamics.binnavi.standardplugins.coverage.VisualCoveragePlugin) CallResolverPlugin(com.google.security.zynamics.binnavi.standardplugins.callresolver.CallResolverPlugin) IPlugin(com.google.security.zynamics.binnavi.api2.plugins.IPlugin)

Example 5 with IPluginInterface

use of com.google.security.zynamics.binnavi.api2.IPluginInterface in project binnavi by google.

the class PluginInterface method reloadPlugins.

/**
   * Reloads all plugins.
   */
public void reloadPlugins() {
    registry.getNative().unloadAll();
    NaviLogger.info("Loading built-in plugins...");
    final Collection<IPlugin<IPluginInterface>> plugins = new PluginLoader().getPlugins();
    for (final IPlugin<IPluginInterface> plugin : plugins) {
        registry.addPlugin(plugin);
    }
    CPluginLoader.loadPlugins(mainWindow.getFrame(), this, registry.getNative(), startPath, ConfigManager.instance());
    for (final IPluginInterfaceListener listener : listeners) {
        try {
            listener.loadedPlugins();
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
}
Also used : IPluginInterface(com.google.security.zynamics.binnavi.api2.IPluginInterface) PluginLoader(com.google.security.zynamics.binnavi.standardplugins.PluginLoader) CPluginLoader(com.google.security.zynamics.binnavi.Startup.CPluginLoader) IPlugin(com.google.security.zynamics.binnavi.api2.plugins.IPlugin)

Aggregations

IPluginInterface (com.google.security.zynamics.binnavi.api2.IPluginInterface)4 IPlugin (com.google.security.zynamics.binnavi.api2.plugins.IPlugin)2 ArrayList (java.util.ArrayList)2 JComponent (javax.swing.JComponent)2 JSeparator (javax.swing.JSeparator)2 IGraphMenuPlugin (com.google.security.zynamics.binnavi.API.plugins.IGraphMenuPlugin)1 IModuleMenuPlugin (com.google.security.zynamics.binnavi.API.plugins.IModuleMenuPlugin)1 IProjectFolderMenuPlugin (com.google.security.zynamics.binnavi.API.plugins.IProjectFolderMenuPlugin)1 CCreateProjectAction (com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Actions.CCreateProjectAction)1 CNodeSelectionUpdater (com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Updaters.CNodeSelectionUpdater)1 CPluginLoader (com.google.security.zynamics.binnavi.Startup.CPluginLoader)1 PluginLoader (com.google.security.zynamics.binnavi.standardplugins.PluginLoader)1 CallResolverPlugin (com.google.security.zynamics.binnavi.standardplugins.callresolver.CallResolverPlugin)1 VisualCoveragePlugin (com.google.security.zynamics.binnavi.standardplugins.coverage.VisualCoveragePlugin)1 LoopSelectionCriteriumPlugin (com.google.security.zynamics.binnavi.standardplugins.criterium.LoopSelectionCriteriumPlugin)1 PathfinderPlugin (com.google.security.zynamics.binnavi.standardplugins.pathfinder.PathfinderPlugin)1 JMenuItem (javax.swing.JMenuItem)1