Search in sources :

Example 6 with IPlugin

use of com.google.security.zynamics.binnavi.api2.plugins.IPlugin 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 7 with IPlugin

use of com.google.security.zynamics.binnavi.api2.plugins.IPlugin 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)

Example 8 with IPlugin

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

the class CCriteriaFactory method getConditions.

/**
   * Returns all available criterium creators.
   *
   * @return All available criterium creators.
   */
public List<ICriteriumCreator> getConditions() {
    final List<ICriteriumCreator> conditions = new ArrayList<ICriteriumCreator>();
    conditions.add(new CTextCriteriumCreator());
    conditions.add(new CTagCriteriumCreator(m_tagManager));
    conditions.add(new CColorCriteriumCreator(m_graph));
    conditions.add(new CIndegreeCriteriumCreator());
    conditions.add(new COutdegreeCriteriumCreator());
    conditions.add(new CVisibilityCriteriumCreator());
    conditions.add(new CSelectionCriteriumCreator());
    for (@SuppressWarnings("rawtypes") final IPlugin plugin : PluginInterface.instance().getPluginRegistry()) {
        if (plugin instanceof ICriteriaSelectionPlugin) {
            final ICriteriaSelectionPlugin cplugin = (ICriteriaSelectionPlugin) plugin;
            conditions.add(new CPluginCriteriumCreator(m_view2D, cplugin));
        }
    }
    return conditions;
}
Also used : CVisibilityCriteriumCreator(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Visibillity.CVisibilityCriteriumCreator) ICriteriaSelectionPlugin(com.google.security.zynamics.binnavi.API.plugins.ICriteriaSelectionPlugin) ArrayList(java.util.ArrayList) CTextCriteriumCreator(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Text.CTextCriteriumCreator) IPlugin(com.google.security.zynamics.binnavi.api2.plugins.IPlugin) COutdegreeCriteriumCreator(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.OutDegree.COutdegreeCriteriumCreator) CIndegreeCriteriumCreator(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.InDegrees.CIndegreeCriteriumCreator) CSelectionCriteriumCreator(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Selection.CSelectionCriteriumCreator) CColorCriteriumCreator(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.NodeColor.CColorCriteriumCreator) ICriteriumCreator(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.ICriteriumCreator) CTagCriteriumCreator(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Tag.CTagCriteriumCreator)

Example 9 with IPlugin

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

the class CProjectNodeMenuBuilder 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<IProjectMenuPlugin> plugins = new ArrayList<IProjectMenuPlugin>();
    for (@SuppressWarnings("rawtypes") final IPlugin plugin : PluginInterface.instance().getPluginRegistry()) {
        if (plugin instanceof IProjectMenuPlugin) {
            plugins.add((IProjectMenuPlugin) plugin);
        }
    }
    if (!plugins.isEmpty()) {
        boolean addedSeparator = false;
        for (final IProjectMenuPlugin plugin : plugins) {
            try {
                final List<JComponent> menuItems = plugin.extendProjectMenu(getPluginProjects());
                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 = "E00088: " + "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 : ArrayList(java.util.ArrayList) JComponent(javax.swing.JComponent) IProjectMenuPlugin(com.google.security.zynamics.binnavi.API.plugins.IProjectMenuPlugin) JSeparator(javax.swing.JSeparator) IPlugin(com.google.security.zynamics.binnavi.api2.plugins.IPlugin)

Example 10 with IPlugin

use of com.google.security.zynamics.binnavi.api2.plugins.IPlugin 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)

Aggregations

IPlugin (com.google.security.zynamics.binnavi.api2.plugins.IPlugin)7 ArrayList (java.util.ArrayList)6 IPluginInterface (com.google.security.zynamics.binnavi.api2.IPluginInterface)4 JComponent (javax.swing.JComponent)3 JSeparator (javax.swing.JSeparator)3 IGraphMenuPlugin (com.google.security.zynamics.binnavi.API.plugins.IGraphMenuPlugin)2 CActionOpenLogConsole (com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Actions.CActionOpenLogConsole)2 JMenuItem (javax.swing.JMenuItem)2 ICriteriaSelectionPlugin (com.google.security.zynamics.binnavi.API.plugins.ICriteriaSelectionPlugin)1 IMainWindowMenuPlugin (com.google.security.zynamics.binnavi.API.plugins.IMainWindowMenuPlugin)1 IModuleMenuPlugin (com.google.security.zynamics.binnavi.API.plugins.IModuleMenuPlugin)1 IProjectFolderMenuPlugin (com.google.security.zynamics.binnavi.API.plugins.IProjectFolderMenuPlugin)1 IProjectMenuPlugin (com.google.security.zynamics.binnavi.API.plugins.IProjectMenuPlugin)1 ICriteriumCreator (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.ICriteriumCreator)1 CIndegreeCriteriumCreator (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.InDegrees.CIndegreeCriteriumCreator)1 CColorCriteriumCreator (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.NodeColor.CColorCriteriumCreator)1 COutdegreeCriteriumCreator (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.OutDegree.COutdegreeCriteriumCreator)1 CSelectionCriteriumCreator (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Selection.CSelectionCriteriumCreator)1 CTagCriteriumCreator (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Tag.CTagCriteriumCreator)1 CTextCriteriumCreator (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Text.CTextCriteriumCreator)1