Gnumed.timelinelib.wxgui.dialogs.export.view

Package Gnumed :: Package timelinelib :: Package wxgui :: Package dialogs :: Package export :: Module view |
[frames] | no frames]

# Source Code for Module Gnumed.timelinelib.wxgui.dialogs.export.view

      1  # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018  Rickard Lindberg, Roger Lindberg
      2  #
      3  # This file is part of Timeline.
      4  #
      5  # Timeline is free software: you can redistribute it and/or modify
      6  # it under the terms of the GNU General Public License as published by
      7  # the Free Software Foundation, either version 3 of the License, or
      8  # (at your option) any later version.
      9  #
     10  # Timeline is distributed in the hope that it will be useful,
     11  # but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  # GNU General Public License for more details.
     14  #
     15  # You should have received a copy of the GNU General Public License
     16  # along with Timeline.  If not, see <http://www.gnu.org/licenses/>.
     17
     18
     19  import wx
     20
     21  from timelinelib.wxgui.dialogs.export.controller import ExportDialogController
     22  from timelinelib.wxgui.dialogs.fieldselection.view import FieldSelectionDialog
     23  from timelinelib.wxgui.framework import Dialog
     24  from timelinelib.wxgui.utils import display_information_message
     25
     26
     27  IGNORE = _("Ignore")
     28  REPLACE = _("Replace")
     29  XML_REPLACE = _("XML-Replace")
     30  STRICT = _("Strict")
     31  STRATEGY = {IGNORE: "ignore", REPLACE: "replace", XML_REPLACE: "xmlcharrefreplace", STRICT: "strict"}
     32
     33
     34 -class ExportDialog(Dialog):
     35
     36      """
     37      <BoxSizerVertical>
     38          <StaticBoxSizerVertical label="$(type_description_text)" border="ALL">
     39              <ListBox style="LB_SINGLE" name="lb_target_types" />
     40          </StaticBoxSizerVertical>
     41
     42          <StaticBoxSizerVertical label="$(encoding_description_text)" border="LEFT|RIGHT|BOTTOM">
     43              <ListBox style="LB_SINGLE" name="lb_text_encodings" />
     44          </StaticBoxSizerVertical>
     45
     46          <StaticBoxSizerVertical label="$(encoding_error_strategy_text)" border="LEFT|RIGHT|BOTTOM">
     47              <ListBox
     48                  style="LB_SINGLE"
     49                  name="lb_error_strategies"
     50                  choices="$(lb_error_strategies_choices)" />
     51          </StaticBoxSizerVertical>
     52
     53          <StaticBoxSizerVertical label="$(export_items_description_text)" border="LEFT|RIGHT|BOTTOM">
     54              <FlexGridSizer rows="0" columns="2" border="ALL">
     55                  <CheckBox align="ALIGN_CENTER_VERTICAL" label="$(events_text)" name="cbx_events" />
     56                  <Button align="ALIGN_CENTER_VERTICAL" label="$(select_text)"
     57                      event_EVT_BUTTON="on_edit_event_fields" />
     58                  <CheckBox align="ALIGN_CENTER_VERTICAL" label="$(categories_text)" name="cbx_categories"/>
     59                  <Button align="ALIGN_CENTER_VERTICAL" label="$(select_text)"
     60                      event_EVT_BUTTON="on_edit_categories_fields" />
     61              </FlexGridSizer>
     62          </StaticBoxSizerVertical>
     63
     64          <DialogButtonsOkCancelSizer
     65              border="LEFT|RIGHT|BOTTOM"
     66              event_EVT_BUTTON__ID_OK="on_ok"
     67          />
     68      </BoxSizerVertical>
     69      """
     70
     71 -    def __init__(self, parent):
     72          Dialog.__init__(self, ExportDialogController, parent, {
     73              "type_description_text": _("Select Export File Type"),
     74              "encoding_description_text": _("Select Text Encoding"),
     75              "encoding_error_strategy_text": _("Select encoding error strategy"),
     76              "export_items_description_text": _("Select Items to export"),
     77              "events_text": _("Events"),
     78              "categories_text": _("Categories"),
     79              "select_text": _("Select Fields..."),
     80              "lb_error_strategies_choices": [IGNORE, REPLACE, XML_REPLACE, STRICT],
     81          }, title=_("Export Timeline"))
     82          self.controller.on_init()
     83          self.lb_error_strategies.Select(0)
     84
     85 -    def SetTargetTypes(self, types):
     86          self.lb_target_types.AppendItems(types)
     87          self.lb_target_types.Select(0)
     88
     89 -    def SetTextEncodings(self, encodings):
     90          self.lb_text_encodings.AppendItems(encodings)
     91          self.lb_text_encodings.Select(0)
     92
     93 -    def SetEvents(self, state):
     94          self.cbx_events.SetValue(state)
     95
     96 -    def SetCategories(self, state):
     97          self.cbx_categories.SetValue(state)
     98
     99 -    def EditEventFields(self):
    100          dlg = FieldSelectionDialog(self, _("Select Event Fields"), "Event",
    101                                     self.controller.get_event_fields())
    102          if dlg.ShowModal() == wx.ID_OK:
    103              self.controller.set_event_fields(dlg.GetSelectedFields())
    104          dlg.Destroy()
    105
    106 -    def EditCategoryFields(self):
    107          dlg = FieldSelectionDialog(self, _("Select Category Fields"), "Category",
    108                                     self.controller.get_category_fields())
    109          if dlg.ShowModal() == wx.ID_OK:
    110              self.controller.set_category_fields(dlg.GetSelectedFields())
    111          dlg.Destroy()
    112
    113 -    def GetExportEvents(self):
    114          return self.cbx_events.GetValue()
    115
    116 -    def GetExportCategories(self):
    117          return self.cbx_categories.GetValue()
    118
    119 -    def DisplayInformationMessage(self, label, text):
    120          display_information_message(label, text, self)
    121
    122 -    def Close(self):
    123          self.EndModal(wx.ID_OK)
    124
    125 -    def GetExportType(self):
    126          return self.lb_target_types.GetStringSelection()
    127
    128 -    def GetTextEncoding(self):
    129          return self.lb_text_encodings.GetStringSelection()
    130
    131 -    def GetTextEncodingErrorStrategy(self):
    132          return STRATEGY[self.lb_error_strategies.GetStringSelection()]
    133
    134 -    def GetEventFields(self):
    135          return self.controller.get_event_fields()
    136
    137 -    def GetCategoryFields(self):
    138          return self.controller.get_category_fields()
    139