Ignore:
Timestamp:
Mar 12, 2012, 10:23:40 AM (12 years ago)
Author:
chronos
Message:
  • Modified: TChronisBase.Active property control Client connection instead of direct call of Client.Connect and Client.Disconnect methods.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r44 r45  
    6161    Splitter1: TSplitter;
    6262    StatusBar1: TStatusBar;
     63    ToolBar1: TToolBar;
     64    ToolButton1: TToolButton;
     65    ToolButton2: TToolButton;
     66    ToolButton3: TToolButton;
     67    ToolButton4: TToolButton;
     68    ToolButton5: TToolButton;
    6369    TreeView1: TTreeView;
    6470    procedure AAboutExecute(Sender: TObject);
     
    6975    procedure AObjectEditExecute(Sender: TObject);
    7076    procedure AObjectGroupAddGroupExecute(Sender: TObject);
     77    procedure AObjectGroupDeleteExecute(Sender: TObject);
    7178    procedure AObjectGroupEditExecute(Sender: TObject);
    7279    procedure ASettingsExecute(Sender: TObject);
     
    154161
    155162procedure TMainForm.UpdateInterface;
    156 begin
    157   ADisconnect.Enabled := Assigned(Core.Client) and Core.Client.Connected;
    158   AConnect.Enabled := Assigned(Core.Client) and not Core.Client.Connected;
    159   AImportStructure.Enabled := Assigned(Core.Client) and Core.Client.Connected;
     163var
     164  I: Integer;
     165begin
     166  ADisconnect.Enabled := Core.System.Active;
     167  AConnect.Enabled := not Core.System.Active;
     168  AImportStructure.Enabled := Core.System.Active;
    160169  if Assigned(MainPanelForm) then
    161170    Caption := MainPanelForm.Caption + ' - ' + ApplicationInfo.Name
    162171    else Caption := ApplicationInfo.Name;
    163172  Application.Title := Caption;
    164   if Assigned(Core.Client) then
    165   with Core.Client do
     173  if Core.System.Active then
     174  with Core.System.Client do
    166175    StatusBar1.Panels[0].Text := User + '@' + Host + ':' + IntToStr(Port) + '/' + Schema;
     176
     177  for I := 0 to ToolBar1.ButtonCount - 1 do
     178    ToolBar1.Buttons[I].Hint := ToolBar1.Buttons[I].Caption;
    167179end;
    168180
     
    201213
    202214procedure TMainForm.AObjectGroupAddGroupExecute(Sender: TObject);
     215begin
     216
     217end;
     218
     219procedure TMainForm.AObjectGroupDeleteExecute(Sender: TObject);
    203220begin
    204221
     
    270287  try
    271288    LoginForm := TLoginForm.Create(MainForm);
    272   Core.Profiles.LoadFromRegistry(Core.RegistryRootKey, Core.RegistryKey);
    273   if LoginForm.ShowModal = mrOK then begin
    274     with TConnectProfile(Core.Profiles[Core.LastProfile]) do begin
    275       FreeAndNil(Core.Client);
    276       if Protocol = cpMySQL then Core.Client := TChronisClientMySQL.Create
    277         else if Protocol = cpDirect then Core.Client := TChronisClientDirect.Create
    278         else if Protocol = cpXMLRPC then Core.Client := TChronisClientXMLRPC.Create;
    279       Core.System.Client := Core.Client;
    280       Core.System.Client.Host := HostName;
    281       Core.System.Client.Schema := Database;
    282       Core.System.Client.User := Core.LastUserName;
    283       Core.System.Client.Password := Core.LastPassword;
    284       Core.System.Client.Port := Port;
     289    Core.Profiles.LoadFromRegistry(Core.RegistryRootKey, Core.RegistryKey);
     290    if LoginForm.ShowModal = mrOK then begin
     291      with TConnectProfile(Core.Profiles[Core.LastProfile]) do begin
     292        FreeAndNil(Core.System.Client);
     293        if Protocol = cpMySQL then Core.System.Client := TChronisClientMySQL.Create
     294          else if Protocol = cpDirect then Core.System.Client := TChronisClientDirect.Create
     295          else if Protocol = cpXMLRPC then Core.System.Client := TChronisClientXMLRPC.Create;
     296        Core.System.Client.Host := HostName;
     297        Core.System.Client.Schema := Database;
     298        Core.System.Client.User := Core.LastUserName;
     299        Core.System.Client.Password := Core.LastPassword;
     300        Core.System.Client.Port := Port;
     301      end;
     302      try
     303        Core.System.Active := True;
     304        LoadTree;
     305      except
     306        on E: Exception do ShowMessage(E.Message);
     307      end;
    285308    end;
    286     try
    287       Core.System.Client.Connect;
    288       if Core.System.IsDatabaseEmpty then Core.System.ModuleSystem.Install;
    289       Core.System.LoadTypes;
    290       LoadTree;
    291       UpdateInterface;
    292     except
    293       on E: Exception do ShowMessage(E.Message);
    294     end;
    295   end;
    296309  finally
    297310    LoginForm.Free;
     311    UpdateInterface;
    298312  end;
    299313end;
     
    302316begin
    303317  if Assigned(Core.System.Client) then
    304   if Core.System.Client.Connected then begin
    305     Core.System.Client.Disconnect;
     318  if Core.System.Active then begin
     319    Core.System.Active := False;
    306320    TreeView1.Items.Clear;
    307     Core.System.Types.Clear;
    308     FreeAndNil(Core.Client);
    309     Core.System.Client := Core.Client;
    310321  end;
    311322  UpdateInterface;
Note: See TracChangeset for help on using the changeset viewer.