// ĠCopyright Ġ 2 0 0 0 - 2 0 2 0 Ġ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 Ġgit 4 idea . ui Ċ Ċ import Ġcom . intellij . application . subscribe Ċ import Ġcom . intellij . dv cs . ui . Clone D vcs Validation Utils Ċ import Ġcom . intellij . dv cs . ui . D vcs Clone Dialog Component Ċ import Ġcom . intellij . openapi . application . Application Activation Listener Ċ import Ġcom . intellij . openapi . application . Modal ity State Ċ import Ġcom . intellij . openapi . application . invoke And Wait IfNeeded Ċ import Ġcom . intellij . openapi . diagnostic . Logger Ċ import Ġcom . intellij . openapi . project . Project Ċ import Ġcom . intellij . openapi . vcs . Checkout Provider Ċ import Ġcom . intellij . openapi . vcs . V cs Notifier Ċ import Ġcom . intellij . openapi . vcs . ui . clone Dialog . V cs Clone Dialog Component State Listener Ċ import Ġcom . intellij . openapi . vfs . Local FileSystem Ċ import Ġcom . intellij . openapi . wm . Ide Frame Ċ import Ġcom . intellij . util . Alarm Ċ import Ġgit 4 idea . Git Util Ċ import Ġgit 4 idea . checkout . Git Checkout Provider Ċ import Ġgit 4 idea . commands . Git Ċ import Ġgit 4 idea . config .* Ċ import Ġgit 4 idea . remote . Git Remember ed Inputs Ċ import Ġjava . nio . file . Paths Ċ Ċ class ĠGit Clone Dialog Component ( project : ĠProject , Ġprivate Ġval Ġmod ality State : ĠMod ality State ) Ġ: ĊĠ ĠD vcs Clone Dialog Component ( project , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠGit Util . DOT _ GIT , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠGit Remember ed Inputs . getInstance ()) Ġ{ ĊĠ Ġprivate Ġval ĠLOG Ġ= ĠLogger . getInstance ( Git Clone Dialog Component :: class . java ) ĊĊĠ Ġprivate Ġval Ġexecutable Manager Ġget () Ġ= ĠGit Executable Manager . getInstance () ĊĠ Ġprivate Ġval Ġinline Component Ġ= ĠGit Executable Inline Component ( error Component , Ġmod ality State , Ġmain Panel ) ĊĠ Ġprivate Ġval Ġerror Notifier Ġ= ĠInline Error Notifier ( inline Component , Ġmod ality State , Ġthis ) ĊĊĠ Ġprivate Ġval Ġexecutable Problem Handler Ġ= Ġfind Git Executable Problem Handler ( project ) ĊĠ Ġprivate Ġval Ġcheck Version Alarm Ġ= ĠAlarm ( Alarm . Thread ToUse . PO O LED _ THREAD , Ġthis ) ĊĠ Ġprivate Ġvar Ġlistener Installed Ġ= Ġfalse ĊĊĠ Ġoverride Ġfun Ġdo Clone ( project : ĠProject , Ġlistener : ĠCheckout Provider . Listener ) Ġ{ ĊĠĠĠ Ġval Ġparent Ġ= ĠPaths . get ( get Directory ()). to AbsolutePath (). parent ĊĠĠĠ Ġval Ġdestination Validation Ġ= ĠClone D vcs Validation Utils . create Destination ( parent . toString ()) ĊĠĠĠ Ġif Ġ( destination Validation Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠ ĠLOG . error (" Unable Ġto Ġcreate Ġdestination Ġdirectory ", Ġdestination Validation . message ) ĊĠĠĠĠĠ ĠV cs Notifier . getInstance ( project ). notify Error (" Clone Ġfailed ", Ġ" Unable Ġto Ġcreate Ġdestination Ġdirectory ") ĊĠĠĠĠĠ Ġreturn ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġl fs Ġ= ĠLocal FileSystem . getInstance () ĊĠĠĠ Ġvar Ġdestination Parent Ġ= Ġl fs . find File By Io File ( parent . to File ()) ĊĠĠĠ Ġif Ġ( destination Parent Ġ== Ġnull ) Ġ{ ĊĠĠĠĠĠ Ġdestination Parent Ġ= Ġl fs . refresh And Find File By Io File ( parent . to File ()) ĊĠĠĠ Ġ} ĊĠĠĠ Ġif Ġ( destination Parent Ġ== Ġnull ) Ġ{ ĊĠĠĠĠĠ ĠLOG . error (" Clone ĠFailed . ĠDestination Ġdoesn 't Ġexist ") ĊĠĠĠĠĠ ĠV cs Notifier . getInstance ( project ). notify Error (" Clone Ġfailed ", Ġ" Unable Ġto Ġfind Ġdestination ") ĊĠĠĠĠĠ Ġreturn ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġsource Repository URL Ġ= ĠgetUrl () ĊĠĠĠ Ġval Ġdirectory Name Ġ= ĠPaths . get ( get Directory ()). fileName . toString () ĊĠĠĠ Ġval Ġparent Directory Ġ= Ġparent . to AbsolutePath (). toString () ĊĊĠĠĠ ĠGit Checkout Provider . clone ( project , ĠGit . getInstance (), Ġlistener , Ġdestination Parent , Ġsource Repository URL , Ġdirectory Name , Ġparent Directory ) ĊĠĠĠ Ġval Ġremember ed Inputs Ġ= ĠGit Remember ed Inputs . getInstance () ĊĠĠĠ Ġremember ed Inputs . add Url ( source Repository URL ) ĊĠĠĠ Ġremember ed Inputs . clone Parent Dir Ġ= Ġparent Directory ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon Component Selected ( dialog State Listener : ĠV cs Clone Dialog Component State Listener ) Ġ{ ĊĠĠĠ Ġdialog State Listener . on Ok Action Enabled ( false ) ĊĊĠĠĠ Ġval Ġschedule Check Version Ġ= Ġ{ ĊĠĠĠĠĠ Ġif Ġ(! error Notifier . is Task InProgress ) Ġ{ ĊĠĠĠĠĠĠĠ Ġcheck Version Alarm . add Request ({ Ġcheck Git Version ( dialog State Listener ) Ġ}, Ġ 0 ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġif Ġ(! listener Installed ) Ġ{ ĊĠĠĠĠĠ Ġlistener Installed Ġ= Ġtrue ĊĠĠĠĠĠ ĠApplication Activation Listener . TOPIC . subscribe ( this , Ġobject Ġ: ĠApplication Activation Listener Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġapplication Activated ( ide Frame : ĠIde Frame ) Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġschedule Check Version () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ}) ĊĠĠĠ Ġ} ĊĠĠĠ Ġschedule Check Version () ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcheck Git Version ( dialog State Listener : ĠV cs Clone Dialog Component State Listener ) Ġ{ ĊĠĠĠ Ġinvoke And Wait IfNeeded ( modal ity State ) Ġ{ ĊĠĠĠĠĠ Ġinline Component . show Progress (" Checking ĠGit Ġversion ...") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠ Ġexecutable Manager . drop Executable Cache () ĊĠĠĠĠĠ Ġval Ġpath To Git Ġ= Ġexecutable Manager . path To Git ĊĠĠĠĠĠ Ġval Ġgit Version Ġ= Ġexecutable Manager . identify Version ( path To Git ) ĊĊĠĠĠĠĠ Ġinvoke And Wait IfNeeded ( modal ity State ) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ(! git Version . is Supported ) Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġshow Unsupported Version Error ( project , Ġgit Version , Ġerror Notifier ) ĊĠĠĠĠĠĠĠĠĠ Ġdialog State Listener . on Ok Action Enabled ( false ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġinline Component . hide Progress () ĊĠĠĠĠĠĠĠĠĠ Ġdialog State Listener . on Ok Action Enabled ( true ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġcatch Ġ( t : ĠThrowable ) Ġ{ ĊĠĠĠĠĠ Ġinvoke And Wait IfNeeded ( modal ity State ) Ġ{ ĊĠĠĠĠĠĠĠ Ġexecutable Problem Handler . show Error ( t , Ġerror Notifier , ĠonError Resolved Ġ= Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġdialog State Listener . on Ok Action Enabled ( true ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠĠĠ Ġdialog State Listener . on Ok Action Enabled ( false ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ