public static ActionCategory[] loadCategories(final SwingGuiContext swingGuiContext)
{
final ArrayList categories = new ArrayList();
final Configuration configuration = swingGuiContext.getConfiguration();
final Iterator keys = configuration.findPropertyKeys(CATEGORY_PREFIX);
while (keys.hasNext())
{
final String enableKey = (String) keys.next();
if (enableKey.endsWith(".enabled") == false) //$NON-NLS-1$
{
continue;
}
if ("true".equals(configuration.getConfigProperty(enableKey)) == false) //$NON-NLS-1$
{
continue;
}
final String base = enableKey.substring(0, enableKey.length() - ".enabled".length()); //$NON-NLS-1$
if (base.length() == 0)
{
continue;
}
final String categoryKey = base.substring(CATEGORY_PREFIX.length());
final String className = configuration.getConfigProperty(base + ".class"); //$NON-NLS-1$
ActionCategory actionCategory;
if (className == null)
{
actionCategory = new ActionCategory();
}
else
{
actionCategory = (ActionCategory) ObjectUtilities.loadAndInstantiate
(className, PreviewPane.class, ActionCategory.class);
if (actionCategory == null)
{
actionCategory = new ActionCategory();
}
}
final String positionText = configuration.getConfigProperty(base + ".position"); //$NON-NLS-1$
actionCategory.setPosition(StringUtil.parseInt(positionText, 0));
actionCategory.setName(categoryKey);
actionCategory.setResourceBase(configuration.getConfigProperty(base + ".resource-base")); //$NON-NLS-1$
actionCategory.setResourcePrefix(configuration.getConfigProperty(base + ".resource-prefix")); //$NON-NLS-1$
actionCategory.initialize(swingGuiContext);
categories.add(actionCategory);
}
return (ActionCategory[]) categories.toArray