// Ġ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 Ġcom . intellij . openapi . vcs Ċ Ċ import Ġcom . intellij . Common Bundle Ċ import Ġcom . intellij . ide . util . Properties Component Ċ import Ġcom . intellij . notification . Notification Ċ import Ġcom . intellij . notification . Notification Action Ċ import Ġcom . intellij . openapi . Disposable Ċ import Ġcom . intellij . openapi . project . Project Ċ import Ġcom . intellij . openapi . util . Dis poser Ċ import Ġcom . intellij . openapi . vcs . changes . ui . Select Files Dialog Ċ import Ġcom . intellij . openapi . vfs . Virtual File Ċ import Ġcom . intellij . openapi . util . N ls Contexts Ċ Ċ abstract Ġclass ĠFiles Processor With Notification Impl ( protected Ġval Ġproject : ĠProject , Ġparent Disposable : ĠDis posable ) Ġ: ĠFiles Processor Ġ{ ĊĠ Ġprivate Ġval Ġfiles Ġ= Ġmutable Set Of < Virtual File >() ĊĊĠ Ġprivate Ġval ĠNOT IFICATION _ LOCK Ġ= ĠObject () ĊĊĠ Ġprivate Ġvar Ġnotification : ĠNotification ? Ġ= Ġnull ĊĊĠ Ġabstract Ġval Ġasked Before Property : ĠString ĊĊĠ Ġabstract Ġval Ġdo For Current Project Property : ĠString ? ĊĊĠ Ġabstract Ġval Ġshow Action Text : ĠString ĊĠ Ġabstract Ġval Ġfor Current Project Action Text : ĠString ĊĠ Ġabstract Ġval Ġfor All Projects Action Text : ĠString ? ĊĠ Ġabstract Ġval Ġmute Action Text : ĠString ĊĊĠ Ġabstract Ġfun Ġnotification Title (): ĠString ĊĠ Ġabstract Ġfun Ġnotification Message (): ĠString ĊĊĠ Ġabstract Ġfun Ġdo Action On Ch osen Files ( files : ĠCollection < Virtual File >) ĊĊĠ Ġabstract Ġfun Ġdo Filter Files ( files : ĠCollection < Virtual File >): ĠCollection < Virtual File > ĊĊĠ Ġabstract Ġfun Ġremember ForAll Projects () ĊĊĠ Ġprotected Ġopen Ġval Ġview Files Dialog Title : Ġ@ N ls Contexts . Dialog Title ĠString ? Ġ= Ġnull ĊĠ Ġprotected Ġopen Ġval Ġview Files Dialog Ok Action Name : Ġ@ N ls Contexts . Button ĠString Ġ= ĠCommon Bundle . get Add ButtonText () ĊĠ Ġprotected Ġopen Ġval Ġview Files Dialog Cancel Action Name : Ġ@ N ls Contexts . Button ĠString Ġ= ĠCommon Bundle . get Cancel ButtonText () ĊĊĠ Ġprotected Ġopen Ġfun Ġremember For Current Project () Ġ{ ĊĠĠĠ Ġset For Current Project ( true ) ĊĠ Ġ} ĊĊĠ Ġinit Ġ{ ĊĠĠĠ ĠDis poser . register ( parent Disposable , Ġthis ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġprocess Files ( files : ĠList < Virtual File >): ĠList < Virtual File > Ġ{ ĊĊĠĠĠ Ġval Ġfiltered Files Ġ= Ġdo Filter Files ( files ) ĊĊĠĠĠ Ġif Ġ( filtered Files . isEmpty ()) Ġreturn Ġfiles ĊĊĠĠĠ Ġadd New Files ( filtered Files ) ĊĊĠĠĠ Ġif Ġ( need Do For Current Project ()) Ġ{ ĊĠĠĠĠĠ Ġdo Action On Ch osen Files ( acquire Valid Files ()) ĊĠĠĠĠĠ Ġclear Files () ĊĠĠĠ Ġ} ĊĠĠĠ Ġelse Ġ{ ĊĠĠĠĠĠ Ġpropose To Process Files () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġreturn Ġfiles Ġ- Ġfiltered Files ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġpropose To Process Files () Ġ{ ĊĠĠĠ Ġsynchronized ( NOTIFICATION _ LOCK ) Ġ{ ĊĠĠĠĠĠ Ġif Ġ( not Ask ed Before () Ġ&& Ġnotification Not Present ()) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġnotification Actions Ġ= Ġmutable ListOf ( show Action (), Ġadd For Current Project Action ()). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġif Ġ( for All Projects Action Text Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadd ( for All Projects Action ()) ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġadd ( mute Action ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġnotification Ġ= ĠV cs Notifier . getInstance ( project ). notify Minor Info ( true , Ġnotification Title (), Ġnotification Message (), Ġ* notification Actions . to Typed Array ()) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Synchron ized ĊĠ Ġprotected Ġfun Ġremove Files ( files ToRemove : ĠCollection < Virtual File >) Ġ{ ĊĠĠĠ Ġfiles . removeAll ( files ToRemove ) ĊĠ Ġ} ĊĊĠ Ġ@ Synchron ized ĊĠ Ġprivate Ġfun Ġis Files Empty () Ġ= Ġfiles . isEmpty () ĊĊĠ Ġ@ Synchron ized ĊĠ Ġprivate Ġfun Ġadd New Files ( files ToAdd : ĠCollection < Virtual File >) Ġ{ ĊĠĠĠ Ġfiles . addAll ( files ToAdd ) ĊĠ Ġ} ĊĊĠ Ġ@ Synchron ized ĊĠ Ġprotected Ġfun Ġacquire Valid Files (): ĠList < Virtual File > Ġ{ ĊĠĠĠ Ġfiles . removeAll Ġ{ Ġ! it . isValid Ġ} ĊĠĠĠ Ġreturn Ġfiles . toList () ĊĠ Ġ} ĊĊĠ Ġ@ Synchron ized ĊĠ Ġprivate Ġfun Ġclear Files () Ġ{ ĊĠĠĠ Ġfiles . clear () ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġdispose () Ġ{ ĊĠĠĠ Ġclear Files () ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġshow Action () Ġ= ĠNotification Action . create Simple ( show Action Text ) Ġ{ ĊĠĠĠ Ġval Ġall Files Ġ= Ġacquire Valid Files () ĊĠĠĠ Ġif Ġ( all Files . isNotEmpty ()) Ġ{ ĊĠĠĠĠĠ Ġwith ( Select Files Dialog . init ( project , Ġall Files , Ġnull , Ġnull , Ġtrue , Ġtrue , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġview Files Dialog Ok Action Name , Ġview Files Dialog Cancel Action Name )) Ġ{ ĊĠĠĠĠĠĠĠ Ġtitle Ġ= Ġview Files Dialog Title ĊĠĠĠĠĠĠĠ Ġselected Files Ġ= Ġall Files ĊĠĠĠĠĠĠĠ Ġif Ġ( show AndGet ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġval Ġuser Selected Files Ġ= Ġselected Files ĊĠĠĠĠĠĠĠĠĠ Ġdo Action On Ch osen Files ( user Selected Files ) ĊĠĠĠĠĠĠĠĠĠ Ġremove Files ( user Selected Files ) ĊĠĠĠĠĠĠĠĠĠ Ġif Ġ( is Files Empty ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexpire Notification () ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġadd For Current Project Action () Ġ= ĠNotification Action . create ( for Current Project Action Text ) Ġ{ Ġ_, Ġ_ Ġ-> ĊĠĠĠ Ġdo Action On Ch osen Files ( acquire Valid Files ()) ĊĠĠĠ Ġremember For Current Project () ĊĠĠĠ ĠProperties Component . getInstance ( project ). setValue ( ask ed Before Property , Ġtrue ) ĊĠĠĠ Ġexpire Notification () ĊĠĠĠ Ġclear Files () ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġfor All Projects Action () Ġ= ĠNotification Action . create ( for All Projects Action Text !! ) Ġ{ Ġ_, Ġ_ Ġ-> ĊĠĠĠ Ġdo Action On Ch osen Files ( acquire Valid Files ()) ĊĠĠĠ Ġremember For Current Project () ĊĠĠĠ ĠProperties Component . getInstance ( project ). setValue ( ask ed Before Property , Ġtrue ) ĊĠĠĠ Ġremember ForAll Projects () ĊĠĠĠ Ġexpire Notification () ĊĠĠĠ Ġclear Files () ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġmute Action () Ġ= ĠNotification Action . create ( mute Action Text ) Ġ{ Ġ_, Ġnotification Ġ-> ĊĠĠĠ Ġset For Current Project ( false ) ĊĠĠĠ ĠProperties Component . getInstance ( project ). setValue ( ask ed Before Property , Ġtrue ) ĊĠĠĠ Ġnotification . expire () ĊĠ Ġ} ĊĊĠ Ġprotected Ġfun Ġnotification Not Present () Ġ= ĊĠĠĠ Ġsynchronized ( NOTIFICATION _ LOCK ) Ġ{ ĊĠĠĠĠĠ Ġnotification ?. is Expired Ġ?: Ġtrue ĊĠĠĠ Ġ} ĊĊĠ Ġprotected Ġfun Ġexpire Notification () Ġ= ĊĠĠĠ Ġsynchronized ( NOTIFICATION _ LOCK ) Ġ{ ĊĠĠĠĠĠ Ġnotification ?. expire () ĊĠĠĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġset For Current Project ( value : ĠBoolean ) Ġ{ ĊĠĠĠ Ġdo For Current Project Property ?. let Ġ{ ĊĠĠĠĠĠ ĠProperties Component . getInstance ( project ). setValue ( it , Ġvalue ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġget For Current Project (): ĠBoolean Ġ{ ĊĠĠĠ Ġreturn Ġdo For Current Project Property ?. let Ġ{ ĠProperties Component . getInstance ( project ). getBoolean ( it , Ġfalse ) Ġ} Ġ?: Ġfalse ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġnot Ask ed Before () Ġ= Ġ! was Ask ed Before () ĊĊĠ Ġprotected Ġfun Ġwas Ask ed Before () Ġ= ĠProperties Component . getInstance ( project ). getBoolean ( ask ed Before Property , Ġfalse ) ĊĊĠ Ġprotected Ġopen Ġfun Ġneed Do For Current Project () Ġ= Ġget For Current Project () Ċ }