/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/UI/mainwindow.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/UI/mainwindow.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1622 by jan, Thu Aug 21 11:56:06 2003 UTC revision 2529 by russell, Thu Jan 20 17:55:23 2005 UTC
# Line 1  Line 1 
1  # Copyright (C) 2001, 2002, 2003 by Intevation GmbH  # Copyright (C) 2001, 2002, 2003, 2004 by Intevation GmbH
2  # Authors:  # Authors:
3  # Jan-Oliver Wagner <[email protected]>  # Jan-Oliver Wagner <[email protected]>
4  # Bernhard Herzog <[email protected]>  # Bernhard Herzog <[email protected]>
# Line 12  The main window Line 12  The main window
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.messages import TITLE_CHANGED
27  from Thuban.Model.session import create_empty_session  from Thuban.Model.session import create_empty_session
28  from Thuban.Model.layer import Layer, RasterLayer  from Thuban.Model.layer import Layer, RasterLayer
29  from Thuban.Model.postgisdb import PostGISShapeStore  from Thuban.Model.postgisdb import PostGISShapeStore, has_postgis_support
30  # XXX: replace this by  # XXX: replace this by
31  # from wxPython.lib.dialogs import wxMultipleChoiceDialog  # from wxPython.lib.dialogs import wxMultipleChoiceDialog
32  # when Thuban does not support wxPython 2.4.0 any more.  # when Thuban does not support wxPython 2.4.0 any more.
# Line 37  from Thuban.UI.multiplechoicedialog impo Line 35  from Thuban.UI.multiplechoicedialog impo
35  import view  import view
36  import tree  import tree
37  import tableview, identifyview  import tableview, identifyview
 from Thuban.UI.classifier import Classifier  
38  import legend  import legend
39  from menu import Menu  from menu import Menu
40    
# Line 49  from about import About Line 46  from about import About
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    
53  import projdialog  import projdialog
54    
55    from Thuban.Lib.classmapper import ClassMapper
56    
57    layer_properties_dialogs = ClassMapper()
58    
59  class MainWindow(DockFrame):  class MainWindow(DockFrame):
60    
# Line 104  class MainWindow(DockFrame): Line 104  class MainWindow(DockFrame):
104          canvas.Subscribe(VIEW_POSITION, self.view_position_changed)          canvas.Subscribe(VIEW_POSITION, self.view_position_changed)
105          canvas.Subscribe(SHAPES_SELECTED, self.identify_view_on_demand)          canvas.Subscribe(SHAPES_SELECTED, self.identify_view_on_demand)
106          self.canvas = canvas          self.canvas = canvas
107            self.canvas.Subscribe(TITLE_CHANGED, self.title_changed)
108    
109          self.SetMainWindow(self.canvas)          self.SetMainWindow(self.canvas)
110    
# Line 135  class MainWindow(DockFrame): Line 136  class MainWindow(DockFrame):
136          """          """
137          if channel in self.delegated_messages:          if channel in self.delegated_messages:
138              object = getattr(self, self.delegated_messages[channel])              object = getattr(self, self.delegated_messages[channel])
139              object.Unsubscribe(channel, *args)              try:
140                    object.Unsubscribe(channel, *args)
141                except wxPyDeadObjectError:
142                    # The object was a wxObject and has already been
143                    # destroyed. Hopefully it has unsubscribed all its
144                    # subscribers already so that it's OK if we do nothing
145                    # here
146                    pass
147    
148      def __getattr__(self, attr):      def __getattr__(self, attr):
149          """If attr is one of the delegated methods return that method          """If attr is one of the delegated methods return that method
# Line 332  class MainWindow(DockFrame): Line 340  class MainWindow(DockFrame):
340              text = "(%10.10g, %10.10g)" % pos              text = "(%10.10g, %10.10g)" % pos
341          else:          else:
342              text = ""              text = ""
343                map = self.canvas.Map()
344                for layer in map.layers:
345                    bbox = layer.LatLongBoundingBox()
346                    if bbox:
347                        left, bottom, right, top = bbox
348                        if not (-180 <= left <= 180 and
349                            -180 <= right <= 180 and
350                            -90 <= top <= 90 and
351                            -90 <= bottom <= 90):
352                            text = ("Select '"+layer.title+"' and pick a " +
353                                "projection using Layer/Projection...")
354                            break
355    
356          self.set_position_text(text)          self.set_position_text(text)
357    
358      def set_position_text(self, text):      def set_position_text(self, text):
# Line 343  class MainWindow(DockFrame): Line 364  class MainWindow(DockFrame):
364          """          """
365          self.SetStatusText(text)          self.SetStatusText(text)
366    
367        def OpenOrRaiseDialog(self, name, dialog_class, *args, **kw):
368            """
369            Open or raise a dialog.
370    
371            If a dialog with the denoted name does already exist it is
372            raised.  Otherwise a new dialog, an instance of dialog_class,
373            is created, inserted into the main list and displayed.
374            """
375            dialog = self.get_open_dialog(name)
376    
377            if dialog is None:
378                dialog = dialog_class(self, name, *args, **kw)
379                self.add_dialog(name, dialog)
380                dialog.Show(True)
381            else:
382                dialog.Raise()
383                              
384      def save_modified_session(self, can_veto = 1):      def save_modified_session(self, can_veto = 1):
385          """If the current session has been modified, ask the user          """If the current session has been modified, ask the user
386          whether to save it and do so if requested. Return the outcome of          whether to save it and do so if requested. Return the outcome of
# Line 372  class MainWindow(DockFrame): Line 410  class MainWindow(DockFrame):
410    
411      def OpenSession(self):      def OpenSession(self):
412          if self.save_modified_session() != wxID_CANCEL:          if self.save_modified_session() != wxID_CANCEL:
413              dlg = wxFileDialog(self, _("Open Session"), ".", "",              dlg = wxFileDialog(self, _("Open Session"),
414                                   self.application.Path("data"), "",
415                                 "Thuban Session File (*.thuban)|*.thuban",                                 "Thuban Session File (*.thuban)|*.thuban",
416                                 wxOPEN)                                 wxOPEN)
417              if dlg.ShowModal() == wxID_OK:              if dlg.ShowModal() == wxID_OK:
418                  self.application.OpenSession(dlg.GetPath())                  self.application.OpenSession(dlg.GetPath(),
419                                                 self.run_db_param_dialog)
420                    self.application.SetPath("data", dlg.GetPath())
421              dlg.Destroy()              dlg.Destroy()
422    
423        def run_db_param_dialog(self, parameters, message):
424            dlg = DBDialog(self, _("DB Connection Parameters"), parameters,
425                           message)
426            return dlg.RunDialog()
427    
428      def SaveSession(self):      def SaveSession(self):
429          if self.application.session.filename == None:          if self.application.session.filename == None:
430              self.SaveSessionAs()              self.SaveSessionAs()
# Line 386  class MainWindow(DockFrame): Line 432  class MainWindow(DockFrame):
432              self.application.SaveSession()              self.application.SaveSession()
433    
434      def SaveSessionAs(self):      def SaveSessionAs(self):
435          dlg = wxFileDialog(self, _("Save Session As"), ".", "",          dlg = wxFileDialog(self, _("Save Session As"),
436                               self.application.Path("data"), "",
437                             "Thuban Session File (*.thuban)|*.thuban",                             "Thuban Session File (*.thuban)|*.thuban",
438                             wxSAVE|wxOVERWRITE_PROMPT)                             wxSAVE|wxOVERWRITE_PROMPT)
439          if dlg.ShowModal() == wxID_OK:          if dlg.ShowModal() == wxID_OK:
440              self.application.session.SetFilename(dlg.GetPath())              self.application.session.SetFilename(dlg.GetPath())
441              self.application.SaveSession()              self.application.SaveSession()
442                self.application.SetPath("data",dlg.GetPath())
443          dlg.Destroy()          dlg.Destroy()
444    
445      def Exit(self):      def Exit(self):
# Line 414  class MainWindow(DockFrame): Line 462  class MainWindow(DockFrame):
462    
463      def SetMap(self, map):      def SetMap(self, map):
464          self.canvas.SetMap(map)          self.canvas.SetMap(map)
465          self.__SetTitle(map.Title())          self.update_title()
466    
467          dialog = self.FindRegisteredDock("legend")          dialog = self.FindRegisteredDock("legend")
468          if dialog is not None:          if dialog is not None:
# Line 456  class MainWindow(DockFrame): Line 504  class MainWindow(DockFrame):
504          dialog.Raise()          dialog.Raise()
505    
506      def AddLayer(self):      def AddLayer(self):
507          dlg = wxFileDialog(self, _("Select one or more data files"), ".", "",          dlg = wxFileDialog(self, _("Select one or more data files"),
508                             _("Shapefiles (*.shp)") + "|*.shp|" +                             self.application.Path("data"), "",
509                             _("All Files (*.*)") + "|*.*",                             _("Shapefiles (*.shp)") + "|*.shp;*.SHP|" +
510                               _("All Files (*.*)") + "|*.*",
511                             wxOPEN | wxMULTIPLE)                             wxOPEN | wxMULTIPLE)
512          if dlg.ShowModal() == wxID_OK:          if dlg.ShowModal() == wxID_OK:
513              filenames = dlg.GetPaths()              filenames = dlg.GetPaths()
# Line 479  class MainWindow(DockFrame): Line 528  class MainWindow(DockFrame):
528                          # if we're adding a layer to an empty map, fit the                          # if we're adding a layer to an empty map, fit the
529                          # new map to the window                          # new map to the window
530                          self.canvas.FitMapToWindow()                          self.canvas.FitMapToWindow()
531                        self.application.SetPath("data",filename)
532          dlg.Destroy()          dlg.Destroy()
533    
534      def AddRasterLayer(self):      def AddRasterLayer(self):
535          dlg = wxFileDialog(self, _("Select an image file"), ".", "", "*.*",          dlg = wxFileDialog(self, _("Select an image file"),
536                               self.application.Path("data"), "", "*.*",
537                             wxOPEN)                             wxOPEN)
538          if dlg.ShowModal() == wxID_OK:          if dlg.ShowModal() == wxID_OK:
539              filename = dlg.GetPath()              filename = dlg.GetPath()
# Line 501  class MainWindow(DockFrame): Line 552  class MainWindow(DockFrame):
552                      # if we're adding a layer to an empty map, fit the                      # if we're adding a layer to an empty map, fit the
553                      # new map to the window                      # new map to the window
554                      self.canvas.FitMapToWindow()                      self.canvas.FitMapToWindow()
555                    self.application.SetPath("data", filename)
556          dlg.Destroy()          dlg.Destroy()
557    
558      def AddDBLayer(self):      def AddDBLayer(self):
559          """Add a layer read from a database"""          """Add a layer read from a database"""
560          session = self.application.Session()          session = self.application.Session()
561          dlg = ChooseDBTableDialog(self.application.Session(), self,-1, "")          dlg = ChooseDBTableDialog(self, self.application.Session())
562    
563          if dlg.ShowModal() == wxID_OK:          if dlg.ShowModal() == wxID_OK:
564              dbconn, dbtable = dlg.GetTable()              dbconn, dbtable, id_column, geo_column = dlg.GetTable()
565              try:              try:
566                  title = str(dbtable)                  title = str(dbtable)
567    
568                  # Chose the correct Interface for the database type                  # Chose the correct Interface for the database type
569                  store = PostGISShapeStore(dbconn, dbtable)                  store = session.OpenDBShapeStore(dbconn, dbtable,
570                  session.AddShapeStore(store)                                                   id_column = id_column,
571                                                     geometry_column = geo_column)
572                  layer = Layer(title, store)                  layer = Layer(title, store)
573              except:              except:
574                  # Some error occured while initializing the layer                  # Some error occured while initializing the layer
575                  self.RunMessageBox(_("Add Layer from database"),                  self.RunMessageBox(_("Add Layer from database"),
576                                     _("Can't open the database table '%s'")                                     _("Can't open the database table '%s'")
577                                     % dbtable)                                     % dbtable)
578                    return
579    
580              map = self.canvas.Map()              map = self.canvas.Map()
581    
# Line 550  class MainWindow(DockFrame): Line 604  class MainWindow(DockFrame):
604              return self.canvas.Map().CanRemoveLayer(layer)              return self.canvas.Map().CanRemoveLayer(layer)
605          return False          return False
606    
607        def LayerToTop(self):
608            layer = self.current_layer()
609            if layer is not None:
610                self.canvas.Map().MoveLayerToTop(layer)
611    
612      def RaiseLayer(self):      def RaiseLayer(self):
613          layer = self.current_layer()          layer = self.current_layer()
614          if layer is not None:          if layer is not None:
# Line 560  class MainWindow(DockFrame): Line 619  class MainWindow(DockFrame):
619          if layer is not None:          if layer is not None:
620              self.canvas.Map().LowerLayer(layer)              self.canvas.Map().LowerLayer(layer)
621    
622        def LayerToBottom(self):
623            layer = self.current_layer()
624            if layer is not None:
625                self.canvas.Map().MoveLayerToBottom(layer)
626    
627      def current_layer(self):      def current_layer(self):
628          """Return the currently selected layer.          """Return the currently selected layer.
629    
# Line 571  class MainWindow(DockFrame): Line 635  class MainWindow(DockFrame):
635          """Return true if a layer is currently selected"""          """Return true if a layer is currently selected"""
636          return self.canvas.HasSelectedLayer()          return self.canvas.HasSelectedLayer()
637    
638        def has_selected_shape_layer(self):
639            """Return true if a shape layer is currently selected"""
640            return isinstance(self.current_layer(), Layer)
641    
642      def has_selected_shapes(self):      def has_selected_shapes(self):
643          """Return true if a shape is currently selected"""          """Return true if a shape is currently selected"""
644          return self.canvas.HasSelectedShapes()          return self.canvas.HasSelectedShapes()
# Line 578  class MainWindow(DockFrame): Line 646  class MainWindow(DockFrame):
646      def HideLayer(self):      def HideLayer(self):
647          layer = self.current_layer()          layer = self.current_layer()
648          if layer is not None:          if layer is not None:
649              layer.SetVisible(0)              layer.SetVisible(False)
650    
651      def ShowLayer(self):      def ShowLayer(self):
652          layer = self.current_layer()          layer = self.current_layer()
653          if layer is not None:          if layer is not None:
654              layer.SetVisible(1)              layer.SetVisible(True)
655    
656        def ToggleLayerVisibility(self):
657            layer = self.current_layer()
658            layer.SetVisible(not layer.Visible())
659    
660      def DuplicateLayer(self):      def DuplicateLayer(self):
661          """Ceate a new layer above the selected layer with the same shapestore          """Ceate a new layer above the selected layer with the same shapestore
# Line 594  class MainWindow(DockFrame): Line 666  class MainWindow(DockFrame):
666                                layer.ShapeStore(),                                layer.ShapeStore(),
667                                projection = layer.GetProjection())                                projection = layer.GetProjection())
668              new_classification = copy.deepcopy(layer.GetClassification())              new_classification = copy.deepcopy(layer.GetClassification())
669                new_layer.SetClassificationColumn(
670                        layer.GetClassificationColumn())
671              new_layer.SetClassification(new_classification)              new_layer.SetClassification(new_classification)
672              self.Map().AddLayer(new_layer)              self.Map().AddLayer(new_layer)
673    
# Line 603  class MainWindow(DockFrame): Line 677  class MainWindow(DockFrame):
677          return layer is not None and hasattr(layer, "ShapeStore")          return layer is not None and hasattr(layer, "ShapeStore")
678    
679      def LayerShowTable(self):      def LayerShowTable(self):
680            """
681            Present a TableView Window for the current layer.
682            In case the window is already open, bring it to the front.
683            In case, there is no active layer, do nothing.
684            In case, the layer has no ShapeStore, do nothing.
685            """
686          layer = self.current_layer()          layer = self.current_layer()
687          if layer is not None:          if layer is not None:
688                if not hasattr(layer, "ShapeStore"):
689                    return
690              table = layer.ShapeStore().Table()              table = layer.ShapeStore().Table()
691              name = "table_view" + str(id(table))              name = "table_view" + str(id(table))
692              dialog = self.get_open_dialog(name)              dialog = self.get_open_dialog(name)
# Line 615  class MainWindow(DockFrame): Line 697  class MainWindow(DockFrame):
697                  self.add_dialog(name, dialog)                  self.add_dialog(name, dialog)
698                  dialog.Show(True)                  dialog.Show(True)
699              else:              else:
700                  # FIXME: bring dialog to front here                  dialog.Raise()
                 pass  
701    
702      def MapProjection(self):      def MapProjection(self):
703    
# Line 658  class MainWindow(DockFrame): Line 739  class MainWindow(DockFrame):
739          self.OpenLayerProperties(layer)          self.OpenLayerProperties(layer)
740    
741      def OpenLayerProperties(self, layer, group = None):      def OpenLayerProperties(self, layer, group = None):
742          name = "layer_properties" + str(id(layer))          """
743          dialog = self.get_open_dialog(name)          Open or raise the properties dialog.
744    
745          if dialog is None:          This method opens or raises the properties dialog for the
746              dialog = Classifier(self, name, self.Map(), layer, group)          currently selected layer if one is defined for this layer
747              self.add_dialog(name, dialog)          type.
748              dialog.Show()          """
749          dialog.Raise()          dialog_class = layer_properties_dialogs.get(layer)
750    
751            if dialog_class is not None:
752                name = "layer_properties" + str(id(layer))
753                self.OpenOrRaiseDialog(name, dialog_class, layer, group = group)
754    
755      def LayerJoinTable(self):      def LayerJoinTable(self):
756          layer = self.canvas.SelectedLayer()          layer = self.canvas.SelectedLayer()
# Line 706  class MainWindow(DockFrame): Line 791  class MainWindow(DockFrame):
791          return dialog is not None and dialog.IsShown()          return dialog is not None and dialog.IsShown()
792    
793      def TableOpen(self):      def TableOpen(self):
794          dlg = wxFileDialog(self, _("Open Table"), ".", "",          dlg = wxFileDialog(self, _("Open Table"),
795                               self.application.Path("data"), "",
796                             _("DBF Files (*.dbf)") + "|*.dbf|" +                             _("DBF Files (*.dbf)") + "|*.dbf|" +
797                             #_("CSV Files (*.csv)") + "|*.csv|" +                             #_("CSV Files (*.csv)") + "|*.csv|" +
798                             _("All Files (*.*)") + "|*.*",                             _("All Files (*.*)") + "|*.*",
# Line 722  class MainWindow(DockFrame): Line 808  class MainWindow(DockFrame):
808                                     _("Can't open the file '%s'.") % filename)                                     _("Can't open the file '%s'.") % filename)
809              else:              else:
810                  self.ShowTableView(table)                  self.ShowTableView(table)
811                    self.application.SetPath("data",filename)
812    
813      def TableClose(self):      def TableClose(self):
814          tables = self.application.session.UnreferencedTables()          tables = self.application.session.UnreferencedTables()
# Line 798  class MainWindow(DockFrame): Line 885  class MainWindow(DockFrame):
885    
886          # Second, let the user rename the layers          # Second, let the user rename the layers
887          for table in to_rename:          for table in to_rename:
888              dlg = wxTextEntryDialog(self, "Table Title: ", "Rename Table",              dlg = wxTextEntryDialog(self, _("Table Title:"), _("Rename Table"),
889                                      table.Title())                                      table.Title())
890              try:              try:
891                  if dlg.ShowModal() == wxID_OK:                  if dlg.ShowModal() == wxID_OK:
# Line 847  class MainWindow(DockFrame): Line 934  class MainWindow(DockFrame):
934          self.canvas.Print()          self.canvas.Print()
935    
936      def RenameMap(self):      def RenameMap(self):
937          dlg = wxTextEntryDialog(self, "Map Title: ", "Rename Map",          dlg = wxTextEntryDialog(self, _("Map Title:"), _("Rename Map"),
938                                  self.Map().Title())                                  self.Map().Title())
939          if dlg.ShowModal() == wxID_OK:          if dlg.ShowModal() == wxID_OK:
940              title = dlg.GetValue()              title = dlg.GetValue()
941              if title != "":              if title != "":
942                  self.Map().SetTitle(title)                  self.Map().SetTitle(title)
                 self.__SetTitle(title)  
943    
944          dlg.Destroy()          dlg.Destroy()
945    
# Line 861  class MainWindow(DockFrame): Line 947  class MainWindow(DockFrame):
947          """Let the user rename the currently selected layer"""          """Let the user rename the currently selected layer"""
948          layer = self.current_layer()          layer = self.current_layer()
949          if layer is not None:          if layer is not None:
950              dlg = wxTextEntryDialog(self, "Layer Title: ", "Rename Layer",              dlg = wxTextEntryDialog(self, _("Layer Title:"), _("Rename Layer"),
951                                      layer.Title())                                      layer.Title())
952              try:              try:
953                  if dlg.ShowModal() == wxID_OK:                  if dlg.ShowModal() == wxID_OK:
# Line 895  class MainWindow(DockFrame): Line 981  class MainWindow(DockFrame):
981                  # FIXME: bring dialog to front?                  # FIXME: bring dialog to front?
982                  pass                  pass
983    
984      def __SetTitle(self, title):      def title_changed(self, map):
985          self.SetTitle("Thuban - " + title)          """Subscribed to the canvas' TITLE_CHANGED messages"""
986            self.update_title()
987    
988        def update_title(self):
989            """Update the window's title according to it's current state.
990    
991            In this default implementation the title is 'Thuban - ' followed
992            by the map's title or simply 'Thuban' if there is not map.
993            Derived classes should override this method to get different
994            titles.
995    
996            This method is called automatically by other methods when the
997            title may have to change. For the methods implemented in this
998            class this usually only means that a different map has been set
999            or the current map's title has changed.
1000            """
1001            map = self.Map()
1002            if map is not None:
1003                title = _("Thuban - %s") % (map.Title(),)
1004            else:
1005                title = _("Thuban")
1006            self.SetTitle(title)
1007    
1008    
1009  #  #
1010  # Define all the commands available in the main window  # Define all the commands available in the main window
# Line 938  def _has_selected_layer(context): Line 1046  def _has_selected_layer(context):
1046      """Return true if a layer is selected in the context"""      """Return true if a layer is selected in the context"""
1047      return context.mainwindow.has_selected_layer()      return context.mainwindow.has_selected_layer()
1048    
1049    def _has_selected_layer_visible(context):
1050        """Return true if a layer is selected in the context which is
1051        visible."""
1052        if context.mainwindow.has_selected_layer():
1053            layer = context.mainwindow.current_layer()
1054            if layer.Visible(): return True
1055        return False
1056    
1057    def _has_selected_shape_layer(context):
1058        """Return true if a shape layer is selected in the context"""
1059        return context.mainwindow.has_selected_shape_layer()
1060    
1061  def _has_selected_shapes(context):  def _has_selected_shapes(context):
1062      """Return true if a layer is selected in the context"""      """Return true if a layer is selected in the context"""
1063      return context.mainwindow.has_selected_shapes()      return context.mainwindow.has_selected_shapes()
# Line 957  def _has_visible_map(context): Line 1077  def _has_visible_map(context):
1077      if map is not None:      if map is not None:
1078          for layer in map.Layers():          for layer in map.Layers():
1079              if layer.Visible():              if layer.Visible():
1080                  return 1                  return True
1081      return 0      return False
1082    
1083  def _has_legend_shown(context):  def _has_legend_shown(context):
1084      """Return true if the legend window is shown"""      """Return true if the legend window is shown"""
# Line 972  def _has_dbconnections(context): Line 1092  def _has_dbconnections(context):
1092      """Return whether the the session has database connections"""      """Return whether the the session has database connections"""
1093      return context.session.HasDBConnections()      return context.session.HasDBConnections()
1094    
1095    def _has_postgis_support(context):
1096        return has_postgis_support()
1097    
1098    
1099  # File menu  # File menu
1100  _method_command("new_session", _("&New Session"), "NewSession",  _method_command("new_session", _("&New Session"), "NewSession",
1101                  helptext = _("Start a new session"))                  helptext = _("Start a new session"))
# Line 988  _method_command("toggle_legend", _("Lege Line 1112  _method_command("toggle_legend", _("Lege
1112                  checked = _has_legend_shown,                  checked = _has_legend_shown,
1113                  helptext = _("Toggle Legend on/off"))                  helptext = _("Toggle Legend on/off"))
1114  _method_command("database_management", _("&Database Connections..."),  _method_command("database_management", _("&Database Connections..."),
1115                  "DatabaseManagement")                  "DatabaseManagement",
1116                    sensitive = _has_postgis_support)
1117  _method_command("exit", _("E&xit"), "Exit",  _method_command("exit", _("E&xit"), "Exit",
1118                  helptext = _("Finish working with Thuban"))                  helptext = _("Finish working with Thuban"))
1119    
# Line 1069  _method_command("layer_hide", _("&Hide") Line 1194  _method_command("layer_hide", _("&Hide")
1194                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer)
1195  _method_command("layer_show_table", _("Show Ta&ble"), "LayerShowTable",  _method_command("layer_show_table", _("Show Ta&ble"), "LayerShowTable",
1196                  helptext = _("Show the selected layer's table"),                  helptext = _("Show the selected layer's table"),
1197                  sensitive = _has_selected_layer)                  sensitive = _has_selected_shape_layer)
1198  _method_command("layer_properties", _("&Properties..."), "LayerEditProperties",  _method_command("layer_properties", _("&Properties..."), "LayerEditProperties",
1199                  sensitive = _has_selected_layer,                  sensitive = _has_selected_layer,
1200                  helptext = _("Edit the properties of the selected layer"))                  helptext = _("Edit the properties of the selected layer"))
1201  _method_command("layer_jointable", _("&Join Table..."), "LayerJoinTable",  _method_command("layer_jointable", _("&Join Table..."), "LayerJoinTable",
1202                  sensitive = _has_selected_layer,                  sensitive = _has_selected_shape_layer,
1203                  helptext = _("Join and attach a table to the selected layer"))                  helptext = _("Join and attach a table to the selected layer"))
1204    
1205    # further layer methods:
1206    _method_command("layer_to_top", _("&Top"), "LayerToTop",
1207                    helptext = _("Put selected layer to the top"),
1208                    sensitive = _has_selected_layer)
1209    _method_command("layer_to_bottom", _("&Bottom"), "LayerToBottom",
1210                    helptext = _("Put selected layer to the bottom"),
1211                    sensitive = _has_selected_layer)
1212    _method_command("layer_visibility", _("&Visible"), "ToggleLayerVisibility",
1213                    checked = _has_selected_layer_visible,
1214                    helptext = _("Toggle visibility of selected layer"),
1215                    sensitive = _has_selected_layer)
1216    
1217  def _can_unjoin(context):  def _can_unjoin(context):
1218      """Return whether the Layer/Unjoin command can be executed.      """Return whether the Layer/Unjoin command can be executed.
1219    

Legend:
Removed from v.1622  
changed lines
  Added in v.2529

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26