Changeset 347

Show
Ignore:
Timestamp:
Mon Oct 22 18:38:12 2007
Author:
Brian
Message:

Changed eol-style to native; accept characters into ORM drawing canvas

Files:

Legend:

Unmodified
Added
Removed
Modified
  • scripts/trunk/ORM/Install ORM Tables.py

    r344 r347  
    1   # Install ORM Tables  
    2   # Copyright 2004, 2005, 2006, 2007 by Brian C. Christensen  
    3    
    4   #    This file is part of GanttPV.  
    5   #  
    6   #    GanttPV is free software; you can redistribute it and/or modify  
    7   #    it under the terms of the GNU General Public License as published by  
    8   #    the Free Software Foundation; either version 2 of the License, or  
    9   #    (at your option) any later version.  
    10   #  
    11   #    GanttPV is distributed in the hope that it will be useful,  
    12   #    but WITHOUT ANY WARRANTY; without even the implied warranty of  
    13   #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
    14   #    GNU General Public License for more details.  
    15   #  
    16   #    You should have received a copy of the GNU General Public License  
    17   #    along with GanttPV; if not, write to the Free Software  
    18   #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
    19    
    20   # 070806 - first draft of program based on Install Assignment Hours  
    21   #       Included draft of tables and objects  
    22   # 070807 - added object and report_object  
    23   # 070907 - more corrections and additions  
    24    
    25   # These design notes are intended to explore the problem. They include more than will be  
    26   #   implemented in the initial version.  
    27    
    28   def DoAdd():  
    29       # Specified all required Report Types and Column Types  
    30       # It will either add them or update them if they already exist.  
    31    
    32   #       Report  
    33   #           set it so that data.py won't manage the rows - done  
    34    
    35   #       ReportRow - all diagram objects are represented as a report row  
    36   #       - ID  
    37   #       - ReportID  
    38   #       - PosX      # these refer to the center of the object (the target of arrows pointing to the object)  
    39   #       - PosY  
    40   #                   # this line connects these two objects, follow each end if it is moved  
    41   #       - NodeAID   # these are pointers to other ReportRow objects that are the ends of a connector  
    42   #       - NodeBID  
    43   #       - OffsetX   # Text that is displayed offset from the main object (that text is separately moveable)  
    44   #       - OffsetY   # needed for role, probably not for reading  
    45   #       - Moveable  # can this object be moved with the mouse - is this needed????  
    46   #       - FollowID  # if this ID is moved, follow it - is this needed? - maybe - for reading?  
    47    
    48   #       ORMObject  
    49   #       - ID  
    50   #       - ProjectID (Schema)  
    51   #       - Name  
    52   #       - RefMode = identifier used to refer to instances of object  
    53   #       - Type ['Entity', 'Value']  
    54   #       - Independent [None, '!']  
    55   #       - Derived [None, '*', '+']  
    56   #       - DerivationRule  
    57    
    58       rt = { 'Name': 'ORM Diagram', 'TableA': 'ORMObject', 'TableB': None, 'Also': None, 'AllOrEach': 'each',  
    59              'SuggestedColumns': ',ID;,Name', 'AdjustRowOption': 'ORMDiagram' }  
    60       ct = [  
    61       { 'Name': 'ID',           'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35  },  
    62       { 'Name': 'Name',         'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 100  },  
    63           ]  
    64       Data.AddReportType(rt, ct)  
    65    
    66    
    67       rt = { 'Name': 'ORM Objects', 'TableA': 'ORMObject', 'TableB': None, 'Also': None, 'AllOrEach': 'each',  
    68              'SuggestedColumns': ',ID;,Name;,RefMode;,Type;,Independent;,Derived;,DerivationRule;,DateAdded' }  
    69       ct = [  
    70       { 'Name': 'ProjectID',    'Label': 'Project\nID',    'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 50  },  
    71       { 'Name': 'Project/Name', 'Label': 'Project\nName',  'DataType': 't', 'AccessType': 'i', 'T': 'A', 'Edit': False, 'Width': 100  },  
    72       { 'Name': 'ID',           'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35  },  
    73       { 'Name': 'Name',         'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 100  },  
    74       { 'Name': 'RefMode',      'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 100  },  
    75       { 'Name': 'Type',         'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
    76       { 'Name': 'Independent',  'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 75  },  
    77       { 'Name': 'Derived',      'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 50  },  
    78       { 'Name': 'DerivationRule',  'Label': None,          'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 180  },  
    79       { 'Name': 'DateAdded',    'Label': 'Date\nAdded',    'DataType': 'd', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 80  },  
    80           ]  
    81       Data.AddReportType(rt, ct)  
    82    
    83   #       ORMFact  
    84   #       - ID  
    85   #       - ProjectID (Schema)  
    86   #       - Nary (1 ..)  
    87   #       - ORMReadingID         # prefered reading  
    88   #       - ORMReadingAltID            # do I need this????  
    89   #       - Derived [None, '*', '+']  
    90   #       - DerivationRule  
    91    
    92       rt = { 'Name': 'ORM Facts', 'TableA': 'ORMFact', 'TableB': None, 'Also': None, 'AllOrEach': 'each',  
    93              'SuggestedColumns': ',ID;,Name;,RefMode;,Type;,Independent;,Derived;,DerivationRule;,DateAdded' }  
    94       ct = [  
    95       { 'Name': 'ProjectID',    'Label': 'Project\nID',    'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 50  },  
    96       { 'Name': 'Project/Name', 'Label': 'Project\nName',  'DataType': 't', 'AccessType': 'i', 'T': 'A', 'Edit': False, 'Width': 100  },  
    97       { 'Name': 'ID',           'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35  },  
    98       { 'Name': 'Name',         'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 100  },  
    99       { 'Name': 'Nary',          'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 100  },  
    100       { 'Name': 'ORMReadingID',   'Label': 'ReadingID',    'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
    101       { 'Name': 'ORMReadingAltID','Label': 'ReadingAltID', 'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 75  },  
    102       { 'Name': 'Derived',       'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 50  },  
    103       { 'Name': 'DerivationRule',  'Label': None,          'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 180  },  
    104       { 'Name': 'DateAdded',     'Label': 'Date\nAdded',    'DataType': 'd', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 80  },  
    105           ]  
    106       Data.AddReportType(rt, ct)  
    107    
    108   #       ORMReading  (follows the fact, but has it's own X&Y)  
    109   #       - ID  
    110   #       - ProjectID (Schema)  
    111   #       - ORMFactID  
    112   #       - Reading (reading text refers to role ids??)  
    113    
    114       rt = { 'Name': 'ORM Reading', 'TableA': 'ORMReading', 'TableB': None, 'Also': None, 'AllOrEach': 'each',  
    115              'SuggestedColumns': ',ID;,FactID;,Reading;,DateAdded' }  
    116       ct = [  
    117       { 'Name': 'ProjectID',     'Label': 'Project\nID',    'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 50  },  
    118       { 'Name': 'Project/Name',  'Label': 'Project\nName',  'DataType': 't', 'AccessType': 'i', 'T': 'A', 'Edit': False, 'Width': 100  },  
    119       { 'Name': 'ID',            'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35  },  
    120       { 'Name': 'ORMFactID',     'Label': 'ORMFactID',      'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 100  },  
    121       { 'Name': 'Reading',       'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
    122       { 'Name': 'DateAdded',     'Label': 'Date\nAdded',    'DataType': 'd', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 80  },  
    123           ]  
    124       Data.AddReportType(rt, ct)  
    125    
    126   #       ORMRole  (the role name can be positioned, but the line end points follow the entities and facts  
    127   #       - ID  
    128   #       - ProjectID (Schema)  
    129   #       - ORMFactID - NodeA in the report row  
    130   #       - ORMObjectID - NodeB in the report row  
    131   #       - Seq = sequence number - this identifies the position of the role in the fact  
    132   #       - Name  
    133   #       - Mandatory ['a', 'd']  
    134   #       - Unique ['a', 'd']  
    135    
    136       rt = { 'Name': 'ORM Role', 'TableA': 'ORMRole', 'TableB': None, 'Also': None, 'AllOrEach': 'each',  
    137              'SuggestedColumns': ',ID;,FactID;,Seq;,Name;,DateAdded' }  
    138       ct = [  
    139       { 'Name': 'ProjectID',     'Label': 'Project\nID',    'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 50  },  
    140       { 'Name': 'Project/Name',  'Label': 'Project\nName',  'DataType': 't', 'AccessType': 'i', 'T': 'A', 'Edit': False, 'Width': 100  },  
    141       { 'Name': 'ID',            'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35  },  
    142       { 'Name': 'ORMFactID',     'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 100  },  
    143       { 'Name': 'ORMObjectID',   'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 100  },  
    144       { 'Name': 'Seq',           'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 100  },  
    145       { 'Name': 'Name',          'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
    146       { 'Name': 'Mandatory',     'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
    147       { 'Name': 'Unique',        'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
    148       { 'Name': 'DateAdded',     'Label': 'Date\nAdded',    'DataType': 'd', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 80  },  
    149           ]  
    150       Data.AddReportType(rt, ct)  
    151    
    152   #       ORMConstraint  
    153   #       - ID  
    154   #       - ProjectID (Schema)  
    155   ##       - Name  
    156   #       - Type ['a', 'd']  
    157   #       - Unique ['a', 'd']  
    158   #       - ORMPathID  
    159   #       - ORMPathAltID  
    160    
    161       rt = { 'Name': 'ORM Constraint', 'TableA': 'ORMConstraint', 'TableB': None, 'Also': None, 'AllOrEach': 'each',  
    162              'SuggestedColumns': ',ID;,FactID;,Seq;,Name;,DateAdded' }  
    163       ct = [  
    164       { 'Name': 'ProjectID',     'Label': 'Project\nID',    'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 50  },  
    165       { 'Name': 'Project/Name',  'Label': 'Project\nName',  'DataType': 't', 'AccessType': 'i', 'T': 'A', 'Edit': False, 'Width': 100  },  
    166       { 'Name': 'ID',            'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35  },  
    167       { 'Name': 'Type',          'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
    168       { 'Name': 'Alethic',       'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
    169       { 'Name': 'DateAdded',     'Label': 'Date\nAdded',    'DataType': 'd', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 80  },  
    170           ]  
    171       Data.AddReportType(rt, ct)  
    172    
    173       rt = { 'Name': 'ORM Constraint Connectors', 'TableA': 'ORMConstraintConnector', 'TableB': None, 'Also': None, 'AllOrEach': 'each',  
    174              'SuggestedColumns': ',ID;,ORMNoteID;,TableName;,TableID' }  
    175       ct = [  
    176       { 'Name': 'ID',           'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35  },  
    177       { 'Name': 'ORMConstraintID',    'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 55  },  
    178       { 'Name': 'ORMRoleID',      'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 55  },  
    179           ]  
    180       Data.AddReportType(rt, ct)  
    181    
    182   #       ORMPath  
    183   #       - ID  
    184   #       - ProjectID (Schema)  
    185   ##       - Name  
    186    
    187   #       ORMPathLink  
    188   #       - ID  
    189   #       - ProjectID (Schema)  
    190   #       - ORMRole  
    191   #       - Sequence  (1 ..)  
    192    
    193   #       ORMNote  
    194   #       - ID  
    195   #       - ProjectID (Schema)  
    196   #       - Text  
    197    
    198       rt = { 'Name': 'ORM Notes', 'TableA': 'ORMNote', 'TableB': None, 'Also': None, 'AllOrEach': 'each',  
    199              'SuggestedColumns': ',ID;,Text' }  
    200       ct = [  
    201       { 'Name': 'ID',           'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35  },  
    202       { 'Name': 'Text',         'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 300  },  
    203           ]  
    204       Data.AddReportType(rt, ct)  
    205    
    206   #       ORMNoteConnector  
    207   #       - ID  
    208   #       - ProjectID (Schema)  
    209   #       - ORMNoteID  # notes are always at one end of the note connector  
    210   #       - TableName - this is the way ganttpv points to any object  
    211   #       - TableID  
    212    
    213       rt = { 'Name': 'ORM Note Connectors', 'TableA': 'ORMNoteConnector', 'TableB': None, 'Also': None, 'AllOrEach': 'each',  
    214              'SuggestedColumns': ',ID;,ORMNoteID;,TableName;,TableID' }  
    215       ct = [  
    216       { 'Name': 'ID',           'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35  },  
    217       { 'Name': 'ORMNoteID',    'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 55  },  
    218       { 'Name': 'TableName',    'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 100  },  
    219       { 'Name': 'TableID',      'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 55  },  
    220           ]  
    221       Data.AddReportType(rt, ct)  
    222    
    223   # --------------------------  
    224    
    225   ### instead of a report object, it might be better just to use the good old report row?  
    226   ##    rt = { 'Name': 'ORM Report Objects', 'TableA': 'ORMReportObject', 'TableB': None, 'Also': None, 'AllOrEach': 'each',  
    227   ##           'SuggestedColumns': ',ReportID;,Report/Name;,ID;,ORMObjectID;,ORMObject/Name;,PosX;,PosY;,DateAdded' }  
    228   ##    ct = [  
    229   ##    { 'Name': 'ProjectID',    'Label': 'Project\nID',    'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 50  },  
    230   ##    { 'Name': 'Project/Name', 'Label': 'Project\nName',  'DataType': 't', 'AccessType': 'i', 'T': 'A', 'Edit': False, 'Width': 100  },  
    231   ##    { 'Name': 'ReportID',     'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
    232   ##    { 'Name': 'Report/Name',  'Label': 'Report\nName',   'DataType': 't', 'AccessType': 'i', 'T': 'A', 'Edit': False, 'Width': 100  },  
    233   ##    { 'Name': 'ID',           'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35  },  
    234   ##    { 'Name': 'ORMObjectID',  'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 80  },  
    235   ##    { 'Name': 'ORMObject/Name', 'Label': 'ORMObject\nName', 'DataType': 't', 'AccessType': 'i', 'T': 'A', 'Edit': False, 'Width': 100  },  
    236   ##    { 'Name': 'PosX',         'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
    237   ##    { 'Name': 'PosY',         'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
    238   ##    { 'Name': 'DateAdded',    'Label': 'Date\nAdded',    'DataType': 'd', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 80  },  
    239   ##        ]  
    240   ##    Data.AddReportType(rt, ct)  
    241    
    242   #       ReportORMFact  
    243   #       - ORMFactID  # many may point to same  
    244   #       - ReportID  
    245   #       - PosX  
    246   #       - PosY  
    247    
    248   #       ReportORMRole  
    249   #       - ORMRoleID  # many may point to same  
    250   #       - ReportID  
    251   #       - ReportORMFactID       # these determine where to draw the role  
    252   #       - ReportORMObjectID     #  
    253    
    254   #       ReportORMConstraint  
    255   #       - ORMConstraintID  # many may point to same  
    256   #       - ReportID  
    257   #       - PosX  
    258   #       - PosY  
    259    
    260   #       ReportORMNote  
    261   #       - ORMNoteID  # many may point to same  
    262   #       - ReportID  
    263   #       - PosX  
    264   #       - PosY  
    265   #       - ObjectType        # can point to any orm report object  
    266   #       - ObjectID  
    267    
    268   # This script must be run against each file to include the new report options.  
    269    
    270   # If you want to make sure the report types and column types you add don't conflict  
    271   #    with new releases of GanttPV, prefix the Name with "xx". For  
    272   #    example: "xxDocument", "xxOwner", "xxURL", etc.  
    273    
    274       # add required data tables  
    275   #    Data.AddTable('ProjectWeek')  
    276    
    277       # add required aliases  
    278       Data.Database['NodeA'] = Data.Database['ReportRow']  # Does this name work?  
    279       Data.Database['NodeB'] = Data.Database['ReportRow']  
    280       Data.AddAlias('NodeA', 'ReportRow')     # is this the best way to do this?  
    281       Data.AddAlias('NodeB', 'ReportRow')  
    282    
    283       Data.SetUndo("Install ORM Tables")  
    284    
    285   # do only if GanttPV version 0.2 or greater  
    286   DoAdd()  
      1 # Install ORM Tables  
      2 # Copyright 2004, 2005, 2006, 2007 by Brian C. Christensen  
      3  
      4 #    This file is part of GanttPV.  
      5 #  
      6 #    GanttPV is free software; you can redistribute it and/or modify  
      7 #    it under the terms of the GNU General Public License as published by  
      8 #    the Free Software Foundation; either version 2 of the License, or  
      9 #    (at your option) any later version.  
      10 #  
      11 #    GanttPV is distributed in the hope that it will be useful,  
      12 #    but WITHOUT ANY WARRANTY; without even the implied warranty of  
      13 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
      14 #    GNU General Public License for more details.  
      15 #  
      16 #    You should have received a copy of the GNU General Public License  
      17 #    along with GanttPV; if not, write to the Free Software  
      18 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
      19  
      20 # 070806 - first draft of program based on Install Assignment Hours  
      21 #       Included draft of tables and objects  
      22 # 070807 - added object and report_object  
      23 # 070907 - more corrections and additions  
      24  
      25 # These design notes are intended to explore the problem. They include more than will be  
      26 #   implemented in the initial version.  
      27  
      28 def DoAdd():  
      29     # Specified all required Report Types and Column Types  
      30     # It will either add them or update them if they already exist.  
      31  
      32 #       Report  
      33 #           set it so that data.py won't manage the rows - done  
      34  
      35 #       ReportRow - all diagram objects are represented as a report row  
      36 #       - ID  
      37 #       - ReportID  
      38 #       - PosX      # these refer to the center of the object (the target of arrows pointing to the object)  
      39 #       - PosY  
      40 #                   # this line connects these two objects, follow each end if it is moved  
      41 #       - NodeAID   # these are pointers to other ReportRow objects that are the ends of a connector  
      42 #       - NodeBID  
      43 #       - OffsetX   # Text that is displayed offset from the main object (that text is separately moveable)  
      44 #       - OffsetY   # needed for role, probably not for reading  
      45 #       - Moveable  # can this object be moved with the mouse - is this needed????  
      46 #       - FollowID  # if this ID is moved, follow it - is this needed? - maybe - for reading?  
      47  
      48 #       ORMObject  
      49 #       - ID  
      50 #       - ProjectID (Schema)  
      51 #       - Name  
      52 #       - RefMode = identifier used to refer to instances of object  
      53 #       - Type ['Entity', 'Value']  
      54 #       - Independent [None, '!']  
      55 #       - Derived [None, '*', '+']  
      56 #       - DerivationRule  
      57  
      58     rt = { 'Name': 'ORM Diagram', 'TableA': 'ORMObject', 'TableB': None, 'Also': None, 'AllOrEach': 'each',  
      59            'SuggestedColumns': ',ID;,Name', 'AdjustRowOption': 'ORMDiagram' }  
      60     ct = [  
      61     { 'Name': 'ID',           'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35  },  
      62     { 'Name': 'Name',         'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 100  },  
      63         ]  
      64     Data.AddReportType(rt, ct)  
      65  
      66  
      67     rt = { 'Name': 'ORM Objects', 'TableA': 'ORMObject', 'TableB': None, 'Also': None, 'AllOrEach': 'each',  
      68            'SuggestedColumns': ',ID;,Name;,RefMode;,Type;,Independent;,Derived;,DerivationRule;,DateAdded' }  
      69     ct = [  
      70     { 'Name': 'ProjectID',    'Label': 'Project\nID',    'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 50  },  
      71     { 'Name': 'Project/Name', 'Label': 'Project\nName',  'DataType': 't', 'AccessType': 'i', 'T': 'A', 'Edit': False, 'Width': 100  },  
      72     { 'Name': 'ID',           'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35  },  
      73     { 'Name': 'Name',         'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 100  },  
      74     { 'Name': 'RefMode',      'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 100  },  
      75     { 'Name': 'Type',         'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
      76     { 'Name': 'Independent',  'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 75  },  
      77     { 'Name': 'Derived',      'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 50  },  
      78     { 'Name': 'DerivationRule',  'Label': None,          'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 180  },  
      79     { 'Name': 'DateAdded',    'Label': 'Date\nAdded',    'DataType': 'd', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 80  },  
      80         ]  
      81     Data.AddReportType(rt, ct)  
      82  
      83 #       ORMFact  
      84 #       - ID  
      85 #       - ProjectID (Schema)  
      86 #       - Nary (1 ..)  
      87 #       - ORMReadingID         # prefered reading  
      88 #       - ORMReadingAltID            # do I need this????  
      89 #       - Derived [None, '*', '+']  
      90 #       - DerivationRule  
      91  
      92     rt = { 'Name': 'ORM Facts', 'TableA': 'ORMFact', 'TableB': None, 'Also': None, 'AllOrEach': 'each',  
      93            'SuggestedColumns': ',ID;,Name;,RefMode;,Type;,Independent;,Derived;,DerivationRule;,DateAdded' }  
      94     ct = [  
      95     { 'Name': 'ProjectID',    'Label': 'Project\nID',    'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 50  },  
      96     { 'Name': 'Project/Name', 'Label': 'Project\nName',  'DataType': 't', 'AccessType': 'i', 'T': 'A', 'Edit': False, 'Width': 100  },  
      97     { 'Name': 'ID',           'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35  },  
      98     { 'Name': 'Name',         'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 100  },  
      99     { 'Name': 'Nary',          'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 100  },  
      100     { 'Name': 'ORMReadingID',   'Label': 'ReadingID',    'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
      101     { 'Name': 'ORMReadingAltID','Label': 'ReadingAltID', 'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 75  },  
      102     { 'Name': 'Derived',       'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 50  },  
      103     { 'Name': 'DerivationRule',  'Label': None,          'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 180  },  
      104     { 'Name': 'DateAdded',     'Label': 'Date\nAdded',    'DataType': 'd', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 80  },  
      105         ]  
      106     Data.AddReportType(rt, ct)  
      107  
      108 #       ORMReading  (follows the fact, but has it's own X&Y)  
      109 #       - ID  
      110 #       - ProjectID (Schema)  
      111 #       - ORMFactID  
      112 #       - Reading (reading text refers to role ids??)  
      113  
      114     rt = { 'Name': 'ORM Reading', 'TableA': 'ORMReading', 'TableB': None, 'Also': None, 'AllOrEach': 'each',  
      115            'SuggestedColumns': ',ID;,FactID;,Reading;,DateAdded' }  
      116     ct = [  
      117     { 'Name': 'ProjectID',     'Label': 'Project\nID',    'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 50  },  
      118     { 'Name': 'Project/Name',  'Label': 'Project\nName',  'DataType': 't', 'AccessType': 'i', 'T': 'A', 'Edit': False, 'Width': 100  },  
      119     { 'Name': 'ID',            'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35  },  
      120     { 'Name': 'ORMFactID',     'Label': 'ORMFactID',      'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 100  },  
      121     { 'Name': 'Reading',       'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
      122     { 'Name': 'DateAdded',     'Label': 'Date\nAdded',    'DataType': 'd', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 80  },  
      123         ]  
      124     Data.AddReportType(rt, ct)  
      125  
      126 #       ORMRole  (the role name can be positioned, but the line end points follow the entities and facts  
      127 #       - ID  
      128 #       - ProjectID (Schema)  
      129 #       - ORMFactID - NodeA in the report row  
      130 #       - ORMObjectID - NodeB in the report row  
      131 #       - Seq = sequence number - this identifies the position of the role in the fact  
      132 #       - Name  
      133 #       - Mandatory ['a', 'd']  
      134 #       - Unique ['a', 'd']  
      135  
      136     rt = { 'Name': 'ORM Role', 'TableA': 'ORMRole', 'TableB': None, 'Also': None, 'AllOrEach': 'each',  
      137            'SuggestedColumns': ',ID;,FactID;,Seq;,Name;,DateAdded' }  
      138     ct = [  
      139     { 'Name': 'ProjectID',     'Label': 'Project\nID',    'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 50  },  
      140     { 'Name': 'Project/Name',  'Label': 'Project\nName',  'DataType': 't', 'AccessType': 'i', 'T': 'A', 'Edit': False, 'Width': 100  },  
      141     { 'Name': 'ID',            'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35  },  
      142     { 'Name': 'ORMFactID',     'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 100  },  
      143     { 'Name': 'ORMObjectID',   'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 100  },  
      144     { 'Name': 'Seq',           'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 100  },  
      145     { 'Name': 'Name',          'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
      146     { 'Name': 'Mandatory',     'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
      147     { 'Name': 'Unique',        'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
      148     { 'Name': 'DateAdded',     'Label': 'Date\nAdded',    'DataType': 'd', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 80  },  
      149         ]  
      150     Data.AddReportType(rt, ct)  
      151  
      152 #       ORMConstraint  
      153 #       - ID  
      154 #       - ProjectID (Schema)  
      155 ##       - Name  
      156 #       - Type ['a', 'd']  
      157 #       - Unique ['a', 'd']  
      158 #       - ORMPathID  
      159 #       - ORMPathAltID  
      160  
      161     rt = { 'Name': 'ORM Constraint', 'TableA': 'ORMConstraint', 'TableB': None, 'Also': None, 'AllOrEach': 'each',  
      162            'SuggestedColumns': ',ID;,FactID;,Seq;,Name;,DateAdded' }  
      163     ct = [  
      164     { 'Name': 'ProjectID',     'Label': 'Project\nID',    'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 50  },  
      165     { 'Name': 'Project/Name',  'Label': 'Project\nName',  'DataType': 't', 'AccessType': 'i', 'T': 'A', 'Edit': False, 'Width': 100  },  
      166     { 'Name': 'ID',            'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35  },  
      167     { 'Name': 'Type',          'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
      168     { 'Name': 'Alethic',       'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
      169     { 'Name': 'DateAdded',     'Label': 'Date\nAdded',    'DataType': 'd', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 80  },  
      170         ]  
      171     Data.AddReportType(rt, ct)  
      172  
      173     rt = { 'Name': 'ORM Constraint Connectors', 'TableA': 'ORMConstraintConnector', 'TableB': None, 'Also': None, 'AllOrEach': 'each',  
      174            'SuggestedColumns': ',ID;,ORMNoteID;,TableName;,TableID' }  
      175     ct = [  
      176     { 'Name': 'ID',           'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35  },  
      177     { 'Name': 'ORMConstraintID',    'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 55  },  
      178     { 'Name': 'ORMRoleID',      'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 55  },  
      179         ]  
      180     Data.AddReportType(rt, ct)  
      181  
      182 #       ORMPath  
      183 #       - ID  
      184 #       - ProjectID (Schema)  
      185 ##       - Name  
      186  
      187 #       ORMPathLink  
      188 #       - ID  
      189 #       - ProjectID (Schema)  
      190 #       - ORMRole  
      191 #       - Sequence  (1 ..)  
      192  
      193 #       ORMNote  
      194 #       - ID  
      195 #       - ProjectID (Schema)  
      196 #       - Text  
      197  
      198     rt = { 'Name': 'ORM Notes', 'TableA': 'ORMNote', 'TableB': None, 'Also': None, 'AllOrEach': 'each',  
      199            'SuggestedColumns': ',ID;,Text' }  
      200     ct = [  
      201     { 'Name': 'ID',           'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35  },  
      202     { 'Name': 'Text',         'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 300  },  
      203         ]  
      204     Data.AddReportType(rt, ct)  
      205  
      206 #       ORMNoteConnector  
      207 #       - ID  
      208 #       - ProjectID (Schema)  
      209 #       - ORMNoteID  # notes are always at one end of the note connector  
      210 #       - TableName - this is the way ganttpv points to any object  
      211 #       - TableID  
      212  
      213     rt = { 'Name': 'ORM Note Connectors', 'TableA': 'ORMNoteConnector', 'TableB': None, 'Also': None, 'AllOrEach': 'each',  
      214            'SuggestedColumns': ',ID;,ORMNoteID;,TableName;,TableID' }  
      215     ct = [  
      216     { 'Name': 'ID',           'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35  },  
      217     { 'Name': 'ORMNoteID',    'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 55  },  
      218     { 'Name': 'TableName',    'Label': None,             'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 100  },  
      219     { 'Name': 'TableID',      'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 55  },  
      220         ]  
      221     Data.AddReportType(rt, ct)  
      222  
      223 # --------------------------  
      224  
      225 ### instead of a report object, it might be better just to use the good old report row?  
      226 ##    rt = { 'Name': 'ORM Report Objects', 'TableA': 'ORMReportObject', 'TableB': None, 'Also': None, 'AllOrEach': 'each',  
      227 ##           'SuggestedColumns': ',ReportID;,Report/Name;,ID;,ORMObjectID;,ORMObject/Name;,PosX;,PosY;,DateAdded' }  
      228 ##    ct = [  
      229 ##    { 'Name': 'ProjectID',    'Label': 'Project\nID',    'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 50  },  
      230 ##    { 'Name': 'Project/Name', 'Label': 'Project\nName',  'DataType': 't', 'AccessType': 'i', 'T': 'A', 'Edit': False, 'Width': 100  },  
      231 ##    { 'Name': 'ReportID',     'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
      232 ##    { 'Name': 'Report/Name',  'Label': 'Report\nName',   'DataType': 't', 'AccessType': 'i', 'T': 'A', 'Edit': False, 'Width': 100  },  
      233 ##    { 'Name': 'ID',           'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35  },  
      234 ##    { 'Name': 'ORMObjectID',  'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 80  },  
      235 ##    { 'Name': 'ORMObject/Name', 'Label': 'ORMObject\nName', 'DataType': 't', 'AccessType': 'i', 'T': 'A', 'Edit': False, 'Width': 100  },  
      236 ##    { 'Name': 'PosX',         'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
      237 ##    { 'Name': 'PosY',         'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 35  },  
      238 ##    { 'Name': 'DateAdded',    'Label': 'Date\nAdded',    'DataType': 'd', 'AccessType': 'd', 'T': 'A', 'Edit': True,  'Width': 80  },  
      239 ##        ]  
      240 ##    Data.AddReportType(rt, ct)  
      241  
      242 #       ReportORMFact  
      243 #       - ORMFactID  # many may point to same  
      244 #       - ReportID  
      245 #       - PosX  
      246 #       - PosY  
      247  
      248 #       ReportORMRole  
      249 #       - ORMRoleID  # many may point to same  
      250 #       - ReportID  
      251 #       - ReportORMFactID       # these determine where to draw the role  
      252 #       - ReportORMObjectID     #  
      253  
      254 #       ReportORMConstraint  
      255 #       - ORMConstraintID  # many may point to same  
      256 #       - ReportID  
      257 #       - PosX  
      258 #       - PosY  
      259  
      260 #       ReportORMNote  
      261 #       - ORMNoteID  # many may point to same  
      262 #       - ReportID  
      263 #       - PosX  
      264 #       - PosY  
      265 #       - ObjectType        # can point to any orm report object  
      266 #       - ObjectID  
      267  
      268 # This script must be run against each file to include the new report options.  
      269  
      270 # If you want to make sure the report types and column types you add don't conflict  
      271 #    with new releases of GanttPV, prefix the Name with "xx". For  
      272 #    example: "xxDocument", "xxOwner", "xxURL", etc.  
      273  
      274     # add required data tables  
      275 #    Data.AddTable('ProjectWeek')  
      276  
      277     # add required aliases  
      278     Data.Database['NodeA'] = Data.Database['ReportRow']  # Does this name work?  
      279     Data.Database['NodeB'] = Data.Database['ReportRow']  
      280     Data.AddAlias('NodeA', 'ReportRow')     # is this the best way to do this?  
      281     Data.AddAlias('NodeB', 'ReportRow')  
      282  
      283     Data.SetUndo("Install ORM Tables")  
      284  
      285 # do only if GanttPV version 0.2 or greater  
      286 DoAdd()  
  • scripts/trunk/ORM/Open ORM Window.py

    r346 r347  
    1   # Copyright 2007 by Brian C. Christensen  
    2    
    3   # uses FlagNotebook to control placement of the notebook pages on the screen  
    4    
    5   # higher priority  
    6   # 1) add a menu bar to the window - change content depending on which pane is active?  
    7   # 2))put a toolbar at the top of each page in the notebooks  
    8   #  steal it from the demo  
    9   # 3) put a status bar at the bottom  
    10   # 4) put popupmenus on the orm drawing canvas - to select different types of objects  
    11   #       -- partly DONE working for pseudo dc canvas  
    12   # 5) add a pseudo dc window -- DONE  
    13   # 6) put all of the notebook windows into a dynamic sash window??  
    14   #   but there may be problems with the scroll bars??  
    15   #   also, I can't see how to save and restore the subwindow layout  
    16    
    17   # lower priority  
    18   # 1) Put the OGL windows into dynamicsashwindows so they can be split  
    19   # 2) Use Style Text Control for editing formated text  
    20   #    it will allow you to select text with the mouse and drag it within  
    21   #        the document, maybe also can drag into other objects?  
    22    
    23    
    24   # 070806 - First experiments with combining FlatNoteBook and OGL  
    25   # 070807 - Added pseudo dc window  
    26   # 070825 - Added separate sections for adding orm ojext to the model and to the display  
    27    
    28   import wx  
    29   import wx.lib.flatnotebook as fnb  
    30   import random  
    31   # import images  
    32   import sys  
    33    
    34   #---------------------------------------------------------------------------  
    35   # This is the code from the custom tree control demo  
    36   #---------------------------------------------------------------------------  
    37   import wx.lib.ogl as ogl  
    38   ogl.OGLInitialize()  # affter app object, but before OGL is used  
    39   db = Data._dbDatabase(Data.Database)  # will get objects from this database  
    40    
    41   debug = 1  
    42    
    43   #import wx  
    44   import string  
    45   import os  
    46   import wx.lib.colourselect as csel  
    47    
    48   import wx.lib.customtreectrl as CT  
    49    
    50