home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / IDEHOOK.PAK / WIPEOPTS.CPP < prev    next >
C/C++ Source or Header  |  1995-08-29  |  4KB  |  183 lines

  1. //----------------------------------------------------------------------------
  2. // IdeHook - (C) Copyright 1994 by Borland International
  3. //----------------------------------------------------------------------------
  4. #pragma hdrstop
  5.  
  6. #include "idehook.h"
  7. #include <string.h>
  8.  
  9. static char wipeOptsName[] = "OptionsWiper";
  10.  
  11.  
  12. class _HOOKCLASS LocalToolClient : public ToolClient
  13. {
  14. public:
  15.     ToolReturn _HOOKEP RunOptionWiper( ToolInvokeArgs * );
  16.  
  17.     void RegisterMyCallBacks( ToolServer * );
  18.  
  19. private:
  20.  
  21.    void WipeNodeOptions( ProjectNode, ProjectServer *, OptionSetServer * );
  22.  
  23.             int                 registered;
  24.     static  ToolRegisterPack    entryPoints[];
  25.  
  26. };
  27.  
  28. static LocalToolClient  localToolClient;
  29.  
  30. ToolRegisterPack LocalToolClient::entryPoints[] =
  31. {
  32.     { wipeOptsName, (ToolMethod)&LocalToolClient::RunOptionWiper },
  33.     { 0 }
  34. };
  35.  
  36. void
  37. LocalToolClient::RegisterMyCallBacks( ToolServer * ts )
  38. {
  39.     if( !registered )
  40.     {
  41.         registered = 1;
  42.         ts->ToolRegisterImplementor( this, entryPoints );
  43.     }
  44. }
  45.  
  46. void
  47. LocalToolClient::WipeNodeOptions
  48. (
  49.    ProjectNode         node,
  50.    ProjectServer *     projectServer,
  51.    OptionSetServer *  optSetServer
  52. )
  53. {
  54.     optSetServer->OptionRemove( node, OID_RemoveAll );
  55.  
  56.     ProjectNodeInfo    nodeInfo;
  57.  
  58.     projectServer->QueryNodeInfo( node, nodeInfo );
  59.  
  60.     node = nodeInfo.firstChild;
  61.  
  62.     while( node )
  63.     {
  64.        WipeNodeOptions( node, projectServer, optSetServer );
  65.  
  66.        projectServer->QueryNodeInfo( node, nodeInfo );
  67.  
  68.        node = nodeInfo.nextSibling;
  69.     }
  70. }
  71.  
  72. ToolReturn _HOOKEP 
  73. LocalToolClient::RunOptionWiper( ToolInvokeArgs * args )
  74. {
  75.     int count = args->numNodes;
  76.  
  77.     ProjectReq     projectServer;
  78.     OptionSetReq   optSetServer;
  79.     
  80.     for( int i = 0; i < count; i++ )
  81.     {
  82.        ProjectNode   node = args->nodeArray[i];
  83.  
  84.        WipeNodeOptions( node, projectServer, optSetServer );
  85.     }
  86.  
  87.     return( Success );
  88. }
  89.  
  90.  
  91. //
  92. //      Project stuff
  93. //
  94.  
  95. class _HOOKCLASS LocalProjClient : public ProjectClient
  96. {
  97. public:
  98.    LocalProjClient();
  99.    
  100.     virtual void _HOOKEP    OpenNotify
  101.                                     (
  102.                                         const char * name 
  103.                                     );
  104.  
  105.     virtual void _HOOKEP    CloseNotify();
  106.  
  107.     virtual void _HOOKEP NodeDeleteNotify
  108.                                     (
  109.                                         ProjectNode
  110.                                     );
  111.                                 
  112.     virtual void _HOOKEP  DependencyQueryResponder
  113.                                     (
  114.                                         ProjectNode , 
  115.                                         const char * 
  116.                                     );
  117. };
  118.  
  119. static LocalProjClient LocalProjClient;
  120.  
  121. LocalProjClient::LocalProjClient()
  122. {
  123.    ProjectReq ps;
  124.  
  125.    ps->RegisterProjectClient(this);
  126. }
  127.  
  128.  
  129. void _HOOKEP
  130. LocalProjClient::OpenNotify
  131. (
  132.    const char * // name 
  133. )
  134. {
  135.     ToolReq   ts;
  136.  
  137.     localToolClient.RegisterMyCallBacks( ts );
  138.  
  139.     if( !ts->ToolFind( wipeOptsName ) )
  140.     {
  141.         ToolInfo toolInfo;
  142.  
  143.         toolInfo.toolType      = Transfer;
  144.         toolInfo.name          = wipeOptsName;
  145.         toolInfo.path          = 0;
  146.         toolInfo.flags         = OnToolsMenu;
  147.         toolInfo.menuName      = "&Options Wiper";
  148.         toolInfo.helpHint      = "Delete the local overrides for node(s)";
  149.         toolInfo.defCmdLine    = 0;
  150.         toolInfo.appliesTo     = 0;
  151.         toolInfo.defaultFor    = 0;
  152.         toolInfo.translateTo   = 0;
  153.         toolInfo.launchId      = CALLBACK_LAUNCH_ID;
  154.  
  155.         ts->ToolAdd( &toolInfo );
  156.     }
  157. }
  158.  
  159. void _HOOKEP
  160. LocalProjClient::CloseNotify()
  161. {
  162. }
  163.  
  164. void _HOOKEP
  165. LocalProjClient::NodeDeleteNotify
  166. (
  167.    ProjectNode
  168. )
  169. {
  170. }
  171.  
  172. void _HOOKEP  
  173. LocalProjClient::DependencyQueryResponder
  174. (
  175.    ProjectNode ,
  176.    const char *
  177. )
  178. {
  179. }
  180.  
  181. // End of file
  182.  
  183.