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

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