407 |
# yet. |
# yet. |
408 |
self.canvas.Unsubscribe(VIEW_POSITION, self.view_position_changed) |
self.canvas.Unsubscribe(VIEW_POSITION, self.view_position_changed) |
409 |
DockFrame.OnClose(self, event) |
DockFrame.OnClose(self, event) |
410 |
|
for dlg in self.dialogs.values(): |
411 |
|
dlg.Destroy() |
412 |
|
self.canvas.Destroy() |
413 |
self.Destroy() |
self.Destroy() |
414 |
|
|
415 |
def SetMap(self, map): |
def SetMap(self, map): |
651 |
return dialog is not None and dialog.IsShown() |
return dialog is not None and dialog.IsShown() |
652 |
|
|
653 |
def TableOpen(self): |
def TableOpen(self): |
|
print "TableOpen: not implemented" |
|
654 |
dlg = wxFileDialog(self, _("Open Table"), ".", "", |
dlg = wxFileDialog(self, _("Open Table"), ".", "", |
655 |
"DBF Files (*.dbf)|*.dbf|" + |
_("DBF Files (*.dbf)") + "|*.dbf|" + |
656 |
"CSV Files (*.csv)|*.csv|" + |
#_("CSV Files (*.csv)") + "|*.csv|" + |
657 |
"All Files (*.*)|*.*", |
_("All Files (*.*)") + "|*.*", |
658 |
wxOPEN) |
wxOPEN) |
659 |
if dlg.ShowModal() == wxID_OK: |
if dlg.ShowModal() == wxID_OK: |
660 |
#self.application.session.OpenTable(dlg.GetPath()) |
filename = dlg.GetPath() |
661 |
pass |
dlg.Destroy() |
662 |
|
try: |
663 |
dlg.Destroy() |
table = self.application.session.OpenTableFile(filename) |
664 |
|
except IOError: |
665 |
|
# the layer couldn't be opened |
666 |
|
self.RunMessageBox(_("Open Table"), |
667 |
|
_("Can't open the file '%s'.") % filename) |
668 |
|
else: |
669 |
|
self.ShowTableView(table) |
670 |
|
|
671 |
def TableClose(self): |
def TableClose(self): |
672 |
print "TableClose: not implemented" |
print "TableClose: not implemented" |
673 |
|
|
674 |
def TableShow(self): |
def TableShow(self): |
675 |
"""Offer a multi-selection dialog for tables to be displayed |
"""Offer a multi-selection dialog for tables to be displayed |
676 |
|
|
677 |
The windows for the selected tables are opened or brought to |
The windows for the selected tables are opened or brought to |
678 |
the front. |
the front. |
679 |
""" |
""" |
680 |
tables = self.application.session.Tables() |
tables = self.application.session.Tables() |
|
table_list = [] |
|
|
for table in tables: |
|
|
table_list.append(table.Title()) |
|
681 |
|
|
682 |
dlg = wxMultipleChoiceDialog(self, _("Pick the table to show:"), |
dlg = wxMultipleChoiceDialog(self, _("Pick the table to show:"), |
683 |
_("Show Table"), table_list, |
_("Show Table"), |
684 |
|
[t.Title() for t in tables], |
685 |
size = (400,300), style = wxRESIZE_BORDER) |
size = (400,300), style = wxRESIZE_BORDER) |
686 |
if (dlg.ShowModal() == wxID_OK): |
if (dlg.ShowModal() == wxID_OK): |
687 |
for i in dlg.GetValue(): |
for i in dlg.GetValue(): |
|
# XXX: First check whether the dialog is already open |
|
|
# and if so, bring it to the front. |
|
688 |
# XXX: if the table belongs to a layer, open a |
# XXX: if the table belongs to a layer, open a |
689 |
# LayerTableFrame instead of QueryTableFrame |
# LayerTableFrame instead of QueryTableFrame |
690 |
print "tables[i]:", tables[i] |
self.ShowTableView(tables[i]) |
|
dialog = tableview.QueryTableFrame(self, table_list[i], |
|
|
_("Table: %s") % table_list[i], |
|
|
tables[i]) |
|
|
self.add_dialog(table_list[i], dialog) |
|
|
dialog.Show(True) |
|
|
|
|
|
# XXX: just some analyis code, remove it when the above XXX is |
|
|
# resolved. |
|
|
for d in self.dialogs.values(): |
|
|
if isinstance(d, tableview.LayerTableFrame): |
|
|
print "LayerTable:", d.GetTitle() |
|
|
elif isinstance(d, tableview.QueryTableFrame): |
|
|
print "QueryTable:", d.GetTitle() |
|
|
else: |
|
|
print "Other:", d.GetTitle() |
|
|
|
|
|
def TableHide(self): |
|
|
print "TableHide: not implemented" |
|
691 |
|
|
692 |
def TableJoin(self): |
def TableJoin(self): |
693 |
dlg = JoinDialog(self, _("Join Tables"), self.application.session) |
dlg = JoinDialog(self, _("Join Tables"), self.application.session) |
694 |
dlg.ShowModal() |
dlg.ShowModal() |
695 |
|
|
696 |
|
def ShowTableView(self, table): |
697 |
|
"""Open a table view for the table and optionally""" |
698 |
|
name = "table_view%d" % id(table) |
699 |
|
dialog = self.get_open_dialog(name) |
700 |
|
if dialog is None: |
701 |
|
dialog = tableview.QueryTableFrame(self, name, |
702 |
|
_("Table: %s") % table.Title(), |
703 |
|
table) |
704 |
|
self.add_dialog(name, dialog) |
705 |
|
dialog.Show(True) |
706 |
|
# FIXME: else bring dialog to front |
707 |
|
|
708 |
def ZoomInTool(self): |
def ZoomInTool(self): |
709 |
self.canvas.ZoomInTool() |
self.canvas.ZoomInTool() |
710 |
|
|
927 |
_method_command("table_open", _("&Open..."), "TableOpen") |
_method_command("table_open", _("&Open..."), "TableOpen") |
928 |
_method_command("table_close", _("&Close"), "TableClose") |
_method_command("table_close", _("&Close"), "TableClose") |
929 |
_method_command("table_show", _("&Show"), "TableShow") |
_method_command("table_show", _("&Show"), "TableShow") |
|
_method_command("table_hide", _("&Hide"), "TableHide") |
|
930 |
_method_command("table_join", _("&Join..."), "TableJoin") |
_method_command("table_join", _("&Join..."), "TableJoin") |
931 |
|
|
932 |
# Export only under Windows ... |
# Export only under Windows ... |
971 |
Menu("table", _("&Table"), |
Menu("table", _("&Table"), |
972 |
["table_open", "table_close", |
["table_open", "table_close", |
973 |
None, |
None, |
974 |
"table_show", "table_hide", |
"table_show", |
975 |
None, |
None, |
976 |
"table_join"]), |
"table_join"]), |
977 |
Menu("help", _("&Help"), |
Menu("help", _("&Help"), |