def _flag_add(self, flagname):
     if not self._flag_isset(flagname):
         newFlag = Record.EMPTY("object_flag")
         newFlag.refobjectid = self._object.objectid
         newFlag.flagname = flagname.upper()
         newFlag.write()
         self.update()
 def __init__(self, field, parent, *args, **kwargs):
     mwx.StaticText.__init__(self,
                             parent,
                             style=wx.CB_READONLY,
                             name=field.path)
     BaseReferenceEditor.__init__(self,
                                  field,
                                  getrecords=False,
                                  **kwargs)
     from ProvCon.dbui.orm import Record
     self.referenced_record = Record.EMPTY(field.reference.name)
 def _param_set(self, paramname, paramval):
     if self._param_get(paramname):
         if paramval is None:
             self._param_del(paramname)
         else:
             oldParam = Record.ID(self._params_id[paramname.upper()])
             oldParam.content = paramval
             oldParam.write()
             self.update()
     elif paramval is not None:
         newParam = Record.EMPTY("object_parameter")
         newParam.refobjectid = self._object.objectid
         newParam.parametername = paramname.upper()
         newParam.content = paramval
         newParam.write()
         self.update()
    def __init__(self, field, parent, *args, **kwargs):
        from ProvCon.dbui.orm import Record
        BaseReferenceEditor.__init__(self,
                                     field,
                                     getrecords=False,
                                     *args,
                                     **kwargs)
        wx.CollapsiblePane.__init__(self,
                                    parent,
                                    style=wx.CP_DEFAULT_STYLE
                                    | wx.CP_NO_TLW_RESIZE)

        self._current = AttrDict()
        self._dialogs = AttrDict()

        self._current.city = Record.EMPTY("city")
        self._current.street = Record.EMPTY("street")
        self._current.building = Record.EMPTY("building")
        self._current.location = Record.EMPTY("location")

        self._widgets = AttrDict()
        self._store = AttrDict()
        self._hooks = AttrDict()

        pane = self.GetPane()

        sizer = wx.BoxSizer(wx.VERTICAL)

        self._store.city = APP.DataStore.city
        self._widgets.city = mwx.RecordListCombo(pane, self._store.city)
        self._hooks.city_change = self._widgets.city.listenForEvent(
            "current_record_changed", partial(self.ref_record_changed, "city"))
        self._hooks.city_command = self._widgets.city.listenForEvent(
            "keyboard_command", partial(self.ref_keyboard_command, "city"))
        self._widgets.city.Bind(wx.EVT_RIGHT_DOWN, partial(self.add, "city"))
        sizer.Add(self._widgets.city, flag=wx.EXPAND)

        self._store.street = orm.RecordListView(APP.DataStore.street)
        self._widgets.street = mwx.RecordListCombo(pane, self._store.street)
        self._hooks.street_change = self._widgets.street.listenForEvent(
            "current_record_changed", partial(self.ref_record_changed,
                                              "street"))
        self._hooks.street_command = self._widgets.street.listenForEvent(
            "keyboard_command", partial(self.ref_keyboard_command, "street"))
        self._widgets.street.Bind(wx.EVT_RIGHT_DOWN,
                                  partial(self.add, "street"))
        sizer.Add(self._widgets.street, flag=wx.EXPAND)

        self._store.building = orm.RecordListView(APP.DataStore.building)
        self._widgets.building = mwx.RecordListCombo(pane,
                                                     self._store.building)
        self._hooks.building_change = self._widgets.building.listenForEvent(
            "current_record_changed",
            partial(self.ref_record_changed, "building"))
        self._hooks.building_command = self._widgets.building.listenForEvent(
            "keyboard_command", partial(self.ref_keyboard_command, "building"))
        self._widgets.building.Bind(wx.EVT_RIGHT_DOWN,
                                    partial(self.add, "building"))
        sizer.Add(self._widgets.building, flag=wx.EXPAND)

        self._store.location = orm.RecordListView(APP.DataStore.location)
        self._widgets.location = mwx.RecordListCombo(pane,
                                                     self._store.location)
        self._hooks.location_change = self._widgets.location.listenForEvent(
            "current_record_changed",
            partial(self.ref_record_changed, "location"))
        self._hooks.location_command = self._widgets.location.listenForEvent(
            "keyboard_command", partial(self.ref_keyboard_command, "location"))
        self._widgets.location.Bind(wx.EVT_RIGHT_DOWN,
                                    partial(self.add, "location"))
        sizer.Add(self._widgets.location, flag=wx.EXPAND)

        btsizer = wx.BoxSizer(wx.HORIZONTAL)

        self._widgets.save = wx.Button(pane, size=(-1, 30), label="Ustaw")
        self._widgets.save.Bind(wx.EVT_BUTTON, self.save)
        btsizer.Add(self._widgets.save, 1, flag=wx.EXPAND)

        self._widgets.revert = wx.Button(pane, size=(-1, 30), label="Przywróć")
        btsizer.Add(self._widgets.revert, 1, flag=wx.EXPAND)

        sizer.Add(btsizer, flag=wx.EXPAND)

        self._widgets.street.Enabled = False
        self._widgets.building.Enabled = False
        self._widgets.location.Enabled = False

        pane.SetSizer(sizer)

        self.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self.OnPaneToggled)