Commit c67e4126 authored by eric pellegrini's avatar eric pellegrini
Browse files

The job plugin can now be plugged into the viewer or on the data plugin

The DataInfoPlugin is now OK
Bug fix with pubsub.sendMessage wrong keyword
Improved the AtomListSelectionDialog
Removed unuseful pubsub calls from the molecular viewer
parent 9e9c7fe1
......@@ -47,7 +47,7 @@ class UserDefinitionViewerPlugin(ComponentPlugin):
label = "User Definition Viewer"
ancestor = None
ancestor = []
def __init__(self, parent, *args, **kwargs):
......
......@@ -117,7 +117,7 @@ class AtomsListDialog(UserDefinitionsDialog):
for aname in atomNames:
self._molecules.AppendItem(molnode,aname)
self._atoms = wx.ListCtrl(panel, wx.ID_ANY, style=wx.LC_LIST)
self._atoms = wx.ListCtrl(panel, wx.ID_ANY)
dt = AtomNameDropTarget(self._molecules,self._atoms)
self._atoms.SetDropTarget(dt)
......@@ -147,21 +147,26 @@ class AtomsListDialog(UserDefinitionsDialog):
def on_delete_atom_name(self,event):
keycode = event.GetKeyCode()
if keycode != wx.WXK_DELETE:
return
if keycode == wx.WXK_DELETE:
item = self._atoms.GetFirstSelected()
selectedItems = []
while item != -1:
selectedItems.append(item)
item = self._atoms.GetNextSelected(item)
item = self._atoms.GetFirstSelected()
selectedItems = []
while item != -1:
selectedItems.append(item)
item = self._atoms.GetNextSelected(item)
if not selectedItems:
return
if not selectedItems:
return
selectedItems.reverse()
for it in selectedItems:
self._atoms.DeleteItem(it)
selectedItems.reverse()
for it in selectedItems:
self._atoms.DeleteItem(it)
# This is the ASCII value for Ctrl+A key
elif keycode == 1:
for i in range(self._atoms.GetItemCount()):
item = self._atoms.GetItem(i)
self._atoms.SetItemState(item.GetId(),wx.LIST_STATE_SELECTED,wx.LIST_STATE_SELECTED)
def on_drag_atom_name(self,event):
......@@ -170,7 +175,10 @@ class AtomsListDialog(UserDefinitionsDialog):
parentItem = self._molecules.GetItemParent(item)
if parentItem == self._molecules.GetRootItem():
return
if self._atoms.GetItemCount() >= self._nAtoms:
return
text = self._molecules.GetItemText(item)
tdo = wx.TextDataObject(text)
tds = wx.DropSource(self._molecules)
......@@ -182,7 +190,7 @@ class AtomsListDialog(UserDefinitionsDialog):
self._selection = []
if self._atoms.GetItemCount() != self._nAtoms:
LOGGER('You must select %d atoms.' % self._nAtoms,'error',['dialog'])
LOGGER('You must select exactly %d atoms.' % self._nAtoms,'error',['dialog'])
return
atTreeItem = self._molecules.GetSelection()
......@@ -245,7 +253,7 @@ if __name__ == "__main__":
app = wx.App(False)
p = AtomsListDialog(None,t,10)
p = AtomsListDialog(None,t,4)
p.ShowModal()
......
......@@ -86,24 +86,27 @@ class PluginsTreePanel(wx.Panel):
for kls in REGISTRY["plugin"].values():
ancestor = getattr(kls,"ancestor","")
ancestor = getattr(kls,"ancestor",[])
if not ancestor:
continue
category = getattr(kls, "category", ("Miscellaneous",))
ancestors = []
for anc in ancestor:
ancestors.append(anc)
ancestors.extend([c.type for c in REGISTRY['plugin'][anc].__subclasses__()])
ancestors = [ancestor] + [c.type for c in REGISTRY['plugin'][ancestor].__subclasses__()]
for a in ancestors:
for a in ancestors:
d = self._hierarchy.setdefault(a,collections.OrderedDict())
for cat in category:
d = d.setdefault(cat,{})
d = d.setdefault(cat,collections.OrderedDict())
d[kls.type] = True
def on_double_click(self, event):
data = self._tree.GetPyData(event.GetItem())
......
......@@ -33,7 +33,7 @@ Created on Apr 10, 2015
import wx
import wx.aui as wxaui
from MDANSE.Externals.pubsub import pub as Publisher
from MDANSE.Externals.pubsub import pub
from MDANSE import REGISTRY
from MDANSE.GUI import DATA_CONTROLLER
......@@ -102,6 +102,8 @@ class WorkingPanel(wx.Panel):
self._notebook.SetFocus()
self._notebook.SetSelection(self._notebook.GetPageCount()-1)
def add_empty_data(self):
container = REGISTRY["plugin"].get("empty_data")
......@@ -119,7 +121,7 @@ class WorkingPanel(wx.Panel):
dataPlugin = self._notebook.GetPage(self._notebook.GetSelection())
Publisher.sendMessage(('msg_set_plugins_tree'), message=dataPlugin)
pub.sendMessage('msg_set_plugins_tree', message=dataPlugin)
def on_close_page(self, event):
......@@ -128,5 +130,5 @@ class WorkingPanel(wx.Panel):
dataPlugin.close_children()
if self._notebook.GetPageCount() == 1:
Publisher.sendMessage(('msg_set_plugins_tree'), message=None)
pub.sendMessage('msg_set_plugins_tree', message=None)
\ No newline at end of file
......@@ -17,9 +17,9 @@ for job in REGISTRY["job"].values():
if not hasattr(job, "type"):
continue
attrs = {"type" : job.type,
"ancestor" : getattr(job,"ancestor",""),
"ancestor" : getattr(job,'ancestor',[]),
"category" : ('Analysis',) + getattr(job, "category", ("Miscellaneous",)),
"label" : getattr(job, "label", job.__name__)}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment