2 @package gmodeler.dialogs 
    4 @brief wxGUI Graphical Modeler - dialogs 
    7  - dialogs::ModelDataDialog 
    8  - dialogs::ModelSearchDialog 
    9  - dialogs::ModelRelationDialog 
   10  - dialogs::ModelItemDialog 
   11  - dialogs::ModelLoopDialog 
   12  - dialogs::ModelConditionDialog 
   13  - dialogs::ModelListCtrl 
   14  - dialogs::ValiableListCtrl 
   15  - dialogs::ItemListCtrl 
   16  - dialogs::ItemCheckListCtrl 
   18 (C) 2010-2011 by the GRASS Development Team 
   20 This program is free software under the GNU General Public License 
   21 (>=v2). Read the file COPYING that comes with GRASS for details. 
   23 @author Martin Landa <landa.martin gmail.com> 
   30 import wx.lib.mixins.listctrl 
as listmix
 
   32 from core                 
import globalvar
 
   33 from core                 
import utils
 
   35 from core.gcmd            import GError, EncodeString
 
   39 from gui_core.forms       
import CmdPanel
 
   46     """!Data item properties dialog""" 
   47     def __init__(self, parent, shape, id = wx.ID_ANY, title = _(
"Data properties"),
 
   48                  style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
 
   53         ElementDialog.__init__(self, parent, title, label = label, etype = etype)
 
   56         self.element.SetValue(shape.GetValue())
 
   58         self.Bind(wx.EVT_BUTTON, self.
OnOK,     self.
btnOK)
 
   67         self.SetMinSize(self.GetSize())
 
   71         prompt = self.shape.GetPrompt()
 
   72         if prompt == 
'raster':
 
   73             label = _(
'Name of raster map:')
 
   74         elif prompt == 
'vector':
 
   75             label = _(
'Name of vector map:')
 
   78             label = _(
'Name of element:')
 
   84         self.dataSizer.Add(self.
element, proportion=0,
 
   85                       flag=wx.EXPAND | wx.ALL, border=1)
 
   87         self.panel.SetSizer(self.
sizer)
 
   96                 self.shape.SetPrompt(
'raster')
 
   98                 self.shape.SetPrompt(
'raster')
 
  100         self.parent.canvas.Refresh()
 
  101         self.parent.SetStatusText(
'', 0)
 
  102         self.shape.SetPropDialog(
None)
 
  110         """!Cancel pressed""" 
  111         self.shape.SetPropDialog(
None)
 
  118     def __init__(self, parent, id = wx.ID_ANY, title = _(
"Add new GRASS module to the model"),
 
  119                  style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs):
 
  120         """!Graphical modeler module search window 
  122         @param parent parent window 
  124         @param title window title 
  125         @param kwargs wx.Dialogs' arguments 
  129         wx.Dialog.__init__(self, parent = parent, id = id, title = title, **kwargs)
 
  130         self.SetName(
"ModelerDialog")
 
  131         self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 
'grass.ico'), wx.BITMAP_TYPE_ICO))
 
  133         self.
panel = wx.Panel(parent = self, id = wx.ID_ANY)
 
  136                                    label=
" %s " % _(
"Command"))
 
  140         wx.CallAfter(self.cmd_prompt.SetFocus)
 
  143         items = self.cmd_prompt.GetCommandItems()
 
  147         self.btnOk.SetDefault()
 
  148         self.btnOk.Enable(
False)
 
  150         self.cmd_prompt.Bind(wx.EVT_KEY_UP, self.
OnText)
 
  151         self.search.searchChoice.Bind(wx.EVT_CHOICE, self.
OnText)
 
  152         self.Bind(wx.EVT_BUTTON, self.
OnOk, self.
btnOk)
 
  157         self.SetSize((500, 275))
 
  160         cmdSizer = wx.StaticBoxSizer(self.
cmdBox, wx.VERTICAL)
 
  161         cmdSizer.Add(item = self.
cmd_prompt, proportion = 1,
 
  164         btnSizer = wx.StdDialogButtonSizer()
 
  166         btnSizer.AddButton(self.
btnOk)
 
  169         mainSizer = wx.BoxSizer(wx.VERTICAL)
 
  170         mainSizer.Add(item = self.
search, proportion = 0,
 
  171                       flag = wx.EXPAND | wx.ALL, border = 3)
 
  172         mainSizer.Add(item = cmdSizer, proportion = 1,
 
  173                       flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, border = 3)
 
  174         mainSizer.Add(item = btnSizer, proportion = 0,
 
  175                       flag = wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border = 5)
 
  177         self.panel.SetSizer(mainSizer)
 
  178         mainSizer.Fit(self.
panel)
 
  183         """!Get dialog panel""" 
  188         line = self.cmd_prompt.GetCurLine()[0].strip()
 
  200         """!Button 'OK' pressed""" 
  202         if self.cmd_prompt.AutoCompActive():
 
  203             self.cmd_prompt.AutoCompCancel()
 
  205         self.btnOk.SetFocus()
 
  209             GError(parent = self,
 
  210                    message = _(
"Command not defined.\n\n" 
  211                                "Unable to add new action to the model."))
 
  214         if cmd[0] 
not in globalvar.grassCmd:
 
  215             GError(parent = self,
 
  216                    message = _(
"'%s' is not a GRASS module.\n\n" 
  217                                "Unable to add new action to the model.") % cmd[0])
 
  220         self.EndModal(wx.ID_OK)
 
  223         """Cancel pressed, close window""" 
  225         if self.cmd_prompt.AutoCompActive():
 
  226             self.cmd_prompt.AutoCompCancel()
 
  231         """!Text in prompt changed""" 
  232         if self.cmd_prompt.AutoCompActive():
 
  236         if isinstance(event, wx.KeyEvent):
 
  237             entry = self.cmd_prompt.GetTextLeft()
 
  238         elif isinstance(event, wx.stc.StyledTextEvent):
 
  239             entry = event.GetText()
 
  241             entry = event.GetString()
 
  246             self.btnOk.Enable(
False)
 
  253         self.cmd_prompt.OnCmdErase(
None)
 
  254         self.btnOk.Enable(
False)
 
  255         self.cmd_prompt.SetFocus()
 
  258     """!Relation properties dialog""" 
  259     def __init__(self, parent, shape, id = wx.ID_ANY, title = _(
"Relation properties"),
 
  260                  style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs):
 
  270         wx.Dialog.__init__(self, parent, id, title, style = style, **kwargs)
 
  271         self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 
'grass.ico'), wx.BITMAP_TYPE_ICO))
 
  273         self.
panel = wx.Panel(parent = self, id = wx.ID_ANY)
 
  276                                     label = 
" %s " % _(
"From"))
 
  277         self.
toBox = wx.StaticBox(parent = self.
panel, id = wx.ID_ANY,
 
  278                                   label = 
" %s " % _(
"To"))
 
  281                                   style = wx.CB_READONLY,
 
  283         self.option.Bind(wx.EVT_COMBOBOX, self.
OnOption)
 
  287         self.btnOk.Enable(
False)
 
  292         mainSizer = wx.BoxSizer(wx.VERTICAL)
 
  294         fromSizer = wx.StaticBoxSizer(self.
fromBox, wx.VERTICAL)
 
  295         self.
_layoutShape(shape = self.shape.GetFrom(), sizer = fromSizer)
 
  296         toSizer = wx.StaticBoxSizer(self.
toBox, wx.VERTICAL)
 
  297         self.
_layoutShape(shape = self.shape.GetTo(), sizer = toSizer)
 
  299         btnSizer = wx.StdDialogButtonSizer()
 
  301         btnSizer.AddButton(self.
btnOk)
 
  304         mainSizer.Add(item = fromSizer, proportion = 0,
 
  305                       flag = wx.EXPAND | wx.ALL, border = 5)
 
  306         mainSizer.Add(item = toSizer, proportion = 0,
 
  307                       flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border = 5)
 
  308         mainSizer.Add(item = btnSizer, proportion = 0,
 
  309                       flag = wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border = 5)
 
  311         self.panel.SetSizer(mainSizer)
 
  312         mainSizer.Fit(self.
panel)
 
  315         self.SetSize(self.GetBestSize())
 
  317     def _layoutShape(self, shape, sizer):
 
  318         if isinstance(shape, ModelData):
 
  319             sizer.Add(item = wx.StaticText(parent = self.
panel, id = wx.ID_ANY,
 
  320                                            label = _(
"Data: %s") % shape.GetLog()),
 
  321                       proportion = 1, flag = wx.EXPAND | wx.ALL,
 
  323         elif isinstance(shape, ModelAction):
 
  324             gridSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
 
  325             gridSizer.Add(item = wx.StaticText(parent = self.
panel, id = wx.ID_ANY,
 
  326                                                label = _(
"Command:")),
 
  328             gridSizer.Add(item = wx.StaticText(parent = self.
panel, id = wx.ID_ANY,
 
  329                                                label = shape.GetName()),
 
  331             gridSizer.Add(item = wx.StaticText(parent = self.
panel, id = wx.ID_ANY,
 
  332                                                label = _(
"Option:")),
 
  333                           flag = wx.ALIGN_CENTER_VERTICAL,
 
  335             gridSizer.Add(item = self.
option,
 
  337             sizer.Add(item = gridSizer,
 
  338                       proportion = 1, flag = wx.EXPAND | wx.ALL,
 
  341     def _getOptions(self):
 
  342         """!Get relevant options""" 
  344         fromShape = self.shape.GetFrom()
 
  345         if not isinstance(fromShape, ModelData):
 
  346             GError(parent = self.
parent,
 
  347                    message = _(
"Relation doesn't start with data item.\n" 
  348                                "Unable to add relation."))
 
  351         toShape = self.shape.GetTo()
 
  352         if not isinstance(toShape, ModelAction):
 
  353             GError(parent = self.
parent,
 
  354                    message = _(
"Relation doesn't point to GRASS command.\n" 
  355                                "Unable to add relation."))
 
  358         prompt = fromShape.GetPrompt()
 
  359         task = toShape.GetTask()
 
  360         for p 
in task.get_options()[
'params']:
 
  361             if p.get(
'prompt', 
'') == prompt 
and \
 
  363                 items.append(p[
'name'])
 
  366             GError(parent = self.
parent,
 
  367                    message = _(
"No relevant option found.\n" 
  368                                "Unable to add relation."))
 
  372         """!Get selected option""" 
  373         return self.option.GetStringSelection()
 
  376         """!Check if relation is valid""" 
  381         if event.GetString():
 
  384             self.btnOk.Enable(
False)
 
  387     """!Abstract item properties dialog""" 
  388     def __init__(self, parent, shape, title, id = wx.ID_ANY,
 
  389                  style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs):
 
  393         wx.Dialog.__init__(self, parent, id, title = title, style = style, **kwargs)
 
  395         self.
panel = wx.Panel(parent = self, id = wx.ID_ANY)
 
  398                                     label=
" %s " % _(
"Condition"))
 
  400                                     value = shape.GetText())
 
  404                                           columns = [_(
"ID"), _(
"Name"),
 
  407         self.itemList.Populate(self.parent.GetModel().GetItems())
 
  411         self.btnOk.SetDefault()
 
  414         """!Do layout (virtual method)""" 
  418         """!Get loop condition""" 
  419         return self.condText.GetValue()
 
  422     """!Loop properties dialog""" 
  423     def __init__(self, parent, shape, id = wx.ID_ANY, title = _(
"Loop properties"),
 
  424                  style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs):
 
  425         ModelItemDialog.__init__(self, parent, shape, title,
 
  426                                  style = style, **kwargs)
 
  429                                     label=
" %s " % _(
"List of items in loop"))
 
  433         self.btnSeries.SetToolTipString(_(
"Define map series as condition for the loop"))
 
  434         self.btnSeries.Bind(wx.EVT_BUTTON, self.
OnSeries)
 
  437         self.SetMinSize(self.GetSize())
 
  438         self.SetSize((500, 400))
 
  442         sizer = wx.BoxSizer(wx.VERTICAL)
 
  444         condSizer = wx.StaticBoxSizer(self.
condBox, wx.HORIZONTAL)
 
  445         condSizer.Add(item = self.
condText, proportion = 1,
 
  446                       flag = wx.ALL, border = 3)
 
  447         condSizer.Add(item = self.
btnSeries, proportion = 0,
 
  450         listSizer = wx.StaticBoxSizer(self.
listBox, wx.VERTICAL)
 
  451         listSizer.Add(item = self.
itemList, proportion = 1,
 
  452                       flag = wx.EXPAND | wx.ALL, border = 3)
 
  454         btnSizer = wx.StdDialogButtonSizer()
 
  456         btnSizer.AddButton(self.
btnOk)
 
  459         sizer.Add(item = condSizer, proportion = 0,
 
  460                   flag = wx.EXPAND | wx.ALL, border = 3)
 
  461         sizer.Add(item = listSizer, proportion = 1,
 
  462                   flag = wx.EXPAND | wx.LEFT | wx.RIGHT, border = 3)
 
  463         sizer.Add(item = btnSizer, proportion=0,
 
  464                   flag = wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5)
 
  466         self.panel.SetSizer(sizer)
 
  467         sizer.Fit(self.
panel)
 
  472         """!Get list of selected actions""" 
  473         return self.itemList.GetItems()
 
  476         """!Define map series as condition""" 
  477         dialog = 
MapLayersDialog(parent = self, title = _(
"Define series of maps"), modeler = 
True)
 
  478         if dialog.ShowModal() != wx.ID_OK:
 
  482         cond = dialog.GetDSeries()
 
  484             cond = 
'map in %s' % map(
lambda x: str(x), dialog.GetMapLayers())
 
  486         self.condText.SetValue(cond)
 
  491     """!Condition properties dialog""" 
  492     def __init__(self, parent, shape, id = wx.ID_ANY, title = _(
"If-else properties"),
 
  493                  style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs):
 
  494         ModelItemDialog.__init__(self, parent, shape, title,
 
  495                                  style = style, **kwargs)
 
  498                                       label=
" %s " % _(
"List of items in 'if' block"))
 
  500         self.itemListIf.SetName(
'IfBlockList')
 
  503                                         label=
" %s " % _(
"List of items in 'else' block"))
 
  506                                               columns = [_(
"ID"), _(
"Name"),
 
  509         self.itemListElse.SetName(
'ElseBlockList')
 
  510         self.itemListElse.Populate(self.parent.GetModel().
GetItems())
 
  513         self.SetMinSize(self.GetSize())
 
  514         self.SetSize((500, 400))
 
  518         sizer = wx.BoxSizer(wx.VERTICAL)
 
  520         condSizer = wx.StaticBoxSizer(self.
condBox, wx.VERTICAL)
 
  521         condSizer.Add(item = self.
condText, proportion = 1,
 
  524         listIfSizer = wx.StaticBoxSizer(self.
listBoxIf, wx.VERTICAL)
 
  525         listIfSizer.Add(item = self.
itemListIf, proportion = 1,
 
  527         listElseSizer = wx.StaticBoxSizer(self.
listBoxElse, wx.VERTICAL)
 
  528         listElseSizer.Add(item = self.
itemListElse, proportion = 1,
 
  531         btnSizer = wx.StdDialogButtonSizer()
 
  533         btnSizer.AddButton(self.
btnOk)
 
  536         sizer.Add(item = condSizer, proportion = 0,
 
  537                   flag = wx.EXPAND | wx.ALL, border = 3)
 
  538         sizer.Add(item = listIfSizer, proportion = 1,
 
  539                   flag = wx.EXPAND | wx.LEFT | wx.RIGHT, border = 3)
 
  540         sizer.Add(item = listElseSizer, proportion = 1,
 
  541                   flag = wx.EXPAND | wx.LEFT | wx.RIGHT, border = 3)
 
  542         sizer.Add(item = btnSizer, proportion=0,
 
  543                   flag = wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5)
 
  545         self.panel.SetSizer(sizer)
 
  546         sizer.Fit(self.
panel)
 
  551         """!Item in if-block checked/unchecked""" 
  555         aId = int(self.itemListIf.GetItem(index, 0).GetText())
 
  556         if aId 
in self.itemListElse.GetItems()[
'checked']:
 
  557             self.itemListElse.CheckItemById(aId, 
False)
 
  560         """!Item in else-block checked/unchecked""" 
  564         aId = int(self.itemListElse.GetItem(index, 0).GetText())
 
  565         if aId 
in self.itemListIf.GetItems()[
'checked']:
 
  566             self.itemListIf.CheckItemById(aId, 
False)
 
  570         return { 
'if'   : self.itemListIf.GetItems(),
 
  571                  'else' : self.itemListElse.GetItems() }
 
  574                     listmix.ListCtrlAutoWidthMixin,
 
  575                     listmix.TextEditMixin,
 
  576                     listmix.ColumnSorterMixin):
 
  577     def __init__(self, parent, columns, id = wx.ID_ANY,
 
  578                  style = wx.LC_REPORT | wx.BORDER_NONE |
 
  579                  wx.LC_SORT_ASCENDING |wx.LC_HRULES |
 
  580                  wx.LC_VRULES, **kwargs):
 
  581         """!List of model variables""" 
  587         except AttributeError:
 
  590         wx.ListCtrl.__init__(self, parent, id = id, style = style, **kwargs)
 
  591         listmix.ListCtrlAutoWidthMixin.__init__(self)
 
  592         listmix.TextEditMixin.__init__(self)
 
  593         listmix.ColumnSorterMixin.__init__(self, 4)
 
  597             self.InsertColumn(i, col)
 
  598             self.SetColumnWidth(i, wx.LIST_AUTOSIZE_USEHEADER)
 
  604         self.Bind(wx.EVT_LIST_BEGIN_LABEL_EDIT, self.
OnBeginEdit)
 
  605         self.Bind(wx.EVT_LIST_END_LABEL_EDIT, self.
OnEndEdit)
 
  606         self.Bind(wx.EVT_LIST_COL_CLICK, self.
OnColClick)
 
  607         self.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.OnRightUp) 
 
  608         self.Bind(wx.EVT_RIGHT_UP, self.OnRightUp)            
 
  611         """!Editing of item started""" 
  615         """!Finish editing of item""" 
  619         """!Click on column header (order by)""" 
  624         """!List of model variables""" 
  625         ModelListCtrl.__init__(self, parent, columns, **kwargs)
 
  627         self.SetColumnWidth(2, 200) 
 
  630         """!Used by ColumnSorterMixin""" 
  638         """!Populate the list""" 
  641         for name, values 
in data.iteritems():
 
  643                                    values.get(
'value', 
''),
 
  644                                    values.get(
'description', 
'')]
 
  648         self.DeleteAllItems()
 
  650         for name, vtype, value, desc 
in self.itemDataMap.itervalues():
 
  651             index = self.InsertStringItem(sys.maxint, name)
 
  652             self.SetStringItem(index, 0, name)
 
  653             self.SetStringItem(index, 1, vtype)
 
  654             self.SetStringItem(index, 2, value)
 
  655             self.SetStringItem(index, 3, desc)
 
  656             self.SetItemData(index, i)
 
  659     def Append(self, name, vtype, value, desc):
 
  660         """!Append new item to the list 
  662         @return None on success 
  665         for iname, ivtype, ivalue, idesc 
in self.itemDataMap.itervalues():
 
  667                 return _(
"Variable <%s> already exists in the model. " 
  668                          "Adding variable failed.") % name
 
  670         index = self.InsertStringItem(sys.maxint, name)
 
  671         self.SetStringItem(index, 0, name)
 
  672         self.SetStringItem(index, 1, vtype)
 
  673         self.SetStringItem(index, 2, value)
 
  674         self.SetStringItem(index, 3, desc)
 
  683         """!Remove selected variable(s) from the model""" 
  684         item = self.GetFirstSelected()
 
  686             self.DeleteItem(item)
 
  688             item = self.GetFirstSelected()
 
  689         self.parent.UpdateModelVariables()
 
  694         """!Remove all variable(s) from the model""" 
  695         dlg = wx.MessageBox(parent=self,
 
  696                             message=_(
"Do you want to delete all variables from " 
  698                             caption=_(
"Delete variables"),
 
  699                             style=wx.YES_NO | wx.CENTRE)
 
  703         self.DeleteAllItems()
 
  706         self.parent.UpdateModelVariables()
 
  709         """!Finish editing of item""" 
  710         itemIndex = event.GetIndex()
 
  711         columnIndex = event.GetColumn()
 
  712         nameOld = self.GetItem(itemIndex, 0).GetText()
 
  717         self.
itemDataMap[itemIndex][columnIndex] = event.GetText()
 
  719         self.parent.UpdateModelVariables()
 
  722         """!Reload list of variables""" 
  723         self.
Populate(self.parent.parent.GetModel().GetVariables())
 
  726         """!Mouse right button up""" 
  727         if not hasattr(self, 
"popupID1"):
 
  737         menu.Append(self.
popupID1, _(
"Delete selected"))
 
  738         menu.Append(self.
popupID2, _(
"Delete all"))
 
  739         if self.GetFirstSelected() == -1:
 
  743         menu.AppendSeparator()
 
  744         menu.Append(self.
popupID3, _(
"Reload"))
 
  750     def __init__(self, parent, columns, disablePopup = False, **kwargs):
 
  751         """!List of model actions""" 
  754         ModelListCtrl.__init__(self, parent, columns, **kwargs)
 
  755         self.SetColumnWidth(1, 100)
 
  756         self.SetColumnWidth(2, 65)
 
  759         """!Used by ColumnSorterMixin""" 
  767         """!Populate the list""" 
  771             if isinstance(self.
shape, ModelCondition):
 
  772                 if self.GetName() == 
'ElseBlockList':
 
  773                     shapeItems = map(
lambda x: x.GetId(), self.shape.GetItems()[
'else'])
 
  775                     shapeItems = map(
lambda x: x.GetId(), self.shape.GetItems()[
'if'])
 
  777                 shapeItems = map(
lambda x: x.GetId(), self.shape.GetItems())
 
  785             if isinstance(action, ModelData) 
or \
 
  786                     action == self.
shape:
 
  793                 aId = action.GetBlockId()
 
  794                 if action.GetId() 
in shapeItems:
 
  799                 bId = action.GetBlockId()
 
  804                                        ','.join(map(str, bId)),
 
  810         self.DeleteAllItems()
 
  813             for aid, name, desc 
in self.itemDataMap.itervalues():
 
  814                 index = self.InsertStringItem(sys.maxint, aid)
 
  815                 self.SetStringItem(index, 0, aid)
 
  816                 self.SetStringItem(index, 1, name)
 
  817                 self.SetStringItem(index, 2, desc)
 
  818                 self.SetItemData(index, i)
 
  820                     self.CheckItem(index, 
True)
 
  823             for aid, name, inloop, desc 
in self.itemDataMap.itervalues():
 
  824                 index = self.InsertStringItem(sys.maxint, aid)
 
  825                 self.SetStringItem(index, 0, aid)
 
  826                 self.SetStringItem(index, 1, name)
 
  827                 self.SetStringItem(index, 2, inloop)
 
  828                 self.SetStringItem(index, 3, desc)
 
  829                 self.SetItemData(index, i)
 
  833         """!Remove selected action(s) from the model""" 
  834         model = self.frame.GetModel()
 
  835         canvas = self.frame.GetCanvas()
 
  837         item = self.GetFirstSelected()
 
  839             self.DeleteItem(item)
 
  842             aId = self.GetItem(item, 0).GetText()
 
  843             action = model.GetItem(int(aId))
 
  845                 item = self.GetFirstSelected()
 
  848             model.RemoveItem(action)
 
  849             canvas.GetDiagram().RemoveShape(action)
 
  850             self.frame.ModelChanged()
 
  852             item = self.GetFirstSelected()
 
  859         """!Remove all variable(s) from the model""" 
  860         deleteDialog = wx.MessageBox(parent=self,
 
  861                                      message=_(
"Selected data records (%d) will permanently deleted " 
  862                                                "from table. Do you want to delete them?") % \
 
  863                                          (len(self.listOfSQLStatements)),
 
  864                                      caption=_(
"Delete records"),
 
  865                                      style=wx.YES_NO | wx.CENTRE)
 
  866         if deleteDialog != wx.YES:
 
  869         self.DeleteAllItems()
 
  872         self.parent.UpdateModelVariables()
 
  875         """!Finish editing of item""" 
  876         itemIndex = event.GetIndex()
 
  877         columnIndex = event.GetColumn()
 
  879         self.
itemDataMap[itemIndex][columnIndex] = event.GetText()
 
  881         aId = int(self.GetItem(itemIndex, 0).GetText())
 
  882         action = self.frame.GetModel().GetItem(aId)
 
  886             action.SetId(int(event.GetText()))
 
  888         self.frame.ModelChanged()
 
  891         """!Reload list of actions""" 
  892         self.
Populate(self.frame.GetModel().GetItems())
 
  895         """!Mouse right button up""" 
  899         if not hasattr(self, 
"popupID1"):
 
  911         menu.Append(self.
popupID1, _(
"Delete selected"))
 
  912         menu.Append(self.
popupID2, _(
"Delete all"))
 
  913         if self.GetFirstSelected() == -1:
 
  917         menu.AppendSeparator()
 
  918         menu.Append(self.
popupID4, _(
"Normalize"))
 
  919         menu.Append(self.
popupID3, _(
"Reload"))
 
  925         """!Update id of actions""" 
  926         model = self.frame.GetModel()
 
  929         for item 
in model.GetItems():
 
  934         self.frame.GetCanvas().Refresh()
 
  935         self.frame.ModelChanged()
 
  938     def __init__(self, parent, shape, columns, window = None, **kwargs):
 
  942         ItemListCtrl.__init__(self, parent, columns, disablePopup = 
True, **kwargs)
 
  943         listmix.CheckListCtrlMixin.__init__(self)
 
  944         self.SetColumnWidth(0, 50)
 
  949         """!Disable editing""" 
  953         """!Item checked/unchecked""" 
  954         name = self.GetName()
 
  955         if name == 
'IfBlockList' and self.
window:
 
  956             self.window.OnCheckItemIf(index, flag)
 
  957         elif name == 
'ElseBlockList' and self.
window:
 
  958             self.window.OnCheckItemElse(index, flag)
 
  961         """!Get list of selected actions""" 
  962         ids = { 
'checked'   : list(),
 
  963                 'unchecked' : list() }
 
  964         for i 
in range(self.GetItemCount()):
 
  965             iId = int(self.GetItem(i, 0).GetText())
 
  966             if self.IsChecked(i):
 
  967                 ids[
'checked'].append(iId)
 
  969                 ids[
'unchecked'].append(iId)
 
  974         """!Check/uncheck given item by id""" 
  975         for i 
in range(self.GetItemCount()):
 
  976             iId = int(self.GetItem(i, 0).GetText())
 
  978                 self.CheckItem(i, flag)
 
def OnRightUp
Mouse right button up. 
 
def GetData
Get list data. 
 
def Append
Append new item to the list. 
 
def OnReload
Reload list of actions. 
 
Data item properties dialog. 
 
def OnReload
Reload list of variables. 
 
def IsValid
Check if relation is valid. 
 
def OnEndEdit
Finish editing of item. 
 
def OnBeginEdit
Disable editing. 
 
wxGUI Graphical Modeler (base classes & read/write) 
 
def OnBeginEdit
Editing of item started. 
 
def GetType
Get element type. 
 
def GetItems
Get list of selected actions. 
 
def Populate
Populate the list. 
 
Relation properties dialog. 
 
Abstract item properties dialog. 
 
def GetListCtrl
Used by ColumnSorterMixin. 
 
def OnRemove
Remove selected action(s) from the model. 
 
def OnEndEdit
Finish editing of item. 
 
def OnCheckItemIf
Item in if-block checked/unchecked. 
 
Condition properties dialog. 
 
def GetCondition
Get loop condition. 
 
def OnColClick
Click on column header (order by) 
 
Various dialogs used in wxGUI. 
 
def GetListCtrl
Used by ColumnSorterMixin. 
 
Custom control that selects elements. 
 
def GetPanel
Get dialog panel. 
 
def split
Platform spefic shlex.split. 
 
def OnRightUp
Mouse right button up. 
 
def OnText
Text in prompt changed. 
 
def __init__
List of model variables. 
 
def OnOk
Button 'OK' pressed. 
 
def __init__
Graphical modeler module search window. 
 
def OnSeries
Define map series as condition. 
 
def CheckItemById
Check/uncheck given item by id. 
 
def EncodeString
Return encoded string using system locales. 
 
def GetElement
Return (mapName, overwrite) 
 
def OnNormalize
Update id of actions. 
 
def GetOption
Get selected option. 
 
def OnRemoveAll
Remove all variable(s) from the model. 
 
def OnRemove
Remove selected variable(s) from the model. 
 
def GetItems
Get list of selected actions. 
 
def OnRemoveAll
Remove all variable(s) from the model. 
 
def OnEndEdit
Finish editing of item. 
 
def Populate
Populate the list. 
 
def GetData
Get list data. 
 
def OnCheckItemElse
Item in else-block checked/unchecked. 
 
def __init__
List of model variables. 
 
def __init__
List of model actions. 
 
def OnCheckItem
Item checked/unchecked. 
 
def OnCancel
Cancel pressed. 
 
def _getOptions
Get relevant options. 
 
def _layout
Do layout (virtual method)