home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / ioc / lancelot / lproject.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  31.6 KB  |  733 lines

  1. /******************************************************************************
  2. * .FILE:         lproject.cpp                                                 *
  3. *                                                                             *
  4. * .DESCRIPTION:  Lancelot Sample Program:              Class Implementation   *
  5. *                                                                             *
  6. * .CLASSES:      ProjectPage                                                  *
  7. *                ProjCnrObj                                                   *
  8. *                                                                             *
  9. * .COPYRIGHT:                                                                 *
  10. *                                                                             *
  11. * .DISCLAIMER:                                                                *
  12. *                                                                             *
  13. * .NOTE: WE RECOMMEND USING A FIXED SPACE FONT TO LOOK AT THE SOURCE          *
  14. *                                                                             *
  15. ******************************************************************************/
  16.  
  17. #ifndef _IBASE_                         //Make sure ibase.hpp is included
  18.   #include <ibase.hpp>                  //  since that is where IC_<environ>
  19. #endif                                  //  is defined.
  20. #include <iapp.hpp>
  21. #include <iexcbase.hpp>
  22. #include <ihelp.hpp>
  23. #include <ireslib.hpp>
  24. #include "lancelot.h"
  25. #include "lproject.hpp"
  26.  
  27. /******************************************************************************
  28. * Class ProjectPage :: ProjectPage - Constructor for the project page         *
  29. *                                                                             *
  30. * Define yourself as an IMultiCellCanvas                                      *
  31. * Create generic page buttons                                                 *
  32. * Create generic page container buttons                                       *
  33. * Create static text for the project                                          *
  34. * Create static text for the active indicator                                 *
  35. * Create static text for the description                                      *
  36. * Create static text for the responsible manager                              *
  37. * Create entryfield for the project                                           *
  38. * Create checkbox for the active indicator                                    *
  39. * Create entryfield for the description                                       *
  40. * Create combobox for the responsible manager                                 *
  41. * Define a null container pointer                                             *
  42. * Define a null container object pointer                                      *
  43. * Define a null container column pointer                                      *
  44. * Define a null container column pointer                                      *
  45. * Define a null container column pointer                                      *
  46. * Define a null container column pointer                                      *
  47. * Create an project data object given the key                                 *
  48. * Create a empty project data object                                          *
  49. * Set the key in your private data                                            *
  50. * Create the notebook page settings                                           *
  51. * Create a alphanumeric handler (MOTIF only)                                  *
  52. * Create a container select handler                                           *
  53. ******************************************************************************/
  54. ProjectPage::ProjectPage(  IWindow* pParent,
  55.                            const IString& aKey )
  56.      :IMultiCellCanvas     ( ID_PROJECT_PAGE, pParent, pParent ),
  57.       pageButtons          ( ID_PROJECT_PAGE_BUTTONS,
  58.                              this, this, false ),
  59.       pageCnrButtons       ( ID_PROJECT_PAGE_CNRBUTTONS,
  60.                              this, this, false ),
  61.       projText             ( ID_NO_ITEM, this, this ),
  62.       activeText           ( ID_NO_ITEM, this, this ),
  63.       descrText            ( ID_NO_ITEM, this, this ),
  64.       respMgrText          ( ID_NO_ITEM, this, this ),
  65.       project              ( ID_PRJ_PROJ_EF, this, this,
  66.                              IRectangle(),
  67.                              IEntryField::classDefaultStyle
  68.                              | IControl::tabStop ),
  69.       active               ( ID_PRJ_ACTIVE_CB, this, this ),
  70.       descr                ( ID_PRJ_DESCR_EF, this, this,
  71.                              IRectangle(),
  72.                              IEntryField::classDefaultStyle
  73.                              | IControl::tabStop ),
  74.       respMgr              ( ID_WRK_RESP_MGR_CBX, this, this,
  75.                              IRectangle(),
  76.                              IComboBox::defaultStyle()
  77.                              & ~IComboBox::simpleType
  78.                              | IComboBox::dropDownType
  79.                              | IControl::tabStop ),
  80.       pCnr                 ( NULL ),
  81.       pProjCnrObj          ( (ProjCnrObj*) NULL ),
  82.       pColProj             ( ( IContainerColumn*) NULL ),
  83.       pColDesc             ( ( IContainerColumn*)NULL ),
  84.       pColMgr              ( ( IContainerColumn*)NULL ),
  85.       pColAct              ( ( IContainerColumn*)NULL ),
  86.       projectData          ( aKey ),
  87.       origProjectData      (),
  88.       Key                  ( aKey ),
  89.       thePageSettings      ( IApplication::current().userResourceLibrary().
  90.                              loadString( STR_PRJ_PROJECT_TAB ), NULL,
  91.                              INotebook::PageSettings::autoPageSize
  92.                              | INotebook::PageSettings::majorTab ),
  93. #ifdef IC_MOTIF
  94.       alphaNumericHandler  ( this, TEST_ALPHANUMERIC ),
  95. #endif
  96.       cnrSelHandler        ( this )
  97. {
  98. /*-----------------------------------------------------------------------------
  99. | Save the project data to another object in case the user wishes to          |
  100. |  undo any changes.                                                          |
  101. | Label the static text objects.                                              |
  102. | Set the limit for the entryfield and combobox.                              |
  103. | Set the combobox input type and range.                                      |
  104. -----------------------------------------------------------------------------*/
  105.    origProjectData = projectData;
  106.    projText.setText( STR_PRJ_PROJ );
  107.    activeText.setText( STR_PRJ_ACTIVE );
  108.    descrText.setText( STR_PRJ_DESCRIPTION );
  109.    respMgrText.setText( STR_PRJ_RESP_MGR );
  110.    project.setLimit( DISPLAY_LARGE );
  111.    descr.setLimit( DISPLAY_TEXT );
  112.    respMgr.setLimit( DISPLAY_LARGE );
  113.  
  114. /*-----------------------------------------------------------------------------
  115. | Fill the combobox from the database.                                        |
  116. | Fill the container from the database.                                       |
  117. | Set the objects on yourself (IMultiCellCanvas).                             |
  118. | Start handling the events.                                                  |
  119. -----------------------------------------------------------------------------*/
  120.    fillPage();
  121.    fillCnr();
  122.    setCells();
  123.    handleIt();
  124. }
  125.  
  126.  
  127. /******************************************************************************
  128. * Class ProjectPage :: ~ProjectPage - Destructor for the project page         *
  129. ******************************************************************************/
  130. ProjectPage::~ProjectPage()
  131. {
  132. /*-----------------------------------------------------------------------------
  133. | Stop handling events.                                                       |
  134. -----------------------------------------------------------------------------*/
  135.    ICommandHandler::stopHandlingEventsFor( &pageButtons );
  136.    ICommandHandler::stopHandlingEventsFor( &pageCnrButtons );
  137.    ISelectHandler::stopHandlingEventsFor( &pageButtons );
  138.    cnrSelHandler.stopHandlingEventsFor( pCnr );
  139. #ifdef IC_MOTIF
  140.     alphaNumericHandler.stopHandlingEventsFor( &project );
  141. #endif
  142. }
  143.  
  144.  
  145. /******************************************************************************
  146. * Class ProjectPage :: fillPage - Populate combobox from database             *
  147. ******************************************************************************/
  148. ProjectPage& ProjectPage :: fillPage()
  149. {
  150.    IString
  151.       theId;
  152.  
  153.    QueryMgrs
  154.      *pM = new QueryMgrs();
  155.  
  156. /*-----------------------------------------------------------------------------
  157. | Get the manager Ids.                                                        |
  158. -----------------------------------------------------------------------------*/
  159.    pM->getMatchList();
  160.    if ( pM->setFirstMatchId() )
  161.    {
  162.       while ( pM->getMatchId( theId ) )
  163.       {
  164.          LEmployeeData
  165.            *pED = new LEmployeeData( theId );
  166.          IString mgr =  pED->firstName() ;
  167.  
  168. /*-----------------------------------------------------------------------------
  169. | Add middle initial with a "." only if there is one                          |
  170. -----------------------------------------------------------------------------*/
  171.          if ( ( pED->middleInitial().length() > 0 ) &&
  172.               ( pED->middleInitial().isAlphabetic() > 0 ) )
  173.             mgr += " " + pED->middleInitial() + ". " ;
  174.          else
  175.             mgr +=" ";
  176.  
  177.          mgr += pED->lastName() ;
  178.  
  179.          respMgr.addAsLast( mgr ) ;
  180.          delete pED;
  181.          pM->getNextMatchId();
  182.       }
  183.    }
  184.  
  185.    delete pM;
  186.  
  187.    return *this;
  188. }
  189.  
  190.  
  191. /******************************************************************************
  192. * Class ProjectPage :: handleIt()                                             *
  193. ******************************************************************************/
  194. ProjectPage& ProjectPage::handleIt()
  195. {
  196. /*-----------------------------------------------------------------------------
  197. | Begin handling events.                                                      |
  198. -----------------------------------------------------------------------------*/
  199.    ICommandHandler::handleEventsFor( &pageButtons );
  200.    ICommandHandler::handleEventsFor( &pageCnrButtons );
  201.    ISelectHandler::handleEventsFor( &pageButtons );
  202. #ifdef IC_MOTIF
  203.     alphaNumericHandler.handleEventsFor( &project );
  204. #endif
  205.    return *this;
  206. }
  207.  
  208.  
  209. /******************************************************************************
  210. * Class ProjectPage :: fillCnr - Set up the container                         *
  211. ******************************************************************************/
  212. ProjectPage& ProjectPage::fillCnr()
  213. {
  214. /*-----------------------------------------------------------------------------
  215. | If the container already exists,                                            |
  216. |  delete all the objects                                                     |
  217. | Else create a new container.                                                |
  218. -----------------------------------------------------------------------------*/
  219.    if ( pCnr )
  220.       pCnr->deleteAllObjects();
  221.    else
  222.    {
  223.       pCnr = new IContainerControl( ID_PRJ_CNR,
  224.                                     this, this,
  225.                                     IRectangle(),
  226.                                     IContainerControl::classDefaultStyle
  227.                                     | IContainerControl::readOnly | IContainerControl::pmCompatible,
  228.                                     IContainerControl::readOnlyTitle
  229.                                     | IContainerControl::detailsView );
  230.  
  231. /*-----------------------------------------------------------------------------
  232. | Handle selection events for the new container.                              |
  233. -----------------------------------------------------------------------------*/
  234.       cnrSelHandler.handleEventsFor( pCnr );
  235.  
  236. /*-----------------------------------------------------------------------------
  237. | Delete the objects when the container is deleted.                           |
  238. | Tell the container to allow multiple selection.                             |
  239. | Tell the container to automatically refresh upon changes.                   |
  240. -----------------------------------------------------------------------------*/
  241.       pCnr->setDeleteObjectsOnClose();
  242.       pCnr->setDeleteColumnsOnClose();
  243.       pCnr->setMultipleSelection();
  244.  
  245. /*-----------------------------------------------------------------------------
  246. | Create four container columns.                                              |
  247. -----------------------------------------------------------------------------*/
  248.       pColProj =
  249.          new IContainerColumn( pProjCnrObj->projOffset(),
  250.                                IContainerColumn::defaultHeadingStyle(),
  251.                                IContainerColumn::string );
  252.  
  253.       pColDesc =
  254.          new IContainerColumn( pProjCnrObj->descOffset(),
  255.                                IContainerColumn::defaultHeadingStyle(),
  256.                                IContainerColumn::string );
  257.  
  258.       pColMgr =
  259.          new IContainerColumn( pProjCnrObj->mgrOffset(),
  260.                                IContainerColumn::defaultHeadingStyle(),
  261.                                IContainerColumn::string );
  262.  
  263.       pColAct =
  264.          new IContainerColumn( pProjCnrObj->actOffset(),
  265.                                IContainerColumn::defaultHeadingStyle(),
  266.                                IContainerColumn::string );
  267.  
  268. /*-----------------------------------------------------------------------------
  269. | Label the container column headings.                                        |
  270. | Show the headings.                                                          |
  271. | Show the headings.                                                          |
  272. -----------------------------------------------------------------------------*/
  273.       pColProj->setHeadingText( STR_PRJ_PROJECT2 );
  274.       pColDesc->setHeadingText( STR_PRJ_DESCRIPTION2 );
  275.       pColMgr->setHeadingText( STR_PRJ_MGR );
  276.       pColAct->setHeadingText( STR_PRJ_ACTIVE2 );
  277.       pCnr->showDetailsViewTitles();
  278.  
  279. /*-----------------------------------------------------------------------------
  280. | Add the columns to the container.                                           |
  281. | Add column separators between the columns.                                  |
  282. -----------------------------------------------------------------------------*/
  283.       pCnr->addColumn( pColProj );
  284.       pCnr->addColumn( pColDesc );
  285.       pCnr->addColumn( pColMgr );
  286.       pCnr->addColumn( pColAct );
  287.       pColProj->showSeparators( IContainerColumn::verticalSeparator
  288.                                 | IContainerColumn::horizontalSeparator );
  289.       pColDesc->showSeparators( IContainerColumn::verticalSeparator
  290.                                 | IContainerColumn::horizontalSeparator );
  291.       pColMgr->showSeparators( IContainerColumn::verticalSeparator
  292.                                | IContainerColumn::horizontalSeparator );
  293.       pColAct->showSeparators( IContainerColumn::horizontalSeparator );
  294.    }
  295.  
  296. /*-----------------------------------------------------------------------------
  297. | Start from the beginning of the project data.                               |
  298. | While there exists items,                                                   |
  299. |   add objects to the container.                                             |
  300. | Refresh the container.                                                      |
  301. | Return yourself.                                                            |
  302. -----------------------------------------------------------------------------*/
  303.    IString
  304.       theProj,
  305.       theDesc,
  306.       theMgr,
  307.       cbAct ;
  308.    LProjectData::Rule
  309.       rule = LProjectData::na;
  310.  
  311.    projectData.setFirst();
  312.    while ( projectData.getItem( theProj, theDesc, theMgr, cbAct , rule ) )
  313.    {
  314.       addProj( theProj, theDesc, theMgr, cbAct );
  315.       projectData.getNext();
  316.    }
  317.  
  318.    active.select();
  319.    pCnr->refresh();
  320.  
  321.    return *this;
  322. }
  323.  
  324.  
  325. /******************************************************************************
  326. * Class ProjectPage :: setCells - Set up your multicell canvas cells          *
  327. ******************************************************************************/
  328. ProjectPage& ProjectPage::setCells()
  329. {
  330. /*-----------------------------------------------------------------------------
  331. | Add the objects to your multicell canvas.                                   |
  332. | Allow the container to expand horizontally.                                 |
  333. | Allow the page buttons to expand horizontally.                              |
  334. | Return yourself.                                                            |
  335. -----------------------------------------------------------------------------*/
  336.    addToCell( &projText,        2,  2 );
  337.    addToCell( &project,         3,  2 );
  338.  
  339.    addToCell( &active,          5,  2 );
  340.    addToCell( &activeText,      6,  2 );
  341.  
  342.    addToCell( &descrText,       2,  3 );
  343.    addToCell( &descr,           3,  3 );
  344.  
  345.    addToCell( &respMgrText,     2,  4 );
  346.    addToCell( &respMgr,         3,  4 );
  347.    respMgr.setMinimumRows( 1 );
  348.  
  349.    addToCell( pCnr,             2,  6,  7,  3 );
  350.    addToCell( &pageCnrButtons,  9,  7 );
  351.    setColumnWidth(              8,  0,  true );
  352.  
  353.    addToCell( &pageButtons,     2,  9,  6,  3 );
  354.    setColumnWidth(              7,  0,  true );
  355.  
  356.    return *this;
  357. }
  358.  
  359.  
  360. /******************************************************************************
  361. * Class ProjectPage :: verifyAndSave - Save page information to the database  *
  362. ******************************************************************************/
  363. IBase::Boolean ProjectPage::verifyAndSave( IString& pString,
  364.                                            IString& theEntry,
  365.                                            const IString saveName )
  366. {
  367.  
  368. /*-----------------------------------------------------------------------------
  369. | If there is no data or is a query, return.                                  |
  370. -----------------------------------------------------------------------------*/
  371.    if ( ( ! saveName.length() )
  372.         && ( ! Key.length() ) )
  373.       return true;
  374.  
  375. /*-----------------------------------------------------------------------------
  376. | If able to retrieve the container information,                              |
  377. |  save the information to the database based on the key or query name.       |
  378. -----------------------------------------------------------------------------*/
  379.    if ( setProjectData() )
  380.    {
  381.       if ( saveName.length() )
  382.          projectData.save( saveName );
  383.       else
  384.          projectData.save( Key );
  385.    }
  386.  
  387.    return true;
  388. }
  389.  
  390.  
  391. /******************************************************************************
  392. * Class ProjectPage :: setProjectData - Retrieve the page information         *
  393. ******************************************************************************/
  394. IBase::Boolean ProjectPage :: setProjectData()
  395. {
  396.    IContainerControl::ObjectCursor
  397.       iterator( *pCnr );
  398.  
  399.    iterator.setToFirst();
  400.    if ( ! iterator.isValid() )
  401.       return false;
  402.  
  403.    ProjCnrObj
  404.      *cnrEntry;
  405.    IString
  406.       it1,
  407.       it2;
  408.  
  409. /*-----------------------------------------------------------------------------
  410. | Empty the bag.                                                              |
  411. | Iterate through the cursor and add objects to the bag.                      |
  412. -----------------------------------------------------------------------------*/
  413.    projectData.emptyBag();
  414.    while ( iterator.isValid() )
  415.    {
  416.       cnrEntry = (ProjCnrObj *) iterator.current();
  417.       projectData.putItem( cnrEntry->proj(),
  418.                            cnrEntry->desc(),
  419.                            cnrEntry->mgr(),
  420.                            cnrEntry->act() );
  421.       cnrEntry = (ProjCnrObj *) iterator.next();
  422.    }
  423.  
  424.    return true;
  425. }
  426.  
  427.  
  428. /******************************************************************************
  429. * Class ProjectPage :: fillEntryfields - Fill the entryfields for the object  *
  430. ******************************************************************************/
  431. ProjectPage& ProjectPage::fillEntryfields( ProjCnrObj* pCnrObject )
  432. {
  433. /*-----------------------------------------------------------------------------
  434. | Set the entryfields for the given project container object.                 |
  435. | Return yourself.                                                            |
  436. -----------------------------------------------------------------------------*/
  437.    project.setText( pCnrObject->proj() );
  438.    descr.setText( pCnrObject->desc() );
  439.    respMgr.setText( pCnrObject->mgr() );
  440.    if ( pCnrObject->act() == "yes" )
  441.       active.select();
  442.    else
  443.       active.select( false );
  444.  
  445.    return *this;
  446. };
  447.  
  448.  
  449. /******************************************************************************
  450. * Class ProjectPage :: command - Catch and process command events.            *
  451. ******************************************************************************/
  452. IBase::Boolean ProjectPage::command( ICommandEvent& cmdEvent )
  453. {
  454.    IString
  455.       theProj = project.text(),
  456.       theDesc = descr.text(),
  457.       theMgr  = respMgr.text(),
  458.       theAct = ( true == active.isSelected() ) ? "yes" : "no";
  459.    LProjectData::Rule
  460.       theRule = LProjectData::na;
  461.    Boolean
  462.       rc = false;
  463.    unsigned int
  464.       count = 0;
  465.  
  466. /*-----------------------------------------------------------------------------
  467. | Create a container object cursor based on the selected objects.             |
  468. | Process the command events.                                                 |
  469. -----------------------------------------------------------------------------*/
  470.    IContainerControl::ObjectCursor
  471.       soc( *pCnr, IContainerObject::selected );
  472.  
  473.    switch ( cmdEvent.commandId() )
  474.    {
  475. /*-----------------------------------------------------------------------------
  476. | User pressed the UNDO button.                                               |
  477. | Reset the project data to the original project data.                        |
  478. | Reset the container.                                                        |
  479. | Reset the entryfields, combobox, and checkbox.                              |
  480. -----------------------------------------------------------------------------*/
  481.       case ID_BUTTON_UNDO:
  482.       {
  483.          projectData = origProjectData;
  484.          fillCnr();
  485.          project.setText( "" );
  486.          descr.setText( "" );
  487.          respMgr.setText( "" );
  488.          active.select();
  489.          rc = true;
  490.          break;
  491.       }
  492.  
  493. /*-----------------------------------------------------------------------------
  494. | User pressed the REMOVE button.                                             |
  495. | Iterate through the selected objects,                                       |
  496. |  remove the object from the the database.                                   |
  497. -----------------------------------------------------------------------------*/
  498.       case ID_BUTTON_REMOVE:
  499.       {
  500.          for ( soc.setToFirst();
  501.                soc.isValid();
  502.                soc.setToNext())
  503.          {
  504.             ProjCnrObj
  505.               *pObj = (ProjCnrObj *) soc.current();
  506.             projectData.putItem( pObj->proj(),
  507.                                  pObj->desc(),
  508.                                  pObj->mgr(),
  509.                                  pObj->act(),
  510.                                  LProjectData::remove );
  511.             ++count;
  512.          }
  513.          if ( ! count )
  514.          {
  515.             IMessageBox
  516.                warning( owner() );
  517.             warning.show( STR_MSG_REMOVE,
  518.                           IMessageBox::enterButton
  519.                           | IMessageBox::informationIcon );
  520.          }
  521.          else
  522.          {
  523.             pCnr->removeSelectedObjects();
  524.             pCnr->refresh();
  525.          }
  526.          rc = true;
  527.          break;
  528.       }
  529.  
  530. /*-----------------------------------------------------------------------------
  531. | User pressed the CHANGE button.                                             |
  532. | Ignore all but the first selected container object.                         |
  533. | Update the entryfields with the selected container object information.      |
  534. -----------------------------------------------------------------------------*/
  535.       case ID_BUTTON_CHANGE:
  536.       {
  537.          soc.setToFirst();
  538.          if ( soc.isValid() )
  539.          {
  540.             if ( theProj.length() )
  541.             {
  542.                changeProj( theProj, theDesc, theMgr, theAct,
  543.                   (ProjCnrObj*) soc.current() );
  544.                project.setText( "" );
  545.                descr.setText( "" );
  546.                respMgr.setText( "" );
  547.                active.select();
  548.             }
  549.  
  550.          }
  551.          else
  552.          {
  553.             IMessageBox
  554.                warning( owner() );
  555.             warning.show( STR_MSG_CHANGE,
  556.                           IMessageBox::enterButton
  557.                           | IMessageBox::informationIcon );
  558.          }
  559.          unMark();
  560.          rc = true;
  561.          break;
  562.       }
  563.  
  564. /*-----------------------------------------------------------------------------
  565. | User pressed the ADD button.                                                |
  566. | Add the entryfield information to the database and container.               |
  567. | Reset the entryfields.                                                      |
  568. -----------------------------------------------------------------------------*/
  569.       case ID_BUTTON_ADD:
  570.       {
  571.          if ( theProj.length() )
  572.          {
  573.             addProj( theProj, theDesc, theMgr, theAct );
  574.             project.setText( "" );
  575.             descr.setText( "" );
  576.             respMgr.setText( "" );
  577.             active.select();
  578.          }
  579.  
  580. /*-----------------------------------------------------------------------------
  581. | Deselect any container objects.                                             |
  582. -----------------------------------------------------------------------------*/
  583.          unMark();
  584.          rc = true;
  585.          break;
  586.       }
  587.  
  588. /*-----------------------------------------------------------------------------
  589. | User pressed the HELP button.                                               |
  590. | Show the help for the account page.                                         |
  591. -----------------------------------------------------------------------------*/
  592.       case ID_BUTTON_HELP:
  593.       {
  594.          IHelpWindow::helpWindow( this )->
  595.             show( IResourceId( ID_PROJECT_PAGE ) );
  596.          rc = true;
  597.          break;
  598.       }
  599.    }
  600.  
  601.    return rc;
  602. }
  603.  
  604. /******************************************************************************
  605. * Class ProjectPage :: addProj - Add the project information to the container *
  606. ******************************************************************************/
  607. IBase::Boolean ProjectPage::addProj( IString& proj, IString& desc,
  608.                                      IString& mgr, IString& act )
  609. {
  610.    Boolean
  611.       rc = true;
  612.  
  613. /*-----------------------------------------------------------------------------
  614. | Create a container text cursor based on the project.                        |
  615. -----------------------------------------------------------------------------*/
  616.    IContainerControl::TextCursor
  617.       txtCur( *pCnr, IString( proj ), true, false, true );
  618.  
  619.    txtCur.setToFirst();
  620.    if ( txtCur.isValid() )
  621.       rc = false;
  622.  
  623. /*-----------------------------------------------------------------------------
  624. | If the object doesn't exist,                                                |
  625. |  Add the object to the database.                                            |
  626. |  Create a container object.                                                 |
  627. |  Add the object to the container.                                           |
  628. |  Refresh the container.                                                     |
  629. -----------------------------------------------------------------------------*/
  630.    if ( rc )
  631.    {
  632.       projectData.putItem( proj, desc, mgr, act, LProjectData::add );
  633.       pProjCnrObj = new ProjCnrObj( proj, desc, mgr, act );
  634.       pCnr->addObject( pProjCnrObj );
  635.       pCnr->refresh();
  636.    }
  637.  
  638.    return rc;
  639. }
  640.  
  641. /******************************************************************************
  642. * Class ProjectPage :: changeProj - Change the project information for the    *
  643. *  selected container object.                                                 *
  644. ******************************************************************************/
  645. IBase::Boolean ProjectPage::changeProj( IString& proj, IString& desc,
  646.                                         IString& mgr, IString& act,
  647.                                         ProjCnrObj* pCnrObj )
  648. {
  649.    Boolean
  650.       rc = true;
  651.  
  652. /*-----------------------------------------------------------------------------
  653. | Create a container text cursor based on the project.                        |
  654. -----------------------------------------------------------------------------*/
  655.    IContainerControl::TextCursor
  656.       txtCur( *pCnr, IString( proj ), true, false, true );
  657.  
  658.  
  659.    txtCur.setToFirst();
  660.    if ( !txtCur.isValid() )
  661.       rc = false;
  662.  
  663. /*-----------------------------------------------------------------------------
  664. | If the container object exists -and- the project exists,                    |
  665. |  Set the container object's data.                                           |
  666. |  Reset the entryfields.                                                     |
  667. |  Deselect the container objects.                                            |
  668. -----------------------------------------------------------------------------*/
  669.    if ( pCnrObj && rc )
  670.    {
  671.       pCnrObj->setProj( proj );
  672.       pCnrObj->setDesc( desc );
  673.       pCnrObj->setMgr( mgr );
  674.       pCnrObj->setAct( "yes" );
  675.  
  676.    }
  677.  
  678.    return rc;
  679. }
  680.  
  681.  
  682. /******************************************************************************
  683. * Class ProjectPage :: unMark - Deselect the selected container objects.      *
  684. ******************************************************************************/
  685. ProjectPage& ProjectPage::unMark()
  686. {
  687.    IContainerControl::ObjectCursor
  688.       co( *pCnr );
  689.    for ( co.setToFirst();
  690.          co.isValid();
  691.          co.setToNext() )
  692.    {
  693.       try
  694.       {
  695.          pCnr->removeSelected( pCnr->objectAt( co ) );
  696.       }
  697.       catch ( IException& exc )
  698.       {}
  699.    }
  700.  
  701.    return *this;
  702. };
  703.  
  704.  
  705. /******************************************************************************
  706. * Class ProjectCnrObj :: ProjectCnrObj - Constructor for project container    *
  707. *  objects.                                                                   *
  708. *                                                                             *
  709. * Define yourself as a container object.                                      *
  710. * Set the project in your private data.                                       *
  711. * Set the description in your private data.                                   *
  712. * Set the manager in your private data.                                       *
  713. * Set the active flag in your private data.                                   *
  714. ******************************************************************************/
  715. ProjCnrObj::ProjCnrObj(    const IString& stProj,
  716.                            const IString& stDesc,
  717.                            const IString& stMgr,
  718.                            const IString& stAct )
  719.      :IContainerObject(),
  720.       Proj( stProj ),
  721.       Desc( stDesc ),
  722.       Mgr(  stMgr  ),
  723.       Act(  stAct  )
  724. {}
  725.  
  726.  
  727. /******************************************************************************
  728. * Class ProjectCnrObj :: ~ProjectCnrObj - Destructor for project container    *
  729. *  object.                                                                    *
  730. ******************************************************************************/
  731. ProjCnrObj :: ~ProjCnrObj()
  732. {}
  733.