scName = ((FunctionalAgentGem) inputGem).getName();
}
// What we do next depends on whether we use cached sink values
ValueNode cachedVN;
final ValueEditor editor;
if (canUseCachedArgs && (cachedVN = gemCutter.getTableTop().getCachedValue(inputPart)) != null) {
// use cached sink value to generate the VEP
// get a copy of the cached VN but with the new type expr
ValueNode newVN = cachedVN.copyValueNode();
// instantiate the VEP with the new VN (which has the old cached value)
editor = valueEditorDirector.getRootValueEditor(valueEditorHierarchyManager,
newVN,
scName,
argumentNumber,
new GemCutterMetadataRunner(gemCutter, inputGem));
} else {
// don't use cached sink value. Generate the default VEP for this sink.
TypeExpr inputType = specializedInputTypes[i];
editor = valueEditorDirector.getRootValueEditor(valueEditorHierarchyManager,
inputType,
scName,
argumentNumber,
new GemCutterMetadataRunner(gemCutter, inputGem));
}
// If this is a value entry panel then set the name of the input for use in tooltips
if (editor instanceof ValueEntryPanel) {
((ValueEntryPanel)editor).setArgumentName(inputPart.getArgumentName().getCompositeName());
}
// Position the editor next to the connection point.
positionEditor(editor, inputPart);
// Now add the editor to the table top.
tableTopPanel.add(editor, 0);
// Add to the list of active entry panels
valueEditorHierarchyManager.addTopValueEditor(editor);
// Update the context and editor map
editor.setContext(new ValueEditorContext() {
public TypeExpr getLeastConstrainedTypeExpr() {
return inputPart.getType();
}
});
inputToEditorMap.put(inputPart, editor);
// If the editor resizes because it's value changes, make sure it stays aligned to the connection
editor.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
positionEditor((ValueEditor) e.getComponent(), inputPart);
}
});