/* Ċ Ġ* Ġ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 . project Generator . panel . interpreter Ċ Ċ import Ġcom . intellij . openapi . ui . Validation Info Ċ import Ġorg . jetbrains . r . R Bundle Ċ import Ġorg . jetbrains . r . R Plugin Util Ċ import Ġorg . jetbrains . r . configuration . R Manage Interpreter Panel Ċ import Ġorg . jetbrains . r . execution . Execute Expression Utils Ċ import Ġorg . jetbrains . r . interpreter . R Interpreter Info Ċ import Ġorg . jetbrains . r . interpreter . R Interpreter Location Ċ import Ġorg . jetbrains . r . interpreter . R Interpreter Util Ċ import Ġorg . jetbrains . r . interpreter . getVersion Ċ import Ġjava . awt . Border Layout Ċ Ċ class ĠR AddNew Interpreter Panel ( existing Inter pre ters : ĠList < R Interpreter Info >, Ġlocal Only : ĠBoolean ) Ġ: ĠR Interpreter Panel () Ġ{ ĊĠ Ġoverride Ġval Ġpanel Name Ġ= ĠPAN EL _ NAME ĊĊĠ Ġprivate Ġval Ġmanage Interpreter Panel Ġ= ĠR Manage Interpreter Panel ( PANEL _ HINT , Ġlocal Only ) Ġ{ ĊĠĠĠ Ġrun Listeners () ĊĠ Ġ} ĊĠ Ġprivate Ġval Ġlast Validated Interpreter Ġ= ĠLast Validated Interpreter () ĊĊĠ Ġoverride Ġval Ġinterpreter Location : ĠR Interpreter Location ? ĊĠĠĠ Ġget () Ġ= Ġmanage Interpreter Panel . current Selection ?. interpreter Location ĊĊĠ Ġinit Ġ{ ĊĠĠĠ Ġlayout Ġ= ĠBorderLayout () ĊĠĠĠ Ġmanage Interpreter Panel . initial Inter pre ters Ġ= Ġexisting Inter pre ters ĊĠĠĠ Ġmanage Interpreter Panel . initial Selection Ġ= Ġexisting Inter pre ters . first OrNull () ĊĠĠĠ Ġmanage Interpreter Panel . reset () ĊĠĠĠ Ġadd ( manage Interpreter Panel . component , ĠBorderLayout . NORTH ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġfetch Installed Packages (): ĠList < String > Ġ{ ĊĠĠĠ Ġval Ġlocation Ġ= Ġinterpreter Location Ġ?: Ġreturn Ġempty List () ĊĠĠĠ Ġreturn ĠExecute Expression Utils . getS ynchronously ( FETCH _ INST ALLED _ PACK AGES ) Ġ{ ĊĠĠĠĠĠ Ġlocation . upload File To Host ( FETCH _ PACK AGES _ PATH ) ĊĠĠĠĠĠ ĠR Interpreter Util . run Helper ( location , ĠFETCH _ PACK AGES _ PATH , Ġnull , Ġempty List ()). lines (). drop ( 1 ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġvalidate Interpreter (): ĠList < Validation Info > Ġ{ ĊĠĠĠ Ġval Ġlocation Ġ= Ġinterpreter Location Ġ?: Ġreturn ĠlistOf ( Validation Info ( MISSING _ INTER PRE TER _ TEXT )) ĊĠĠĠ Ġif Ġ( location Ġ== Ġlast Validated Interpreter . location ) Ġreturn Ġlast Validated Interpreter . validation Info ĊĠĠĠ Ġlast Validated Interpreter . location Ġ= Ġlocation ĊĠĠĠ Ġlast Validated Interpreter . validation Info Ġ= Ġif Ġ(! is Correct Interpreter Location ( location )) Ġ{ ĊĠĠĠĠĠ ĠlistOf ( Validation Info ( INVALID _ INTER PRE TER _ TEXT )) ĊĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠ Ġempty List () ĊĠĠĠ Ġ} ĊĠĠĠ Ġreturn Ġlast Validated Interpreter . validation Info ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġis Correct Interpreter Location ( interpreter Location : ĠR Interpreter Location ): ĠBoolean Ġ{ ĊĠĠĠ Ġreturn Ġtry Ġ{ ĊĠĠĠĠĠ Ġval Ġversion Ġ= ĠExecute Expression Utils . getS ynchronously ( CHECK _ INTER PRE TER _ TITLE ) Ġ{ ĊĠĠĠĠĠĠĠ Ġinterpreter Location . getVersion () ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ ĠR Interpreter Util . is Supported Version ( version ) ĊĠĠĠ Ġ} Ġcatch Ġ(_ : ĠException ) Ġ{ ĊĠĠĠĠĠ Ġfalse ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġdata Ġclass ĠLast Validated Interpreter ( var Ġlocation : ĠR Interpreter Location ? Ġ= Ġnull , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġvar Ġvalidation Info : ĠList < Validation Info > Ġ= Ġempty List ()) ĊĊĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġprivate Ġval ĠPAN EL _ NAME Ġ= ĠR Bundle . message (" project . settings . new . interpreter ") ĊĠĠĠ Ġprivate Ġval ĠPAN EL _ HINT Ġ= ĠR Bundle . message (" project . settings . base . interpreter ") ĊĠĠĠ Ġprivate Ġval ĠCHECK _ INTER PRE TER _ TITLE Ġ= ĠR Bundle . message (" project . settings . check . interpreter ") ĊĠĠĠ Ġprivate Ġval ĠMIS SING _ INTER PRE TER _ TEXT Ġ= ĠR Bundle . message (" project . settings . missing . interpreter ") ĊĠĠĠ Ġprivate Ġval ĠINVALID _ INTER PRE TER _ TEXT Ġ= ĠR Bundle . message (" project . settings . invalid . interpreter ") ĊĠĠĠ Ġprivate Ġval ĠFETCH _ INST ALLED _ PACK AGES Ġ= ĠR Bundle . message (" project . settings . fetch . installed . packages ") ĊĊĠĠĠ Ġprivate Ġval ĠFETCH _ PACK AGES _ PATH Ġby Ġlazy Ġ{ ĠR Plugin Util . find File In R Helpers (" R / project Generator / getAll Installed Packages . R ") Ġ} ĊĠ Ġ} Ċ }