home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.bin / SourceCode / Palettes / IBMole / Examples / main1.m < prev    next >
Encoding:
Text File  |  1994-06-11  |  1.6 KB  |  73 lines

  1. #import <remote/NXConnection.h>
  2. /*
  3.     This is the nastiest program I've done so far.  In fifteen minutes it changed 800+ SmartFields in 33 nibs into TextFields and SmartCells into TextCells.  If you have ever seriously used SmartFields then you probably know why I wanted to do that.
  4. */
  5.  
  6. main()
  7. {
  8.     id server;
  9.     id docList;
  10.     int count;
  11.     id 
  12.         obj,
  13.         cell,
  14.         parser;
  15.     char
  16.         buf[256]="";
  17.     server = [NXConnection connectToName:"IBMole"];
  18.     if (server)
  19.     {
  20.         printf("Got the mole!\n");
  21.     }
  22.     docList = [server docList];
  23.     count = [docList count];
  24.     printf("%d docs\n",count);
  25.     while (count--)
  26.     {
  27.         int objCount;
  28.         id objs=[[List alloc] init];
  29.         
  30.         [[docList objectAt:count] getObjects:objs];
  31.         objCount = [objs count];
  32.     printf("%d objects\n",objCount);
  33.         while (objCount--)
  34.         {
  35.             cell = nil;
  36.             obj = [objs objectAt:objCount];
  37.             printf("%s class\n",[[obj class] name]);
  38.             if ([obj respondsTo:@selector(setTextDelegate:)])
  39.             {
  40.                 [obj setTextDelegate:NULL];
  41.                 printf("Changed textDelegate\n");
  42.             }
  43.             if (!strcmp("OTSmartField",[[obj class] name]))
  44.             {
  45.                 cell = [obj cell];
  46.             }
  47.             
  48.             if (!strcmp("OTSmartCell",[[obj class] name]))
  49.             {
  50.                 cell = obj;
  51.             }
  52.             printf("cell is %s\n",[[cell class] name]);
  53.             printf("parser is %s\n",[[[cell parser] class] name]);
  54.             if (cell)
  55.             {
  56.                 parser = [cell parser];
  57.                 if (!strcmp("OTPvdLookup",[[parser class] name]))
  58.                 {
  59.                     if ([obj isEditable] && strcmp("date",[parser lookupName]))
  60.                     {//becomeSuperclass method installed as a catagory to Object in my palette...
  61.                         [obj becomeSuperclass];
  62.                         [cell becomeSuperclass];
  63.                         printf("Turned a SmartField to a TextField!\n");
  64.                     }
  65.                     printf(".\n");
  66.                 }
  67.             }
  68.  
  69.         }
  70.     }
  71.     exit(0);
  72. }
  73.