2.17.2: 2011-06-17

net.sf.basedb.util
Class ContextUtil

java.lang.Object
  extended by net.sf.basedb.util.ContextUtil

public class ContextUtil
extends Object

A class with utility methods for plug-ins.

Version:
2.4
Author:
Nicklas
Last modified
$Date: 2008-10-21 09:20:40 +0200 (Tue, 21 Oct 2008) $

Nested Class Summary
static class ContextUtil.ContextResult
          Class for holding the result of a call to the InteractivePlugin.isInContext(GuiContext, Object) method.
static class ContextUtil.IsInContextFilter
          Filter implementation that works on collections of ContextUtil.ContextResult:s and return only those that return true from ContextUtil.ContextResult.isInContext().
 
Constructor Summary
ContextUtil()
           
 
Method Summary
static List<ContextUtil.ContextResult> checkContext(DbControl dc, ItemQuery<PluginDefinition> pluginQuery, ItemQuery<PluginConfiguration> configQuery, GuiContext context, Object currentItem)
          Call the InteractivePlugin.isInContext(GuiContext, Object) method for all plug-ins returned by the queries.
static int countUsuablePlugins(Collection<ContextUtil.ContextResult> results)
          Count all plug-in / configuration combinations that can be used.
static Set<String> getContextMessages(Collection<ContextUtil.ContextResult> results, boolean includeMessage, boolean includeError)
          Get all messages from plug-in / configurations combinations that can't be used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextUtil

public ContextUtil()
Method Detail

checkContext

public static List<ContextUtil.ContextResult> checkContext(DbControl dc,
                                                           ItemQuery<PluginDefinition> pluginQuery,
                                                           ItemQuery<PluginConfiguration> configQuery,
                                                           GuiContext context,
                                                           Object currentItem)
Call the InteractivePlugin.isInContext(GuiContext, Object) method for all plug-ins returned by the queries.

Parameters:
dc - The DbControl to use for database access
pluginQuery - A query returning plugin definition items
configQuery - A query returning plugin configuration items. The query must have defined a parameter plugin which restricts the query to only return configurations for a particular plugin definition
context - The current context
currentItem - The current item, or null if used from a list context
Returns:
A list of ContextUtil.ContextResult objects

countUsuablePlugins

public static int countUsuablePlugins(Collection<ContextUtil.ContextResult> results)
Count all plug-in / configuration combinations that can be used.

Parameters:
results - A collection of ContextUtil.ContextResult objects
Returns:
The number of objects in the collection where ContextUtil.ContextResult.isInContext() returns true

getContextMessages

public static Set<String> getContextMessages(Collection<ContextUtil.ContextResult> results,
                                             boolean includeMessage,
                                             boolean includeError)
Get all messages from plug-in / configurations combinations that can't be used.

Parameters:
results - A collection of ContextUtil.ContextResult objects
includeMessage - If warning messages should be included or not
includeError - If error messages should be include or not
Returns:
A set containing the error / warning message

2.17.2: 2011-06-17