Example #1
0
    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()
Example #2
0
    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()
Example #3
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 ]
Example #4
0
    def __init__(self, aParentWindow, anEntity ):
        """Constructor
        aSystemPath string
        returns 
        """
        # Sets the return number
        self.theModelEditor = aParentWindow.theModelEditor

        # Sets the return number
        self.__value = None

        # Create the Dialog
        self.win = gtk.Dialog( "VariableBrowser", None, gtk.DIALOG_MODAL)
        self.win.connect("destroy",self.destroy)

        # Sets size and position
        self.win.set_border_width(2)
        self.win.set_default_size(300,75)
        self.win.set_position(gtk.WIN_POS_MOUSE)

        # appends ok button
        ok_button = gtk.Button("  OK  ")
        self.win.action_area.pack_start(ok_button,False,False,)
        ok_button.set_flags(gtk.CAN_DEFAULT)
        ok_button.grab_default()
        ok_button.show()
        ok_button.connect("clicked",self.oKButtonClicked)


        # appends cancel button
        cancel_button = gtk.Button(" Cancel ")
        self.win.action_area.pack_start(cancel_button,False,False)
        cancel_button.show()
        cancel_button.connect("clicked",self.cancelButtonClicked)   

        # Sets title
        
        self.theComponent = ViewComponent( self.win.vbox, 'attachment_box', 'FullIDChooser.glade' )
        aPixbuf16 = gtk.gdk.pixbuf_new_from_file(
            os.path.join( config.GLADEFILE_PATH, "modeleditor.png") )
        aPixbuf32 = gtk.gdk.pixbuf_new_from_file(
            os.path.join( config.GLADEFILE_PATH, "modeleditor32.png") )
        self.win.set_icon_list(aPixbuf16, aPixbuf32)
               
        # create systree, processlist, propertylist
        self.theSystemTree = SystemTree( self, self.theComponent['SystemTreeFrame'] )
        self.theEntityList = EntityList( self, self.theComponent['EntityListFrame'], ME_VARIABLE_TYPE )
               
        if getFullIDType( anEntity) == ME_SYSTEM_TYPE:
            aSysID = anEntity
        else:
            aSysID = convertSysPathToSysID( anEntity.split(':')[1] )

        self.theSystemTree.changeSelection( [ aSysID ] )
        
        self.theSystemTree.selectByUser()
        
        self.theModelEditor.setFullIDBrowser( self )
        
        
        self.win.show_all()
        gtk.main()
Example #5
0
class FullIDBrowserWindow:

    # ==========================================================================
    def __init__(self, aParentWindow, anEntity ):
        """Constructor
        aSystemPath string
        returns 
        """
        # Sets the return number
        self.theModelEditor = aParentWindow.theModelEditor

        # Sets the return number
        self.__value = None

        # Create the Dialog
        self.win = gtk.Dialog( "VariableBrowser", None, gtk.DIALOG_MODAL)
        self.win.connect("destroy",self.destroy)

        # Sets size and position
        self.win.set_border_width(2)
        self.win.set_default_size(300,75)
        self.win.set_position(gtk.WIN_POS_MOUSE)

        # appends ok button
        ok_button = gtk.Button("  OK  ")
        self.win.action_area.pack_start(ok_button,False,False,)
        ok_button.set_flags(gtk.CAN_DEFAULT)
        ok_button.grab_default()
        ok_button.show()
        ok_button.connect("clicked",self.oKButtonClicked)


        # appends cancel button
        cancel_button = gtk.Button(" Cancel ")
        self.win.action_area.pack_start(cancel_button,False,False)
        cancel_button.show()
        cancel_button.connect("clicked",self.cancelButtonClicked)   

        # Sets title
        
        self.theComponent = ViewComponent( self.win.vbox, 'attachment_box', 'FullIDChooser.glade' )
        aPixbuf16 = gtk.gdk.pixbuf_new_from_file(
            os.path.join( config.GLADEFILE_PATH, "modeleditor.png") )
        aPixbuf32 = gtk.gdk.pixbuf_new_from_file(
            os.path.join( config.GLADEFILE_PATH, "modeleditor32.png") )
        self.win.set_icon_list(aPixbuf16, aPixbuf32)
               
        # create systree, processlist, propertylist
        self.theSystemTree = SystemTree( self, self.theComponent['SystemTreeFrame'] )
        self.theEntityList = EntityList( self, self.theComponent['EntityListFrame'], ME_VARIABLE_TYPE )
               
        if getFullIDType( anEntity) == ME_SYSTEM_TYPE:
            aSysID = anEntity
        else:
            aSysID = convertSysPathToSysID( anEntity.split(':')[1] )

        self.theSystemTree.changeSelection( [ aSysID ] )
        
        self.theSystemTree.selectByUser()
        
        self.theModelEditor.setFullIDBrowser( self )
        
        
        self.win.show_all()
        gtk.main()


    # ==========================================================================
    def update( self, aType=None, aFullID=None ):
        if aType == ME_SYSTEM_TYPE:
            self.updateSystemTree( aFullID )
        elif aType == ME_VARIABLE_TYPE:
            self.updateEntityList( aFullID )
        else:
            self.updateEntityList()



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

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


    # ==========================================================================
    def updateEntityList ( self, aFullID = None ):
        """
        in: string aFullID where changes happened
        """

        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( )




    # ==========================================================================
    def oKButtonClicked( self, *arg ):
        """If OK button clicked or the return pressed, this method is called.
        """

        # sets the return number
        selectedIDs = self.theLastActiveComponent.getSelectedIDs()
        if len(selectedIDs) == 1:
            selectedID = selectedIDs[0]
        else:
            selectedID = None

        self.__value = selectedID
        
        
        self.destroy()


    # ==========================================================================
    def cancelButtonClicked( self, *arg ):
        """If Cancel button clicked or the return pressed, this method is called.
        """

        # set the return number
        self.__value = None
        self.destroy()
    

    # ==========================================================================
    def return_result( self ):
        """Returns result
        """
        return self.__value


    # ==========================================================================
    def destroy( self, *arg ):
        """destroy dialog
        """
        self.theModelEditor.setFullIDBrowser( None )

        self.win.hide()
        gtk.main_quit()

    # ==========================================================================
    def setLastActiveComponent( self, aComponent ):
        self.theLastActiveComponent = aComponent
Example #6
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]