/[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 1080 by bh, Wed May 28 09:12:21 2003 UTC revision 1644 by bh, Mon Aug 25 12:44:55 2003 UTC
# Line 12  The main window Line 12  The main window
12  """  """
13    
14  __version__ = "$Revision$"  __version__ = "$Revision$"
15    # $Source$
16  __ThubanVersion__ = "0.2" #"$THUBAN_0_2$"  # $Id$
 #__BuildDate__ = "$Date$"  
17    
18  import os  import os
19    import copy
20    
21  from wxPython.wx import *  from wxPython.wx import *
22  from wxPython.wx import __version__ as wxPython_version  from wxPython.wx import __version__ as wxPython_version
23    
 from wxPython.lib.dialogs import wxMultipleChoiceDialog  
   
24  import Thuban  import Thuban
25  import Thuban.version  import Thuban.version
26    
27  from Thuban import _  from Thuban import _
28  from Thuban.Model.session import create_empty_session  from Thuban.Model.session import create_empty_session
29  from Thuban.Model.layer import Layer, RasterLayer  from Thuban.Model.layer import Layer, RasterLayer
30    from Thuban.Model.postgisdb import PostGISShapeStore, has_postgis_support
31    # XXX: replace this by
32    # from wxPython.lib.dialogs import wxMultipleChoiceDialog
33    # when Thuban does not support wxPython 2.4.0 any more.
34    from Thuban.UI.multiplechoicedialog import wxMultipleChoiceDialog
35    
36  import view  import view
37  import tree  import tree
# Line 39  from menu import Menu Line 42  from menu import Menu
42    
43  from context import Context  from context import Context
44  from command import registry, Command, ToolCommand  from command import registry, Command, ToolCommand
45  from messages import LAYER_SELECTED, SHAPES_SELECTED, VIEW_POSITION  from messages import LAYER_SELECTED, SHAPES_SELECTED, VIEW_POSITION, \
46         MAP_REPLACED
47    from about import About
48    
49  from Thuban.UI.dock import DockFrame  from Thuban.UI.dock import DockFrame
50  from Thuban.UI.join import JoinDialog  from Thuban.UI.join import JoinDialog
51    from Thuban.UI.dbdialog import DBFrame, ChooseDBTableDialog
52  import resource  import resource
53    import Thuban.Model.resource
54    
55  import projdialog  import projdialog
56    
57    
   
58  class MainWindow(DockFrame):  class MainWindow(DockFrame):
59    
60      # Some messages that can be subscribed/unsubscribed directly through      # Some messages that can be subscribed/unsubscribed directly through
# Line 58  class MainWindow(DockFrame): Line 63  class MainWindow(DockFrame):
63      # actually come from. This delegation is implemented in the      # actually come from. This delegation is implemented in the
64      # Subscribe and unsubscribed methods      # Subscribe and unsubscribed methods
65      delegated_messages = {LAYER_SELECTED: "canvas",      delegated_messages = {LAYER_SELECTED: "canvas",
66                            SHAPES_SELECTED: "canvas"}                            SHAPES_SELECTED: "canvas",
67                              MAP_REPLACED: "canvas"}
68    
69      # Methods delegated to some instance variables. The delegation is      # Methods delegated to some instance variables. The delegation is
70      # implemented in the __getattr__ method.      # implemented in the __getattr__ method.
# Line 104  class MainWindow(DockFrame): Line 110  class MainWindow(DockFrame):
110    
111          self.init_dialogs()          self.init_dialogs()
112    
113            self.ShowLegend()
114    
115          EVT_CLOSE(self, self.OnClose)          EVT_CLOSE(self, self.OnClose)
116    
117      def Subscribe(self, channel, *args):      def Subscribe(self, channel, *args):
# Line 357  class MainWindow(DockFrame): Line 365  class MainWindow(DockFrame):
365              result = wxID_NO              result = wxID_NO
366          return result          return result
367    
     def prepare_new_session(self):  
         for d in self.dialogs.values():  
             if not isinstance(d, tree.SessionTreeView):  
                 d.Close()  
   
368      def NewSession(self):      def NewSession(self):
369          if self.save_modified_session() != wxID_CANCEL:          if self.save_modified_session() != wxID_CANCEL:
             self.prepare_new_session()  
370              self.application.SetSession(create_empty_session())              self.application.SetSession(create_empty_session())
371    
372      def OpenSession(self):      def OpenSession(self):
# Line 373  class MainWindow(DockFrame): Line 375  class MainWindow(DockFrame):
375                                 "Thuban Session File (*.thuban)|*.thuban",                                 "Thuban Session File (*.thuban)|*.thuban",
376                                 wxOPEN)                                 wxOPEN)
377              if dlg.ShowModal() == wxID_OK:              if dlg.ShowModal() == wxID_OK:
                 self.prepare_new_session()  
378                  self.application.OpenSession(dlg.GetPath())                  self.application.OpenSession(dlg.GetPath())
379              dlg.Destroy()              dlg.Destroy()
380    
# Line 439  class MainWindow(DockFrame): Line 440  class MainWindow(DockFrame):
440          return self.get_open_dialog("session_tree") is not None          return self.get_open_dialog("session_tree") is not None
441    
442      def About(self):      def About(self):
443          self.RunMessageBox(_("About"),          dlg = About(self)
444                             _("Thuban %s\n"          dlg.ShowModal()
445                              #"Build Date: %s\n"          dlg.Destroy()
446                              "using:\n"  
447                              "  %s\n"      def DatabaseManagement(self):
448                              "  %s\n\n"          name = "dbmanagement"
449                              "Thuban is a program for\n"          dialog = self.get_open_dialog(name)
450                              "exploring geographic data.\n"          if dialog is None:
451                              "Copyright (C) 2001-2003 Intevation GmbH.\n"              map = self.canvas.Map()
452                              "Thuban is licensed under the GNU GPL"              dialog = DBFrame(self, name, self.application.Session())
453                              % (Thuban.version.longversion,              self.add_dialog(name, dialog)
454                                 "wxPython %s" % wxPython_version,              dialog.Show()
455                                 "Python %d.%d.%d" % sys.version_info[:3]          dialog.Raise()
                               )),  
 #                           % __ThubanVersion__), #__BuildDate__)),  
                            wxOK | wxICON_INFORMATION)  
456    
457      def AddLayer(self):      def AddLayer(self):
458          dlg = wxFileDialog(self, _("Select a data file"), ".", "", "*.*",          dlg = wxFileDialog(self, _("Select one or more data files"), ".", "",
459                             wxOPEN)                             _("Shapefiles (*.shp)") + "|*.shp|" +
460                               _("All Files (*.*)") + "|*.*",
461                               wxOPEN | wxMULTIPLE)
462          if dlg.ShowModal() == wxID_OK:          if dlg.ShowModal() == wxID_OK:
463              filename = dlg.GetPath()              filenames = dlg.GetPaths()
464              title = os.path.splitext(os.path.basename(filename))[0]              for filename in filenames:
465              map = self.canvas.Map()                  title = os.path.splitext(os.path.basename(filename))[0]
466              has_layers = map.HasLayers()                  map = self.canvas.Map()
467              try:                  has_layers = map.HasLayers()
468                  store = self.application.Session().OpenShapefile(filename)                  try:
469              except IOError:                      store = self.application.Session().OpenShapefile(filename)
470                  # the layer couldn't be opened                  except IOError:
471                  self.RunMessageBox(_("Add Layer"),                      # the layer couldn't be opened
472                                     _("Can't open the file '%s'.") % filename)                      self.RunMessageBox(_("Add Layer"),
473              else:                                         _("Can't open the file '%s'.")%filename)
474                  layer = Layer(title, store)                  else:
475                  map.AddLayer(layer)                      layer = Layer(title, store)
476                  if not has_layers:                      map.AddLayer(layer)
477                      # if we're adding a layer to an empty map, fit the                      if not has_layers:
478                      # new map to the window                          # if we're adding a layer to an empty map, fit the
479                      self.canvas.FitMapToWindow()                          # new map to the window
480                            self.canvas.FitMapToWindow()
481          dlg.Destroy()          dlg.Destroy()
482    
483      def AddRasterLayer(self):      def AddRasterLayer(self):
# Line 501  class MainWindow(DockFrame): Line 502  class MainWindow(DockFrame):
502                      self.canvas.FitMapToWindow()                      self.canvas.FitMapToWindow()
503          dlg.Destroy()          dlg.Destroy()
504    
505        def AddDBLayer(self):
506            """Add a layer read from a database"""
507            session = self.application.Session()
508            dlg = ChooseDBTableDialog(self.application.Session(), self,-1, "")
509    
510            if dlg.ShowModal() == wxID_OK:
511                dbconn, dbtable = dlg.GetTable()
512                try:
513                    title = str(dbtable)
514    
515                    # Chose the correct Interface for the database type
516                    store = PostGISShapeStore(dbconn, dbtable)
517                    session.AddShapeStore(store)
518                    layer = Layer(title, store)
519                except:
520                    # Some error occured while initializing the layer
521                    self.RunMessageBox(_("Add Layer from database"),
522                                       _("Can't open the database table '%s'")
523                                       % dbtable)
524    
525                map = self.canvas.Map()
526    
527                has_layers = map.HasLayers()
528                map.AddLayer(layer)
529                if not has_layers:
530                    self.canvas.FitMapToWindow()
531    
532            dlg.Destroy()
533    
534      def RemoveLayer(self):      def RemoveLayer(self):
535          layer = self.current_layer()          layer = self.current_layer()
536          if layer is not None:          if layer is not None:
# Line 548  class MainWindow(DockFrame): Line 578  class MainWindow(DockFrame):
578          layer = self.current_layer()          layer = self.current_layer()
579          if layer is not None:          if layer is not None:
580              layer.SetVisible(0)              layer.SetVisible(0)
581            
582      def ShowLayer(self):      def ShowLayer(self):
583          layer = self.current_layer()          layer = self.current_layer()
584          if layer is not None:          if layer is not None:
585              layer.SetVisible(1)              layer.SetVisible(1)
586    
587        def DuplicateLayer(self):
588            """Ceate a new layer above the selected layer with the same shapestore
589            """
590            layer = self.current_layer()
591            if layer is not None and hasattr(layer, "ShapeStore"):
592                new_layer = Layer(_("Copy of `%s'") % layer.Title(),
593                                  layer.ShapeStore(),
594                                  projection = layer.GetProjection())
595                new_classification = copy.deepcopy(layer.GetClassification())
596                new_layer.SetClassification(new_classification)
597                self.Map().AddLayer(new_layer)
598    
599        def CanDuplicateLayer(self):
600            """Return whether the DuplicateLayer method can create a duplicate"""
601            layer = self.current_layer()
602            return layer is not None and hasattr(layer, "ShapeStore")
603    
604      def LayerShowTable(self):      def LayerShowTable(self):
605          layer = self.current_layer()          layer = self.current_layer()
606          if layer is not None:          if layer is not None:
607              table = layer.table              table = layer.ShapeStore().Table()
608              name = "table_view" + str(id(table))              name = "table_view" + str(id(table))
609              dialog = self.get_open_dialog(name)              dialog = self.get_open_dialog(name)
610              if dialog is None:              if dialog is None:
# Line 614  class MainWindow(DockFrame): Line 661  class MainWindow(DockFrame):
661          dialog = self.get_open_dialog(name)          dialog = self.get_open_dialog(name)
662    
663          if dialog is None:          if dialog is None:
664              dialog = Classifier(self, name, layer, group)              dialog = Classifier(self, name, self.Map(), layer, group)
665              self.add_dialog(name, dialog)              self.add_dialog(name, dialog)
666              dialog.Show()              dialog.Show()
667          dialog.Raise()          dialog.Raise()
# Line 678  class MainWindow(DockFrame): Line 725  class MainWindow(DockFrame):
725      def TableClose(self):      def TableClose(self):
726          tables = self.application.session.UnreferencedTables()          tables = self.application.session.UnreferencedTables()
727    
728            lst = [(t.Title(), t) for t in tables]
729            lst.sort()
730            titles = [i[0] for i in lst]
731          dlg = wxMultipleChoiceDialog(self, _("Pick the tables to close:"),          dlg = wxMultipleChoiceDialog(self, _("Pick the tables to close:"),
732                                       _("Close Table"),                                       _("Close Table"), titles,
733                                       [t.Title() for t in tables],                                       size = (400, 300),
734                                       size = (400, 300), style=wxRESIZE_BORDER)                                       style = wxDEFAULT_DIALOG_STYLE |
735                                                 wxRESIZE_BORDER)
736          if dlg.ShowModal() == wxID_OK:          if dlg.ShowModal() == wxID_OK:
737              for i in dlg.GetValue():              for i in dlg.GetValue():
738                  self.application.session.RemoveTable(tables[i])                  self.application.session.RemoveTable(lst[i][1])
739    
740    
741      def TableShow(self):      def TableShow(self):
# Line 695  class MainWindow(DockFrame): Line 746  class MainWindow(DockFrame):
746          """          """
747          tables = self.application.session.Tables()          tables = self.application.session.Tables()
748    
749            lst = [(t.Title(), t) for t in tables]
750            lst.sort()
751            titles = [i[0] for i in lst]
752          dlg = wxMultipleChoiceDialog(self, _("Pick the table to show:"),          dlg = wxMultipleChoiceDialog(self, _("Pick the table to show:"),
753                                       _("Show Table"),                                       _("Show Table"), titles,
                                      [t.Title() for t in tables],  
754                                       size = (400,300),                                       size = (400,300),
755                                       style = wxDEFAULT_DIALOG_STYLE |                                       style = wxDEFAULT_DIALOG_STYLE |
756                                               wxRESIZE_BORDER)                                               wxRESIZE_BORDER)
# Line 705  class MainWindow(DockFrame): Line 758  class MainWindow(DockFrame):
758              for i in dlg.GetValue():              for i in dlg.GetValue():
759                  # XXX: if the table belongs to a layer, open a                  # XXX: if the table belongs to a layer, open a
760                  # LayerTableFrame instead of QueryTableFrame                  # LayerTableFrame instead of QueryTableFrame
761                  self.ShowTableView(tables[i])                  self.ShowTableView(lst[i][1])
762    
763      def TableJoin(self):      def TableJoin(self):
764          dlg = JoinDialog(self, _("Join Tables"), self.application.session)          dlg = JoinDialog(self, _("Join Tables"), self.application.session)
# Line 721  class MainWindow(DockFrame): Line 774  class MainWindow(DockFrame):
774                                                 table)                                                 table)
775              self.add_dialog(name, dialog)              self.add_dialog(name, dialog)
776              dialog.Show(True)              dialog.Show(True)
777          # FIXME: else bring dialog to front          dialog.Raise()
778    
779        def TableRename(self):
780            """Let the user rename a table"""
781    
782            # First, let the user select a table
783            tables = self.application.session.Tables()
784            lst = [(t.Title(), t) for t in tables]
785            lst.sort()
786            titles = [i[0] for i in lst]
787            dlg = wxMultipleChoiceDialog(self, _("Pick the table to rename:"),
788                                         _("Rename Table"), titles,
789                                         size = (400,300),
790                                         style = wxDEFAULT_DIALOG_STYLE |
791                                                 wxRESIZE_BORDER)
792            if (dlg.ShowModal() == wxID_OK):
793                to_rename = [lst[i][1] for i in dlg.GetValue()]
794                dlg.Destroy()
795            else:
796                to_rename = []
797    
798            # Second, let the user rename the layers
799            for table in to_rename:
800                dlg = wxTextEntryDialog(self, "Table Title: ", "Rename Table",
801                                        table.Title())
802                try:
803                    if dlg.ShowModal() == wxID_OK:
804                        title = dlg.GetValue()
805                        if title != "":
806                            table.SetTitle(title)
807    
808                            # Make sure the session is marked as modified.
809                            # FIXME: This should be handled automatically,
810                            # but that requires more changes to the tables
811                            # than I have time for currently.
812                            self.application.session.changed()
813                finally:
814                    dlg.Destroy()
815    
816    
817      def ZoomInTool(self):      def ZoomInTool(self):
818          self.canvas.ZoomInTool()          self.canvas.ZoomInTool()
# Line 765  class MainWindow(DockFrame): Line 856  class MainWindow(DockFrame):
856    
857          dlg.Destroy()          dlg.Destroy()
858    
859        def RenameLayer(self):
860            """Let the user rename the currently selected layer"""
861            layer = self.current_layer()
862            if layer is not None:
863                dlg = wxTextEntryDialog(self, "Layer Title: ", "Rename Layer",
864                                        layer.Title())
865                try:
866                    if dlg.ShowModal() == wxID_OK:
867                        title = dlg.GetValue()
868                        if title != "":
869                            layer.SetTitle(title)
870                finally:
871                    dlg.Destroy()
872    
873      def identify_view_on_demand(self, layer, shapes):      def identify_view_on_demand(self, layer, shapes):
874          """Subscribed to the canvas' SHAPES_SELECTED message          """Subscribed to the canvas' SHAPES_SELECTED message
875    
# Line 858  def _has_legend_shown(context): Line 963  def _has_legend_shown(context):
963      """Return true if the legend window is shown"""      """Return true if the legend window is shown"""
964      return context.mainwindow.LegendShown()      return context.mainwindow.LegendShown()
965    
966    def _has_gdal_support(context):
967        """Return True if the GDAL is available"""
968        return Thuban.Model.resource.has_gdal_support()
969    
970    def _has_dbconnections(context):
971        """Return whether the the session has database connections"""
972        return context.session.HasDBConnections()
973    
974    def _has_postgis_support(context):
975        return has_postgis_support()
976    
977    
978  # File menu  # File menu
979  _method_command("new_session", _("&New Session"), "NewSession")  _method_command("new_session", _("&New Session"), "NewSession",
980  _method_command("open_session", _("&Open Session..."), "OpenSession")                  helptext = _("Start a new session"))
981  _method_command("save_session", _("&Save Session"), "SaveSession")  _method_command("open_session", _("&Open Session..."), "OpenSession",
982  _method_command("save_session_as", _("Save Session &As..."), "SaveSessionAs")                  helptext = _("Open a session file"))
983    _method_command("save_session", _("&Save Session"), "SaveSession",
984                    helptext =_("Save this session to the file it was opened from"))
985    _method_command("save_session_as", _("Save Session &As..."), "SaveSessionAs",
986                    helptext = _("Save this session to a new file"))
987  _method_command("toggle_session_tree", _("Session &Tree"), "ToggleSessionTree",  _method_command("toggle_session_tree", _("Session &Tree"), "ToggleSessionTree",
988                  checked = _has_tree_window_shown)                  checked = _has_tree_window_shown,
989                    helptext = _("Toggle on/off the session tree analysis window"))
990  _method_command("toggle_legend", _("Legend"), "ToggleLegend",  _method_command("toggle_legend", _("Legend"), "ToggleLegend",
991                  checked = _has_legend_shown)                  checked = _has_legend_shown,
992  _method_command("exit", _("E&xit"), "Exit")                  helptext = _("Toggle Legend on/off"))
993    _method_command("database_management", _("&Database Connections..."),
994                    "DatabaseManagement",
995                    sensitive = _has_postgis_support)
996    _method_command("exit", _("E&xit"), "Exit",
997                    helptext = _("Finish working with Thuban"))
998    
999  # Help menu  # Help menu
1000  _method_command("help_about", _("&About..."), "About")  _method_command("help_about", _("&About..."), "About",
1001                    helptext = _("Info about Thuban authors, version and modules"))
1002    
1003    
1004  # Map menu  # Map menu
1005  _method_command("map_projection", _("Pro&jection..."), "MapProjection")  _method_command("map_projection", _("Pro&jection..."), "MapProjection",
1006                    helptext = _("Set or change the map projection"))
1007    
1008  _tool_command("map_zoom_in_tool", _("&Zoom in"), "ZoomInTool", "ZoomInTool",  _tool_command("map_zoom_in_tool", _("&Zoom in"), "ZoomInTool", "ZoomInTool",
1009                helptext = _("Switch to map-mode 'zoom-in'"), icon = "zoom_in",                helptext = _("Switch to map-mode 'zoom-in'"), icon = "zoom_in",
# Line 894  _tool_command("map_label_tool", _("&Labe Line 1022  _tool_command("map_label_tool", _("&Labe
1022                helptext = _("Add/Remove labels"), icon = "label",                helptext = _("Add/Remove labels"), icon = "label",
1023                sensitive = _has_visible_map)                sensitive = _has_visible_map)
1024  _method_command("map_full_extent", _("&Full extent"), "FullExtent",  _method_command("map_full_extent", _("&Full extent"), "FullExtent",
1025                 helptext = _("Full Extent"), icon = "fullextent",                 helptext = _("Zoom to the full map extent"), icon = "fullextent",
1026                sensitive = _has_visible_map)                sensitive = _has_visible_map)
1027  _method_command("layer_full_extent", _("&Full layer extent"), "FullLayerExtent",  _method_command("layer_full_extent", _("&Full layer extent"), "FullLayerExtent",
1028                 helptext = _("Full Layer Extent"), icon = "fulllayerextent",                  helptext = _("Zoom to the full layer extent"),
1029                sensitive = _has_selected_layer)                  icon = "fulllayerextent", sensitive = _has_selected_layer)
1030  _method_command("selected_full_extent", _("&Full selection extent"), "FullSelectionExtent",  _method_command("selected_full_extent", _("&Full selection extent"),
1031                 helptext = _("Full Selection Extent"), icon = "fullselextent",                  "FullSelectionExtent",
1032                sensitive = _has_selected_shapes)                  helptext = _("Zoom to the full selection extent"),
1033                    icon = "fullselextent", sensitive = _has_selected_shapes)
1034  _method_command("map_export", _("E&xport"), "ExportMap",  _method_command("map_export", _("E&xport"), "ExportMap",
1035                      helptext = _("Export the map to file"))                  helptext = _("Export the map to file"))
1036  _method_command("map_print", _("Prin&t"), "PrintMap",  _method_command("map_print", _("Prin&t"), "PrintMap",
1037                  helptext = _("Print the map"))                  helptext = _("Print the map"))
1038  _method_command("map_rename", _("&Rename..."), "RenameMap",  _method_command("map_rename", _("&Rename..."), "RenameMap",
1039                  helptext = _("Rename the map"))                  helptext = _("Rename the map"))
1040  _method_command("layer_add", _("&Add Layer..."), "AddLayer",  _method_command("layer_add", _("&Add Layer..."), "AddLayer",
1041                  helptext = _("Add a new layer to active map"))                  helptext = _("Add a new layer to the map"))
1042  _method_command("rasterlayer_add", _("&Add Image Layer..."), "AddRasterLayer",  _method_command("rasterlayer_add", _("&Add Image Layer..."), "AddRasterLayer",
1043                  helptext = _("Add a new image layer to active map"))                  helptext = _("Add a new image layer to the map"),
1044                    sensitive = _has_gdal_support)
1045    _method_command("layer_add_db", _("Add &Database Layer..."), "AddDBLayer",
1046                    helptext = _("Add a new database layer to active map"),
1047                    sensitive = _has_dbconnections)
1048  _method_command("layer_remove", _("&Remove Layer"), "RemoveLayer",  _method_command("layer_remove", _("&Remove Layer"), "RemoveLayer",
1049                  helptext = _("Remove selected layer(s)"),                  helptext = _("Remove selected layer"),
1050                  sensitive = _can_remove_layer)                  sensitive = _can_remove_layer)
1051    
1052  # Layer menu  # Layer menu
1053  _method_command("layer_projection", _("Pro&jection..."), "LayerProjection",  _method_command("layer_projection", _("Pro&jection..."), "LayerProjection",
1054                    sensitive = _has_selected_layer,
1055                    helptext = _("Specify projection for selected layer"))
1056    _method_command("layer_duplicate", _("&Duplicate"), "DuplicateLayer",
1057                    helptext = _("Duplicate selected layer"),
1058              sensitive = lambda context: context.mainwindow.CanDuplicateLayer())
1059    _method_command("layer_rename", _("Re&name ..."), "RenameLayer",
1060                    helptext = _("Rename selected layer"),
1061                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer)
1062  _method_command("layer_raise", _("&Raise"), "RaiseLayer",  _method_command("layer_raise", _("&Raise"), "RaiseLayer",
1063                  helptext = _("Raise selected layer(s)"),                  helptext = _("Raise selected layer"),
1064                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer)
1065  _method_command("layer_lower", _("&Lower"), "LowerLayer",  _method_command("layer_lower", _("&Lower"), "LowerLayer",
1066                  helptext = _("Lower selected layer(s)"),                  helptext = _("Lower selected layer"),
1067                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer)
1068  _method_command("layer_show", _("&Show"), "ShowLayer",  _method_command("layer_show", _("&Show"), "ShowLayer",
1069                  helptext = _("Make selected layer(s) visible"),                  helptext = _("Make selected layer visible"),
1070                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer)
1071  _method_command("layer_hide", _("&Hide"), "HideLayer",  _method_command("layer_hide", _("&Hide"), "HideLayer",
1072                  helptext = _("Make selected layer(s) unvisible"),                  helptext = _("Make selected layer unvisible"),
1073                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer)
1074  _method_command("layer_show_table", _("Show Ta&ble"), "LayerShowTable",  _method_command("layer_show_table", _("Show Ta&ble"), "LayerShowTable",
1075                  helptext = _("Show the selected layer's table"),                  helptext = _("Show the selected layer's table"),
1076                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer)
1077  _method_command("layer_properties", _("&Properties..."), "LayerEditProperties",  _method_command("layer_properties", _("&Properties..."), "LayerEditProperties",
1078                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer,
1079                    helptext = _("Edit the properties of the selected layer"))
1080  _method_command("layer_jointable", _("&Join Table..."), "LayerJoinTable",  _method_command("layer_jointable", _("&Join Table..."), "LayerJoinTable",
1081                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer,
1082                    helptext = _("Join and attach a table to the selected layer"))
1083    
1084  def _can_unjoin(context):  def _can_unjoin(context):
1085      """Return whether the Layer/Unjoin command can be executed.      """Return whether the Layer/Unjoin command can be executed.
# Line 954  def _can_unjoin(context): Line 1096  def _can_unjoin(context):
1096      else:      else:
1097          return 0          return 0
1098  _method_command("layer_unjointable", _("&Unjoin Table..."), "LayerUnjoinTable",  _method_command("layer_unjointable", _("&Unjoin Table..."), "LayerUnjoinTable",
1099                  sensitive = _can_unjoin)                  sensitive = _can_unjoin,
1100                    helptext = _("Undo the last join operation"))
1101    
1102    
1103    def _has_tables(context):
1104        return bool(context.session.Tables())
1105    
1106  # Table menu  # Table menu
1107  _method_command("table_open", _("&Open..."), "TableOpen")  _method_command("table_open", _("&Open..."), "TableOpen",
1108  _method_command("table_close", _("&Close"), "TableClose",                  helptext = _("Open a DBF-table from a file"))
1109         sensitive = lambda context: bool(context.session.UnreferencedTables()))  _method_command("table_close", _("&Close..."), "TableClose",
1110  _method_command("table_show", _("&Show"), "TableShow")         sensitive = lambda context: bool(context.session.UnreferencedTables()),
1111  _method_command("table_join", _("&Join..."), "TableJoin")                  helptext = _("Close one or more tables from a list"))
1112    _method_command("table_rename", _("&Rename..."), "TableRename",
1113                    sensitive = _has_tables,
1114                    helptext = _("Rename one or more tables"))
1115    _method_command("table_show", _("&Show..."), "TableShow",
1116                    sensitive = _has_tables,
1117                    helptext = _("Show one or more tables in a dialog"))
1118    _method_command("table_join", _("&Join..."), "TableJoin",
1119                    sensitive = _has_tables,
1120                    helptext = _("Join two tables creating a new one"))
1121    
1122  #  Export only under Windows ...  #  Export only under Windows ...
1123  map_menu = ["layer_add", "rasterlayer_add", "layer_remove", "map_rename",  map_menu = ["layer_add", "layer_add_db", "rasterlayer_add", "layer_remove",
1124                          None,                          None,
1125                            "map_rename",
1126                          "map_projection",                          "map_projection",
1127                          None,                          None,
1128                          "map_zoom_in_tool", "map_zoom_out_tool",                          "map_zoom_in_tool", "map_zoom_out_tool",
1129                          "map_pan_tool",                          "map_pan_tool",
1130                          "map_full_extent",                          "map_full_extent",
1131                          "layer_full_extent",                          "layer_full_extent",
1132                          "selected_full_extent",                          "selected_full_extent",
1133                          None,                          None,
# Line 987  main_menu = Menu("<main>", "<main>", Line 1144  main_menu = Menu("<main>", "<main>",
1144                   [Menu("file", _("&File"),                   [Menu("file", _("&File"),
1145                         ["new_session", "open_session", None,                         ["new_session", "open_session", None,
1146                          "save_session", "save_session_as", None,                          "save_session", "save_session_as", None,
1147                            "database_management", None,
1148                          "toggle_session_tree", None,                          "toggle_session_tree", None,
1149                          "exit"]),                          "exit"]),
1150                    Menu("map", _("&Map"), map_menu),                    Menu("map", _("&Map"), map_menu),
1151                    Menu("layer", _("&Layer"),                    Menu("layer", _("&Layer"),
1152                          ["layer_raise", "layer_lower",                         ["layer_rename", "layer_duplicate",
1153                            None,
1154                            "layer_raise", "layer_lower",
1155                          None,                          None,
1156                          "layer_show", "layer_hide",                          "layer_show", "layer_hide",
1157                          None,                          None,
# Line 1003  main_menu = Menu("<main>", "<main>", Line 1163  main_menu = Menu("<main>", "<main>",
1163                          None,                          None,
1164                          "layer_properties"]),                          "layer_properties"]),
1165                    Menu("table", _("&Table"),                    Menu("table", _("&Table"),
1166                         ["table_open", "table_close",                         ["table_open", "table_close", "table_rename",
1167                         None,                         None,
1168                         "table_show",                         "table_show",
1169                         None,                         None,
# Line 1020  main_toolbar = Menu("<toolbar>", "<toolb Line 1180  main_toolbar = Menu("<toolbar>", "<toolb
1180                       "selected_full_extent",                       "selected_full_extent",
1181                       None,                       None,
1182                       "map_identify_tool", "map_label_tool"])                       "map_identify_tool", "map_label_tool"])
1183    

Legend:
Removed from v.1080  
changed lines
  Added in v.1644

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26