Package net.sf.basedb.util
Class ContextUtil
java.lang.Object
net.sf.basedb.util.ContextUtil
A class with utility methods for plug-ins.
- Version:
- 2.4
- Author:
- Nicklas
- Last modified
- $Date: 2013-12-06 11:52:11 +0100 (fr, 06 dec 2013) $
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Class for holding the result of a call to theInteractivePlugin.isInContext(GuiContext, Object)
method.static class
Filter implementation that works on collections ofContextUtil.ContextResult
:s and return only those that return true fromContextUtil.ContextResult.isInContext()
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<ContextUtil.ContextResult>
checkContext
(DbControl dc, ItemQuery<PluginDefinition> pluginQuery, ItemQuery<PluginConfiguration> configQuery, GuiContext context, Object currentItem) Call theInteractivePlugin.isInContext(GuiContext, Object)
method for all plug-ins returned by the queries.static int
Count all plug-in / configuration combinations that can be used.getContextMessages
(Collection<ContextUtil.ContextResult> results, boolean includeMessage, boolean includeError) Get all messages from plug-in / configurations combinations that can't be used.
-
Constructor Details
-
ContextUtil
public ContextUtil()
-
-
Method Details
-
checkContext
public static List<ContextUtil.ContextResult> checkContext(DbControl dc, ItemQuery<PluginDefinition> pluginQuery, ItemQuery<PluginConfiguration> configQuery, GuiContext context, Object currentItem) Call theInteractivePlugin.isInContext(GuiContext, Object)
method for all plug-ins returned by the queries.- Parameters:
dc
- The DbControl to use for database accesspluginQuery
- A query returning plugin definition itemsconfigQuery
- A query returning plugin configuration items. The query must have defined a parameterplugin
which restricts the query to only return configurations for a particular plugin definitioncontext
- The current contextcurrentItem
- The current item, or null if used from a list context- Returns:
- A list of
ContextUtil.ContextResult
objects
-
countUsuablePlugins
Count all plug-in / configuration combinations that can be used.- Parameters:
results
- A collection ofContextUtil.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 ofContextUtil.ContextResult
objectsincludeMessage
- If warning messages should be included or notincludeError
- If error messages should be include or not- Returns:
- A set containing the error / warning message
-