/**
* Initializes all component for the module editor and creates and layouts all keyeditors.
*/
protected void build()
{
final StringWriter writer = new StringWriter();
writer.write("<html><head><title></title></head><body>"); //$NON-NLS-1$
final JTextArea mangleInfo = new JTextArea();
mangleInfo.setText(messages.getString("DefaultModuleEditor.USER_GUIDE", modulePackage)); //$NON-NLS-1$
mangleInfo.setName("DescriptionArea"); //$NON-NLS-1$
mangleInfo.setMinimumSize(new Dimension(100, 10));
mangleInfo.setEditable(false);
mangleInfo.setLineWrap(true);
mangleInfo.setWrapStyleWord(true);
mangleInfo.setOpaque(false);
contentpane.add(mangleInfo);
final ConfigDescriptionEntry[] keyNames = getKeyNames();
if (keyNames == null)
{
throw new IllegalStateException(messages.getString("DefaultModuleEditor.ERROR_0001_NO_KEYS_DEFINED")); //$NON-NLS-1$
}
activeEditors = new EditorCarrier[keyNames.length];
for (int i = 0; i < keyNames.length; i++)
{
final KeyEditor editor;
final String displayName = createDisplayName(keyNames[i].getKeyName());
if (keyNames[i] instanceof EnumConfigDescriptionEntry)
{
final EnumConfigDescriptionEntry entry = (EnumConfigDescriptionEntry) keyNames[i];
editor = new EnumKeyEditor(getConfig(), entry, displayName);
}
else if (keyNames[i] instanceof ClassConfigDescriptionEntry)
{
final ClassConfigDescriptionEntry entry = (ClassConfigDescriptionEntry) keyNames[i];
editor = new ClassKeyEditor(getConfig(), entry, displayName);
}
else
{
editor = new TextKeyEditor(getConfig(), keyNames[i], displayName);
}
final JCheckBox enableCB = new JCheckBox();
enableCB.addActionListener(new EnableAction(editor, enableCB));
final JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(enableCB, BorderLayout.WEST);
panel.add(editor.getComponent(), BorderLayout.CENTER);
contentpane.add(panel);
activeEditors[i] = new EditorCarrier(editor, enableCB);
writer.write("<h3><b>"); //$NON-NLS-1$
writer.write(keyNames[i].getKeyName());
writer.write("</b></h3>"); //$NON-NLS-1$
writer.write("<p>"); //$NON-NLS-1$
writer.write(keyNames[i].getDescription());
writer.write("</p><hr>"); //$NON-NLS-1$
}
int width = 0;
for (int i = 0; i < activeEditors.length; i++)
{
width = Math.max(width, activeEditors[i].getEditor().getLabelWidth());
}
for (int i = 0; i < activeEditors.length; i++)
{
activeEditors[i].getEditor().setLabelWidth(width);
}
writer.write("</body></html>"); //$NON-NLS-1$
helpPane.setText(writer.toString());
}