示例#1
0
class EntityListTab(ListWindow):


    def __init__( self, aModelEditor,aRoot=None ):
        """
        in: ModelEditor theModelEditor
        returns nothing
        """
        self.theModelEditor = aModelEditor

        # init superclass
        ListWindow.__init__( self, self.theModelEditor ,aRoot)
        


    def openWindow( self ):
        """
        in: nothing
        returns nothing
        """

        # superclass openwindow
        ListWindow.openWindow( self )

        # create systree, processlist, propertylist
        self.theSystemTree = SystemTree( self, self['SystemTreeFrame'] )
        self.theEntityType = self.__getEntityType()
        
        ###############################################################################
        self.theEntityList = EntityList( self, self['EntityListFrame'], self.theEntityType )
       
        self.theEntityEditorList = EntityEditor( self, self['EntityEditorFrame'], self.theEntityType )
           
        # add signal handlers
        self.addHandlers({ 'on_variable1_activate' : self.__entitychooser_changed, 
                            'on_process1_activate' : self.__entitychooser_changed
                })

        self.theEntityList.changeDisplayedType( self.theEntityType )


        self.selectEntity( [ME_ROOTID] )


        self.update()
           
        
    def setLastActiveComponent( self, aComponent ):
        self.theLastActiveComponent = aComponent
        self.updatePropertyList()


    def update( self, aType = None, aFullID = None ):
        #if self.theModelEditor.getMode() == ME_RUN_MODE:
        #    self.theEntityEditorList.thePropertyList.update()
        #    return
        if aType == ME_SYSTEM_TYPE:
            self.updateSystemTree( aFullID )
        elif aType == ME_STEPPER_TYPE:
            self.updatePropertyList()
        elif aType == self.theEntityType:
            self.updateEntityList( aFullID )
        elif aType == ME_VARIABLE_TYPE and self.theEntityType == ME_PROCESS_TYPE:
            self.updatePropertyList()
        elif aType == ME_PROPERTY_TYPE:
            self.updatePropertyList( aFullID )
        else:
            self.updateSystemTree()
        
    def selectEntity( self, anEntityList ):

        aType = getFullIDType ( anEntityList[0] )
        if aType == ME_SYSTEM_TYPE:
            self.theLastActiveComponent = self.theSystemTree
            
        elif aType in [ ME_PROCESS_TYPE, ME_VARIABLE_TYPE ]:
            displayedType = self.__getEntityType()
            #self.theEntityList.aValue = self.theEntityEditorList.getValue()
            if aType != displayedType:
                
                self.theEntityList.changeDisplayedType( aType )

            self.theLastActiveComponent = self.theEntityList 
        else:
            raise Exception("Wrong type to select %s"% aType )
        self.theLastActiveComponent.changeSelection( anEntityList )     
            
        self.theLastActiveComponent.selectByUser()
        
        

    def updateSystemTree ( self, aSystemFullID = None ):
        """
        in: string aSystemFullID where changes happened
        """

        if not self.exists():
            return
        if aSystemFullID != None:
            self.theSystemTree.update ( aSystemFullID )
        self.updateEntityList( aSystemFullID )



    def updateEntityList ( self, aFullID = None ):
        """
        in: string aFullID where changes happened
        """
        if not self.exists():
            return

        displayedFullID = self.theEntityList.getDisplayedSysID() 
        systemTreeFullIDs = self.theSystemTree.getSelectedIDs() 
        if len(systemTreeFullIDs) != 1:
            systemTreeFullID = None
        else:
            systemTreeFullID = systemTreeFullIDs[0]

        # check if new system is selected
        if displayedFullID != systemTreeFullID:
            self.theEntityList.setDisplayedSysID( systemTreeFullID )

        elif displayedFullID == aFullID or aFullID == None:
            self.theEntityList.update( )

        # check whether there were any changes in displayed data
        self.updatePropertyList( aFullID )


    
    def updatePropertyList ( self, aFullID = None ):
        """
        in: anID where changes happened
        """

        if not self.exists():
            return
        # get selected process or systemid
        selectedID = None

        selectedIDs = self.theLastActiveComponent.getSelectedIDs()
        if len(selectedIDs) == 1:
            selectedID = selectedIDs[0]
        else:
            selectedID = None
        
        # get displayed entity from propertylist
        
        propertyListEntity = self.theEntityEditorList.getDisplayedEntity()
        # check if selection was changed
        if propertyListEntity != selectedID :

            self.theEntityEditorList.setDisplayedEntity ( selectedID )

        elif aFullID == selectedID or aFullID == None or aFullID[-4:] == "SIZE":

            self.theEntityEditorList.update()

    def changeEntityType( self ):
        self.theEntityType = self.__getEntityType()
        self.theEntityList.changeDisplayedType( self.theEntityType )
        self.updateEntityList()


    #############################
    #      SIGNAL HANDLERS      #
    #############################

    def deleted( self, *arg ):
        ListWindow.deleted( self, *arg )
        self.theSystemTree.close()
        self.theEntityList.close()
        self.theEntityEditorList.close()
        self.theModelEditor.theEntityListWindowList.remove( self )
        self.theModelEditor.updateWindows()
        return True


    def __entitychooser_changed( self, *args ):
    
        self.changeEntityType()     
      

    def __getEntityType( self ):
        """
        returns string type of entity chooser
        """
        anIndex = self['EntityChooser'].get_history()
        return (ME_VARIABLE_TYPE, ME_PROCESS_TYPE)[ anIndex ]
示例#2
0
class ObjectEditorWindow :

    def __init__( self, aModelEditor, aLayoutName, anObjectId ):
        """
        sets up a modal dialogwindow displaying 
        the EntityEditor and the ShapeProperty
        # objectID can be None, String, list of strings
        """ 
        self.theModelEditor = aModelEditor  
        self.theTopFrame = gtk.VBox()
        self.theEntityEditor = EntityEditor( self, self.theTopFrame,'Entity', True )
        self.theShapeProperty = self.theEntityEditor.getShapeProperty()
        self.setDisplayObjectEditorWindow(aLayoutName, anObjectId)
    # ==========================================================================

    def setDisplayObjectEditorWindow(self,aLayoutName, anObjectID):
        self.theLayoutName = aLayoutName
        self.theLayout =self.theModelEditor.theLayoutManager.getLayout(aLayoutName)
        self.theObjectDict = {}
        self.theType = "None"
        if anObjectID == None:
            objectIDList = []

        elif type(anObjectID ) == type(""):
            objectIDList = [ anObjectID]
        elif type( anObjectID ) == type ( [] ):
            objectIDList = anObjectID
            
        for anID in objectIDList:
            anObject = self.theLayout.getObject( anID ) 
            self.theObjectDict[anID] = anObject 
            aType = anObject.getProperty( OB_TYPE )
            if self.theType == "None":
                self.theType = aType
            elif self.theType != aType:
                self.theType = "Mixed"
        if len( self.theObjectDict.values() ) == 1:
            self.theLastFullID = self.theObjectDict.values()[0].getProperty( OB_FULLID )
        else:
            self.theLastFullID = None
        self.theEntityEditor.setDisplayedEntity (self.theLastFullID)
        self.theShapeProperty.setDisplayedShapeProperty( self.theObjectDict, self.theType )
        self.bringToTop()

    # ==========================================================================


    def bringToTop( self ):
        self.theModelEditor.theMainWindow.setSmallWindow( self.theTopFrame )
        self.theEntityEditor.bringToTop()




    
    def update(self, aType = None, aFullID = None):
        #if aFullID not None, see whether all objects exist
        deletion = False

        existObjectList = self.theLayout.getObjectList()
        for anObjectID in self.theObjectDict.keys()[:]:
            if anObjectID not in existObjectList:
                self.theObjectDict.__delitem__( anObjectID )
                deletion = True
        if deletion:
            self.setDisplayObjectEditorWindow( self.theLayoutName, self.theObjectDict.keys()[:] ) 
        else:
            # detect deleted fullid or changed fullid
            newFullID = None
            if  len( self.theObjectDict.keys() ) == 1:
                theObject = self.theObjectDict.values()[0]
                if theObject.getProperty( OB_HASFULLID ):
                    newFullID = theObject.getProperty( OB_FULLID )
            if self.theLastFullID != None:
                if not self.theModelEditor.theModelStore.isEntityExist( self.theLastFullID ):
                    newFullID = None
            if newFullID != None:
                if not self.theModelEditor.theModelStore.isEntityExist( newFullID ):
                    newFullID = None
            if self.theLastFullID != newFullID :
                self.theEntityEditor.setDisplayedEntity( newFullID )
            # if nothing deleted, update windows
            else:
                self.updatePropertyList()
                self.updateShapeProperty()



    def updatePropertyList ( self, aFullID = None ):
        """
        in: anID where changes happened
        """
        # get selected objectID
        propertyListEntity = self.theEntityEditor.getDisplayedEntity()
        # check if displayed fullid is affected by changes

        if propertyListEntity != self.theLastFullID:
            self.theEntityEditor.setDisplayedEntity ( self.theLastFullID )
        else:
            self.theEntityEditor.update()



        

    def updateShapeProperty(self):
        if self.theModelEditor.getMode() != ME_DESIGN_MODE:
            return
        self.theShapeProperty.updateShapeProperty()

        

    # ==========================================================================
    def destroy( self, *arg ):
        """destroy dialog
        """
        pass        
#        self.win.destroy()
        

        
        
    def selectEntity(self,anEntityList):

        if type(anEntityList) == type(""):
            return
        if len( self.theObjectDict.keys() ) == 1:
            theObject = self.theObjectDict.values()[0]
            if theObject.getProperty(OB_HASFULLID):
                self.theLastFullID = theObject.getProperty( OB_FULLID )
                if not self.theModelEditor.getModel().isEntityExist( self.theLastFullID ):
                    self.theLastFullID = None
        self.theEntityEditor.setDisplayedEntity ( self.theLastFullID )
        self.theEntityEditor.update()
        self.bringToTop()
示例#3
0
class ObjectEditorWindow :

    def __init__( self, aModelEditor, aLayoutName, anObjectId ):
        """
        sets up a modal dialogwindow displaying 
        the EntityEditor and the ShapeProperty
        # objectID can be None, String, list of strings
        """ 
        self.theModelEditor = aModelEditor  
        self.theTopFrame = gtk.VBox()
        self.theEntityEditor = EntityEditor( self, self.theTopFrame,'Entity', True )
        self.theShapeProperty = self.theEntityEditor.getShapeProperty()
        self.setDisplayObjectEditorWindow(aLayoutName, anObjectId)
    # ==========================================================================

    def setDisplayObjectEditorWindow(self,aLayoutName, anObjectID):
        self.theLayoutName = aLayoutName
        self.theLayout =self.theModelEditor.theLayoutManager.getLayout(aLayoutName)
        self.theObjectDict = {}
        self.theType = "None"
        if anObjectID == None:
            objectIDList = []

        elif type(anObjectID ) == type(""):
            objectIDList = [ anObjectID]
        elif type( anObjectID ) == type ( [] ):
            objectIDList = anObjectID
            
        for anID in objectIDList:
            anObject = self.theLayout.getObject( anID ) 
            self.theObjectDict[anID] = anObject 
            aType = anObject.getProperty( OB_TYPE )
            if self.theType == "None":
                self.theType = aType
            elif self.theType != aType:
                self.theType = "Mixed"
        if len( self.theObjectDict.values() ) == 1:
            self.theLastFullID = self.theObjectDict.values()[0].getProperty( OB_FULLID )
        else:
            self.theLastFullID = None
        self.theEntityEditor.setDisplayedEntity (self.theLastFullID)
        self.theShapeProperty.setDisplayedShapeProperty( self.theObjectDict, self.theType )
        self.bringToTop()

    # ==========================================================================


    def bringToTop( self ):
        self.theModelEditor.theMainWindow.setSmallWindow( self.theTopFrame )
        self.theEntityEditor.bringToTop()




    
    def update(self, aType = None, aFullID = None):
        #if aFullID not None, see whether all objects exist
        deletion = False

        existObjectList = self.theLayout.getObjectList()
        for anObjectID in self.theObjectDict.keys()[:]:
            if anObjectID not in existObjectList:
                self.theObjectDict.__delitem__( anObjectID )
                deletion = True
        if deletion:
            self.setDisplayObjectEditorWindow( self.theLayoutName, self.theObjectDict.keys()[:] ) 
        else:
            # detect deleted fullid or changed fullid
            newFullID = None
            if  len( self.theObjectDict.keys() ) == 1:
                theObject = self.theObjectDict.values()[0]
                if theObject.getProperty( OB_HASFULLID ):
                    newFullID = theObject.getProperty( OB_FULLID )
            if self.theLastFullID != None:
                if not self.theModelEditor.theModelStore.isEntityExist( self.theLastFullID ):
                    newFullID = None
            if newFullID != None:
                if not self.theModelEditor.theModelStore.isEntityExist( newFullID ):
                    newFullID = None
            if self.theLastFullID != newFullID :
                self.theEntityEditor.setDisplayedEntity( newFullID )
            # if nothing deleted, update windows
            else:
                self.updatePropertyList()
                self.updateShapeProperty()



    def updatePropertyList ( self, aFullID = None ):
        """
        in: anID where changes happened
        """
        # get selected objectID
        propertyListEntity = self.theEntityEditor.getDisplayedEntity()
        # check if displayed fullid is affected by changes

        if propertyListEntity != self.theLastFullID:
            self.theEntityEditor.setDisplayedEntity ( self.theLastFullID )
        else:
            self.theEntityEditor.update()



        

    def updateShapeProperty(self):
        if self.theModelEditor.getMode() != ME_DESIGN_MODE:
            return
        self.theShapeProperty.updateShapeProperty()

        

    # ==========================================================================
    def destroy( self, *arg ):
        """destroy dialog
        """
        pass        
#        self.win.destroy()
        

        
        
    def selectEntity(self,anEntityList):

        if type(anEntityList) == type(""):
            return
        if len( self.theObjectDict.keys() ) == 1:
            theObject = self.theObjectDict.values()[0]
            if theObject.getProperty(OB_HASFULLID):
                self.theLastFullID = theObject.getProperty( OB_FULLID )
                if not self.theModelEditor.getModel().isEntityExist( self.theLastFullID ):
                    self.theLastFullID = None
        self.theEntityEditor.setDisplayedEntity ( self.theLastFullID )
        self.theEntityEditor.update()
        self.bringToTop()
示例#4
0
class EntityListTab(ListWindow):
    def __init__(self, aModelEditor, aRoot=None):
        """
        in: ModelEditor theModelEditor
        returns nothing
        """
        self.theModelEditor = aModelEditor

        # init superclass
        ListWindow.__init__(self, self.theModelEditor, aRoot)

    def openWindow(self):
        """
        in: nothing
        returns nothing
        """

        # superclass openwindow
        ListWindow.openWindow(self)

        # create systree, processlist, propertylist
        self.theSystemTree = SystemTree(self, self['SystemTreeFrame'])
        self.theEntityType = self.__getEntityType()

        ###############################################################################
        self.theEntityList = EntityList(self, self['EntityListFrame'],
                                        self.theEntityType)

        self.theEntityEditorList = EntityEditor(self,
                                                self['EntityEditorFrame'],
                                                self.theEntityType)

        # add signal handlers
        self.addHandlers({
            'on_variable1_activate': self.__entitychooser_changed,
            'on_process1_activate': self.__entitychooser_changed
        })

        self.theEntityList.changeDisplayedType(self.theEntityType)

        self.selectEntity([ME_ROOTID])

        self.update()

    def setLastActiveComponent(self, aComponent):
        self.theLastActiveComponent = aComponent
        self.updatePropertyList()

    def update(self, aType=None, aFullID=None):
        #if self.theModelEditor.getMode() == ME_RUN_MODE:
        #    self.theEntityEditorList.thePropertyList.update()
        #    return
        if aType == ME_SYSTEM_TYPE:
            self.updateSystemTree(aFullID)
        elif aType == ME_STEPPER_TYPE:
            self.updatePropertyList()
        elif aType == self.theEntityType:
            self.updateEntityList(aFullID)
        elif aType == ME_VARIABLE_TYPE and self.theEntityType == ME_PROCESS_TYPE:
            self.updatePropertyList()
        elif aType == ME_PROPERTY_TYPE:
            self.updatePropertyList(aFullID)
        else:
            self.updateSystemTree()

    def selectEntity(self, anEntityList):

        aType = getFullIDType(anEntityList[0])
        if aType == ME_SYSTEM_TYPE:
            self.theLastActiveComponent = self.theSystemTree

        elif aType in [ME_PROCESS_TYPE, ME_VARIABLE_TYPE]:
            displayedType = self.__getEntityType()
            #self.theEntityList.aValue = self.theEntityEditorList.getValue()
            if aType != displayedType:

                self.theEntityList.changeDisplayedType(aType)

            self.theLastActiveComponent = self.theEntityList
        else:
            raise Exception("Wrong type to select %s" % aType)
        self.theLastActiveComponent.changeSelection(anEntityList)

        self.theLastActiveComponent.selectByUser()

    def updateSystemTree(self, aSystemFullID=None):
        """
        in: string aSystemFullID where changes happened
        """

        if not self.exists():
            return
        if aSystemFullID != None:
            self.theSystemTree.update(aSystemFullID)
        self.updateEntityList(aSystemFullID)

    def updateEntityList(self, aFullID=None):
        """
        in: string aFullID where changes happened
        """
        if not self.exists():
            return

        displayedFullID = self.theEntityList.getDisplayedSysID()
        systemTreeFullIDs = self.theSystemTree.getSelectedIDs()
        if len(systemTreeFullIDs) != 1:
            systemTreeFullID = None
        else:
            systemTreeFullID = systemTreeFullIDs[0]

        # check if new system is selected
        if displayedFullID != systemTreeFullID:
            self.theEntityList.setDisplayedSysID(systemTreeFullID)

        elif displayedFullID == aFullID or aFullID == None:
            self.theEntityList.update()

        # check whether there were any changes in displayed data
        self.updatePropertyList(aFullID)

    def updatePropertyList(self, aFullID=None):
        """
        in: anID where changes happened
        """

        if not self.exists():
            return
        # get selected process or systemid
        selectedID = None

        selectedIDs = self.theLastActiveComponent.getSelectedIDs()
        if len(selectedIDs) == 1:
            selectedID = selectedIDs[0]
        else:
            selectedID = None

        # get displayed entity from propertylist

        propertyListEntity = self.theEntityEditorList.getDisplayedEntity()
        # check if selection was changed
        if propertyListEntity != selectedID:

            self.theEntityEditorList.setDisplayedEntity(selectedID)

        elif aFullID == selectedID or aFullID == None or aFullID[-4:] == "SIZE":

            self.theEntityEditorList.update()

    def changeEntityType(self):
        self.theEntityType = self.__getEntityType()
        self.theEntityList.changeDisplayedType(self.theEntityType)
        self.updateEntityList()

    #############################
    #      SIGNAL HANDLERS      #
    #############################

    def deleted(self, *arg):
        ListWindow.deleted(self, *arg)
        self.theSystemTree.close()
        self.theEntityList.close()
        self.theEntityEditorList.close()
        self.theModelEditor.theEntityListWindowList.remove(self)
        self.theModelEditor.updateWindows()
        return True

    def __entitychooser_changed(self, *args):

        self.changeEntityType()

    def __getEntityType(self):
        """
        returns string type of entity chooser
        """
        anIndex = self['EntityChooser'].get_history()
        return (ME_VARIABLE_TYPE, ME_PROCESS_TYPE)[anIndex]