12 |
""" |
""" |
13 |
|
|
14 |
__version__ = "$Revision$" |
__version__ = "$Revision$" |
15 |
|
# $Source$ |
16 |
__ThubanVersion__ = "0.8" #"$THUBAN_0_2$" |
# $Id$ |
|
#__BuildDate__ = "$Date$" |
|
17 |
|
|
18 |
import os |
import os |
19 |
import copy |
import copy |
20 |
|
|
21 |
from wxPython.wx import * |
from wxPython.wx import * |
|
from wxPython.wx import __version__ as wxPython_version |
|
22 |
|
|
23 |
import Thuban |
import Thuban |
|
import Thuban.version |
|
24 |
|
|
25 |
from Thuban import _ |
from Thuban import _ |
26 |
from Thuban.Model.session import create_empty_session |
from Thuban.Model.session import create_empty_session |
27 |
from Thuban.Model.layer import Layer, RasterLayer |
from Thuban.Model.layer import Layer, RasterLayer |
28 |
from Thuban.Model.postgisdb import PostGISShapeStore |
from Thuban.Model.postgisdb import PostGISShapeStore, has_postgis_support |
29 |
# XXX: replace this by |
# XXX: replace this by |
30 |
# from wxPython.lib.dialogs import wxMultipleChoiceDialog |
# from wxPython.lib.dialogs import wxMultipleChoiceDialog |
31 |
# when Thuban does not support wxPython 2.4.0 any more. |
# when Thuban does not support wxPython 2.4.0 any more. |
46 |
|
|
47 |
from Thuban.UI.dock import DockFrame |
from Thuban.UI.dock import DockFrame |
48 |
from Thuban.UI.join import JoinDialog |
from Thuban.UI.join import JoinDialog |
49 |
from Thuban.UI.dbdialog import DBFrame, ChooseDBTableDialog |
from Thuban.UI.dbdialog import DBFrame, DBDialog, ChooseDBTableDialog |
50 |
import resource |
import resource |
51 |
import Thuban.Model.resource |
import Thuban.Model.resource |
52 |
|
|
373 |
"Thuban Session File (*.thuban)|*.thuban", |
"Thuban Session File (*.thuban)|*.thuban", |
374 |
wxOPEN) |
wxOPEN) |
375 |
if dlg.ShowModal() == wxID_OK: |
if dlg.ShowModal() == wxID_OK: |
376 |
self.application.OpenSession(dlg.GetPath()) |
self.application.OpenSession(dlg.GetPath(), |
377 |
|
self.run_db_param_dialog) |
378 |
dlg.Destroy() |
dlg.Destroy() |
379 |
|
|
380 |
|
def run_db_param_dialog(self, parameters, message): |
381 |
|
dlg = DBDialog(self, _("DB Connection Parameters"), parameters, |
382 |
|
message) |
383 |
|
return dlg.RunDialog() |
384 |
|
|
385 |
def SaveSession(self): |
def SaveSession(self): |
386 |
if self.application.session.filename == None: |
if self.application.session.filename == None: |
387 |
self.SaveSessionAs() |
self.SaveSessionAs() |
509 |
def AddDBLayer(self): |
def AddDBLayer(self): |
510 |
"""Add a layer read from a database""" |
"""Add a layer read from a database""" |
511 |
session = self.application.Session() |
session = self.application.Session() |
512 |
dlg = ChooseDBTableDialog(self.application.Session(), self,-1, "") |
dlg = ChooseDBTableDialog(self, self.application.Session()) |
513 |
|
|
514 |
if dlg.ShowModal() == wxID_OK: |
if dlg.ShowModal() == wxID_OK: |
515 |
dbconn, dbtable = dlg.GetTable() |
dbconn, dbtable = dlg.GetTable() |
975 |
"""Return whether the the session has database connections""" |
"""Return whether the the session has database connections""" |
976 |
return context.session.HasDBConnections() |
return context.session.HasDBConnections() |
977 |
|
|
978 |
|
def _has_postgis_support(context): |
979 |
|
return has_postgis_support() |
980 |
|
|
981 |
|
|
982 |
# File menu |
# File menu |
983 |
_method_command("new_session", _("&New Session"), "NewSession", |
_method_command("new_session", _("&New Session"), "NewSession", |
984 |
helptext = _("Start a new session")) |
helptext = _("Start a new session")) |
995 |
checked = _has_legend_shown, |
checked = _has_legend_shown, |
996 |
helptext = _("Toggle Legend on/off")) |
helptext = _("Toggle Legend on/off")) |
997 |
_method_command("database_management", _("&Database Connections..."), |
_method_command("database_management", _("&Database Connections..."), |
998 |
"DatabaseManagement") |
"DatabaseManagement", |
999 |
|
sensitive = _has_postgis_support) |
1000 |
_method_command("exit", _("E&xit"), "Exit", |
_method_command("exit", _("E&xit"), "Exit", |
1001 |
helptext = _("Finish working with Thuban")) |
helptext = _("Finish working with Thuban")) |
1002 |
|
|