1 -- File: IFSelect_ListEditor.cdl
2 -- Created: Tue Jul 28 11:17:08 1998
3 -- Author: Christian CAILLET
4 -- <cky@heliox.paris1.matra-dtv.fr>
5 ---Copyright: Matra Datavision 1998
8 class ListEditor from IFSelect inherits TShared from MMgt
10 ---Purpose : A ListEditor is an auxiliary operator for Editor/EditForm
11 -- I.E. it works on parameter values expressed as strings
13 -- For a parameter which is a list, it may not be edited in once
14 -- by just setting a new value (as a string)
16 -- Firstly, a list can be long (and tedious to be accessed flat)
17 -- then requires a better way of accessing
19 -- Moreover, not only its VALUES may be changed (SetValue), but
20 -- also its LENGTH : items may be added or removed ...
22 -- Hence, the way of editing a parameter as a list is :
23 -- - edit it separately, with the help of a ListEditor
24 -- - it remains possible to prepare a new list of values apart
25 -- - then give the new list in once to the EditForm
27 -- An EditList is produced by the Editor, with a basic definition
28 -- This definition (brought by this class) can be redefined
29 -- Hence the Editor may produce a specific ListEditor as needed
31 uses CString, HAsciiString from TCollection,
32 HSequenceOfHAsciiString from TColStd,
33 HSequenceOfInteger from TColStd,
34 TypedValue from Interface, InterfaceModel from Interface
38 Create returns ListEditor;
39 ---Purpose : Creates a ListEditor with absolutely no constraint
41 Create (def : TypedValue; max : Integer = 0) returns ListEditor;
42 ---Purpose : Creates a ListEditor, for which items of the list to edit are
43 -- defined by <def>, and <max> describes max length :
44 -- 0 (D) means no limit
45 -- value > 0 means : no more the <max> items are allowed
47 LoadModel (me : mutable; model : InterfaceModel);
48 ---Purpose : Loads a Model. It is used to check items of type Entity(Ident)
50 LoadValues (me : mutable; vals : HSequenceOfHAsciiString);
51 ---Purpose : Loads the original values for the list
52 -- Remark : If its length is mor then MaxLength, editions remain
53 -- allowed, except Add
55 SetTouched (me : mutable);
56 ---Purpose : Declares this ListEditor to have been touched (whatever action)
58 ClearEdit (me : mutable);
59 ---Purpose : Clears all editions already recorded
61 --- Editing : can be specialised
63 LoadEdited (me : mutable; list : HSequenceOfHAsciiString)
64 returns Boolean is virtual;
65 ---Purpose : Loads a new list to replace the older one, in once !
66 -- By default (can be redefined) checks the length of the list
67 -- and the value of each item according to the def
68 -- Items are all recorded as Modified
70 -- If no def has been given at creation time, no check is done
71 -- Returns True when done, False if checks have failed ... a
72 -- specialisation may also lock it by returning always False ...
74 SetValue (me : mutable; num : Integer; val : HAsciiString)
75 returns Boolean is virtual;
76 ---Purpose : Sets a new value for the item <num> (in edited list)
77 -- <val> may be a Null Handle, then the value will be cleared but
79 -- Returns True when done. False if <num> is out of range or if
80 -- <val> does not satisfy the definition
82 AddValue (me : mutable; val : HAsciiString; atnum : Integer = 0)
83 returns Boolean is virtual;
84 ---Purpose : Adds a new item. By default appends (at the end of the list)
85 -- Can insert before a given rank <num>, if positive
86 -- Returns True when done. False if MaxLength may be overpassed
87 -- or if <val> does not satisfy the definition
89 Remove (me : mutable; num : Integer = 0; howmany : Integer = 1)
90 returns Boolean is virtual;
91 ---Purpose : Removes items from the list
92 -- By default removes one item. Else, count given by <howmany>
93 -- Remove from rank <num> included. By default, from the end
94 -- Returns True when done, False (and does not work) if case of
95 -- out of range of if <howmany> is greater than current length
99 OriginalValues (me) returns HSequenceOfHAsciiString;
100 ---Purpose : Returns the value from which the edition started
102 EditedValues (me) returns HSequenceOfHAsciiString;
103 ---Purpose : Returns the result of the edition
107 NbValues (me; edited : Boolean = Standard_True) returns Integer;
108 ---Purpose : Returns count of values, edited (D) or original
110 Value (me; num : Integer; edited : Boolean = Standard_True)
111 returns HAsciiString;
112 ---Purpose : Returns a value given its rank. Edited (D) or Original
113 -- A Null String means the value is cleared but not removed
115 IsChanged (me; num : Integer) returns Boolean;
116 ---Purpose : Tells if a value (in edited list) has been changed, i.e.
117 -- either modified-value, or added
119 IsModified (me; num : Integer) returns Boolean;
120 ---Purpose : Tells if a value (in edited list) has been modified-value
123 IsAdded (me; num : Integer) returns Boolean;
124 ---Purpose : Tells if a value (in edited list) has been added (new one)
127 IsTouched (me) returns Boolean;
128 ---Purpose : Tells if at least one edition (SetValue-AddValue-Remove) has
135 thetouc : Integer; -- global IsTouched
136 theorig : HSequenceOfHAsciiString;
137 theedit : HSequenceOfHAsciiString;
138 thestat : HSequenceOfInteger;
139 themodl : InterfaceModel;