-- File: TuplesEditor.mesa
-- Contents: interface to a "tuples" subwindow for use by nut implementations
-- Created by: Donahue July 8, 1982 10:44 am
-- Last edited by:
-- Donahue, April 8, 1983 12:20 pm
-- Cattell, May 30, 1983 4:11 pm

DIRECTORY
DB: TYPE USING[ Domain, Entity, Attribute ],
ViewerClasses: TYPE USING[ Viewer ],
VTables: TYPE USING[ VTable ];

TuplesEditor: CEDAR DEFINITIONS IMPORTS DB, ViewerClasses, VTables =

BEGIN OPEN DB, ViewerClasses, VTables;

defaultOld: BOOL; -- FALSE => attributes start in NewOrOld mode, TRUE => OldOnly

DisplayTuples: PROC[e: Entity, attrList: LIST OF Attribute, parent: Viewer] RETURNS[VTable];
-- Make a nested viewer (a VTable) that has all of the tuples where the entity appears in any
-- of the attributes specified. If the attribute is a non-key part of a relation, then a blank row
-- may be provided for adding new tuples

SaveTuples: PROC[ viewer: VTable, newEntity: Entity ← NIL ];
-- Given a table set up by DisplayTuples, add all of its contents to the database.
-- The function of SaveTuples is determined by the newEntity and the oldEntity (the
-- entity originally supplied to DisplayTuples):
--
-- oldEntitynewEntityresult
-- NIL    e   add the relships on the screen to the entity e
-- e    NIL  destroy the entity e
-- e    e   update entity e to reflect any modifications to relships on screen
-- e1    e2 (#e1) add e1's relships, as modified on screen, to e2 (leaves e1 alone)


QueryTuples: PROC[ viewer: VTable, domain: DB.Domain ] RETURNS [LIST OF Entity];
-- Given a table set up by DisplayTuples, finds all the entities in the given domain
-- that satisfy the query filled into the table by the user.

-- NOTE, for both query and editor windows: the top-level viewer containing the viewer on which EditTuples or QueryTuples is called may have a $Typescript property whose value is a stream to send error messages to. If no such stream is provided, error messages will go to the Message window.

END.