22 |
|
|
23 |
from messages import SHAPES_SELECTED, SESSION_REPLACED |
from messages import SHAPES_SELECTED, SESSION_REPLACED |
24 |
from Thuban.Model.messages import TABLE_REMOVED, MAP_LAYERS_REMOVED |
from Thuban.Model.messages import TABLE_REMOVED, MAP_LAYERS_REMOVED |
25 |
|
from Thuban.UI.common import ThubanBeginBusyCursor, ThubanEndBusyCursor |
26 |
|
|
27 |
wx_value_type_map = {FIELDTYPE_INT: wxGRID_VALUE_NUMBER, |
wx_value_type_map = {FIELDTYPE_INT: wxGRID_VALUE_NUMBER, |
28 |
FIELDTYPE_DOUBLE: wxGRID_VALUE_FLOAT, |
FIELDTYPE_DOUBLE: wxGRID_VALUE_FLOAT, |
257 |
nothing. If shape or layer is None also do nothing. |
nothing. If shape or layer is None also do nothing. |
258 |
""" |
""" |
259 |
if layer is not None \ |
if layer is not None \ |
260 |
and layer.table is self.table.table: |
and layer.ShapeStore().Table() is self.table.table: |
261 |
|
|
262 |
self.disallow_messages() |
self.disallow_messages() |
263 |
try: |
try: |
286 |
|
|
287 |
def __init__(self, parent, name, title, table): |
def __init__(self, parent, name, title, table): |
288 |
ThubanFrame.__init__(self, parent, name, title) |
ThubanFrame.__init__(self, parent, name, title) |
289 |
|
self.panel = wxPanel(self, -1) |
290 |
|
|
291 |
self.table = table |
self.table = table |
292 |
self.grid = self.make_grid(self.table) |
self.grid = self.make_grid(self.table) |
293 |
self.app = self.parent.application |
self.app = self.parent.application |
295 |
self.session = self.app.Session() |
self.session = self.app.Session() |
296 |
self.session.Subscribe(TABLE_REMOVED, self.close_on_table_removed) |
self.session.Subscribe(TABLE_REMOVED, self.close_on_table_removed) |
297 |
|
|
298 |
|
|
299 |
def make_grid(self, table): |
def make_grid(self, table): |
300 |
"""Return the table grid to use in the frame. |
"""Return the table grid to use in the frame. |
301 |
|
|
343 |
def __init__(self, parent, name, title, table): |
def __init__(self, parent, name, title, table): |
344 |
TableFrame.__init__(self, parent, name, title, table) |
TableFrame.__init__(self, parent, name, title, table) |
345 |
|
|
346 |
self.combo_fields = wxComboBox(self, -1, style=wxCB_READONLY) |
self.combo_fields = wxComboBox(self.panel, -1, style=wxCB_READONLY) |
347 |
self.choice_comp = wxChoice(self, -1, |
self.choice_comp = wxChoice(self.panel, -1, |
348 |
choices=["<", "<=", "==", "!=", ">=", ">"]) |
choices=["<", "<=", "==", "!=", ">=", ">"]) |
349 |
self.combo_value = wxComboBox(self, ID_COMBOVALUE) |
self.combo_value = wxComboBox(self.panel, ID_COMBOVALUE) |
350 |
self.choice_action = wxChoice(self, -1, |
self.choice_action = wxChoice(self.panel, -1, |
351 |
choices=[_("Replace Selection"), |
choices=[_("Replace Selection"), |
352 |
_("Refine Selection"), |
_("Refine Selection"), |
353 |
_("Add to Selection")]) |
_("Add to Selection")]) |
354 |
|
|
355 |
button_query = wxButton(self, ID_QUERY, _("Query")) |
button_query = wxButton(self.panel, ID_QUERY, _("Query")) |
356 |
button_saveas = wxButton(self, ID_EXPORT, _("Export")) |
button_saveas = wxButton(self.panel, ID_EXPORT, _("Export")) |
357 |
|
|
358 |
self.CreateStatusBar() |
self.CreateStatusBar() |
|
self.SetStatusText(_("0 rows (0 selected), 0 columns")) |
|
359 |
|
|
360 |
self.grid.SetSize((400, 200)) |
self.grid.SetSize((400, 200)) |
361 |
|
|
371 |
self.choice_action.SetSelection(0) |
self.choice_action.SetSelection(0) |
372 |
self.choice_comp.SetSelection(0) |
self.choice_comp.SetSelection(0) |
373 |
|
|
374 |
|
self.grid.Reparent(self.panel) |
375 |
|
|
376 |
|
self.UpdateStatusText() |
377 |
|
|
378 |
topBox = wxBoxSizer(wxVERTICAL) |
topBox = wxBoxSizer(wxVERTICAL) |
379 |
|
|
380 |
sizer = wxStaticBoxSizer(wxStaticBox(self, -1, |
sizer = wxStaticBoxSizer(wxStaticBox(self.panel, -1, |
381 |
_("Selection")), |
_("Selection")), |
382 |
wxHORIZONTAL) |
wxHORIZONTAL) |
383 |
sizer.Add(self.combo_fields, 1, wxEXPAND|wxALL, 4) |
sizer.Add(self.combo_fields, 1, wxEXPAND|wxALL, 4) |
391 |
topBox.Add(sizer, 0, wxEXPAND|wxALL, 4) |
topBox.Add(sizer, 0, wxEXPAND|wxALL, 4) |
392 |
topBox.Add(self.grid, 1, wxEXPAND|wxALL, 0) |
topBox.Add(self.grid, 1, wxEXPAND|wxALL, 0) |
393 |
|
|
394 |
|
self.panel.SetAutoLayout(True) |
395 |
|
self.panel.SetSizer(topBox) |
396 |
|
topBox.Fit(self.panel) |
397 |
|
topBox.SetSizeHints(self.panel) |
398 |
|
|
399 |
|
panelSizer = wxBoxSizer(wxVERTICAL) |
400 |
|
panelSizer.Add(self.panel, 1, wxEXPAND, 0) |
401 |
self.SetAutoLayout(True) |
self.SetAutoLayout(True) |
402 |
self.SetSizer(topBox) |
self.SetSizer(panelSizer) |
403 |
topBox.Fit(self) |
panelSizer.Fit(self) |
404 |
topBox.SetSizeHints(self) |
panelSizer.SetSizeHints(self) |
405 |
|
|
406 |
self.grid.SetFocus() |
self.grid.SetFocus() |
407 |
|
|
408 |
EVT_BUTTON(self, ID_QUERY, self.OnQuery) |
EVT_BUTTON(self, ID_QUERY, self.OnQuery) |
409 |
EVT_BUTTON(self, ID_EXPORT, self.OnSaveAs) |
EVT_BUTTON(self, ID_EXPORT, self.OnSaveAs) |
410 |
EVT_KEY_DOWN(self.grid, self.OnKeyDown) |
EVT_KEY_DOWN(self.grid, self.OnKeyDown) |
434 |
event.Skip() |
event.Skip() |
435 |
|
|
436 |
def OnQuery(self, event): |
def OnQuery(self, event): |
437 |
wxBeginBusyCursor() |
ThubanBeginBusyCursor() |
438 |
try: |
try: |
439 |
|
|
440 |
text = self.combo_value.GetValue() |
text = self.combo_value.GetValue() |
496 |
self.grid.SelectRow(ids[0], True) |
self.grid.SelectRow(ids[0], True) |
497 |
|
|
498 |
finally: |
finally: |
499 |
wxEndBusyCursor() |
ThubanEndBusyCursor() |
500 |
|
|
501 |
def OnSaveAs(self, event): |
def OnSaveAs(self, event): |
502 |
dlg = wxFileDialog(self, _("Export Table To"), ".", "", |
dlg = wxFileDialog(self, _("Export Table To"), ".", "", |