From: Andrey C. <sku...@us...> - 2006-11-03 16:32:19
|
Update of /cvsroot/eas-dev/ocmng/EAS/forms In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv6950/EAS/forms Added Files: create.xpm delete.xpm edit.xpm form.prg form.xml form_action.xml form_localization.xml form_menu.prg form_menu.xml form_service.xml Log Message: Move all components to top level. Remove ocmng and xml2xmo sources. Add components: - dbconsole - form_menu, form_action and form_localization for menu generation - update form component for generation menu --- NEW FILE: create.xpm --- /* XPM */ static char * item_new_xpm[] = { "16 16 31 1", " c None", ". c #6238B6", "+ c #F5E15E", "@ c #183196", "# c #A29EF6", "$ c #C0C000", "% c #152C89", "& c #173093", "* c #000000", "= c #5933A6", "- c #FFFF85", "; c #968200", "> c #FFFFFF", ", c #E1E1E1", "' c #CECECE", ") c #FFFFC0", "! c #FFFF00", "~ c #777777", "{ c #5B5B5B", "] c #C1C1C1", "^ c #010101", "/ c #CDCDCD", "( c #6D6D6D", "_ c #3F3F3F", ": c #E9E9E9", "< c #4A4A4A", "[ c #5F5F5F", "} c #5C5C5C", "| c #838383", "1 c #FAFAFA", "2 c #F9F9F9", " ", " ", " ", " ........... ", " .+@##@@$%&$**$ ", " .......=-;-;-* ", " .>>>>>,';)!);* ", " .>~~~>{$-!>!-$ ", " .>>>>>,];)!);* ", " .>^^^^^*-;-;-* ", " .>^>>>>$/($_*$ ", " ..^>~~~:<[}|* ", " ^>>>>1:12:* ", " ^^^^^^^^^^^ ", " ", " "}; --- NEW FILE: delete.xpm --- /* XPM */ static char * item_delete_xpm[] = { "16 16 25 1", " c None", ". c #6238B6", "+ c #F5E15E", "@ c #183196", "# c #A29EF6", "$ c #382069", "% c #C91B33", "& c #43267D", "* c #6036B2", "= c #FFFFFF", "- c #3C2270", "; c #777777", "> c #525252", ", c #000000", "' c #FAFAFA", ") c #9D9D9D", "! c #010101", "~ c #3F3F3F", "{ c #E9E9E9", "] c #202020", "^ c #303030", "/ c #B1B1B1", "( c #CDCDCD", "_ c #838383", ": c #F4F4F4", " ", " ", " ", " ........... ", " .+@##@@@@@. ", " .......$%&* % ", " .======%%%-%%% ", " .=;;;=;>%%%%%, ", " .======')%%%,, ", " .=!!!!!!%%%%% ", " .=!====%%%~%%% ", " ..!=;;;{%]^/%, ", " !===='(_(:, ", " !!!!!!,,,!, ", " ", " "}; --- NEW FILE: edit.xpm --- /* XPM */ static char * edit_xpm[] = { "16 16 19 1", " c None", ". c #6238B6", "+ c #7F4978", "@ c #F5E15E", "# c #183196", "$ c #A29EF6", "% c #FFA1F3", "& c #FFFFFF", "* c #000000", "= c #777777", "- c #010101", "; c #ADADAD", "> c #FBFBFB", ", c #010000", "' c #707070", ") c #494949", "! c #5B5B5B", "~ c #545454", "{ c #F9F9F9", " ", " ", " ", " ........... + ", " .@#$$#####.+%+ ", " ..........+%+%+", " .&&&&&&&&+%+%+*", " .&===&==+%+%+* ", " .&&&&&&+++%+* ", " .&----*;>++** ", " .&-&&&;,'+);* ", " ..-&==,'!~'&* ", " -&&&&&&&&{- ", " ----****--- ", " ", " "}; --- NEW FILE: form.prg --- /*-------------------------------------------------------------------------*/ /* E/AS Component (part of E/AS project) */ /* */ /* Copyright (C) 2005 by E/AS Software Foundation */ /* Author: Andrey Cherepanov <sk...@ea...> */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as */ /* published by the Free Software Foundation; either version 2 of the */ /* License, or (at your option) any later version. */ /*-------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------/ / / / Name: UI form center / / System name: form / / Description: Get UI form for object / / Version: 0.1 / / Author: Andrey Cherepanov <sk...@ea...> / / / / Available commands: / / GET Get form content / / <name> form name / / [<type>] type of form (optional) / / object get the XFL form for edit object content / / list get the XFL form with list of objects / / select get the XFL form for select object from list / / print_object get the XPL card for object / / print_list get the XPL form for print object list / / / / GETVIEW Get object with view (object list) / / <name> view name / / / /--------------------------------------------------------------------------*/ /** Component: form */ #define DEFAULT_TITLE_MAIN_WINDOW 'E/AS' #define DEFAULT_FORM_DB 'ETC0101' #define DEFAULT_FORM_CLASS 'mng_form' #define DEFAULT_ENCODING 'koi8-r' parameters cMethod, params local cContent:='' local oErr, i, err:='', view eDebug(12, "FORM method:", cMethod) oErr := ErrorBlock({|e| break(e) }) begin sequence /*=========================================================================*/ // GET() if lower(cMethod) == 'get' if assertParameters( params, { 'name:C' } ) return NIL endif eDebug(15, "FORM args:", params) // Check if form exist in database and return it if (cContent:=get_StoredForm(params)) != NIL return cContent else cContent := '' endif if 'TYPE' $ params if params:type == 'list' cContent := get_UIList(params) elseif params:type == 'object' cContent := get_UIObject(params) endif else if params:name == 'main' cContent := get_MainForm(params) else eDebug(5, "FORM: Unknown file:", params:name) // TODO: dialog box for unknown form cContent := NIL endif endif return cContent /*=========================================================================*/ // GETVIEW() elseif lower(cMethod) == 'getview' view := get_View(params) eDebug( 17, "FORM.getView:", view:data ) return view else eDebug(3, "FORM has not method '"+cMethod+"'") endif recover using oErr i := 1 while ( !empty(ProcName(i)) ) err += "Called from "+allTrim(ProcName(i)) + ; ":" + alltrim(str(ProcLine(i))) + chr(10) i++ end eDebug(5, "FORM component internal error:", errorMessage(oErr)) return NIL end sequence return NIL /* Generate main window */ static function get_MainForm(params) local f:='', title:=DEFAULT_TITLE_MAIN_WINDOW, l, i, ent, aIgnoreClasses local deps, edep, dep, list_all:={}, m title += " " + EASGetVersion() f := '<?xml version="1.0" encoding="'+DEFAULT_ENCODING+'" ?>&\n' + ; '<!-- Main window interface form -->&\n' + ; '<!-- Web: http://eas.lrn.ru -->&\n&\n' + ; ; '<form>&\n' + ; '<head>&\n' + ; '</head>&\n' + ; '<interface>&\n' + ; '<widget class="mainWindow" name="mainWindow" label="'+title+'">&\n&\n' + ; ; ' <!-- Menu -->&\n' m := lcomponent('form_menu', 'generate') if valtype(m) == 'C' // Generate menu from component form_menu f += m else // Generate from available class names f += '<widget class="menuBar">&\n' f += ' <widget class="popupMenu" name="file_menu" label="&Databases">&\n' + ; ' <msg lang="ru" id="&Databases" value="&äÁÎÎÙÅ" />&\n' // Show classes aIgnoreClasses := { "void" } // TODO: get from configuration file deps := lquery(params, 'show databases') asort(deps,,,{|a,b| a[1] < b[1]}) for edep in deps dep := edep[1] params:db := dep l := lquery(params, 'show classes') i := 1 while i <= len(l) if ascan(aIgnoreClasses, lower(l[i][2])) != 0 adel( l, i ) asize( l, len(l)-1 ) endif i++ enddo eDebug(12, 'FORM', dep, ':', len(l), 'class(es)' ) if len(l) == 0 loop endif f += '&\t<widget class="popupMenu" label="'+dep+'">&\n' if valtype(l) == 'A' asort(l,,,{|a,b| a[2] < b[2]}) for i in l f += '&\t&\t<widget class="menuItem" label="'+i[2]+'" name="'+dep+':'+i[2]+'.list"/>&\n' aadd( list_all, dep+':'+i[2] ) next endif f += '&\t</widget>&\n' next eDebug(12, 'FORM: finish append classes' ) f += ' <widget class="menuSeparator"/>&\n' + ; ' <widget class="menuItem" label="&Exit" name="Menu.Quit">&\n' + ; ' <msg lang="ru" id="&Exit" value="÷&ÙÈÏÄ" />&\n' + ; ' <rule>&\n' + ; ' <event widget="Menu.Quit" signal="activate"/>&\n' + ; ' <action><call widget="mainWindow" method="close"/></action>&\n' + ; ' </rule>&\n' + ; ' </widget>&\n' + ; ' </widget>&\n' + ; '</widget>&\n&\n' endif f += ' <!-- Statusbar -->&\n' + ; ' <widget class="statusBar" name="main_statusBar" label="Done.">&\n' + ; ' <msg lang="ru" id="Done." value="çÏÔÏ×Ï." />&\n' + ; ' </widget>&\n' + ; ; '</widget>&\n' + ; '</interface>&\n&\n' + ; ; '<!-- Widgets properties -->&\n' + ; '<style>&\n' + ; ' <property widget="mainWindow" name="geometry" value="600,450,35,15" />&\n' + ; ' <property widget="mainWindow" name="position" value="center" />&\n' + ; ' <property widget="mainWindow" name="MDI" value="true" />&\n' + ; '</style>&\n&\n' f += '<actions>&\n' + ; ' <!-- System actions -->&\n' // Actions for i in list_all f += '<rule>&\n' f += ' <event widget="'+i+'.list" signal="activate"/>&\n' f += ' <action><call method="openForm"><param value="'+i+'"/><param value="list"/>' f += '</call></action>&\n' f += '</rule>&\n' next f += '</actions>&\n' + ; '</form>&\n' eDebug(15, "FORM getMainForm:", len(f)) return f // Generate form with list of all class object static function get_UIList(params) local f, ent:=params:name, fields, i, pclass f := '<?xml version="1.0" encoding="'+DEFAULT_ENCODING+'" ?>&\n' + ; '<!-- '+ent+' list form -->&\n' + ; '<!-- Web: http://eas.lrn.ru -->&\n&\n' + ; ; '<form>&\n' + ; ' <head>&\n' + ; // TODO: fill table with autoreloading (see openView() ) ' <call method="openView">&\n' + ; ' <param><property widget="list" name="object"/></param>&\n' + ; ' <param value="'+ent+'"/>&\n' + ; ' <param value="60" />&\n' + ; // 60 seconds by default ' <param><property widget="__form" name="object"/></param>&\n' + ; ' </call>&\n' + ; ' </head>&\n' + ; ' <interface>&\n' + ; ' <widget class="childWindow" name="__form" label="'+ent+' list">&\n&\n' + ; ; ' <!-- Toolbar -->&\n' + ; ' <widget class="toolBar" name="main_tbar">&\n' + ; ; ' <widget name="create" class="toolButton" label="New">&\n' + ; ' <property name="icon" value="create.xpm"/>&\n' + ; ' </widget>&\n' + ; ' <widget name="edit" class="toolButton" label="Edit">&\n' + ; ' <property name="icon" value="edit.xpm"/>&\n' + ; ' </widget>&\n' + ; ' <widget name="delete" class="toolButton" label="Delete">&\n' + ; ' <property name="icon" value="delete.xpm"/>&\n' + ; ' </widget>&\n' + ; ' </widget>&\n' + ; ; ' <widget name="list" class="table">&\n' pclass := form_splitClass( ent ) params:db := pclass[1] fields := lquery(params, 'describe '+pclass[2]) if valtype(fields) == 'A' for i in fields if i[2] $ 'CNDLXRS' .and. i[1] != 'id' f += ' <column name="'+i[1]+'" title="'+i[1]+'"/>&\n' endif next endif f += ' </widget>&\n' + ; ' <widget class="buttonBar">&\n' + ; ' <widget class="button" label="&Close" name="close" />&\n' + ; ' </widget>&\n' + ; ' </widget>&\n' + ; ' </interface>&\n&\n' + ; ' <style>&\n' + ; ' </style>&\n&\n' + ; ' <actions>&\n' + ; ; ' <rule label="&Create">&\n' + ; ' <event widget="create" signal="clicked"/>&\n' + ; ' <action><call method="openForm"><param value="'+ent+'"/><param value="object"/>&\n' + ; ' </call></action></rule>&\n' + ; ; ' <rule label="&Edit">&\n' + ; ' <event widget="edit" signal="clicked"/>&\n' + ; ' <event widget="list" signal="selected"/>&\n' + ; ' <action><call method="openForm"><param value="'+ent+'"/><param value="object"/>' + ; ' <param><call widget="list" method="getSelectionId"/></param>&\n' + ; ' </call></action></rule>&\n' + ; ; ' <rule label="&Delete...">&\n' + ; ' <event widget="delete" signal="clicked"/>&\n' + ; ' <action>&\n' + ; ' <call widget="__form" method="dialogBox">&\n' + ; ' <param value="Confirmation"/>&\n' + ; ' <param value="Delete item?"/>&\n' f += ' <param value="'+"'"+'&Delete'+"','"+'&Cancel'+"'"+'"/>&\n' f += ' <return>&\n' + ; ' <condition>&\n' + ; ' <param><returnedvalue /></param>&\n' + ; ' <case value="true">&\n' + ; ' <call method="deleteObject">&\n' + ; ' <param><call widget="list" method="getSelectionId"/></param>&\n' + ; ' </call>&\n' + ; ' <call method="openView">&\n' + ; ' <param><property widget="list" name="object"/></param>&\n' + ; ' <param value="'+ent+'"/>&\n' + ; ' </call>&\n' + ; ' </case>&\n' + ; ' </condition>&\n' + ; ' </return>' + ; ' </call>&\n' + ; ' </action>&\n' + ; ' </rule>&\n' f += ' <rule label="-C&lose">&\n' + ; ' <event widget="close" signal="clicked"/>&\n' + ; ' <action><call widget="__form" method="close"/></action>&\n' + ; ' </rule>&\n' + ; ' </actions>&\n' + ; '</form>' return f /* Lookup form in database */ static function get_StoredForm(params) local fClass, fName, r, c:=NIL, id, appendix:='' local q, fType:='', types:={ 'list', 'object' } fClass := DEFAULT_FORM_CLASS fName := params:name if fName[6] == ':' fName := substr( fName, 7 ) endif // list, object if "TYPE" $ params .and. ascan( types, {|e| e==params:type } ) > 0 fName := fName + '.' + params:type endif q := 'select content from ' + fClass + ' where name=="' + fName + '"' r := lquery(params, q) if valtype(r) == 'A' .and. len(r) > 0 c := r[1][1] eDebug(15, "FORM:",fName,len(c)) endif return c /* Get filled view for table */ // TODO: using TVIEW if exists static function get_View(params) local query, a if assertParameters( params, { 'name:C', 'fields:C' } ) return NIL endif a := form_splitClass( params:name ) query := 'select '+params:fields+' from '+a[2] return lcomponent('sys.db', 'executeExt', 'db', a[1], 'query', query) /* Generate visial form for show class object */ static function get_UIObject(params) local class:=params:name, f:="", attr, i, a, t, name, chooseElem:={}, pclass pclass := form_splitClass( class ) params:db := pclass[1] /* XML head */ f += '<?xml version="1.0" encoding="'+DEFAULT_ENCODING+'" ?>&\n' f += '<!-- "'+class+'" dialog interface form -->&\n&\n' /* Form head */ f += '<form>&\n<head>' + ; ' <class name="'+class+'"/>&\n' + ; ' <call method="setFormObject"><param><property widget="__form" name="object"/></param></call>&\n'+ ; '</head>&\n' /* Interface definition */ f += '<interface>&\n' f += '<widget class="document" name="__form" label="'+pclass[2]+'">&\n'+ ; '<widget name="title" class="label" label="'+pclass[2]+'"/>&\n' // Get fields list attr := lquery(params, 'describe '+pclass[2]) if valtype(attr) != 'A' attr := array(0) endif // eDebug(5, "ATTR:",var2log(attr,3,.T.)) if len(attr) > 0 f += '<widget class="grid">&\n'+ ; ' <property name="cols" value="2"/>&\n'+ ; ' <property name="rows" value="'+alltrim(str(len(attr)))+'"/>&\n' endif // Add fields by type for i=1 to len(attr) a := attr[i] name := a[1] if name == 'id' loop endif t := a[2] switch t case 'L' f += ' <widget class="checkbox" name="'+name+'" pos="'+alltrim(str(i))+',1-2+" label="&'+name+'"/>&\n' case 'D' f += ' <widget class="label" pos="'+alltrim(str(i))+',1" label="&'+name+':" accel="'+name+'"/>&\n' f += ' <widget class="editdate" name="'+name+':date" pos="'+alltrim(str(i))+',2+" />&\n' case 'N' f += ' <widget class="label" pos="'+alltrim(str(i))+',1" label="&'+name+':" accel="'+name+'"/>&\n' f += ' <widget class="edit" name="'+name+':number" pos="'+alltrim(str(i))+',2+" />&\n' case 'M' f += ' <widget class="label" pos="'+alltrim(str(i))+',1" label="&'+name+':" accel="'+name+'"/>&\n' f += ' <widget class="edittext" name="'+name+'" pos="'+alltrim(str(i))+'+,2+" />&\n' // TODO: widget for choosing object with button // case 'R' // f += ' <widget class="label" pos="'+alltrim(str(i))+',1" label="&'+name+'" accel="'+name+"_choose"+'"/>&\n' // f += ' <widget class="edit" name="'+name+'" pos="'+alltrim(str(i))+',2" />&\n' // TODO: file uploading for blob otherwise f += ' <widget class="label" pos="'+alltrim(str(i))+',1" label="&'+name+':" accel="'+name+'"/>&\n' f += ' <widget class="edit" name="'+name+'" pos="'+alltrim(str(i))+',2+" />&\n' endswitch next if len(attr) > 0 f += '</widget>&\n' endif // Bottom bar f += '<widget class="buttonBar">&\n'+ ; ' <widget class="button" label="&Ok" name="save" />&\n' ' <widget class="button" label="&Print" name="print" />&\n'+ ; f += ' <widget class="button" label="&Close" name="close" />&\n'+ ; '</widget>&\n'+ ; '</widget>&\n' // Footer f += '</interface>&\n' f += '<!-- Widget properties -->&\n'+ ; '<style>&\n'+ ; ' <property widget="__form" name="spacing" value="2"/>&\n'+ ; ' <property widget="title" name="font.style" value="BOLD"/>&\n'+ ; ' <property widget="title" name="font.size" value="+2"/>&\n'+ ; '</style>&\n' f += '<!-- Actions -->&\n'+ ; '<actions>&\n'+ ; ' <rule label="&OK">&\n'+ ; ' <event widget="save" signal="clicked"/>&\n'+ ; ' <action>&\n'+ ; ' <call method="saveForm"><param><property widget="__form" name="object"/></param><param value="'+class+'" /></call>&\n'+ ; ' <call widget="__form" method="close"/>&\n'+ ; ' </action>&\n'+ ; ' </rule>&\n'+ ; ' <rule label="-&Close">&\n'+ ; ' <event widget="close" signal="clicked"/>&\n'+ ; ' <action>&\n'+ ; ' <call method="dialogBoxConfirmClose"><param><property widget="__form" name="object"/></param><param value="'+class+'" /></call>&\n'+ ; ' </action>&\n'+ ; ' </rule>&\n' /* Add choose action (chooseElem)*/ /* <rule> <event widget="payer" signal="clicked"/> <action><call widget="__form" method="open"> <param value="Partner.Choice.xfl"/> <return> <call widget="payer" method="setValue"> <param><returnedvalue /></param> </call> <property widget="payer.name" name="label"> <call method="getObjectAttr"> <param><returnedvalue /></param> <param value="name"/> </call> </property> </return> </call></action> </rule> */ f += '</actions>&\n' f += '</form>' return f --- NEW FILE: form.xml --- <?xml version="1.0" encoding="koi8-r" standalone="no" ?> <component> <name>form</name> <category>Core/Interface</category> <version>0.1</version> <description>Interface and print form support: get from database or generate</description> <license>GNU/GPL</license> <created>2006-05-01</created> <modified>2006-10-18</modified> <requires> <dependence type="component">../../ocmng/component.xml</dependence> </requires> <author>Skull</author> <meta dictionary="ETC01"> <!-- mng_form --> <attribute name="name" type="string" lenType="rtrim" len="50" notNull="yes" notEmpty="yes" /> <attribute name="type" type="string" len="50" lenType="rtrim" /> <attribute name="content" type="text" lenType="alltrim" /> <index name="name" expression="name"/> <class name="mng_form" extent="component" essence="name" uniqueKey="name" attributes="name,type,description,content" indices="name" mainIdx="name" findAttrs="name" /> <!-- mng_command --> <attribute name="form" type="ref" len="12" refTo="ETC01:mng_form" lenType="ignore" /> <class name="mng_command" extent="component" essence="name" uniqueKey="name" attributes="name,component_name,form,description" indices="name,component_name" mainIdx="name" findAttrs="name" /> </meta> <data> <objects depository="ETC0101" class="mng_form"> <object> <attr name="name">form.po</attr> <attr name="type">application/x-clip-plugin</attr> <attr name="description">Form plugin</attr> <attr name="content">form.po</attr> </object> <object> <attr name="name">create.xpm</attr> <attr name="type">image/x-xpm</attr> <attr name="description">Create icon</attr> <attr name="content">create.xpm</attr> </object> <object> <attr name="name">edit.xpm</attr> <attr name="type">image/x-xpm</attr> <attr name="description">Edit icon</attr> <attr name="content">edit.xpm</attr> </object> <object> <attr name="name">delete.xpm</attr> <attr name="type">image/x-xpm</attr> <attr name="description">Delete icon</attr> <attr name="content">delete.xpm</attr> </object> </objects> <objects depository="ETC0101" class="mng_command"> <object> <attr name="name">get</attr> <attr name="component_name">form</attr> <attr name="form" refTo="ETC0101:mng_form">form.po</attr> <attr name="description"><![CDATA[Get/generate form. Arguments: name - String. Form name. type - String. Form type. Optional. Form types: object XFL form for edit object content list XFL form with list of objects select XFL form for select object from list print_object XPL card for object print_list XPL form for print object list Returns: String. Form contents.]]></attr> </object> <object> <attr name="name">getview</attr> <attr name="component_name">form</attr> <attr name="form" refTo="ETC0101:mng_form">form.po</attr> <attr name="description"><![CDATA[Get view content. Arguments: name - String. Class name. fields - String. Comma separated list of object fields. Returns: Array. View content.]]></attr> </object> </objects> </data> <locale lang="ru"> <name>form</name> <description>ðÏÄÄÅÒÖËÁ ÉÎÔÅÒÆÅÊÓÎÙÈ É ÐÅÞÁÔÎÙÈ ÆÏÒÍ: ÐÏÌÕÞÅÎÉÅ ÉÚ ÂÁÚÙ ÉÌÉ ÇÅÎÅÒÁÃÉÑ</description> </locale> </component> --- NEW FILE: form_action.xml --- <?xml version="1.0" encoding="koi8-r" standalone="no" ?> <component> <name>form_action</name> <category>Core/Interface</category> <version>0.1</version> <description>Support interface actions (for form generation)</description> <license>GNU/GPL</license> <created>2006-10-18</created> <modified>2006-10-26</modified> <requires> <dependence type="component">../../ocmng/ETC01.xml</dependence> </requires> <author>Skull</author> <meta dictionary="ETC01"> <!-- óÔÒÕËÔÕÒÁ ËÌÁÓÓÁ form_action: name ÉÍÑ menu_group ÇÒÕÐÐÁ ÍÅÎÀ toolbar_group ÇÒÕÐÐÁ ÐÁÎÅÌÉ ÉÎÓÔÒÕÍÅÎÔÏ× menu_name ÉÍÑ × ÍÅÎÀ tooltip ÐÏÄÓËÁÚËÁ icon ÚÎÁÞÏË shortcut ËÏÍÂÉÎÁÃÉÑ ËÌÁ×ÉÛ ÐÏ ÕÍÏÌÞÁÎÉÀ l10n_context ËÏÎÔÅËÓÔ ÄÌÑ ÐÅÒÅ×ÏÄÁ acl_context ËÏÎÔÅËÓÔ ÄÌÑ ÐÒÁ× ÄÏÓÔÕÐÁ action ÄÅÊÓÔ×ÉÅ --> <!-- form_action --> <attribute name="name" type="string" len="50" lenType="rtrim" notNull="yes" notEmpty="yes" /> <attribute name="menu_group" type="string" len="50" lenType="rtrim" /> <attribute name="toolbar_group" type="string" len="50" lenType="rtrim" /> <attribute name="menu_name" type="string" len="50" lenType="rtrim" /> <attribute name="tooltip" type="string" lenType="rtrim" /> <attribute name="icon" type="string" len="50" lenType="rtrim" /> <attribute name="shortcut" type="string" len="20" lenType="rtrim" /> <attribute name="l10n_context" type="string" len="50" lenType="rtrim" /> <attribute name="acl_context" type="string" len="50" lenType="rtrim" /> <attribute name="action" type="text" lenType="alltrim" /> <index name="name" expression="name"/> <index name="menu_group" expression="menu_group"/> <index name="toolbar_group" expression="toolbar_group"/> <class name="form_action" extent="form" essence="name" uniqueKey="name" attributes="name,menu_group,toolbar_group,menu_name,tooltip,icon,shortcut,l10n_context,acl_context,action" indices="name,menu_group,toolbar_group" mainIdx="name" findAttrs="name" /> </meta> <data> <objects depository="ETC0101" class="form_action"> <object> <attr name="name">file</attr> <attr name="menu_name">&File</attr> </object> <object> <attr name="name">exit</attr> <attr name="menu_name">&Exit</attr> <attr name="shortcut">Ctrl+Q</attr> <attr name="action"><![CDATA[<call method="applicationQuit" />]]></attr> </object> <object> <attr name="name">help</attr> <attr name="menu_name">&Help</attr> </object> <object> <attr name="name">about</attr> <attr name="menu_name">&About</attr> <attr name="action"><![CDATA[<call method="dialogAbout" />]]></attr> </object> </objects> </data> <locale lang="ru"> <name>form_action</name> <description>ðÏÄÄÅÒÖËÁ ÕÎÉÆÉÃÉÒÏ×ÁÎÎÙÈ ÄÅÊÓÔ×ÉÊ ÉÎÔÅÒÆÅÊÓÁ (ÄÌÑ ÇÅÎÅÒÁÃÉÉ ÆÏÒÍ)</description> </locale> </component> --- NEW FILE: form_localization.xml --- <?xml version="1.0" encoding="koi8-r" standalone="no" ?> <component> <name>form_localization</name> <category>Core/Interface</category> <version>0.1</version> <description>Interface localization</description> <license>GNU/GPL</license> <created>2006-10-21</created> <modified>2006-10-26</modified> <requires> <dependence type="component">../../ocmng/ETC01.xml</dependence> </requires> <author>Skull</author> <meta dictionary="ETC01"> <!-- óÔÒÕËÔÕÒÁ ËÌÁÓÓÁ form_localization: lang ÑÚÙË context ËÏÎÔÅËÓÔ action_parent id ÄÅÊÓÔ×ÉÑ msgid ÏÒÉÇÉÎÁÌØÎÁÑ ÓÔÒÏËÁ msgstr ÐÅÒÅ×ÏÄ fuzzy ÆÌÁÇ ÞÅÒÎÏ×ÏÇÏ ÐÅÒÅ×ÏÄÁ comment ËÏÍÍÅÎÔÁÒÉÊ --> <!-- form_localization --> <attribute name="lang" type="string" len="10" lentype="rtrim" notNull="yes" notEmpty="yes" /> <attribute name="context" type="string" len="50" lenType="rtrim" /> <attribute name="msgid" type="text" lenType="ignore" notNull="yes" notEmpty="yes" /> <attribute name="msgstr" type="text" lenType="ignore" /> <attribute name="fuzzy" type="logical" len="1" lenType="ignore"/> <attribute name="comment" type="string" lenType="ignore" /> <index name="icontext" expression="context+msgid"/> <index name="mcontext" expression="lang+context+msgid"/> <class name="form_localization" extent="form" essence="lang+context+msgid" uniqueKey="" attributes="lang,context,msgid,msgstr,fuzzy,comment" indices="icontext,mcontext" mainIdx="mcontext" findAttrs="lang+context+msgid" /> </meta> <data> <objects depository="ETC0101" class="form_localization"> <object> <attr name="lang">ru</attr> <attr name="context">menu_name</attr> <attr name="msgid">&File</attr> <attr name="msgstr">&æÁÊÌ</attr> </object> <object> <attr name="lang">ru</attr> <attr name="context">menu_name</attr> <attr name="msgid">&Exit</attr> <attr name="msgstr">÷&ÙÈÏÄ</attr> </object> <object> <attr name="lang">ru</attr> <attr name="context">menu_name</attr> <attr name="msgid">&Help</attr> <attr name="msgstr">&óÐÒÁ×ËÁ</attr> </object> <object> <attr name="lang">ru</attr> <attr name="context">menu_name</attr> <attr name="msgid">&About</attr> <attr name="msgstr">&ï ÐÒÏÇÒÁÍÍÅ</attr> </object> </objects> </data> <locale lang="ru"> <name>form_localization</name> <description>ìÏËÁÌÉÚÁÃÉÑ ÉÎÔÅÒÆÅÊÓÁ</description> </locale> </component> --- NEW FILE: form_menu.prg --- /*-------------------------------------------------------------------------*/ /* E/AS Component (part of E/AS project) */ /* */ /* Copyright (C) 2006 by E/AS Software Foundation */ /* Author: Andrey Cherepanov <sk...@ea...> */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as */ /* published by the Free Software Foundation; either version 2 of the */ /* License, or (at your option) any later version. */ /*-------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------/ / / / Name: Form menu / / System name: form_menu / / Description: Menu generation / / Version: 0.1 / / Author: Andrey Cherepanov <sk...@ea...> / / / / Available commands: / / GENERATE Generate menu / / [<context>] menu context (optional) / / / /--------------------------------------------------------------------------*/ /** Component: form_menu */ parameters cMethod, params static defaultDb := 'ETC01' local cContent:='' local oErr, i, err:='', m:='' static componentName:='form_menu' oErr := ErrorBlock({|e| break(e) }) begin sequence /*=========================================================================*/ // GENERATE() if lower(cMethod) == 'generate' eDebug(15, componentName + " args:", params) m := get_Menu( iif('CONTEXT' $ params, params:context, NIL ) ) eDebug( 17, componentName + ".generate:", m ) return m else eDebug(3, componentName + " has not method '"+cMethod+"'") endif recover using oErr i := 1 while ( !empty(ProcName(i)) ) err += "Called from "+allTrim(ProcName(i)) + ; ":" + alltrim(str(ProcLine(i))) + chr(10) i++ end eDebug(5, componentName + " internal error:", errorMessage(oErr)) return NIL end sequence return NIL /* Get real name of elements */ static function __MenuName( s ) local params:=map(), res params:db := defaultDb res := lquery(params, 'select menu_name from form_action where name=="'+s+'"') // Return name if len(res) > 0 s := res[1][1] endif return s /* Get locale for menu item */ static function __MenuNameLocal( name ) local s:="", params:=map(), res, i params:db := defaultDb res := lquery(params, 'select lang,msgstr,fuzzy from form_localization where context+msgid=="menu_name'+name+'"') if valtype(res) == 'A' .and. len(res) > 0 for i in res if .not. i[3] s += '<msg lang="'+i[1]+'" id="'+safeXML(name)+'" value="'+safeXML(i[2])+'"/>&\n' endif next endif //eDebug(15, "MENU:", name, s ) return s /* Recursive process nodes in tree */ static function __processTree( node, s, op ) local i, n, l, params:=map(), res, action, mName if op == 'lookup' if node:id == s return node else for i in node:childs n := __processTree( i, s, op ) if n != NIL return n endif next endif elseif op == 'generate' // Generate node string switch node:type case 'M' mName := __MenuName(node:name) s += '<widget class="popupMenu" label="'+safeXML(mName)+'">&\n' s += __MenuNameLocal( mName ) case 'A' mName := __MenuName(node:name) s += '<widget class="menuItem" label="'+safeXML(mName)+'" name="'+node:name+'">&\n' s += __MenuNameLocal( mName ) case 'S' s += '<widget class="menuSeparator">&\n' otherwise s += '<widget class="UNKNOWN">&\n' endswitch // Process childs for i in asort( node:childs, NIL, NIL, {|a,b| a:order < b:order } ) __processTree( i, @s, op ) next // Action if node:type == 'A' s += ' <rule><event widget="'+node:name+'" signal="activate" />'+chr(10) params:db := defaultDb res := lquery(params, 'select action from form_action where name=="'+node:name+'"') if len(res) > 0 action := res[1][1] else action := '' endif s += ' <action>'+action+'</action>'+chr(10) s += " </rule>&\n" endif s += '</widget>' + chr(10) endif return NIL /* Generate menu */ static function get_Menu( context ) local s:='', params:=map(), res, m:={} local i, l, n, g, j, p, parent params:db := defaultDb res := lquery(params, 'select id,menu_node,menu_type,menu_parent,menu_order from form_menu') // Build menu tree l := len(res) if l == 0 return '' endif for i:=1 to l n := map() n:id := res[i][1] n:name := res[i][2] n:type := left(res[i][3],1) n:parent := res[i][4] n:order := 0+res[i][5] eDebug( 25, componentName + ".add:", n:name, res[i][5], n:order ) n:childs := array(0) if n:parent == '' // Add top level menu items aadd( m, n ) else // Lookup parents parent := NIL for j in m p := __processTree( j, n:parent, 'lookup' ) if p != NIL parent := p exit endif next if parent == NIL aadd( m, n ) else aadd( parent:childs, n ) endif endif next // Write nodes //eDebug( 15, 'TOP LEVEL NODES:', m ) s := '<widget class="menuBar">&\n' for j in asort( m, NIL, NIL, {|a,b| a:order < b:order } ) p := __processTree( j, @s, 'generate' ) next s += '</widget>&\n' eDebug(22, componentName+".generate:", s) return s --- NEW FILE: form_menu.xml --- <?xml version="1.0" encoding="koi8-r" standalone="no" ?> <component> <name>form_menu</name> <category>Core/Interface</category> <version>0.1</version> <description>Menu generation</description> <license>GNU/GPL</license> <created>2006-10-21</created> <modified>2006-10-26</modified> <requires> <dependence type="component">form.xml</dependence> <dependence type="component">form_action.xml</dependence> <dependence type="component">form_localization.xml</dependence> </requires> <author>Skull</author> <meta dictionary="ETC01"> <!-- óÔÒÕËÔÕÒÁ ËÌÁÓÓÁ form_menu menu_node ÉÍÑ ÜÌÅÍÅÎÔÁ ÉÌÉ ÄÅÊÓÔ×ÉÑ menu_type ÔÉÐ menu_parent id ÒÏÄÉÔÅÌØÓËÏÇÏ ÜÌÅÍÅÎÔÁ menu_order ÐÏÒÑÄËÏ×ÙÊ ÎÏÍÅÒ × ÍÅÎÀ --> <!-- form_menu_item --> <attribute name="menu_node" type="string" len="50" lenType="rtrim" /> <attribute name="menu_type" type="string" len="1" lenType="rtrim" /> <attribute name="menu_parent" type="ref" len="12" lenType="ignore" refTo="ETC01:form_menu"/> <attribute name="menu_order" type="number" len="2" lenType="rtrim" /> <index name="menu_node" expression="menu_node"/> <class name="form_menu" extent="form" essence="menu_node" uniqueKey="menu_node" attributes="menu_node,menu_type,menu_parent,menu_order" indices="menu_node" mainIdx="menu_node" findAttrs="menu_node" /> </meta> <data> <objects depository="ETC0101" class="mng_form"> <object> <attr name="name">form_menu.po</attr> <attr name="type">application/x-clip-plugin</attr> <attr name="description">Form menu plugin</attr> <attr name="content">form_menu.po</attr> </object> </objects> <objects depository="ETC0101" class="mng_command"> <object> <attr name="name">generate</attr> <attr name="component_name">form_menu</attr> <attr name="form" refTo="ETC0101:mng_form">form_menu.po</attr> <attr name="description"><![CDATA[Generate menu for form. Arguments: context - String. Menu context. Optional. Returns: String. Menu in XFL format.]]> </attr> </object> </objects> <!-- Default menus --> <objects depository="ETC0101" class="form_menu"> <!-- File menu --> <object> <attr name="menu_node">file</attr> <attr name="menu_type">M</attr> <attr name="menu_parent"></attr> <attr name="menu_order">1</attr> </object> <object> <attr name="menu_node">-exit</attr> <attr name="menu_type">S</attr> <attr name="menu_parent">file</attr> <attr name="menu_order">98</attr> </object> <object> <attr name="menu_node">exit</attr> <attr name="menu_type">A</attr> <attr name="menu_parent">file</attr> <attr name="menu_order">99</attr> </object> <!-- Help menu --> <object> <attr name="menu_node">help</attr> <attr name="menu_type">M</attr> <attr name="menu_parent"></attr> <attr name="menu_order">99</attr> </object> <object> <attr name="menu_node">about</attr> <attr name="menu_type">A</attr> <attr name="menu_parent">help</attr> <attr name="menu_order">99</attr> </object> </objects> </data> <locale lang="ru"> <name>form_menu</name> <description>çÅÎÅÒÁÃÉÑ ÍÅÎÀ</description> </locale> </component> --- NEW FILE: form_service.xml --- <?xml version="1.0" encoding="koi8-r" standalone="no" ?> <component> <name>form_service</name> <category>Core/Interface</category> <version>0.1</version> <description>'Service' Menu</description> <license>GNU/GPL</license> <created>2006-10-31</created> <modified>2006-10-31</modified> <requires> <dependence type="component">form_menu.xml</dependence> </requires> <author>Skull</author> <data> <objects depository="ETC0101" class="form_menu"> <!-- Service menu --> <object> <attr name="menu_node">service</attr> <attr name="menu_type">M</attr> <attr name="menu_parent"></attr> <attr name="menu_order">70</attr> </object> </objects> <objects depository="ETC0101" class="form_action"> <object> <attr name="name">service</attr> <attr name="menu_name">&Service</attr> </object> </objects> <objects depository="ETC0101" class="form_localization"> <object> <attr name="lang">ru</attr> <attr name="context">menu_name</attr> <attr name="msgid">&Service</attr> <attr name="msgstr">ó&ÅÒ×ÉÓ</attr> </object> </objects> </data> <locale lang="ru"> <name>form_service</name> <description>íÅÎÀ 'óÅÒ×ÉÓ'</description> </locale> </component> |