EnglishРусский  

   ..

   gtsave.g

   prj.g

   prj3.g

   prjnew.g

The project is closed! You can look at a new scripting language. It is available on GitHub.
Also, try our open source cross-platform automation software.

Ads

Installer and installation software
Commercial and Freeware installers.

source\lib\prj\prjnew.g
  1 /******************************************************************************
  2 *
  3 * Copyright (C) 2006, The Gentee Group. All rights reserved. 
  4 * This file is part of the Gentee open source project - http://www.gentee.com. 
  5 * 
  6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT"). 
  7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS 
  8 * ACCEPTANCE OF THE AGREEMENT.
  9 *
 10 * ID: prj 17.10.06 0.0.A.
 11 *
 12 * Author: Alexey Krivonogov ( gentee )
 13 *
 14 ******************************************************************************/
 15 
 16 include
 17 {
 18    $"..\gt2\gt.g"
 19 }
 20 
 21 /*-----------------------------------------------------------------------------
 22 *
 23 * ID: prj 12.10.06 1.1.A. 
 24 * 
 25 * Summary: Project type
 26 *  
 27 -----------------------------------------------------------------------------*/
 28 
 29 type prj <inherit = gt2 index = str>
 30 {
 31    uint opened       // 1 if there is an open project
 32    uint changed      // 1 if the project was changed
 33    uint nfy          // id of the notify function
 34    str  filename     // The current file name or an empty string
 35    str  program      // The unique program name
 36    uint version      // The unique version
 37    str  update       // Update data for adding missing values
 38 }
 39 
 40 /*-----------------------------------------------------------------------------
 41 *
 42 * ID: prjnfy 12.10.06 1.1.A. 
 43 * 
 44 * Summary: Project notify codes
 45 *  
 46 -----------------------------------------------------------------------------*/
 47 
 48 define <export>
 49 {
 50    PRJNFY_OPEN = 0    // The project was opened
 51    PRJNFY_CLOSE       // The project was closed
 52    PRJNFY_CANCLOSE    // Send when the user tries to close the project
 53    PRJNFY_CHANGE      // The project was chaged. Send one time (after the 
 54                       // first changing )
 55    PRJNFY_NEW         // Request the new project pattern
 56    PRJNFY_NAME        // Change the file name    
 57 }
 58 
 59 global
 60 {
 61    str  prjempty
 62 }
 63 
 64 /*-----------------------------------------------------------------------------
 65 *
 66 * ID: prj_setnotify 12.10.06 1.1.A. 
 67 * 
 68 * Summary: Specify notify function. func uint name( prj iprj, uint code )
 69   where code can be PRJNFY_*
 70 *  
 71 -----------------------------------------------------------------------------*/
 72 
 73 method  prj.settings( uint nfyfunc, str program, uint version )
 74 {
 75    this.nfy = nfyfunc
 76    this.program = program
 77    this.version = version         
 78 }
 79 
 80 /*-----------------------------------------------------------------------------
 81 *
 82 * ID: prj_notify 12.10.06 1.1.A. 
 83 * 
 84 * Summary: Send notify message PRJNFY_*
 85 *  
 86 -----------------------------------------------------------------------------*/
 87 
 88 method uint prj.notify( uint nfy )
 89 {
 90    if this.nfy : return this.nfy->func( this, nfy )
 91    return 0      
 92 }
 93 
 94 /*-----------------------------------------------------------------------------
 95 *
 96 * ID: prj_close 12.10.06 1.1.A. 
 97 * 
 98 * Summary: Close the project
 99 *  
100 -----------------------------------------------------------------------------*/
101 
102 method uint prj.close
103 {
104    if !this.opened : return 1
105    
106    this.notify( $PRJNFY_CANCLOSE ) 
107    
108    this.clear()
109    this.opened = 0
110    this.changed = 0
111 //   this.filename.clear()   
112    
113    this.notify( $PRJNFY_CLOSE )
114    return 1   
115 }
116 
117 /*-----------------------------------------------------------------------------
118 *
119 * ID: prj_new 12.10.06 1.1.A. 
120 * 
121 * Summary: Specify notify function. func uint name( prj iprj, uint code )
122   where code can be PRJNFY_*
123 *  
124 -----------------------------------------------------------------------------*/
125 
126 method uint prj.new
127 {
128    if this.opened : this.close()
129    if *this.update : this += this.update
130    this.notify( $PRJNFY_NEW )
131    this.filename.clear()
132    this.opened = 1
133    this.changed = 1   
134    this.notify( $PRJNFY_OPEN )
135    return 1   
136 }
137 
138 /*-----------------------------------------------------------------------------
139 *
140 * ID: prj_open 12.10.06 1.1.A. 
141 * 
142 * Summary: Load a project from the file
143 *  
144 -----------------------------------------------------------------------------*/
145 
146 method uint prj.open( str filename )
147 {
148    if this.opened : this.close()
149    if *this.update : this += this.update
150    this.read( filename )
151    this.filename = filename
152    this.opened = 1
153    this.notify( $PRJNFY_OPEN )
154    return 1   
155 }
156 
157 /*-----------------------------------------------------------------------------
158 *
159 * ID: prj_save 12.10.06 1.1.A. 
160 * 
161 * Summary: Save a project
162 *  
163 -----------------------------------------------------------------------------*/
164 
165 method uint prj.save()
166 {
167    gt2save gt2s
168    
169    if !this.opened || !*this.filename : return 0
170     
171    gt2s.offstep = 3
172    gt2s.inside = 0
173    gt2s.endname = 0
174    
175    this.write( this.filename, gt2s )
176    if this.changed
177    {
178       this.changed = 0
179       this.notify( $PRJNFY_CHANGE )
180    }
181    return 1   
182 }
183 
184 /*-----------------------------------------------------------------------------
185 *
186 * ID: prj_save 12.10.06 1.1.A. 
187 * 
188 * Summary: Save a project to the filename
189 *  
190 -----------------------------------------------------------------------------*/
191 
192 method uint prj.save( str filename )
193 {
194    uint ret
195    
196    this.filename = filename
197    ret = this.save()   
198    this.notify( $PRJNFY_NAME )
199    return ret
200 }
201 
202 /*-----------------------------------------------------------------------------
203 *
204 * ID: prj_index 12.10.06 1.1.A. 
205 * 
206 * Summary: 
207 *  
208 -----------------------------------------------------------------------------*/
209 
210 method uint prj.index( str name )
211 {
212    uint gti
213    
214    gti as this.find( "project/\(name)" )
215    if >i : return >i.value
216    prjempty.clear()
217    return &prjempty
218 }
219 
220 /*-----------------------------------------------------------------------------
221 *
222 * ID: prj_set 12.10.06 1.1.A. 
223 * 
224 * Summary: Set a project value
225 *  
226 -----------------------------------------------------------------------------*/
227 
228 method prj.set( str name value )
229 {
230    uint  sti
231    
232    sti as this[ name ]
233    if &sti
234    {
235       sti = value
236       if !this.changed
237       {
238          this.changed = 1
239          this.notify( $PRJNFY_CHANGE )
240       }
241    }
242 }
243 
244 /*-----------------------------------------------------------------------------
245 *
246 * ID: prj_set 12.10.06 1.1.A. 
247 * 
248 * Summary: Set a project value
249 *  
250 -----------------------------------------------------------------------------*/
251 
252 method prj.set( gt2item gti, str value )
253 {
254    gti.value = value
255    if !this.changed
256    {
257       this.changed = 1
258       this.notify( $PRJNFY_CHANGE )
259    }
260 }
261 
262 /*-----------------------------------------------------------------------------
263 *
264 * ID: prj_insert 12.10.06 1.1.A. 
265 * 
266 * Summary: Insert project items
267 *  
268 -----------------------------------------------------------------------------*/
269 
270 method gt2item prj.insert( str data, gt2item parent after )
271 {
272    uint  ret
273  
274    ret as parent.load( data, after )
275    if !this.changed
276    {
277       this.changed = 1
278       this.notify( $PRJNFY_CHANGE )
279    }
280        
281    return ret->gt2item
282 }
283 
284 /*-----------------------------------------------------------------------------
285 *
286 * ID: prj_moveup 12.10.06 1.1.A. 
287 * 
288 * Summary: Move the project item up
289 *  
290 -----------------------------------------------------------------------------*/
291 
292 method gt2item prj.moveup( gt2item cur )
293 {
294    if cur.moveup() && !this.changed
295    {
296       this.changed = 1
297       this.notify( $PRJNFY_CHANGE )
298    }    
299    return cur
300 }
301 
302 /*-----------------------------------------------------------------------------
303 *
304 * ID: prj_movedown 12.10.06 1.1.A. 
305 * 
306 * Summary: Move the project item down
307 *  
308 -----------------------------------------------------------------------------*/
309 
310 method gt2item prj.movedown( gt2item cur )
311 {
312    if cur.movedown() && !this.changed
313    {
314       this.changed = 1
315       this.notify( $PRJNFY_CHANGE )
316    }    
317    return cur
318 }
319 
320 /*-----------------------------------------------------------------------------
321 *
322 * ID: prj_disable 12.10.06 1.1.A. 
323 * 
324 * Summary: Move the project item down
325 *  
326 -----------------------------------------------------------------------------*/
327 
328 method uint prj.disable( gt2item gti, uint state )
329 {
330    if state : gti.setattrib( "disable" )
331    else : gti.delattrib( "disable" )
332    
333    if !this.changed
334    {
335       this.changed = 1
336       this.notify( $PRJNFY_CHANGE )
337    }    
338    return 1
339 }
340 
341 /*-----------------------------------------------------------------------------
342 *
343 * ID: prj_disable 12.10.06 1.1.A. 
344 * 
345 * Summary: Move the project item down
346 *  
347 -----------------------------------------------------------------------------*/
348 
349 method uint prj.del( gt2item gti )
350 {
351    gti.del()
352       
353    if !this.changed
354    {
355       this.changed = 1
356       this.notify( $PRJNFY_CHANGE )
357    }    
358    return 1
359 }