Grammalecte  Diff

Differences From Artifact [8b8fa9d3c8]:

To Artifact [b31844a66b]:


135
136
137
138
139
140
141

142
143
144
145
146
147
148

        self.xNewName = self._addWidget('newname', 'Edit', nX, nY1+20, 60, 10, FontDescriptor = xFDMono)
        self.xNewPattern = self._addWidget('newreplace', 'Edit', nX+65, nY1+20, 130, 10, FontDescriptor = xFDMono)
        self.xNewRepl = self._addWidget('newby', 'Edit', nX+200, nY1+20, 100, 10, FontDescriptor = xFDMono)
        self.xNewRegex = self._addWidget('newregex', 'CheckBox', nX+305, nY1+22, 35, nHeight, Label = ui.get("regex"), HelpText=ui.get("regex_help"))
        self.xNewCaseSens = self._addWidget('newcasesens', 'CheckBox', nX+340, nY1+22, 40, nHeight, Label = ui.get("casesens"), HelpText=ui.get("casesens_help"), State=True)


        self._addWidget('add', 'Button', self.xDialog.Width-50, nY1+31, 40, 11, Label = ui.get('add'))

        lColumns = [
            {"Title": ui.get("name"),     "ColumnWidth": 80},
            {"Title": ui.get("pattern"),  "ColumnWidth": 160},
            {"Title": ui.get("repl"),     "ColumnWidth": 120},
            {"Title": ui.get("regex"),    "ColumnWidth": 60},







>







135
136
137
138
139
140
141
142
143
144
145
146
147
148
149

        self.xNewName = self._addWidget('newname', 'Edit', nX, nY1+20, 60, 10, FontDescriptor = xFDMono)
        self.xNewPattern = self._addWidget('newreplace', 'Edit', nX+65, nY1+20, 130, 10, FontDescriptor = xFDMono)
        self.xNewRepl = self._addWidget('newby', 'Edit', nX+200, nY1+20, 100, 10, FontDescriptor = xFDMono)
        self.xNewRegex = self._addWidget('newregex', 'CheckBox', nX+305, nY1+22, 35, nHeight, Label = ui.get("regex"), HelpText=ui.get("regex_help"))
        self.xNewCaseSens = self._addWidget('newcasesens', 'CheckBox', nX+340, nY1+22, 40, nHeight, Label = ui.get("casesens"), HelpText=ui.get("casesens_help"), State=True)

        self._addWidget('order_info', 'FixedText', nX, nY1+32, 300, nHeight, Label = ui.get("order_info"))
        self._addWidget('add', 'Button', self.xDialog.Width-50, nY1+31, 40, 11, Label = ui.get('add'))

        lColumns = [
            {"Title": ui.get("name"),     "ColumnWidth": 80},
            {"Title": ui.get("pattern"),  "ColumnWidth": 160},
            {"Title": ui.get("repl"),     "ColumnWidth": 120},
            {"Title": ui.get("regex"),    "ColumnWidth": 60},
234
235
236
237
238
239
240
241
242

243
244
245
246
247
248
249
250
251
252
253
254

    # XGridSelectionListener
    def selectionChanged (self, xGridSelectionEvent):
        try:
            aRows = self.xGridControl.getSelectedRows()
            if aRows and len(aRows) == 1:
                self.iSelectedRow = aRows[0]
                self.sSelectedRuleName, sPattern, sRepl, sRegex, sCaseSens = self.xGridModel.GridDataModel.getRowData(self.iSelectedRow)
                # fill fields

                self.xEditName.Text = self.sSelectedRuleName
                self.xEditPattern.Text = sPattern
                self.xEditRepl.Text = sRepl
                self.xEditRegex.State = sRegex == "True"
                self.xEditCaseSens.State = sCaseSens == "True"
                # enable widgets
                self.xEditName.Enabled = True
                self.xEditPattern.Enabled = True
                self.xEditRepl.Enabled = True
                self.xEditRegex.Enabled = True
                self.xEditCaseSens.Enabled = True
                self.xDeleteButton.Enabled = True







|

>

|
|
|
|







235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256

    # XGridSelectionListener
    def selectionChanged (self, xGridSelectionEvent):
        try:
            aRows = self.xGridControl.getSelectedRows()
            if aRows and len(aRows) == 1:
                self.iSelectedRow = aRows[0]
                self.sSelectedRuleName, *_ = self.xGridModel.GridDataModel.getRowData(self.iSelectedRow)
                # fill fields
                dRule = self.dRules[self.sSelectedRuleName]
                self.xEditName.Text = self.sSelectedRuleName
                self.xEditPattern.Text = dRule["sPattern"]
                self.xEditRepl.Text = dRule["sRepl"]
                self.xEditRegex.State = dRule["bRegex"]
                self.xEditCaseSens.State = dRule["bCaseSens"]
                # enable widgets
                self.xEditName.Enabled = True
                self.xEditPattern.Enabled = True
                self.xEditRepl.Enabled = True
                self.xEditRegex.Enabled = True
                self.xEditCaseSens.Enabled = True
                self.xDeleteButton.Enabled = True
308
309
310
311
312
313
314
315



316
317
318
319
320
321
322
        }
        xGridDataModel = self.xGridModel.GridDataModel
        xGridDataModel.addRow(xGridDataModel.RowCount + 1, self._getValuesForRow(sRuleName))
        xGridDataModel.sortByColumn(0, True)
        self._clearAddFields()

    def _getValuesForRow (self, sRuleName):
        return (sRuleName, self.dRules[sRuleName]["sPattern"], self.dRules[sRuleName]["sRepl"], str(self.dRules[sRuleName]["bRegex"]), str(self.dRules[sRuleName]["bCaseSens"]))




    def _checkRuleName (self, sRuleName):
        return re.search(r"^\w[\w_#.,;!?-]{,14}$", sRuleName)

    def modifyRule (self):
        if not self._checkRuleName(self.xEditName.Text):
            MessageBox(self.xDocument, ui.get("name_error"), ui.get("name_error_title"), ERRORBOX)







|
>
>
>







310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
        }
        xGridDataModel = self.xGridModel.GridDataModel
        xGridDataModel.addRow(xGridDataModel.RowCount + 1, self._getValuesForRow(sRuleName))
        xGridDataModel.sortByColumn(0, True)
        self._clearAddFields()

    def _getValuesForRow (self, sRuleName):
        return (sRuleName, self.dRules[sRuleName]["sPattern"],
                self.dRules[sRuleName]["sRepl"],
                "✓"  if self.dRules[sRuleName]["bRegex"]  else "",
                "✓"  if self.dRules[sRuleName]["bCaseSens"]  else "")

    def _checkRuleName (self, sRuleName):
        return re.search(r"^\w[\w_#.,;!?-]{,14}$", sRuleName)

    def modifyRule (self):
        if not self._checkRuleName(self.xEditName.Text):
            MessageBox(self.xDocument, ui.get("name_error"), ui.get("name_error_title"), ERRORBOX)