diff --git a/Mixins/Abstractable.py b/Mixins/Abstractable.py index ba692e6c..4517384e 100644 --- a/Mixins/Abstractable.py +++ b/Mixins/Abstractable.py @@ -23,7 +23,6 @@ import sys from Mixins.Attributable import Attributable -from DomainInterface.DomainBehavior import DomainBehavior import Container import DetachedFrame diff --git a/PluginsGUI.py b/PluginsGUI.py index 6e1f8d57..0726739f 100644 --- a/PluginsGUI.py +++ b/PluginsGUI.py @@ -62,7 +62,7 @@ def __init__(self, *args, **kw): self.EnableCheckBoxes(True) self.IsChecked = self.IsItemChecked - #else: + CheckListCtrlMixin.__init__(self) self.id = -100000000 @@ -94,22 +94,22 @@ def __init__(self, *args, **kw): #self.Bind(wx.EVT_MOTION, self.OnMotion) - def OnMotion(self, evt): - """ - """ - item, flags = self.HitTest(evt.GetPosition()) + # def OnMotion(self, evt): + # """ + # """ + # item, flags = self.HitTest(evt.GetPosition()) - try: - path = self.GetPyData(item) - self.SetToolTip(path[0].__file__) - except: - self.SetToolTip(None) + # try: + # path = self.GetPyData(item) + # self.SetToolTip(path[0].__file__) + # except: + # self.SetToolTip(None) - ### only from wx 4.1.0 - self.EnableCheckBoxes(True) + # ### only from wx 4.1.0 + # self.EnableCheckBoxes(True) - ### else the drag and drop dont run - #evt.Skip() + # ### else the drag and drop dont run + # evt.Skip() def OnRightClick(self, event): """ Right click has been invoked. @@ -141,24 +141,42 @@ def OnRightClick(self, event): menu.Append(disable) menu.Append(edit) - ### disable the edit menu for the .pyc file - for i in range(self.GetItemCount()): - module = self.GetPyData(i)[0] - if self.IsSelected(i) and module: - path = module.__file__ - if path: - if path.endswith('.pyc'): - edit.Enable(False) - else: - edit.Enable(False) + index = self.currentItem + path = self.GetPath(index) + ### if not path, the module corresponding to the item is + if path: + ### disable the edit menu for the .pyc file + if path.endswith('.pyc'): + edit.Enable(False) + else: + ### is py file and enable only the right sumbemu depending on the stats of the check box + sel = self.IsChecked(index) + if sel: enable.Enable(False) + disable.Enable(True) + else: + enable.Enable(True) disable.Enable(False) + else: + enable.Enable(False) + disable.Enable(False) + edit.Enable(False) # Popup the menu. If an item is selected then its handler # will be called before PopupMenu returns. self.PopupMenu(menu) menu.Destroy() + def isOk(self, item): + """ item is well imported + """ + + module = self.GetPyData(item)[0] + return module and module.__file__ + + def GetPath(self,item): + return self.GetPyData(item)[0].__file__ if self.GetPyData(item) else None + def OnEnable(self, event): """ Ebnable the current item. """ @@ -167,18 +185,9 @@ def OnEnable(self, event): except: index = self.currentItem - try: - module = self.GetPyData(index)[0] - except: - pass - else: - ### module can be disabled - if module.__file__: - self.CheckItem(index, True) - self.SetItemImage(index,1) - else: - self.CheckItem(index, False) - + self.CheckItem(index, True) + self.SetItemImage(index,1) + def OnDisable(self, event): """ Disable the current item. """ @@ -187,17 +196,8 @@ def OnDisable(self, event): except: index = self.currentItem - try: - module = self.GetPyData(index)[0] - except: - pass - else: - ### module can be disabled - if module.__file__: - self.CheckItem(index, False) - self.SetItemImage(index,0) - else: - self.CheckItem(index, True) + self.CheckItem(index, False) + self.SetItemImage(index,0) @abstractmethod def OnEdit(self, event): @@ -215,7 +215,7 @@ def SetPyData(self, item, data): def GetPyData(self, item): """ Get python object Data. """ - return self.map[self.GetItemData(item)] + return self.map.get(self.GetItemData(item),None) def get_selected_items(self): """ @@ -386,23 +386,22 @@ def Clear(self): def OnEdit(self, event): """ """ - for i in range(self.GetItemCount()): - module = self.GetPyData(i)[0] - if self.IsSelected(i) and module: - path = module.__file__ - if path.endswith('.py'): - name = os.path.basename(path) - ### editor frame for the text of plug-ins - editorFrame = Editor.GetEditor(None, \ - wx.NewIdRef(), \ - _("%s - Plug-ins Editor")%name, \ - module, \ - file_type = 'block') - editorFrame.AddEditPage(name, path) - editorFrame.Show() - ### for .pyc file - else: - pass + index = self.currentItem + path = self.GetPath(index) + if self.IsSelected(index) and path and path.endswith('.py'): + name = os.path.basename(path) + module = self.GetPyData(index)[0] + ### editor frame for the text of plug-ins + editorFrame = Editor.GetEditor(None, \ + wx.NewIdRef(), \ + _("%s - Plug-ins Editor")%name, \ + module, \ + file_type = 'block') + editorFrame.AddEditPage(name, path) + editorFrame.Show() + ### for .pyc file + else: + pass def OnApply(self, event): """ Method called by PreferenceGUI class. @@ -417,11 +416,11 @@ def OnApply(self, event): module = self.GetPyData(i)[0] if inspect.ismodule(module): ### plug-in file path - file = module.__file__ + path = module.__file__ ### built-in module coming from empty module create by error manager - if file is not None: + if path: ### get abspath and exclude .pyc - name,ext = os.path.splitext(os.path.basename(file)) + name,ext = os.path.splitext(os.path.basename(path)) ### if plug-in is checked, we activate it if self.IsChecked(i): diff --git a/devsimpy.py b/devsimpy.py index d68d9098..77f8e85d 100644 --- a/devsimpy.py +++ b/devsimpy.py @@ -150,8 +150,8 @@ 'LOG_FILE': os.devnull, # log file (null by default) 'DEFAULT_SIM_STRATEGY': 'bag-based', #choose the default simulation strategy for PyDEVS 'PYDEVS_SIM_STRATEGY_DICT' : {'original':'SimStrategy1', 'bag-based':'SimStrategy2', 'direct-coupling':'SimStrategy3'}, # list of available simulation strategy for PyDEVS package - 'PYPDEVS_SIM_STRATEGY_DICT' : {'classic':'SimStrategy4', 'distributed':'SimStrategy5', 'parallel':'SimStrategy6'}, # list of available simulation strategy for PyPDEVS package - 'PYPDEVS_221_SIM_STRATEGY_DICT' : {'classic':'SimStrategy4', 'distributed':'SimStrategy5', 'parallel':'SimStrategy6'}, # list of available simulation strategy for PyPDEVS package + 'PYPDEVS_SIM_STRATEGY_DICT' : {'classic':'SimStrategy4', 'parallel':'SimStrategy5'}, # list of available simulation strategy for PyPDEVS package + 'PYPDEVS_221_SIM_STRATEGY_DICT' : {'classic':'SimStrategy4', 'parallel':'SimStrategy5'}, # list of available simulation strategy for PyPDEVS package 'HELP_PATH' : os.path.join('doc', 'html'), # path of help directory 'NTL' : False, # No Time Limit for the simulation 'DYNAMIC_STRUCTURE' : False, # Dynamic Structure for local PyPDEVS simulation @@ -170,7 +170,8 @@ ### Check if the pypdevs241 directory is empty (not --recursive option when the devsimpy git has been cloned) path = os.path.join(ABS_HOME_PATH,'DEVSKernel','PyPDEVS','pypdevs241') if os.path.exists(path) and not len(os.listdir(path)) == 0: - builtin_dict['DEVS_DIR_PATH_DICT'].update({'PyPDEVS_241':os.path.join(path ,'src','pypdevs')}) + builtin_dict['PYPDEVS_221_SIM_STRATEGY_DICT'] = {'classic':'SimStrategy4', 'parallel':'SimStrategy5'} + builtin_dict['DEVS_DIR_PATH_DICT'].update({'PyPDEVS_241':os.path.join(path ,'src','pypdevs')}) else: sys.stdout.write("PyPDEVS Kernel in version 2.4.1 is not loaded.\nPlease install it in the directory %s using git (http://msdl.uantwerpen.be/git/yentl/PythonPDEVS.git)\n"%path)