/* Ċ Ġ* ĠCopyright Ġ 2 0 0 0 - 2 0 1 9 ĠJetBrains Ġs . r . o . ĠUse Ġof Ġthis Ġsource Ġcode Ġis Ġgoverned Ġby Ġthe ĠApache Ġ 2 . 0 Ġlicense Ġthat Ġcan Ġbe Ġfound Ġin Ġthe ĠLICENSE Ġfile . Ċ Ġ*/ Ċ Ċ package Ġorg . jetbrains . r . rendering . editor Ċ Ċ import Ġcom . intellij . openapi . action System .* Ċ import Ġcom . intellij . openapi . action System . impl . Simple DataContext Ċ import Ġcom . intellij . openapi . file Editor . File Document Manager Ċ import Ġcom . intellij . openapi . file Editor . Text Editor Ċ import Ġcom . intellij . openapi . project . D umb Aware Action Ċ import Ġcom . intellij . openapi . project . Project Ċ import Ġcom . intellij . openapi . vfs . Virtual File Ċ import Ġcom . intellij . psi . Psi Manager Ċ import Ġorg . jetbrains . r . R Bundle Ċ import Ġorg . jetbrains . r . actions . R Action Util Ċ import Ġorg . jetbrains . r . actions . is Virtual File For Test Ċ import Ġjava . awt . Border Layout Ċ Ċ class ĠR File Editor ( project : ĠProject , Ġtext Editor : ĠText Editor , Ġvirtual File : ĠVirtual File ) ĊĠ Ġ: ĠAdvanced Text Editor ( project , Ġtext Editor , Ġvirtual File ) Ġ{ ĊĠ Ġinit Ġ{ ĊĠĠĠ Ġval Ġis Test able Ġ= Ġis Virtual File For Test ( virtual File , Ġproject ) ĊĠĠĠ Ġmain Component . add ( create RE d itor Toolbar ( is Test able ). component , ĠBorderLayout . NORTH ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun ĠgetName () Ġ= ĠR Bundle . message (" editor . r . editor . name ") ĊĊĠ Ġprivate Ġfun Ġcreate RE d itor Toolbar ( is Test able : ĠBoolean ): ĠAction Toolbar Ġ= ĊĠĠĠ ĠAction Manager . getInstance (). create Action Toolbar ( Action Places . EDITOR _ TOOL BAR , Ġcreate Action Group ( is Test able ), Ġtrue ). also Ġ{ ĊĠĠĠĠĠ Ġit . setTarget Component ( text Editor . editor . content Component ) ĊĠĠĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcreate Action Group ( is Test able : ĠBoolean ): ĠAction Group Ġ= Ġobject Ġ: ĠDefault Action Group () Ġ{ ĊĠĠĠ Ġprivate Ġval Ġbasic Actions Ġ= ĠlistOf < An Action >( ĊĠĠĠĠĠ ĠToolbar Action (" org . jetbrains . r . actions . R Run Action "), ĊĠĠĠĠĠ ĠToolbar Action (" org . jetbrains . r . actions . R Debug Action "), ĊĠĠĠĠĠ ĠToolbar Action (" org . jetbrains . r . console . jobs . Run R Job Action "), ĊĠĠĠĠĠ ĠSe parator (), ĊĠĠĠĠĠ ĠToolbar Action (" org . jetbrains . r . actions . Run Selection "), ĊĠĠĠĠĠ ĠToolbar Action (" org . jetbrains . r . actions . Debug Selection ")) ĊĠĠĠ Ġprivate Ġval Ġtests Actions Ġ= ĠlistOf < An Action >( ĊĠĠĠĠĠ ĠSe parator (), ĊĠĠĠĠĠ ĠToolbar Action (" org . jetbrains . r . actions . Create R Test File Action ")) ĊĠĠĠ Ġprivate Ġval Ġhelp Actions Ġ= ĠlistOf < An Action >( ĊĠĠĠĠĠ ĠSe parator (), ĊĠĠĠĠĠ ĠToolbar Action (" org . jetbrains . r . actions . RE d itor Help Action ")) ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠ Ġadd All ( basic Actions ) ĊĠĠĠĠĠ Ġif Ġ( is Test able ) Ġadd All ( tests Actions ) ĊĠĠĠĠĠ Ġadd All ( help Actions ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġinner Ġclass ĠToolbar Action ( action Id : ĠString ) Ġ: ĠD umb Aware Action () Ġ{ ĊĠĠĠ Ġprivate Ġval Ġaction Ġ= ĠAction Manager . getInstance (). getAction ( action Id ). also Ġ{ Ġcopy From ( it ) Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠactionPerformed ( e : ĠAn ActionEvent ) Ġ{ ĊĠĠĠĠĠ ĠR Action Util . perform Deleg ated Action ( action , Ġcreate Event ( e )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġupdate ( e : ĠAn ActionEvent ) Ġ{ ĊĠĠĠĠĠ Ġaction . update ( create Event ( e )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Event ( e : ĠAn ActionEvent ): ĠAn ActionEvent Ġ{ ĊĠĠĠĠĠ Ġval Ġfile Ġ= ĠFile Document Manager . getInstance (). getFile ( text Editor . editor . document ) ĊĠĠĠĠĠ Ġreturn ĠAn ActionEvent . createFrom Input Event ( ĊĠĠĠĠĠĠĠ Ġe . input Event , Ġ"", Ġe . presentation , ĊĠĠĠĠĠĠĠ ĠSimple DataContext . getSimple Context ( ĊĠĠĠĠĠĠĠĠĠ Ġmap Of ( Common Data Keys . EDITOR . name Ġto Ġtext Editor . editor , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠCommon Data Keys . VIRTUAL _ FILE . name Ġto Ġfile , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠCommon Data Keys . P SI _ FILE . name Ġto Ġfile ?. let Ġ{ ĠPsi Manager . getInstance ( project ). find File ( it ) Ġ}), ĊĠĠĠĠĠĠĠĠĠ Ġe . data Context )) ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ