VDBAbstractApplication.st
changeset 0 33a652015a1a
child 1 09b3ef5606e7
equal deleted inserted replaced
-1:000000000000 0:33a652015a1a
       
     1 "{ Package: 'jv:vdb' }"
       
     2 
       
     3 ApplicationModel subclass:#VDBAbstractApplication
       
     4 	instanceVariableNames:'debuggerHolder debugger'
       
     5 	classVariableNames:''
       
     6 	poolDictionaries:''
       
     7 	category:'VDB-UI-Abstract'
       
     8 !
       
     9 
       
    10 !VDBAbstractApplication class methodsFor:'interface opening'!
       
    11 
       
    12 openFor: debugger
       
    13     self new 
       
    14         debugger: debugger;
       
    15         open.
       
    16 
       
    17     "Created: / 06-06-2014 / 21:35:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    18 ! !
       
    19 
       
    20 !VDBAbstractApplication class methodsFor:'plugin spec'!
       
    21 
       
    22 aspectSelectors
       
    23     ^ #(
       
    24         debuggerHolder
       
    25     )
       
    26 
       
    27     "Created: / 06-06-2014 / 21:47:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    28 ! !
       
    29 
       
    30 !VDBAbstractApplication methodsFor:'acessing'!
       
    31 
       
    32 debugger
       
    33     ^ debugger
       
    34 
       
    35     "Created: / 06-06-2014 / 21:37:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    36 !
       
    37 
       
    38 debugger: dbg
       
    39     self debuggerHolder value: dbg
       
    40 
       
    41     "Created: / 06-06-2014 / 21:36:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    42 ! !
       
    43 
       
    44 !VDBAbstractApplication methodsFor:'aspects'!
       
    45 
       
    46 debuggerHolder
       
    47     "return/create the 'debuggerHolder' value holder (automatically generated)"
       
    48 
       
    49     debuggerHolder isNil ifTrue:[
       
    50         debuggerHolder := ValueHolder new.
       
    51         debuggerHolder addDependent:self.
       
    52     ].
       
    53     ^ debuggerHolder
       
    54 !
       
    55 
       
    56 debuggerHolder:aValueModel
       
    57     "set the 'debuggerHolder' value holder (automatically generated)"
       
    58 
       
    59     |oldValue newValue|
       
    60 
       
    61     debuggerHolder notNil ifTrue:[
       
    62         oldValue := debuggerHolder value.
       
    63         debuggerHolder removeDependent:self.
       
    64     ].
       
    65     debuggerHolder := aValueModel.
       
    66     debuggerHolder notNil ifTrue:[
       
    67         debuggerHolder addDependent:self.
       
    68     ].
       
    69     newValue := debuggerHolder value.
       
    70     oldValue ~~ newValue ifTrue:[
       
    71         self update:#value with:newValue from:debuggerHolder.
       
    72     ].
       
    73 ! !
       
    74 
       
    75 !VDBAbstractApplication methodsFor:'change & update'!
       
    76 
       
    77 update:something with:aParameter from:changedObject
       
    78     "Invoked when an object that I depend upon sends a change notification."
       
    79 
       
    80     changedObject == debuggerHolder ifTrue:[
       
    81         debuggerHolder value == debugger ifFalse:[
       
    82             debugger notNil ifTrue:[ 
       
    83                 self unsubscribe.
       
    84             ].
       
    85             debugger := debuggerHolder value.
       
    86             debugger notNil ifTrue:[ 
       
    87                 self subscribe.
       
    88             ].
       
    89         ].
       
    90         ^ self.
       
    91     ].
       
    92     super update:something with:aParameter from:changedObject
       
    93 
       
    94     "Modified: / 06-06-2014 / 22:09:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    95 ! !
       
    96 
       
    97 !VDBAbstractApplication methodsFor:'dependents access'!
       
    98 
       
    99 release
       
   100     "remove all dependencies from the receiver"
       
   101 
       
   102     super release.
       
   103     self unsubscribe
       
   104 
       
   105     "Created: / 06-06-2014 / 22:13:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   106 ! !
       
   107 
       
   108 !VDBAbstractApplication methodsFor:'initialization & release'!
       
   109 
       
   110 subscribe   
       
   111     "Register for debugger events. To be overrided by subclasses"
       
   112 
       
   113     "Created: / 06-06-2014 / 21:26:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   114 !
       
   115 
       
   116 unsubscribe
       
   117     "Unsubscribe myself fo debugger events"
       
   118 
       
   119     debugger announcer unsubscribe: self.
       
   120 
       
   121     "Created: / 06-06-2014 / 21:26:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   122 ! !
       
   123 
       
   124 !VDBAbstractApplication methodsFor:'startup & release'!
       
   125 
       
   126 releaseAsSubCanvas
       
   127     "a subcanvas is closed or switching to a new application.
       
   128      Can be redefined to perform a self release in this case."
       
   129 
       
   130     self release
       
   131 
       
   132     "Created: / 06-06-2014 / 22:12:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   133 ! !
       
   134