| | 591 | class DictionaryEntryDialog(wx.Dialog): |
| | 592 | |
| | 593 | def __init__(self,parent): |
| | 594 | super(DictionaryEntryDialog,self).__init__(parent,title=_("Edit dictionary entry")) |
| | 595 | mainSizer=wx.BoxSizer(wx.VERTICAL) |
| | 596 | settingsSizer=wx.BoxSizer(wx.VERTICAL) |
| | 597 | settingsSizer.Add(wx.StaticText(self,-1,label=_("&Pattern"))) |
| | 598 | self.patternTextCtrl=wx.TextCtrl(self,wx.NewId()) |
| | 599 | settingsSizer.Add(self.patternTextCtrl) |
| | 600 | settingsSizer.Add(wx.StaticText(self,-1,label=_("&Replacement"))) |
| | 601 | self.replacementTextCtrl=wx.TextCtrl(self,wx.NewId()) |
| | 602 | settingsSizer.Add(self.replacementTextCtrl) |
| | 603 | settingsSizer.Add(wx.StaticText(self,-1,label=_("&Comment"))) |
| | 604 | self.commentTextCtrl=wx.TextCtrl(self,wx.NewId()) |
| | 605 | settingsSizer.Add(self.commentTextCtrl) |
| | 606 | self.caseSensitiveCheckBox=wx.CheckBox(self,wx.NewId(),label=_("Case &sensitive")) |
| | 607 | settingsSizer.Add(self.caseSensitiveCheckBox) |
| | 608 | self.regexpCheckBox=wx.CheckBox(self,wx.NewId(),label=_("Regular &expression")) |
| | 609 | settingsSizer.Add(self.regexpCheckBox) |
| | 610 | mainSizer.Add(settingsSizer,border=20,flag=wx.LEFT|wx.RIGHT|wx.TOP) |
| | 611 | buttonSizer=self.CreateButtonSizer(wx.OK|wx.CANCEL) |
| | 612 | mainSizer.Add(buttonSizer,border=20,flag=wx.LEFT|wx.RIGHT|wx.BOTTOM) |
| | 613 | mainSizer.Fit(self) |
| | 614 | self.SetSizer(mainSizer) |
| | 615 | self.patternTextCtrl.SetFocus() |
| | 616 | |
| 644 | | if self.editingIndex==-1: |
| 645 | | addEntryDialog=scriptUI.TextEntriesDialog((_("&Pattern"),_("&Replacement"),_("&Comment")),title=_("Add an entry"),callback=self.onDialog) |
| 646 | | addEntryDialog.run() |
| | 672 | entryDialog=DictionaryEntryDialog(self) |
| | 673 | if entryDialog.ShowModal()==wx.ID_OK: |
| | 674 | self.tempUserDict.append(userDictHandler.UserDictEntry(entryDialog.patternTextCtrl.GetValue(),entryDialog.replacementTextCtrl.GetValue(),entryDialog.commentTextCtrl.GetValue(),entryDialog.caseSensitiveCheckBox.GetValue(),entryDialog.regexpCheckBox.GetValue())) |
| | 675 | self.dictList.Append((entryDialog.commentTextCtrl.GetValue(),entryDialog.patternTextCtrl.GetValue(),entryDialog.replacementTextCtrl.GetValue(),str(bool(entryDialog.caseSensitiveCheckBox.GetValue())),str(bool(entryDialog.regexpCheckBox.GetValue())))) |
| | 676 | index=self.dictList.GetFirstSelected() |
| | 677 | while index>=0: |
| | 678 | self.dictList.Select(index,on=0) |
| | 679 | index=self.dictList.GetNextSelected(index) |
| | 680 | addedIndex=self.dictList.GetItemCount()-1 |
| | 681 | self.dictList.Select(addedIndex) |
| | 682 | self.dictList.Focus(addedIndex) |
| | 683 | self.dictList.SetFocus() |
| | 684 | entryDialog.Destroy() |
| 649 | | if (self.dictList.GetSelectedItemCount()==1) and (self.editingIndex==-1): |
| 650 | | self.editingIndex=self.dictList.GetNextItem(-1,wx.LIST_NEXT_ALL,wx.LIST_STATE_SELECTED) |
| 651 | | editEntryDialog=scriptUI.TextEntriesDialog((_("&Pattern"),_("&Replacement"),_("&Comment")),title=_("Edit an entry"),defaults=(self.tempUserDict[self.editingIndex].pattern,self.tempUserDict[self.editingIndex].replacement,self.tempUserDict[self.editingIndex].comment), callback=self.onDialog) |
| 652 | | editEntryDialog.run() |
| | 687 | if self.dictList.GetSelectedItemCount()!=1: |
| | 688 | return |
| | 689 | editIndex=self.dictList.GetFirstSelected() |
| | 690 | if editIndex<0: |
| | 691 | return |
| | 692 | entryDialog=DictionaryEntryDialog(self) |
| | 693 | entryDialog.patternTextCtrl.SetValue(self.tempUserDict[editIndex].pattern) |
| | 694 | entryDialog.replacementTextCtrl.SetValue(self.tempUserDict[editIndex].replacement) |
| | 695 | entryDialog.commentTextCtrl.SetValue(self.tempUserDict[editIndex].comment) |
| | 696 | entryDialog.caseSensitiveCheckBox.SetValue(self.tempUserDict[editIndex].caseSensitive) |
| | 697 | entryDialog.regexpCheckBox.SetValue(self.tempUserDict[editIndex].regexp) |
| | 698 | if entryDialog.ShowModal()==wx.ID_OK: |
| | 699 | self.tempUserDict[editIndex].comment=entryDialog.commentTextCtrl.GetValue() |
| | 700 | self.dictList.SetStringItem(editIndex,0,entryDialog.commentTextCtrl.GetValue()) |
| | 701 | self.tempUserDict[editIndex].pattern=entryDialog.patternTextCtrl.GetValue() |
| | 702 | self.dictList.SetStringItem(editIndex,1,entryDialog.patternTextCtrl.GetValue()) |
| | 703 | self.tempUserDict[editIndex].replacement=entryDialog.replacementTextCtrl.GetValue() |
| | 704 | self.dictList.SetStringItem(editIndex,2,entryDialog.replacementTextCtrl.GetValue()) |
| | 705 | self.tempUserDict[editIndex].caseSensitive=bool(entryDialog.caseSensitiveCheckBox.GetValue()) |
| | 706 | self.dictList.SetStringItem(editIndex,3,str(bool(entryDialog.caseSensitiveCheckBox.GetValue()))) |
| | 707 | self.tempUserDict[editIndex].regexp=bool(entryDialog.regexpCheckBox.GetValue()) |
| | 708 | self.dictList.SetStringItem(editIndex,4,str(bool(entryDialog.regexpCheckBox.GetValue()))) |
| | 709 | self.dictList.SetFocus() |
| | 710 | entryDialog.Destroy() |
| 660 | | |
| 661 | | def onDialog(self,texts): |
| 662 | | if texts is not None: |
| 663 | | if self.editingIndex>=0: |
| 664 | | self.tempUserDict[self.editingIndex]=userDictHandler.UserDictEntry(texts[0],texts[1],texts[2]) |
| 665 | | self.dictList.SetStringItem(self.editingIndex,1,texts[0]) |
| 666 | | self.dictList.SetStringItem(self.editingIndex,2,texts[1]) |
| 667 | | self.dictList.SetStringItem(self.editingIndex,0,texts[2]) |
| 668 | | else: |
| 669 | | self.tempUserDict.append(userDictHandler.UserDictEntry(texts[0],texts[1],texts[2])) |
| 670 | | self.dictList.Append((texts[2],texts[0],texts[1])) |
| 671 | | self.editingIndex=-1 |
| 672 | | self.dictList.SetFocus() |