ValueEntryPanel getValueEntryPanel(final ValueGem valueGem) {
// Lazily create the value panel on demand.
if (!valueGemPanelMap.containsKey(valueGem)) {
final ValueEditorHierarchyManager valueEditorHierarchyManager = gemCutter.getValueEditorHierarchyManager();
ValueEditorManager valueEditorManager = valueEditorHierarchyManager.getValueEditorManager();
ValueNode valueNode = valueGem.getValueNode();
// Create the value entry panel.
final ValueEntryPanel valueEntryPanel =
(ValueEntryPanel)valueEditorManager.getValueEditorDirector().getRootValueEditor(valueEditorHierarchyManager,
valueNode, null, 0, null);
// Add it to the map.
valueGemPanelMap.put(valueGem, valueEntryPanel);
// add a listener to propagate changes in the value gem to the VEP.
valueGem.addValueChangeListener(new ValueGemChangeListener() {
public void valueChanged(ValueGemChangeEvent e) {
ValueGem valueGem = (ValueGem)e.getSource();
valueEditorHierarchyManager.collapseHierarchy(valueEntryPanel, false);
valueEntryPanel.changeOwnerValue(valueGem.getValueNode());
valueEntryPanel.setSize(valueEntryPanel.getPreferredSize());
valueEntryPanel.revalidate();
}
});