// Ġ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 Ġcom . intellij . vcs . commit Ċ Ċ import Ġcom . intellij . application . subscribe Ċ import Ġcom . intellij . ide . Application Initialized Listener Ċ import Ġcom . intellij . ide . util . Properties Component Ċ import Ġcom . intellij . openapi . action System . An ActionEvent Ċ import Ġcom . intellij . openapi . application . Application Manager . getApplication Ċ import Ġcom . intellij . openapi . application . Config Import Helper . isNew User Ċ import Ġcom . intellij . openapi . application . run In Ed t Ċ import Ġcom . intellij . openapi . components . Service Ċ import Ġcom . intellij . openapi . components . service Ċ import Ġcom . intellij . openapi . project . Project Ċ import Ġcom . intellij . openapi . util . registry . Registry Ċ import Ġcom . intellij . openapi . util . registry . Registry Value Ċ import Ġcom . intellij . openapi . util . registry . Registry Value Listener Ċ import Ġcom . intellij . openapi . vcs .* Ċ import Ġcom . intellij . openapi . vcs . Project Level V cs Manager . V CS _ CONFIGURATION _ CHANGED Ċ import Ġcom . intellij . openapi . vcs . changes . ui . Changes View Content Manager Listener Ċ import Ġcom . intellij . openapi . vcs . impl . V cs EP Ċ import Ġcom . intellij . openapi . vcs . impl . V cs Init Object Ċ import Ġcom . intellij . openapi . vcs . impl . V cs Startup Activity Ċ import Ġcom . intellij . util . concurrency . annotations . Requires Ed t Ċ import Ġcom . intellij . util . messages . Topic Ċ import Ġcom . intellij . vcs . commit . Non Modal Commit Usage s Collector . log StateChanged Ċ import Ġjava . util .* Ċ Ċ private Ġval Ġis Toggle Commit Ui Ġget () Ġ= ĠRegistry . get (" vcs . non . modal . commit . toggle . ui ") Ċ private Ġval Ġis Force Non Modal Commit Ġget () Ġ= ĠRegistry . get (" vcs . force . non . modal . commit ") Ċ private Ġval Ġapp Settings Ġget () Ġ= ĠV cs Application Settings . getInstance () Ċ Ċ internal Ġfun ĠAn ActionEvent . getProject Commit Mode (): ĠCommit Mode ? Ġ= ĊĠ Ġproject ?. let Ġ{ ĠCommit Mode Manager . getInstance ( it ). getCurrent Commit Mode () Ġ} Ċ Ċ internal Ġclass ĠNon Modal Commit Custom ization Ġ: ĠApplication Initialized Listener Ġ{ ĊĠ Ġoverride Ġfun Ġcomponents Initialized () Ġ{ ĊĠĠĠ Ġif Ġ(! isNew User ()) Ġreturn ĊĊĠĠĠ ĠProperties Component . getInstance (). setValue ( KEY , Ġtrue ) ĊĠĠĠ Ġapp Settings . COMMIT _ FROM _ LOCAL _ CHANG ES Ġ= Ġtrue ĊĠĠĠ Ġlog StateChanged ( null ) ĊĠ Ġ} ĊĊĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġprivate Ġconst Ġval ĠKEY Ġ= Ġ" Non Modal Commit Custom ization . Is Applied " ĊĊĠĠĠ Ġinternal Ġfun Ġis Non Modal Custom ization Applied (): ĠBoolean Ġ= ĠProperties Component . getInstance (). isTrue Value ( KEY ) ĊĠ Ġ} Ċ } Ċ Ċ class ĠCommit Mode Manager ( private Ġval Ġproject : ĠProject ) Ġ{ ĊĠ Ġclass ĠMy Startup Activity Ġ: ĠV cs Startup Activity Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġrun Activity ( project : ĠProject ) Ġ{ ĊĠĠĠĠĠ Ġrun In Ed t Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( project . is Disposed ) Ġreturn @ run In Ed t ĊĠĠĠĠĠĠĠ Ġval Ġcommit Mode Manager Ġ= ĠgetInstance ( project ) ĊĠĠĠĠĠĠĠ Ġcommit Mode Manager . subscribe To Changes () ĊĠĠĠĠĠĠĠ Ġcommit Mode Manager . update Commit Mode () ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget Order (): ĠInt Ġ= ĠV cs Init Object . MAPP INGS . order Ġ+ Ġ 5 0 ĊĠ Ġ} ĊĊĠ Ġprivate Ġvar Ġcommit Mode : ĠCommit Mode Ġ= ĠCommit Mode . Pending Commit Mode ĊĊĠ Ġ@ Requires Ed t ĊĠ Ġfun Ġupdate Commit Mode () Ġ{ ĊĠĠĠ Ġif Ġ( project . is Disposed ) Ġreturn ĊĊĠĠĠ Ġval Ġnew Commit Mode Ġ= Ġget New Commit Mode () ĊĠĠĠ Ġif Ġ( commit Mode Ġ== Ġnew Commit Mode ) Ġreturn ĊĠĠĠ Ġcommit Mode Ġ= Ġnew Commit Mode ĊĊĠĠĠ Ġproject . message Bus . sync Publisher ( COMMIT _ MODE _ TOPIC ). commit Mode Changed () ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġget New Commit Mode (): ĠCommit Mode Ġ{ ĊĠĠĠ Ġval Ġactive Vc ses Ġ= ĠProject Level V cs Manager . getInstance ( project ). all Active V css ĊĠĠĠ Ġval Ġsingle V cs Ġ= Ġactive Vc ses . single OrNull () ĊĊĠĠĠ Ġif Ġ( active Vc ses . isEmpty ()) Ġreturn ĠCommit Mode . Pending Commit Mode ĊĊĠĠĠ Ġif Ġ( single V cs Ġ!= Ġnull Ġ&& Ġsingle V cs . is With Custom Local Changes ) Ġ{ ĊĠĠĠĠĠ Ġreturn ĠCommit Mode . External Commit Mode ( single V cs ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġif Ġ( is Non Modal In Settings () Ġ&& Ġcan Set Non Modal ()) Ġ{ ĊĠĠĠĠĠ Ġval Ġis Toggle Mode Ġ= Ġis Toggle Commit Ui . as Boolean () ĊĠĠĠĠĠ Ġreturn ĠCommit Mode . Non Modal Commit Mode ( is Toggle Mode ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġreturn ĠCommit Mode . Modal Commit Mode ĊĠ Ġ} ĊĊĠ Ġfun ĠgetCurrent Commit Mode (): ĠCommit Mode Ġ{ ĊĠĠĠ Ġreturn Ġcommit Mode ĊĠ Ġ} ĊĊĠ Ġinternal Ġfun Ġcan Set Non Modal (): ĠBoolean Ġ{ ĊĠĠĠ Ġif Ġ( is Force Non Modal Commit . as Boolean ()) Ġreturn Ġtrue ĊĠĠĠ Ġval Ġactive Vc ses Ġ= ĠProject Level V cs Manager . getInstance ( project ). all Active V css ĊĠĠĠ Ġreturn Ġactive Vc ses . isNotEmpty () Ġ&& Ġactive Vc ses . all Ġ{ Ġit . type Ġ== ĠV cs Type . distributed Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġsubscribe To Changes () Ġ{ ĊĠĠĠ Ġif Ġ( project . is Disposed ) Ġreturn ĊĊĠĠĠ Ġis Force Non Modal Commit . addListener ( object Ġ: ĠRegistry Value Listener Ġ{ ĊĠĠĠĠĠ Ġoverride Ġfun Ġafter ValueChanged ( value : ĠRegistry Value ) Ġ= Ġupdate Commit Mode () ĊĠĠĠ Ġ}, Ġproject ) ĊĠĠĠ Ġis Toggle Commit Ui . addListener ( object Ġ: ĠRegistry Value Listener Ġ{ ĊĠĠĠĠĠ Ġoverride Ġfun Ġafter ValueChanged ( value : ĠRegistry Value ) Ġ= Ġupdate Commit Mode () ĊĠĠĠ Ġ}, Ġproject ) ĊĠĠĠ ĠSET T INGS . subscribe ( project , Ġobject Ġ: ĠSettings Listener Ġ{ ĊĠĠĠĠĠ Ġoverride Ġfun Ġsettings Changed () Ġ= Ġupdate Commit Mode () ĊĠĠĠ Ġ}) ĊĊĠĠĠ ĠV cs EP . EP _ NAME . add ChangeListener ( Runnable Ġ{ Ġupdate Commit Mode () Ġ}, Ġproject ) ĊĠĠĠ Ġproject . message Bus . connect (). subscribe ( V CS _ CONFIGURATION _ CHANGED , ĠV cs Listener Ġ{ Ġrun In Ed t Ġ{ Ġupdate Commit Mode () Ġ} Ġ}) ĊĠ Ġ} ĊĊĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġval ĠSET T INGS : ĠTopic < Settings Listener > Ġ= ĠTopic ( Settings Listener :: class . java , ĠTopic . Broadcast Direction . TO _ DIRECT _ CHILD REN , Ġtrue ) ĊĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġval ĠCOMMIT _ MODE _ TOPIC : ĠTopic < Commit Mode Listener > Ġ= ĠTopic ( Commit Mode Listener :: class . java , ĠTopic . Broadcast Direction . NONE , Ġtrue ) ĊĊĠĠĠ Ġ@ Jvm Static ĊĠĠĠ Ġfun ĠgetInstance ( project : ĠProject ): ĠCommit Mode Manager Ġ= Ġproject . service () ĊĊĠĠĠ Ġ@ Jvm Static ĊĠĠĠ Ġfun Ġset Commit From Local Changes ( project : ĠProject ?, Ġvalue : ĠBoolean ) Ġ{ ĊĠĠĠĠĠ Ġval ĠoldValue Ġ= Ġapp Settings . COMMIT _ FROM _ LOCAL _ CHANG ES ĊĠĠĠĠĠ Ġif Ġ( oldValue Ġ== Ġvalue ) Ġreturn ĊĊĠĠĠĠĠ Ġapp Settings . COMMIT _ FROM _ LOCAL _ CHANG ES Ġ= Ġvalue ĊĠĠĠĠĠ Ġlog StateChanged ( project ) ĊĠĠĠĠĠ Ġget Application (). message Bus . sync Publisher ( SETTINGS ). settings Changed () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġis Non Modal In Settings (): ĠBoolean Ġ= Ġis Force Non Modal Commit . as Boolean () Ġ|| Ġapp Settings . COMMIT _ FROM _ LOCAL _ CHANG ES ĊĠ Ġ} ĊĊĠ Ġinterface ĠSettings Listener Ġ: ĠEvent Listener Ġ{ ĊĠĠĠ Ġfun Ġsettings Changed () ĊĠ Ġ} ĊĊĠ Ġinterface ĠCommit Mode Listener Ġ: ĠEvent Listener Ġ{ ĊĠĠĠ Ġ@ Requires Ed t ĊĠĠĠ Ġfun Ġcommit Mode Changed () ĊĠ Ġ} Ċ } Ċ Ċ sealed Ġclass ĠCommit Mode Ġ{ ĊĠ Ġabstract Ġfun Ġuse Commit Tool Window (): ĠBoolean ĊĠ Ġopen Ġfun Ġhide Local Changes Tab (): ĠBoolean Ġ= Ġfalse ĊĠ Ġopen Ġfun Ġdisable Default Commit Action (): ĠBoolean Ġ= Ġfalse ĊĊĠ Ġobject ĠPending Commit Mode Ġ: ĠCommit Mode () Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġuse Commit Tool Window (): ĠBoolean Ġ{ ĊĠĠĠĠĠ Ġ// ĠEnable Ġ' Commit ' Ġtool window Ġbefore Ġvc ses Ġare Ġactivated ĊĠĠĠĠĠ Ġreturn ĠCommit Mode Manager . is Non Modal In Settings () ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġobject ĠModal Commit Mode Ġ: ĠCommit Mode () Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġuse Commit Tool Window (): ĠBoolean Ġ= Ġfalse ĊĠ Ġ} ĊĊĠ Ġdata Ġclass ĠNon Modal Commit Mode ( val Ġis Toggle Mode : ĠBoolean ) Ġ: ĠCommit Mode () Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġuse Commit Tool Window (): ĠBoolean Ġ= Ġtrue ĊĠ Ġ} ĊĊĠ Ġdata Ġclass ĠExternal Commit Mode ( val Ġv cs : ĠAbstract V cs ) Ġ: ĠCommit Mode () Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġuse Commit Tool Window (): ĠBoolean Ġ= Ġtrue ĊĠĠĠ Ġoverride Ġfun Ġhide Local Changes Tab (): ĠBoolean Ġ= Ġtrue ĊĠĠĠ Ġoverride Ġfun Ġdisable Default Commit Action (): ĠBoolean Ġ= Ġtrue ĊĠ Ġ} Ċ }