bool OnClose(bool parentClosing)
{
- return NotifyClosing();
+ bool result = NotifyClosing();
+ if(result)
+ {
+ EditClear();
+ }
+ return result;
}
// List
{
Row r { table };
Array<Id> matches = SearchWordList();
- OnList(this, r, matches);
+ OnList(r, matches);
delete matches;
delete r;
}
modifiedDocument = false; // setting this here is not really logical, enumeration and modified have nothing to do with eachother
}
- virtual void TableEditor::OnList(Row r, Array<Id> matches)
+ virtual void OnList(Row r, Array<Id> matches)
{
DebugLn("TableEditor::OnList");
listEnumerationCompleted = false;
listEnumerationTimer.Start();
}
- virtual void TableEditor::OnCreateDynamicLookupEditors()
+ virtual void OnCreateDynamicLookupEditors()
{
DebugLn("TableEditor::OnCreateLookupEditors");
if(dynamicLookupFields && dynamicLookupFields.count)
{
- for(luf : dynamicLookupFields)
+ for(f : dynamicLookupFields)
{
- if(luf.editorClass && luf.parentWindow)
+ if(f.editorClass && f.parentWindow)
{
- TableEditor editor = eInstance_New(luf.editorClass);
- editor.parent = luf.parentWindow;
- editor.master = this;
- dynamicLookupTableEditors.Add(editor);
+ Row row { tbl = f.lookupTable };
+ // todo: make this work for all types
+ uint id = 0;
+ editRow.GetData(f.field, id);
+ for(row.Find(f.lookupField, middle, nil, id); !row.nil; row.Next())
+ {
+ // todo: make this work for all types, although this is meant to be an id field
+ uint id = 0;
+ TableEditor editor = eInstance_New(f.editorClass);
+ incref editor;
+ editor.parent = f.parentWindow;
+ editor.master = this;
+ dynamicLookupTableEditors.Add(editor);
+ editor.Create();
+ row.GetData(f.lookupIdField, id);
+ editor.Select(id);
+ }
+ delete row;
}
}
}
void EditLoad()
{
DebugLn("TableEditor::EditLoad");
+ EditClear();
OnLoad();
internalModifications = true;
for(fb : fieldsBoxes)
fb.Load();
+ OnCreateDynamicLookupEditors();
internalModifications = false;
DebugLn(" TODO: implement virtual method TableEditor::OnSubEditorsLoad");
internalModifications = true;
for(fb : fieldsBoxes)
fb.Clear();
+ for(e : dynamicLookupTableEditors)
+ {
+ e.visible = false;
+ e.parent = null;
+ e.master = null;
+ e.Destroy(0);
+ delete e;
+ }
+ dynamicLookupTableEditors.Free();
+ //dynamicLookupTableEditors.size = 0;
internalModifications = false;
DebugLn(" TODO: remove all sub table editors");
public class LookupField : struct
{
public:
+ subclass(TableEditor) editorClass;
+ Window parentWindow;
Field field;
Table lookupTable;
Field lookupField;
- Field lookupValueField;
+ Field lookupIdField;
String (*CustomLookup)(Id);
- subclass(TableEditor) editorClass;
- Window parentWindow;
}
static WordEntry * btnodes;
public class Id : uint
{
class_data Table * table; class_property Table * table { set { class_data(table) = value; } get { return class_data(table); } };
+ //class_data Field * idField; class_property Field * idField { set { class_data(nameField) = value; } get { return class_data(idField); } };
+ //class_data Field * displayField; class_property Field * displayField { set { class_data(displayField) = value; } get { return class_data(displayField); } };
class_data Field * nameField; class_property Field * nameField { set { class_data(nameField) = value; } get { return class_data(nameField); } };
class_data char * addText; class_property char * addText { set { class_data(addText) = value; } };
class_data void * Refill; class_property void * Refill { set { class_data(Refill) = value; } };
TableDropBox dropBox = dataBox.keepEditor ? (TableDropBox)dataBox.editor /*obsolete*/ : null;
if(!dropBox)
{
+/*
+ if(eClass_IsDerived(dataBox._class, class(FieldDropBox)))
+ {
+ FieldDropBox fieldDropBox = (FieldDropBox)dataBox;
+
+ }
+ else if(eClass_IsDerived(dataBox._class, class(FieldBox)))
+ {
+ FieldBox fieldBox = (FieldBox)dataBox;
+
+ }
+*/
+
dropBox = TableDropBox
{
dataBox, borderStyle = 0, anchor = { 0, 0, 0, 0 },