2006-08-08 10:48:55 +02:00
|
|
|
|
|
|
|
from system import logger, dataset
|
|
|
|
|
|
|
|
import pygtk
|
|
|
|
import gtk
|
|
|
|
import gtk.gdk
|
|
|
|
import gtk.glade
|
|
|
|
import gnome
|
|
|
|
import gnome.ui
|
|
|
|
import gobject
|
|
|
|
|
|
|
|
class SelectionTree(gtk.TreeView):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.store = gtk.TreeStore(gobject.TYPE_STRING)
|
|
|
|
gtk.TreeView.__init__(self, self.store)
|
|
|
|
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
sel_column = gtk.TreeViewColumn('Selection', renderer, text=0)
|
|
|
|
self.insert_column(sel_column, 0)
|
|
|
|
|
|
|
|
self.connect('row-activated', self.on_row_activated)
|
|
|
|
|
|
|
|
self._identifier_list = None
|
|
|
|
self._dim_list = {}
|
|
|
|
|
|
|
|
# A mapping of selection names to selection lines.
|
|
|
|
self._selections = {}
|
|
|
|
|
|
|
|
self.set_headers_visible(True)
|
2006-08-09 16:35:42 +02:00
|
|
|
self._current_dim = None
|
2006-08-08 10:48:55 +02:00
|
|
|
|
|
|
|
def set_identifier_list(self, identifier_list):
|
|
|
|
self._identifier_list = identifier_list
|
|
|
|
|
|
|
|
def set_project(self, project):
|
|
|
|
self.project = project
|
|
|
|
project.add_selection_observer(self)
|
|
|
|
project.add_dataset_observer(self)
|
|
|
|
self.update_dims(project.dim_names)
|
|
|
|
|
|
|
|
def selection_changed(self, selection):
|
|
|
|
self.update_dims(selection.keys())
|
2006-08-09 16:35:42 +02:00
|
|
|
self._update_current_dim()
|
2006-08-08 10:48:55 +02:00
|
|
|
|
|
|
|
def dataset_changed(self):
|
|
|
|
self.selection_changed(self.project.get_selection())
|
|
|
|
|
|
|
|
def update_dims(self, dim_list):
|
|
|
|
for dim in dim_list:
|
|
|
|
if not self._dim_list.has_key(dim):
|
|
|
|
d = self.store.insert_after(None, None, (dim,))
|
|
|
|
self._dim_list[dim] = d
|
|
|
|
self.store.insert_before(d, None, ('current selection',))
|
|
|
|
|
|
|
|
def on_row_activated(self, treeview, path, column):
|
|
|
|
i = self.store.get_iter(path)
|
|
|
|
p = self.store.iter_parent(i)
|
2006-08-09 16:35:42 +02:00
|
|
|
self._current_dim = self.store.get_value(p, 0)
|
|
|
|
self._update_current_dim()
|
2006-08-08 10:48:55 +02:00
|
|
|
|
2006-08-09 16:35:42 +02:00
|
|
|
def _update_current_dim(self):
|
|
|
|
if not self._current_dim:
|
|
|
|
return
|
|
|
|
id_list = self.project.get_selection()[self._current_dim]
|
|
|
|
self._identifier_list.set_identifiers(id_list)
|
2006-08-08 10:48:55 +02:00
|
|
|
|
|
|
|
class IdentifierList(gtk.TreeView):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.store = gtk.ListStore(gobject.TYPE_STRING)
|
|
|
|
gtk.TreeView.__init__(self, self.store)
|
|
|
|
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
ids_column = gtk.TreeViewColumn('Identifiers', renderer, text=0)
|
|
|
|
self.insert_column(ids_column, 0)
|
|
|
|
|
|
|
|
self.set_headers_visible(True)
|
|
|
|
|
|
|
|
def set_identifiers(self, identifiers):
|
|
|
|
self.store.clear()
|
|
|
|
for e in identifiers:
|
|
|
|
self.store.append((e,))
|