Example #1
0
 def __setupMDSession(self):
     print "startmdsess called"
     """
     Sets up a MagicDraw session, as appropriate
     """
     ##
     ## Maddalena: set up MagicDraw session here
     self.__highlighter = ActHi(self.__project)
     self.__mdSession = object()
     pass
Example #2
0
 def __setupMDSession(self):
     print "startmdsess called"
     """
     Sets up a MagicDraw session, as appropriate
     """
     ##
     ## Maddalena: set up MagicDraw session here
     self.__highlighter=ActHi(self.__project)
     self.__mdSession = object()
     pass
Example #3
0
            JOptionPane.QUESTION_MESSAGE,
            None,
            options,
            options[1],
        )

        # Edit both package name and block name
        if a == JOptionPane.YES_OPTION:
            activity = actname.getSelectedItem()
            params = inputs.getText()
            # validate format!
            # if invalid, call window again?
            if debug == 1:
                gl.log("Starting activity " + activity + " with parameters " + params)
            project = Application.getInstance().getProjectsManager().getActiveProject()
            ah = ActHi(project, False)
            ah.repaintDiagram(activity)
            start = s.start(activity, params)
            # gl.log(str(start))
            if start is True:
                gl.log(activity + " has successfully started!")
            else:
                gl.log(str(start))

        elif a == JOptionPane.NO_OPTION:
            pass
        else:
            pass

    except KeyboardInterrupt:
        print s.terminate()
Example #4
0
class MdAnimationUpdater(object):
    '''
    XML-RPC Server class to handle GUI messages for
    the Autocoder Python trace GUI.
    '''
    def __init__(self, MDProject, port=XMLRPC_PORT, debug=False):
        '''
        Constructor
        '''
        gl.log("init method called")
        self.__serverName = "localhost"
        self.__serverPort = port
        self.__debug = debug  # debug flag
        # whether to keep serving or not
        self.__keepServing = True
        #
        self.__mdSession = None  # Maddalena: cache of MagicDraw session?!
        self.__highlighter = None
        self.__project = MDProject

    def __destroy(self):
        """
        Method to stop this XML-RPC server.
        It stops and deletes the thread, and clears all queues.
        """
        self.__keepServing = False  # stop the serving
        # Clean-up session
        self.__teardownMDSession()
        #- stop the XML-RPC server
        self.__rpcServer.server_close()
        del self.__rpcServer
        self.__rpcServer = None
        #
        if self.__debug:
            gl.log("destroy: Destroy() complete!")
            print "destroy complete!"
            print "------"

    def serve(self):
        """
        Method to set-up the XML-RPC server and begin handling GUI activities.
        """
        # Instantiate XML-RPC server thread
        self.__rpcServer = SimpleXMLRPCServer.SimpleXMLRPCServer(
            (self.__serverName, self.__serverPort), logRequests=True)
        print "XMLRPC GUI server started on http://%s:%d/RPC2..." % (
            self.__serverName, self.__serverPort)
        gl.log("serve: XMLRPC GUI server started...")
        print "XMLRPC GUI server started... "
        self.__rpcServer.register_introspection_functions()
        self.__rpcServer.register_instance(self)
        print self.__rpcServer.system_listMethods()
        #
        if self.__debug:
            print "debug serve: GUI Server started!"

        #
        try:
            # Now run the GUI update loop
            gl.log("serve called")
            print "runRPCSERVER called!"
            while self.__keepServing:
                self.__rpcServer.handle_request()
            #
            if self.__debug:
                gl.log("XML-RPC server thread stopped!")
                print "XML-RPC server thread stopped!"
            self.__destroy()
        except Exception:
            print
            print "GUI Server terminated!"
            sys.exit(0)

    def __setupMDSession(self):
        print "startmdsess called"
        """
        Sets up a MagicDraw session, as appropriate
        """
        ##
        ## Maddalena: set up MagicDraw session here
        self.__highlighter = ActHi(self.__project)
        self.__mdSession = object()
        pass

    def __teardownMDSession(self):
        """
        Tears down the MagicDraw session, if necessary
        """
        ##
        ## Maddalena: tear down MagicDraw session here if needed
        ## Should clear all painters on exit. Need to put this elsewhere also?
        if self.__highlighter is not None:
            self.__highlighter.clearAll()
        self.__mdSession = None

    def beginSession(self):
        gl.log("beginSession called")
        """
        Method invoked by the XML-RPC client to notify MagicDraw to begin a
        session for diagram modifications if one isn't already active.
        """
        self.__setupMDSession()
        return "MagicDraw session starting..."

    def sendUpdate(self, params):
        """
        Method to send ON/OFF GUI updates to MagicDraw.
        This method uses the highlighter object to highlight a diagram element.
        
        Each message must consist of 3 whitespace-separated elements:
            <Diagram Name> <Action/Flow Name> <On/Off>
        """
        # Figure out which diagram, and which action within that diagram
        # to change to what state
        if params is not None:
            ##
            ## Maddalena, this is all yours!  :-)
            ##
            if len(params) < 3:
                # raise exception?
                gl.log("GUI update param must have 3 elements!")
            else:
                if self.__mdSession is not None and self.__highlighter is not None:
                    print "==> Turn diagram:node/flow '%s:%s' highlight '%s'"\
                            % (params[0], params[1], params[2])
                    self.__highlighter.highlight(params[0], params[1],
                                                 params[2])
                else:
                    gl.log(
                        "ERROR! No MagicDraw session to allow updating diagram(s)!"
                    )
        #
        if self.__debug:
            print "Update queue:", self.__updateQueue.queue
        #
        return "'%s' GUI update" % params

    def endSession(self):
        """
        Method invoked by the XML-RPC client to notify MagicDraw to end the
        session started for diagram modification.
        """
        self.__teardownMDSession()
        self.__destroy()
        return "MagicDraw session ended!"
Example #5
0
class MdAnimationUpdater(object):
    '''
    XML-RPC Server class to handle GUI messages for
    the Autocoder Python trace GUI.
    '''

    def __init__(self, MDProject, port=XMLRPC_PORT, debug=False):
        '''
        Constructor
        '''
        gl.log("init method called")
        self.__serverName = "localhost"
        self.__serverPort = port
        self.__debug = debug  # debug flag
        # whether to keep serving or not
        self.__keepServing = True
        #
        self.__mdSession = None  # Maddalena: cache of MagicDraw session?!
        self.__highlighter = None
        self.__project = MDProject

    def __destroy(self):
        """
        Method to stop this XML-RPC server.
        It stops and deletes the thread, and clears all queues.
        """
        self.__keepServing = False  # stop the serving
        # Clean-up session
        self.__teardownMDSession()
        #- stop the XML-RPC server
        self.__rpcServer.server_close()
        del self.__rpcServer
        self.__rpcServer = None
        #
        if self.__debug:
            gl.log( "destroy: Destroy() complete!")
            print "destroy complete!"
            print "------"


    def serve(self):
        """
        Method to set-up the XML-RPC server and begin handling GUI activities.
        """
        # Instantiate XML-RPC server thread
        self.__rpcServer = SimpleXMLRPCServer.SimpleXMLRPCServer((self.__serverName, self.__serverPort), logRequests=True)
        print "XMLRPC GUI server started on http://%s:%d/RPC2..." % (self.__serverName, self.__serverPort)
        gl.log("serve: XMLRPC GUI server started...")
        print "XMLRPC GUI server started... "
        self.__rpcServer.register_introspection_functions()
        self.__rpcServer.register_instance(self)
        print self.__rpcServer.system_listMethods()
        #
        if self.__debug:
            print "debug serve: GUI Server started!"
            
        #
        try:
            # Now run the GUI update loop
            gl.log("serve called")
            print "runRPCSERVER called!"
            while self.__keepServing:
                self.__rpcServer.handle_request()
            #
            if self.__debug:
                gl.log( "XML-RPC server thread stopped!")
                print "XML-RPC server thread stopped!"
            self.__destroy()
        except Exception:
            print
            print "GUI Server terminated!"
            sys.exit(0)

    def __setupMDSession(self):
        print "startmdsess called"
        """
        Sets up a MagicDraw session, as appropriate
        """
        ##
        ## Maddalena: set up MagicDraw session here
        self.__highlighter=ActHi(self.__project)
        self.__mdSession = object()
        pass

    def __teardownMDSession(self):
        """
        Tears down the MagicDraw session, if necessary
        """
        ##
        ## Maddalena: tear down MagicDraw session here if needed
        ## Should clear all painters on exit. Need to put this elsewhere also?
        if self.__highlighter is not None:
            self.__highlighter.clearAll()
        self.__mdSession = None

    def beginSession(self):
        gl.log("beginSession called")
        """
        Method invoked by the XML-RPC client to notify MagicDraw to begin a
        session for diagram modifications if one isn't already active.
        """
        self.__setupMDSession()
        return "MagicDraw session starting..."

    def sendUpdate(self, params):
        """
        Method to send ON/OFF GUI updates to MagicDraw.
        This method uses the highlighter object to highlight a diagram element.
        
        Each message must consist of 3 whitespace-separated elements:
            <Diagram Name> <Action/Flow Name> <On/Off>
        """
        # Figure out which diagram, and which action within that diagram
        # to change to what state
        if params is not None:
            ##
            ## Maddalena, this is all yours!  :-)
            ##
            if len(params) < 3:
                # raise exception?
                gl.log( "GUI update param must have 3 elements!")
            else:
                if self.__mdSession is not None and self.__highlighter is not None:
                    print "==> Turn diagram:node/flow '%s:%s' highlight '%s'"\
                            % (params[0], params[1], params[2]) 
                    self.__highlighter.highlight(params[0],params[1],params[2])
                else:
                    gl.log( "ERROR! No MagicDraw session to allow updating diagram(s)!" )
        #
        if self.__debug:
            print "Update queue:", self.__updateQueue.queue
        #
        return "'%s' GUI update" % params

    def endSession(self):
        """
        Method invoked by the XML-RPC client to notify MagicDraw to end the
        session started for diagram modification.
        """
        self.__teardownMDSession()
        self.__destroy()
        return "MagicDraw session ended!"
Example #6
0
            server = 1
        except:
            gl.log(
                "ERROR: server inaccessable - not started or something. geez.")

        if server == 1:
            step = None
            step = s.step()

            if debug == 1:
                gl.log("DEBUG: " + str(step))

            if step is not None:
                project = Application.getInstance().getProjectsManager(
                ).getActiveProject()
                ah = ActHi(project, False)
                if len(step) == 2:
                    msg, end = step
                    if msg == "Activity started":
                        gl.log("Starting sub activity")
                else:
                    activity, node, state, message, end = step
                    gl.log(str(message))
                    ah.highlight(activity, node, state)

                    if end is True:
                        n = JOptionPane.showConfirmDialog(
                            None,
                            "Activity finished. Would you like to see \nthe final output?",
                            "Activity Final", JOptionPane.YES_NO_OPTION)
                        if n == JOptionPane.YES_OPTION:
Example #7
0
                               JOptionPane.YES_NO_OPTION,
                               JOptionPane.QUESTION_MESSAGE,
                               None,
                               options,
                               options[1])

        #Edit both package name and block name       
        if a==JOptionPane.YES_OPTION:
            activity=actname.getSelectedItem()
            params=inputs.getText()
            #validate format!
            #if invalid, call window again?
            if debug==1:
                gl.log("Starting activity " + activity + " with parameters " + params)
            project = Application.getInstance().getProjectsManager().getActiveProject()
            ah=ActHi(project,False)
            ah.repaintDiagram(activity)
            start=s.start(activity, params)
            #gl.log(str(start))
            if start is True:
                gl.log(activity + " has successfully started!")
            else:
                gl.log(str(start))                
  
  
        elif a==JOptionPane.NO_OPTION:
            pass
        else:
            pass
        
        
Example #8
0
 try:
     blah=s.system.listMethods()
     server=1
 except:
     gl.log("ERROR: server inaccessable - not started or something. geez.")
 
 if server==1:
     step=None
     step=s.step()
     
     if debug==1:
         gl.log("DEBUG: " + str(step))
     
     if step is not None:
         project = Application.getInstance().getProjectsManager().getActiveProject()
         ah=ActHi(project,False)
         if len(step)==2:
             msg,end=step
             if msg=="Activity started":
                 gl.log("Starting sub activity")
         else:
             activity,node,state,message,end=step
             gl.log(str(message))
             ah.highlight(activity,node,state)
             
             if end is True:
                 n = JOptionPane.showConfirmDialog(None,
                                                   "Activity finished. Would you like to see \nthe final output?",
                                                   "Activity Final",
                                                   JOptionPane.YES_NO_OPTION);
                 if n == JOptionPane.YES_OPTION: