unit Unit3;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ValEdit,
  Menus, StdCtrls;

type

  { TForm3 }

  TForm3 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    ComboBox1: TComboBox;
    Edit1: TEdit;
    Label1: TLabel;
    MenuItem1: TMenuItem;
    MenuItem2: TMenuItem;
    MenuItem3: TMenuItem;
    MenuItem4: TMenuItem;
    PopupMenu1: TPopupMenu;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    SelDirDialog1: TSelectDirectoryDialog;
    SelDirDialog2: TSelectDirectoryDialog;
    SelDirDialog3: TSelectDirectoryDialog;
    ValueListEditor1: TValueListEditor;
    procedure Button1Click(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure MenuItem1Click(Sender: TObject);
    procedure MenuItem2Click(Sender: TObject);
    procedure MenuItem3Click(Sender: TObject);
    procedure MenuItem4Click(Sender: TObject);
    procedure RadioButton1Click(Sender: TObject);
  private

  public

  end;

var
  Form3: TForm3;
  list: TStringList;
implementation
   Uses unit1;
{$R *.lfm}

{ TForm3 }

procedure TForm3.FormCreate(Sender: TObject);
begin
  Form3.ValueListEditor1.Values['JDK']:=DirJDK;
  //Form3.ValueListEditor1.Values['FX']:=DirFX;
  //Form3.ValueListEditor1.Values['JDK8']:=DirJDK8;
end;

procedure TForm3.Button1Click(Sender: TObject);
begin
  close;
end;

procedure TForm3.ComboBox1Change(Sender: TObject);
begin
  Edit1.Text:=ComboBox1.Items.Strings[ComboBox1.ItemIndex];
end;

procedure TForm3.FormActivate(Sender: TObject);
begin
  if DirJDK = '' then Form3.RadioButton1.Checked:=true
    else Form3.RadioButton2.Checked:=true;
 Edit1.Text:= terminal;
end;

procedure TForm3.MenuItem1Click(Sender: TObject);
begin
   SelDirDialog1.InitialDir:=unit1.Dirpro;
   if SelDirDialog1.Execute then
  begin
   ValueListEditor1.Values['JDK'] := SelDirDialog1.FileName;
   DirJDK := ValueListEditor1.Values['JDK'];
  end;
    ValueListEditor1.Refresh;
end;

procedure TForm3.MenuItem2Click(Sender: TObject);
begin
   SelDirDialog1.InitialDir:=unit1.Dirpro;
   if SelDirDialog2.Execute then
  begin
   ValueListEditor1.Values['FX'] := SelDirDialog2.FileName;
   DirFX := ValueListEditor1.Values['FX'];
  end;
    ValueListEditor1.Refresh;
end;

procedure TForm3.MenuItem3Click(Sender: TObject);
begin
  list := TStringList.Create;
  list.Clear;
  list.Add(ValueListEditor1.Values['JDK']);
  //list.Add(ValueListEditor1.Values['FX']);
  //list.Add(ValueListEditor1.Values['JDK8']);
  terminal:=Edit1.Text;
  Form1.ProcessUTF8_2.XTermProgram:=terminal;
  list.Add(terminal);
  list.SaveToFile(ExtractFileDir(pr_path) + st_p + 'jdk.ini');

  close;
end;

procedure TForm3.MenuItem4Click(Sender: TObject);
begin
  SelDirDialog3.InitialDir:=unit1.Dirpro;
  if SelDirDialog3.Execute then
 begin
  ValueListEditor1.Values['JDK8'] := SelDirDialog3.FileName;
  DirJDK8 := ValueListEditor1.Values['JDK8'];
 end;
   ValueListEditor1.Refresh
end;

procedure TForm3.RadioButton1Click(Sender: TObject);
begin
    DirJDK := '';
    ValueListEditor1.Values['JDK'] := DirJDK;
end;

end.

