|
@@ -58,6 +58,8 @@ from debug import Debug
|
|
|
from gcmd import GMessage, GError
|
|
|
from gdialogs import ElementDialog, GetImageHandlers
|
|
|
from preferences import PreferencesBaseDialog, globalSettings as UserSettings
|
|
|
+from ghelp import SearchModuleWindow
|
|
|
+
|
|
|
from grass.script import core as grass
|
|
|
|
|
|
class Model(object):
|
|
@@ -477,6 +479,7 @@ class ModelFrame(wx.Frame):
|
|
|
Debug.msg(4, "ModelFrame.OnModelSave(): filename=%s" % self.modelFile)
|
|
|
self.WriteModelFile(self.modelFile)
|
|
|
self.SetStatusText(_('File <%s> saved') % self.modelFile, 0)
|
|
|
+ self.SetTitle(self.baseTitle + " - " + os.path.basename(self.modelFile))
|
|
|
elif not self.modelFile:
|
|
|
self.OnModelSaveAs(None)
|
|
|
|
|
@@ -1530,37 +1533,20 @@ class ModelSearchDialog(wx.Dialog):
|
|
|
self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO))
|
|
|
|
|
|
self.panel = wx.Panel(parent = self, id = wx.ID_ANY)
|
|
|
-
|
|
|
- self.findBox = wx.StaticBox(parent = self.panel, id = wx.ID_ANY,
|
|
|
- label=" %s " % _("Find module(s) by"))
|
|
|
+
|
|
|
self.cmdBox = wx.StaticBox(parent = self.panel, id = wx.ID_ANY,
|
|
|
label=" %s " % _("Command"))
|
|
|
|
|
|
- self.searchBy = wx.Choice(parent = self.panel, id = wx.ID_ANY,
|
|
|
- choices = [_("description"),
|
|
|
- _("keywords")])
|
|
|
- self.searchBy.SetSelection(0)
|
|
|
- self.search = wx.TextCtrl(parent = self.panel, id = wx.ID_ANY,
|
|
|
- value = "", size = (-1, 25))
|
|
|
- self.searchTip = menuform.StaticWrapText(parent = self.panel, id = wx.ID_ANY,
|
|
|
- size = (-1, 35))
|
|
|
-
|
|
|
- self.searchChoice = wx.Choice(parent = self.panel, id = wx.ID_ANY)
|
|
|
-
|
|
|
self.cmd_prompt = prompt.GPromptSTC(parent = self)
|
|
|
-
|
|
|
+ self.search = SearchModuleWindow(parent = self.panel, cmdPrompt = self.cmd_prompt)
|
|
|
+
|
|
|
# get commands
|
|
|
items = self.cmd_prompt.GetCommandItems()
|
|
|
- self.searchTip.SetLabel(_("%d modules found") % len(items))
|
|
|
- self.searchChoice.SetItems(items)
|
|
|
|
|
|
self.btnCancel = wx.Button(self.panel, wx.ID_CANCEL)
|
|
|
self.btnOk = wx.Button(self.panel, wx.ID_OK)
|
|
|
self.btnOk.SetDefault()
|
|
|
|
|
|
- self.search.Bind(wx.EVT_TEXT, self.OnSearchModule)
|
|
|
- self.searchChoice.Bind(wx.EVT_CHOICE, self.OnSelectModule)
|
|
|
-
|
|
|
self._layout()
|
|
|
|
|
|
self.SetSize((500, 275))
|
|
@@ -1570,31 +1556,12 @@ class ModelSearchDialog(wx.Dialog):
|
|
|
btnSizer.AddButton(self.btnCancel)
|
|
|
btnSizer.AddButton(self.btnOk)
|
|
|
btnSizer.Realize()
|
|
|
-
|
|
|
- findSizer = wx.StaticBoxSizer(self.findBox, wx.HORIZONTAL)
|
|
|
- gridSizer = wx.GridBagSizer(hgap = 3, vgap = 3)
|
|
|
- gridSizer.AddGrowableCol(1)
|
|
|
-
|
|
|
- cmdSizer = wx.StaticBoxSizer(self.cmdBox, wx.VERTICAL)
|
|
|
-
|
|
|
- gridSizer.Add(item = self.searchBy,
|
|
|
- flag=wx.ALIGN_CENTER_VERTICAL, pos = (0, 0))
|
|
|
- gridSizer.Add(item = self.search,
|
|
|
- flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, pos = (0, 1))
|
|
|
- gridSizer.Add(item = self.searchTip,
|
|
|
- flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, pos = (1, 0), span = (1, 2))
|
|
|
- gridSizer.Add(item = self.searchChoice,
|
|
|
- flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, pos = (2, 0), span = (1, 2))
|
|
|
- findSizer.Add(item = gridSizer, proportion = 1)
|
|
|
-
|
|
|
- cmdSizer.Add(item=self.cmd_prompt, proportion=1,
|
|
|
- flag=wx.EXPAND | wx.ALL, border=1)
|
|
|
|
|
|
mainSizer = wx.BoxSizer(wx.VERTICAL)
|
|
|
- mainSizer.Add(item=findSizer, proportion=0,
|
|
|
- flag=wx.EXPAND | wx.ALL, border=5)
|
|
|
- mainSizer.Add(item=cmdSizer, proportion=1,
|
|
|
- flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border = 5)
|
|
|
+ mainSizer.Add(item=self.search, proportion=0,
|
|
|
+ flag=wx.EXPAND | wx.ALL, border=3)
|
|
|
+ mainSizer.Add(item=self.cmd_prompt, proportion=1,
|
|
|
+ flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, border=3)
|
|
|
mainSizer.Add(item=btnSizer, proportion=0,
|
|
|
flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5)
|
|
|
|
|
@@ -1619,53 +1586,7 @@ class ModelSearchDialog(wx.Dialog):
|
|
|
cmd = shlex.split(utils.EncodeString((line)))
|
|
|
|
|
|
return cmd
|
|
|
-
|
|
|
- def OnSearchModule(self, event):
|
|
|
- """!Search module by keywords or description"""
|
|
|
- text = event.GetString()
|
|
|
- if not text:
|
|
|
- self.cmd_prompt.SetFilter(None)
|
|
|
- return
|
|
|
-
|
|
|
- modules = dict()
|
|
|
- iFound = 0
|
|
|
- for module, data in self.cmd_prompt.moduleDesc.iteritems():
|
|
|
- found = False
|
|
|
- if self.searchBy.GetSelection() == 0: # -> description
|
|
|
- if text in data['desc']:
|
|
|
- found = True
|
|
|
- else: # -> keywords
|
|
|
- if self.cmd_prompt.CheckKey(text, data['keywords']):
|
|
|
- found = True
|
|
|
-
|
|
|
- if found:
|
|
|
- iFound += 1
|
|
|
- try:
|
|
|
- group, name = module.split('.')
|
|
|
- except ValueError:
|
|
|
- continue # TODO
|
|
|
-
|
|
|
- if not modules.has_key(group):
|
|
|
- modules[group] = list()
|
|
|
- modules[group].append(name)
|
|
|
-
|
|
|
- self.cmd_prompt.SetFilter(modules)
|
|
|
- self.searchTip.SetLabel(_("%d modules found") % iFound)
|
|
|
- self.searchChoice.SetItems(self.cmd_prompt.GetCommandItems())
|
|
|
-
|
|
|
- def OnSelectModule(self, event):
|
|
|
- """!Module selected from choice, update command prompt"""
|
|
|
- cmd = event.GetString().split(' ', 1)[0]
|
|
|
- text = cmd + ' '
|
|
|
- pos = len(text)
|
|
|
- self.cmd_prompt.SetText(text)
|
|
|
- self.cmd_prompt.SetSelectionStart(pos)
|
|
|
- self.cmd_prompt.SetCurrentPos(pos)
|
|
|
- self.cmd_prompt.SetFocus()
|
|
|
-
|
|
|
- desc = self.cmd_prompt.GetCommandDesc(cmd)
|
|
|
- self.searchTip.SetLabel(desc)
|
|
|
-
|
|
|
+
|
|
|
def OnOk(self, event):
|
|
|
self.btnOk.SetFocus()
|
|
|
|