Search in sources :

Example 1 with LoggingSectionHandler

use of org.eclipse.titan.common.parsers.cfg.indices.LoggingSectionHandler in project titan.EclipsePlug-ins by eclipse.

the class LoggingTreeSubPage method addPluginToList.

/**
 * Adds a new logging plugin to the list of logging plugins available
 * for a given component. If necessary also creates the list of logging
 * plugins.
 *
 * @param componentName
 *                the name of the component to add the plugin to.
 * @param pluginName
 *                the name of the plugin to add
 * @param path
 *                the path of the plugin to add, or null if none.
 */
private void addPluginToList(final String componentName, final String pluginName, final String path) {
    if (loggingSectionHandler == null) {
        return;
    }
    final StringBuilder pluginBuilder = new StringBuilder();
    pluginBuilder.append(pluginName);
    if (path != null && path.length() != 0) {
        pluginBuilder.append(" := \"").append(path).append('\"');
    }
    /*
		 *   loggingSectionHandler.getLastSectionRoot()
		 *     entry.getLoggerPluginsRoot()
		 *       entry.getLoggerPluginsListRoot()
		 *         {
		 *           pluginEntry.getLoggerPluginRoot()
		 *         }
		 */
    LoggingSectionHandler.LoggerPluginsEntry entry = loggingSectionHandler.getLoggerPluginsTree().get(componentName);
    if (entry == null) {
        entry = new LoggingSectionHandler.LoggerPluginsEntry();
        loggingSectionHandler.getLoggerPluginsTree().put(componentName, entry);
        final ParseTree loggerPluginsRoot = new ParserRuleContext();
        ConfigTreeNodeUtilities.addChild(loggingSectionHandler.getLastSectionRoot(), loggerPluginsRoot);
        entry.setLoggerPluginsRoot(loggerPluginsRoot);
        final StringBuilder builder = new StringBuilder();
        builder.append('\n').append(componentName).append(".LoggerPlugins := ");
        ConfigTreeNodeUtilities.addChild(loggerPluginsRoot, new AddedParseTree(builder.toString()));
        ConfigTreeNodeUtilities.addChild(loggerPluginsRoot, new AddedParseTree("{"));
        final ParseTree loggerPluginsListRoot = new ParserRuleContext();
        entry.setLoggerPluginsListRoot(loggerPluginsListRoot);
        final LoggingSectionHandler.LoggerPluginEntry pluginEntry = new LoggingSectionHandler.LoggerPluginEntry();
        final ParseTree pluginRoot = new ParserRuleContext();
        pluginEntry.setLoggerPluginRoot(pluginRoot);
        pluginEntry.setName(pluginName);
        pluginEntry.setPath(path);
        ConfigTreeNodeUtilities.addChild(pluginRoot, new AddedParseTree(pluginBuilder.toString()));
        entry.setPluginRoots(new HashMap<String, LoggingSectionHandler.LoggerPluginEntry>(1));
        entry.getPluginRoots().put(pluginName, pluginEntry);
        ConfigTreeNodeUtilities.addChild(loggerPluginsListRoot, pluginRoot);
        ConfigTreeNodeUtilities.addChild(loggerPluginsRoot, loggerPluginsListRoot);
        ConfigTreeNodeUtilities.addChild(loggerPluginsRoot, new AddedParseTree("}"));
        return;
    }
    final int childCount = entry.getLoggerPluginsListRoot().getChildCount();
    ConfigTreeNodeUtilities.addChild(entry.getLoggerPluginsListRoot(), new AddedParseTree((childCount > 0 ? ", " : "") + pluginBuilder.toString()));
}
Also used : ParserRuleContext(org.antlr.v4.runtime.ParserRuleContext) LoggingSectionHandler(org.eclipse.titan.common.parsers.cfg.indices.LoggingSectionHandler) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Aggregations

ParserRuleContext (org.antlr.v4.runtime.ParserRuleContext)1 ParseTree (org.antlr.v4.runtime.tree.ParseTree)1 AddedParseTree (org.eclipse.titan.common.parsers.AddedParseTree)1 LoggingSectionHandler (org.eclipse.titan.common.parsers.cfg.indices.LoggingSectionHandler)1