FileDropClass Overview

Top  Previous  Next

Future FileDropClasses

The current implementation of the FileDropClass is a place-holder implementation. In the future the FileDropClass, or its replacement, will be derived from the BrowseClass.

FileDropClass Concepts

The FileDropClass is a ViewManager that supports a file-loaded scrollable list on a window. By convention, a FileDrop provides a "pick list" for the end user. A pick list is a finite list of mutually exclusive or alternative choices--the end user may choose only one of several items, but need not memorize the choices, because all the choices are displayed.

Based on the end user selection, you can assign one or more values from the selected item to one or more target fields. You may display one field (e.g., a description field) but assign another field (e.g., a code field) from the selected list item.

The FileDropClass also supports filters, range limits, colors, icons, sorting, and multiple item selection (marking). See Control Templates--FileDrop for information on the template implementation of these features.

FileDropClass Relationship to Other Application Builder Classes

The FileDropClasss is closely integrated with the WindowManager. These objects register their presence with each other, set each other's properties, and call each other's methods as needed to accomplish their respective tasks.

The FileDropComboClass is derived from the FileDropClass, and the FileDropClass is derived from the ViewManager. The FileDropClass relies on several of the other Application Builder Classes to accomplish its tasks. Therefore, if your program instantiates the FileDropClass, it must also instantiate these other classes. Much of this is automatic when you INCLUDE the FileDropClass header (ABDROPS.INC) in your program's data section. See the Conceptual Example.

FileDropClass ABC Template Implementation

The ABC Templates automatically include all the classes and generate all the code necessary to support the functionality specified in your application's FileDrop control templates.

The templates derive a class from the FileDropClass and instantiate an object for each FileDropControl template in the application. The derived class and object is called FDB# where # is the FileDrop Control template instance number. The templates provide the derived class so you can use the FileDropControl template Classes tab to modify the FileDrop's behavior on an instance-by-instance basis.

The derived FileDropClass is local to the procedure, is specific to a single FileDropCombo and relies on the global file-specific RelationManager and FileManager objects for the displayed lookup file.

FileDropClass Source Files

The FileDropClass source code is installed by default to the Clarion \LIBSRC folder. The FileDropClass source code and their respective components are contained in:

 

ABDROPS.INC

FileDropClass declarations

 

ABDROPS.CLW

FileDropClass method definitions

FileDropClass Conceptual Example

The following example shows a typical sequence of statements to declare, instantiate, initialize, use, and terminate a FileDropClass object and related objects.

This example uses the FileDropClass object to let the end user select a valid state code for a given client. The state code comes from the State file. When they are initialized properly, the FileDropClass and WindowManager objects do most of the work (event handling and field assignments) internally.

PROGRAM

 

INCLUDE('ABWINDOW.INC')

INCLUDE('ABDROPS.INC')

MAP

END

 

State        FILE,DRIVER('TOPSPEED'),PRE(ST),THREAD

StateCodeKey KEY(ST:STATECODE),NOCASE,OPT

Record        RECORD,PRE()

StateCode      STRING(2)

StateName      STRING(20)

             END

            END

 

Customer  FILE,DRIVER('TOPSPEED'),PRE(CUS),CREATE,THREAD

BYNUMBER  KEY(CUS:CUSTNO),NOCASE,OPT,PRIMARY

Record     RECORD,PRE()

CUSTNO      LONG

Name        STRING(30)

State       STRING(2)

          END

         END

 

GlobalErrors ErrorClass

VCRRequest   LONG(0),THREAD

 

Access:State  CLASS(FileManager)

Init           PROCEDURE

             END

 

Relate:State  CLASS(RelationManager)

Init           PROCEDURE

             END

 

Access:Customer CLASS(FileManager)

Init             PROCEDURE

               END

 

Relate:Customer CLASS(RelationManager)

Init             PROCEDURE

               END

 

StateQ       QUEUE

ST:STATECODE  LIKE(ST:STATECODE)

ViewPosition  STRING(512)

             END

StateView VIEW(State)

         END

 

CusWindow WINDOW('Add Customer'),AT(,,157,58),IMM,SYSTEM,GRAY

      PROMPT('Customer:'),AT(5,7),USE(?NamePrompt)

      ENTRY(@s20),AT(61,5,88,11),USE(CUS:NAME)

      PROMPT('State:'),AT(5,22),USE(?StatePrompt)

      LIST,AT(61,20,65,11),USE(CUS:State),FROM(StateQ),|

      FORMAT('8L~STATECODE~@s2@'),DROP(5)

      BUTTON('OK'),AT(60,39),USE(?OK),DEFAULT

      BUTTON('Cancel'),AT(104,39),USE(?Cancel)

     END

 

ThisWindow CLASS(WindowManager)

Init        PROCEDURE(),BYTE,PROC,VIRTUAL

Kill        PROCEDURE(),BYTE,PROC,VIRTUAL

          END

 

StateDrop  CLASS(FileDropClass)

Q           &StateQ

          END

 CODE

 ThisWindow.Run()

 

ThisWindow.Init PROCEDURE()

ReturnValue  BYTE,AUTO

 CODE

 GlobalErrors.Init

 Relate:State.Init

 Relate:Customer.Init

 SELF.Request = InsertRecord

 ReturnValue = PARENT.Init()

 IF ReturnValue THEN RETURN ReturnValue.

 SELF.FirstField = ?CUS:NAME

 SELF.VCRRequest &= VCRRequest

 SELF.Errors &= GlobalErrors

 SELF.AddUpdateFile(Access:Customer)

 SELF.AddItem(?Cancel,RequestCancelled)

 SELF.OkControl = ?OK

 Relate:Customer.Open

 Relate:State.Open

 SELF.Primary &= Relate:Customer

 SELF.InsertAction = Insert:Batch

 IF SELF.PrimeUpdate() THEN RETURN Level:Notify.

 OPEN(CusWindow)

 SELF.Opened=True

!initialize the FileDrop Class with:

! the LISTS's USE variable, LIST control, view POSITION, VIEW, LISTS's FROM QUEUE,

! primary file RelationManager object, WindowManager object

 StateDrop.Init(?CUS:State,StateQ.ViewPosition,StateView,StateQ,Relate:State,ThisWindow)

 StateDrop.Q &= StateQ

 StateDrop.AddSortOrder()

 StateDrop.AddField(ST:STATECODE,StateDrop.Q.ST:STATECODE)

 StateDrop.AddUpdateField(ST:STATECODE,CUS:State)

 ThisWindow.AddItem(StateDrop)

 SELF.SetAlerts()

 RETURN ReturnValue

 

ThisWindow.Kill PROCEDURE()

ReturnValue     BYTE,AUTO

 CODE

 ReturnValue = PARENT.Kill()

 IF ReturnValue THEN RETURN ReturnValue.

 Relate:Customer.Close

 Relate:State.Close

 Relate:State.Kill

 Relate:Customer.Kill

 GlobalErrors.Kill

 RETURN ReturnValue

 

Access:State.Init PROCEDURE

 CODE

 PARENT.Init(State,GlobalErrors)

 SELF.FileNameValue = 'State'

 SELF.Buffer &= ST:Record

 SELF.LazyOpen = False

 SELF.AddKey(ST:StateCodeKey,'ST:StateCodeKey',0)

 

Access:Customer.Init PROCEDURE

 CODE

 PARENT.Init(Customer,GlobalErrors)

 SELF.FileNameValue = 'Customer'

 SELF.Buffer &= CUS:Record

 SELF.Create = True

 SELF.LazyOpen = False

 SELF.AddKey(CUS:BYNUMBER,'CUS:BYNUMBER',0)

 

Relate:State.Init PROCEDURE

 CODE

 Access:State.Init

 PARENT.Init(Access:State,1)

 

Relate:Customer.Init PROCEDURE

 CODE

 Access:Customer.Init

 PARENT.Init(Access:Customer,1)