@@ -40,6 +40,7 @@ import ReferenceEdge from "./ReferenceEdge";
4040import { CustomEdgeType , CustomNodeType } from "./types" ;
4141import { ArrayCreationDialog } from "./ArrayCreationDialog" ;
4242import { SimpleInputDialog } from "./SimpleInputDialog" ;
43+ import { StringCreationDialog } from "./StringCreationDialog" ;
4344
4445const selector = ( state : RFState ) => ( {
4546 selectedNodeId : state . selectedNodeId ,
@@ -130,6 +131,12 @@ export const MemoryView = () => {
130131 const [ showLocalVarDialog , setShowLocalVarDialog ] = useState ( false ) ;
131132 const [ localVarDialogNodeId , setLocalVarDialogNodeId ] = useState < string | null > ( null ) ;
132133
134+ // String creation dialog state
135+ const [ showStringDialog , setShowStringDialog ] = useState ( false ) ;
136+ const [ stringDialogCallback , setStringDialogCallback ] = useState <
137+ ( ( name : string , value : string ) => void ) | null
138+ > ( null ) ;
139+
133140 const methodCalls = nodes . filter ( isMethodCallNode ) ;
134141 let previousMethodCall = methodCalls [ 0 ] ;
135142 let lastMethodCall = methodCalls [ 0 ] ;
@@ -200,6 +207,14 @@ export const MemoryView = () => {
200207 return [ ...primitveDataTypes , ...Object . keys ( memory . klasses ) ] ;
201208 } ;
202209
210+ // Helper function to show string creation dialog
211+ const showStringCreationDialog = (
212+ callback : ( name : string , value : string ) => void
213+ ) => {
214+ setStringDialogCallback ( ( ) => callback ) ;
215+ setShowStringDialog ( true ) ;
216+ } ;
217+
203218 // Handler for declaring local variables
204219 const handleDeclareLocalVariable = ( nodeId : string ) => {
205220 setLocalVarDialogNodeId ( nodeId ) ;
@@ -498,6 +513,79 @@ export const MemoryView = () => {
498513 }
499514
500515 if ( type != "variable" ) {
516+ if ( type == "String" && memory . options . useStringAsObject ) {
517+ // Show dialog for String creation
518+ showStringCreationDialog ( ( name , value ) => {
519+ const objAttributes : Record < string , Attribute > = {
520+ value : {
521+ dataType : "String" ,
522+ value : value ,
523+ } ,
524+ } ;
525+
526+ const newNode : CustomNodeType = {
527+ id : getId ( ) ,
528+ type : "object" ,
529+ position,
530+ data : {
531+ klass : "String" ,
532+ attributes : objAttributes ,
533+ position,
534+ } ,
535+ } ;
536+
537+ if ( lastMethodCall === undefined ) {
538+ const newVar : CustomNodeType = {
539+ id : getId ( ) ,
540+ type : "variable" ,
541+ position : {
542+ x : position . x - 100 ,
543+ y : position . y ,
544+ } ,
545+ data : {
546+ name,
547+ value : newNode . id ,
548+ position : {
549+ x : position . x - 100 ,
550+ y : position . y ,
551+ } ,
552+ dataType : "String" ,
553+ } ,
554+ } ;
555+ setNodes ( ( nds ) => nds . concat ( newNode , newVar ) ) ;
556+ const newEdge : CustomEdgeType = {
557+ id : getId ( ) ,
558+ source : newVar . id ,
559+ target : newNode . id ,
560+ } ;
561+ setEdges ( ( egs ) => egs . concat ( newEdge ) ) ;
562+ } else {
563+ setNodes ( ( nds ) =>
564+ nds
565+ . map ( ( n ) => {
566+ if ( n . id == lastMethodCall . id ) {
567+ ( n . data as any ) . localVariables [ name ] = {
568+ dataType : "String" ,
569+ value : newNode . id ,
570+ } ;
571+ return n ;
572+ }
573+ return n ;
574+ } )
575+ . concat ( newNode )
576+ ) ;
577+ const newEdge : CustomEdgeType = {
578+ id : getId ( ) ,
579+ source : lastMethodCall . id ,
580+ sourceHandle : name ,
581+ target : newNode . id ,
582+ } ;
583+ setEdges ( ( egs ) => egs . concat ( newEdge ) ) ;
584+ }
585+ } ) ;
586+ return ;
587+ }
588+
501589 if ( type == "Array" ) {
502590 // Show dialog for array creation
503591 showArrayCreationDialog ( ( name , length , elementType ) => {
@@ -831,6 +919,19 @@ export const MemoryView = () => {
831919 } }
832920 />
833921 ) }
922+ { showStringDialog && stringDialogCallback && (
923+ < StringCreationDialog
924+ onConfirm = { ( name , value ) => {
925+ stringDialogCallback ( name , value ) ;
926+ setShowStringDialog ( false ) ;
927+ setStringDialogCallback ( null ) ;
928+ } }
929+ onCancel = { ( ) => {
930+ setShowStringDialog ( false ) ;
931+ setStringDialogCallback ( null ) ;
932+ } }
933+ />
934+ ) }
834935 </ div >
835936 ) ;
836937} ;
0 commit comments