Check-in [9368ecb481]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Register a module notifier for each file opened, and unregister it on destruction.
Timelines: family | ancestors | descendants | both | feature/rewrite-multi-async
Files: files | file ages | folders
SHA1:9368ecb481bcb4f329504ac24e0c560673439cc6
User & Date: tinus 2016-02-21 13:00:59
Context
2016-02-21
15:22
Added scaffolding for VCS client interface. check-in: 083aa4a165 user: tinus tags: feature/rewrite-multi-async
13:00
Register a module notifier for each file opened, and unregister it on destruction. check-in: 9368ecb481 user: tinus tags: feature/rewrite-multi-async
2016-02-14
18:18
Added View class, implementing all the UI notifiers. check-in: 23ed19ff24 user: tinus tags: feature/rewrite-multi-async
Changes

Changes to src/Delphi10/VCSInfo_BPL.dproj.

201
202
203
204
205
206
207
208









209
210
211
212
213
214
215
...
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
                </DeployFile>
                <DeployFile LocalName="C:\Users\Public\Documents\Embarcadero\Studio\17.0\Bpl\VCSInfo_BPL.bpl" Configuration="Debug" Class="ProjectOutput">
                    <Platform Name="Win32">
                        <RemoteName>VCSInfo_BPL.bpl</RemoteName>
                        <Overwrite>true</Overwrite>
                    </Platform>
                </DeployFile>
                <DeployClass Name="ProjectiOSDeviceResourceRules"/>









                <DeployClass Name="ProjectOSXResource">
                    <Platform Name="OSX32">
                        <RemoteDir>Contents\Resources</RemoteDir>
                        <Operation>1</Operation>
                    </Platform>
                </DeployClass>
                <DeployClass Name="AndroidClassesDexFile">
................................................................................
                </DeployClass>
                <DeployClass Name="Android_LauncherIcon36">
                    <Platform Name="Android">
                        <RemoteDir>res\drawable-ldpi</RemoteDir>
                        <Operation>1</Operation>
                    </Platform>
                </DeployClass>
                <DeployClass Name="DependencyModule">
                    <Platform Name="Win32">
                        <Operation>0</Operation>
                        <Extensions>.dll;.bpl</Extensions>
                    </Platform>
                    <Platform Name="OSX32">
                        <Operation>1</Operation>
                        <Extensions>.dylib</Extensions>
                    </Platform>
                </DeployClass>
                <ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
                <ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
                <ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
                <ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
                <ProjectRoot Platform="OSX32" Name="$(PROJECTNAME)"/>
                <ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
                <ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>







|
>
>
>
>
>
>
>
>
>







 







|
<
<
<
<
<
<
<
<
<







201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
...
524
525
526
527
528
529
530
531









532
533
534
535
536
537
538
                </DeployFile>
                <DeployFile LocalName="C:\Users\Public\Documents\Embarcadero\Studio\17.0\Bpl\VCSInfo_BPL.bpl" Configuration="Debug" Class="ProjectOutput">
                    <Platform Name="Win32">
                        <RemoteName>VCSInfo_BPL.bpl</RemoteName>
                        <Overwrite>true</Overwrite>
                    </Platform>
                </DeployFile>
                <DeployClass Name="DependencyModule">
                    <Platform Name="Win32">
                        <Operation>0</Operation>
                        <Extensions>.dll;.bpl</Extensions>
                    </Platform>
                    <Platform Name="OSX32">
                        <Operation>1</Operation>
                        <Extensions>.dylib</Extensions>
                    </Platform>
                </DeployClass>
                <DeployClass Name="ProjectOSXResource">
                    <Platform Name="OSX32">
                        <RemoteDir>Contents\Resources</RemoteDir>
                        <Operation>1</Operation>
                    </Platform>
                </DeployClass>
                <DeployClass Name="AndroidClassesDexFile">
................................................................................
                </DeployClass>
                <DeployClass Name="Android_LauncherIcon36">
                    <Platform Name="Android">
                        <RemoteDir>res\drawable-ldpi</RemoteDir>
                        <Operation>1</Operation>
                    </Platform>
                </DeployClass>
                <DeployClass Name="ProjectiOSDeviceResourceRules"/>









                <ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
                <ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
                <ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
                <ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
                <ProjectRoot Platform="OSX32" Name="$(PROJECTNAME)"/>
                <ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
                <ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>

Changes to src/VCSInfoView.pas.

1
2
3
4
5
6
7
8
9
10


11



12
13
14
15
16
17
18
..
86
87
88
89
90
91
92

















93
94
95
96
97
98
99
...
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
...
165
166
167
168
169
170
171



172
173
174
175
176




177

178
179

180
181
182
183
184
185
186
unit VCSInfoView;

interface
uses
  ToolsAPI, System.Classes;

type
  TVCSInfoView = class(TNotifierObject,
                        IOTAIDENotifier, IOTAIDENotifier50, IOTAIDENotifier80,
                        IOTAModuleNotifier, IOTAModuleNotifier80, IOTAModuleNotifier90)


  public



    procedure LogMessage(const Text: string; const Args: array of const); overload;
    procedure LogMessage(const Text: string); overload;
  public
    { IOTAIDENotifier }

    { This procedure is called for many various file operations within the
      IDE }
................................................................................


implementation
uses
  System.SysUtils;

{ TVCSInfoView }


















procedure TVCSInfoView.LogMessage(const Text: string; const Args: array of const);
begin
  LogMessage(Format(Text, Args));
end;

procedure TVCSInfoView.LogMessage(const Text: string);
................................................................................
procedure TVCSInfoView.AfterCompile(Succeeded, IsCodeInsight: Boolean);
begin
end;

procedure TVCSInfoView.AfterCompile(const Project: IOTAProject; Succeeded, IsCodeInsight: Boolean);
begin
  if not IsCodeInsight then begin
    // TODO: update workdir status
  end;
end;

procedure TVCSInfoView.AfterCompile(Succeeded: Boolean);
begin
end;

procedure TVCSInfoView.AfterRename(const OldFileName, NewFileName: string);
begin
  // TODO: rename in VCS as well
  LogMessage('Renamed "%s" to "%s"', [OldFilename, NewFileName]);
end;

function TVCSInfoView.AllowSave: Boolean;
begin
  Result := True;
  // TODO: schedule to refresh the working dir in two seconds
  LogMessage('AllowSave: %d', [Ord(Result)]);
end;

procedure TVCSInfoView.BeforeCompile(const Project: IOTAProject; var Cancel: Boolean);
begin
end;

................................................................................
function TVCSInfoView.CheckOverwrite: Boolean;
begin
  Result := True;
end;

procedure TVCSInfoView.FileNotification(NotifyCode: TOTAFileNotification; const FileName: string;
  var Cancel: Boolean);



begin
  case NotifyCode of
    ofnFileOpened: begin
      // TODO: Reflect change in UI
      LogMessage('File opened: "%s"', [FileName]);




    end;

    ofnActiveProjectChanged: begin
      // TODO: Reflect change in UI (if necessary)

      LogMessage('Active project changed: "%s"', [FileName]);
    end;
  end;
end;

function TVCSInfoView.GetOverwriteFileName(Index: Integer): string;
begin




|





>
>

>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|









|






|







 







>
>
>



|

>
>
>
>
|
>

<
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
...
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208

209
210
211
212
213
214
215
216
unit VCSInfoView;

interface
uses
  ToolsAPI, System.Classes, System.Generics.Collections;

type
  TVCSInfoView = class(TNotifierObject,
                        IOTAIDENotifier, IOTAIDENotifier50, IOTAIDENotifier80,
                        IOTAModuleNotifier, IOTAModuleNotifier80, IOTAModuleNotifier90)
  private
    FModules: TDictionary<IOTAModule,Integer>;
  public
    constructor Create;
    destructor Destroy; override;

    procedure LogMessage(const Text: string; const Args: array of const); overload;
    procedure LogMessage(const Text: string); overload;
  public
    { IOTAIDENotifier }

    { This procedure is called for many various file operations within the
      IDE }
................................................................................


implementation
uses
  System.SysUtils;

{ TVCSInfoView }

constructor TVCSInfoView.Create;
begin
  inherited;
  FModules := TDictionary<IOTAModule,Integer>.Create;
end;

destructor TVCSInfoView.Destroy;
var
  Module: IOTAModule;
begin
  for Module in FModules.Keys do begin
    Module.RemoveNotifier(FModules.Items[Module]);
  end;
  FModules.Free;
  inherited;
end;

procedure TVCSInfoView.LogMessage(const Text: string; const Args: array of const);
begin
  LogMessage(Format(Text, Args));
end;

procedure TVCSInfoView.LogMessage(const Text: string);
................................................................................
procedure TVCSInfoView.AfterCompile(Succeeded, IsCodeInsight: Boolean);
begin
end;

procedure TVCSInfoView.AfterCompile(const Project: IOTAProject; Succeeded, IsCodeInsight: Boolean);
begin
  if not IsCodeInsight then begin
    {$MESSAGE WARN 'TODO: update workdir status'}
  end;
end;

procedure TVCSInfoView.AfterCompile(Succeeded: Boolean);
begin
end;

procedure TVCSInfoView.AfterRename(const OldFileName, NewFileName: string);
begin
  {$MESSAGE HINT 'TODO: rename in VCS as well'}
  LogMessage('Renamed "%s" to "%s"', [OldFilename, NewFileName]);
end;

function TVCSInfoView.AllowSave: Boolean;
begin
  Result := True;
  {$MESSAGE WARN 'TODO: (re)schedule to refresh the working dir in two seconds'}
  LogMessage('AllowSave: %d', [Ord(Result)]);
end;

procedure TVCSInfoView.BeforeCompile(const Project: IOTAProject; var Cancel: Boolean);
begin
end;

................................................................................
function TVCSInfoView.CheckOverwrite: Boolean;
begin
  Result := True;
end;

procedure TVCSInfoView.FileNotification(NotifyCode: TOTAFileNotification; const FileName: string;
  var Cancel: Boolean);
var
  NewModule: IOTAModule;
  Index: Integer;
begin
  case NotifyCode of
    ofnFileOpened: begin
      {$MESSAGE WARN 'TODO: (re)schedule to refresh the working dir in a second'}
      LogMessage('File opened: "%s"', [FileName]);
      NewModule := (BorlandIDEServices as IOTAModuleServices).FindModule(FileName);
      if Assigned(NewModule) then begin
        Index := NewModule.AddNotifier(Self);
        FModules.Add(NewModule, Index);
      end;
    end;
    ofnActiveProjectChanged: begin

      {$MESSAGE WARN 'TODO: (re)schedule to refresh the working dir in a second'}
      LogMessage('Active project changed: "%s"', [FileName]);
    end;
  end;
end;

function TVCSInfoView.GetOverwriteFileName(Index: Integer): string;
begin

Changes to src/VCSInfoWzrd.pas.

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{ ------------------------------------------------------------------------------------------------ }
{ TVCSInfoStatusWizard }

constructor TVCSInfoStatusWizard.Create;
begin
  FLogo := TBitmap.Create;
  FLogo.LoadFromResourceName(HInstance, 'BMP_LOGO');
  (BorlandIDEServices as IOTAAboutBoxServices).AddPluginInfo(rsWizardName, rsWizardName, FLogo.Handle,
                                                            False, 'Freeware');
  SplashScreenServices.AddPluginBitmap(rsWizardName, FLogo.Handle,
                                        False, 'Freeware');
  // TODO: set up cache (Model)
  // TODO: set up UI, including timer and notifiers (View)
  FView := TVCSInfoView.Create;
  (BorlandIDEServices as IOTAServices).AddNotifier(FView);
  // TODO: set up thread queue (Controller)
end;








|
|
|
|







34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{ ------------------------------------------------------------------------------------------------ }
{ TVCSInfoStatusWizard }

constructor TVCSInfoStatusWizard.Create;
begin
  FLogo := TBitmap.Create;
  FLogo.LoadFromResourceName(HInstance, 'BMP_LOGO');
  SplashScreenServices.AddPluginBitmap(rsWizardName, FLogo.Handle,
                                        False, 'Freeware');
  (BorlandIDEServices as IOTAAboutBoxServices).AddPluginInfo(rsWizardName, rsWizardName, FLogo.Handle,
                                                            False, 'Freeware');
  // TODO: set up cache (Model)
  // TODO: set up UI, including timer and notifiers (View)
  FView := TVCSInfoView.Create;
  (BorlandIDEServices as IOTAServices).AddNotifier(FView);
  // TODO: set up thread queue (Controller)
end;

Changes to todo.md.