Beispiel #1
0
 def expand_sublists(self, item):
     if self.IsExpanded(item):
         # This event can happen twice in the self.Expand call
         return
     obj = self.GetPyData(item)
     node = obj.gethead()
     fileserver = servers.get_file_server()
     self.libidx = self.image_list.Add(
         wx.Bitmap(fileserver.manglepath("outgui:images/tools/new.bmp"),
                   wx.BITMAP_TYPE_ANY))
     while node != None:
         obj = pynebula.lookup(node.getfullname())
         new_item = self.AppendItem(item, obj.getname(), -1, -1,
                                    wx.TreeItemData(obj))
         if self.is_library(new_item):
             self.SetItemImage(new_item, self.libidx,
                               wx.TreeItemIcon_Normal)
             self.SetItemImage(new_item, self.libidx,
                               wx.TreeItemIcon_Selected)
             self.SetItemImage(new_item, self.libidx,
                               wx.TreeItemIcon_Expanded)
         elif self.GetItemText(
                 self.get_root_library(new_item)
         ) == 'natives' and servers.get_kernel_server().isclassnative(
                 str(self.GetItemText(new_item))):
             self.SetItemImage(new_item, self.fldridxnative,
                               wx.TreeItemIcon_Normal)
             self.SetItemImage(new_item, self.fldropenidxnative,
                               wx.TreeItemIcon_Selected)
             self.SetItemImage(new_item, self.fldropenidxnative,
                               wx.TreeItemIcon_Expanded)
         elif self.GetItemText(
                 self.get_root_library(new_item)
         ) == 'natives' and not servers.get_kernel_server().isclassnative(
                 str(self.GetItemText(new_item))):
             self.SetItemImage(new_item, self.fldridxuser,
                               wx.TreeItemIcon_Normal)
             self.SetItemImage(new_item, self.fldropenidxuser,
                               wx.TreeItemIcon_Selected)
             self.SetItemImage(new_item, self.fldropenidxuser,
                               wx.TreeItemIcon_Expanded)
         else:
             self.SetItemImage(new_item, self.fldridxnormal,
                               wx.TreeItemIcon_Normal)
             self.SetItemImage(new_item, self.fldropenidxnormal,
                               wx.TreeItemIcon_Selected)
             self.SetItemImage(new_item, self.fldropenidxnormal,
                               wx.TreeItemIcon_Expanded)
         if obj.gethead() != None:
             self.SetItemHasChildren(new_item, True)
         node = obj.getsucc()
         self.SortChildren(item)
Beispiel #2
0
def load_objects():
    # Create libaries for grimoire
    if not pynebula.exists("/editor/libraries"):
        string_list = pynebula.new("nroot", "/editor/libraries")
        kernel = servers.get_kernel_server()
        kernel.loadas("wc:libs/grimoire/general.n2",
                      "/editor/libraries/general")
Beispiel #3
0
def load_objects():  
    # Create libaries for grimoire
    if not pynebula.exists("/editor/libraries"):
        string_list = pynebula.new("nroot", "/editor/libraries")
        kernel = servers.get_kernel_server()
        kernel.loadas(
            "wc:libs/grimoire/general.n2", 
            "/editor/libraries/general"
            )
Beispiel #4
0
 def can_delete_selected_class(self):
     # A class can be deleted only if it isn't native
     item = self.GetSelection()
     if not item.IsOk():
         return False
     postfix = self.GetPyData(item)
     if postfix is not None:
         return False
     class_name = self.GetItemText(item)
     return not servers.get_kernel_server().isclassnative( str(class_name) )
Beispiel #5
0
 def can_delete_selected_class(self):
     # A class can be deleted only if it isn't native
     item = self.GetSelection()
     if not item.IsOk():
         return False
     postfix = self.GetPyData(item)
     if postfix is not None:
         return False
     class_name = self.GetItemText(item)
     return not servers.get_kernel_server().isclassnative(str(class_name))
Beispiel #6
0
def get_class_commands(class_name, inherited_cmds = False):
    """Return the prototype of all the scripted commands for a class"""
    path = format.append_to_path( ClassesPath, class_name )
    path = format.mangle_path( path )
    cmds_list = filedlg.get_file_list( path, ['lua'] )
    if inherited_cmds:
        class_name = servers.get_kernel_server().getsuperclass( class_name )
        if class_name != ':null:':
            cmds_list.extend( get_class_commands(class_name, True) )
    cmds_list.sort()
    return cmds_list
Beispiel #7
0
def get_class_commands(class_name, inherited_cmds=False):
    """Return the prototype of all the scripted commands for a class"""
    path = format.append_to_path(ClassesPath, class_name)
    path = format.mangle_path(path)
    cmds_list = filedlg.get_file_list(path, ['lua'])
    if inherited_cmds:
        class_name = servers.get_kernel_server().getsuperclass(class_name)
        if class_name != ':null:':
            cmds_list.extend(get_class_commands(class_name, True))
    cmds_list.sort()
    return cmds_list
Beispiel #8
0
def get_action_classes():
    """Return a list with all the available action classes (the class names)"""
    open_list = ['ngpbasicaction']
    close_list = []
    while len(open_list) > 0:
        clazz = open_list.pop()
        close_list.append( clazz )
        subclasses = servers.get_kernel_server().getsubclasslist( clazz )
        open_list.extend( subclasses )
    close_list.remove( 'ngpbasicaction' )
    close_list.remove( 'gpactionscript' )
    return close_list
Beispiel #9
0
 def on_new_class(self, event):
     # Ask for a class name
     dlg = wx.TextEntryDialog(
                 None, 
                 "Enter the class name", 
                 "New class"
                 )
     result_ok = dlg.ShowModal() == wx.ID_OK
     if result_ok:
         class_name = dlg.GetValue().capitalize()
     dlg.Destroy()
     
     # Create the new class
     if result_ok:
         # Do some name validations
         ec_server = servers.get_entity_class_server()
         if not ec_server.checkclassname( str(class_name) ):
             cjr.show_error_message(
                 "Invalid class name"
                 )
             return
         k_server = servers.get_kernel_server()
         if k_server.findclass( str(class_name) ) != "":
             cjr.show_error_message(
                 "There is already another class called '%s'" % class_name
                 )
             return
         
         # Finally create the class
         parent_name = self.tree_classes.get_selected_class_name()
         if not ec_server.newclass( str(parent_name), str(class_name) ):
             msg = "Unknown error.\n\n" \
                         "Unable to create the class '%s'." % class_name
             cjr.show_error_message(msg)
             return
         set_nclass_dirty_flag(True)
         servers.get_script_server().addclass( str(class_name) )
         
         # For some classes, add commands and implementation by default
         class_group = self.tree_classes.get_current_class_group()
         if class_group is not None:
             add_cmds_func_name = '_CommandManagerDialog__add_commands_of_' + class_group
             if CommandManagerDialog.__dict__.has_key( add_cmds_func_name ):
                 CommandManagerDialog.__dict__[add_cmds_func_name](
                     self, 
                     class_name 
                     )
                 servers.get_script_server().refreshclass( str(class_name) )
         
         # Refresh the branch of the currently selected class
         self.tree_classes.on_new_class( class_name )
Beispiel #10
0
def get_script_conditions():
    """Return a sequence with all the script conditions paths"""
    # Generate a singleton for each condition class
    classes = servers.get_kernel_server().getsubclasslist('nscriptcondition')
    for class_name in classes:
        servers.get_fsm_server().getscriptcondition( str(class_name) )
    
    paths = []
    conds_path = get_script_conditions_lib()
    cond = pynebula.lookup( conds_path ).gethead()
    while cond != None:
        paths.append( cond.getfullname() )
        cond = cond.getsucc()
    return paths
Beispiel #11
0
    def load(self, file_path):
        if os.path.exists(file_path):
            root = app.get_libraries()
            kernel = servers.get_kernel_server()

            # get file name without extension
            foo, file_name = os.path.split(file_path)
            file_name, ext = os.path.splitext(file_name)

            # load new library into memory
            new_library_path = root.getfullname() + "/" + file_name
            if not pynebula.exists(new_library_path):
                kernel.loadas(str(file_path), str(new_library_path))

            self.files[file_name] = [file_path, False]
            return new_library_path

        return ''
Beispiel #12
0
    def load (self, file_path):
        if os.path.exists(file_path):
            root = app.get_libraries()
            kernel = servers.get_kernel_server()
    
            # get file name without extension
            foo, file_name = os.path.split(file_path)
            file_name, ext = os.path.splitext(file_name)
    
            # load new library into memory
            new_library_path = root.getfullname() + "/" + file_name
            if not pynebula.exists(new_library_path):
                kernel.loadas(str(file_path), str(new_library_path))
                        
            self.files[file_name] = [file_path, False]
            return new_library_path

        return ''
Beispiel #13
0
 def __expand_class(self, item, class_name, show_natives=True):
     # Get children classes
     k_server = servers.get_kernel_server()
     classes_tuple = k_server.getsubclasslist(str(class_name))
     # Sort classes
     classes = []
     for name in classes_tuple:
         if (not show_natives) and k_server.isclassnative(str(name)):
             continue
         classes.append(name)
     classes.sort()
     # Append classes to parent's branch
     for name in classes:
         if k_server.isclassnative(str(name)):
             img = self.native_img
         else:
             img = self.no_native_img
         child_item = self.AppendItem(item, name, img, -1)
         self.__set_children_mark(child_item, name)
Beispiel #14
0
 def __expand_class(self, item, class_name, show_natives=True):
     # Get children classes
     k_server = servers.get_kernel_server()
     classes_tuple = k_server.getsubclasslist( str(class_name) )
     # Sort classes
     classes = []
     for name in classes_tuple:
         if (not show_natives) and k_server.isclassnative( str(name) ):
             continue
         classes.append( name )
     classes.sort()
     # Append classes to parent's branch
     for name in classes:
         if k_server.isclassnative( str(name) ):
             img = self.native_img
         else:
             img = self.no_native_img
         child_item = self.AppendItem( item, name, img, -1 )
         self.__set_children_mark( child_item, name )
Beispiel #15
0
    def on_new_class(self, event):
        # Ask for a class name
        dlg = wx.TextEntryDialog(None, "Enter the class name", "New class")
        result_ok = dlg.ShowModal() == wx.ID_OK
        if result_ok:
            class_name = dlg.GetValue().capitalize()
        dlg.Destroy()

        # Create the new class
        if result_ok:
            # Do some name validations
            ec_server = servers.get_entity_class_server()
            if not ec_server.checkclassname(str(class_name)):
                cjr.show_error_message("Invalid class name")
                return
            k_server = servers.get_kernel_server()
            if k_server.findclass(str(class_name)) != "":
                cjr.show_error_message(
                    "There is already another class called '%s'" % class_name)
                return

            # Finally create the class
            parent_name = self.tree_classes.get_selected_class_name()
            if not ec_server.newclass(str(parent_name), str(class_name)):
                msg = "Unknown error.\n\n" \
                            "Unable to create the class '%s'." % class_name
                cjr.show_error_message(msg)
                return
            set_nclass_dirty_flag(True)
            servers.get_script_server().addclass(str(class_name))

            # For some classes, add commands and implementation by default
            class_group = self.tree_classes.get_current_class_group()
            if class_group is not None:
                add_cmds_func_name = '_CommandManagerDialog__add_commands_of_' + class_group
                if CommandManagerDialog.__dict__.has_key(add_cmds_func_name):
                    CommandManagerDialog.__dict__[add_cmds_func_name](
                        self, class_name)
                    servers.get_script_server().refreshclass(str(class_name))

            # Refresh the branch of the currently selected class
            self.tree_classes.on_new_class(class_name)
Beispiel #16
0
 def __bind_events(self):
     self.Bind(
         wx.EVT_NOTEBOOK_PAGE_CHANGED, 
         self.on_page_changed
         )
     pynebula.pyBindSignal(
         servers.get_kernel_server(), 
         'objectdeleted',
         self, 
         'onobjectdeleted', 
         0 
         )
     #bind to events on property tab if I have one
     if self.__has_property_tab():
         self.property_tab.Bind(
             propertyview.EVT_OK_REQUESTED, 
             self.__handle_ok_on_property_tab
             )
         self.property_tab.Bind(
             propertyview.EVT_CANCEL_REQUESTED, 
             self.__handle_cancel_on_property_tab
             )
Beispiel #17
0
 def on_clean_commands(self, event):
     """Delete the whole directories of the non existent classes"""
     # Remove the classes directories
     ks = servers.get_kernel_server()
     removed_cmds = []
     classes_path = format.mangle_path( cmdmgrdlg.ClassesPath )
     filenames = os.listdir( classes_path )
     for filename in filenames:
         if filename.startswith("."):
             # skip special directories/files
             continue
         file_path = format.append_to_path( classes_path, filename )
         if os.path.isdir( file_path ) and ks.findclass(str(filename)) == "":
             cmdmgrdlg.remove_class_dir( file_path, removed_cmds, filename )
     
     # Show which have been the removed classes
     if len( removed_cmds ) == 0:
         cjr.show_information_message(
             "No trash command has been found."
             )
     else:
         dlg = CleanReportDialog( self.get_frame(), removed_cmds )
         dlg.ShowModal()
         dlg.Destroy()
Beispiel #18
0
 def expand_sublists (self, item):
     if self.IsExpanded(item):
         # This event can happen twice in the self.Expand call
         return
     obj = self.GetPyData(item)
     node = obj.gethead()
     fileserver = servers.get_file_server()
     self.libidx = self.image_list.Add(
                         wx.Bitmap(
                             fileserver.manglepath(
                                 "outgui:images/tools/new.bmp"
                                 ),
                         wx.BITMAP_TYPE_ANY
                         )
                     )
     while node != None:
         obj = pynebula.lookup(node.getfullname())
         new_item = self.AppendItem(
                             item, 
                             obj.getname(), 
                             -1, 
                             -1,
                             wx.TreeItemData(obj)
                             )
         if self.is_library(new_item):
             self.SetItemImage(
                 new_item, self.libidx, wx.TreeItemIcon_Normal
                 )
             self.SetItemImage(
                 new_item, self.libidx, wx.TreeItemIcon_Selected
                 )
             self.SetItemImage(
                 new_item, self.libidx, wx.TreeItemIcon_Expanded
                 )
         elif self.GetItemText(self.get_root_library(new_item)) == 'natives' and servers.get_kernel_server().isclassnative(str(self.GetItemText(new_item))):
             self.SetItemImage(
                 new_item, self.fldridxnative, wx.TreeItemIcon_Normal
                 )
             self.SetItemImage(
                 new_item, self.fldropenidxnative, wx.TreeItemIcon_Selected
                 )
             self.SetItemImage(
                 new_item, self.fldropenidxnative, wx.TreeItemIcon_Expanded
                 )
         elif self.GetItemText(self.get_root_library(new_item)) == 'natives' and not servers.get_kernel_server().isclassnative(str(self.GetItemText(new_item))):
             self.SetItemImage(
                 new_item, self.fldridxuser, wx.TreeItemIcon_Normal
                 )
             self.SetItemImage(
                 new_item, self.fldropenidxuser, wx.TreeItemIcon_Selected
                 )
             self.SetItemImage(
                 new_item, self.fldropenidxuser, wx.TreeItemIcon_Expanded
                 )
         else:
             self.SetItemImage(
                 new_item, self.fldridxnormal, wx.TreeItemIcon_Normal
                 )
             self.SetItemImage(
                 new_item, self.fldropenidxnormal, wx.TreeItemIcon_Selected
             )
             self.SetItemImage(
                 new_item, self.fldropenidxnormal, wx.TreeItemIcon_Expanded
                 )
         if obj.gethead() != None:
             self.SetItemHasChildren(new_item, True)
         node = obj.getsucc()
         self.SortChildren(item)
Beispiel #19
0
def get_script_operations():
    """Return a list with all the available operation scripts (the class names)"""
    classes = servers.get_kernel_server().getsubclasslist( 'nscriptoperation' )
    list = []
    list.extend( classes )
    return list
Beispiel #20
0
 def __set_children_mark(self, item, class_name):
     # Show the expansion mark if there's some class inheriting from the
     # given one, otherwise hide it
     k_server = servers.get_kernel_server()
     has_children = len(k_server.getsubclasslist(class_name) ) > 0
     self.SetItemHasChildren( item, has_children )
Beispiel #21
0
 def __set_children_mark(self, item, class_name):
     # Show the expansion mark if there's some class inheriting from the
     # given one, otherwise hide it
     k_server = servers.get_kernel_server()
     has_children = len(k_server.getsubclasslist(class_name)) > 0
     self.SetItemHasChildren(item, has_children)
Beispiel #22
0
 def loadContainerObjectFromFile(self, aFilePath):
     aKernelServer = servers.get_kernel_server()
     return aKernelServer.load( str(aFilePath) )
Beispiel #23
0
def get_action_scripts():
    """Return a list with all the available action scripts (the class names)"""
    classes = servers.get_kernel_server().getsubclasslist( 'gpactionscript' )
    list = []
    list.extend( classes )
    return list
Beispiel #24
0
def get_fsm_selectors():
    """Return a list with all the available FSM selectors (the class names)"""
    classes = servers.get_kernel_server().getsubclasslist( 'nfsmselector' )
    list = []
    list.extend( classes )
    return list
Beispiel #25
0
def get_trigger_scripts():
    """Return a list with all the available trigger scripts (the class names)"""
    classes = servers.get_kernel_server().getsubclasslist( 'ntriggerscript' )
    list = []
    list.extend( classes )
    return list
Beispiel #26
0
 def __del__(self):
     pynebula.pyUnbindTargetObject(
         servers.get_kernel_server(), 
         'objectdeleted', 
         self
         )