/* Copyright (C) 2002 ITK Author : Uri (uri@itk.ru) License : (GPL) http://www.itk.ru/clipper/license.html */ #include "config.ch" #include "inkey.ch" #include "imenu.ch" #include "set.ch" #include "box.ch" ************************************************ procedure abNew(par1,par2) local obj:=map() setcolor(set("ab_colors")) clear screen obj:classname := "AB_DBU" obj:winNo := 0 obj:maxrow := maxrow() obj:maxcol := maxcol() obj:mapkeys := HK_get("ab") obj:dictArray := NIL obj:dictionary := NIL obj:depository := NIL obj:browse := NIL obj:__statusLine:= [Esc-menu F1-help F2-add F3-card F4-edit F8-delete F10-closeWin] ***** obj:HandleKey := @HandleKey() obj:statusLine := @statusLine() obj:quit := @ab_quit() obj:openDict := @ab_openDict() obj:openOqlQuery:= @ab_openOqlQuery() obj:editDict := @ab_editDict() obj:openDeposit := @ab_openDeposit() obj:menu := make_ab_menu(obj) if !empty(par1) if len(par1)==codb_info("DICT_ID_LEN") obj:dictionary := coDictionary():new(par1) if !empty(obj:dictionary:error) alert(obj:dictionary:error) obj:dictionary:close() obj:dictionary:=NIL else obj:dictionary:open() if !empty(obj:dictionary:error) alert(obj:dictionary:error) obj:dictionary:close() obj:dictionary:=NIL else obj:menu:enableMeta() endif endif else obj:depository := coDepository():new(par1) if !empty(obj:Depository:error) alert(obj:Depository:error) obj:Depository:close() obj:Depository:=NIL else obj:Depository:open() if !empty(obj:Depository:error) alert(obj:dictionary:error) obj:Depository:close() obj:Depository:=NIL else obj:dictionary:=obj:depository:dictionary() obj:menu:enableMeta() obj:menu:enableData() endif endif endif endif ab_sayCopyRight() obj:statusLine() obj:handleKey(0) return obj ************************************************ static function ab_sayCopyRight() @ 2,50, 8,maxcol() box B_DOUBLE+" " @ 3,52 say "Object DB Utility" @ 4,52 say "(C) ITK, 2002" @ 5,52 say "Author: Uri V. Hnykin" @ 6,52 say "Licence: GPL" @ 7,52 say "Home: www.itk.ru" return ************************************************ static function ab_quit() return otvet("Exit from object base utility ?") ************************************************ static function statusLine(str) local oldwin:=wselect(),ret static old_st:="" ret:=old_st str:=iif(str==NIL,::__statusLine,str) old_st:=str wselect(::winNo) @ ::maxrow,0 say padr(str,::maxcol) color set("ab_colors_menu") wselect(oldwin) return ret ********************************************* static function ab_openOqlQuery() local scr:=savescreen(),idList local getlist:={},pic:="@S35" local x1:=6,y1:=10,x2,y2 local sSelect := padr("currency",50), sFrom:=padr("GBL0101",50) local sWhere := space(150) x2:=x1+12; y2:=y1+60 @ x1,y1,x2,y2 box B_DOUBLE+" " @ x1, y1+3 say [Please fill data for query] @ x1+1 , y1+1 say [Select...] get sSelect picture pic @ x1+2 , y1+1 say [From ] get sFrom picture pic @ x1+3 , y1+1 say [Where ........] get sWhere picture pic read restore screen from scr if lastkey()==27 return NIL endif if ::browse!=NIL ::browse:close() ::menu:enableChoice() ::browse:=NIL endif idList := codb_oql_select(alltrim(sSelect), alltrim(sFrom), alltrim(sWhere) ) if !empty(idList:error) alert(idList:error) idlist:close() return endif dispbegin() ::browse := ab_make_data_browse(::depository,sSelect,idList) dispend() if empty(::browse:error) else alert(::browse:error) ::browse:close() ::browse:=NIL endif return ********************************************* static function ab_openDict() local i,scr,m,mlen:=0,vlen:=0,newDict:=NIL,x1,x2,y1,y2 local tmp,new:=.f. if ::dictArray==NIL ::dictArray:=codbList():new() if val(::dictArray:error)>0 alert([Error open dictionary list!]+";"+::dictArray:error) ::dictArray:close() return endif endif m:=::dictArray:list() aadd(m,[Create new dictionary ]) for i=1 to len(m) mlen:=max(mlen,len(m[i])) next mlen:=min(mlen,maxcol()-8) mlen+=2 x1:=int((maxcol()-mlen)/2) x2:=maxcol()-x1 vlen:=min(len(m)+1,maxrow()-6) vlen:=int(max(vlen,maxrow()/4)) y1:=int((maxrow()-vlen)/2) y2:=maxrow()-y1 scr:=savescreen(y1,x1,y2+2,x2+2) i=achoice(y1,x1,y2,x2,m,,,1,1,,B_DOUBLE,[Choice Dictionary]) restscreen(y1,x1,y2+2,x2+2,scr) if i==0 return .f. endif x1:=""; x2:="" if i>0 .and. i 0 dispbegin() if ::browse!=NIL ::browse:close() ::browse:=NIL endif ::browse := ab_make_meta_browse(::dictionary,vMeta[vKey]) dispend() if !empty(::browse:error) alert(::browse:error) ::browse:close() ::browse:=NIL endif hkey:=0 endif if hkey!=0 if ::browse!=NIL hkey:=::browse:handleKey(hKey) if hKey == NIL ::browse := NIL hkey := 0 endif if hKey==0 return ret endif endif endif if hKey==HASH_Exit if ::quit() ret:=0 endif nkey:=0 endif s:="" if ::dictionary!=NIL s:=s+[Dictionary:]+alltrim(::dictionary:name)+space(5) endif if ::depository!=NIL s:=s+[Depository:]+alltrim(::depository:name)+space(5) endif @ maxrow()-1, 0 say padr(s,maxcol()+1) color "14/b" return ret