Index: src/ch/FilterDlg.cpp =================================================================== diff -u -r9250a0229add10f4315e76848c755f337a16ae95 -r63369021254e8b67ffeef5a9ece1b5a70df881c4 --- src/ch/FilterDlg.cpp (.../FilterDlg.cpp) (revision 9250a0229add10f4315e76848c755f337a16ae95) +++ src/ch/FilterDlg.cpp (.../FilterDlg.cpp) (revision 63369021254e8b67ffeef5a9ece1b5a70df881c4) @@ -21,6 +21,7 @@ #include "FilterDlg.h" #include "resource.h" #include "../libstring/TStringArray.h" +#include #ifdef _DEBUG #define new DEBUG_NEW @@ -338,8 +339,7 @@ void CFilterDlg::OnOK() { UpdateData(TRUE); - - // TFileFilter --> dialogu - mask + CString strText; m_ctlIncludeMask.GetWindowText(strText); m_ffFilter.SetUseMask(((m_bFilter != 0) && !strText.IsEmpty())); @@ -386,6 +386,18 @@ m_ffFilter.SetSystem(m_iSystem); m_ffFilter.SetDirectory(m_iDirectory); + if(!FilterTypesMenuWrapper::ValidateFilter(m_ffFilter.GetIncludeMask())) + { + m_ctlIncludeMask.SetFocus(); + return; + } + + if(!FilterTypesMenuWrapper::ValidateFilter(m_ffFilter.GetExcludeMask())) + { + m_ctlExcludeMask.SetFocus(); + return; + } + CLanguageDialog::OnOK(); } Index: src/ch/FilterTypesMenuWrapper.cpp =================================================================== diff -u -r9250a0229add10f4315e76848c755f337a16ae95 -r63369021254e8b67ffeef5a9ece1b5a70df881c4 --- src/ch/FilterTypesMenuWrapper.cpp (.../FilterTypesMenuWrapper.cpp) (revision 9250a0229add10f4315e76848c755f337a16ae95) +++ src/ch/FilterTypesMenuWrapper.cpp (.../FilterTypesMenuWrapper.cpp) (revision 63369021254e8b67ffeef5a9ece1b5a70df881c4) @@ -3,6 +3,7 @@ #include "ch.h" #include "resource.h" #include "../libstring/TStringArray.h" +#include void FilterTypesMenuWrapper::Init() { @@ -53,3 +54,29 @@ } } } + +bool FilterTypesMenuWrapper::ValidateFilter(const chcore::TStringPatternArray& arrPattern) +{ + CStringA strMsg; + try + { + arrPattern.MatchesAny(chcore::PathFromString(L"")); + } + catch(const std::regex_error& e) + { + strMsg = e.what(); + } + + if(!strMsg.IsEmpty()) + { + CString strFmt; + strFmt.Format(L"%S", (PCSTR)strMsg); + + ictranslate::CFormat fmt(GetResManager().LoadString(IDS_INVALID_FILTER)); + fmt.SetParam(_T("%err"), strFmt); + AfxMessageBox(fmt.ToString()); + return false; + } + + return true; +} Index: src/ch/FilterTypesMenuWrapper.h =================================================================== diff -u -r9250a0229add10f4315e76848c755f337a16ae95 -r63369021254e8b67ffeef5a9ece1b5a70df881c4 --- src/ch/FilterTypesMenuWrapper.h (.../FilterTypesMenuWrapper.h) (revision 9250a0229add10f4315e76848c755f337a16ae95) +++ src/ch/FilterTypesMenuWrapper.h (.../FilterTypesMenuWrapper.h) (revision 63369021254e8b67ffeef5a9ece1b5a70df881c4) @@ -18,6 +18,8 @@ // ============================================================================ #pragma once +#include "../libchcore/TStringPatternArray.h" + class FilterTypesMenuWrapper { public: @@ -28,6 +30,8 @@ void OnCommand(int iCommandID, CComboBox& rCombo); + static bool ValidateFilter(const chcore::TStringPatternArray& strFilter); + private: bool m_bTracksIncludeButton = false; CMenu m_menuFilterType; Index: src/ch/RuleEditAlreadyExistsDlg.cpp =================================================================== diff -u -r9250a0229add10f4315e76848c755f337a16ae95 -r63369021254e8b67ffeef5a9ece1b5a70df881c4 --- src/ch/RuleEditAlreadyExistsDlg.cpp (.../RuleEditAlreadyExistsDlg.cpp) (revision 9250a0229add10f4315e76848c755f337a16ae95) +++ src/ch/RuleEditAlreadyExistsDlg.cpp (.../RuleEditAlreadyExistsDlg.cpp) (revision 63369021254e8b67ffeef5a9ece1b5a70df881c4) @@ -217,6 +217,18 @@ // response m_rule.SetResult(m_comboResponse.GetSelectedValue()); + if(!FilterTypesMenuWrapper::ValidateFilter(m_rule.GetIncludeMask())) + { + m_ctlIncludeMask.SetFocus(); + return; + } + + if(!FilterTypesMenuWrapper::ValidateFilter(m_rule.GetExcludeMask())) + { + m_ctlExcludeMask.SetFocus(); + return; + } + CLanguageDialog::OnOK(); } Index: src/ch/RuleEditErrorDlg.cpp =================================================================== diff -u -r9250a0229add10f4315e76848c755f337a16ae95 -r63369021254e8b67ffeef5a9ece1b5a70df881c4 --- src/ch/RuleEditErrorDlg.cpp (.../RuleEditErrorDlg.cpp) (revision 9250a0229add10f4315e76848c755f337a16ae95) +++ src/ch/RuleEditErrorDlg.cpp (.../RuleEditErrorDlg.cpp) (revision 63369021254e8b67ffeef5a9ece1b5a70df881c4) @@ -214,6 +214,18 @@ // response m_rule.SetResult(m_comboResponse.GetSelectedValue()); + if(!FilterTypesMenuWrapper::ValidateFilter(m_rule.GetIncludeMask())) + { + m_ctlIncludeMask.SetFocus(); + return; + } + + if(!FilterTypesMenuWrapper::ValidateFilter(m_rule.GetExcludeMask())) + { + m_ctlExcludeMask.SetFocus(); + return; + } + CLanguageDialog::OnOK(); } Index: src/ch/RuleEditNotEnoughSpaceDlg.cpp =================================================================== diff -u -r9250a0229add10f4315e76848c755f337a16ae95 -r63369021254e8b67ffeef5a9ece1b5a70df881c4 --- src/ch/RuleEditNotEnoughSpaceDlg.cpp (.../RuleEditNotEnoughSpaceDlg.cpp) (revision 9250a0229add10f4315e76848c755f337a16ae95) +++ src/ch/RuleEditNotEnoughSpaceDlg.cpp (.../RuleEditNotEnoughSpaceDlg.cpp) (revision 63369021254e8b67ffeef5a9ece1b5a70df881c4) @@ -155,6 +155,18 @@ // response m_rule.SetResult(m_comboResponse.GetSelectedValue()); + if(!FilterTypesMenuWrapper::ValidateFilter(m_rule.GetIncludeMask())) + { + m_ctlIncludeMask.SetFocus(); + return; + } + + if(!FilterTypesMenuWrapper::ValidateFilter(m_rule.GetExcludeMask())) + { + m_ctlExcludeMask.SetFocus(); + return; + } + CLanguageDialog::OnOK(); } Index: src/ch/ch.rc =================================================================== diff -u -r9250a0229add10f4315e76848c755f337a16ae95 -r63369021254e8b67ffeef5a9ece1b5a70df881c4 --- src/ch/ch.rc (.../ch.rc) (revision 9250a0229add10f4315e76848c755f337a16ae95) +++ src/ch/ch.rc (.../ch.rc) (revision 63369021254e8b67ffeef5a9ece1b5a70df881c4) @@ -469,8 +469,8 @@ LTEXT "size of destination file",IDC_DST_SIZE_STATIC,176,96,103,8 RTEXT "Date of source file",IDC_SOURCE_DATE_STATIC,15,129,103,8 LTEXT "date of destination file",IDC_DST_DATE_STATIC,176,129,103,8 - CONTROL "...",IDC_INCLUDE_MASK_BUTTON,"MfcButton",WS_TABSTOP,267,34,17,12 - CONTROL "...",IDC_EXCLUDE_MASK_BUTTON,"MfcButton",WS_TABSTOP,267,63,17,12 + CONTROL "...",IDC_INCLUDE_MASK_BUTTON,"MfcButton",WS_TABSTOP,267,34,17,13 + CONTROL "...",IDC_EXCLUDE_MASK_BUTTON,"MfcButton",WS_TABSTOP,267,63,17,13 END IDD_RULE_EDIT_ERROR_DIALOG DIALOGEX 0, 0, 291, 219 @@ -495,8 +495,8 @@ LTEXT "...then respond with:",IDC_RESPONSE_STATIC,7,155,277,8 COMBOBOX IDC_RESPONSE_COMBO,15,168,269,133,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP EDITTEXT IDC_FILTER_BY_SYSTEMERROR_EDIT,15,126,269,14,ES_AUTOHSCROLL | ES_NUMBER - CONTROL "...",IDC_INCLUDE_MASK_BUTTON,"MfcButton",WS_TABSTOP,267,34,17,12 - CONTROL "...",IDC_EXCLUDE_MASK_BUTTON,"MfcButton",WS_TABSTOP,267,63,17,12 + CONTROL "...",IDC_INCLUDE_MASK_BUTTON,"MfcButton",WS_TABSTOP,267,34,17,13 + CONTROL "...",IDC_EXCLUDE_MASK_BUTTON,"MfcButton",WS_TABSTOP,267,63,17,13 END IDD_RULE_EDIT_NOTENOUGHSPACE_DIALOG DIALOGEX 0, 0, 291, 157 @@ -515,8 +515,8 @@ LTEXT "When all of the following conditions are met...:",IDC_HEADER_STATIC,7,7,277,8 LTEXT "...then respond with:",IDC_RESPONSE_STATIC,7,92,277,8 COMBOBOX IDC_RESPONSE_COMBO,15,105,269,133,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "...",IDC_INCLUDE_MASK_BUTTON,"MfcButton",WS_TABSTOP,267,34,17,12 - CONTROL "...",IDC_EXCLUDE_MASK_BUTTON,"MfcButton",WS_TABSTOP,267,63,17,12 + CONTROL "...",IDC_INCLUDE_MASK_BUTTON,"MfcButton",WS_TABSTOP,267,34,17,13 + CONTROL "...",IDC_EXCLUDE_MASK_BUTTON,"MfcButton",WS_TABSTOP,267,63,17,13 END IDD_RULE_EDIT_ALL_DIALOG DIALOGEX 0, 0, 351, 341 @@ -1884,6 +1884,7 @@ IDS_STATUS_LOADERROR_STRING "Load error" IDS_EXPORTING_TASK_FAILED "Exporting task data failed. Reason: %reason." IDS_LOGFILEEMPTY_STRING "Log file is empty" + IDS_INVALID_FILTER "Invalid filter:\n%err" END STRINGTABLE Index: src/ch/ch.vc140.vcxproj.filters =================================================================== diff -u -r9250a0229add10f4315e76848c755f337a16ae95 -r63369021254e8b67ffeef5a9ece1b5a70df881c4 --- src/ch/ch.vc140.vcxproj.filters (.../ch.vc140.vcxproj.filters) (revision 9250a0229add10f4315e76848c755f337a16ae95) +++ src/ch/ch.vc140.vcxproj.filters (.../ch.vc140.vcxproj.filters) (revision 63369021254e8b67ffeef5a9ece1b5a70df881c4) @@ -273,7 +273,9 @@ Source Files\GUI\Utils - + + Source Files\GUI\Utils + @@ -469,7 +471,7 @@ Source Files\GUI\Dialogs\Feedback rule editor - Source Files + Source Files\GUI\Utils Index: src/ch/resource.h =================================================================== diff -u -r31be0106a2d78fd0ddcb735f5351658abe56dc48 -r63369021254e8b67ffeef5a9ece1b5a70df881c4 --- src/ch/resource.h (.../resource.h) (revision 31be0106a2d78fd0ddcb735f5351658abe56dc48) +++ src/ch/resource.h (.../resource.h) (revision 63369021254e8b67ffeef5a9ece1b5a70df881c4) @@ -804,6 +804,7 @@ #define IDS_STATUS_LOADERROR_STRING 21555 #define IDS_EXPORTING_TASK_FAILED 21556 #define IDS_LOGFILEEMPTY_STRING 21558 +#define IDS_INVALID_FILTER 21559 #define ID_POPUP_SHOW_STATUS 32773 #define ID_POPUP_TIME_CRITICAL 32774 #define ID_POPUP_HIGHEST 32775 Index: src/libchengine/FeedbackAlreadyExistsRule.h =================================================================== diff -u -r22c7d5559ca17c9b1859d2283b667516b23ac597 -r63369021254e8b67ffeef5a9ece1b5a70df881c4 --- src/libchengine/FeedbackAlreadyExistsRule.h (.../FeedbackAlreadyExistsRule.h) (revision 22c7d5559ca17c9b1859d2283b667516b23ac597) +++ src/libchengine/FeedbackAlreadyExistsRule.h (.../FeedbackAlreadyExistsRule.h) (revision 63369021254e8b67ffeef5a9ece1b5a70df881c4) @@ -72,6 +72,9 @@ string::TString GetCombinedExcludeMask() const; void SetCombinedExcludeMask(const string::TString& strMask); + const chcore::TStringPatternArray& GetIncludeMask() const { return m_spaMask; } + const chcore::TStringPatternArray& GetExcludeMask() const { return m_spaExcludeMask; } + bool GetUseDateCompare() const; void SetUseDateCompare(bool bUseDateCompare); Index: src/libchengine/FeedbackErrorRule.h =================================================================== diff -u -r22c7d5559ca17c9b1859d2283b667516b23ac597 -r63369021254e8b67ffeef5a9ece1b5a70df881c4 --- src/libchengine/FeedbackErrorRule.h (.../FeedbackErrorRule.h) (revision 22c7d5559ca17c9b1859d2283b667516b23ac597) +++ src/libchengine/FeedbackErrorRule.h (.../FeedbackErrorRule.h) (revision 63369021254e8b67ffeef5a9ece1b5a70df881c4) @@ -73,6 +73,9 @@ string::TString GetCombinedExcludeMask() const; void SetCombinedExcludeMask(const string::TString& strMask); + const chcore::TStringPatternArray& GetIncludeMask() const { return m_spaMask; } + const chcore::TStringPatternArray& GetExcludeMask() const { return m_spaExcludeMask; } + bool GetUseErrorType() const; void SetUseErrorType(bool bUseErrorType); EFileError GetErrorType() const; Index: src/libchengine/FeedbackNotEnoughSpaceRule.h =================================================================== diff -u -r22c7d5559ca17c9b1859d2283b667516b23ac597 -r63369021254e8b67ffeef5a9ece1b5a70df881c4 --- src/libchengine/FeedbackNotEnoughSpaceRule.h (.../FeedbackNotEnoughSpaceRule.h) (revision 22c7d5559ca17c9b1859d2283b667516b23ac597) +++ src/libchengine/FeedbackNotEnoughSpaceRule.h (.../FeedbackNotEnoughSpaceRule.h) (revision 63369021254e8b67ffeef5a9ece1b5a70df881c4) @@ -69,6 +69,9 @@ string::TString GetCombinedExcludeMask() const; void SetCombinedExcludeMask(const string::TString& strMask); + const chcore::TStringPatternArray& GetIncludeMask() const { return m_spaMask; } + const chcore::TStringPatternArray& GetExcludeMask() const { return m_spaExcludeMask; } + EFeedbackResult GetResult() const; void SetResult(EFeedbackResult eResult); Index: src/libchengine/TFileFilter.h =================================================================== diff -u -r22c7d5559ca17c9b1859d2283b667516b23ac597 -r63369021254e8b67ffeef5a9ece1b5a70df881c4 --- src/libchengine/TFileFilter.h (.../TFileFilter.h) (revision 22c7d5559ca17c9b1859d2283b667516b23ac597) +++ src/libchengine/TFileFilter.h (.../TFileFilter.h) (revision 63369021254e8b67ffeef5a9ece1b5a70df881c4) @@ -120,6 +120,9 @@ string::TString GetCombinedExcludeMask() const; void SetCombinedExcludeMask(const string::TString& pMask); + const chcore::TStringPatternArray& GetIncludeMask() const { return m_astrMask; } + const chcore::TStringPatternArray& GetExcludeMask() const { return m_astrExcludeMask; } + bool GetUseSize1() const; void SetUseSize1(bool bUseSize1);