public ModuleEditor getModule(Module module,
HierarchicalConfiguration config,
ConfigDescriptionEntry[] keyNames) {
if (module == null)
{
throw new NullPointerException(EditorFactory.messages.getErrorString("EditorFactory.ERROR_0002_MODULE_IS_NULL")); //$NON-NLS-1$
}
if (config == null)
{
throw new NullPointerException(EditorFactory.messages.getErrorString("EditorFactory.ERROR_0003_CONFIG_IS_NULL")); //$NON-NLS-1$
}
if (keyNames == null)
{
throw new NullPointerException(EditorFactory.messages.getErrorString("EditorFactory.ERROR_0004_KEYNAMES_IS_NULL")); //$NON-NLS-1$
}
final Iterator keys = priorities.keySet().iterator();
ModuleEditor currentEditor = null;
int currentEditorPriority = Integer.MIN_VALUE;
while (keys.hasNext())
{
final ModuleEditor ed = (ModuleEditor) keys.next();
if (ed.canHandle(module))
{
final Integer prio = (Integer) priorities.get(ed);
if (prio.intValue() > currentEditorPriority)
{
currentEditorPriority = prio.intValue();
currentEditor = ed;
}
}
}
if (currentEditor != null)
{
return currentEditor.createInstance(module, config, keyNames);
}
return null;
}
Returns the module editor that will be most suitable for editing the given module. |