diff --git a/build/RegisterEmail.cpp b/build/RegisterEmail.cpp new file mode 100644 index 0000000..59535aa --- /dev/null +++ b/build/RegisterEmail.cpp @@ -0,0 +1,424 @@ +#include "ConnectionCommunity.h" +#include "GUIHelper.h" +#include "CommonHelper.h" +#include "Http.h" +#include + +#define VERIFIED "WinReg" + +extern PGLOBALS pGlobals; + +CRegInfoCommunity::CRegInfoCommunity() +{ + m_hlinkfont = NULL; + m_hlinkfont2 = NULL; + m_tracking = wyFalse; +} + +CRegInfoCommunity::~CRegInfoCommunity() +{ + if(m_hlinkfont) + DeleteFont(m_hlinkfont); + + if(m_hlinkfont2) + DeleteFont(m_hlinkfont2); +} + +wyInt32 +CRegInfoCommunity::Show(HWND hwndParent, wyInt32 isregistered) +{ + wyInt32 ret; + m_isRegistered = Registered(); + if(m_isRegistered == 0) + { + ret = DialogBoxParam(pGlobals->m_hinstance, MAKEINTRESOURCE(IDD_REGISTERSPLASH), + hwndParent, CRegInfoCommunity::DlgProc, (LPARAM)this); + return ret; + } + return 99; +} + +wyInt32 + CRegInfoCommunity::Registered() +{ + HKEY key; + DWORD dwdisverified = REG_BINARY, dwverfieddata = SIZE_128-1, dwdisposition ; + wyChar verifiedword[SIZE_128]={0}; + VERIFY((RegCreateKeyEx(HKEY_CURRENT_USER, TEXT(REGKEY), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE, NULL, &key, &dwdisposition))== ERROR_SUCCESS); + + if(RegQueryValueEx(key, TEXT(VERIFIED), 0, &dwdisverified,(BYTE*)verifiedword, &dwverfieddata)!= ERROR_SUCCESS) + return 0; + else + return 1; +} + +INT_PTR CALLBACK +CRegInfoCommunity::DlgProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) +{ + CRegInfoCommunity* pcreg = (CRegInfoCommunity*)GetWindowLongPtr(hwnd, GWLP_USERDATA); + HICON hicon; + + switch(message) + { + case WM_INITDIALOG: + { + SetWindowLongPtr(hwnd, GWLP_USERDATA, lparam); + LocalizeWindow(hwnd); + PostMessage(hwnd, WM_INITDLGVALUES, 0, 0); + // changing the text of the buying URL displayed + SetWindowText(GetDlgItem(hwnd, IDC_LINK), TEXT(BUYLABEL)); + // Adding logo in the trialsplash + hicon = LoadIcon(pGlobals->m_hinstance, MAKEINTRESOURCE(IDI_MAIN)); + SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hicon); + DestroyIcon(hicon); + } + break; + + case WM_CTLCOLORSTATIC: + return pcreg->OnWmCtlcolorStatic(wparam, lparam); + break; + + case WM_INITDLGVALUES: + pcreg->OnWmInitDlgValues(hwnd); + break; + + case WM_COMMAND: + pcreg->OnWmCommand(hwnd, wparam); + } + + return 0; +} + +/* we use 32649 magic number as IDC_HAND is not defined in WINVER < 0x400 */ + +LRESULT CALLBACK +CRegInfoCommunity::StaticDlgProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) +{ + CRegInfoCommunity * pcreg = (CRegInfoCommunity*)GetWindowLongPtr(hwnd, GWLP_USERDATA); + + switch(message) + { + case WM_MOUSEMOVE: + SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(32649))); + return 0; + } + + return CallWindowProc(pcreg->m_wporigstaticproc, hwnd, message, wparam, lparam); +} + +LRESULT CALLBACK +CRegInfoCommunity::ImageDlgProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) +{ + CRegInfoCommunity * pcreg = (CRegInfoCommunity*)GetWindowLongPtr(hwnd, GWLP_USERDATA); + + switch(message) + { + case WM_MOUSEMOVE: + SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(32649))); + return 0; + } + + return CallWindowProc(pcreg->m_wporigimageproc, hwnd, message, wparam, lparam); +} + +void +CRegInfoCommunity::InitValues() +{ + if(m_isRegistered == 0) + { + ShowEmailWindow(); + } +} + +wyInt32 + CRegInfoCommunity::CheckValidEmail() +{ + wyWChar trial_email[SIZE_128]={0}; + wyString tempmail, str ; + wyString httppasscode; + wyInt32 ret; + + // get the name. + GetWindowText(GetDlgItem(m_hwnddlg, IDC_TRIALEMAIL), (wyWChar*)trial_email, SIZE_128-1); + + if(wcslen(trial_email)== 0) + { + yog_message(m_hwnddlg, _(L"Please enter your email"), pGlobals->m_appname.GetAsWideChar(), MB_OK | MB_ICONINFORMATION); + return -1; + } + tempmail.SetAs(trial_email); + tempmail.LTrim(); + tempmail.RTrim(); + m_newmail.SetAs(tempmail.GetString()); + + if(m_newmail.Compare(m_oldmail) != 0) + { + // Will generate the new passcode only when the new email id is different from the old email id + m_oldmail.SetAs(tempmail.GetString()); + m_passcode.SetAs(""); + m_passcode.AddSprintf("%d",GeneratePasscode()); + } + + if(m_passcode.GetLength() == 0) + { + m_passcode.SetAs(""); + m_passcode.AddSprintf("%d",GeneratePasscode()); + } + + httppasscode.SetAs("http://www.webyog.com/mailmgr/sqlyog_verification?email="); + httppasscode.AddSprintf(tempmail.GetString()); + httppasscode.AddSprintf("&passcode=%s",m_passcode.GetString()); + httppasscode.AddSprintf("&MajorVersion=%s&MinorVersion=%s&UpdateVersion=%s",MAJOR_VERSION,MINOR_VERSION,UPDATE_VERSION); + m_httpreqcode.SetAs(httppasscode.GetString()); + + ret = SendPasscodeRequest(); // Send the passcode email request to webyog server + + return ret; +} + +//Activates and deactivates controls w.r.t. the passcode verification window of trialsplash dialog +void + CRegInfoCommunity::ShowPasscodeWindow() +{ + + EnableWindow(GetDlgItem(m_hwnddlg, IDM_VERIFY),TRUE); + ShowWindow(GetDlgItem(m_hwnddlg, IDC_TITLE), FALSE); + ShowWindow(GetDlgItem(m_hwnddlg, IDC_TRIALEMAIL),FALSE); + ShowWindow(GetDlgItem(m_hwnddlg, IDM_NEXT),FALSE); + ShowWindow(GetDlgItem(m_hwnddlg, IDC_PROGRESS),FALSE); + ShowWindow(GetDlgItem(m_hwnddlg, IDOK), FALSE); + + ShowWindow(GetDlgItem(m_hwnddlg, IDC_TITLE2), TRUE); + ShowWindow(GetDlgItem(m_hwnddlg, IDC_TRIALNOTESTATIC), TRUE); + SendMessage(GetDlgItem(m_hwnddlg, IDC_TRIALNOTESTATIC), WM_SETTEXT, 0,(LPARAM)_(L"If you don't receive the passcode in the inbox within 2 minutes, try looking into the spam folder. Still haven't found it? Click on Resend.")); + ShowWindow(GetDlgItem(m_hwnddlg, IDC_PASSCODE),TRUE); + SendMessage(GetDlgItem(m_hwnddlg, IDC_PASSCODE), WM_SETTEXT, 0,(LPARAM)_(L"")); + ShowWindow(GetDlgItem(m_hwnddlg, IDM_BACK), TRUE); + ShowWindow(GetDlgItem(m_hwnddlg, IDM_RESEND),TRUE); + ShowWindow(GetDlgItem(m_hwnddlg, IDM_VERIFY),TRUE); +} + +// Activates and deactivates controls w.r.t. the email window of trialsplash dialog +void + CRegInfoCommunity::ShowEmailWindow() +{ + ShowWindow(GetDlgItem(m_hwnddlg, IDC_TITLE), TRUE); + ShowWindow(GetDlgItem(m_hwnddlg, IDC_TRIALEMAIL),TRUE); + ShowWindow(GetDlgItem(m_hwnddlg, IDC_TRIALNOTESTATIC), TRUE); + SendMessage(GetDlgItem(m_hwnddlg, IDC_TRIALNOTESTATIC), WM_SETTEXT, 0,(LPARAM)_(L"You will receive passcode in the email provided above. Click Next to receive passcode:")); +// ShowWindow(GetDlgItem(m_hwnddlg, IDM_BUY),TRUE); + ShowWindow(GetDlgItem(m_hwnddlg, IDM_NEXT),TRUE); + + ShowWindow(GetDlgItem(m_hwnddlg, IDOK), FALSE); + ShowWindow(GetDlgItem(m_hwnddlg, IDC_TITLE2), FALSE); + ShowWindow(GetDlgItem(m_hwnddlg, IDC_PASSCODE),FALSE); + ShowWindow(GetDlgItem(m_hwnddlg, IDM_BACK), FALSE); + ShowWindow(GetDlgItem(m_hwnddlg, IDM_RESEND),FALSE); + ShowWindow(GetDlgItem(m_hwnddlg, IDM_VERIFY),FALSE); + EnableWindow(GetDlgItem(m_hwnddlg, IDM_VERIFY),FALSE); +} + +// Verify the entered passcode +wyInt32 + CRegInfoCommunity::PasscodeVerification() +{ + wyWChar passcode_entered[SIZE_64]={0}; + wyString passcode; + wyInt32 ret; + GetWindowText(GetDlgItem(m_hwnddlg, IDC_PASSCODE), (wyWChar*)passcode_entered, SIZE_64-1); + passcode.SetAs(passcode_entered); + if(passcode.Compare(m_passcode.GetString()) == 0) + { + m_httpreqcode.AddSprintf("&isVerified=Y"); + ret = SendPasscodeVerifiedStatus(); + if(ret == 0) + { + yog_message(m_hwnddlg, _(L"Verification failed. Check your internet connectivity."), pGlobals->m_appname.GetAsWideChar(), MB_OK | MB_ICONINFORMATION); + return -1; + } + yog_message(m_hwnddlg, _(L"Passcode verified successfully."), pGlobals->m_appname.GetAsWideChar(), MB_OK | MB_ICONINFORMATION); + AddVerifiedToRegistry(); + return 1; + } + else + { + yog_message(m_hwnddlg, _(L"Invalid passcode. Please try again."), pGlobals->m_appname.GetAsWideChar(), MB_OK | MB_ICONINFORMATION); + return -1; + } +} + +wyInt32 +CRegInfoCommunity::OnWmCtlcolorStatic(WPARAM wparam, LPARAM lparam) +{ + wyInt32 identifier; + HDC hdc = (HDC)wparam; + DWORD fontheight; + + identifier = GetDlgCtrlID((HWND)lparam); + + if(identifier == IDC_LINK) + { + fontheight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72); + + if(!m_hlinkfont2) + m_hlinkfont2 = CreateFont(fontheight, 0, 0, 0, FW_BOLD, 0, TRUE, 0, 0, 0, 0, 0, 0, L"Verdana"); + SelectObject(hdc, m_hlinkfont2); + SetBkMode(hdc, TRANSPARENT); + SetTextColor(hdc, RGB(0, 0, 255)); + + return(BOOL)GetStockObject(HOLLOW_BRUSH); + } + else if(identifier == IDC_TRIALSTATIC) + { + fontheight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72); + + if(!m_hlinkfont2) + m_hlinkfont2 = CreateFont(fontheight, 0, 0, 0, FW_BOLD, 0, FALSE, 0, 0, 0, 0, 0, 0, L"Verdana"); + SelectObject(hdc, m_hlinkfont2); + SetBkMode(hdc, TRANSPARENT); + SetTextColor(hdc, RGB(0, 0, 0)); + + return(BOOL)GetStockObject(HOLLOW_BRUSH); + } + else + { + fontheight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72); + if(!m_hlinkfont) + m_hlinkfont = CreateFont(fontheight, 0, 0, 0, 0, 0, FALSE, 0, 0, 0, 0, 0, 0, L"Verdana"); + SelectObject(hdc, m_hlinkfont); + SetBkMode(hdc, TRANSPARENT); + SetTextColor(hdc, RGB(0, 0, 0)); + return 0; + } +} + +void +CRegInfoCommunity::OnWmInitDlgValues(HWND hwnd) +{ + HWND hwndstatic = GetDlgItem(hwnd, IDC_LINK); + HWND hwndimg = GetDlgItem(hwnd, IDC_IMAGELINK); + + m_hwnddlg = hwnd; + InitValues(); + + m_wporigstaticproc = (WNDPROC)SetWindowLongPtr(hwndstatic, GWLP_WNDPROC, (LONG_PTR)StaticDlgProc); + SetWindowLongPtr(hwndstatic, GWLP_USERDATA,(LONG_PTR)this); + + m_wporigimageproc = (WNDPROC)SetWindowLongPtr(hwndimg, GWLP_WNDPROC, (LONG_PTR)ImageDlgProc); + SetWindowLongPtr(hwndimg, GWLP_USERDATA,(LONG_PTR)this); + + return; +} + +void +CRegInfoCommunity::OnWmCommand(HWND hwnd, WPARAM wparam) +{ + wyString msg; + wyInt32 ret; + switch(LOWORD(wparam)) + { + case IDOK: + break; + + case IDCANCEL: + yog_enddialog(hwnd, TRIAL_CLOSE); + break; + + case IDM_NEXT: + ret = CRegInfoCommunity::CheckValidEmail(); + if(ret == -1 ) + break; + if( ret == 1 ) + { + CRegInfoCommunity::ShowPasscodeWindow(); + } + break; + + case IDM_VERIFY: + ret = CRegInfoCommunity::PasscodeVerification(); + if( ret == 1 ) + yog_enddialog(hwnd, TRIAL_LATER); + + break; + + case IDM_RESEND: + ret = CRegInfoCommunity::SendPasscodeRequest(); + break; + + case IDM_BACK: + CRegInfoCommunity::ShowEmailWindow(); + break; + + + case IDC_LITE: + yog_enddialog(hwnd, TRIAL_LITE); + break; + } + + if((HIWORD(wparam)== STN_CLICKED)) + { + if(LOWORD(wparam)== IDC_LINK) + ShellExecute(NULL, L"open", TEXT(BUYURL), NULL, NULL, SW_SHOWNORMAL); + else if(LOWORD(wparam)== IDC_IMAGELINK) + ShellExecute(NULL, L"open", TEXT(IMAGEURL), NULL, NULL, SW_SHOWNORMAL); + } + + return; +} + +wyBool + CRegInfoCommunity::AddVerifiedToRegistry() +{ + DWORD dwdisposition; + HKEY key; + VERIFY((RegCreateKeyEx(HKEY_CURRENT_USER, TEXT(REGKEY), 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_READ | KEY_WRITE, NULL, &key, &dwdisposition))== ERROR_SUCCESS); + + VERIFY(RegSetValueEx(key, TEXT(VERIFIED), 0, REG_BINARY, (UCHAR*)m_newmail.GetString(), sizeof(DWORD))== ERROR_SUCCESS); + VERIFY(RegCloseKey(key)== ERROR_SUCCESS); + return wyTrue; +} + +wyInt32 + CRegInfoCommunity::SendPasscodeRequest() +{ + CHttp http; + int status; + + http.SetUrl(m_httpreqcode.GetAsWideChar()); + http.SetContentType(L"text/xml"); + + if(!http.SendData("abc", 3, false, &status, false )) + { + yog_message(m_hwnddlg, _(L"Passcode not sent. Please try again."),pGlobals->m_appname.GetAsWideChar(), MB_OK | MB_ICONINFORMATION); + return 0; // internet connectivity issue + } + + yog_message(m_hwnddlg, _(L"Passcode request sent successfully."),pGlobals->m_appname.GetAsWideChar(), MB_OK | MB_ICONINFORMATION); + return 1; +} + +wyInt32 + CRegInfoCommunity::SendPasscodeVerifiedStatus() +{ + CHttp http; + int status; + wyString httpreqverified; + httpreqverified.SetAs(""); + httpreqverified.AddSprintf("http://www.webyog.com/mailmgr/sqlyog_verified?email=%s&is_verified=Y",m_newmail.GetString()); + http.SetUrl(httpreqverified.GetAsWideChar()); + http.SetContentType(L"text/xml"); + + if(!http.SendData("abc", 3, false, &status, false )) + { + return 0; // internet connectivity issue + } + return 1; +} + +wyInt32 + CRegInfoCommunity::GeneratePasscode() +{ + srand(time(NULL)); + return rand()%10*1000+rand()%10*100+rand()%10*10+rand()%10; +} \ No newline at end of file diff --git a/build/SQLyogCommunity.vcxproj b/build/SQLyogCommunity.vcxproj index e663c47..3207496 100644 --- a/build/SQLyogCommunity.vcxproj +++ b/build/SQLyogCommunity.vcxproj @@ -335,6 +335,7 @@ + $(IntDir)%(Filename)1.obj $(IntDir)%(Filename)1.obj @@ -482,6 +483,7 @@ + diff --git a/build/SQLyogCommunity.vcxproj.filters b/build/SQLyogCommunity.vcxproj.filters index 94cf05e..85fd48a 100644 --- a/build/SQLyogCommunity.vcxproj.filters +++ b/build/SQLyogCommunity.vcxproj.filters @@ -360,6 +360,9 @@ Source Files + + Source Files + @@ -710,6 +713,9 @@ Header Files + + Header Files + diff --git a/include/AppInfo.h b/include/AppInfo.h index 4ab833a..9a11f2f 100644 --- a/include/AppInfo.h +++ b/include/AppInfo.h @@ -38,7 +38,7 @@ #define SQLITE_APPVERSION_MAJOR "10" #define SQLITE_APPVERSION_MINOR "5" -#define COMPANY_COPYRIGHT "(c) 2001-2018 Webyog Inc." +#define COMPANY_COPYRIGHT "(c) 2001-2019 Webyog Inc." #define FILEVER MAJOR_VERSION_INT ## , ## MINOR_VERSION_INT ## , ## UPDATE_VERSION_INT ## , ## RELEASE_VERSION_INT #define STRFILEVER MAJOR_VERSION "." MINOR_VERSION "." STRINGIZE(UPDATE_VERSION_INT) "." STRINGIZE(RELEASE_VERSION_INT) diff --git a/include/CalendarCtrl.h b/include/CalendarCtrl.h index b83d435..5e26b21 100644 --- a/include/CalendarCtrl.h +++ b/include/CalendarCtrl.h @@ -138,7 +138,10 @@ class CalendarCtrl void OnClickOk(); //Handles click of the OK button - void OnClickNow(); + void OnClickNow(DataView *m_dv); + + //Get preference to show server date and time when click on NOW button + wyBool GetPreferenceForNowButton(); //Handles click of the Cancel button void OnClickCancel(); diff --git a/include/CommonHelper.h b/include/CommonHelper.h index 41b5579..bdf3b65 100644 --- a/include/CommonHelper.h +++ b/include/CommonHelper.h @@ -59,6 +59,7 @@ #define FMT_SPACE_4 " " + #define REGKEY "Use any UUID here" @@ -547,6 +548,18 @@ wyBool CheckForOnUpdate(wyString &strcreate, wyInt32 fieldpos); */ wyBool GetExpressionValue(wyChar * currentrow, wyString * expression); +//get the check constraint expression value by parsing the current row definition +/** +@param currentrow : FIELD definiton in create table statement +@param expression : Value of expression used +@returns wyTrue on success else wyFalse +*/ +wyBool GetCheckConstraintValue(wyChar * currentrow, wyString * expression); +wyBool GettablelevelCheckConstraintValue(wyChar * currentrow, wyString * expression); +void CheckForQuotesAndReplace(wyString *name); + +wyBool GetCheckConstraintName(wyChar * currentrow, wyString * checkconstraintname); + wyInt32 GetBitFieldColumnWidth(wyString &strcreate, wyInt32 fieldpos); /// Gets the module filename length. @@ -961,6 +974,8 @@ void RotateBitLeft (unsigned char *str); void RemoveDefiner(wyString &text, const wyChar* pattern, wyInt32 extra); +void RemoveBrackets(wyString &text, const wyChar* pattern); + //void DebugLog(const char *buffer); #ifdef _WIN32 void WriteLog(const wyChar* str); diff --git a/include/ConnectionTab.h b/include/ConnectionTab.h index 21ddb6a..ce649a6 100644 --- a/include/ConnectionTab.h +++ b/include/ConnectionTab.h @@ -86,6 +86,8 @@ class ConnectionTab */ HWND GetActiveWindowHandle(HWND hwndtab); + //void insert(wyString tabname, opentabs *head); + /// To get tab index for active window /* @param hwndtab : IN connetiontab HANDLE diff --git a/include/CustTab.h b/include/CustTab.h index 7c9c909..993a1b2 100644 --- a/include/CustTab.h +++ b/include/CustTab.h @@ -52,6 +52,7 @@ typedef LRESULT(CALLBACK* CTBWNDPROC)(HWND, UINT, WPARAM, LPARAM, wyBool* pishan #define CTCN_PAINTTIMERSTART WM_USER+130 #define CTCN_PAINTTIMEREND WM_USER+132 #define CTCN_TABRENAME WM_USER+133 +#define CTCN_DROPDOWNBUTTONCLICK WM_USER+134 #define CTBIF_TEXT 1 #define CTBIF_IMAGE 2 @@ -235,7 +236,9 @@ class CCustTab @param isexplicit : IN whether the tab was closed with an explicti close operation @returns wyBool, wyTrue if success, otherwise wyFalse */ - wyBool DeleteItem(wyInt32 tabindex, wyBool isexplicit = wyFalse); + + //Added notdeletefromstruct Param: wyTrue denotes the tab doesn't need to remove from the drop down structure, wyFalse: remove tab details from drop down + wyBool DeleteItem(wyInt32 tabindex, wyBool isexplicit = wyFalse, wyBool notdeletefromstruct = wyFalse); /// Remove all tabs /** @@ -472,6 +475,9 @@ class CCustTab */ wyBool FreeItem(LPCTCITEMEX pitem, wyInt32 tabindex = -1); + /// Reset sequence numbers for different tabs + void ResetGlobalSequenceNumbers(wyString tabname); + /// Checks the Cursor position is over any of the tabs /** @@ -742,6 +748,10 @@ class CCustTab void CreateBottomLinePen(); + void UpdateDropDownStructPosition(wyInt32 selectedtab, wyInt32 dropindex); + void UpdateDropDownNodePosforconnection(wyInt32 selectedtab, wyInt32 dropindex); + void FindAndUpdateTheDropDown(wyInt32 selectedtab,wyInt32 dropindex); + /// Flag for tab width is fixed or not wyBool m_isfixedlength; @@ -989,7 +999,7 @@ wyInt32 CustomTab_SetMinTabWidth(HWND hwnd , wyInt32 cx); @param index : IN Index of the tab to be deleted @returns wyTrue on success else wyFalse */ -wyBool CustomTab_DeleteItem(HWND hwnd , wyInt32 index); +wyBool CustomTab_DeleteItem(HWND hwnd , wyInt32 index,wyBool isdelrequired=wyFalse); /// Function to delete all item from the tab diff --git a/include/EditorProcs.h b/include/EditorProcs.h index fc6cd26..690fd53 100644 --- a/include/EditorProcs.h +++ b/include/EditorProcs.h @@ -58,6 +58,7 @@ class EditorProcs : public EditorBase @returns (HWND)handle to AdvEdit. */ HWND CreateAdvEdit(MDIWindow *wnd, HWND hwnd, HTREEITEM hitem, wyString *strhitemname = NULL); + ///Function executes the current query. ///i.e the query in which the cursor is at the moment. diff --git a/include/FrameWindow.h b/include/FrameWindow.h index e6a0529..673b480 100644 --- a/include/FrameWindow.h +++ b/include/FrameWindow.h @@ -101,6 +101,49 @@ class MDIlisttemp : public wyElem List *m_listtabeditor_temp; }; +enum TabType +{ + querytab, + querybuilder, + schemadesigner, + datasearch, + none +}; +class ListOfOpenQueryTabs : public wyElem +{ +public: + wyString tabname; + wyInt32 seqofquerytab; + wyInt32 seqofquerybuilder; + wyInt32 seqofschemadesigner; + wyInt32 seqofdatasearch; + TabType tabtype; + ListOfOpenQueryTabs() + { + tabname = ""; + seqofquerytab = 1; + seqofquerybuilder = 1; + seqofschemadesigner = 1; + seqofdatasearch = 1; + tabtype = none; + } +}; +class MDIListForDropDrown : public wyElem +{ +public: + wyString name; + MDIWindow *mdi; + List *opentab; + //HWND m_hwndconntabinlist; + //TabModule * m_hwndTabModuleinlist; + MDIListForDropDrown() + { + name = ""; + opentab = new List(); + } +}; + + class tabdetailelem : public wyElem { public: @@ -136,6 +179,19 @@ class QueryRestore : public wyElem wyString m_content; }; +class ListofOpenTabs : public wyElem +{ + public: + wyString name; + //HWND m_hwndconntabinlist; + TabModule * m_hwndTabModuleinlist; + ListofOpenTabs() + { + name = ""; + + } +}; + class FrameWindow { @@ -653,6 +709,10 @@ class FrameWindow void LoadConnTabPlusMenu(LPARAM lparam); + //Display connection and query tab drop down menu + + void LoadConnTabDropDownMenu(LPARAM lparam); + static void CALLBACK TooltipTimerProc(HWND hwnd, UINT message, UINT_PTR id, DWORD time); static void ShowQueryExecToolTip(wyBool show = wyTrue); @@ -773,6 +833,8 @@ class FrameWindow wyInt32 m_focussedcon; + wyBool m_isresizing; + #ifdef COMMUNITY //Tab Header object @@ -1673,6 +1735,12 @@ class FrameWindow */ void OnImportConnectionDetails(); + /// Function to update dropdown structure + /** + + */ + void UpdateDropDownStruct(wyString tabname); + wyBool SaveConnectionDetails(wySQLite *ssnsqliteobj = NULL); wyBool SaveConnectionDetails2(wySQLite *ssnsqliteobj = NULL); diff --git a/include/FrameWindowSplitter.h b/include/FrameWindowSplitter.h index 01cd27d..54782a6 100644 --- a/include/FrameWindowSplitter.h +++ b/include/FrameWindowSplitter.h @@ -53,7 +53,7 @@ class FrameWindowSplitter /** @returns wyBool, wyTrue always */ - wyBool Resize(wyBool isannouncements = wyFalse); + wyBool Resize(wyBool isannouncements = wyFalse, wyBool ismanualresize =wyFalse); /// Helps to Resize connection window /** diff --git a/include/Global.h b/include/Global.h index 0ba96c6..63cec8b 100644 --- a/include/Global.h +++ b/include/Global.h @@ -609,6 +609,7 @@ typedef struct tagsqlite */ + typedef struct tagGlobals { wyInt32 m_colcount; @@ -717,6 +718,9 @@ typedef struct tagGlobals wyBool m_sessionrestore; wyString m_database; wyString m_sessionbackup; + List *m_connectiontabnamelist; + List *m_mdilistfordropdown; + } GLOBALS, *PGLOBALS; diff --git a/include/MDIWindow.h b/include/MDIWindow.h index 8732458..975c7fa 100644 --- a/include/MDIWindow.h +++ b/include/MDIWindow.h @@ -67,6 +67,7 @@ class tabeditorelem : public wyElem wyBool m_isedited; wyInt32 m_leftortoppercent; wyString m_content; + }; class TableDiag @@ -288,6 +289,9 @@ class MDIWindow { public: + wyBool m_isfromsave; + wyBool m_isfromsaveas; + wyBool m_fromdirtytab; /// Parametric constructor /** @param hwnd : Window HANDLE @@ -489,7 +493,7 @@ class MDIWindow /** @returns wyTrue */ - void Resize(); + void Resize(wyBool iswindowresize =wyFalse); /// Ask or confirmation to save file and return the value. /** @@ -759,6 +763,8 @@ class MDIWindow */ void OnWmCreate(HWND hwnd); + void DelFromQueryStruct(MDIWindow *wnd); + /// Handles the WM_CLOSE case /** @param hwnd : Window HANDLE @@ -999,7 +1005,15 @@ class MDIWindow void LoadQueryTabPlusMenu(LPARAM lparam); - void PositionTabs(wyBool isupdtabledata, wyBool isupdhistory, wyBool isupdinfo); + void LoadQueryTabDropDownMenu(HWND hwnd, WPARAM wparam, LPARAM lparam); + + void PositionTabs(wyBool isupdtabledata, wyBool isupdhistory, wyBool isupdinfo,wyBool delfromdropdown=wyFalse); + + //delete info, Table data and History tabs from drop down strct + void DelFromDropdownStruct(MDIWindow *wnd,wyInt64 index); + + void DelFromDropdownStructInfo(MDIWindow *wnd, wyInt64 index); + void DelFromDropdownStructtabledata(MDIWindow *wnd, wyInt64 index); //Function to handle Timer for keep-alive ping diff --git a/include/MySQLVersionHelper.h b/include/MySQLVersionHelper.h index f822072..514f3ff 100644 --- a/include/MySQLVersionHelper.h +++ b/include/MySQLVersionHelper.h @@ -151,6 +151,12 @@ wyBool IsMySQL565(Tunnel * tunnel, PMYSQL mysql); //mariadb 5.2 for Virtual/Persistent wyBool IsMariaDB52(Tunnel * tunnel, PMYSQL mysql); +/// Checks the server version is greater than or equal to 10.3.9 +/** +for virtual columns Persistent->Stored +*/ +wyBool IsMariaDB10309(Tunnel * tunnel, PMYSQL mysql); + //MySQL 5.7.0 for Virtual/Stored columns wyBool IsMySQL57(Tunnel * tunnel, PMYSQL mysql); @@ -198,4 +204,12 @@ wyChar *quote_for_like(const wyChar *name, wyChar *buff); */ void SetCharacterSet(Tunnel *tunnel, MYSQL * mysql, wyChar * charset); +/// Checks the server version is greater than or equal to 5.0.10 +/** +@param tunnel: IN tunnel pointer +@param mysql: IN PMYSQL value +@returns wyBool, wyTrue if it is SUCCESS, else wyFalse +*/ +wyBool IsMySQL80011(Tunnel * tunnel, PMYSQL mysql); + #endif diff --git a/include/ObjectBrowser.h b/include/ObjectBrowser.h index f464316..ff26c68 100644 --- a/include/ObjectBrowser.h +++ b/include/ObjectBrowser.h @@ -1551,6 +1551,14 @@ class CCopyTable */ wyBool GetSelectStmt(wyString &select, wyString &alterQuery , wyWChar new_table[]); + /// Function prepares the select stmt and stores it in the buffer passed as parameter. + /** + @param select : Selected items. + */ + wyBool GetCheckConstraints(wyString &select, wyString &alterQuery, wyWChar new_table[]); + + + /// Function copies the initial field stmt. into the buffer. /** @param query : Query. diff --git a/include/SQLyog.rc b/include/SQLyog.rc index 76fab7f..9a61d4d 100644 --- a/include/SQLyog.rc +++ b/include/SQLyog.rc @@ -167,22 +167,38 @@ END // IDB_GREEN BITMAP "bitmaps\\greenback.bmp" + IDB_WATERMARK BITMAP "bitmaps\\Watermrk.bmp" + IDB_BANNER BITMAP "bitmaps\\Header.bmp" + IDB_DBICON BITMAP "bitmaps\\sqlyog2.bmp" + IDB_ARROW BITMAP "bitmaps\\sqlyog3.bmp" + IDB_DSYNC1 BITMAP "bitmaps\\dsync1.bmp" + IDB_DSYNC2 BITMAP "bitmaps\\dsync2.bmp" + IDB_BLUE BITMAP "bitmaps\\blueback.bmp" + IDB_JOBBIG BITMAP "bitmaps\\jobbig.bmp" + IDB_JOBSMALL BITMAP "bitmaps\\jobsmall.bmp" + IDB_CONNECTION BITMAP "bitmaps\\connection.bmp" + IDB_SCHDBIG BITMAP "bitmaps\\schexport_big.bmp" + IDB_SCHDSMALL BITMAP "bitmaps\\schdexport_small.bmp" + IDB_SCHDODBC BITMAP "bitmaps\\odbc_schd.bmp" + IDB_COMSPLASH BITMAP "bitmaps\\splash.bmp" + IDB_TWILIGHT_THEME_BITMAP BITMAP "bitmaps\\bg.bmp" + ///////////////////////////////////////////////////////////////////////////// // // Menu @@ -296,7 +312,7 @@ BEGIN POPUP "Open" BEGIN MENUITEM "Refresh Object Browser\tF9", IDM_REFRESHOBJECT - MENUITEM "Collapse All in Object Browser\tShift+{-}", IDM_COLLAPSEOBJECT + MENUITEM "Collapse All in Object Browser\tShift+{-}", IDM_COLLAPSEOBJECT MENUITEM SEPARATOR MENUITEM "Create &Database...\tCtrl+D", IDM_CREATEDATABASE MENUITEM "New Data Searc&h\tCtrl+Shift+D", ID_DATASEARCH @@ -484,8 +500,8 @@ BEGIN BEGIN MENUITEM "Refresh &Object Browser\tF5", IDM_REFRESHOBJECT MENUITEM "Change Objec&t Browser Color\t", IDM_OBCOLOR - MENUITEM "Collapse All in Object Browser\tShift+{-}", IDM_COLLAPSEOBJECT - MENUITEM SEPARATOR + MENUITEM "Collapse All in Object Browser\tShift+{-}", IDM_COLLAPSEOBJECT + MENUITEM SEPARATOR POPUP "Execute Quer&y" BEGIN MENUITEM "Exe&cute Query\tF9", ACCEL_EXECUTE_MENU @@ -834,6 +850,14 @@ BEGIN END END +IDR_CONNDROPDOWNMENU MENU +BEGIN + POPUP "connection drop down list" + BEGIN + MENUITEM " a", IDM_DROPDOWNLISTITEM + END +END + IDR_INFOTABMENU MENU BEGIN POPUP "Object" @@ -1645,7 +1669,7 @@ BEGIN EDITTEXT IDC_MESSAGE,35,7,204,48,ES_MULTILINE | ES_READONLY | NOT WS_BORDER | WS_HSCROLL END -IDD_PREF2 DIALOGEX 0, 0, 255, 280 +IDD_PREF2 DIALOGEX 0, 0, 255, 291 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION CAPTION "Editor" FONT 8, "MS Shell Dlg", 0, 0, 0x0 @@ -1681,8 +1705,8 @@ BEGIN EDITTEXT IDC_TAB,45,232,33,13,ES_AUTOHSCROLL | ES_NUMBER CONTROL "&Insert spaces",IDC_INSERTSPACES,"Button",BS_AUTORADIOBUTTON | WS_GROUP,91,230,77,8 CONTROL "Kee&p tabs",IDC_KEEPTABS,"Button",BS_AUTORADIOBUTTON,91,242,48,8 - PUSHBUTTON "Restore &All Defaults",IDC_EDITORRESTOREALL,97,262,75,15 - PUSHBUTTON "Restore &Tab Defaults",IDC_EDITORRESTORETAB,176,262,75,15 + PUSHBUTTON "Restore &All Defaults",IDC_EDITORRESTOREALL,97,273,75,15 + PUSHBUTTON "Restore &Tab Defaults",IDC_EDITORRESTORETAB,176,273,75,15 END IDD_ADDFAVORITES DIALOGEX 0, 0, 310, 231 @@ -1829,7 +1853,7 @@ BEGIN PUSHBUTTON "Go to &Download page",IDC_DOWNLOAD,128,43,81,12 END -IDD_PREFOTHERS DIALOGEX 0, 0, 255, 280 +IDD_PREFOTHERS DIALOGEX 0, 0, 255, 291 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION CAPTION "Others" FONT 8, "MS Shell Dlg", 400, 0, 0x1 @@ -1861,8 +1885,8 @@ BEGIN COMBOBOX IDC_ICONSIZE,6,236,71,44,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP GROUPBOX "Theme ",IDC_STATIC,85,225,163,29 COMBOBOX IDC_THEMECOMBO,90,236,153,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Restore &All Defaults",IDC_OTHERSRESTOREALL,97,262,75,15 - PUSHBUTTON "Restore &Tab Defaults",IDC_OTHERSRESTORETAB,176,262,75,15 + PUSHBUTTON "Restore &All Defaults",IDC_OTHERSRESTOREALL,97,273,75,15 + PUSHBUTTON "Restore &Tab Defaults",IDC_OTHERSRESTORETAB,176,273,75,15 CONTROL "R&estore session on startup",IDC_CONRESTORE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,74,216,9 GROUPBOX "Transaction Options",IDC_TRANSACTION,4,185,247,36 CONTROL "Prompt when query causing implicit commit is executed",IDC_PROMPTTRANSACTION, @@ -1871,48 +1895,51 @@ BEGIN "Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,208,212,10 END -IDD_PREFGENERAL DIALOGEX 0, 0, 255, 280 +IDD_PREFGENERAL DIALOGEX 0, 0, 255, 305 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION CAPTION "General" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN CONTROL "Generate &queries using backquote(`)",IDC_BACKQUOTES, - "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,4,5,202,10 + "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,4,6,202,10 CONTROL "Keep &focus on SQL editor after query execution",IDC_FOCUSAFTERQUERY, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,16,205,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,17,205,10 CONTROL "P&rompt if a tab with unsaved changes is closed",IDC_CONFIRMONTABCLOSE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,27,202,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,28,202,10 CONTROL "Paste object name in &editor on double-click",IDC_GETTEXTONDBCLICK, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,38,202,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,39,202,10 CONTROL "Enable &word wrap in SQL editor, BLOB and JSON viewer",IDC_WORDWRAP, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,49,202,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,50,202,10 + CONTROL "F&ormat JSON data in JSON viewer",IDC_JSON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,61,202,10 CONTROL "Enable transaction support for &batch process",IDC_TRANSACTIONENABLE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,60,202,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,72,202,10 CONTROL "Force disable F&K check throughout HTTP import batch process",IDC_FKCHKIMPORT, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,71,225,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,83,225,10 CONTROL "&Show Warning(s) in Messages tab",IDC_SHOWWARNING, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,82,124,10 - CONTROL "Halt Execution of Queries on Error",IDC_HALTEXEC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,93,124,10 - GROUPBOX "Export Options ",IDC_STATIC,4,106,247,99 - GROUPBOX "Max. size (in KB) for BULK INSERT statement(s)",IDC_STATIC,9,116,237,40 - CONTROL "&Get server default",IDC_DEF_BULK_SIZE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,127,112,8 - LTEXT "Custom si&ze",IDC_STATIC,14,141,39,10 - EDITTEXT IDC_BULKINSERT,58,139,37,12,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED - GROUPBOX "Chunk size (in rows) during batch exports ",IDC_STATIC,9,160,237,41 - CONTROL "&Don't break into chunks",IDC_SETMAXROW,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,170,115,9 - LTEXT "&Chunk size",IDC_STATIC,14,186,36,9 - EDITTEXT IDC_ROW_LIMIT,58,184,37,12,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED - LTEXT "rows",IDC_STATIC,100,187,31,9 - PUSHBUTTON "Restore &All Defaults",IDC_GENRESTOREALL,97,262,75,15 - PUSHBUTTON "Restore &Tab Defaults",IDC_GENRESTORETAB,176,262,75,15 - GROUPBOX "Table Data/Info/History Tab positioning",IDC_STATIC,4,208,247,49 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,94,124,10 + CONTROL "Halt Execution of Queries on Error",IDC_HALTEXEC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,105,124,10 + GROUPBOX "Export Options ",IDC_STATIC,4,130,247,99 + GROUPBOX "Max. size (in KB) for BULK INSERT statement(s)",IDC_STATIC,9,140,237,40 + CONTROL "&Get server default",IDC_DEF_BULK_SIZE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,151,112,8 + LTEXT "Custom si&ze",IDC_STATIC,14,165,39,10 + EDITTEXT IDC_BULKINSERT,58,163,37,12,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED + GROUPBOX "Chunk size (in rows) during batch exports ",IDC_STATIC,9,184,237,41 + CONTROL "&Don't break into chunks",IDC_SETMAXROW,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,195,115,9 + LTEXT "&Chunk size",IDC_STATIC,14,210,36,9 + EDITTEXT IDC_ROW_LIMIT,58,208,37,12,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED + LTEXT "rows",IDC_STATIC,100,211,31,9 + PUSHBUTTON "Restore &All Defaults",IDC_GENRESTOREALL,97,286,75,15 + PUSHBUTTON "Restore &Tab Defaults",IDC_GENRESTORETAB,176,286,75,15 + GROUPBOX "Table Data/Info/History Tab positioning",IDC_STATIC,4,232,247,49 CONTROL "Tab&le Data under Query tabs",IDC_TABLEDATAPOSITION, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,219,109,10 - CONTROL "&Info under Query tabs",IDC_INFOPOSITION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,231,88,10 - CONTROL "&History under Query tabs",IDC_HISTORYPOSITION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,243,97,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,243,109,10 + CONTROL "&Info under Query tabs",IDC_INFOPOSITION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,255,88,10 + CONTROL "&History under Query tabs",IDC_HISTORYPOSITION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,267,97,10 + CONTROL "Date picker shall set server time",IDC_SERVERDATE, + "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,4,116,202,10 END -IDD_PREF3 DIALOGEX 0, 0, 255, 280 +IDD_PREF3 DIALOGEX 0, 0, 255, 291 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION CAPTION "Power Tools" FONT 8, "MS Shell Dlg", 400, 0, 0x1 @@ -1933,12 +1960,13 @@ BEGIN CONTROL "Sh&ow Profile",IDC_PQAPROF,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,96,136,10 CONTROL "Status &Variables",IDC_PQASTATUS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,120,122,10 CONTROL "E&XPLAIN Result",IDC_PQAEXPLAIN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,108,136,10 - CONTROL "EXPLAIN EXTENDED &info",IDC_PQAEXPLAINEXT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,132,136,10 - PUSHBUTTON "Restore &All Defaults",IDC_POWERTOOLSRESTOREALL,97,262,75,15 - PUSHBUTTON "Restore &Tab Defaults",IDC_POWERTOOLSRESTORETAB,176,262,75,15 + CONTROL "EXPLAIN EXTENDED &info (if supported)",IDC_PQAEXPLAINEXT, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,132,136,10 + PUSHBUTTON "Restore &All Defaults",IDC_POWERTOOLSRESTOREALL,97,273,75,15 + PUSHBUTTON "Restore &Tab Defaults",IDC_POWERTOOLSRESTORETAB,176,273,75,15 END -IDD_PREFFORMATTER DIALOGEX 0, 0, 255, 280 +IDD_PREFFORMATTER DIALOGEX 0, 0, 255, 291 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION CAPTION "SQL Formatter" FONT 8, "MS Shell Dlg", 400, 0, 0x1 @@ -1952,8 +1980,8 @@ BEGIN LTEXT "spaces",IDC_SPACES,79,90,26,10 GROUPBOX "Preview ",IDC_PRWGROUP,4,105,247,111 CONTROL "Custom2",IDC_FORMATTERPREVIEW,"Scintilla",0x0,8,115,239,96 - PUSHBUTTON "Restore &All Defaults",IDC_FORMATTERRESTOREALL,97,262,75,15 - PUSHBUTTON "Restore &Tab Defaults",IDC_FORMATTERRESTORETAB,176,262,75,15 + PUSHBUTTON "Restore &All Defaults",IDC_FORMATTERRESTOREALL,97,273,75,15 + PUSHBUTTON "Restore &Tab Defaults",IDC_FORMATTERRESTORETAB,176,273,75,15 GROUPBOX "Table and Column List Style ",IDC_STATIC,4,3,247,39 GROUPBOX "Linebreaks ",IDC_STATIC,4,45,247,40 END @@ -2096,8 +2124,11 @@ BEGIN COMBOBOX IDC_FILTER_COND,96,15,50,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP LTEXT "&Value",IDC_STATIC,153,4,18,8 EDITTEXT IDC_FILTER_VALUE,152,15,83,13,ES_AUTOHSCROLL + LTEXT "Show SQL Preview",IDC_SHOWSQL,6,33,72,8,SS_NOTIFY | SS_CENTERIMAGE | NOT WS_VISIBLE + LTEXT "Hide SQL Preview",IDC_HIDESQL,6,33,70,8,SS_NOTIFY | SS_CENTERIMAGE | NOT WS_VISIBLE DEFPUSHBUTTON "&OK",IDOK,131,33,50,14 PUSHBUTTON "Cance&l",IDCANCEL,185,33,50,14 + CONTROL "Custom",IDC_PREVIEW,"Scintilla",0x0,6,50,229,40 END IDD_LANGUAGE DIALOGEX 0, 0, 212, 59 @@ -2281,223 +2312,442 @@ END // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. IDI_MAIN ICON "..\\include\\bitmaps\\mysql.ICO" + IDI_SCHEMA ICON "..\\include\\bitmaps\\schema.ICO" + IDI_SORTDSC ICON "..\\include\\bitmaps\\sortdsc.ico" + IDI_INSERT ICON "..\\include\\bitmaps\\insertupdate.ICO" + IDI_XMLHTML ICON "..\\include\\bitmaps\\exportxmlhtml.ico" + IDI_NEWQUERY ICON "..\\include\\bitmaps\\first.ico" + IDI_SAVE ICON "..\\include\\bitmaps\\save.ico" + IDI_CUT ICON "..\\include\\bitmaps\\cut.ico" + IDI_COPY ICON "..\\include\\bitmaps\\Copy.ico" + IDI_PASTE ICON "..\\include\\bitmaps\\paste.ico" + IDI_OPEN ICON "..\\include\\bitmaps\\open.ico" + IDI_EXECUTE ICON "..\\include\\bitmaps\\execute.ico" + IDI_REFRESH ICON "..\\include\\bitmaps\\refresh.ico" + IDI_ODBC ICON "..\\include\\bitmaps\\odbc.ico" + IDI_DIFFTOOL ICON "..\\include\\bitmaps\\Sync.ico" + IDI_USERS ICON "..\\include\\bitmaps\\users.ICO" + IDI_FLUSH ICON "..\\include\\bitmaps\\flush.ico" + IDI_TABLEDIAG ICON "..\\include\\bitmaps\\tablediag.ico" + IDI_PROCESS ICON "..\\include\\bitmaps\\process.ico" + IDI_CHECK ICON "..\\include\\bitmaps\\check.ICO" + IDI_EXECUTEFORUPD ICON "..\\include\\bitmaps\\execforupd.ico" + IDI_EXECUTEALL ICON "..\\include\\bitmaps\\execall.ico" + IDI_SMALL ICON "..\\include\\bitmaps\\smallico.ICO" + IDI_COLUMN ICON "..\\include\\bitmaps\\column.ico" + IDI_DROPTABLE ICON "..\\include\\bitmaps\\drop_table.ico" + IDI_DROPCOLUMN ICON "..\\include\\bitmaps\\dropcolumn.ico" + IDI_INDEX ICON "..\\include\\bitmaps\\index.ico" + IDI_MANINDEX ICON "..\\include\\bitmaps\\manage_index.ico" + IDI_QUERYRECORD ICON "..\\include\\bitmaps\\result_set.ico" + IDI_TABLE ICON "..\\include\\bitmaps\\table.ico" + IDI_TILE ICON "..\\include\\bitmaps\\tile.ico" + IDI_ALTERTABLE ICON "..\\include\\bitmaps\\altertable.ico" + IDI_COPYDATABASE ICON "..\\include\\bitmaps\\copy_data.ico" + IDI_EXPORTDATA ICON "..\\include\\bitmaps\\export_data.ico" + IDI_HELP ICON "..\\include\\bitmaps\\help.ICO" + IDI_IMPORTDATA ICON "..\\include\\bitmaps\\import_data.ico" + IDI_HISTORY ICON "..\\include\\bitmaps\\history.ico" + IDI_DATABASE ICON "..\\include\\bitmaps\\database.ico" + IDI_KEYSHORT ICON "..\\include\\bitmaps\\keyboard.ICO" + IDI_NEWDATABASE ICON "..\\include\\bitmaps\\new_data.ico" + IDI_TABLEINDEX ICON "..\\include\\bitmaps\\object.ico" + IDI_REDOSM ICON "..\\include\\bitmaps\\redo.ico" + IDI_UNDOSM ICON "..\\include\\bitmaps\\undo.ico" + IDI_SERVER ICON "..\\include\\bitmaps\\serv.ico" + IDI_REPLACE ICON "..\\include\\bitmaps\\replace.ico" + IDI_FIND ICON "..\\include\\bitmaps\\search.ico" + IDI_EXECBATCH ICON "..\\include\\bitmaps\\execbatch.ico" + IDI_COPYTABLE ICON "..\\include\\bitmaps\\copytable.ICO" + IDI_REORDER ICON "..\\include\\bitmaps\\reordercolumns.ico" + IDI_MANREL ICON "..\\include\\bitmaps\\manrel.ico" + IDI_QUERYMESSAGE ICON "..\\include\\bitmaps\\ico00002.ico" + IDI_RESTORE ICON "..\\include\\bitmaps\\restore_data.ico" + IDI_BACKUP ICON "..\\include\\bitmaps\\backup.ico" + IDI_CREATETABLE ICON "..\\include\\bitmaps\\createtableindata.ico" + IDI_TEMPLATE ICON "..\\include\\bitmaps\\templatesm.ico" + IDI_DISCON ICON "..\\include\\bitmaps\\discon.ICO" + IDI_DISCONALL ICON "..\\include\\bitmaps\\disconall.ICO" + IDI_CONNECT ICON "..\\include\\bitmaps\\connect.ico" + IDI_CASCADE ICON "..\\include\\bitmaps\\cascade.ico" + IDI_JOBMANAGER ICON "..\\include\\bitmaps\\jobmanager.ico" + IDI_NOTIFICATION ICON "..\\include\\bitmaps\\notification.ico" + IDI_EDITUSER ICON "..\\include\\bitmaps\\editusers.ico" + IDI_ADDUSER ICON "..\\include\\bitmaps\\addusers.ico" + IDI_CSV ICON "..\\include\\bitmaps\\csv.ico" + IDI_EMPTYDB ICON "..\\include\\bitmaps\\emptydata.ico" + IDI_RENAME ICON "..\\include\\bitmaps\\rename.ico" + IDI_TABLEPROP ICON "..\\include\\bitmaps\\tableprop.ico" + IDI_TRUNCDB ICON "..\\include\\bitmaps\\truncatedata.ico" + IDI_VIEWDATA ICON "..\\include\\bitmaps\\viewdata.ico" + IDI_SORTASC ICON "..\\include\\bitmaps\\sortasc.ico" + IDI_DBSYNC ICON "..\\include\\bitmaps\\dbsync.ico" + IDI_COMMIT ICON "..\\include\\bitmaps\\commit.ico" + IDI_ROLLBACK ICON "..\\include\\bitmaps\\rollback.ico" + IDI_START_TRANSACTION ICON "..\\include\\bitmaps\\start_transaction.ico" + IDI_PREF ICON "..\\include\\bitmaps\\preferences.ico" + IDI_REORDERCOL ICON "..\\include\\bitmaps\\reordercol.ico" + IDI_EMPTYTABLE ICON "..\\include\\bitmaps\\emptytable.ico" + IDI_DROPDB ICON "..\\include\\bitmaps\\dropdatabase.ico" + IDI_MYSQL ICON "..\\include\\bitmaps\\MySQL.ico" + IDI_TUNNEL ICON "..\\include\\bitmaps\\tunnel.ico" + IDI_SERVERGROUP ICON "..\\include\\bitmaps\\GroupofServers.ico" + IDI_STOP ICON "bitmaps\\Stop.ico" + IDI_EXPORTRESULTCSV ICON "bitmaps\\export_csv.ico" + IDI_EXPORTSELCSV ICON "bitmaps\\export_sel_csv.ico" + IDI_EXPORTSELCELLCSV ICON "bitmaps\\export_sel_cell_csv.ico" + IDI_RESULTCANCEL ICON "bitmaps\\result_cancel.ico" + IDI_RESULTDELETE ICON "bitmaps\\result_delete.ico" + IDI_RESULTINSERT ICON "bitmaps\\result_insert.ico" + IDI_RESULTSAVE ICON "bitmaps\\result_save.ico" + IDI_SCHDEXPORT ICON "bitmaps\\schdexport.ico" + IDI_EMAILMANAGER ICON "bitmaps\\emailmanager.ico" + IDI_VIEW ICON "..\\include\\bitmaps\\view.ico" + IDI_CREATEVIEW ICON "..\\include\\bitmaps\\viewnew.ico" + IDI_ALTERVIEW ICON "..\\include\\bitmaps\\alterview.ico" + IDI_DROPVIEW ICON "..\\include\\bitmaps\\deleteview.ico" + IDI_PROCEDURE ICON "..\\include\\bitmaps\\sp.ico" + IDI_CREATEPROCEDURE ICON "..\\include\\bitmaps\\addsp.ico" + IDI_ALTERPROCEDURE ICON "..\\include\\bitmaps\\altersp.ico" + IDI_DROPPROCEDURE ICON "..\\include\\bitmaps\\deletesp.ico" + IDI_CREATETRIGGER ICON "..\\include\\bitmaps\\addtrigger.ico" + IDI_ALTERTRIGGER ICON "..\\include\\bitmaps\\altertrigger.ico" + IDI_DROPTRIGGER ICON "..\\include\\bitmaps\\deletetrigger.ico" + IDI_CREATEFUNCTION ICON "..\\include\\bitmaps\\addfunction.ico" + IDI_ALTERFUNCTION ICON "..\\include\\bitmaps\\alterfunction.ico" + IDI_DROPFUNCTION ICON "..\\include\\bitmaps\\deletefunction.ico" + IDI_QUERY ICON "bitmaps\\query.ico" + IDI_FAVORITES ICON "bitmaps\\favorites.ico" + IDI_ORGANIZEFAV ICON "bitmaps\\organize_favorites.ico" + IDI_ADDTOFAV ICON "bitmaps\\addtofavorite.ico" + IDI_SQL ICON "bitmaps\\sql_file.ico" + IDI_QUERYBUILDER ICON "bitmaps\\querybuilder.ico" + IDI_SCHEMADESIGNER ICON "bitmaps\\schemadesigner.ico" + IDI_PKEY ICON "bitmaps\\pkey.ico" + IDI_NEXT ICON "bitmaps\\nextbutton.ico" + IDI_PREVIOUS ICON "bitmaps\\previousbutton.ico" + IDI_CLOSETABLE ICON "bitmaps\\closetable.ICO" + IDI_SDTABLEVIEW ICON "bitmaps\\tableviews.ico" + IDI_EXPORTASIMG ICON "bitmaps\\Exportasimg.ico" + IDI_SDPRINT ICON "bitmaps\\Print.ico" + IDI_SDZOOMIN ICON "bitmaps\\zoomin.ico" + IDI_SDZOOMOUT ICON "bitmaps\\zoomout.ico" + IDI_ALTEREVENT ICON "bitmaps\\alterevent.ico" + IDI_DROPEVENT ICON "bitmaps\\dropevent.ico" + IDI_RENAMEEVENT ICON "bitmaps\\renameevent.ico" + IDI_EVENT ICON "bitmaps\\event.ico" + IDI_ADDTABLES ICON "bitmaps\\Addtables.ico" + IDI_ALTERDB ICON "bitmaps\\alterdb.ico" + IDI_CHECKICON ICON "bitmaps\\check16.ico" + IDI_UNCHECKICON ICON "bitmaps\\uncheck16.ico" + IDI_LINEICON ICON "bitmaps\\line16.ico" + IDI_ENTMENU ICON "bitmaps\\entmenu.ico" + IDI_RESETFILTER ICON "bitmaps\\resetfilter.ico" + IDI_QADONTALERT ICON "bitmaps\\qa_noalert.ico" + IDI_QAALERT ICON "bitmaps\\qa_alert.ico" + IDI_FORMATQUERY ICON "bitmaps\\formatall.ico" + IDI_ABOUTICO ICON "bitmaps\\about.ico" + IDI_EXITICO ICON "bitmaps\\exit.ico" + IDI_REFRESHCANVAS ICON "bitmaps\\refreshcanvas.ico" + IDI_CLOSETAB ICON "bitmaps\\closetab.ico" + IDI_FAVREFRESH ICON "bitmaps\\refreshfav.ico" + IDI_INDEXDROP ICON "bitmaps\\indexdelete.ico" + IDI_INDEXCREATE ICON "bitmaps\\indexcreate.ico" + IDI_INDEXEDIT ICON "bitmaps\\indexedit.ico" + IDI_RENAMETRIGGER ICON "bitmaps\\renametrigger.ico" + IDI_RENAMEVIEW ICON "bitmaps\\renameview.ico" + IDI_EXPORTVIEW ICON "bitmaps\\expotview.ico" + IDI_COPYQUERYTOCLIP ICON "bitmaps\\copyquerytoclip.ico" + IDI_COPYQUERYTOCURTAB ICON "bitmaps\\copyquerytocurrenttab.ico" + IDI_COPYQUERYTONEWTAB ICON "bitmaps\\copyquerytonewtab.ico" + IDI_FOLDER ICON "bitmaps\\foldericon.ico" + IDI_CREATEEVENT ICON "bitmaps\\eventnew.ico" + IDI_TRIGGER ICON "bitmaps\\trigger.ico" + IDI_FUNCTION ICON "bitmaps\\function.ico" + IDI_CONNECT_16 ICON "bitmaps\\connect_16.ico" + IDI_COPYDATABASE_16 ICON "bitmaps\\copy_data_16.ico" + IDI_DBSYNC_16 ICON "bitmaps\\dbsync_16.ico" + IDI_COMMIT_16 ICON "bitmaps\\commit_16.ico" + IDI_ROLLBACK_16 ICON "bitmaps\\rollback_16.ico" + IDI_START_TRANSACTION_16 ICON "bitmaps\\start_transaction_16.ico" + IDI_EXECUTEALL_16 ICON "bitmaps\\execall_16.ico" + IDI_EXECUTE_16 ICON "bitmaps\\execute_16.ico" + IDI_EXECUTEFORUPD_16 ICON "bitmaps\\execforupd_16.ico" + IDI_EXPORTDATA_16 ICON "bitmaps\\export_data_16.ico" + IDI_QUERYBUILDER_16 ICON "bitmaps\\querybuilder_16.ico" + IDI_QUERY_16 ICON "bitmaps\\query_16.ico" + IDI_RENAMEQUERY_16 ICON "bitmaps\\renamequery_16.ico" + IDI_SAVESESSION_16 ICON "bitmaps\\session_save_all.ico" + IDI_OPENSESSION_16 ICON "bitmaps\\session_open.ico" + IDI_CLOSESESSION_16 ICON "bitmaps\\session_close.ico" + IDI_SCHEMADESIGNER_16 ICON "bitmaps\\schemadesigner_16.ico" + IDI_SCHDEXPORT_16 ICON "bitmaps\\schdexport_16.ico" + IDI_NOTIFICATION_16 ICON "bitmaps\\notification_16.ico" + IDI_REFRESH_16 ICON "bitmaps\\refresh_16.ico" + IDI_MANREL_16 ICON "bitmaps\\manrel_16.ico" + IDI_MANINDEX_16 ICON "bitmaps\\manage_index_16.ico" + IDI_EXECBATCH_16 ICON "bitmaps\\execbatch_16.ico" + IDI_XMLHTML_16 ICON "bitmaps\\exportxmlhtml_16.ico" + IDI_ODBC_16 ICON "..\\include\\bitmaps\\icon9.ico" + IDI_DIFFTOOL_16 ICON "bitmaps\\Sync_16.ico" + IDI_PRIMARYKEY ICON "bitmaps\\primary_key_16.ico" + IDI_OPENINNEWTAB ICON "bitmaps\\open_in_new_tab.ico" + IDI_USERMANAGER ICON "bitmaps\\usermanager.ICO" + IDI_SAVEAS ICON "bitmaps\\saveas.ico" + IDI_CONNCOLOR ICON "bitmaps\\colorpicker.ico" + IDI_RENAMEUSER ICON "bitmaps\\renameuser.ico" + IDI_USER_16 ICON "bitmaps\\user16.ico" + IDI_USER_GLOBALPRIV ICON "bitmaps\\user-globe.ico" + IDI_USER_OBJECTPRIV ICON "bitmaps\\user-objects.ico" + IDI_USER_ADD ICON "bitmaps\\user_add.ico" + IDI_USER_WRITE ICON "bitmaps\\user_write.ico" + IDI_DATAVIEWTYPE ICON "bitmaps\\dataview.ico" + IDI_DATASEARCH ICON "bitmaps\\datasearch.ico" + IDI_MOVEDOWN ICON "bitmaps\\Down.ico" + IDI_MOVEUP ICON "bitmaps\\Up.ico" + IDI_ADDROW ICON "bitmaps\\add.ico" + IDI_DELETEROW ICON "bitmaps\\delete.ico" + IDI_TABLEOPTIONS ICON "bitmaps\\TableOptions.ico" + IDI_TABPREVIEW ICON "bitmaps\\TabPreview.ico" + IDI_CIRCLE8 ICON "bitmaps\\circle8.ico" + IDI_CIRCLE1 ICON "bitmaps\\circle1.ico" + IDI_CIRCLE2 ICON "bitmaps\\circle2.ico" + IDI_CIRCLE3 ICON "bitmaps\\circle3.ico" + IDI_CIRCLE4 ICON "bitmaps\\circle4.ico" + IDI_CIRCLE5 ICON "bitmaps\\circle5.ico" + IDI_CIRCLE6 ICON "bitmaps\\circle6.ico" + IDI_CIRCLE7 ICON "bitmaps\\circle7.ico" + IDI_TABLEREFRESH ICON "bitmaps\\tablerefresh.ico" + IDI_DATAGRID ICON "bitmaps\\grid_view.ico" + IDI_FORMICON ICON "bitmaps\\form_view.ico" + IDI_TEXTVIEW ICON "bitmaps\\text_view.ico" + IDI_DUPLICATEROW ICON "bitmaps\\duplicaterow.ico" + IDI_FILTER ICON "bitmaps\\filter.ico" + IDI_REMOVE_DB_FILTER ICON "bitmaps\\remove_db_filter.ico" + IDI_TABLEEXPORT ICON "bitmaps\\result_export.ico" + IDI_REMOVE_FILTER ICON "bitmaps\\remove_filter.ico" + IDI_OVERLAYFILTER ICON "bitmaps\\overlay_filter.ico" + IDI_VDD ICON "bitmaps\\compare-data.ico" +IDI_CHECKCONSTRAINT ICON "bitmaps\\check_constraints.ico" + + ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO @@ -2734,6 +2984,7 @@ BEGIN IDD_PREFGENERAL, DIALOG BEGIN + BOTTOMMARGIN, 291 END IDD_PREF3, DIALOG @@ -2908,23 +3159,40 @@ END // PK PNG "bitmaps\\primary_key_16.png" + SERVER PNG "bitmaps\\serv.png" + TABLE PNG "bitmaps\\table.png" + DATABASE PNG "bitmaps\\database.png" + INDEX PNG "bitmaps\\index.png" + SP PNG "bitmaps\\sp.png" + VIEW PNG "bitmaps\\view.png" + FUNCTION PNG "bitmaps\\function.png" + TRIGGER PNG "bitmaps\\trigger.png" + EVENT PNG "bitmaps\\event.png" + CALENDAR PNG "bitmaps\\calendar.png" + DOWNARROW PNG "bitmaps\\downarrow.png" + REVERTSELECTED PNG "bitmaps\\revert_selected.png" + APPLY PNG "bitmaps\\apply.png" + APPLYALL PNG "bitmaps\\apply_all.png" + REVERTALL PNG "bitmaps\\revert_all.png" + STOP PNG "bitmaps\\stop.png" + ///////////////////////////////////////////////////////////////////////////// // // README @@ -2932,14 +3200,17 @@ STOP PNG "bitmaps\\stop.png" IDR_README README "readme.txt" + ///////////////////////////////////////////////////////////////////////////// // // THEME // IDR_THEME_TWILIGHT THEME "twilight_theme.xml" + IDR_THEME_FLAT THEME "Flat.xml" + ///////////////////////////////////////////////////////////////////////////// // // GIF @@ -2947,6 +3218,7 @@ IDR_THEME_FLAT THEME "Flat.xml" PROGRESS GIF "bitmaps\\progress.gif" + ///////////////////////////////////////////////////////////////////////////// // // String Table @@ -2972,7 +3244,6 @@ END STRINGTABLE BEGIN IDM_REFRESHOBJECT " Refresh the object browser" - IDM_COLLAPSEOBJECT " Collapses all expanded objects in object browser" ID_OBJECT_DROPDATABASE " Drop the currently selected database" ID_OBJECT_DROPTABLE " Drop the currently selected table" ID_OBJECT_INSERTSTMT " Create a valid SQL INSERT statement for the table" @@ -2981,6 +3252,11 @@ BEGIN ACCEL_EXECUTE " Execute query" END +STRINGTABLE +BEGIN + IDM_COLLAPSEOBJECT " Collapses all expanded objects in object browser" +END + STRINGTABLE BEGIN IDM_EDIT_TEMP_USER1 "/*\r\nUSE Statement\r\nSource : MySQL documentation\r\n*/\r\nUSE db_name" diff --git a/include/TabCheck.h b/include/TabCheck.h new file mode 100644 index 0000000..b3dfbd8 --- /dev/null +++ b/include/TabCheck.h @@ -0,0 +1,241 @@ +/* Copyright (C) 2013 Webyog Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + +*/ + +#include "FrameWindowHelper.h" +class TableTabInterfaceTabMgmt; + +#define NO_EXPRESSION_SPECIFIED_FOR_CHECK _(L"No Expression specified ") + +class FieldStructWrapper; + +class CheckColumn : public wyElem +{ +public: + FieldStructWrapper *m_pcwrapobj; + wyInt32 m_lenth; + CheckColumn(FieldStructWrapper *value); +}; + +struct CheckConstarintInfo +{ + wyString m_name; + wyString m_checkexpression; + List *m_listcolumns; +}; + +class CheckConstraintStructWrapper : public wyElem +{ +public: + CheckConstarintInfo *m_newval; + CheckConstarintInfo *m_oldval; + wyString *m_errmsg; + + CheckConstraintStructWrapper(CheckConstarintInfo *value, wyBool isnew); + ~CheckConstraintStructWrapper(); +}; + + +class TabCheck +{ +public: + /// Window handle + HWND m_hwnd; + + //HWND m_checktext; + + /// Grid Window Handle + HWND m_hgridtblcheckconst; + + HWND m_hdlggrid; + + //.. sub tabs' tabmgmt ptr + TableTabInterfaceTabMgmt* m_ptabmgmt; + + List m_listwrapperstruct; + + CRITICAL_SECTION m_cs; //..Doubt.. Ask vishal + + MDIWindow* m_mdiwnd; + + wyBool m_ismysql41; + wyBool m_ismariadb52; + wyBool m_ismysql553; + + // backtick string from preferences, either empty or quote + wyChar* m_backtick; + + wyString m_celldataprevval; + + // used for Shift+Click functionality + wyInt32 m_lastclickindgrid; + wyInt32 m_lastclickdlggrid; + + /// Constructor + TabCheck(HWND hwndparent, TableTabInterfaceTabMgmt* ptabmgmt); + TabCheck(); + + /// Destructor + ~TabCheck(); + + /// Grid Window Procedure + /** + @param hwnd : IN hwnd + @param message : IN message + @param wparam : IN wparam + @param lparam : IN lparam + @returns + */ + static LRESULT CALLBACK GridWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); + + //wyBool OnGVNBeginLabelEdit(HWND hwnd, WPARAM wParam, LPARAM lParam); + + + /// Creates the structure of the grid + /** + @returns void + */ + void InitGrid(); + //void InitDlgGrid(); + + /// intializes m_mysql, m_tunnel and calls CreateGrid() + /** + @returns void + */ + wyBool Create(); + wyInt32 InsertRow(); + + /// Saves the last focused row and column in the grid + /** + @returns void + */ + void OnTabSelChanging(); + void ApplyCancelGridChanges(); + wyBool ValidateChecks(wyBool showmsg = wyFalse); + + //..makes Windows Visible/Invisible + /* + @returns void + */ + void OnTabSelChange(); + + void Resize(); + + /// Drops the selected check constraint + /** + @returns wyBool, wyTrue if success, otherwise wyFalse + */ + wyBool DropSelectedChecks(); + + /// Inserts a new row + /** + @returns wyTrue + */ + wyBool ProcessInsert(); + + wyBool OnGVNBeginLabelEdit(HWND hwnd, WPARAM wParam, LPARAM lParam); + + /// Shows the Dialog-box if the grid cell on which mouse is clicked is INDEXCOLUMNS + /** + @returns void + */ + void OnGVNButtonClick(); + + wyBool OnGVNEndLabelEdit(WPARAM wParam, LPARAM lParam); + + void HandleCheckboxClick(HWND hwnd, LPARAM lparam, WPARAM wparam, wyInt32 &lastclickindex); + + LRESULT OnGVNSysKeyDown(HWND hwnd, WPARAM wParam, LPARAM lParam); + + //wyBool GetAlteredIndexes(wyString &query, wyUInt32 &querybuflen, wyBool execute=wyFalse); + + wyBool GenerateQuery(wyString &query); + + wyBool GenerateCreateQuery(wyString &query); + + wyBool GenerateAlterQuery(wyString &query); + wyBool GetDroppedChecks(wyString &query); + + wyUInt32 GetGridCellData(HWND hwndgrid, wyUInt32 row, wyUInt32 col, wyString &celldata); + + wyBool OnEndEditExpression(WPARAM wParam, LPARAM lParam); + + wyBool OnEndEditName(WPARAM wParam, LPARAM lParam); + + CheckConstarintInfo *GetDuplicateCheckStruct(CheckConstarintInfo* duplicateof); + + /// Generates query for the newly added indexes + /** + @param query : OUT query string + @param querybuflen : OUT length of query generated + @param execute : IN whether execute or not ? (wyTrue : Alter table || wyFalse : Create table) + @returns wyTrue if query is valid else wyFalse + */ + wyBool GetNewAndModifiedChecks(wyString &query, wyBool execute = wyFalse); + + //..Scans entire row for the changed values (Alter table) + //.....called on EndLabelEdit and close of the Dialog + /* + @param currentrow : IN currently selected row + @param currentcol : IN currently selected column + @param currentdata : IN current data + @returns wyTrue if row is scanned successfully, else wyFalse + */ + wyBool ScanEntireRow(wyUInt32 currentrow, wyInt32 currentcol, wyString& currentdata); + + //.. Clears all memory allocated during process + /* + @param iscallfromdestructor : IN wyTrue/wyFalse + @returns + */ + void ClearAllMemory(wyBool iscallfromdestructor = wyTrue); + + /// Function to initialize the grid with the relevant data i.e about the indexes + /** + @returns wyBool, wyTrue is SUCCESS, otherwise wyFalse + */ + wyBool FetchCheckConstraintsIntoWrapper(); + + + //.. Fill the initial values from the structure "m_backupcopy" + /* + @param iscancelchanges : IN + @returns pointer of duplicate structure object + */ + void FillInitValues(); + + wyBool GetAllCheckConstraint(wyChar * createstring, wyString *allcheckconstraint); + + /// After Save, Reinitializes the grid (because, in case, if user doesn't provide index name, we need to show names assigned by mysql) + /** + @returns void + */ + void ReInitializeGrid(); + + + void HandleChecksOnFieldRename(CheckConstraintStructWrapper* checkwrap); + + void CheckForQuotesAndReplace(wyString *colname); + + void CancelChanges(wyBool isaltertable); + wyBool ProcessDelete(); + wyBool DropCheck(wyUInt32 row); + void ChangeListOnDelete(CheckConstraintStructWrapper* cwrapobj); + + wyBool ExecuteQuery(wyString &query); + +}; \ No newline at end of file diff --git a/include/TabFields.h b/include/TabFields.h index 736e70f..5c21382 100644 --- a/include/TabFields.h +++ b/include/TabFields.h @@ -43,7 +43,7 @@ #define COLLATIONCOL 10 #define VIRTUALITY 13 #define EXPRESSION 14 - +#define CHECKCONSTRAINT 15 #define MAXLENWITHBACKTICKS 4 #define DEFAULTNUMROWS 6 @@ -75,6 +75,7 @@ struct FIELDATTRIBS wyString m_expression; //expression for virtual coloumn. wyString m_mysqlvirtuality; //for mysql virtual/stored columns wyString m_mysqlexpression; //expression for virtual coloumn. + wyString m_mycheckexpression; //expression for check constraint. struct FIELDATTRIBS* m_next; /// pointer to the next FIELDATTRIBS struct elem }; @@ -148,6 +149,9 @@ class TabFields //is mariadb version>=5.2 wyBool m_ismariadb52; + //is mariadb version>=10.3.9 + wyBool m_ismariadb10309; + //is mysql version>=5.7 wyBool m_ismysql57; @@ -194,6 +198,9 @@ class TabFields // backtick string from preferences, either empty or quote wyChar* m_backtick; + //to check whether control from save table or alter table + wyBool m_isalter; + /// intializes m_mysql, m_tunnel and calls CreateGrid() /** @returns void @@ -628,6 +635,15 @@ class TabFields */ void GetCommentValue(wyString& query, FIELDATTRIBS* pfieldattribs); + + /// Helper function to get the check condition of the columns + /** + @param query : OUT wyString in which the values have to be added + @param prowdata : IN Array of column values from which data needs to be extracted + @returns void + */ + void GetCheckValue(wyString& query, FIELDATTRIBS* pfieldattribs); + /// Fetches the initial the values /** @returns wyBool, wyTrue if success, otherwise wyFalse @@ -791,12 +807,23 @@ class TabFields wyBool IsDropAndRecreateRequired(FieldStructWrapper* cwrapobj,wyBool isnew); + //function to findout wehther to generate drop or recreate for check constraint + + wyBool IsDropAndRecreateCheckRequired(FieldStructWrapper* cwrapobj, wyBool isnew); + /// rotates through all grid rows, finds the wrapper from the column name /* @param : IN column name @returns FieldStructWrapper object pointer */ - FieldStructWrapper* GetWrapperObjectPointer(wyString &columnname); + FieldStructWrapper* GetWrapperObjectPointer(wyString &columnname); + + /// rotates through all grid rows, finds the wrapper from the column name + /* + @param : IN column name + @returns FieldStructWrapper object pointer + */ + FieldStructWrapper* GetWrapperObjectPointerch(); /// Drops columns from indexes when user deletes the field from the grid /* diff --git a/include/TabMgmt.h b/include/TabMgmt.h index 9273b6e..372bc87 100644 --- a/include/TabMgmt.h +++ b/include/TabMgmt.h @@ -173,7 +173,7 @@ class TabMgmt wyInt32 SelectFixedTab(wyInt32 image, wyBool isonlyprob = wyFalse); - void DeleteTab(wyInt32 index); + void DeleteTab(wyInt32 index,wyBool ispostion=wyFalse); void AddFixedTab(wyInt32 image); diff --git a/include/TabModule.h b/include/TabModule.h index 726174e..2f395b6 100644 --- a/include/TabModule.h +++ b/include/TabModule.h @@ -27,6 +27,7 @@ #include "TabObject.h" #include "TabTableData.h" #include "FindAndReplace.h" +#include "FrameWindow.h" class EditorProcs; class TabEditor; @@ -37,15 +38,28 @@ class TabSchemaDesigner; class TableTabInterface; class TabObject; class TabHistory; +class FrameWindow; #ifdef COMMUNITY class CommunityRibbon; #endif +enum pretabtype +{ + ishistory, + isinfo, + isdata +}; + class TabModule { + public: + wyInt32 m_serialnoqb; + wyInt32 m_serialnosd; + wyInt32 m_serialnoet; + /// Constructor with parent window handle. /** @@ -98,7 +112,10 @@ class TabModule @return wyBool wytrue if it is SUCCESS, otherwise failure. @param wnd : IN parent connection window pointer. */ - wyBool CreateQueryEditorTab(MDIWindow* wnd, wyInt32 pos = -1, wyBool setfocus = wyTrue); + wyBool CreateQueryEditorTab(MDIWindow* wnd, wyInt32 pos = -1, wyBool setfocus = wyTrue, wyBool frompreferencetoggle=wyFalse); + + wyInt32 GetMaxSequence(MDIWindow* wnd); + wyInt32 GetMaxSequenceQB(MDIWindow* wnd); /// Creates the normal query editor @@ -140,6 +157,15 @@ class TabModule */ wyBool CreateQueryBuilderTab(MDIWindow * wnd); + //set the sequence of each query tab + wyString SetTabSequence(wyString s,MDIWindow *wnd); + + //set the sequence of each sd tab + wyString SetTabSequenceSD(wyString s, MDIWindow *wnd); + + wyInt32 GetMaxSequenceSD(MDIWindow* wnd); + + //wyInt32 GetMaxSequenceDS(MDIWindow* wnd); ///Function to instantiate the TabQueryBuilder /* @param wnd : IN parent connection window pointer. @@ -160,6 +186,7 @@ class TabModule wyBool IsAlterTableTabOpen(wyString& tblname, wyInt32& tabindex); + void UpdateDropDownStruct(MDIWindow *wnd,wyString tabname); ///Wrapper to create Tab for SchemaDesigner /** @@ -181,6 +208,8 @@ class TabModule wyBool CreateTabDataTab(MDIWindow * wnd, wyBool isnewtab = wyFalse, wyBool setfocus = wyFalse); + //insert tab into the drop down struct + VOID InsertTabIntoDropDownStruct(MDIWindow * wnd, pretabtype tabtype); ///Function to instantiate the TabSchemaDesigner /** @param wnd : IN parent connection window pointer. @@ -322,7 +351,12 @@ class TabModule @return void */ VOID SetTabName(wyWChar *filename, wyBool isshowext, wyBool isedited = wyFalse); - VOID SetTabRename(wyWChar *name, wyBool isedited = wyFalse); + VOID SetTabRename(wyWChar *name, wyBool isedited = wyFalse,MDIWindow *wnd=NULL, wyBool isfromrenamedlg=wyFalse); + + VOID UpdateNameinStruc(wyInt32 itemindex,wyString newname); + + //Add table data tab in the drop down + VOID AddTabletabIntoDropDown(MDIWindow *wnd, TabTableData* temptab ,wyBool setfocus); /// Shows/Hides all the content of the editor /** @param tabindex: IN currently selected tab index. diff --git a/include/TableTabInterface.h b/include/TableTabInterface.h index 95b1eed..d6b5a2b 100644 --- a/include/TableTabInterface.h +++ b/include/TableTabInterface.h @@ -386,4 +386,6 @@ class TableTabInterface : public TabTypes void OnDlgWMPaint(HWND hwnd); void CreateDlgCancel(HWND hwnd); + + void UpdateDropdownStruct(wyInt32 index,wyString newname); }; \ No newline at end of file diff --git a/include/TableTabInterfaceTabMgmt.h b/include/TableTabInterfaceTabMgmt.h index 037f117..0166b55 100644 --- a/include/TableTabInterfaceTabMgmt.h +++ b/include/TableTabInterfaceTabMgmt.h @@ -25,6 +25,9 @@ class TabAdvancedProperties; class TabIndexes; class TabForeignKeys; class TabPreview; +class TabCheck; + + class TableTabInterfaceTabMgmt { @@ -60,6 +63,8 @@ class TableTabInterfaceTabMgmt wyBool CreateForeignKeysTab(); + wyBool CreateCheckConstraintTab(); + wyBool CreatePreviewTab(); wyBool CreateTableTab(); @@ -108,6 +113,8 @@ class TableTabInterfaceTabMgmt TabForeignKeys* m_tabfk; + TabCheck* m_tabcheck; + TabPreview* m_tabpreview; wyBool m_allsubtabsloaded; diff --git a/include/bitmaps/check_constraints.ico b/include/bitmaps/check_constraints.ico new file mode 100644 index 0000000..ce9d006 Binary files /dev/null and b/include/bitmaps/check_constraints.ico differ diff --git a/include/resource.h b/include/resource.h index 090251c..40abd0d 100644 --- a/include/resource.h +++ b/include/resource.h @@ -342,6 +342,7 @@ #define IDI_REMOVE_FILTER 994 #define IDI_REMOVE_DB_FILTER 995 #define IDI_OVERLAYFILTER 997 +#define IDR_CONNTABPLUSMENU1 998 #define IDB_PNG1 1004 #define IDC_DLGCONNECT_USER 1005 #define IDI_ICON1 1005 @@ -622,9 +623,12 @@ #define IDC_FOCUSAFTERQUERY 1215 #define IDC_CONFIRMONTABCLOSE 1216 #define IDC_GETTEXTONDBCLICK 1217 +#define IDC_BACKQUOTES2 1218 #define IDC_AUTOCOMPLETE 1219 +#define IDC_SERVERDATE 1219 #define IDC_GETINFOKW 1219 #define IDC_AUTOCOMPLETEREBUILD 1220 +#define IDC_SERVERDATE2 1220 #define IDC_AUTOCOMPLETESHOWTOOLTIP 1221 #define IDC_QUERY 1232 #define IDC_ERROR_NUMBER 1233 @@ -984,8 +988,8 @@ #define IDC_TRIALSTATIC 1812 #define IDC_INITCOMMANDHELP 2644 #define IDC_COMBOCUSTOM 2645 -#define IDC_SHOWSQL 2646 -#define IDC_HIDESQL 2647 +#define IDC_SHOWSQL 2646 +#define IDC_HIDESQL 2647 #define ID_IMPORT_FROMXML 2655 #define ACCEL_IMPORTXML 2656 #define FAVORITE_MENU_ID 2900 @@ -1580,6 +1584,7 @@ #define ID_OPEN_SELECT 41754 #define ID_OPEN_COPYALL 41755 #define ID_OPEN_SELECTALL41756 41756 +#define ID_DATABASE_REBUILDTAGS 41756 #define ID_TABMENU_CREATETABLE 41757 #define ID_TABMENU_HISTORY 41758 #define ID_TABMENU_INFO 41759 @@ -1624,7 +1629,6 @@ #define ID_SAVEPOINT_CREATESAVEPOINT 41821 #define ID_SAVEPOINT_RELEASESAVEPOINT 41822 #define ID_Menu 41823 -#define ID_DATABASE_REBUILDTAGS 41756 #define ID_Menu41826 41826 #define ID_Menu41827 41827 #define IDM_COLLAPSEOBJECT 41828 @@ -1655,6 +1659,9 @@ #define IDD_CREATESAVEPOINT 44140 #define IDD_RELEASESAVEPOINT 44141 #define IDD_ROLLBACKTO 44142 +#define IDI_CHECKCONSTRAINT 44143 +#define IDM_DROPDOWNLISTITEM 44145 +#define IDR_CONNDROPDOWNMENU 44146 // Next default values for new objects // diff --git a/lib/Keywords.db b/lib/Keywords.db index 5730b2f..092092c 100644 Binary files a/lib/Keywords.db and b/lib/Keywords.db differ diff --git a/localization/Strings/String/en/file27.xml b/localization/Strings/String/en/file27.xml new file mode 100644 index 0000000..2457f44 --- /dev/null +++ b/localization/Strings/String/en/file27.xml @@ -0,0 +1,11 @@ + + + Enable word wrap + Format JSON data in JSON viewer + Halt Execution of Queries on Error + Date picker shall insert server time + Prompt when query causing implicit commit is executed + Prompt when closing session or program if transaction is active + Transaction options + + \ No newline at end of file diff --git a/localization/Strings/String/ja/file27.xml b/localization/Strings/String/ja/file27.xml new file mode 100644 index 0000000..3c551c3 --- /dev/null +++ b/localization/Strings/String/ja/file27.xml @@ -0,0 +1,11 @@ + + + ワードラップを有効にする + JSONビューアでJSONデータをフォーマットする + エラー時にクエリの実行を停止する + 日付ピッカーはサーバー時間を挿入する + 暗黙のコミットを引き起こすクエリが実行されたときにプロンプ​​トを表示する + トランザクションがアクティブな場合にセッションまたはプログラムを閉じるときにプロンプ​​ト + トランザクションオプション + + \ No newline at end of file diff --git a/localization/Strings/String/ko/file27.xml b/localization/Strings/String/ko/file27.xml new file mode 100644 index 0000000..6d43a87 --- /dev/null +++ b/localization/Strings/String/ko/file27.xml @@ -0,0 +1,11 @@ + + + 단어 감싸기 사용 + JSON 뷰어에서 JSON 데이터 형식 지정 + 오류시 질의 실행 중지 + 날짜 선택 도구는 서버 시간을 삽입해야합니다. + 암시 적 커밋을 발생시키는 쿼리가 실행될 때 알리는 메시지 + 트랜잭션이 활성화 된 경우 세션 또는 프로그램을 종료 할 때 확인 + 트랜잭션 옵션 + + \ No newline at end of file diff --git a/localization/Strings/String/zh-cn/file27.xml b/localization/Strings/String/zh-cn/file27.xml new file mode 100644 index 0000000..d91e6fd --- /dev/null +++ b/localization/Strings/String/zh-cn/file27.xml @@ -0,0 +1,11 @@ + + + 啟用自動換行 + 在JSON查看器中格式化JSON數據 + 在錯誤時停止執行查詢 + 日期選擇器應插入服務器時間 + 執行導致隱式提交的查詢時提示 + 如果交易處於活動狀態,則在關閉會話或程序時提示 + 交易選項 + + \ No newline at end of file diff --git a/localization/bin/KernelBase.dll b/localization/bin/KernelBase.dll new file mode 100644 index 0000000..6908c9d Binary files /dev/null and b/localization/bin/KernelBase.dll differ diff --git a/localization/bin/kernel32.dll b/localization/bin/kernel32.dll new file mode 100644 index 0000000..fd1fe1d Binary files /dev/null and b/localization/bin/kernel32.dll differ diff --git a/localization/bin/ntdll.dll b/localization/bin/ntdll.dll new file mode 100644 index 0000000..db4f326 Binary files /dev/null and b/localization/bin/ntdll.dll differ diff --git a/src/CalendarCtrl.cpp b/src/CalendarCtrl.cpp index a793765..b8cc67b 100644 --- a/src/CalendarCtrl.cpp +++ b/src/CalendarCtrl.cpp @@ -192,7 +192,7 @@ CalendarCtrl::CalendarCtrlProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lP switch(LOWORD(wParam)) { case IDCURRDATE: - pcc->OnClickNow(); + pcc->OnClickNow(pcc->m_dv); break; case IDOK: @@ -296,12 +296,38 @@ void CalendarCtrl::InitCalendarValues() { wyInt32 iszerodateflag=0; - wyString temp,temp2; + wyString temp,temp2,settozero; m_row = CustomGrid_GetCurSelRow(m_hwndparent); m_col = CustomGrid_GetCurSelCol(m_hwndparent); wyChar tempchar[5]= ""; wyString year,month,day; wyChar * tempstr = NULL; + wyBool pretoshowserverdate; + MYSQL *mysql; + Tunnel *tunnel; + wyString query("select NOW()"); + MYSQL_RES *res; + MYSQL_ROW row; + wyString myrowstr; + wyInt32 qret, checkint=1; + + //Get preference setting to show server date or system date + pretoshowserverdate = GetPreferenceForNowButton(); + + if (pretoshowserverdate && m_dv != NULL) { + tunnel = m_dv->m_data->m_pmdi->m_tunnel; + mysql = m_dv->m_data->m_pmdi->m_mysql; + qret = HandleMySQLRealQuery(tunnel, mysql, query.GetString(), query.GetLength(), wyTrue, wyTrue, wyTrue); + + res = tunnel->mysql_store_result(mysql, wyTrue); + /* we specifically ignore empty queries */ + if (res == NULL && mysql->affected_rows == -1) + { + return; + } + row = tunnel->mysql_fetch_row(res); + myrowstr.SetAs(row[0]); + } // Year Section tempstr = m_orgdata.Substr(0,4); @@ -313,8 +339,15 @@ CalendarCtrl::InitCalendarValues() strcpy(tempchar,"1970"); iszerodateflag=-1; } - else - strcpy(tempchar,year.GetString()); + else { + strcpy(tempchar, year.GetString()); + settozero.Add(tempchar); + checkint = settozero.GetAsUInt32(); + if (pretoshowserverdate && checkint==0) + { + strcpy(tempchar, myrowstr.Substr(0, 4)); + } + } } else { @@ -334,8 +367,16 @@ CalendarCtrl::InitCalendarValues() strcpy(tempchar,"01"); iszerodateflag=-1; } - else - strcpy(tempchar,month.GetString()); + else { + strcpy(tempchar, month.GetString()); + settozero.Add(tempchar); + checkint = -1; + checkint = settozero.GetAsUInt32(); + if (pretoshowserverdate && checkint == 0) + { + strcpy(tempchar, myrowstr.Substr(5, 2)); + } + } } else { @@ -355,46 +396,106 @@ CalendarCtrl::InitCalendarValues() strcpy(tempchar,"01"); iszerodateflag=-1; } - else - strcpy(tempchar,day.GetString()); + else { + strcpy(tempchar, day.GetString()); + settozero.Add(tempchar); + checkint = -1; + checkint = settozero.GetAsUInt32(); + if (pretoshowserverdate && checkint == 0) + { + strcpy(tempchar, myrowstr.Substr(8, 2)); + } + + } } else { - strcpy(tempchar,"0"); + if (pretoshowserverdate) + { + strcpy(tempchar, myrowstr.Substr(8, 2)); + } + else { + strcpy(tempchar, "0"); + } } temp.Add(tempchar); m_datetime.wDay=temp.GetAsUInt32(); temp.Clear(); - if(m_orgdata.Substr(11,2)==NULL) + if(m_orgdata.Substr(11,2)==NULL && !pretoshowserverdate) strcpy(tempchar,"0"); - else - strcpy(tempchar,m_orgdata.Substr(11,2)); + else { + if (m_orgdata.Substr(11, 2) == NULL) + { + strcpy(tempchar, myrowstr.Substr(11, 2)); + } + else { + strcpy(tempchar, m_orgdata.Substr(11, 2)); + settozero.Add(tempchar); + checkint = -1; + checkint = settozero.GetAsUInt32(); + if (pretoshowserverdate && checkint == 0) + { + strcpy(tempchar, myrowstr.Substr(11, 2)); + } + } + + } + temp.Add(tempchar); m_datetime.wHour=temp.GetAsUInt32(); temp.Clear(); - if(m_orgdata.Substr(14,2)==NULL) + if(m_orgdata.Substr(14,2)==NULL && !pretoshowserverdate) strcpy(tempchar,"0"); - else - strcpy(tempchar,m_orgdata.Substr(14,2)); - temp.Add(tempchar); + else { + if (m_orgdata.Substr(14, 2) == NULL) + { + strcpy(tempchar, myrowstr.Substr(14, 2)); + } + else { + strcpy(tempchar, m_orgdata.Substr(14, 2)); + settozero.Add(tempchar); + checkint = -1; + checkint = settozero.GetAsUInt32(); + if (pretoshowserverdate && checkint == 0) + { + strcpy(tempchar, myrowstr.Substr(14, 2)); + } + } - m_datetime.wMinute=temp.GetAsUInt32(); - temp.Clear(); + + } + temp.Add(tempchar); + m_datetime.wMinute=temp.GetAsUInt32(); + temp.Clear(); - if(m_orgdata.Substr(17,2)==NULL) + if(m_orgdata.Substr(17,2)==NULL && !pretoshowserverdate) strcpy(tempchar,"0"); - else - strcpy(tempchar,m_orgdata.Substr(17,2)); + else { + if (m_orgdata.Substr(17, 2) == NULL) + { + strcpy(tempchar, myrowstr.Substr(17, 2)); + } + else { + strcpy(tempchar, m_orgdata.Substr(17, 2)); + settozero.Add(tempchar); + checkint = -1; + checkint = settozero.GetAsUInt32(); + if (pretoshowserverdate && checkint == 0) + { + strcpy(tempchar, myrowstr.Substr(17, 2)); + } + } + + } temp.Add(tempchar); m_datetime.wSecond=temp.GetAsUInt32(); m_datetime.wMilliseconds=0; - - + /* to check if the user has entered a date containg year as zero or month as zero or day as zero*/ @@ -566,11 +667,55 @@ CalendarCtrl::OnClickOk() // handle NOW Click void -CalendarCtrl::OnClickNow() +CalendarCtrl::OnClickNow(DataView *m_dv) { - wyString temp; SYSTEMTIME seltime; - GetLocalTime(&seltime); + wyBool pretoshowserverdate; + + //Get preference setting to show server date or system date + pretoshowserverdate = GetPreferenceForNowButton(); + + if (pretoshowserverdate && m_dv != NULL) { + + MYSQL *mysql; + Tunnel *tunnel; + wyString query("select NOW()"); + MYSQL_RES *res; + MYSQL_ROW row; + wyString myrowstr; + wyInt32 qret; + + tunnel = m_dv->m_data->m_pmdi->m_tunnel; + mysql = m_dv->m_data->m_pmdi->m_mysql; + qret = HandleMySQLRealQuery(tunnel, mysql, query.GetString(), query.GetLength(), wyTrue, wyTrue, wyTrue); + + res = tunnel->mysql_store_result(mysql, wyTrue); + /* we specifically ignore empty queries */ + if (res == NULL && mysql->affected_rows == -1) + { + return; + } + row = tunnel->mysql_fetch_row(res); + myrowstr.SetAs(row[0]); + + seltime.wYear = atoi(myrowstr.Substr(0, 4)); + seltime.wMonth = atoi(myrowstr.Substr(5, 2)); + seltime.wDay = atoi(myrowstr.Substr(8, 2)); + seltime.wDayOfWeek = 0; + seltime.wHour = atoi(myrowstr.Substr(11, 2)); + seltime.wMinute = atoi(myrowstr.Substr(14, 2)); + seltime.wSecond = atoi(myrowstr.Substr(17, 2)); + seltime.wMilliseconds = 0; + + // free the result space + m_dv->m_data->m_pmdi->m_tunnel->mysql_free_result(res); + + } + else + { + GetLocalTime(&seltime); + } + EnableWindow(GetDlgItem(m_hwnd, IDOK), TRUE); MonthCal_SetCurSel(GetDlgItem(m_hwnd,IDC_MONTHCALENDAR1), &seltime); DateTime_SetFormat(GetDlgItem(m_hwnd,IDC_DATETIMEPICKER1), L"HH:mm:ss"); @@ -593,6 +738,23 @@ CalendarCtrl::OnClickCancel() delete this; } +// Get preference set by user +wyBool +CalendarCtrl::GetPreferenceForNowButton() +{ + wyWChar *lpfileport = 0; + wyWChar directory[MAX_PATH + 1] = { 0 }; + wyInt32 ret = 0; + wyString dirstr; + + // Get the complete path. + SearchFilePath(L"sqlyog", L".ini", MAX_PATH, directory, &lpfileport); + dirstr.SetAs(directory); + ret = wyIni::IniGetInt(GENERALPREFA, "ShowServerDate", 1, dirstr.GetString()); + + return(ret) ? (wyTrue) : (wyFalse); +} + // handle LButtonDown on parent (formview) void CalendarCtrl::OnLButtonDown(LPARAM lParam) diff --git a/src/CommonHelper.cpp b/src/CommonHelper.cpp index 6d9f2fc..221e07e 100644 --- a/src/CommonHelper.cpp +++ b/src/CommonHelper.cpp @@ -1130,6 +1130,119 @@ if(ptr) { return found; +} +wyBool GetCheckConstraintValue(wyChar * currentrow, wyString * expression) +{ + if (currentrow == NULL) + { + return wyFalse; + } + wyChar * find = "CHECK", *findcomment = "COMMENT"; + wyBool found = wyFalse; + wyChar *ptr = strstr(currentrow, find); + wyChar *ptrc = strstr(currentrow, findcomment); + wyString s1, s2,s3; + s1.SetAs(currentrow); + s2.SetAs(""); + s3.SetAs("COMMENT"); + wyInt32 index=0; + if (ptr) { + if (ptrc) { + index = ptr - currentrow + 5; + s2.SetAs(s1.Substr(index, 7)); + while (s2.CompareI(s3)!=0)//(currentrow[index + 2] != 'C' && currentrow[index + 3] != 'O' && currentrow[index + 4] != 'M') + { + expression->AddSprintf("%c", currentrow[index]); + index++; + s2.SetAs(s1.Substr(index, 7)); + } + found = wyTrue; + } + else + { + index = ptr - currentrow + 5; + + while (wyTrue) + { + if ((currentrow[index] == ',' && currentrow[index + 2] == ' ')|| (currentrow[index] == '\0' )) + break; + + expression->AddSprintf("%c", currentrow[index]); + index++; + } + found = wyTrue; + } + + } + + return found; + +} + +wyBool GettablelevelCheckConstraintValue(wyChar * currentrow, wyString * expression) +{ + wyChar * find = "CHECK"; + wyBool found = wyFalse;/*, withcomment = wyFalse, withoutcomment = wyFalse;*/ + wyChar *ptr = strstr(currentrow, find); + wyInt32 index=0; + if (ptr) { + found = wyTrue; + index =( ptr - currentrow) + 5; + while (currentrow[index] != '\0') + { + /*if (currentrow[index] == '\0' && currentrow[index + 2] == ' ') + break;*/ + expression->AddSprintf("%c", currentrow[index]); + index++; + } + const char last = expression->GetCharAt(expression->GetLength() - 1); + if (last == ',') + { + expression->Strip(1); + } + } + + return found; +} + +void +CheckForQuotesAndReplace(wyString *name) +{ + wyBool flag = wyFalse; + const char first = name->GetCharAt(0); + const char last = name->GetCharAt(name->GetLength() - 1); + + if (first == '`' && last == '`') + { + name->Strip(1); + name->Erase(0, 1); + } + return ; +} + +wyBool GetCheckConstraintName(wyChar * currentrow, wyString * checkconstraintname) +{ + wyChar * find = "CONSTRAINT"; + wyBool found = wyFalse; + wyString s1, s2(""), p; + wyInt32 index = 0; + + s1.SetAs(currentrow); + + wyChar *ptr = strstr(currentrow, find); + if (ptr) { + found = wyTrue; + index = ptr - currentrow + 12; + while (currentrow[index] != '`') + { + checkconstraintname->AddSprintf("%c", currentrow[index]); + index++; + } + + } + + return found; + } wyInt32 GetBitFieldColumnWidth(wyString &strcreate, wyInt32 fieldpos) @@ -4332,6 +4445,82 @@ RemoveDefiner(wyString &text, const wyChar* pattern, wyInt32 extra) } + +void +RemoveBrackets(wyString &text, const wyChar* pattern) +{ + + wyInt32 ovector[30]; + pcre *re; + wyInt32 erroffset, rc = -1, sucess = 0;//, i = 0; + wyInt32 subject_length, text_length; + const char *error; + wyString tempstr, strfirst,strlast; + wyChar * tempstr1 = NULL; + + + + subject_length = (wyInt32)strlen(text.GetString()); + + re = pcre_compile( + pattern, /* the pattern */ + PCRE_UTF8 | PCRE_CASELESS | PCRE_NEWLINE_CR,/* default options */ //match is a case insensitive + &error, /* for error message */ + &erroffset, /* for error offset */ + NULL); /* use default character tables */ + + /* Compilation failed: print the error message and exit */ + + if (re == NULL) + return; + + /************************************************************************* + * If the compilation succeeded, we call PCRE again, in order to do a * + * pattern match against the subject string. This does just ONE match * + *************************************************************************/ + + rc = pcre_exec( + re, /* the compiled pattern */ + NULL, /* no extra data - we didn't study the pattern */ + text.GetString(), /* the subject string */ + subject_length, /* the length of the subject */ + 0, /* start at offset 0 in the subject */ + PCRE_NO_UTF8_CHECK, /* default options */ + ovector, /* output vector for substring information */ + 30); /* number of elements in the output vector */ + + if (re) + pcre_free(re); + + tempstr.SetAs(text.GetString()); + strlast.SetAs(text.GetString()); + + if (rc == 2) + { + tempstr1=tempstr.Substr(ovector[0], ovector[1]); + if (tempstr1 != NULL) + { + text.SetAs(tempstr1); + } + strlast.Erase(ovector[0], ovector[1] - ovector[0]); + } + //Add method to remove the opening and closing brackets + text_length = (wyInt32)strlen(strlast.GetString()); + + const char first = strlast.GetCharAt(0); + const char last = strlast.GetCharAt(text_length - 1); + + + if (strcmp(&first,"(")==0 && strcmp(&last, ")")==0) + { + strlast.Erase(0, 1); + strlast.Strip(1); + } + strfirst.AddSprintf("%s%s", text.GetString(), strlast.GetString()); + text.SetAs(strfirst); + +} + //void DebugLog(const char *buffer) //{ // wyWChar directory[MAX_PATH+1]; diff --git a/src/ConnectionTab.cpp b/src/ConnectionTab.cpp index 6b95f06..fdc586c 100644 --- a/src/ConnectionTab.cpp +++ b/src/ConnectionTab.cpp @@ -38,6 +38,8 @@ extern PGLOBALS pGlobals; ConnectionTab::ConnectionTab() { + pGlobals->m_connectiontabnamelist = new List; + pGlobals->m_mdilistfordropdown = new List; } ConnectionTab::~ConnectionTab() @@ -103,6 +105,7 @@ ConnectionTab::DeleteConnectionTabItem(HWND hwnd) } + //To insert a connection tab item wyBool ConnectionTab::InsertConnectionTab(wyString * title, LPARAM lparam, wyBool iscon_res,ConnectionInfo* conninfo) @@ -111,7 +114,8 @@ ConnectionTab::InsertConnectionTab(wyString * title, LPARAM lparam, wyBool iscon HWND hwndtab; unsigned long tempcolor = -1; MDIWindow *wnd = GetActiveWin(); - wyString tabname; + TabModule * hwndTabModule = wnd->m_pctabmodule; + wyString tabname,t1; if(!wnd) { @@ -119,9 +123,16 @@ ConnectionTab::InsertConnectionTab(wyString * title, LPARAM lparam, wyBool iscon } hwndtab = pGlobals->m_pcmainwin->m_hwndconntab; - + pGlobals->m_conncount; tabname.Sprintf(" %s", wnd->m_title.GetString()); + ListofOpenTabs *tabdetails = new ListofOpenTabs; + + //set the node of global m_connectiontabnamelist + tabdetails->name.SetAs(wnd->m_title.GetString()); + tabdetails->m_hwndTabModuleinlist = hwndTabModule; + pGlobals->m_connectiontabnamelist->Insert(tabdetails); + CTCITEM item = {0}; item.m_psztext = (wyChar*)tabname.GetString(); item.m_cchtextmax = tabname.GetLength(); diff --git a/src/CustTab.cpp b/src/CustTab.cpp index 86606a3..5da835a 100644 --- a/src/CustTab.cpp +++ b/src/CustTab.cpp @@ -41,10 +41,11 @@ the perfomance and a few redundant members are removed. #define FIXED_WIDTH 150 #define SCROLLBUTTONPADDING 1 #define SCROLLBUTTONWIDTH (16 + SCROLLBUTTONPADDING) -#define RIGHTPADDING(ISPLUSSIGN) (ISPLUSSIGN ? SCROLLBUTTONWIDTH + 28 : SCROLLBUTTONWIDTH) +#define RIGHTPADDING(ISPLUSSIGN) (ISPLUSSIGN ? SCROLLBUTTONWIDTH + 50 : SCROLLBUTTONWIDTH) #define SCROLLTHRESHOLD 10 #define IDC_LEFTSCROLL 1 #define IDC_RIGHTSCROLL 2 +#define IDC_DROPDOWN 14 #define IDC_PLUSSIGN 3 #define DRAGSCROLLTIMER 100 #define SCROLLTIMER 200 @@ -1475,13 +1476,18 @@ CCustTab::OnLButtonUp(WPARAM wPram, LPARAM lParam) nmctc.curpos = pnt; SendTabMessage(CTCN_PLUSBUTTONCLICK, &nmctc); } + else if (i == IDC_DROPDOWN) + { + ClientToScreen(m_hwnd, &pnt); + nmctc.curpos = pnt; + SendTabMessage(CTCN_DROPDOWNBUTTONCLICK, &nmctc); + } else { KillTimer(m_hwnd, SCROLLTIMER); } } } - SetCursor(LoadCursor(NULL, IDC_ARROW)); m_closebuttondowntab = -1; m_tabcontroldown = -1; @@ -1558,6 +1564,9 @@ CCustTab::OnDragEnd() } } + //m_selectedtab and dropindex , find the node store in a tem and insert before and after wyInt32 m_selectedtab + FindAndUpdateTheDropDown(m_selectedtab, dropindex); + m_tabdet[dropindex] = tabitem; m_selectedtab = dropindex; } @@ -1583,8 +1592,193 @@ CCustTab::OnDragEnd() } EnsureVisible(m_selectedtab); + +} + +void +CCustTab::FindAndUpdateTheDropDown(wyInt32 selectedtab,wyInt32 dropindex) +{ + wyInt32 nooftab, conncount; + wyBool isconndrag = wyFalse; + + wyString* title1 = new wyString(); + GetItemTitle(selectedtab, title1); + //find the name and type of the tab and change the location of that perticular tab only + ListofOpenTabs * listofopentabs = (ListofOpenTabs *)pGlobals->m_connectiontabnamelist->GetFirst(); + + //getting the count of open connections + conncount = pGlobals->m_connectiontabnamelist->GetCount(); + for (nooftab = 0; nooftab < conncount; nooftab++) + { + title1->LTrim(); + title1->RTrim(); + //int y = title1->CompareI(listofopentabs->name.GetString());//getting name of the connection + if (title1->CompareI(listofopentabs->name.GetString())==0) + { + isconndrag = wyTrue; + break; + } + listofopentabs = (ListofOpenTabs *)listofopentabs->m_next; //moving pointer to next conenction window + } + if (isconndrag) + { + UpdateDropDownNodePosforconnection(m_selectedtab, dropindex); + } + else + { + UpdateDropDownStructPosition(m_selectedtab, dropindex); + } + +} + +void +CCustTab::UpdateDropDownStructPosition(wyInt32 selectedtab, wyInt32 dropindex) +{ + //to initialise the structure for drop down + MDIListForDropDrown *p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); + wyBool found = wyFalse; + ListOfOpenQueryTabs *listofopentabs,*currnodefroseltab, *currnodefroindextab,*prevsel; + wyBool dragnodefound = wyFalse, selnodefound = wyFalse; + wyInt32 tabcount; + + MDIWindow *wnd = GetActiveWin(); + if(!wnd) + { + return; + } + + //To search for the particular tab + while (p) + { + if (wnd == p->mdi) + { + found = wyTrue; + break; + } + p = (MDIListForDropDrown *)p->m_next; + } + + if (found) { + listofopentabs = (ListOfOpenQueryTabs *)p->opentab->GetFirst(); + if(!listofopentabs) + { + return; + } + tabcount = p->opentab->GetCount(); + + for (int i = 0; i < tabcount; i++) + { + if (i == dropindex && dragnodefound==wyFalse) //not to change the index if dragindex is found once + { + prevsel = (ListOfOpenQueryTabs *)listofopentabs->m_prev; + currnodefroindextab = listofopentabs; + dragnodefound = wyTrue; + } + if (i == selectedtab && selnodefound==wyFalse) //not to change the index if selindex is found once + { + currnodefroseltab = listofopentabs; + selnodefound = wyTrue; + } + if (selnodefound && dragnodefound) //if both node are found + { + break; + } + + listofopentabs = (ListOfOpenQueryTabs *)listofopentabs->m_next; + + } + if (selnodefound && dragnodefound) //if both node are found + { + if (dropindexopentab->Remove(currnodefroseltab); + p->opentab->InsertBefore(currnodefroindextab, currnodefroseltab); + + } + else + { + p->opentab->Remove(currnodefroseltab); + p->opentab->InsertAfter(prevsel, currnodefroseltab); + } + + } + else + { + p->opentab->Remove(currnodefroseltab); + p->opentab->InsertAfter(currnodefroindextab, currnodefroseltab); + } + + } + + } + } +void +CCustTab::UpdateDropDownNodePosforconnection(wyInt32 selectedtab, wyInt32 dropindex) +{ + ListofOpenTabs *listofopentabs, *currnodefroseltab, *currnodefroindextab,*prevsel; + wyBool dragnodefound = wyFalse, selnodefound = wyFalse; + wyInt32 conncount; + + listofopentabs = (ListofOpenTabs *)pGlobals->m_connectiontabnamelist->GetFirst(); + List *p = pGlobals->m_connectiontabnamelist; + + if (!listofopentabs) + { + return; + } + + conncount = pGlobals->m_connectiontabnamelist->GetCount(); + + for (int i = 0; i < conncount; i++) + { + if (i == dropindex && dragnodefound == wyFalse) //not to change the index if dragindex is found once + { + prevsel = (ListofOpenTabs *)listofopentabs->m_prev; + currnodefroindextab = listofopentabs; + dragnodefound = wyTrue; + } + if (i == selectedtab && selnodefound == wyFalse) //not to change the index if selindex is found once + { + currnodefroseltab = listofopentabs; + selnodefound = wyTrue; + } + if (selnodefound && dragnodefound) //if both node are found + { + break; + } + + listofopentabs = (ListofOpenTabs *)listofopentabs->m_next; + + } + if (selnodefound && dragnodefound) //if both node are found + { + if(dropindexRemove(currnodefroseltab); + p->InsertBefore(currnodefroindextab, currnodefroseltab); + } + else + { + p->Remove(currnodefroseltab); + p->InsertAfter(prevsel, currnodefroseltab); + } + + } + else + { + p->Remove(currnodefroseltab); + p->InsertAfter(currnodefroindextab, currnodefroseltab); + } + + } + +} wyInt32 CCustTab::OverTabs(PPOINT pnt, wyBool* pisoverclosebutton) @@ -1649,7 +1843,7 @@ wyInt32 CCustTab::OverTabControls(POINT* pt) { RECT rect = {0, 0, SCROLLBUTTONWIDTH, m_size.cy + EXTRAHEIGHT - 1}, temprect; - wyInt32 i, left = 0, width = 8; + wyInt32 i, left = 0, width = 20; if(m_isscroll) { @@ -1673,17 +1867,28 @@ CCustTab::OverTabControls(POINT* pt) if(PtInRect(&rect, *pt)) { - temprect.left = rect.left + ((rect.right - rect.left) / 2) - (width / 2) - 2; + temprect.left = rect.left + ((rect.right - rect.left) / 2);// -(width / 2) + 1; temprect.right = temprect.left + width; - temprect.top = rect.top + ((rect.bottom - rect.top) / 2) - (width / 2); + temprect.top = rect.top + ((rect.bottom - rect.top) / 2) -(width / 2); temprect.top += (m_isfixedlength == wyTrue) ? 2 : 1; temprect.bottom = temprect.top + width; - temprect.left -= 4; + if (PtInRect(&temprect, *pt)) + { + return IDC_DROPDOWN; + } + + temprect.left = rect.left;// +((rect.right - rect.left) / 2);// -(width / 2) + 1; + temprect.right = temprect.left + width; + temprect.top = rect.top + ((rect.bottom - rect.top) / 2) -(width / 2); + temprect.top += (m_isfixedlength == wyTrue) ? 2 : 1; + temprect.bottom = temprect.top + width; + + /* temprect.left -= 5; temprect.top -= 4; temprect.bottom += 4; - temprect.right += 4; - + temprect.right -= 1; +*/ if(!PtInRect(&temprect, *pt)) { return -1; @@ -1712,16 +1917,16 @@ CCustTab::OverTabControls(POINT* pt) if(PtInRect(&rect, *pt)) { - temprect.left = rect.left + ((rect.right - rect.left) / 2) - (width / 2) - 2; + temprect.left = rect.left + ((rect.right - rect.left) / 2) -(width / 2) - 2; temprect.right = temprect.left + width; temprect.top = rect.top + ((rect.bottom - rect.top) / 2) - (width / 2); temprect.top += (m_isfixedlength == wyTrue) ? 2 : 1; temprect.bottom = temprect.top + width; - temprect.left -= 4; - temprect.top -= 4; - temprect.bottom += 4; - temprect.right += 4; + temprect.left -= 10; + temprect.top += 4; + temprect.bottom += 4; + temprect.right -= 10; if(!PtInRect(&temprect, *pt)) { @@ -2005,11 +2210,18 @@ CCustTab::SetGradient(HDC hdcmem, TRIVERTEX *vertex) /*Function is used to remove a particular tab*/ wyBool -CCustTab::DeleteItem(wyInt32 tabindex, wyBool isexplicit) +CCustTab::DeleteItem(wyInt32 tabindex, wyBool isexplicit, wyBool ispositionrequired) { LPCTCITEMEX newa = NULL; wyInt32 ret, selindex; NMCTC nmctc = {0}; + ListofOpenTabs * listofopentabs; + wyInt64 tabcount,i; + wyBool deletedfromstruct = wyFalse, found = wyFalse, delfound = wyFalse,nodefound =wyFalse; + MDIListForDropDrown *pfound = NULL, *p; + ListofOpenTabs * temp; + MDIWindow *wnd; + wnd = GetActiveWin(); if(tabindex >= m_tabs || tabindex < 0) { @@ -2079,6 +2291,55 @@ CCustTab::DeleteItem(wyInt32 tabindex, wyBool isexplicit) m_istabchanging = wyFalse; } + //Added code to Remove the tab from drop down structure + if (!ispositionrequired) { // + //getting the head of the list containing all connection details + p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); + if (!p) + { + return wyTrue; + } + if (!wnd) + { + return wyTrue; + } + // To search for the particular tab + while (p) + { + if (wnd == p->mdi) + { + found = wyTrue; + pfound = p; + nodefound = wyTrue; + break; + } + p = (MDIListForDropDrown *)p->m_next; + } + + // getting the tab which is being closed + if (found) { + listofopentabs = (ListofOpenTabs *)p->opentab->GetFirst(); + tabcount = p->opentab->GetCount(); + + for (i = 0; i < tabcount; i++) + { + if (i == tabindex && !deletedfromstruct) + { + temp = listofopentabs; + deletedfromstruct = wyTrue; + delfound = wyTrue; + break; + } + listofopentabs = (ListofOpenTabs *)listofopentabs->m_next; + } + if (delfound) + { + p->opentab->Remove(temp); + delfound = wyFalse; + } + } + } + return wyTrue; } @@ -2818,12 +3079,13 @@ CCustTab::DrawTabs(HDC hdc) { DrawScrollButton(hdc, IDC_LEFTSCROLL, 0, &pt); DrawScrollButton(hdc, IDC_RIGHTSCROLL, rect.right - RIGHTPADDING(m_isplussign) + 1 + SCROLLBUTTONPADDING, &pt); + DrawScrollButton(hdc, IDC_DROPDOWN, rect.right - RIGHTPADDING(m_isplussign) + 1 + SCROLLBUTTONPADDING + 40, &pt); i = rect.right; hpen = (HPEN)SelectObject(hdc, m_hpenactivesep); //rect.bottom = m_size.cy + RECTHEIGHT + TABTOPSPACE; rect.top = 0; rect.left = rect.right - RIGHTPADDING(m_isplussign) + 1; - MoveToEx(hdc, rect.left, drawrect.bottom - 1, NULL); + MoveToEx(hdc, rect.left, drawrect.bottom - 1, NULL); LineTo(hdc, rect.right + 1, drawrect.bottom - 1); rect.right = SCROLLBUTTONWIDTH; @@ -2845,6 +3107,7 @@ CCustTab::DrawTabs(HDC hdc) { DrawPlusButton(hdc, &rect, &pt); } + } void @@ -2921,6 +3184,17 @@ CCustTab::DrawScrollButton(HDC hdc, wyInt32 id, wyInt32 x,PPOINT pnt) arrowpoints[1].y = height; arrowpoints[2].x = (id == IDC_RIGHTSCROLL) ? drawrect.left : drawrect.right; arrowpoints[2].y = height + SCALEANTIALIASING(6) - scale; + + if (id == IDC_DROPDOWN) + { + height = ((drawrect.bottom - drawrect.top) / 2) + drawrect.top; + arrowpoints[0].x = drawrect.left - SCALEANTIALIASING(2); + arrowpoints[0].y = height - SCALEANTIALIASING(6) + scale; + arrowpoints[1].x = drawrect.right + SCALEANTIALIASING(2); + arrowpoints[1].y = height - SCALEANTIALIASING(6) + scale; + arrowpoints[2].x = (drawrect.left + drawrect.right) / 2; + arrowpoints[2].y = height + SCALEANTIALIASING(2) - scale; + } hrgnarrow = CreatePolygonRgn(arrowpoints, 3, WINDING); FillRgn(m_hdcantialias, hrgnarrow, hbr); @@ -2951,7 +3225,7 @@ CCustTab::DrawPlusButton(HDC hdc, PRECT prect, PPOINT pnt) TRIVERTEX vertex[2]; width = 8; - rect.left = prect->left + ((prect->right - prect->left) / 2) - (width / 2) - 2; + rect.left = prect->left + ((prect->right - prect->left) / 2) - (width / 2) - 10; rect.right = rect.left + width; rect.top = prect->top + ((prect->bottom - prect->top) / 2) - (width / 2); @@ -3747,12 +4021,12 @@ LPARAM CustomTab_GetLongData(HWND hwnd) return pct->GetLongData(); } -wyBool CustomTab_DeleteItem(HWND hwnd, wyInt32 tabcount) +wyBool CustomTab_DeleteItem(HWND hwnd, wyInt32 tabcount,wyBool ispositionrequired) { wyBool ret; CCustTab *pct = GetCustTabCtrlData(hwnd); - ret = pct->DeleteItem(tabcount); + ret = pct->DeleteItem(tabcount, wyFalse ,ispositionrequired); pct->OnWMSize(); pct->PaintTab(); diff --git a/src/EditorProcs.cpp b/src/EditorProcs.cpp index 38962db..572b243 100644 --- a/src/EditorProcs.cpp +++ b/src/EditorProcs.cpp @@ -65,38 +65,39 @@ EditorProcs::Create(MDIWindow *wnd, HTREEITEM hitem, wyString *strhitemname) HWND EditorProcs::CreateAdvEdit(MDIWindow *wnd, HWND hwnd, HTREEITEM hitem, wyString *strhitemname) { - if(CreateEditor(wnd, hwnd) == NULL) - return NULL; - + if (CreateEditor(wnd, hwnd) == NULL) + return NULL; + m_hitem = hitem; - if(strhitemname) - m_hitemname.SetAs(strhitemname->GetString()); - else - m_hitemname.Clear(); + if (strhitemname) { + m_hitemname.SetAs(strhitemname->GetString()); + } + else + m_hitemname.Clear(); - m_dbname.SetAs(wnd->m_pcqueryobject->m_seldatabase); + m_dbname.SetAs(wnd->m_pcqueryobject->m_seldatabase); - m_nodeimage = GetItemImage(wnd->m_pcqueryobject->m_hwnd, TreeView_GetSelection(wnd->m_pcqueryobject->m_hwnd)); + m_nodeimage = GetItemImage(wnd->m_pcqueryobject->m_hwnd, TreeView_GetSelection(wnd->m_pcqueryobject->m_hwnd)); - switch(m_nodeimage) - { + switch (m_nodeimage) + { case NTABLE: - m_nodeimage = NTABLES; - break; + m_nodeimage = NTABLES; + break; case NVIEWSITEM: - m_nodeimage = NVIEWS; + m_nodeimage = NVIEWS; break; case NEVENTITEM: - m_nodeimage = NEVENTS; - break; + m_nodeimage = NEVENTS; + break; case NSPITEM: - m_nodeimage = NSP; + m_nodeimage = NSP; break; case NFUNCITEM: - m_nodeimage = NFUNC; + m_nodeimage = NFUNC; break; case NTRIGGERITEM: - m_nodeimage = NTRIGGER; + m_nodeimage = NTRIGGER; break; case NFOLDER: break; @@ -105,12 +106,12 @@ EditorProcs::CreateAdvEdit(MDIWindow *wnd, HWND hwnd, HTREEITEM hitem, wyString case NSP: case NFUNC: case NTABLES: - case NTRIGGER: - break; + case NTRIGGER: + break; case NDATABASE: - break; + break; } - + return m_hwnd; } diff --git a/src/FrameWindow.cpp b/src/FrameWindow.cpp index 435e75f..aab5b89 100644 --- a/src/FrameWindow.cpp +++ b/src/FrameWindow.cpp @@ -59,6 +59,7 @@ #include "CCustomComboBox.h" #include "Http.h" #include "htmlayout.h" +#include "TabCheck.h" #ifndef COMMUNITY #include "RegistrationApi.h" @@ -233,6 +234,8 @@ FrameWindow::FrameWindow(HINSTANCE hinstance) #ifdef COMMUNITY m_commribbon = NULL; #endif + + m_isresizing = wyFalse; } @@ -1506,6 +1509,10 @@ FrameWindow::WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) break; + case WM_SIZING: + pcmainwin->m_isresizing = wyTrue; + return 1; + case WM_SIZE: return pcmainwin->OnWmSize(wparam); @@ -2237,6 +2244,7 @@ FrameWindow::Resize(WPARAM wparam) m_connection->ResizeStatusWindow(GetHwnd(), GetStatusHwnd()); ResizeMDIWindow(); + m_isresizing = wyFalse; //To paint properely while maximizing frame window if(GetHwnd() && wparam == SIZE_MAXIMIZED) @@ -2796,6 +2804,7 @@ FrameWindow::OnWmCommand(WPARAM wParam) if(hwndactive) CreateNewQueryEditor(pcquerywnd); break; + case ID_EDIT_SWITCHTABSTORIGHT: case ACCEL_NAVIGATETABDOWN: @@ -5015,7 +5024,7 @@ FrameWindow::OnActiveConn() ID_COMMIT_ANDCHAIN, ID_COMMIT_ANDNOCHAIN, ID_COMMIT_RELEASE, ID_COMMIT_NORELEASE, ID_ROLLBACK_TOSAVEPOINT, ID_ROLLBACK_ANDCHAIN, ID_ROLLBACK_ANDNOCHAIN, ID_ROLLBACK_RELEASE, ID_ROLLBACK_NORELEASE, ID_SAVEPOINT_CREATESAVEPOINT, - ID_SAVEPOINT_RELEASESAVEPOINT}; + ID_SAVEPOINT_RELEASESAVEPOINT }; if(pGlobals->m_conncount == 0) { @@ -5943,6 +5952,9 @@ FrameWindow::HandleCreateTrigger(HWND hwnd, MDIWindow *pcquerywnd, wyWChar *trig query.Sprintf("show triggers from `%s` where `Trigger` = '%s'", db.GetString(), triggernamestr.GetString()); + //update the structure to add trigger name to the drop down + //UpdateDropDownStruct(triggernamestr.GetString()); + res = ExecuteAndGetResult(pcquerywnd, pcquerywnd->m_tunnel, &pcquerywnd->m_mysql, query); if(!res && pcquerywnd->m_tunnel->mysql_affected_rows(pcquerywnd->m_mysql)== -1) { @@ -5962,11 +5974,48 @@ FrameWindow::HandleCreateTrigger(HWND hwnd, MDIWindow *pcquerywnd, wyWChar *trig return wyTrue; } +void +FrameWindow::UpdateDropDownStruct(wyString tabname) +{ + + + //to initialise the structure for drop down + MDIListForDropDrown *p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); + wyBool found = wyFalse; + //wyString tabbname = ""; + MDIListForDropDrown *pfound = p; + ListOfOpenQueryTabs *newnode; + + MDIWindow *wnd = GetActiveWin(); + + //To search for the particular tab + while (p) + { + if (wnd == p->mdi) + { + found = wyTrue; + pfound = p; + break; + } + p = (MDIListForDropDrown *)p->m_next; + } + + if (found) { + + //search for the particular tab which is modified + + newnode = new ListOfOpenQueryTabs(); + newnode->tabname.SetAs(tabname); + pfound->opentab->Insert(newnode); + } + +} + void FrameWindow::PrepareCreateProcedure(MDIWindow *pcquerywnd, const wyChar *procedurename, wyString &strproc) { - wyString db; - + wyString db,spname; + spname.SetAs(procedurename); GetSelectedDB(pcquerywnd, db); if(db.GetLength() == 0) @@ -5980,14 +6029,17 @@ FrameWindow::PrepareCreateProcedure(MDIWindow *pcquerywnd, const wyChar *procedu | COMMENT 'string'*/\r\n\tBEGIN\r\n\r\n\tEND", db.GetString(), procedurename, db.GetString(), procedurename); + //update the structure to add trigger name to the drop down + //UpdateDropDownStruct(spname.GetString()); + return; } void FrameWindow::PrepareCreateFunction(MDIWindow *pcquerywnd, const wyChar *functionname, wyString &strfunc) { - wyString db; - + wyString db,funname; + funname.SetAs(functionname); GetSelectedDB(pcquerywnd, db); if(db.GetLength() == 0) @@ -6036,7 +6088,8 @@ FrameWindow::PrepareCreateTrigger(MDIWindow *pcquerywnd, const wyChar *triggerna void FrameWindow::PrepareCreateView(MDIWindow *pcquerywnd, const wyChar *viewname, wyString &strview, wyString *qbquery) { - wyString db; + wyString db,vwname; + vwname.SetAs(viewname); GetSelectedDB(pcquerywnd, db); @@ -6058,13 +6111,17 @@ FrameWindow::PrepareCreateView(MDIWindow *pcquerywnd, const wyChar *viewname, wy if(qbquery) strview.Add(qbquery->GetString()); #endif + //update the structure to add trigger name to the drop down + //UpdateDropDownStruct(vwname.GetString()); return; } void FrameWindow::PrepareCreateEvent(MDIWindow *pcquerywnd, const wyChar *eventname, wyString &strevent) { - wyString db; + wyString db,evname; + + evname.SetAs(eventname); GetSelectedDB(pcquerywnd, db); @@ -6084,6 +6141,9 @@ FrameWindow::PrepareCreateEvent(MDIWindow *pcquerywnd, const wyChar *eventname, ENDS CURRENT_TIMESTAMP/'YYYY-MM-DD HH:MM.SS' { + INTERVAL 1 [HOUR|MONTH|WEEK|DAY|MINUTE|...] } */\r\n\r\n\ /*[ON COMPLETION [NOT] PRESERVE]\r\n[ENABLE | DISABLE]\r\n[COMMENT 'comment']*/\r\n\r\nDO\r\n\tBEGIN\r\n\t (sql_statements)\r\n\tEND", db.GetString(), eventname, db.GetString(), eventname); + + //update the structure to add trigger name to the drop down + //UpdateDropDownStruct(evname.GetString()); return; } @@ -7441,6 +7501,13 @@ FrameWindow::ONWmMainWinNotify(HWND hwnd, LPARAM lparam, WPARAM wparam) case CTCN_PAINTTIMEREND: CustomTab_SetBufferedDrawing(wyFalse); break; + + case CTCN_DROPDOWNBUTTONCLICK: + if (lpnmhdr->idFrom == IDC_CONNECTIONTAB) + { + LoadConnTabDropDownMenu(lparam); + } + break; } return 1; @@ -8100,6 +8167,9 @@ FrameWindow::OnCreateFunction(HWND hwndactive, MDIWindow *wnd) pGlobals->m_pcmainwin->HandleGoTo(pGlobals->m_pcmainwin->m_hwndmain, wnd, L"8"); // set focus on 8th line + //update the structure to add trigger name to the drop down + //UpdateDropDownStruct(functionnamestr.GetString()); + free(functionname); VERIFY(SetCursor(LoadCursor(NULL, IDC_ARROW))); @@ -9614,6 +9684,69 @@ FrameWindow::LoadConnTabPlusMenu(LPARAM lparam) VERIFY(DestroyMenu(hmenu)); } +void +FrameWindow::LoadConnTabDropDownMenu(LPARAM lparam) +{ + LPNMCTC lpnmctc; + wyString tabname(""); + wyWChar *namestring; + wyInt64 conncount, nooftab,id=0, cmdid=0; + //opentabs *head = pGlobals->m_headtolist, *p; + BOOL flag; + HMENU hsubmenu; + static wyInt32 activetabid = 0; + ListofOpenTabs *listofopentabs;// = new ListofOpenTabs; + + //Creating the menu + hsubmenu = ::CreatePopupMenu(); + + + //getting list of opentabs from global variable + listofopentabs = (ListofOpenTabs *)pGlobals->m_connectiontabnamelist->GetFirst(); + + lpnmctc = (LPNMCTC)lparam; + + //hmenu = LoadMenu(pGlobals->m_hinstance, MAKEINTRESOURCE(IDR_CONNDROPDOWNMENU)); + LocalizeMenu(hsubmenu); + //htrackmenu = GetSubMenu(hmenu, 0); + + //getting the count of open connections + conncount = pGlobals->m_connectiontabnamelist->GetCount(); + id = 1; + for (nooftab = 0; nooftab < conncount; nooftab++) + { + tabname.SetAs(listofopentabs->name.GetString());//getting name of the connection + namestring = tabname.GetAsWideChar(); + flag=InsertMenu(hsubmenu, -1, MF_BYPOSITION, id, namestring); + id++; + listofopentabs = (ListofOpenTabs *)listofopentabs->m_next; //moving pointer to next conenction window + } + + // Set menu draw property for drawing icon + //wyTheme::SetMenuItemOwnerDraw(hmenu); + activetabid = CustomTab_GetCurSel(pGlobals->m_pcmainwin->m_hwndconntab); + + SetMenuDefaultItem(hsubmenu, activetabid, TRUE); + + cmdid = TrackPopupMenu(hsubmenu, TPM_RETURNCMD | TPM_LEFTALIGN | TPM_RIGHTBUTTON, lpnmctc->curpos.x - 15, lpnmctc->curpos.y + 15, 0, pGlobals->m_pcmainwin->m_hwndconntab, NULL); + + if (cmdid == 0) + { + CustomTab_SetCurSel(pGlobals->m_pcmainwin->m_hwndconntab, activetabid,1); + CustomTab_EnsureVisible(pGlobals->m_pcmainwin->m_hwndconntab, activetabid); + } + else + { + CustomTab_SetCurSel(pGlobals->m_pcmainwin->m_hwndconntab, cmdid-1,1); + CustomTab_EnsureVisible(pGlobals->m_pcmainwin->m_hwndconntab, cmdid-1); + } + + activetabid = CustomTab_GetCurSel(pGlobals->m_pcmainwin->m_hwndconntab); + + //FreeMenuOwnerDrawItem(htrackmenu); + VERIFY(DestroyMenu(hsubmenu)); +} + void CALLBACK FrameWindow::TooltipTimerProc(HWND hwnd, UINT message, UINT_PTR id, DWORD time) { diff --git a/src/FrameWindowHelper.cpp b/src/FrameWindowHelper.cpp index bef4e26..cfc85d5 100644 --- a/src/FrameWindowHelper.cpp +++ b/src/FrameWindowHelper.cpp @@ -136,7 +136,7 @@ wyInt32 my_query(MDIWindow *wnd, Tunnel * tunnel, PMYSQL mysql, const wyChar *qu if(wnd) wnd->m_execstarttime = timetaken = GetHighPrecisionTickCount(); //execution starting time - ret = HandleMySQLRealQuery(tunnel,*mysql, query, length, isbadforxml, + ret = HandleMySQLRealQuery(tunnel,*mysql, query, length, isbadforxml, batch, isend, (bool*)stop, isread ? true : false, fksethttpimport == wyTrue ? true:false); tsrecon = GetHighPrecisionTickCount(); diff --git a/src/FrameWindowSplitter.cpp b/src/FrameWindowSplitter.cpp index 9702630..981e287 100644 --- a/src/FrameWindowSplitter.cpp +++ b/src/FrameWindowSplitter.cpp @@ -144,47 +144,55 @@ FrameWindowSplitter::WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpar // function to resize the splitter window. wyBool -FrameWindowSplitter::Resize(wyBool isannouncements) +FrameWindowSplitter::Resize(wyBool isannouncements, wyBool iswindowresize) { RECT parentrect; LONG ret; - MDIWindow * pcquerywnd = (MDIWindow*)GetWindowLongPtr(m_hwndparent, GWLP_USERDATA); + MDIWindow * pcquerywnd = (MDIWindow*)GetWindowLongPtr(m_hwndparent, GWLP_USERDATA); _ASSERT(pcquerywnd); VERIFY(GetClientRect(m_hwndparent, &parentrect)); - parentrect.top += 2; - parentrect.bottom -= 2; - parentrect.left += 2; - parentrect.right -= 2; - if(isannouncements) + parentrect.top += 2; + parentrect.bottom -= 2; + parentrect.left += 2; + + parentrect.right -= 2; + if (isannouncements) { //force splitter to 22% of the screen for announcements window //m_rect.left = 272; - if(m_leftortoppercent < 22) + if (m_leftortoppercent < 22) m_leftortoppercent = 22; } - m_rect.left = (long)((parentrect.right *((long)m_leftortoppercent /(float)100))); - m_rect.top = parentrect.top; //set the splitter size same as other controls - m_rect.right = m_width; - m_rect.bottom = parentrect.bottom - m_rect.top; + //if (m_rect.left <= 2) + // m_rect.left = (long)((parentrect.right *((long)m_leftortoppercent / (float)100))); + + if (!pGlobals->m_pcmainwin->m_isresizing) { + m_rect.left = (long)((parentrect.right *((long)m_leftortoppercent / (float)100))); + } + + m_rect.top = parentrect.top; //set the splitter size same as other controls + m_rect.right = m_width; + m_rect.bottom = parentrect.bottom - m_rect.top; + + if (m_rect.left < 2) + { + m_rect.left = 2; + } + //If Object Browser size is greater than main window size then retain Object Browser size + if (m_rect.left + m_width > parentrect.right) + { + m_rect.left = parentrect.right - m_width; + } - if(m_rect.left < 2) - { - m_rect.left = 2; - } - if(m_rect.left + m_width > parentrect.right) - { - m_rect.left = parentrect.right - m_width; - } - if(pcquerywnd->m_isobjbrowvis == wyTrue) pGlobals->m_pcmainwin->SetSplitterPos(&m_rect, m_leftortoppercent); - VERIFY(ret = MoveWindow(m_hwnd, m_rect.left, m_rect.top, m_rect.right, m_rect.bottom, TRUE)); - + VERIFY(ret = MoveWindow(m_hwnd, m_rect.left, m_rect.top, m_rect.right, m_rect.bottom, TRUE)); + return wyTrue; } diff --git a/src/MDIWindow.cpp b/src/MDIWindow.cpp index 67f41a9..8c47fd3 100644 --- a/src/MDIWindow.cpp +++ b/src/MDIWindow.cpp @@ -42,6 +42,7 @@ #include "TableTabInterface.h" #include "TableTabInterfaceTabMgmt.h" #include "OtherDialogs.h" +#include "List.h" #ifndef COMMUNITY #include "ConnectionEnt.h" @@ -161,6 +162,9 @@ MDIWindow::MDIWindow(HWND hwnd, ConnectionInfo * conninfo, wyString &dbname, wyS m_isanncreate = wyFalse; m_listtabeditor = NULL; m_listtabdetails = NULL; + m_isfromsave = wyFalse; + m_isfromsaveas = wyFalse; + m_fromdirtytab = wyFalse; //m_tabposition = 0; } @@ -459,7 +463,13 @@ MDIWindow::WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) ConnectionBase* conbase = NULL; wyInt32 exstyle; wyString errmsg; - + //wyInt32 nWidth; + + //wyString str; + + //str.Sprintf("MDI window message - %d", message); + //logtext1(str.GetString()); + switch(message) { /*case WM_COMMAND: @@ -557,7 +567,12 @@ MDIWindow::WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) break; case WM_SIZE: - pcquerywnd->Resize(); + + //str.Sprintf("MDI window size - %d", message); + //logtext1(str.GetString()); + + //nWidth = LOWORD(lparam); + pcquerywnd->Resize(wyTrue); //8.04, for avoiding painting issues at border of con. window when 'Restored' if(wparam == SIZE_RESTORED && pcquerywnd->m_ismanualresizing == wyFalse) @@ -906,6 +921,14 @@ MDIWindow::OnWmClose(HWND hwnd) CTCITEM item = {0}; item.m_mask = CTBIF_IMAGE; HWND hwndTabModule = m_pctabmodule->GetHwnd(); + wyInt64 conncount, nooftab; + wyBool found = wyFalse; + + ListofOpenTabs *listofopentabs;// = new ListofOpenTabs; + ListofOpenTabs *templistofopentabs;// = new ListofOpenTabs; + + //get the first of the node from the list + listofopentabs = (ListofOpenTabs *)pGlobals->m_connectiontabnamelist->GetFirst(); if(m_keepaliveinterval) { @@ -1026,10 +1049,62 @@ MDIWindow::OnWmClose(HWND hwnd) pGlobals->m_pcmainwin->ResizeToolBar(); + //Start: drop down: Remove tab details from the global m_connectiontabnamelist + + listofopentabs = (ListofOpenTabs *)pGlobals->m_connectiontabnamelist->GetFirst(); + conncount = pGlobals->m_connectiontabnamelist->GetCount(); + + for (nooftab = 0; nooftab < conncount; nooftab++) + { + + //get the node details from the list + if (listofopentabs->m_hwndTabModuleinlist->m_hwnd == hwndTabModule) + { + templistofopentabs = listofopentabs; + found = wyTrue; + break; + } + listofopentabs = (ListofOpenTabs *)listofopentabs->m_next; //moving pointer to next conenction window + } + //remove the node from the list; + if (found) + { + //delete the connection tab details from the list + pGlobals->m_connectiontabnamelist->Remove(templistofopentabs); + } + + //delete the connection list from m_mdilistfordropdown file + DelFromQueryStruct(wnd); + + //End dropdown + SetCursor(LoadCursor(NULL, IDC_ARROW)); return 1; } +void +MDIWindow::DelFromQueryStruct(MDIWindow *wnd) +{ + wyBool deletedfromstruct = wyFalse, found = wyFalse; + MDIListForDropDrown *pfound = NULL, *p; + + p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); + + while (p) + { + if (wnd == p->mdi) + { + found = wyTrue; + pfound = p; + break; + } + p = (MDIListForDropDrown *)p->m_next; + } + if (found) + { + pGlobals->m_mdilistfordropdown->Remove(pfound); + } +} wyInt32 MDIWindow::OnWmNotify(HWND hwnd, WPARAM wparam, LPARAM lparam) @@ -1183,6 +1258,10 @@ MDIWindow::OnWmNotify(HWND hwnd, WPARAM wparam, LPARAM lparam) LoadQueryTabPlusMenu(lparam); break; + case CTCN_DROPDOWNBUTTONCLICK: + LoadQueryTabDropDownMenu(hwnd, wparam, lparam); + break; + case CTCN_ONCONTEXTMENU: tabcount = CustomTab_GetItemCount(lpnmhdr->hwndFrom); if(lpnmhdr->idFrom == IDC_CTAB) @@ -1952,7 +2031,7 @@ MDIWindow::SetDirtyTitle() peditorbase = m_pctabmodule->GetActiveTabType()->m_peditorbase; peditorbase->m_edit = wyTrue; } - + m_fromdirtytab = wyTrue; SetQueryWindowTitle(); } @@ -1963,9 +2042,10 @@ MDIWindow::SetDirtyTitle() // Basically it calls the resize function of all its child window in orderly manner to implement // change of size of all its child window. void -MDIWindow::Resize() +MDIWindow::Resize(wyBool iswindowresize) { - m_pcqueryvsplitter->Resize(); + m_ismanualresizing; + m_pcqueryvsplitter->Resize(wyFalse, iswindowresize); m_pctabmodule->Resize(); if(pGlobals->m_isannouncementopen) @@ -2013,6 +2093,7 @@ MDIWindow::HandleFileSave() TabEditor *ptabeditor; wyInt32 tabimageid, sel; wyBool retval = wyFalse; + m_isfromsave = wyTrue; tabimageid = m_pctabmodule->GetActiveTabImage(); switch(tabimageid) @@ -2160,6 +2241,8 @@ MDIWindow::HandleSaveAsFile() TabEditor *ptabeditor; wyInt32 tabimageid, sel; wyBool retval = wyFalse; + + m_isfromsaveas = wyTrue; tabimageid = m_pctabmodule->GetActiveTabImage(); switch(tabimageid) @@ -4003,7 +4086,9 @@ MDIWindow::TabEditorTitles(wyString *mdititle) wyString newtitle; EditorBase *peditorbase = NULL; TabEditor *ptabeditor = NULL; + MDIWindow *wnd; + wnd = GetActiveWin(); ptabeditor = GetActiveTabEditor(); peditorbase = ptabeditor->m_peditorbase; @@ -4026,7 +4111,7 @@ MDIWindow::TabEditorTitles(wyString *mdititle) else if(peditorbase->m_save == wyTrue) { //Set tab name - m_pctabmodule->SetTabName(peditorbase->m_filename.GetAsWideChar(), wyTrue); + m_pctabmodule->SetTabName(peditorbase->m_filename.GetAsWideChar(), wyTrue,wyFalse); newtitle.Sprintf("%s", peditorbase->m_filename.GetString()); } @@ -4078,7 +4163,7 @@ MDIWindow::TabSchemaDesignerTitles(wyString *mdititle) newtitle.Sprintf("%s*", ptabsd->m_filename.GetString()); } - else if(ptabsd->m_save == wyTrue) + else if(ptabsd->m_save == wyTrue && ptabsd->m_filename.GetLength()>0) // Adding ptabsd->m_filename.GetLength()>0 condition as it was causing a crash { m_pctabmodule->SetTabName(ptabsd->m_filename.GetAsWideChar(), wyFalse); newtitle.Sprintf("%s", ptabsd->m_filename.GetString()); @@ -4095,8 +4180,22 @@ MDIWindow::TabSchemaDesignerTitles(wyString *mdititle) } //if there is no file name, then set it to default - if(!ptabsd->m_filename.GetLength()) - m_pctabmodule->SetTabName(_(L"Schema Designer"), wyFalse, wyFalse); + + if (!ptabsd->m_filename.GetLength()) + { + //add the code to display the tab name and the sequence + + + // to append sequence number + wyString qtabname = "", q = "Schema Designer"; + qtabname.SetAs(ptabsd->m_tabnamefordropdown.GetString()); + + m_pctabmodule->SetTabName(qtabname.GetAsWideChar(), wyFalse, wyFalse); + } + + + + //m_pctabmodule->SetTabName(ptabsd->m_filename.GetAsWideChar(), wyFalse, wyFalse); // Set the filename window if(ptabsd->m_filewndtitle.GetLength()) @@ -4147,8 +4246,12 @@ MDIWindow::TabQueryBuilderTitles(wyString *mdititle) // if there is no filename, set the default else { - temp.SetAs(_("Query Builder")); - m_pctabmodule->SetTabName(temp.GetAsWideChar(), wyFalse, wyFalse); + //to append sequence number + wyString qtabname = "", q = "Query Builder"; + + qtabname.SetAs(ptabqb->m_tabnameforqb.GetString()); + + m_pctabmodule->SetTabName(qtabname.GetAsWideChar(), wyFalse, wyFalse); //set the tool bar caption SetWindowText(ptabqb->m_hwndfilename, ptabqb->m_filewndtitle.GetAsWideChar()); @@ -4688,6 +4791,90 @@ MDIWindow::LoadQueryTabPlusMenu(LPARAM lparam) VERIFY(DestroyMenu(hmenu)); } +void +MDIWindow::LoadQueryTabDropDownMenu(HWND hwnd, WPARAM wparam, LPARAM lparam) +{ + LPNMCTC lpnmctc = (LPNMCTC)lparam; + wyInt32 extramenucount = 3, itab, tabcount; + wyInt64 i,qcount,id=0,j=0,cmdid; + MDIWindow *actwin; + wyString queryWindowname(""); + wyWChar *namestring; + BOOL flag; + wyBool winflag = wyFalse, found = wyFalse; + HMENU hsubmenu; + static wyInt32 activetabid; + ListOfOpenQueryTabs *tabs; + + //Creating the menu + hsubmenu = ::CreatePopupMenu(); + + //hmenu = LoadMenu(pGlobals->m_hinstance, MAKEINTRESOURCE(IDR_CONNDROPDOWNMENU)); + LocalizeMenu(hsubmenu); + //htrackmenu = GetSubMenu(hmenu, 0); + + tabcount = pGlobals->m_mdilistfordropdown->GetCount(); + +// MDIlist *temp = (MDIlist *)pGlobals->m_mdiwlist->GetFirst(); + MDIListForDropDrown *p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); + + actwin = GetActiveWin(); + + if (!actwin) + { + return; + } + for (itab = 0; itabmdi)//(actwin == temp->mdi) + { + found = wyTrue; + break; + } + p = (MDIListForDropDrown *)p->m_next; //temp = (MDIlist *)temp->m_next; + } + if (found) + { + tabs = (ListOfOpenQueryTabs *) p->opentab->GetFirst(); + qcount = p->opentab->GetCount(); + } + + id = 1; + for (i = 0; i < qcount; i++) + { + queryWindowname.SetAs(tabs->tabname.GetString()); + namestring = queryWindowname.GetAsWideChar(); + + flag = InsertMenu(hsubmenu, -1, MF_BYPOSITION, id, namestring); + id++; + tabs = (ListOfOpenQueryTabs *)tabs->m_next; + } + + activetabid = CustomTab_GetCurSel(actwin->m_pctabmodule->m_hwnd); + // Set menu draw property for drawing icon + //wyTheme::SetMenuItemOwnerDraw(hsubmenu); + SetMenuDefaultItem(hsubmenu, activetabid, TRUE); + + cmdid= TrackPopupMenu(hsubmenu, TPM_RETURNCMD |TPM_LEFTALIGN | TPM_RIGHTBUTTON, lpnmctc->curpos.x-15, lpnmctc->curpos.y+15, 0, actwin->m_pctabmodule->m_hwnd, NULL); + + if (cmdid == 0) + { + CustomTab_SetCurSel(actwin->m_pctabmodule->m_hwnd, activetabid); + CustomTab_EnsureVisible(actwin->m_pctabmodule->m_hwnd, activetabid); + + } + else + { + CustomTab_SetCurSel(actwin->m_pctabmodule->m_hwnd, cmdid-1); + CustomTab_EnsureVisible(actwin->m_pctabmodule->m_hwnd, cmdid-1); + } + + //FreeMenuOwnerDrawItem(htrackmenu); + activetabid = CustomTab_GetCurSel(actwin->m_pctabmodule->m_hwnd); + + VERIFY(DestroyMenu(hsubmenu)); +} + void MDIWindow::GetCtrlRects() { @@ -4817,7 +5004,7 @@ MDIWindow::OnWMSizeInfo(LPARAM lparam) } void -MDIWindow::PositionTabs(wyBool isupdtabledata, wyBool isupdhistory, wyBool isupdinfo) +MDIWindow::PositionTabs(wyBool isupdtabledata, wyBool isupdhistory, wyBool isupdinfo, wyBool delfromdropdown) { wyInt32 i, count, j, k; CTCITEM item = {0}; @@ -4842,45 +5029,52 @@ MDIWindow::PositionTabs(wyBool isupdtabledata, wyBool isupdhistory, wyBool isupd { if(istabeditorcreated == wyFalse) { - m_pctabmodule->CreateQueryEditorTab(this, i, wyTrue); + m_pctabmodule->CreateQueryEditorTab(this, i, wyTrue,wyTrue); istabeditorcreated = wyTrue; - CustomTab_DeleteItem(m_pctabmodule->m_hwnd, i + 1); + CustomTab_DeleteItem(m_pctabmodule->m_hwnd, i + 1,wyTrue);//true means deleteItem method will not delete any node from the structure + DelFromDropdownStructtabledata(this, i); } else { - CustomTab_DeleteItem(m_pctabmodule->m_hwnd, i); + CustomTab_DeleteItem(m_pctabmodule->m_hwnd, i,wyTrue);//true means deleteItem method will not delete any node from the structure --i; --count; + DelFromDropdownStructtabledata(this, i); } } else if(item.m_iimage == IDI_TABLEINDEX && pGlobals->m_isinfotabunderquery == wyTrue) { if(istabeditorcreated == wyFalse) { - m_pctabmodule->CreateQueryEditorTab(this, i, wyTrue); + m_pctabmodule->CreateQueryEditorTab(this, i, wyTrue , wyTrue); istabeditorcreated = wyTrue; - CustomTab_DeleteItem(m_pctabmodule->m_hwnd, i + 1); + CustomTab_DeleteItem(m_pctabmodule->m_hwnd, i + 1,wyTrue);//true means deleteItem method will not delete any node from the structure + DelFromDropdownStructInfo(this, i); } else { - CustomTab_DeleteItem(m_pctabmodule->m_hwnd, i); + CustomTab_DeleteItem(m_pctabmodule->m_hwnd, i,wyTrue);//true means deleteItem method will not delete any node from the structure --i; --count; + DelFromDropdownStructInfo(this, i); } } else if(item.m_iimage == IDI_HISTORY && pGlobals->m_ishistoryunderquery == wyTrue) { if(istabeditorcreated == wyFalse) { - m_pctabmodule->CreateQueryEditorTab(this, i, wyTrue); + m_pctabmodule->CreateQueryEditorTab(this, i, wyTrue,wyTrue); istabeditorcreated = wyTrue; - CustomTab_DeleteItem(m_pctabmodule->m_hwnd, i + 1); + CustomTab_DeleteItem(m_pctabmodule->m_hwnd, i + 1,wyTrue);//true means deleteItem method will not delete any node from the structure + DelFromDropdownStruct(this, i); } else { - CustomTab_DeleteItem(m_pctabmodule->m_hwnd, i); + CustomTab_DeleteItem(m_pctabmodule->m_hwnd, i,wyTrue);//true means deleteItem method will not delete any node from the structure --i; --count; + //add the code to delete the history node from the srtucture : i is the idex of history code + DelFromDropdownStruct(this, i); } } else if((ptabeditor = m_pctabmodule->GetTabEditorAt(i)) && ptabeditor->m_pctabmgmt) @@ -4895,7 +5089,7 @@ MDIWindow::PositionTabs(wyBool isupdtabledata, wyBool isupdhistory, wyBool isupd } else if(!bottomtabsettings[j * 2] && k != -1) { - ptabeditor->m_pctabmgmt->DeleteTab(k); + ptabeditor->m_pctabmgmt->DeleteTab(k,wyTrue); ptabeditor->m_pctabmgmt->ChangeTitles(); } } @@ -4918,6 +5112,200 @@ MDIWindow::PositionTabs(wyBool isupdtabledata, wyBool isupdhistory, wyBool isupd } } +void +MDIWindow::DelFromDropdownStruct(MDIWindow *wnd, wyInt64 index) +{ + wyBool deletedfromstruct = wyFalse, found = wyFalse, delfound = wyFalse; + MDIListForDropDrown *pfound = NULL, *p; + ListofOpenTabs * temp1, *listofopentabs; + wyInt64 i, tabcount; + ListOfOpenQueryTabs *temp; + + p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); + + if (!p) + { + return; + } + if (!wnd) + { + return; + } + // To search for the particular tab + while (p) + { + if (wnd == p->mdi) + { + found = wyTrue; + pfound = p; + break; + } + p = (MDIListForDropDrown *)p->m_next; + } + + // getting the tab which is being closed + //if (found) { + /*listofopentabs = (ListofOpenTabs *)p->opentab->GetFirst(); + + tabcount = p->opentab->GetCount(); + for (i = 0; i < tabcount; i++) + { + if (i == index+1 && !deletedfromstruct && listofopentabs->) + { + temp = listofopentabs; + deletedfromstruct = wyTrue; + delfound = wyTrue; + break; + } + listofopentabs = (ListofOpenTabs *)listofopentabs->m_next; + }*/ + wyString stemp; + if (found) { + ListOfOpenQueryTabs *opentab = (ListOfOpenQueryTabs *)p->opentab->GetFirst(); + tabcount = p->opentab->GetCount(); + + for (i = 0; i < tabcount; i++) + { + stemp.SetAs(opentab->tabname.GetString()); + //wyInt32 k=stemp.CompareI("History"); + if (stemp.CompareI("History") == 0) + { + delfound = wyTrue; + temp = opentab; + break; + + } + opentab = (ListOfOpenQueryTabs *)opentab->m_next; + } + } + if (delfound) + { + p->opentab->Remove(temp); + delfound = wyFalse; + } + +} + + +void +MDIWindow::DelFromDropdownStructInfo(MDIWindow *wnd, wyInt64 index) +{ + wyBool deletedfromstruct = wyFalse, found = wyFalse, delfound = wyFalse; + MDIListForDropDrown *pfound = NULL, *p; + ListofOpenTabs * temp1, *listofopentabs; + wyInt64 i, tabcount; + ListOfOpenQueryTabs *temp; + + p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); + + if (!p) + { + return; + } + if (!wnd) + { + return; + } + // To search for the particular tab + while (p) + { + if (wnd == p->mdi) + { + found = wyTrue; + pfound = p; + break; + } + p = (MDIListForDropDrown *)p->m_next; + } + wyString stemp; + if (found) { + ListOfOpenQueryTabs *opentab = (ListOfOpenQueryTabs *)p->opentab->GetFirst(); + tabcount = p->opentab->GetCount(); + + for (i = 0; i < tabcount; i++) + { + stemp.SetAs(opentab->tabname.GetString()); + + //wyInt32 k = stemp.CompareI("Info"); + if (stemp.CompareI("Info") == 0) + { + delfound = wyTrue; + temp = opentab; + break; + + } + opentab = (ListOfOpenQueryTabs *)opentab->m_next; + + } + } + if (delfound) + { + p->opentab->Remove(temp); + delfound = wyFalse; + } + +} + + +void +MDIWindow::DelFromDropdownStructtabledata(MDIWindow *wnd, wyInt64 index) +{ + wyBool deletedfromstruct = wyFalse, found = wyFalse, delfound = wyFalse; + MDIListForDropDrown *pfound = NULL, *p; + ListofOpenTabs * temp1, *listofopentabs; + wyInt64 i, tabcount=0; + ListOfOpenQueryTabs *temp; + wyString stemp; + + p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); + if(!p) + { + return; + } + if (!wnd) + { + return; + } + // To search for the particular tab + while (p) + { + if (wnd == p->mdi) + { + found = wyTrue; + pfound = p; + break; + } + p = (MDIListForDropDrown *)p->m_next; + } + + if (found) { + ListOfOpenQueryTabs *opentab = (ListOfOpenQueryTabs *)p->opentab->GetFirst(); + tabcount = p->opentab->GetCount(); + + for (i = 0; i < tabcount; i++) + { + stemp.SetAs(opentab->tabname.GetString()); + + //wyInt32 k = stemp.CompareI("Table Data"); + if (stemp.CompareI("Table Data") == 0) + { + delfound = wyTrue; + temp = opentab; + break; + + } + opentab = (ListOfOpenQueryTabs *)opentab->m_next; + + } + } + if (delfound) + { + p->opentab->Remove(temp); + delfound = wyFalse; + } + +} + void MDIWindow::HandleKeepAliveTimer() { diff --git a/src/MySQLVersionHelper.cpp b/src/MySQLVersionHelper.cpp index db75081..be05ab6 100644 --- a/src/MySQLVersionHelper.cpp +++ b/src/MySQLVersionHelper.cpp @@ -285,6 +285,16 @@ IsMySQL5010(Tunnel * tunnel, PMYSQL mysql) else return wyFalse; } +wyBool +IsMySQL80011(Tunnel * tunnel, PMYSQL mysql) +{ + wyUInt32 me = mysql_get_server_version(*mysql);/* Only available from MySQLv8.1*/ + + if (me >= 80011) + return wyTrue; + else + return wyFalse; +} wyBool IsMySQL5017(Tunnel * tunnel, PMYSQL mysql) @@ -481,6 +491,19 @@ wyBool IsMariaDB52(Tunnel * tunnel, PMYSQL mysql) return wyFalse; +} + +wyBool IsMariaDB10309(Tunnel * tunnel, PMYSQL mysql) +{ + long me = mysql_get_server_version(*mysql); + const char *dbString = mysql_get_server_info(*mysql); + + if (me >= 10309 && strstr(dbString, "MariaDB")) + return wyTrue; + else + return wyFalse; + + } wyBool IsMySQL57(Tunnel * tunnel, PMYSQL mysql) diff --git a/src/OtherDialogs.cpp b/src/OtherDialogs.cpp index 2fa3c54..78de09f 100644 --- a/src/OtherDialogs.cpp +++ b/src/OtherDialogs.cpp @@ -1931,7 +1931,7 @@ CCopyTable::DoCopy() { wyInt32 fieldcount, query_for_virtuality_length, isintransaction = 1;; wyBool relation, isssel, isindex, success, ret; - wyString query, keys, select, query_for_virtuality; + wyString query, keys, select, query_for_virtuality, constraintstmt; MYSQL_RES *res; wyWChar newtable[SIZE_512]={0}; wyChar *tbuff; @@ -1996,6 +1996,20 @@ CCopyTable::DoCopy() query.Add(","); query.AddSprintf("%s", keys.GetString()); } + + //ret = GetCheckConstraints(select, constraintstmt, newtable); + + //if (!ret) + //{ + // SetCursor(LoadCursor(NULL, IDC_ARROW)); + // return wyFalse; + //} + //if (constraintstmt.GetLength()) + //{ + // constraintstmt.Strip(1); + // query.Strip(1); + // query.AddSprintf(",%s)", constraintstmt.GetString()); + //} //Collation, Engine type, Create table options(min_rows, max_rows, checksum, delay_key_write, row_format) if(IsMySQL41(m_tunnel, m_mysql)) @@ -2603,6 +2617,84 @@ CCopyTable::GetSelectStmt(wyString &select, wyString &query_for_virtuality,wyWCh return wyTrue; } +wyBool +CCopyTable::GetCheckConstraints(wyString &select, wyString &constraintstmt, wyWChar new_table[]) +{ + wyString query; + MYSQL_RES *myres; + MYSQL_ROW myfieldrow; + wyString tblname(""), dbname(""), createtable(""), checkexpression, checkname, alltblcheck(""), str(""), *allcheck = NULL; + wyChar *tempstr = NULL, *currentrowstr = NULL, *wholecreatestring = NULL, *wholecreate = NULL; + //CheckConstraintStructWrapper *cwrapobj = NULL; + //CheckConstarintInfo *icheck = NULL; + //FieldStructWrapper *fieldswrap = NULL; + wyChar * findc = "CONSTRAINT", *findch = "CHECK"; + wyBool found = wyFalse; + + query.Clear(); + query.Sprintf("show create table `%s`.`%s`", m_db.GetString(), m_table.GetString()); + myres = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, query); + + if (!myres) + { + ShowMySQLError(m_hwnd, m_tunnel, m_mysql, query.GetString()); + return wyFalse; + } + myfieldrow = m_tunnel->mysql_fetch_row(myres); + createtable = myfieldrow[1]; + wholecreate = (wyChar*)createtable.GetString(); + + const char *ptr = strstr(wholecreate, findc); + str = wholecreate; + if (ptr) + { + const char *ptr2 = strstr(wholecreate, findch); + int index = ptr - wholecreate; + alltblcheck = str.Substr(index, str.GetLength()); + found = wyTrue; + } + + if (found) { + wholecreatestring = (wyChar*)strdup(alltblcheck.GetString()); + if (wholecreatestring) + currentrowstr = strtok(wholecreatestring, "\n"); + + //loop to get all check constraint + + while (currentrowstr != NULL) { + if (checkexpression.GetLength() != 0) + checkexpression.Clear(); + if (!GetCheckConstraintValue(currentrowstr, &checkexpression)) + { + currentrowstr = strtok(NULL, "\n"); + continue; + } + + if (checkname.GetLength() != 0) + checkname.Clear(); + if (!GetCheckConstraintName(currentrowstr, &checkname)) + { + currentrowstr = strtok(NULL, "\n"); + continue; + } + + if (checkname.GetLength() && checkexpression.GetLength()) + { + constraintstmt.AddSprintf("\r\n constraint %s CHECK %s",checkname.GetString(),checkexpression.GetString()); + } + constraintstmt.AddSprintf(","); + + //moving to next set of check constraint + if (currentrowstr) + currentrowstr = strtok(NULL, "\n"); + + } + } + + m_tunnel->mysql_free_result(myres); + +} + // Function to make the new DB the default for the connection // becase in the create table we cant use the form db.table name // so we have to make the default db like the new one. @@ -5750,7 +5842,7 @@ RenameTabDlg::RenameTabDlgProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp yog_message(hwnd, _(L"Please enter a valid name"), pGlobals->m_appname.GetAsWideChar(), MB_OK | MB_HELP | MB_ICONINFORMATION); return 0; } - wnd->m_pctabmodule->SetTabRename(temptext); + wnd->m_pctabmodule->SetTabRename(temptext,wyFalse,wnd,wyTrue); yog_enddialog(hwnd, 0); } else diff --git a/src/PreferenceBase.cpp b/src/PreferenceBase.cpp index 436796f..094f276 100644 --- a/src/PreferenceBase.cpp +++ b/src/PreferenceBase.cpp @@ -45,6 +45,7 @@ extern PGLOBALS pGlobals; #define INFOTAB_POS_DEFAULT 1 #define TABLEDATA_POS_DEFAULT 1 #define HISTORY_POS_DEFAULT 0 +#define SERVERDATE_DEFAULT 0 //Other Preference Default Values #define COLUMNWIDTH_DEFAULT 0 @@ -1213,6 +1214,9 @@ PreferenceBase::InitGeneralPrefValues() truncdata = wyIni::IniGetInt(GENERALPREFA, "HistoryUnderQuery", HISTORY_POS_DEFAULT, dirstr.GetString()); SendMessage(GetDlgItem(m_hwnd, IDC_HISTORYPOSITION), BM_SETCHECK, truncdata, 0); + truncdata = wyIni::IniGetInt(GENERALPREFA, "ShowServerDate", SERVERDATE_DEFAULT, dirstr.GetString()); + SendMessage(GetDlgItem(m_hwnd, IDC_SERVERDATE), BM_SETCHECK, truncdata, 0); + EnableBulkInsert(m_hwnd, truncdata); GetGeneralPrefSizeValues(m_hwnd); @@ -1671,7 +1675,8 @@ PreferenceBase::SaveGeneralPreferences(HWND hwndbase, wyInt32 page) SetBoolProfileString(hwnd, GENERALPREF, L"TableDataUnderQuery", IDC_TABLEDATAPOSITION); SetBoolProfileString(hwnd, GENERALPREF, L"InfoTabUnderQuery", IDC_INFOPOSITION); SetBoolProfileString(hwnd, GENERALPREF, L"HistoryUnderQuery", IDC_HISTORYPOSITION); - + SetBoolProfileString(hwnd, GENERALPREF, L"ShowServerDate", IDC_SERVERDATE); + return wyTrue; } @@ -2206,6 +2211,7 @@ PreferenceBase::SetGenPrefDefaultValues(HWND hwnd) SendMessage(GetDlgItem(hwnd, IDC_TABLEDATAPOSITION), BM_SETCHECK, TABLEDATA_POS_DEFAULT, 0); SendMessage(GetDlgItem(hwnd, IDC_INFOPOSITION), BM_SETCHECK, INFOTAB_POS_DEFAULT, 0); SendMessage(GetDlgItem(hwnd, IDC_HISTORYPOSITION), BM_SETCHECK, HISTORY_POS_DEFAULT, 0); + SendMessage(GetDlgItem(hwnd, IDC_SERVERDATE), BM_SETCHECK, SERVERDATE_DEFAULT, 0); SetGeneralPrefDefaultSizeValues(hwnd); @@ -2492,7 +2498,8 @@ PreferenceBase::SaveDefaultGeneralPreferences() wyIni::IniWriteInt(GENERALPREFA, "TableDataUnderQuery", TABLEDATA_POS_DEFAULT, dirstr.GetString()); wyIni::IniWriteInt(GENERALPREFA, "InfoTabUnderQuery", INFOTAB_POS_DEFAULT, dirstr.GetString()); wyIni::IniWriteInt(GENERALPREFA, "HistoryUnderQuery", HISTORY_POS_DEFAULT, dirstr.GetString()); - + wyIni::IniWriteInt(GENERALPREFA, "ShowServerDate", SERVERDATE_DEFAULT, dirstr.GetString()); + return ; } diff --git a/src/Source.cpp b/src/Source.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/TabAdvancedProperties.cpp b/src/TabAdvancedProperties.cpp index 2f2dcd1..a6e3201 100644 --- a/src/TabAdvancedProperties.cpp +++ b/src/TabAdvancedProperties.cpp @@ -315,7 +315,7 @@ TabAdvancedProperties::CreateOtherWindows(HWND hwndparent) if(!m_hlastfocusedwnd) m_hlastfocusedwnd = m_hcmbdelaykeywrite; } - + if(m_ptabmgmt->m_tabinterfaceptr->m_open_in_dialog) { m_wporigautoincr = (WNDPROC)SetWindowLongPtr(m_heditautoincr, GWLP_WNDPROC, (LONG_PTR)TabAdvancedProperties::SysKeyDownWndProc); @@ -338,6 +338,7 @@ TabAdvancedProperties::CreateOtherWindows(HWND hwndparent) m_wporigdelaykey = (WNDPROC)SetWindowLongPtr(m_hcmbdelaykeywrite, GWLP_WNDPROC, (LONG_PTR)TabAdvancedProperties::SysKeyDownWndProc); SetWindowLongPtr(m_hcmbdelaykeywrite, GWLP_USERDATA, (LONG_PTR)this); + } m_hwndscroll = CreateWindowEx( @@ -454,6 +455,7 @@ TabAdvancedProperties::FetchInitValues() wyString tempstr; myres = m_ptabmgmt->m_tabinterfaceptr->m_myrestablestatus; + if(!myres) return wyFalse; @@ -462,7 +464,7 @@ TabAdvancedProperties::FetchInitValues() commentindex = GetFieldIndex(myres, "comment", m_mdiwnd->m_tunnel, &m_mdiwnd->m_mysql); myrow = m_mdiwnd->m_tunnel->mysql_fetch_row(myres); - + if(!myrow || !myrow[0] || !myrow[1]) { yog_message(m_hwnd, _(L"Could not read data for the table!"), pGlobals->m_appname.GetAsWideChar(), @@ -628,7 +630,7 @@ TabAdvancedProperties::FillInitValues(wyBool iscancelchanges) SendMessage(m_heditmaxrows, WM_SETTEXT, 0, (LPARAM) m_origmaxrows.GetAsWideChar()); SendMessage(m_heditminrows, WM_SETTEXT, 0, (LPARAM) m_origminrows.GetAsWideChar()); SendMessage(m_heditavgrowlen, WM_SETTEXT, 0, (LPARAM) m_origavgrow.GetAsWideChar()); - + m_disableenchange = wyFalse; return wyTrue; @@ -1205,7 +1207,7 @@ TabAdvancedProperties::ScrollWindows(wyBool isdown, wyInt32 pos) HWND hwndarr[25] = {m_hwnd, m_hwndscroll, m_hstaticcomment, m_heditcomment, m_hstatautoincr, m_heditautoincr, m_hstatavgrowlen, m_heditavgrowlen, m_hstatmaxrows, m_heditmaxrows, m_hstatminrows, m_heditminrows, m_hstatrowformat, m_hcmbrowformat, - m_hstatdelaykeywrite, m_hcmbdelaykeywrite, m_hstatchecksum, m_hcmbchecksum, + m_hstatdelaykeywrite, m_hcmbdelaykeywrite, m_hstatchecksum, m_hcmbchecksum, m_ptabmgmt->m_tabinterfaceptr->m_hbtnsave, m_ptabmgmt->m_tabinterfaceptr->m_hbtncancelchanges, NULL}; wyInt32 temppos = 0; diff --git a/src/TabCheck.cpp b/src/TabCheck.cpp new file mode 100644 index 0000000..56142aa --- /dev/null +++ b/src/TabCheck.cpp @@ -0,0 +1,1678 @@ +/* Copyright (C) 2013 Webyog Inc + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + +*/ + + +#include "TabIndexes.h" +#include "MDIWindow.h" +#include "Global.h" +#include "GUIHelper.h" +#include "CommonHelper.h" +#include "TableTabInterfaceTabMgmt.h" +#include "TableTabInterface.h" +#include "TabFields.h" +#include "TabCheck.h" + +extern PGLOBALS pGlobals; + +#define UM_SETINITFOCUS 545 + +#define HNDLEIDXMGWD 400 +#define HNDLEIDXMGHT 275 +#define GRIDCHECKBOXWD 75 + +#define UM_GRIDROWFOCUSCHANGE 4628 + +#define CONSTRAINTNAME 0 +#define CONSTRAINTEXPRESSION 1 + +CheckColumn::CheckColumn(FieldStructWrapper *value) +{ + m_pcwrapobj = value; + m_lenth = -1; +} + +TabCheck::TabCheck(HWND hwnd, TableTabInterfaceTabMgmt* ptabmgmt) +{ + m_hwnd = hwnd; + m_hgridtblcheckconst = NULL; + m_hdlggrid = NULL; + m_mdiwnd = GetActiveWin(); + m_ptabmgmt = ptabmgmt; + m_ismysql41 = IsMySQL41(m_mdiwnd->m_tunnel, &(m_mdiwnd->m_mysql)); + m_ismariadb52 = IsMySQL564MariaDB53(m_mdiwnd->m_tunnel, &(m_mdiwnd->m_mysql)); + m_ismysql553 = IsMySQL553MariaDB55(m_mdiwnd->m_tunnel, &(m_mdiwnd->m_mysql)); + + m_lastclickindgrid = -1; + m_lastclickdlggrid = -1; + +} + +TabCheck::~TabCheck() +{ + //ClearAllMemory(wyTrue); +} + +TabCheck::TabCheck() +{ + //ClearAllMemory(wyTrue); +} + +CheckConstraintStructWrapper::CheckConstraintStructWrapper(CheckConstarintInfo *value, wyBool isnew) +{ + if (isnew) + { + m_oldval = NULL; + m_newval = value; + } + else + { + m_oldval = m_newval = value; + } + + m_errmsg = NULL; +} + +CheckConstraintStructWrapper::~CheckConstraintStructWrapper() +{ + List *lstcols = NULL; + CheckColumn *indcol1 = NULL, *indcol2 = NULL; + + if (m_oldval) + { + lstcols = m_oldval->m_listcolumns; + + if (lstcols) + indcol1 = (CheckColumn*)lstcols->GetFirst(); + + while (indcol1) + { + indcol2 = (CheckColumn*)lstcols->Remove(indcol1); + delete indcol1; + indcol1 = indcol2; + } + if (lstcols) + delete lstcols; + + m_oldval->m_listcolumns = lstcols = NULL; + } + + if (m_newval) + { + lstcols = m_newval->m_listcolumns; + + if (lstcols) + indcol1 = (CheckColumn*)lstcols->GetFirst(); + + while (indcol1) + { + indcol2 = (CheckColumn*)lstcols->Remove(indcol1); + delete indcol1; + indcol1 = indcol2; + } + if (lstcols) + delete lstcols; + + m_newval->m_listcolumns = lstcols = NULL; + } + + if (m_oldval == m_newval) + { + delete m_newval; + m_oldval = m_newval = NULL; + } + else + { + if (m_oldval) + delete m_oldval; + + if (m_newval) + delete m_newval; + } + if (m_errmsg) + delete m_errmsg; + m_errmsg = NULL; +} + +LRESULT CALLBACK +TabCheck::GridWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + + + TabCheck* ptabind = (TabCheck*)CustomGrid_GetLongData(hwnd); + wyString tblname(""); + + switch (message) + { + case GVN_BEGINLABELEDIT: + { + return ptabind->OnGVNBeginLabelEdit(hwnd, wParam, lParam); + } + break; + + case GVN_BUTTONCLICK: + { + ptabind->OnGVNButtonClick(); + } + break; + + case GVN_ENDLABELEDIT: + { + return ptabind->OnGVNEndLabelEdit(wParam, lParam); + } + break; + + case GVN_BEGINADDNEWROW: + return 0; + + case GVN_CHECKBOXCLICK: + { + ptabind->HandleCheckboxClick(hwnd, lParam, wParam, ptabind->m_lastclickindgrid); + } + break; + + case GVN_DRAWROWCHECK: + { + ((GVROWCHECKINFO*)lParam)->ischecked = CustomGrid_GetRowCheckState(hwnd, wParam) ? wyTrue : wyFalse; + } + break; + + case GVN_DESTROY: + { + //ptabind->ClearAllMemory(wyTrue); + //ptabind->m_lastclickindgrid = -1; + } + break; + + case GVN_NEXTTABORDERITEM: + SetFocus(GetNextDlgTabItem(ptabind->m_ptabmgmt->m_tabinterfaceptr->m_hwnd, hwnd, FALSE)); + break; + + case GVN_PREVTABORDERITEM: + SetFocus(GetNextDlgTabItem(ptabind->m_ptabmgmt->m_tabinterfaceptr->m_hwnd, hwnd, TRUE)); + break; + + case GVN_SYSKEYDOWN: + return ptabind->OnGVNSysKeyDown(hwnd, wParam, lParam); + + case GVN_HELP: + { + //if (ptabind->m_ptabmgmt->m_tabinterfaceptr->m_isaltertable) + //ShowHelp("http://sqlyogkb.webyog.com/article/92-alter-index"); + //else + ShowHelp("https://sqlyogkb.webyog.com/article/192-check-constraint"); + } + } + return 1; +} + + +void +TabCheck::InitGrid() +{ + + wyInt32 counter; // normal counter + wyInt32 num_cols; // number of columns + GVCOLUMN gvcol; // structure used to create columns for grid + wyChar *heading[] = { _("Constraint Name"), _("Expression") }; + wyInt32 mask[] = { GVIF_TEXT, GVIF_TEXT}; + VOID *listtype[] = { NULL, NULL }; + wyInt32 elemsize[] = { 0, 10}; + wyInt32 elemcount[] = { 0, 8}; + wyInt32 cx[] = { 200, 500 }; + wyInt32 format[] = { GVIF_LEFT, GVIF_LEFT }; + wyInt32 width = 0; + + wyString colname; + HFONT hfont; + + m_ptabmgmt->m_tabinterfaceptr->SetFont(m_hgridtblcheckconst); + hfont = CustomGrid_GetColumnFont(m_hgridtblcheckconst); + + num_cols = sizeof(heading) / sizeof(heading[0]); + if (!m_ismysql553) + num_cols--; + + for (counter = 0; counter < num_cols; counter++) + { + //for getting the retained column width + colname.SetAs(heading[counter]); + width = GetTextSize(colname.GetAsWideChar(), m_hgridtblcheckconst, hfont).right + 15; + + memset(&gvcol, 0, sizeof(gvcol)); + + gvcol.mask = mask[counter]; // Set the mask for the sturcture i.e. what kind of column in the grid. + gvcol.fmt = format[counter]; // Alignment + gvcol.pszList = listtype[counter]; // set the kind list in between + gvcol.cx = (width < cx[counter]) ? cx[counter] : width; + gvcol.text = heading[counter]; + gvcol.nElemSize = elemsize[counter]; + gvcol.nListCount = elemcount[counter]; + gvcol.cchTextMax = strlen(heading[counter]); + + CustomGrid_InsertColumn(m_hgridtblcheckconst, &gvcol); + } + return; +} + +void +TabCheck::ClearAllMemory(wyBool iscallfromdestructor) +{ + CheckConstraintStructWrapper *cwrapobj = NULL, *tmpcwrapobj = NULL; + cwrapobj = (CheckConstraintStructWrapper *)m_listwrapperstruct.GetFirst(); + + while (cwrapobj) + { + tmpcwrapobj = cwrapobj; + cwrapobj = (CheckConstraintStructWrapper *)m_listwrapperstruct.Remove(cwrapobj); + delete tmpcwrapobj; + } + + return; +} + + +wyBool +TabCheck::Create() +{ + + m_hgridtblcheckconst = CreateCustomGridEx(m_hwnd, 0, 0, 0, 0, (GVWNDPROC)GridWndProc, GV_EX_ROWCHECKBOX, (LPARAM)this); + + //..Initializing grid + InitGrid(); + + + //from .ini file + m_backtick = AppendBackQuotes() == wyTrue ? "`" : ""; + + if (m_ptabmgmt->m_tabinterfaceptr->m_isaltertable) + { + //..Fetching check constraints into wrapper + if (!FetchCheckConstraintsIntoWrapper()) + return wyFalse; + + //..Setting checkconstraint into grid + FillInitValues(); + } + //..Inserting extra row + InsertRow(); + + ShowWindow(m_hgridtblcheckconst, SW_HIDE); + return wyTrue; +} + +wyBool +TabCheck::FetchCheckConstraintsIntoWrapper() +{ + wyString query ; + MYSQL_RES *myres; + MYSQL_ROW myfieldrow; + wyString tblname(""), dbname(""), createtable(""), checkexpression, checkname, alltblcheck(""), str(""), * allcheck = NULL; + wyChar *tempstr = NULL, *currentrowstr = NULL, *wholecreatestring = NULL, *wholecreate=NULL; + CheckConstraintStructWrapper *cwrapobj = NULL; + CheckConstarintInfo *icheck = NULL; + FieldStructWrapper *fieldswrap = NULL; + wyChar * findc = "CONSTRAINT", *findch = "CHECK"; + wyBool found = wyFalse; + + tblname.SetAs(m_ptabmgmt->m_tabinterfaceptr->m_origtblname); + tblname.FindAndReplace("`", "``"); + + dbname.SetAs(m_ptabmgmt->m_tabinterfaceptr->m_dbname); + dbname.FindAndReplace("`", "``"); + + query.Clear(); + query.Sprintf("show create table `%s`.`%s`", dbname.GetString(), tblname.GetString()); + myres = ExecuteAndGetResult(m_mdiwnd, m_mdiwnd->m_tunnel, &(m_mdiwnd->m_mysql), query); + + if (!myres) + { + ShowMySQLError(m_hwnd, m_mdiwnd->m_tunnel, &(m_mdiwnd->m_mysql), query.GetString()); + return wyFalse; + } + + myfieldrow = m_mdiwnd->m_tunnel->mysql_fetch_row(myres); + createtable = myfieldrow[1]; + wholecreate =(wyChar*) createtable.GetString(); + + const char *ptr = strstr(wholecreate, findc); + str = wholecreate; + if (ptr) + { + const char *ptr2 = strstr(wholecreate, findch); + int index = ptr - wholecreate; + alltblcheck = str.Substr(index, str.GetLength()); + found = wyTrue; + } + if (found) { + wholecreatestring = (wyChar*)strdup(alltblcheck.GetString()); + if (wholecreatestring) + currentrowstr = strtok(wholecreatestring, "\n"); + + //loop to get all check constraint + + while (currentrowstr != NULL) { + if (checkexpression.GetLength() != 0) + checkexpression.Clear(); + if (!GettablelevelCheckConstraintValue(currentrowstr, &checkexpression)) + { + currentrowstr = strtok(NULL, "\n"); + continue; + } + + if (checkname.GetLength() != 0) + checkname.Clear(); + if (!GetCheckConstraintName(currentrowstr, &checkname)) + { + currentrowstr = strtok(NULL, "\n"); + continue; + } + //If quotes are present in show create table + //if (AppendBackQuotes()) { + CheckForQuotesAndReplace(&checkname); + //} + + cwrapobj = new CheckConstraintStructWrapper(NULL, wyFalse); + m_listwrapperstruct.Insert(cwrapobj); + + icheck = new CheckConstarintInfo(); + cwrapobj->m_oldval = cwrapobj->m_newval = icheck; + icheck->m_name.SetAs(checkname); + icheck->m_checkexpression.SetAs(checkexpression); + + cwrapobj = (CheckConstraintStructWrapper*)cwrapobj->m_next; + + //moving to next set of check constraint + if (currentrowstr) + currentrowstr = strtok(NULL, "\n"); + + } + } + + m_mdiwnd->m_tunnel->mysql_free_result(myres); + + + + return wyTrue; +} +wyBool TabCheck::GetAllCheckConstraint(wyChar * createstring, wyString *allcheckconstraint) +{ + wyChar * findc = "CONSTRAINT", *findch = "CHECK"; + wyBool found = wyFalse; + wyString tempstr,str = createstring; + const char *ptr = strstr(createstring, findc); + + if (ptr) + { + const char *ptr2 = strstr(createstring, findch); + int index = ptr2 - createstring; + wyString *p = &tempstr; + tempstr.SetAs(str.Substr(index, str.GetLength())); + + //allcheckconstraint->AddSprintf("%S", tempstr); + + found = wyTrue; + } + + return found; + +} + +void TabCheck::FillInitValues() +{ + + CheckConstraintStructWrapper *cwrapobj = NULL; + wyUInt32 row = -1; + + cwrapobj = (CheckConstraintStructWrapper *)m_listwrapperstruct.GetFirst(); + + while (cwrapobj) + { + row = InsertRow(); + + //..Setting text & Long Values + CustomGrid_SetText(m_hgridtblcheckconst, row, CONSTRAINTNAME, cwrapobj->m_oldval->m_name.GetString()); + CustomGrid_SetText(m_hgridtblcheckconst, row, CONSTRAINTEXPRESSION, cwrapobj->m_oldval->m_checkexpression.GetString()); + + CustomGrid_SetRowLongData(m_hgridtblcheckconst, row, (LPARAM)cwrapobj); + + cwrapobj = (CheckConstraintStructWrapper *)cwrapobj->m_next; + } + + CustomGrid_SetCurSelection(m_hgridtblcheckconst, 0, 0, wyTrue); +} +wyInt32 +TabCheck::InsertRow() +{ + wyInt32 row; + + //..Adding a new row in the grid + row = CustomGrid_InsertRow(m_hgridtblcheckconst); + CustomGrid_SetButtonVis(m_hgridtblcheckconst, row, 1, wyTrue); + CustomGrid_SetButtonText(m_hgridtblcheckconst, row, CONSTRAINTNAME, L"..."); + + return row; +} + +wyBool +TabCheck::GetNewAndModifiedChecks(wyString &query, wyBool execute) +{ + wyInt32 count = 0; + wyBool validflg = wyTrue; + wyString tempstr(""), celldata, namestr, temp, exprstr, columnsstr, indexcomment = ""; + wyString dropck(""), addck(""); + CheckConstraintStructWrapper *pwrapobj = NULL; + wyChar *tbuff = NULL; + + count = CustomGrid_GetRowCount(m_hgridtblcheckconst); + m_backtick = AppendBackQuotes() == wyTrue ? "`" : ""; + + for (int row = 0; row < count; row++) + { + pwrapobj = (CheckConstraintStructWrapper *)CustomGrid_GetRowLongData(m_hgridtblcheckconst, row); + + if (!pwrapobj) //..empty rows + continue; + + if (pwrapobj->m_newval == pwrapobj->m_oldval) //..if, the check constraint is not changed or it's not a new check constraint + continue; + + if (!pwrapobj->m_newval) //..when user had deleted only constraint name and not entire constraint, that time constraint row will be there but m_newval will be NULL; + continue; + + if (pwrapobj->m_oldval) + { + namestr.SetAs(pwrapobj->m_oldval->m_name); + + //from .ini file. Refresh always + m_backtick = AppendBackQuotes() == wyTrue ? "`" : ""; + + //If quotes are present in show create table + //if (AppendBackQuotes()) { + CheckForQuotesAndReplace(&namestr); + //} + + dropck.AddSprintf("\r\n drop constraint %s%s%s,", m_backtick,namestr.GetString(), m_backtick); + } + + GetGridCellData(m_hgridtblcheckconst, row, CONSTRAINTNAME, namestr); + GetGridCellData(m_hgridtblcheckconst, row, CONSTRAINTEXPRESSION, exprstr); + + exprstr.Sprintf("%s", exprstr.GetString()); + tbuff = GetEscapedValue(m_mdiwnd->m_tunnel, &(m_mdiwnd->m_mysql), namestr.GetString()); + namestr.Sprintf("%s", tbuff); + + namestr.FindAndReplace("`", "``"); + + if (namestr.GetLength() > 64) + { + MessageBox(m_hwnd, _(L"Please enter a constraint name less than 64 characters"), + _(L"Warning"), MB_ICONWARNING | MB_OK | MB_DEFBUTTON2); + return wyFalse; + } + if (exprstr.GetLength() == 0) + { + tempstr = ""; + tempstr.SetAs(NO_EXPRESSION_SPECIFIED_FOR_CHECK); + + exprstr.AddSprintf("\t\t/* %s */", _(tempstr.GetString())); + } + + //from .ini file. Refresh always + m_backtick = AppendBackQuotes() == wyTrue ? "`" : ""; + + //If quotes are present in show create table + //if (AppendBackQuotes()) { + CheckForQuotesAndReplace(&namestr); + //} + + if (!(pwrapobj->m_oldval)&& (pwrapobj->m_newval)) //If a new constraint is being added + { + if (namestr.GetLength() <= 0 && exprstr.GetLength()) + { + addck.AddSprintf("\r\n add constraint CHECK (%s)", exprstr.GetString()); + } + else if (namestr.GetLength() && exprstr.GetLength()) + { + addck.AddSprintf("\r\n add constraint %s%s%s CHECK (%s)", m_backtick, namestr.GetString(), m_backtick, exprstr.GetString()); + } + + if (rowm_oldval->m_name) != 0) + { + if (namestr.GetLength() <= 0 && exprstr.GetLength()) + { + addck.AddSprintf("\r\n add constraint CHECK (%s)", exprstr.GetString()); + } + else if (namestr.GetLength() && exprstr.GetLength()) + { + addck.AddSprintf("\r\n add constraint %s%s%s CHECK %s", m_backtick, namestr.GetString(), m_backtick, exprstr.GetString()); + } + if (rowm_oldval->m_checkexpression) != 0) + { + if (namestr.GetLength() <= 0 && exprstr.GetLength()) + { + addck.AddSprintf("\r\n add constraint CHECK (%s)", exprstr.GetString()); + } + else if (namestr.GetLength() && exprstr.GetLength()) + { + addck.AddSprintf("\r\n add constraint %s%s%s CHECK %s", m_backtick, namestr.GetString(), m_backtick, exprstr.GetString()); + } + if (rowm_errmsg) + { + tempstr.AddSprintf("\t\t/* %s */", pwrapobj->m_errmsg->GetString()); + } + } + if (dropck.GetLength()) + query.AddSprintf("%s", dropck.GetString()); + + if (addck.GetLength()) + query.AddSprintf("%s", addck.GetString()); + + query.RTrim(); + + return validflg; +} + +void +TabCheck::CheckForQuotesAndReplace(wyString *name) +{ + wyBool flag = wyFalse; + name->LTrim(); + name->RTrim(); + const char first = name->GetCharAt(0); + const char last = name->GetCharAt(name->GetLength()-1); + + if (first == '`' && last == '`') + { + name->Strip(1); + name->Erase(0, 1); + } + return ; +} + +void +TabCheck::OnTabSelChanging() +{ + ApplyCancelGridChanges(); + ValidateChecks(); +} + +void +TabCheck::OnTabSelChange() +{ + HWND hwndarr[10] = { m_hgridtblcheckconst,m_ptabmgmt->m_hwndtool, NULL}; + + EnumChildWindows(m_hwnd, TableTabInterfaceTabMgmt::ShowWindowsProc, (LPARAM)hwndarr); + + SetFocus(m_hgridtblcheckconst); + + //int b = CustomGrid_GetRowCount(m_hgridtblcheckconst); + + SendMessage(m_ptabmgmt->m_hwndtool, TB_HIDEBUTTON, (WPARAM)IDM_SEPARATOR, (LPARAM)MAKELONG(TRUE, 0)); + SendMessage(m_ptabmgmt->m_hwndtool, TB_HIDEBUTTON, (WPARAM)IDI_MOVEUP, (LPARAM)MAKELONG(TRUE, 0)); + SendMessage(m_ptabmgmt->m_hwndtool, TB_HIDEBUTTON, (WPARAM)IDI_MOVEDOWN, (LPARAM)MAKELONG(TRUE, 0)); +} + +void +TabCheck::ApplyCancelGridChanges() +{ + wyInt32 row, col; + + row = CustomGrid_GetCurSelRow(m_hgridtblcheckconst); + col = CustomGrid_GetCurSelCol(m_hgridtblcheckconst); + + //if (col == INDEXTYPE && m_automatedindexrow != row) + //CustomGrid_CancelChanges(m_hgridtblcheckconst, wyTrue); + //else + CustomGrid_ApplyChanges(m_hgridtblcheckconst, wyTrue); +} + +void +TabCheck::Resize() +{ + RECT rcmain, rctoolbar; + wyInt32 hpos, vpos, height; + + VERIFY(GetWindowRect(m_hwnd, &rcmain)); + VERIFY(MapWindowPoints(NULL, m_hwnd, (LPPOINT)&rcmain, 2)); + + VERIFY(GetWindowRect(m_ptabmgmt->m_hwndtool, &rctoolbar)); + VERIFY(MapWindowPoints(NULL, m_ptabmgmt->m_hwndtool, (LPPOINT)&rctoolbar, 2)); + + //..Moving Grid + hpos = m_ptabmgmt->m_tabinterfaceptr->m_open_in_dialog ? 2 : 1; + vpos = rctoolbar.bottom; // 25; + height = rcmain.bottom - rcmain.top - rctoolbar.bottom - rctoolbar.top - 2; //..25 for "Hide Language Options" checkbox So that grid in each tab is consistent with TabField's grid + + if (m_ptabmgmt->m_tabinterfaceptr->m_open_in_dialog) + MoveWindow(m_hgridtblcheckconst, hpos, vpos, rcmain.right - 3, height, TRUE); + else + MoveWindow(m_hgridtblcheckconst, hpos, vpos, rcmain.right - 2, height, TRUE); +} + +void +TabCheck::ReInitializeGrid() +{ + /// Function re-initializes all index-values in the grid after 'Save' + wyString tblname, dbname; + wyInt32 row = -1; + //m_automatedindexrow = -1; + + //from .ini file. Refresh always + m_backtick = AppendBackQuotes() == wyTrue ? "`" : ""; + + ClearAllMemory(); + CustomGrid_DeleteAllRow(m_hgridtblcheckconst, wyTrue); + + FetchCheckConstraintsIntoWrapper(); + FillInitValues(); + + row = InsertRow(); + if (row != -1) + CustomGrid_SetCurSelection(m_hgridtblcheckconst, row, CONSTRAINTNAME); + +} + + +void +TabCheck::HandleChecksOnFieldRename(CheckConstraintStructWrapper* checkwrap ) +{ + /// Changes the index-columns string, if the column from grid in the Columns-tab in renamed + wyString expr(""), name(""); + wyString tmpstr; + wyUInt32 nrows = 0, row = -1; + IndexColumn *iindcols = NULL; + + if (!checkwrap) + return; + + //from .ini file + m_backtick = AppendBackQuotes() == wyTrue ? "`" : ""; + + nrows = CustomGrid_GetRowCount(m_hgridtblcheckconst); + + for (row = 0; rowm_newval == checkwrap->m_oldval) + checkwrap->m_newval = GetDuplicateCheckStruct(checkwrap->m_oldval); + + checkwrap->m_newval->m_name.SetAs(name); + ScanEntireRow(row, CONSTRAINTNAME, name); + + checkwrap->m_newval->m_checkexpression.SetAs(expr); + ScanEntireRow(row, CONSTRAINTEXPRESSION, expr); + + //CustomGrid_SetText(m_hgridtblcheckconst, row, CONSTRAINTNAME, checkwrap->m_newval->m_name); +} + + + +wyBool +TabCheck::ValidateChecks(wyBool showmsg) +{ + wyUInt32 nrows = 0; + wyString columnsstr; + + nrows = CustomGrid_GetRowCount(m_hgridtblcheckconst); + //IndexesStructWrapper *indwrap = NULL; + + /*for (int row = 0; rowm_errmsg; + indwrap->m_errmsg = NULL; + + if (row == m_automatedindexrow) + continue; + + if (!indwrap->m_newval) + continue; + + GetGridCellData(m_hgridindexes, row, INDEXCOLUMNS, columnsstr); + + if (!columnsstr.GetLength()) + { + if (!indwrap->m_errmsg) + indwrap->m_errmsg = new wyString; + indwrap->m_errmsg->SetAs(NO_COLUMNS_DEFINED_FOR_INDEX); + + if (showmsg) + { + if (m_ptabmgmt->GetActiveTabImage() != IDI_TABIMG_INDEXES) + CustomTab_SetCurSel(m_ptabmgmt->m_hwnd, 1); + + CustomGrid_SetCurSelection(m_hgridindexes, row, INDEXCOLUMNS, wyTrue); + CustomGrid_EnsureVisible(m_hgridindexes, row, INDEXCOLUMNS, wyTrue); + + MessageBox(m_hwnd, NO_COLUMNS_DEFINED_FOR_INDEX, pGlobals->m_appname.GetAsWideChar(), MB_OK | MB_ICONERROR); + return wyFalse; + } + } + }*/ + return wyTrue; +} + +wyBool +TabCheck::ProcessInsert() +{ + wyInt32 newrowid = -1; + ApplyCancelGridChanges(); + + newrowid = InsertRow(); + + if (newrowid != -1) + CustomGrid_SetCurSelection(m_hgridtblcheckconst, newrowid, CONSTRAINTNAME); + + return wyTrue; +} + +wyBool +TabCheck::GenerateQuery(wyString& query) +{ + wyString str(""); + wyBool retval = wyTrue; + + //from .ini file + m_backtick = AppendBackQuotes() == wyTrue ? "`" : ""; + + if (m_ptabmgmt->m_tabinterfaceptr->m_isaltertable) + retval = GenerateAlterQuery(str); + else + retval = GenerateCreateQuery(str); + + if (str.GetLength()) + { + if (m_ptabmgmt->m_tabinterfaceptr->m_isaltertable) + query.AddSprintf(" %s\r\n", str.GetString()); + else + query.AddSprintf("%s\r\n", str.GetString()); + return wyTrue; + } + + return retval; +} + +wyBool +TabCheck::GenerateAlterQuery(wyString &query) +{ + wyBool validflg = wyTrue, flag = wyTrue; + wyString localquerystr(""); + + //..Combining queries for dropped, modified and new indexes + validflg = GetDroppedChecks(localquerystr); + validflg = (flag = GetNewAndModifiedChecks(localquerystr)) ? validflg : flag; + + localquerystr.RTrim(); + + if (localquerystr.GetLength()) + query.AddSprintf("%s", localquerystr.GetString()); + + return validflg; +} + + +wyBool +TabCheck::GetDroppedChecks(wyString& query) +{ + wyString keyname, temp; + wyString dbname, tblname, localquerystr(""); + CheckConstraintStructWrapper *pwrapobj = NULL; + + m_backtick = AppendBackQuotes() == wyTrue ? "`" : ""; + + pwrapobj = (CheckConstraintStructWrapper *)m_listwrapperstruct.GetFirst(); + + while (pwrapobj) + { + if (!pwrapobj->m_newval) + { + temp.SetAs(pwrapobj->m_oldval->m_name); + //if (pwrapobj->m_oldval->m_name.CompareI("PRIMARY") == 0) + //localquerystr.Add("\r\n drop primary key,"); + //else + localquerystr.AddSprintf("\r\n drop constraint %s%s%s,", m_backtick, temp.GetString(),m_backtick); + } + pwrapobj = (CheckConstraintStructWrapper *)pwrapobj->m_next; + } + + localquerystr.RTrim(); + query.SetAs(localquerystr); + + return wyTrue; +} + + +wyBool +TabCheck::GenerateCreateQuery(wyString &query) +{ + wyBool flag = wyTrue; + wyUInt32 rowcount = 0; + wyString constraintnamestr, expressionstr, chkconstraintstr; + wyString tempstr; + rowcount = CustomGrid_GetRowCount(m_hgridtblcheckconst); + CheckConstraintStructWrapper *chkwrap = NULL; + + for (int row = 0; row 64) + //{ + // MessageBox(m_hwnd, _(L"Please enter a constraint name less than 64 characters"), + // _(L"Warning"), MB_ICONWARNING | MB_OK | MB_DEFBUTTON2); + // return wyFalse; + //} + + //from .ini file + m_backtick = AppendBackQuotes() == wyTrue ? "`" : ""; + + //if ((!constraintnamestr.GetLength()) && (!constraintnamestr.GetLength())) + // continue; + + //if ((expressionstr.GetLength() == 0)) + // continue; + if (constraintnamestr.GetLength() <= 0 && expressionstr.GetLength()>0) + { + chkconstraintstr.AddSprintf("\r\n CHECK (%s)", expressionstr.GetString()); + } + else + { + chkconstraintstr.AddSprintf("\r\n CONSTRAINT %s%s%s CHECK (%s)", m_backtick,constraintnamestr.GetString(), m_backtick, expressionstr.GetString()); + } + + + chkconstraintstr.Add(","); + + //..Appending error message + if (expressionstr.GetLength() == 0) + { + tempstr.SetAs(NO_EXPRESSION_SPECIFIED_FOR_CHECK); + chkconstraintstr.AddSprintf("\t\t/* %s */", _(tempstr.GetString())); + } + } + if (chkconstraintstr.GetLength()) + { + chkconstraintstr.Strip(1); + query.AddSprintf("%s", chkconstraintstr.GetString()); + } + return flag; +} + +wyUInt32 +TabCheck::GetGridCellData(HWND hwndgrid, wyUInt32 row, wyUInt32 col, wyString &celldata) +{ + wyString tempstr(""); + wyWChar *data; + wyUInt32 celldatalen = 0; + + celldatalen = 0; + celldatalen = CustomGrid_GetItemTextLength(hwndgrid, row, col); + if (celldatalen) + { + data = (wyWChar*)malloc(sizeof(wyWChar) * (celldatalen + 1)); + data[0] = '\0'; + + CustomGrid_GetItemText(hwndgrid, row, col, data); + tempstr.SetAs(data); + free(data); + } + else + tempstr.SetAs(""); + tempstr.RTrim(); + celldata.SetAs(tempstr); + return celldata.GetLength(); +} + +wyBool +TabCheck::OnGVNBeginLabelEdit(HWND hwnd, WPARAM wParam, LPARAM lParam) +{ + wyUInt32 row = wParam; + wyUInt32 col = lParam; + wyUInt32 count = -1; + wyString celldata, constnamestr, indcolsstr, indexcomment; + + GetGridCellData(m_hgridtblcheckconst, row, CONSTRAINTNAME, constnamestr); + GetGridCellData(m_hgridtblcheckconst, row, CONSTRAINTEXPRESSION, indcolsstr); + + + GetGridCellData(m_hgridtblcheckconst, row, col, m_celldataprevval); + + count = CustomGrid_GetRowCount(m_hgridtblcheckconst); + + if (row == (count - 1)) + { + //..Adding extra row when the row being edited is the last row of the grid + InsertRow(); + } + + return wyTrue; +} + +void +TabCheck::OnGVNButtonClick() +{ + + //row = CustomGrid_GetCurSelRow(m_hgridtblcheckconst); + //col = CustomGrid_GetCurSelCol(m_hgridtblcheckconst); + + //CustomGrid_ApplyChanges(m_hgridtblcheckconst, wyTrue); + + //if (col == INDEXCOLUMNS) + //{ + // CustomGrid_ApplyChanges(m_hgridindexes, wyTrue); + // ShowColumnsDialog(); + //} +} + + +wyBool +TabCheck::OnGVNEndLabelEdit(WPARAM wParam, LPARAM lParam) +{ + wyChar *data = (wyChar*)lParam; + wyUInt32 row, col; + wyString currentdata; + wyString indexnamestr(""), indexcolsstr(""); + row = LOWORD(wParam); + col = HIWORD(wParam); + + + //..Work-around to the cutsomgrid issue + if (!(col >= 0 )) + return wyTrue; + + if (!(row >= 0 && row <= CustomGrid_GetRowCount(m_hgridtblcheckconst))) + return wyTrue; + + if (data) + currentdata.SetAs(data); + + currentdata.RTrim(); + + //.. return if modified celldata is same as previous celldata + if (m_celldataprevval.Compare(currentdata) == 0) + { + return wyTrue; + } + + switch (col) + { + case CONSTRAINTNAME: + if (!OnEndEditName(wParam, lParam)) + return wyFalse; + break; + + case CONSTRAINTEXPRESSION: + if (!OnEndEditExpression(wParam, lParam)) + return wyFalse; + break; + } + if (!m_ptabmgmt->m_tabinterfaceptr->m_dirtytab) + m_ptabmgmt->m_tabinterfaceptr->MarkAsDirty(wyTrue); + + return wyTrue; + +} + + + +LRESULT +TabCheck::OnGVNSysKeyDown(HWND hwnd, WPARAM wParam, LPARAM lParam) +{ + //if (m_ptabmgmt->OnSysKeyDown(hwnd, wParam, lParam) == wyTrue) + //{ + // return 1; + //} + + //if (!m_ptabmgmt->m_tabinterfaceptr->m_open_in_dialog) + // return 1; + + return m_ptabmgmt->m_tabinterfaceptr->OnWMSysKeyDown(1, wParam, lParam); +} + +wyBool +TabCheck::OnEndEditExpression(WPARAM wParam, LPARAM lParam) +{ + wyChar *data = (wyChar*)lParam; + wyUInt32 row, col; + wyString currentdata(""); + CheckConstraintStructWrapper *cwrapobj = NULL; + CheckConstarintInfo *icheck = NULL; + wyString contraintnamestr(""); + wyString expressionstr(""); + + row = LOWORD(wParam); + col = HIWORD(wParam); + + GetGridCellData(m_hgridtblcheckconst, row, CONSTRAINTEXPRESSION, expressionstr); + + if (data) + currentdata.SetAs(data); + + currentdata.RTrim(); + cwrapobj = (CheckConstraintStructWrapper*)CustomGrid_GetRowLongData(m_hgridtblcheckconst, row); + + //..If no wrapper is attached + if (!cwrapobj) + { + icheck = new CheckConstarintInfo(); + icheck->m_name.Clear(); + icheck->m_listcolumns = NULL; + icheck->m_checkexpression.Clear(); + cwrapobj = new CheckConstraintStructWrapper(icheck, wyTrue); + m_listwrapperstruct.Insert(cwrapobj); + } + else + { + //..If the constraint-name is erased + if (!currentdata.GetLength()) + { + //..If user has deleted constraint-name and constraint-expression values from existing check constraint, this condition will be false + // we need to proceed only when user has not cleared Existing check constraint + if (cwrapobj->m_newval) + { + //..If Check constraint name is not selected, then set m_newval to NULL. + //.. if the constraint name is new, then remove it from the m_listwrapper. + if (!contraintnamestr.GetLength()) + { + //..existing constraint (Alter table) + if (cwrapobj->m_oldval) + { + if (cwrapobj->m_oldval != cwrapobj->m_newval) //..true, if existing constraint is already modified + delete cwrapobj->m_newval; + cwrapobj->m_newval = NULL; + } + //..newly added constraint + else if (cwrapobj->m_newval) + { + m_listwrapperstruct.Remove(cwrapobj); + delete cwrapobj; + cwrapobj = NULL; + } + } + //.. If constraint name is selected, + else + { + if (cwrapobj->m_newval == cwrapobj->m_oldval) + { + cwrapobj->m_newval = GetDuplicateCheckStruct(cwrapobj->m_oldval); + } + } + } + } + //.. if something is there as constraint name + else + { + //..If user has not deleted all constraint-values from grid row + if (cwrapobj->m_newval) + { + //..If existing constraint is not yet modified + if (cwrapobj->m_newval == cwrapobj->m_oldval) + { + cwrapobj->m_newval = GetDuplicateCheckStruct(cwrapobj->m_oldval); + } + } + } + } + CustomGrid_SetRowLongData(m_hgridtblcheckconst, row, (LPARAM)cwrapobj); + + if (cwrapobj && cwrapobj->m_newval) + cwrapobj->m_newval->m_checkexpression.SetAs(currentdata); + + ScanEntireRow(row, col, currentdata); + + return wyTrue; +} + +wyBool +TabCheck::OnEndEditName(WPARAM wParam, LPARAM lParam) +{ + wyChar *data = (wyChar*)lParam; + wyUInt32 row, col; + wyString currentdata(""); + CheckConstraintStructWrapper *cwrapobj = NULL; + CheckConstarintInfo *icheck = NULL; + wyString contraintnamestr(""); + wyString expressionstr(""); + + row = LOWORD(wParam); + col = HIWORD(wParam); + + GetGridCellData(m_hgridtblcheckconst, row, CONSTRAINTNAME, contraintnamestr); + + if (data) + currentdata.SetAs(data); + + currentdata.RTrim(); + cwrapobj = (CheckConstraintStructWrapper*)CustomGrid_GetRowLongData(m_hgridtblcheckconst, row); + + //..If no wrapper is attached + if (!cwrapobj) + { + icheck = new CheckConstarintInfo(); + icheck->m_name.Clear(); + icheck->m_listcolumns = NULL; + icheck->m_checkexpression.Clear(); + cwrapobj = new CheckConstraintStructWrapper(icheck, wyTrue); + m_listwrapperstruct.Insert(cwrapobj); + } + else + { + //..If the constraint-name is erased + if (!currentdata.GetLength()) + { + //..If user has deleted constraint-name and constraint-expression values from existing check constraint, this condition will be false + // we need to proceed only when user has not cleared Existing check constraint + if (cwrapobj->m_newval) + { + //..If Check constraint name is not selected, then set m_newval to NULL. + //.. if the constraint name is new, then remove it from the m_listwrapper. + if (!contraintnamestr.GetLength()) + { + //..existing constraint (Alter table) + if (cwrapobj->m_oldval) + { + if (cwrapobj->m_oldval != cwrapobj->m_newval) //..true, if existing constraint is already modified + delete cwrapobj->m_newval; + cwrapobj->m_newval = NULL; + } + //..newly added constraint + else if (cwrapobj->m_newval) + { + m_listwrapperstruct.Remove(cwrapobj); + delete cwrapobj; + cwrapobj = NULL; + } + } + //.. If constraint name is selected, + else + { + if (cwrapobj->m_newval == cwrapobj->m_oldval) + { + cwrapobj->m_newval = GetDuplicateCheckStruct(cwrapobj->m_oldval); + } + } + } + } + //.. if something is there as constraint name + else + { + //..If user has not deleted all constraint-values from grid row + if (cwrapobj->m_newval) + { + //..If existing constraint is not yet modified + if (cwrapobj->m_newval == cwrapobj->m_oldval) + { + cwrapobj->m_newval = GetDuplicateCheckStruct(cwrapobj->m_oldval); + } + } + } + } + CustomGrid_SetRowLongData(m_hgridtblcheckconst, row, (LPARAM)cwrapobj); + + if (cwrapobj && cwrapobj->m_newval) + cwrapobj->m_newval->m_name.SetAs(currentdata); + + ScanEntireRow(row, col, currentdata); + + return wyTrue; +} + +wyBool +TabCheck::ScanEntireRow(wyUInt32 currentrow, wyInt32 currentcol, wyString& currentdata) +{ + CheckConstraintStructWrapper *cwrapobj = NULL; + CheckColumn *chkcol1 = NULL, *chkcol2 = NULL; + List *list1 = NULL, *list2 = NULL; + CheckConstarintInfo *checks = NULL; + wyUInt32 row, col, ncols; + wyString newtext(""), origtext(""); + wyBool changed = wyFalse; + + row = currentrow; + col = currentcol; + + cwrapobj = (CheckConstraintStructWrapper*)CustomGrid_GetRowLongData(m_hgridtblcheckconst, row); + + if (!cwrapobj) + return wyFalse; + + //..Return if anyone of oldval and newval is not there + if (!cwrapobj->m_oldval || !cwrapobj->m_newval) + { + return wyFalse; + } + + //..Return if both oldval and newval are equal + if (cwrapobj->m_oldval == cwrapobj->m_newval) + return wyFalse; + + checks = cwrapobj->m_oldval; + + ncols = CustomGrid_GetColumnCount(m_hgridtblcheckconst); + + for (int i = 0; i< ncols; i++) + { + origtext.Clear(); + + if (i == col) + newtext.SetAs(currentdata); + else + GetGridCellData(m_hgridtblcheckconst, row, i, newtext); + + switch (i) + { + case CONSTRAINTNAME: + origtext.SetAs(checks->m_name); + break; + + case CONSTRAINTEXPRESSION: + origtext.SetAs(checks->m_checkexpression); + break; + + default: + origtext.SetAs(""); + } + newtext.RTrim(); + + if (changed || origtext.Compare(newtext) != 0) + { + changed = wyTrue; + break; + } + } + + if (!changed) + { + delete cwrapobj->m_newval; + cwrapobj->m_newval = cwrapobj->m_oldval; + } + return wyTrue; +} + + +CheckConstarintInfo* +TabCheck::GetDuplicateCheckStruct(CheckConstarintInfo* duplicateof) +{ + CheckConstarintInfo* checks = NULL; + + if (duplicateof) + { + checks = new CheckConstarintInfo(); + checks->m_listcolumns = new List(); + + //..Setting constraint name and expression + checks->m_name.SetAs(duplicateof->m_name); + checks->m_checkexpression.SetAs(duplicateof->m_checkexpression); + } + return checks; +} + +void +TabCheck::CancelChanges(wyBool isaltertable) +{ + wyUInt32 count = -1, row = -1; + CheckConstraintStructWrapper *cwrapobj = NULL; + + //..The below function will apply or cancel the custgrid changes + OnTabSelChanging(); + + count = CustomGrid_GetRowCount(m_hgridtblcheckconst); + + for (row = 0; row < count; row++) + { + cwrapobj = (CheckConstraintStructWrapper *)CustomGrid_GetRowLongData(m_hgridtblcheckconst, row); + if (cwrapobj && cwrapobj->m_newval && !cwrapobj->m_oldval) //..Create/Alter table (If new (valid)field is added) + { + m_listwrapperstruct.Remove(cwrapobj); + + delete cwrapobj; + } + else if (cwrapobj && cwrapobj->m_newval && cwrapobj->m_oldval) //..Alter table (If field is added) + { + if (cwrapobj->m_newval != cwrapobj->m_oldval) //..If field modified, delete m_newval, and set it as m_oldval + delete cwrapobj->m_newval; + + cwrapobj->m_newval = cwrapobj->m_oldval; + } + } + + cwrapobj = (CheckConstraintStructWrapper*)m_listwrapperstruct.GetFirst(); + + while (cwrapobj) + { + if (cwrapobj->m_errmsg) + delete cwrapobj->m_errmsg; + cwrapobj->m_errmsg = NULL; + + cwrapobj->m_newval = cwrapobj->m_oldval; + cwrapobj = (CheckConstraintStructWrapper*)cwrapobj->m_next; + } + + //m_automatedindexrow = -1; + //m_lastclickindgrid = -1; + + CustomGrid_DeleteAllRow(m_hgridtblcheckconst, wyTrue); + + //..Create table + if (!isaltertable) + { + row = InsertRow(); + CustomGrid_SetCurSelection(m_hgridtblcheckconst, row, CONSTRAINTNAME); + InvalidateRect(m_hgridtblcheckconst, NULL, TRUE); + return; + } + + //..Alter table + FillInitValues(); + + row = InsertRow(); + + //if (m_ptabmgmt->GetActiveTabImage() == IDI_TABIMG_INDEXES) + //{ + // SetFocus(m_hgridindexes); + //} + CustomGrid_SetCurSelection(m_hgridtblcheckconst, row, CONSTRAINTNAME); + return; +} + +wyBool +TabCheck::ProcessDelete() +{ + wyInt32 selrow; + + selrow = CustomGrid_GetCurSelRow(m_hgridtblcheckconst); + + if (selrow == -1) + return wyFalse; + + ApplyCancelGridChanges(); + + if (!DropSelectedChecks()) + { + //..Processing Drop of the index for the current row, if user has not checked any row + DropCheck(selrow); + } + //ReInitializeGrid(); + if (CustomGrid_GetRowCount(m_hgridtblcheckconst) == 0) + { + selrow = InsertRow(); + CustomGrid_SetCurSelection(m_hgridtblcheckconst, selrow, CONSTRAINTNAME); + } + + return wyTrue; +} + +wyBool +TabCheck::DropSelectedChecks() +{ + wyInt32 count, row, ret = IDNO; + wyBool checkrowfound = wyFalse; + CheckConstraintStructWrapper *pwrapobj = NULL; + wyString constraint; + + count = CustomGrid_GetRowCount(m_hgridtblcheckconst); + + for (row = 0; rowm_oldval) + { + constraint.SetAs(pwrapobj->m_oldval->m_name); + } + //else //if (pwrapobj != NULL && pwrapobj->m_newval && pwrapobj->m_oldval) + //{ + // constraint.SetAs(pwrapobj->m_newval->m_name); + //} + + + //..Deleting empty row without confirmation + if (!pwrapobj || !pwrapobj->m_newval) + { + CustomGrid_DeleteRow(m_hgridtblcheckconst, row, wyTrue); + row--; + count--; + /*if ((m_automatedindexrow != -1) && row <= m_automatedindexrow) + m_automatedindexrow--;*/ + continue; + } + else if (ret == IDNO) + { + ret = MessageBox(m_hgridtblcheckconst, _(L"Do you want to drop the selected check constraint(s)?"), pGlobals->m_appname.GetAsWideChar(), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2); + if (ret != IDYES) + return wyTrue; + } + + ChangeListOnDelete(pwrapobj); + + + CustomGrid_DeleteRow(m_hgridtblcheckconst, row, wyTrue); + + ////..reduce m_automatedindexrow if row is less than the m_automatedindexrow + //if (row <= m_automatedindexrow) + // m_automatedindexrow--; + row--; + count--; + } + } + + + if (ret == IDYES) + { + if (m_ptabmgmt->m_tabinterfaceptr->m_dirtytab != wyTrue) + { + m_ptabmgmt->m_tabinterfaceptr->MarkAsDirty(wyTrue); + } + } + + //..resetting m_lastclickindgrid + if (checkrowfound && m_lastclickindgrid != -1) + m_lastclickindgrid = -1; + + return checkrowfound; + +} + + +void +TabCheck::ChangeListOnDelete(CheckConstraintStructWrapper * cwrapobj) +{ + /// For existing index, set m_newval to NULL + /// for new added index, remove wrapper from the m_listwrapperstruct and delete it + + if (!cwrapobj) + return; + + if (!cwrapobj->m_newval) + return; + + if (cwrapobj->m_oldval) + { + if (cwrapobj->m_oldval != cwrapobj->m_newval) + { + cwrapobj->m_newval->m_name = ""; + cwrapobj->m_newval->m_checkexpression = ""; + delete cwrapobj->m_newval; + } + cwrapobj->m_newval = NULL; + } + else + { + m_listwrapperstruct.Remove(cwrapobj); + delete cwrapobj; + } +} + + + +wyBool +TabCheck::DropCheck(wyUInt32 row) +{ + /// Dropping the index from the currently selected/focused row in the grid + wyInt32 ret = IDNO; + CheckConstraintStructWrapper *pwrapobj = NULL; + wyString name(""), exprsstr(""); + + pwrapobj = (CheckConstraintStructWrapper*)CustomGrid_GetRowLongData(m_hgridtblcheckconst, row); + + if (pwrapobj && pwrapobj->m_newval) + { + GetGridCellData(m_hgridtblcheckconst, row, CONSTRAINTNAME, name); + GetGridCellData(m_hgridtblcheckconst, row, CONSTRAINTEXPRESSION, exprsstr); + + if (name.GetLength() || exprsstr.GetLength() || pwrapobj->m_oldval) + { + // Ask for confirmation, if the wrapper is associated with the row and the index-values are not deleted from the row + ret = MessageBox(m_hgridtblcheckconst, _(L"Do you want to drop this check constraint?"), pGlobals->m_appname.GetAsWideChar(), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2); + if (ret != IDYES) + return wyFalse; + } + + ChangeListOnDelete(pwrapobj); + } + CustomGrid_DeleteRow(m_hgridtblcheckconst, row, wyTrue); + m_lastclickindgrid = -1; + + if (CustomGrid_GetRowCount(m_hgridtblcheckconst)) + { + if (row == 0) // if the selected row was first then we just select the first row and column + { + CustomGrid_SetCurSelection(m_hgridtblcheckconst, 0, CONSTRAINTNAME); + } + else + { + CustomGrid_SetCurSelection(m_hgridtblcheckconst, --row, CONSTRAINTNAME); + } + } + + if (ret == IDYES && m_ptabmgmt->m_tabinterfaceptr->m_dirtytab != wyTrue) + { + m_ptabmgmt->m_tabinterfaceptr->MarkAsDirty(wyTrue); + } + + return wyTrue; +} + +void +TabCheck::HandleCheckboxClick(HWND hwnd, LPARAM lparam, WPARAM wparam, wyInt32 &lastclickindex) +{ + wyInt32 ret, startpos, endpos, flag, currow = -1; + + if (CustomGrid_GetRowCount(hwnd) == 0) + return; + + ret = GetKeyState(VK_SHIFT);// shift key is pressed or not + + if (wparam == VK_SPACE)// && GetKeyState(VK_CONTROL) + { + if (lastclickindex == -1 || !(ret & 0x8000)) + { + lastclickindex = CustomGrid_GetCurSelRow(hwnd); + if (lastclickindex == -1 || (CustomGrid_GetRowCount(hwnd) == 0)) + return; + + flag = CustomGrid_GetRowCheckState(hwnd, lastclickindex); + CustomGrid_SetRowCheckState(hwnd, lastclickindex, flag == GV_CHEKCED ? wyFalse : wyTrue); + return; + } + currow = CustomGrid_GetCurSelRow(hwnd); + } + else + { + if (lastclickindex == -1 || !(ret & 0x8000)) //..If first time, any checkbox is clicked or shift key is not pressed, then no multiple selection required.. + { + lastclickindex = wparam; + return; + } + + if (lastclickindex == wparam) + return; + currow = wparam; + } + + if (currow < lastclickindex) + { + startpos = currow; + endpos = lastclickindex; + } + else + { + startpos = lastclickindex; + endpos = currow; + } + + flag = CustomGrid_GetRowCheckState(hwnd, currow); + + while (startpos <= endpos) + { + if (wparam == VK_SPACE) + CustomGrid_SetRowCheckState(hwnd, startpos, flag == GV_CHEKCED ? wyFalse : wyTrue); + else + CustomGrid_SetRowCheckState(hwnd, startpos, flag == GV_CHEKCED ? wyTrue : wyFalse); + startpos++; + } + lastclickindex = currow; +} + +wyBool +TabCheck::ExecuteQuery(wyString &query) +{ + MYSQL_RES *res; + wyInt32 isintransaction = 1; + + res = ExecuteAndGetResult(m_mdiwnd, m_mdiwnd->m_tunnel, &(m_mdiwnd->m_mysql), query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction, GetActiveWindow()); + + if (isintransaction == 1) + return wyFalse; + + if (!res && m_mdiwnd->m_tunnel->mysql_affected_rows(m_mdiwnd->m_mysql) == -1) + { + ShowMySQLError(m_hwnd, m_mdiwnd->m_tunnel, &(m_mdiwnd->m_mysql), query.GetString()); + return wyFalse; + } + m_mdiwnd->m_tunnel->mysql_free_result(res); + + return wyTrue; +} diff --git a/src/TabFields.cpp b/src/TabFields.cpp index 89a7735..d5566f5 100644 --- a/src/TabFields.cpp +++ b/src/TabFields.cpp @@ -127,9 +127,10 @@ TabFields::TabFields(HWND hwnd, TableTabInterfaceTabMgmt* ptabmgmt) m_ismariadb52 = IsMariaDB52(m_mdiwnd->m_tunnel, &m_mdiwnd->m_mysql); m_ismysql57 = IsMySQL57(m_mdiwnd->m_tunnel, &m_mdiwnd->m_mysql); m_ismysql578 = IsMySQL578(m_mdiwnd->m_tunnel, &m_mdiwnd->m_mysql); + m_ismariadb10309 = IsMariaDB10309(m_mdiwnd->m_tunnel, &m_mdiwnd->m_mysql); m_p = new Persist; m_p->Create("TabbedInterface"); - + m_isalter = wyFalse; } TabFields::~TabFields() @@ -630,7 +631,7 @@ TabFields::TraverseEachFieldRow(MYSQL_RES *myfieldres,wyString createtable) FIELDATTRIBS *fieldattr = NULL; FieldStructWrapper *cwrapobj = NULL,*cwrapobj2 = NULL; wyChar *tempstr = NULL,*currentrowstr=NULL,*wholecreatestring=NULL; - wyString strcreate, query, expressionvalue; + wyString strcreate, query, expressionvalue, checkexpression; MYSQL_ROW myfieldrow; wyString rowname, datatype; wyString myrowstr, isnullstr, defaultstr; @@ -759,9 +760,9 @@ TabFields::TraverseEachFieldRow(MYSQL_RES *myfieldres,wyString createtable) } } - else if(strstr(myrowstr.GetString(), "PERSISTENT")) + else if(strstr(myrowstr.GetString(), "STORED")) { - fieldattr->m_virtuality.SetAs("PERSISTENT"); + fieldattr->m_virtuality.SetAs("STORED"); if(expressionvalue.GetLength()!=0) expressionvalue.Clear(); if(GetExpressionValue(currentrowstr,&expressionvalue)) @@ -815,6 +816,17 @@ TabFields::TraverseEachFieldRow(MYSQL_RES *myfieldres,wyString createtable) fieldattr->m_onupdate = wyTrue; } } + // we have to parse createtable string for check constraint expression + //if (m_ismariadb52) + //{ + if (checkexpression.GetLength() != 0) + checkexpression.Clear(); + if (GetCheckConstraintValue(currentrowstr, &checkexpression)) + { + fieldattr->m_mycheckexpression.SetAs(checkexpression.GetString()); + + } + //} /// Extracting the len value tempstr[0] = NULL; @@ -1036,6 +1048,7 @@ TabFields::FillInitData() CustomGrid_SetText(m_hgridfields, rowno, LENGTH, temp->m_len.GetString()); CustomGrid_SetText(m_hgridfields, rowno, DEFVALUE, temp->m_default.GetString()); + CustomGrid_SetText(m_hgridfields, rowno, CHECKCONSTRAINT, temp->m_mycheckexpression.GetString()); if(index) { @@ -1048,6 +1061,7 @@ TabFields::FillInitData() CustomGrid_SetText(m_hgridfields, rowno, VIRTUALITY , temp->m_virtuality.GetString()); SetValidation(rowno, (wyChar*) temp->m_virtuality.GetString()); CustomGrid_SetText(m_hgridfields, rowno, EXPRESSION , temp->m_expression.GetString()); + } //filling virtual/Stored combo box. else if(m_ismysql57) @@ -1120,23 +1134,23 @@ TabFields::InitGrid() wyWChar virtuallity[3][20]= { L"(none)", L"VIRTUAL",NULL}; - - if(m_ismariadb52) + if (m_ismariadb10309) + mbstowcs(virtuallity[2], "STORED", strlen("STORED") + 1); + else if(m_ismariadb52) mbstowcs (virtuallity[2], "PERSISTENT", strlen("PERSISTENT")+1); - else mbstowcs (virtuallity[2], "STORED", strlen("STORED")+1); wyChar *heading[] = {_("Column Name"), _("Data Type"), _("Length"), _("Default"), _("PK?"), _("Binary?"), _("Not Null?"), - _("Unsigned?"), _("Auto Incr?"), _("Zerofill?"), _("Charset"), _("Collation"), _("On Update"), _("Comment"), _("Virtuality"),_("Expression")}; + _("Unsigned?"), _("Auto Incr?"), _("Zerofill?"), _("Charset"), _("Collation"), _("On Update"), _("Comment"), _("Virtuality"),_("Expression"),_("Check Constraint")}; wyInt32 mask[] = {GVIF_TEXT, GVIF_LIST, GVIF_TEXT, GVIF_TEXT, GVIF_BOOL, GVIF_BOOL, GVIF_BOOL, GVIF_BOOL, - GVIF_BOOL, GVIF_BOOL, GVIF_LIST, GVIF_LIST, GVIF_BOOL, GVIF_TEXT,GVIF_LIST,GVIF_TEXT}; + GVIF_BOOL, GVIF_BOOL, GVIF_LIST, GVIF_LIST, GVIF_BOOL, GVIF_TEXT,GVIF_LIST,GVIF_TEXT,GVIF_TEXT }; - wyInt32 cx[] = { 125, 95, 40, 80, 40, 60, 70, 70, 75, 70, 90, 140, 80, 150,20,95};//default/min col width + wyInt32 cx[] = { 125, 95, 40, 80, 40, 60, 70, 70, 75, 70, 90, 140, 80, 150,20,95,140 };//default/min col width wyInt32 format[] = { GVIF_LEFT, GVIF_LEFT, GVIF_LEFT, GVIF_LEFT, GVIF_CENTER, GVIF_CENTER, GVIF_CENTER, - GVIF_CENTER, GVIF_CENTER, GVIF_CENTER, GVIF_CENTER, GVIF_CENTER, GVIF_CENTER, GVIF_LEFT, GVIF_CENTER,GVIF_LEFT,GVIF_LEFT}; + GVIF_CENTER, GVIF_CENTER, GVIF_CENTER, GVIF_CENTER, GVIF_CENTER, GVIF_CENTER, GVIF_LEFT, GVIF_CENTER,GVIF_LEFT,GVIF_LEFT,GVIF_LEFT }; wyInt32 width = 0; wyString colname, dbname(RETAINWIDTH_DBNAME), tblname("__create_table"); @@ -1147,9 +1161,9 @@ TabFields::InitGrid() cx[1] = GetTextSize(L"mediumblob ", m_hgridfields, hfont).right + 15; //default min size for datatype col num_cols = sizeof (heading)/sizeof(heading[0]); - VOID *listtype[] = {NULL, (VOID*)type, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, (void*)virtuallity,NULL}; - wyInt32 elemsize[] = { 0, sizeof(type[0]), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,sizeof(virtuallity[0]),0}; - wyInt32 elemcount[] = {0, sizeof(type)/sizeof(type[0]), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, sizeof(virtuallity)/sizeof(virtuallity[0]),0}; + VOID *listtype[] = {NULL, (VOID*)type, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, (void*)virtuallity,NULL,NULL}; + wyInt32 elemsize[] = { 0, sizeof(type[0]), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,sizeof(virtuallity[0]),0,0}; + wyInt32 elemcount[] = {0, sizeof(type)/sizeof(type[0]), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, sizeof(virtuallity)/sizeof(virtuallity[0]),0,0}; if(! m_ismysql578) // to avoid extra counting of the new datatype json elemcount[1]=elemcount[1]-1; @@ -1290,12 +1304,13 @@ TabFields::GenerateCreateQuery(wyString& str) GetExtraValues(query, pfieldattribs); GetDefaultValue(query, cwrapobj); GetVirtualOrPersistentValue( query, cwrapobj); + if(m_ismysql41) { GetCommentValue(query,pfieldattribs); } - + GetCheckValue(query, pfieldattribs); query.RTrim(); query.Add(","); @@ -1364,6 +1379,9 @@ TabFields::GenerateAlterQuery(wyString& query) IndexColumn *icols = NULL; wyBool indexedfirst = wyFalse; + //To avoid extra parenthesis around check constraint extraint + m_isalter = wyTrue; + dbname.SetAs(((TableTabInterface*)m_ptabmgmt->m_tabinterfaceptr)->m_dbname); tablename.SetAs(((TableTabInterface*)m_ptabmgmt->m_tabinterfaceptr)->m_origtblname); @@ -1650,25 +1668,33 @@ void FIELDATTRIBS *fieldattr = NULL; wyString defvalue(""),computedfield(""), onupdate(""),onvirtualpersitentcolumns(""); wyString _comment(""); - wyBool skip=wyFalse, dropandrecreate=wyFalse; + wyBool skip=wyFalse, dropandrecreate=wyFalse, skipforcheck=wyFalse, dropandrecreatecheck=wyFalse; //we can not add other attributes if we are adding VIRTUAL/PERSIATENT - if(m_ismariadb52 && ((cwrapobj->m_newval->m_virtuality.GetLength()>6)&&(cwrapobj->m_newval->m_expression.GetLength()!=0))) + if(m_ismariadb52 && ((cwrapobj->m_newval->m_virtuality.GetLength()>5)&&(cwrapobj->m_newval->m_expression.GetLength()!=0))) skip=wyTrue; else if(m_ismysql57 && ((cwrapobj->m_newval->m_mysqlvirtuality.Compare("(none)"))&&(cwrapobj->m_newval->m_mysqlexpression.GetLength()!=0))) skip=wyTrue; + else if ((cwrapobj->m_newval->m_mycheckexpression.GetLength() != 0))// virtuality and column level check constraint are not allowed on the same column + { + skipforcheck = wyTrue; + } + //skipforcheck = wyTrue; //Altering a Virtual/persuatent column is not allowed we must drop and recreate dropandrecreate=IsDropAndRecreateRequired(cwrapobj,isnew); + + //Alter a CHECK constraint is not allowed. We must drop and recreate + //dropandrecreatecheck= IsDropAndRecreateCheckRequired(cwrapobj, isnew); fieldattr = cwrapobj->m_newval; if(!fieldattr) return; /// Checking which clause to use for column-definition - if(isnew || dropandrecreate ) - { //dropping and recreating - if(dropandrecreate) + if(isnew || dropandrecreate)// || dropandrecreatecheck) + { + if(dropandrecreate)//|| dropandrecreatecheck) { - newcolumns.AddSprintf("\r\n\tDROP COLUMN %s%s%s ,", m_backtick, fieldattr->m_name.GetString(), m_backtick ); + newcolumns.AddSprintf("\r\n\tDROP COLUMN %s%s%s ,", m_backtick, cwrapobj->m_oldval->m_name.GetString(), m_backtick );//modified the column needed to drop in case we modify the name of virtual column newcolumns.Add("\r\n\tadd column "); } else @@ -1774,14 +1800,50 @@ void } } + GetCommentValue(_comment, fieldattr); if(_comment.GetLength()) newcolumns.AddSprintf("%s", _comment.GetString()); newcolumns.RTrim(); + + + if (skipforcheck) + { + //if (m_ismariadb52) + //{ + GetCheckValue(computedfield, cwrapobj->m_newval); + newcolumns.AddSprintf(" %s", computedfield.GetString()); + //} + + } coldef.Add(newcolumns.GetString()); } +wyBool TabFields::IsDropAndRecreateCheckRequired(FieldStructWrapper* cwrapobj, wyBool isnew) +{ + + if (!isnew )//&& m_ismariadb52) + { + if ((cwrapobj->m_oldval->m_mycheckexpression.CompareI("")==0)) + { + return wyFalse; + } + if ((cwrapobj->m_oldval->m_mycheckexpression.CompareI(cwrapobj->m_newval->m_mycheckexpression.GetString()) != 0)) + return wyTrue; + else if ((cwrapobj->m_oldval->m_mycheckexpression.CompareI(cwrapobj->m_newval->m_mycheckexpression.GetString()) == 0) && (cwrapobj->m_newval->m_mycheckexpression.GetLength() != 0)) + return wyTrue; + + else + return wyFalse; + + + } + else + { + return wyFalse; + } +} wyBool TabFields::IsDropAndRecreateRequired(FieldStructWrapper* cwrapobj, wyBool isnew) { @@ -1831,6 +1893,28 @@ void } } +void +TabFields::GetCheckValue(wyString& query, FIELDATTRIBS* pfieldattribs) +{ + if (pfieldattribs->m_mycheckexpression.GetLength()) + { + //wyChar * checkexpressbuff = GetEscapedValue(m_mdiwnd->m_tunnel, &(m_mdiwnd->m_mysql), pfieldattribs->m_mycheckexpression.GetString()); + + // to avoid extra pair of parenthesis + if(m_isalter) + { + query.AddSprintf("CHECK %s", pfieldattribs->m_mycheckexpression.GetString()); + } + else + { + query.AddSprintf("CHECK (%s)", pfieldattribs->m_mycheckexpression.GetString()); + } + + //free(checkexpressbuff); + return; + } +} + void TabFields::GetExtraValues(wyString& query, FIELDATTRIBS* pfieldattribs) { @@ -1993,15 +2077,22 @@ void TabFields::GetVirtualOrPersistentValue(wyString& query, FieldStructWrapper* if(expression.Find("''", 1)) expression.SetAs("''"); } - tbuff = GetEscapedValue(m_mdiwnd->m_tunnel, &(m_mdiwnd->m_mysql), expression.GetString()); - expression.Sprintf("'%s'", tbuff); - - query.AddSprintf("%s ", expression.GetString()); + + if (expression.GetCharAt(0)== '\'' && expression.GetCharAt(expression.GetLength())== '\'') + { + expression.Erase(expression.GetLength(),1); + expression.Strip(1); + tbuff = GetEscapedValue(m_mdiwnd->m_tunnel, &(m_mdiwnd->m_mysql), expression.GetString()); + expression.Sprintf("'%s'", tbuff); + } + else { + //tbuff = GetEscapedValue(m_mdiwnd->m_tunnel, &(m_mdiwnd->m_mysql), expression.GetString()); + expression.Sprintf("%s", expression.GetString()); + } + + query.AddSprintf("%s", expression.GetString()); } - - - query.AddSprintf(") %s ", virtuality.GetString()); } @@ -2793,8 +2884,9 @@ TabFields::OnGVNEndLabelEdit(WPARAM wParam, LPARAM lParam) /// To avoid CustomGrid right-click Issue if(m_ismariadb52||m_ismysql57) - { //for virtual/persistent columns go till coloumn 14 - if(!(col >= 0 && col <= 14)) + { //for virtual/persistent columns go till column 14 + // Added check constraint column so now it will go till column 15 + if(!(col >= 0 && col <= 15)) return 1; } else @@ -3088,6 +3180,7 @@ TabFields::GetDuplicateFieldAttribsStruct(FIELDATTRIBS* original) newstruct->m_expression.SetAs(original->m_expression); newstruct->m_mysqlvirtuality.SetAs(original->m_mysqlvirtuality); newstruct->m_mysqlexpression.SetAs(original->m_mysqlexpression); + newstruct->m_mycheckexpression.SetAs(original->m_mycheckexpression); newstruct->m_next = NULL; @@ -3208,7 +3301,11 @@ TabFields::SetValueToStructure(wyUInt32 row, wyUInt32 col, wyChar* data) cwrap->m_newval->m_zerofill = wyFalse; } } - + else if (col == CHECKCONSTRAINT) + { + if (m_ismariadb52) + cwrap->m_newval->m_mycheckexpression.SetAs(data); + } if(m_ismysql41 && data) { switch(col) @@ -3429,6 +3526,11 @@ TabFields::ScanEntireRow(wyUInt32 currentrow, wyInt32 currentcol, wyString& cur newtext.SetAs(cwrapobj->m_newval->m_mysqlexpression); } break; + + case CHECKCONSTRAINT: + origtext.SetAs(fldattr->m_mycheckexpression); + newtext.SetAs(cwrapobj->m_newval->m_mycheckexpression); + break; } if(i == col) @@ -5103,6 +5205,11 @@ TabFields::ExchangeRowValues(wyInt32 row1, wyInt32 row2) CustomGrid_SetText(m_hgridfields, row1, DEFVALUE, data2.GetString()); CustomGrid_SetText(m_hgridfields, row2, DEFVALUE, data1.GetString()); + GetGridCellData(m_hgridfields, row1, CHECKCONSTRAINT, data1); + GetGridCellData(m_hgridfields, row2, CHECKCONSTRAINT, data2); + CustomGrid_SetText(m_hgridfields, row1, CHECKCONSTRAINT, data2.GetString()); + CustomGrid_SetText(m_hgridfields, row2, CHECKCONSTRAINT, data1.GetString()); + if(m_ismariadb52 || m_ismysql57) { GetGridCellData(m_hgridfields, row1, VIRTUALITY, data1); diff --git a/src/TabForeignKeys.cpp b/src/TabForeignKeys.cpp index 731b19f..7fb3871 100644 --- a/src/TabForeignKeys.cpp +++ b/src/TabForeignKeys.cpp @@ -2549,6 +2549,9 @@ TabForeignKeys::FillTgtColsDlgGrid(HWND hwnd) list = (List*)CustomGrid_GetItemLongValue(m_hgridfk, row, col); + //from .ini file. + m_backtick = AppendBackQuotes() == wyTrue ? "`" : ""; + if(list) { tgtcol = (FKTargetColumn*) list->GetFirst(); @@ -3008,6 +3011,7 @@ TabForeignKeys::HandleFKsOnFieldRename(FKStructWrapper* fkwrapobj, FieldStructWr ScanEntireRow(row, CHILDCOLUMNS, srccolsstr); CustomGrid_SetText(m_hgridfk, row, CHILDCOLUMNS, (wyChar*) srccolsstr.GetString()); + SetValueToStructure(row, CHILDCOLUMNS, (wyChar*)srccolsstr.GetString()); } void @@ -3497,7 +3501,7 @@ TabForeignKeys::ScanEntireRow(wyInt32 currentrow, wyInt32 currentcol, wyString& { if(srccol1->m_pcwrapobj != srccol2->m_pcwrapobj) break; - + srccol1 = (FKSourceColumn *) srccol1->m_next; srccol2 = (FKSourceColumn *) srccol2->m_next; } @@ -4262,6 +4266,9 @@ TabForeignKeys::AddFKOnDrag(FKStructWrapper *cwrap, List *temp_listsrccols) if(!cwrap) return wyFalse; + //from .ini file. + m_backtick = AppendBackQuotes() == wyTrue ? "`" : ""; + listsrccol = new List(); temp_srccol =(FKSrcColName_SD*) temp_listsrccols->GetFirst(); diff --git a/src/TabHistory.cpp b/src/TabHistory.cpp index f969a5c..5d72355 100644 --- a/src/TabHistory.cpp +++ b/src/TabHistory.cpp @@ -358,7 +358,7 @@ TabHistory::Show(wyBool setfocus) wyInt32 count = 0, i; CTCITEM item1 = {0}, item = {0}; wyString buffer; - + wyBool found = wyFalse; wyWChar *lpfileport = 0; wyWChar directory[MAX_PATH+1] = {0}; @@ -399,6 +399,7 @@ TabHistory::Show(wyBool setfocus) CustomTab_SetCurSel(m_hwndparent, i); CustomTab_EnsureVisible(m_hwndparent, i); } + } diff --git a/src/TabIndexes.cpp b/src/TabIndexes.cpp index 6ede0dd..d713a3e 100644 --- a/src/TabIndexes.cpp +++ b/src/TabIndexes.cpp @@ -3179,6 +3179,9 @@ TabIndexes::ReInitializeGrid() m_automatedindexrow = -1; + //from .ini file. Refresh always + m_backtick = AppendBackQuotes() == wyTrue ? "`" : ""; + ClearAllMemory(); CustomGrid_DeleteAllRow(m_hgridindexes, wyTrue); diff --git a/src/TabMgmt.cpp b/src/TabMgmt.cpp index dea7fc2..51e7d6a 100644 --- a/src/TabMgmt.cpp +++ b/src/TabMgmt.cpp @@ -460,7 +460,7 @@ TabMgmt::DeleteAllItem(wyBool isdeletefixedtabs) } ptr = (TabQueryTypes*)ctci.m_lparam; - CustomTab_DeleteItem(m_hwnd, 0); + CustomTab_DeleteItem(m_hwnd, 0,wyTrue); delete ptr; } @@ -472,7 +472,7 @@ TabMgmt::DeleteAllItem(wyBool isdeletefixedtabs) } void -TabMgmt::DeleteTab(wyInt32 index) +TabMgmt::DeleteTab(wyInt32 index, wyBool ispostion) { CTCITEM ctci; TabQueryTypes* ptr; @@ -482,7 +482,7 @@ TabMgmt::DeleteTab(wyInt32 index) ctci.m_mask = CTBIF_LPARAM; CustomTab_GetItem(m_hwnd, index, &ctci); ptr = (TabQueryTypes*)ctci.m_lparam; - CustomTab_DeleteItem(m_hwnd, index); + CustomTab_DeleteItem(m_hwnd, index, ispostion); delete ptr; if(index <= i && CustomTab_GetItemCount(m_hwnd)) diff --git a/src/TabModule.cpp b/src/TabModule.cpp index 8b769ad..593a791 100644 --- a/src/TabModule.cpp +++ b/src/TabModule.cpp @@ -16,6 +16,7 @@ */ +#include "FrameWindow.h" #include "TabModule.h" #include "MDIWindow.h" #include "Global.h" @@ -34,6 +35,7 @@ #include "TabIndexes.h" #include "TabForeignKeys.h" + #ifndef COMMUNITY #include "HelperEnt.h" #include "TabQueryBuilder.h" @@ -51,6 +53,7 @@ extern PGLOBALS pGlobals; #define SIZE_24 24 #define SIZE_12 12 + //constructor sets the window handle TabModule::TabModule(HWND hwnd) { @@ -76,6 +79,15 @@ TabModule::TabModule(HWND hwnd) m_tableview = NULL; + //serailnumber = 1; + + List *m_mdilistfordropdown = new List(); + + m_serialnoqb=1; + m_serialnosd=1; + m_serialnoet=1; + + #ifdef COMMUNITY m_cribbon = NULL; #endif @@ -183,7 +195,7 @@ TabModule::Create(MDIWindow * wnd) CreateQueryEditorTab(wnd); if(!temptabeditorele->m_isfile) { - SetTabRename(temptabdetail->m_psztext.GetAsWideChar()); + SetTabRename(temptabdetail->m_psztext.GetAsWideChar(),wyFalse,wnd); } } else @@ -405,21 +417,99 @@ TabModule::TabWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, wyB // Function creating the normal QueryEditor wyBool -TabModule::CreateQueryEditorTab(MDIWindow* wnd, wyInt32 pos, wyBool setfocus) +TabModule::CreateQueryEditorTab(MDIWindow* wnd, wyInt32 pos, wyBool setfocus,wyBool fromprefencetoggle) { wyInt32 ret, count; wyBool rstatus; CTCITEM item = {0}; + wyString qtabname(""),q("Query"); + wyInt64 serial; + wyBool found = wyFalse; + wyInt32 maxsequence = 0; + + //get the max sequence for the query tab + maxsequence = GetMaxSequence(wnd); + + + serial = maxsequence + 1;//m_serialnoet; //; + + qtabname.Sprintf("%s %d", q.GetString(), serial); + + LPSTR cString = strdup(qtabname.GetString()); + //m_serialnoet++; + m_istabcreate = wyTrue; - item.m_psztext = _("Query"); - item.m_cchtextmax = strlen(_("Query")); + item.m_psztext = cString;//_("Query"); + item.m_cchtextmax = qtabname.GetLength(); //strlen(_("Query")); item.m_mask = CTBIF_IMAGE | CTBIF_TEXT | CTBIF_LPARAM | CTBIF_CMENU | CTBIF_TOOLTIP; item.m_iimage = IDI_QUERY_16; - item.m_tooltiptext = _("Query"); - - + item.m_tooltiptext = cString; // _("Query"); + + //inserting the window and list of open query tab + + MDIListForDropDrown *p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); + MDIListForDropDrown *pfound = p; + + while (p) + { + if (wnd == p->mdi) + { + found = wyTrue; + pfound = p; + break; + } + p = (MDIListForDropDrown *)p->m_next; + } + if (found) { + ListOfOpenQueryTabs *node2 = new ListOfOpenQueryTabs(); + if (fromprefencetoggle) + { + //insert at specified location + ListOfOpenQueryTabs *opentab = (ListOfOpenQueryTabs *)p->opentab->GetFirst(); + ListOfOpenQueryTabs *opentabcurr = (ListOfOpenQueryTabs *)p->opentab->GetFirst(); + wyInt32 tabcount = p->opentab->GetCount(); + wyInt32 i; + wyString stemp = ""; + for (i = 0; i <= pos; i++) + { + opentabcurr = opentab; + opentab = (ListOfOpenQueryTabs *)opentab->m_next; + + } + node2->tabname.SetAs(qtabname); + node2->seqofquerytab = maxsequence + 1; + node2->tabtype = querytab; + pfound->opentab->InsertAfter(opentabcurr, node2); + + } + else + { + node2->tabname.SetAs(qtabname); + node2->seqofquerytab = maxsequence + 1; + node2->tabtype = querytab; + pfound->opentab->Insert(node2); + } + + + } + else//its a new window, create a new mdi winodw node and insert into mdiwindow list + { + MDIListForDropDrown *node = new MDIListForDropDrown(); + ListOfOpenQueryTabs *node1 = new ListOfOpenQueryTabs(); + node->mdi = wnd; + node1->tabname.SetAs(qtabname); + node1->seqofquerytab = maxsequence+1; + node1->tabtype = querytab; + + node->opentab->Insert(node1); + pGlobals->m_mdilistfordropdown->Insert(node); + + } + + //end of code + m_pctabeditor = CreateTabEditor(wnd); m_pctabeditor->Create(wnd, NULL, wyTrue); @@ -455,6 +545,162 @@ TabModule::CreateQueryEditorTab(MDIWindow* wnd, wyInt32 pos, wyBool setfocus) return wyTrue; } +wyInt32 +TabModule::GetMaxSequence(MDIWindow* wnd) +{ + wyInt64 tabcount,i,currseq=0,nextseq=0,maxseq=0; + wyBool found = wyFalse; + ListOfOpenQueryTabs *opentab,*curr; + ListofOpenTabs *listofopentabs; + + MDIListForDropDrown *p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); + MDIListForDropDrown *pfound = p; + + if (!p) + { + return 0; + } + if (!wnd) + { + return 0; + } + while (p) + { + if (wnd == p->mdi) + { + found = wyTrue; + pfound = p; + break; + } + p = (MDIListForDropDrown *)p->m_next; + } + if (found) { + + listofopentabs = (ListofOpenTabs *)pfound->opentab->GetFirst(); + tabcount = pfound->opentab->GetCount(); + + opentab = (ListOfOpenQueryTabs *)pfound->opentab->GetFirst(); + + //tabcount = p->opentab->GetCount(); + + for (i = 0; i < tabcount; i++) + { + curr = (ListOfOpenQueryTabs *)listofopentabs; + currseq = curr->seqofquerytab; + + if (curr->tabtype==querytab && currseq>maxseq) + { + maxseq = currseq; + } + listofopentabs = (ListofOpenTabs *)listofopentabs->m_next; + } + } + return maxseq; +} + + +wyInt32 +TabModule::GetMaxSequenceQB(MDIWindow* wnd) +{ + wyInt64 tabcount, i, currseq = 0, nextseq = 0, maxseq = 0; + wyBool found = wyFalse; + ListOfOpenQueryTabs *opentab, *curr; + ListofOpenTabs *listofopentabs; + + MDIListForDropDrown *p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); + MDIListForDropDrown *pfound = p; + + if (!p) + { + return 0; + } + if (!wnd) + { + return 0; + } + while (p) + { + if (wnd == p->mdi) + { + found = wyTrue; + pfound = p; + break; + } + p = (MDIListForDropDrown *)p->m_next; + } + if (found) { + + listofopentabs = (ListofOpenTabs *)pfound->opentab->GetFirst(); + tabcount = pfound->opentab->GetCount(); + + opentab = (ListOfOpenQueryTabs *)pfound->opentab->GetFirst(); + + for (i = 0; i < tabcount; i++) + { + curr = (ListOfOpenQueryTabs *)listofopentabs; + currseq = curr->seqofquerybuilder; + + if (curr->tabtype == querybuilder && currseq>maxseq) + { + maxseq = currseq; + } + listofopentabs = (ListofOpenTabs *)listofopentabs->m_next; + } + } + return maxseq; +} + + +wyInt32 +TabModule::GetMaxSequenceSD(MDIWindow* wnd) +{ + wyInt64 tabcount, i, currseq = 0, nextseq = 0, maxseq = 0; + wyBool found = wyFalse; + ListOfOpenQueryTabs *opentab, *curr; + ListofOpenTabs *listofopentabs; + + MDIListForDropDrown *p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); + MDIListForDropDrown *pfound = p; + + if (!p) + { + return 0; + } + if (!wnd) + { + return 0; + } + while (p) + { + if (wnd == p->mdi) + { + found = wyTrue; + pfound = p; + break; + } + p = (MDIListForDropDrown *)p->m_next; + } + if (found) { + + listofopentabs = (ListofOpenTabs *)pfound->opentab->GetFirst(); + tabcount = pfound->opentab->GetCount(); + + opentab = (ListOfOpenQueryTabs *)pfound->opentab->GetFirst(); + + for (i = 0; i < tabcount; i++) + { + curr = (ListOfOpenQueryTabs *)listofopentabs; + currseq = curr->seqofschemadesigner; + + if (curr->tabtype == schemadesigner && currseq>maxseq) + { + maxseq = currseq; + } + listofopentabs = (ListofOpenTabs *)listofopentabs->m_next; + } + } + return maxseq; +} wyBool TabModule::CreateAdvEditorTab(MDIWindow *wnd, wyChar* title, wyInt32 image, HTREEITEM hitem, wyString* strhitemname) @@ -514,7 +760,10 @@ TabModule::CreateAdvEditorTab(MDIWindow *wnd, wyChar* title, wyInt32 image, HTRE Resize(); m_istabcreate = wyFalse; - + + if(objectname.GetLength()>0) + UpdateDropDownStruct(wnd, objectname.GetString()); + return wyTrue; } @@ -539,17 +788,32 @@ TabModule::CreateQueryBuilderTab(MDIWindow * wnd) wyInt32 ret, count = 0; wyBool rstatus; CTCITEM item = {0}; + wyInt64 serialqb=0,maxofqb=0; + wyBool found = wyFalse; + wyString qtabname = "",q="Query Builder"; + MDIListForDropDrown *pfound; + wyString tname; + + //Get the global list of Query drop down + MDIListForDropDrown *p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); + pfound = p; + maxofqb = GetMaxSequenceQB(wnd); + serialqb = maxofqb + 1; + + tname.Sprintf("%s %d", q.GetString(), serialqb); // get the number of tabs count = CustomTab_GetItemCount(m_hwnd); - item.m_psztext = _("Query Builder"); - item.m_cchtextmax = strlen(_("Query Builder")); + item.m_psztext = (wyChar *)tname.GetString();// _("Query Builder"); + item.m_cchtextmax = tname.GetLength(); //strlen(_("Query Builder")); item.m_mask = CTBIF_IMAGE | CTBIF_TEXT | CTBIF_LPARAM | CTBIF_CMENU | CTBIF_TOOLTIP; item.m_iimage = IDI_QUERYBUILDER_16; m_pctabqb = CreateTabQB(wnd); - item.m_tooltiptext = _("Query Builder"); - + item.m_tooltiptext = (wyChar *)tname.GetString();//_("Query Builder"); + + //to transfer the updated name into title + m_pctabqb->m_tabnameforqb.SetAs(tname.GetString()); if(!m_pctabqb) return wyFalse; @@ -582,11 +846,53 @@ TabModule::CreateQueryBuilderTab(MDIWindow * wnd) CustomTab_EnsureVisible(m_hwnd, 0, wyFalse); } + //to add query builder to the drop doen structure + if (p) + { + if (wnd) + { + while (p) + { + if (wnd == p->mdi) + { + found = wyTrue; + pfound = p; + break; + } + p = (MDIListForDropDrown *)p->m_next; + } + + if (found) { + ListOfOpenQueryTabs *node2 = new ListOfOpenQueryTabs(); + node2->tabname.SetAs(tname.GetString()); + node2->seqofquerybuilder = maxofqb + 1; + node2->tabtype = querybuilder; + pfound->opentab->Insert(node2); + //loop to get last node in the list and insert the new tab at that position + } + else//its a new window, create a new mdi winodw node and insert into mdiwindow list + { + MDIListForDropDrown *node = new MDIListForDropDrown(); + ListOfOpenQueryTabs *node1 = new ListOfOpenQueryTabs(); + node->mdi = wnd; + node1->tabname.SetAs(tname.GetString()); + node1->seqofquerybuilder = maxofqb + 1; + node1->tabtype = querybuilder; + node->opentab->Insert(node1); + pGlobals->m_mdilistfordropdown->Insert(node); + + } + + } + } + //ShowWindow(m_hwnd , TRUE); Resize(); m_istabcreate = wyFalse; + + #endif return wyTrue; } @@ -660,6 +966,22 @@ TabModule::IsValidFocusInOB(wyInt32 subtabindex) return ret; } +wyString +TabModule::SetTabSequence(wyString s,MDIWindow *wnd) +{ + //MDIWindow *p = GetActiveWin(); + wyInt32 maxseq = 0; + wyString tabname; + + maxseq=GetMaxSequenceQB(wnd); + + //m_serialnoqb; + tabname.Sprintf("%s %d", s.GetString(), maxseq+1); + //m_serialnoqb++; + return tabname.GetString(); +} + + wyBool TabModule::CreateTableTabInterface(MDIWindow *wnd, wyBool isaltertable, wyInt32 setfocustotab) { @@ -807,6 +1129,7 @@ TabModule::CreateTableTabInterface(MDIWindow *wnd, wyBool isaltertable, wyInt32 //ShowWindow(m_hwnd, TRUE); Resize(); m_istabcreate = wyFalse; + UpdateDropDownStruct(wnd, tabtitle.GetString()); return wyTrue; } @@ -814,6 +1137,47 @@ TabModule::CreateTableTabInterface(MDIWindow *wnd, wyBool isaltertable, wyInt32 return wyFalse; } +void +TabModule::UpdateDropDownStruct(MDIWindow *wnd,wyString tabname) +{ + //to initialise the structure for drop down + MDIListForDropDrown *p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); + wyBool found = wyFalse; + MDIListForDropDrown *pfound = p; + ListOfOpenQueryTabs *newnode; + + if (!p) + { + return; + } + if (!wnd) + { + return; + } + + //To search for the particular tab + while (p) + { + if (wnd == p->mdi) + { + found = wyTrue; + pfound = p; + break; + } + p = (MDIListForDropDrown *)p->m_next; + } + + if (found) { + + //search for the particular tab which is modified + + newnode = new ListOfOpenQueryTabs(); + newnode->tabname.SetAs(tabname); + pfound->opentab->Insert(newnode); + } +} + + wyBool TabModule::IsAlterTableTabOpen(wyString& tblname, wyInt32& tabindex) { @@ -855,15 +1219,27 @@ TabModule::CreateSchemaDesigner(MDIWindow * wnd) wyBool rstatus = wyFalse, retval; CTCITEM item = {0}; TabSchemaDesigner *ptabschemadesigner = NULL; + wyInt64 serialsd,maxofsd=0; + + maxofsd = GetMaxSequenceSD(wnd); + serialsd = maxofsd + 1; + + MDIListForDropDrown *p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); + wyBool found = wyFalse; + wyString qtabname = "",q= _("Schema Designer"); + MDIListForDropDrown *pfound = p; + + wyString s; + s.Sprintf("%s %d", q.GetString(), serialsd); // get the number of tabs count = CustomTab_GetItemCount(m_hwnd); - item.m_psztext = _("Schema Designer"); - item.m_cchtextmax = strlen(_("Schema Designer")); + item.m_psztext = (wyChar *)s.GetString(); //_("Schema Designer"); + item.m_cchtextmax = s.GetLength(); //strlen(_("Schema Designer")); item.m_mask = CTBIF_IMAGE | CTBIF_TEXT | CTBIF_LPARAM | CTBIF_CMENU | CTBIF_TOOLTIP; item.m_iimage = IDI_SCHEMADESIGNER_16; - item.m_tooltiptext = _("Schema Designer"); + item.m_tooltiptext = (wyChar *)s.GetString();//cString;//_("Schema Designer"); @@ -880,6 +1256,9 @@ TabModule::CreateSchemaDesigner(MDIWindow * wnd) m_istabcreate = wyTrue; + //to transfer the updated name into title + ptabschemadesigner->m_tabnamefordropdown.SetAs(s.GetString()); + ptabschemadesigner->SetParentPtr(this); item.m_lparam = (LPARAM)ptabschemadesigner; @@ -901,6 +1280,47 @@ TabModule::CreateSchemaDesigner(MDIWindow * wnd) CustomTab_EnsureVisible(m_hwnd, 0, wyFalse); } + if (p) + { + if (wnd) + { + //to add query builder to the drop doen structure + while (p) + { + if (wnd == p->mdi) + { + found = wyTrue; + pfound = p; + break; + } + p = (MDIListForDropDrown *)p->m_next; + } + + if (found) { + ListOfOpenQueryTabs *node2 = new ListOfOpenQueryTabs(); + node2->tabname.SetAs(s.GetString()); + node2->seqofschemadesigner = maxofsd + 1; + node2->tabtype = schemadesigner; + pfound->opentab->Insert(node2); + //loop to get last node in the list and insert the new tab at that position + } + else//its a new window, create a new mdi winodw node and insert into mdiwindow list + { + MDIListForDropDrown *node = new MDIListForDropDrown(); + ListOfOpenQueryTabs *node1 = new ListOfOpenQueryTabs(); + node->mdi = wnd; + node1->tabname.SetAs(s.GetString()); + node1->seqofschemadesigner = maxofsd + 1; + node1->tabtype = schemadesigner; + + node->opentab->Insert(node1); + pGlobals->m_mdilistfordropdown->Insert(node); + + } + + } + } + //ShowWindow(m_hwnd, TRUE); Resize(); m_istabcreate = wyFalse; @@ -935,12 +1355,53 @@ TabModule::CreateDatabaseSearchTab(MDIWindow * wnd, wyBool isdefault) return wyTrue; } +VOID +TabModule::InsertTabIntoDropDownStruct(MDIWindow * wnd,pretabtype tabtype) +{ + wyBool found = wyFalse; + MDIListForDropDrown *p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); + if (!p) + { + return; + } + if (!wnd) + { + return; + } + while (p) + { + if (wnd == p->mdi) + { + found = wyTrue; + //pfound = p; + break; + } + p = (MDIListForDropDrown *)p->m_next; + } + if (found) { + ListOfOpenQueryTabs *newnode = new ListOfOpenQueryTabs(); + if (tabtype = ishistory) + { + newnode->tabname.SetAs("History"); + } + else if (tabtype = isinfo) + { + newnode->tabname.SetAs("Info"); + } + else if (tabtype = isdata) + { + newnode->tabname.SetAs("Table Data"); + } + p->opentab->Insert(newnode); + } +} //History tab wyBool TabModule::CreateHistoryTab(MDIWindow * wnd, wyBool showtab, wyBool setfocus) { TabEditor* pte; + wyBool found = wyFalse; if(!m_pctabhistory) { @@ -971,9 +1432,37 @@ TabModule::CreateHistoryTab(MDIWindow * wnd, wyBool showtab, wyBool setfocus) m_pctabhistory->Resize(); m_pctabhistory->Show(setfocus); GetTabOpenPersistence(IDI_HISTORY, wyTrue, wyTrue); + if (setfocus == wyFalse) + { + MDIListForDropDrown *p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); + if (p) + { + if (wnd) + { + while (p) + { + if (wnd == p->mdi) + { + found = wyTrue; + //pfound = p; + break; + } + p = (MDIListForDropDrown *)p->m_next; + } + if (found) { + ListOfOpenQueryTabs *newhistorynode = new ListOfOpenQueryTabs(); + newhistorynode->tabname.SetAs("History"); + p->opentab->Insert(newhistorynode); + } + } + } + + } } } + + return wyTrue; } @@ -1029,7 +1518,33 @@ TabModule::CreateInfoTab(MDIWindow* wnd, wyBool setfocus) CustomTab_SetCurSel(m_hwnd, count); CustomTab_EnsureVisible(m_hwnd, count); } - + if (setfocus == wyFalse) + { + wyBool found = wyFalse; + MDIListForDropDrown *p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); + if (p) + { + if (wnd) + { + while (p) + { + if (wnd == p->mdi) + { + found = wyTrue; + //pfound = p; + break; + } + p = (MDIListForDropDrown *)p->m_next; + } + if (found) { + ListOfOpenQueryTabs *newhistorynode = new ListOfOpenQueryTabs(); + newhistorynode->tabname.SetAs("Info"); + p->opentab->Insert(newhistorynode); + } + } + } + + } return wyTrue; } @@ -1155,11 +1670,56 @@ TabModule::CreateTabDataTab(MDIWindow * wnd, wyBool isnewtab, wyBool setfocus) { GetTabOpenPersistence(IDI_TABLE, wyTrue, wyTrue); } + + //add the table data tab to drop down + AddTabletabIntoDropDown(wnd, temptab, setfocus); } - return wyTrue; } +VOID +TabModule::AddTabletabIntoDropDown(MDIWindow *wnd, TabTableData* temptab, wyBool setfocus) +{ + wyBool found = wyFalse; + MDIListForDropDrown *p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); + if (!p) + { + return; + } + else if (!wnd) + { + return; + } + + while (p) + { + if (wnd == p->mdi) + { + found = wyTrue; + //pfound = p; + break; + } + p = (MDIListForDropDrown *)p->m_next; + } + if (found) { + ListOfOpenQueryTabs *newnode = new ListOfOpenQueryTabs(); + //newnode->tabname.SetAs("Table Data"); + if (!temptab->m_tabledata) + { + if (setfocus == wyFalse) { + newnode->tabname.SetAs("Table Data"); + p->opentab->Insert(newnode); + } + } + else + { + newnode->tabname.SetAs(temptab->m_tabledata->m_table.GetString()); + p->opentab->Insert(newnode); + } + + } +} + /* Resize for Tab If this fun calls not during the Create any Tab, the m_istabcreate is wyFalse and handling the flickering. While Creating tab, the Create tab function itself handles the WM_SETREDRAW @@ -1754,7 +2314,8 @@ TabModule::SetTabName(wyWChar *filename, wyBool isshowext, wyBool isedited) wyWChar fname[MAX_PATH] = {0}, ext[MAX_PATH] = {0}; wyString file, extn, tempfilename; wyString path; - + wyString newname; + tabimage = GetActiveTabImage(); _wsplitpath(filename, NULL, NULL, fname, ext); @@ -1798,18 +2359,141 @@ TabModule::SetTabName(wyWChar *filename, wyBool isshowext, wyBool isedited) item.m_iimage = tabimage; item.m_tooltiptext = (wyChar*)path.GetString(); + newname = file.GetString(); VERIFY(CustomTab_SetItem(m_hwnd, itemindex, &item)); + + UpdateNameinStruc(itemindex, newname.GetString()); return; } +VOID +TabModule::UpdateNameinStruc(wyInt32 itemindex, wyString newname) +{ + MDIListForDropDrown *pfound = NULL, *p; + wyBool foundmodifiedtab = wyFalse, found = wyFalse; + wyInt32 tabcount, tabindexindropdown,tabnumber,tabn; + wyString s2,sname; + + MDIWindow *wnd = GetActiveWin(); + + p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); + if (wnd) + { + //Update the tabname in query drop down + while (p) + { + if (wnd == p->mdi) + { + found = wyTrue; + pfound = p; + break; + } + p = (MDIListForDropDrown *)p->m_next; + } + if (found) { + if (pfound) { + + //get the tab which is modifed + tabcount = p->opentab->GetCount(); + + ListOfOpenQueryTabs *node2 = new ListOfOpenQueryTabs(); + node2 = (ListOfOpenQueryTabs *)p->opentab->GetFirst(); + for (tabindexindropdown = 0; tabindexindropdown < tabcount; tabindexindropdown++) + { + if (tabindexindropdown == itemindex)//as indexs for tabs starts from 0 + { + foundmodifiedtab = wyTrue; + break; + } + node2 = (ListOfOpenQueryTabs *)node2->m_next; + } + if (foundmodifiedtab) + { + + + if (node2->tabtype == querytab) + { + node2->seqofquerytab = 0; + } + + if (node2->tabtype == querybuilder) + { + s2.SetAs(newname.GetString()); + s2.SetAs(s2.Substr(0, 13)); + s2.LTrim(); + s2.RTrim(); + + tabn = s2.Compare("Query Builder"); + if (tabn>0) { + node2->seqofquerybuilder = 0; + } + if (tabn == 0) + { + + sname.SetAs(newname.Substr(13, newname.GetLength())); + sname.LTrim(); + sname.RTrim(); + tabnumber = sname.GetAsInt32(); + if (tabnumber != node2->seqofquerybuilder) + { + node2->seqofquerybuilder = tabnumber; + } + + } + + } + else if (node2->tabtype == schemadesigner) + { + s2.SetAs(newname.GetString()); + s2.SetAs(s2.Substr(0, 15)); + s2.LTrim(); + s2.RTrim(); + + tabn = s2.Compare("Schema Designer"); + if (tabn>0) { + node2->seqofschemadesigner = 0; + } + if (tabn == 0) + { + + sname.SetAs(newname.Substr(15, newname.GetLength())); + sname.LTrim(); + sname.RTrim(); + tabnumber = sname.GetAsInt32(); + if (tabnumber != node2->seqofschemadesigner) + { + node2->seqofschemadesigner = tabnumber; + } + + } + + } + else if (node2->tabtype == datasearch) + { + node2->seqofdatasearch = 0; + } + wnd->m_isfromsaveas = wyFalse; + + node2->tabname.SetAs(newname.GetString()); + } + } + } + } +} //Setting tab name void -TabModule::SetTabRename(wyWChar *name, wyBool isedited) +TabModule::SetTabRename(wyWChar *name, wyBool isedited,MDIWindow *wnd, wyBool isfromrenamedlg) { CTCITEM item; - wyInt32 itemindex, tabimage; + wyInt32 itemindex, tabimage,tabindexindropdown,tabcount=0, tabn,tabnumber; wyString newname; + wyBool found = wyFalse,foundmodifiedtab=wyFalse; + wyString qtabname = "",newname1="",tabname1="", sname="",s2=""; + MDIListForDropDrown *pfound=NULL ,*p; + +// MDIWindow *wnd = GetActiveWin(); + p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); tabimage = GetActiveTabImage(); newname.SetAs(name); @@ -1819,7 +2503,6 @@ TabModule::SetTabRename(wyWChar *name, wyBool isedited) } - itemindex = CustomTab_GetCurSel(m_hwnd); item.m_mask = CTBIF_TEXT | CTBIF_IMAGE | CTBIF_CMENU | CTBIF_TOOLTIP; @@ -1830,6 +2513,83 @@ TabModule::SetTabRename(wyWChar *name, wyBool isedited) //m_pctabeditor->m_tabtitle.SetAs(item.m_psztext); VERIFY(CustomTab_SetItem(m_hwnd, itemindex, &item)); + + //Update the tabname in query drop down + while (p) + { + if (wnd == p->mdi) + { + found = wyTrue; + pfound = p; + break; + } + p = (MDIListForDropDrown *)p->m_next; + } + if (found) { + if (pfound) { + + //get the tab which is modifed + tabcount = p->opentab->GetCount(); + + ListOfOpenQueryTabs *node2;// = new ListOfOpenQueryTabs(); + node2 = (ListOfOpenQueryTabs *)p->opentab->GetFirst(); + for (tabindexindropdown = 0; tabindexindropdown < tabcount; tabindexindropdown++) + { + if (tabindexindropdown == itemindex)//as indexs for tabs starts from 0 + { + foundmodifiedtab = wyTrue; + break; + } + node2 = (ListOfOpenQueryTabs *)node2->m_next; + } + if (foundmodifiedtab) + { + if (isfromrenamedlg || node2->tabname.CompareI(newname.GetString())) + { + if (node2->tabtype == querytab) + { + //Fix to update sequence number from old and new session + s2.SetAs(newname.GetString()); + s2.SetAs(s2.Substr(0, 5)); + s2.LTrim(); + s2.RTrim(); + + tabn = s2.Compare("Query"); + if (tabn > 0) { + node2->seqofquerytab = 0; + } + if (tabn == 0) + { + if (newname.GetLength()>5)//tabn=0 : tabname is restored name "Query" and if length>5 : sequence from 13.1.2 session with sequence i.e. restore from old session + { + sname.SetAs(newname.Substr(5, newname.GetLength())); + sname.LTrim(); + sname.RTrim(); + tabnumber = sname.GetAsInt32(); + if (tabnumber != node2->seqofquerytab) + { + node2->seqofquerytab = tabnumber; + } + } + else + { + node2->seqofquerytab = 0;// length = 5 : no sequence to append i.e.restore from old session + } + + } + } + + } + /*if (isfromrenamedlg || node2->tabname.CompareI(newname.GetString())) + { + node2->seqofquerytab = 0; + }*/ + node2->tabname.SetAs(newname.GetString()); + } + + } + } + return; } diff --git a/src/TableTabInterface.cpp b/src/TableTabInterface.cpp index 9fca70e..47cc1a4 100644 --- a/src/TableTabInterface.cpp +++ b/src/TableTabInterface.cpp @@ -26,6 +26,7 @@ #include "TabAdvancedProperties.h" #include "TabPreview.h" #include "DoubleBuffer.h" +#include "TabCheck.h" #define SIZE_24 24 #define SIZE_12 12 @@ -150,6 +151,7 @@ TableTabInterface::Create() HINSTANCE hinst = pGlobals->m_entinst?pGlobals->m_entinst:pGlobals->m_hinstance; m_ismysql41 = m_mdiwnd->m_ismysql41; + //..Setting dbname and origtablename from the object browser if(!m_open_in_dialog) @@ -216,7 +218,9 @@ TableTabInterface::Create() CustomGrid_SetCurSelection(m_ptabintmgmt->m_tabfields->m_hgridfields, 0, 0); CustomGrid_SetCurSelection(m_ptabintmgmt->m_tabindexes->m_hgridindexes, 0, 1); + CustomGrid_SetCurSelection(m_ptabintmgmt->m_tabcheck->m_hgridtblcheckconst, 0, 1); CustomGrid_SetCurSelection(m_ptabintmgmt->m_tabfk->m_hgridfk, 0, 1); + if(m_setfocustotab == -1) { @@ -267,7 +271,7 @@ TableTabInterface::OnWmNotify(HWND hwnd, WPARAM wparam, LPARAM lparam) case CTCN_SELCHANGING: { lpnmctc = (LPNMCTC)lparam; - if(lpnmctc->count == 2 && !m_isfksupported) + if(lpnmctc->count == 2 && !m_isfksupported && m_isaltertable) { MessageBox(m_hwnd, _(L"The selected table does not support foreign keys.\nTable engine must be InnoDB, PBXT, SolidDB or ndbcluster (if ndbcluster engine version is greater than or equal to 7.3)."), pGlobals->m_appname.GetAsWideChar(), MB_OK | MB_ICONINFORMATION); return 0; @@ -359,6 +363,7 @@ TableTabInterface::SaveTable(wyBool &queryexecuted) //..Apply\Cancel GridChanges CustomGrid_ApplyChanges(m_ptabintmgmt->m_tabfields->m_hgridfields, wyTrue); m_ptabintmgmt->m_tabindexes->ApplyCancelGridChanges(); + m_ptabintmgmt->m_tabcheck->ApplyCancelGridChanges(); CustomGrid_ApplyChanges(m_ptabintmgmt->m_tabfk->m_hgridfk, wyTrue); //=> Validations @@ -435,6 +440,7 @@ TableTabInterface::SaveTable(wyBool &queryexecuted) ReInitializeBasicOptions(); m_ptabintmgmt->m_tabfields->ReInitializeGrid(); m_ptabintmgmt->m_tabindexes->ReInitializeGrid(); + m_ptabintmgmt->m_tabcheck->ReInitializeGrid(); m_ptabintmgmt->m_tabfk->ReInitializeGrid(listunsavedfks); m_ptabintmgmt->m_tabadvprop->ReinitializeValues(); if(m_ptabintmgmt->GetActiveTabImage() == IDI_TABPREVIEW) @@ -589,6 +595,10 @@ TableTabInterface::SetInitFocus() { PostMessage(m_hwnd, UM_SETFOCUS, (WPARAM)m_ptabintmgmt->m_tabpreview->m_hwndpreview, 0); } + else if (m_ptabintmgmt->GetActiveTabImage() == IDI_CHECKCONSTRAINT) + { + PostMessage(m_hwnd, UM_SETFOCUS, (WPARAM)m_ptabintmgmt->m_tabcheck->m_hgridtblcheckconst, 0); + } } wyBool @@ -641,9 +651,69 @@ TableTabInterface::SetTabItem(HWND hwnd, wyInt32 tabindex, wyString& text, wyUIn CustomTab_SetItem(m_hwndparent, ncurselindex, &ctci); UpdateWindow(m_hwndparent); + //update here name in dropdown + UpdateDropdownStruct(ncurselindex, objectname.GetString()); + return wyFalse; } + +void +TableTabInterface::UpdateDropdownStruct(wyInt32 index,wyString newname) +{ + MDIListForDropDrown *p, *pfound; + wyInt32 tabindexindropdown, tabcount=0; + MDIWindow *wnd; + wyBool found = wyFalse, foundmodifiedtab = wyFalse; + + wnd = GetActiveWin(); + + p = (MDIListForDropDrown *)pGlobals->m_mdilistfordropdown->GetFirst(); + + if (!p) + { + return; + } + if (!wnd) + { + return; + } + while (p) + { + if (wnd == p->mdi) + { + found = wyTrue; + pfound = p; + break; + } + p = (MDIListForDropDrown *)p->m_next; + } + if (found) { + if (pfound) { + + //get the tab which is modifed + tabcount = p->opentab->GetCount(); + + ListOfOpenQueryTabs *node2 = new ListOfOpenQueryTabs(); + node2 = (ListOfOpenQueryTabs *)p->opentab->GetFirst(); + for (tabindexindropdown = 0; tabindexindropdown < tabcount; tabindexindropdown++) + { + if (tabindexindropdown == index)//as indexs for tabs starts from 0 + { + foundmodifiedtab = wyTrue; + break; + } + node2 = (ListOfOpenQueryTabs *)node2->m_next; + } + if (foundmodifiedtab) + { + node2->tabname.SetAs(newname.GetString()); + + } + } + } +} + wyBool TableTabInterface::OnWmCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) { @@ -1003,6 +1073,7 @@ TableTabInterface::OnClickSave(wyBool onclosetab, wyBool showsuccessmsg) return wyTrue; } + void TableTabInterface::CancelChanges() { @@ -1017,7 +1088,10 @@ TableTabInterface::CancelChanges() /// setting m_isfksupported variable wyBool error = wyTrue; - m_isfksupported = IsTableInnoDB(error); + if (m_isaltertable) + m_isfksupported = IsTableInnoDB(error); + else + m_isfksupported = wyTrue; // bug: click on revert ignores the details entered in Foreign key tab for create table if(m_ismysql41) { @@ -1171,6 +1245,9 @@ TableTabInterface::GenerateQuery(wyString &query, wyBool showmsg) tempstr.RTrim(); } + //Add method for table level check constraint + retval = (wyBool)(m_ptabintmgmt->m_tabcheck->GenerateQuery(tempstr) && retval); + //..In Create table, remove last comma, Add bracket.. if(!m_isaltertable) { @@ -1232,9 +1309,8 @@ TableTabInterface::GenerateQuery(wyString &query, wyBool showmsg) if(tempstr.GetLength() && tempstr.Compare(strnoquery) != 0) { - tempstr.Add("\r\n"); - tempstr.Add(")"); - + tempstr.Add("\r\n"); + tempstr.Add(")"); if(otherprop.GetLength()) tempstr.AddSprintf("%s", otherprop.GetString()); tempstr.RTrim(); @@ -1322,6 +1398,7 @@ TableTabInterface::OnClickCancelChanges() m_ptabintmgmt->m_tabfk->CancelChanges(); m_ptabintmgmt->m_tabadvprop->CancelChanges(m_isaltertable); m_ptabintmgmt->m_tabpreview->CancelChanges(); + m_ptabintmgmt->m_tabcheck->CancelChanges(m_isaltertable); //if(m_isaltertable) { @@ -1331,6 +1408,7 @@ TableTabInterface::OnClickCancelChanges() CustomGrid_SetSelAllState(m_ptabintmgmt->m_tabfields->m_hgridfields, BST_UNCHECKED); CustomGrid_SetSelAllState(m_ptabintmgmt->m_tabindexes->m_hgridindexes, BST_UNCHECKED); CustomGrid_SetSelAllState(m_ptabintmgmt->m_tabfk->m_hgridfk, BST_UNCHECKED); + CustomGrid_SetSelAllState(m_ptabintmgmt->m_tabcheck->m_hgridtblcheckconst, BST_UNCHECKED); } @@ -2079,6 +2157,11 @@ TableTabInterface::OnTabSelChange() case IDI_TABPREVIEW: hwndfocus = m_ptabintmgmt->m_tabpreview->m_hwndpreview; break; + + case IDI_CHECKCONSTRAINT: + hwndfocus = m_ptabintmgmt->m_tabcheck->m_hgridtblcheckconst; + break; + } SetFocus(hwndfocus); } @@ -2405,8 +2488,10 @@ TableTabInterface::ReInitializeAllValues() m_ptabintmgmt->m_tabfields->ReInitializeGrid(); m_ptabintmgmt->m_tabindexes->ReInitializeGrid(); + m_ptabintmgmt->m_tabcheck->ReInitializeGrid(); m_ptabintmgmt->m_tabfk->ReInitializeGrid(); m_ptabintmgmt->m_tabadvprop->ReinitializeValues(); + return wyTrue; } @@ -2689,7 +2774,6 @@ TableTabInterface:: GetMyResTableStatus() ShowMySQLError(m_hwnd, m_mdiwnd->m_tunnel, &m_mdiwnd->m_mysql, query.GetString()); return wyFalse; } - return wyTrue; } void diff --git a/src/TableTabInterfaceTabMgmt.cpp b/src/TableTabInterfaceTabMgmt.cpp index 10815e8..bbea2d2 100644 --- a/src/TableTabInterfaceTabMgmt.cpp +++ b/src/TableTabInterfaceTabMgmt.cpp @@ -15,9 +15,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA */ - +#include "TabCheck.h" #include "TableTabInterface.h" -#include "TableTabInterfaceTabMgmt.h" #include "TabFields.h" #include "TabAdvancedProperties.h" #include "TabIndexes.h" @@ -25,6 +24,8 @@ #include "TabPreview.h" #include "DoubleBuffer.h" +#include "TableTabInterfaceTabMgmt.h" + # define MAX_HEIGHT 335 TableTabInterfaceTabMgmt::TableTabInterfaceTabMgmt(HWND hwndparent, TableTabInterface* ptabint) @@ -38,6 +39,7 @@ TableTabInterfaceTabMgmt::TableTabInterfaceTabMgmt(HWND hwndparent, TableTabInte m_hwndtool = NULL; m_tabindexes = NULL; m_tabfk = NULL; + m_tabcheck = NULL; m_tabpreview = NULL; m_tabadvprop = NULL; m_tabfields = NULL; @@ -72,6 +74,12 @@ TableTabInterfaceTabMgmt::~TableTabInterfaceTabMgmt() delete m_tabpreview; m_tabpreview = NULL; } + if (m_tabcheck) + { + delete m_tabcheck; + m_tabcheck = NULL; + } + } @@ -105,6 +113,10 @@ TableTabInterfaceTabMgmt::OnTabSelChanging() case IDI_TABPREVIEW: //..Preview Tab break; + + case IDI_CHECKCONSTRAINT: //..Check constraint Tab + m_tabcheck->OnTabSelChanging(); + break; } return 1; @@ -148,6 +160,10 @@ TableTabInterfaceTabMgmt::OnTabSelChange(wyBool visible) case IDI_MANREL_16: //ForeignKeys Tab m_tabfk->OnTabSelChange(); break; + + case IDI_CHECKCONSTRAINT: //Check constraint Tab + m_tabcheck->OnTabSelChange(); + break; } //SendMessage(m_hwnd, WM_SETREDRAW, TRUE, NULL); @@ -175,6 +191,9 @@ TableTabInterfaceTabMgmt::Create() if(!CreateForeignKeysTab()) return wyFalse; + if (!CreateCheckConstraintTab()) + return wyFalse; + if(!CreateAdvancedPropertiesTab()) return wyFalse; @@ -475,7 +494,10 @@ TableTabInterfaceTabMgmt::OnToolTipInfo(LPNMTTDISPINFO lpnmtt) { m_tooltipstr.SetAs(_(L"Insert new FK (Alt+Ins)")); } - + else if (image == IDI_CHECKCONSTRAINT) + { + m_tooltipstr.SetAs(_(L"Insert new check constraint")); + } break; case IDI_DELETEROW: @@ -491,7 +513,10 @@ TableTabInterfaceTabMgmt::OnToolTipInfo(LPNMTTDISPINFO lpnmtt) { m_tooltipstr.SetAs(_(L"Delete selected FK(s) (Alt+Del)")); } - + else if (image == IDI_CHECKCONSTRAINT) + { + m_tooltipstr.SetAs(_(L"Delete selected check constraint")); + } break; case IDI_MOVEUP: @@ -639,6 +664,9 @@ TableTabInterfaceTabMgmt::OnClickAddRow() case IDI_MANREL_16: m_tabfk->ProcessInsert(); break; + case IDI_CHECKCONSTRAINT: + m_tabcheck->ProcessInsert(); + break; default: return; } @@ -659,6 +687,9 @@ TableTabInterfaceTabMgmt::OnClickDeleteRows() case IDI_MANREL_16: m_tabfk->ProcessDelete(); break; + case IDI_CHECKCONSTRAINT: + m_tabcheck->ProcessDelete(); + break; default: return; } @@ -770,7 +801,10 @@ TableTabInterfaceTabMgmt::Resize() if(m_tabadvprop) m_tabadvprop->Resize(); if(m_tabpreview) - m_tabpreview->Resize();/**/ + m_tabpreview->Resize(); + if (m_tabcheck) + m_tabcheck->Resize(); + /**/ } wyBool @@ -871,13 +905,32 @@ TableTabInterfaceTabMgmt::CreateForeignKeysTab() return retval; } +wyBool +TableTabInterfaceTabMgmt::CreateCheckConstraintTab() +{ + wyBool retval = wyTrue; + wyString tabtitle; + + tabtitle.SetAs(_("&4 Check Constraint")); + + m_tabcheck = new TabCheck(m_hcommonwnd, this); + + /// Creating check constraint-tab + m_tabcheck->Create(); + + /// Inserting check constraint-tab into tab-management + InsertTab(m_hwnd, CustomTab_GetItemCount(m_hwnd), IDI_CHECKCONSTRAINT, tabtitle, (LPARAM)m_tabcheck); + + return retval; +} + wyBool TableTabInterfaceTabMgmt::CreatePreviewTab() { wyBool retval = wyTrue; wyString tabtitle; - tabtitle.SetAs(_("&5 SQL Preview")); + tabtitle.SetAs(_("&6 SQL Preview")); m_tabpreview = new TabPreview(m_hcommonwnd, this); @@ -896,7 +949,7 @@ TableTabInterfaceTabMgmt::CreateAdvancedPropertiesTab() wyBool retval = wyTrue; wyString tabtitle; - tabtitle.SetAs(_("&4 Advanced")); + tabtitle.SetAs(_("&5 Advanced")); m_tabadvprop = new TabAdvancedProperties(m_hcommonwnd, this); diff --git a/src/UserManager.cpp b/src/UserManager.cpp index fab6396..3afaee3 100644 --- a/src/UserManager.cpp +++ b/src/UserManager.cpp @@ -741,11 +741,20 @@ UserManager::SavePassword() return wyFalse; } - //prepare and execute the query - query.Sprintf("GRANT USAGE ON *.* TO '%s'@'%s' IDENTIFIED BY '%s'", - EscapeMySQLString(m_username.GetString(), tempuser).GetString(), - EscapeMySQLString(m_host.GetString(), temphost).GetString(), - EscapeMySQLString(password.GetString(), temppassword).GetString()); + if (IsMySQL80011(m_hmdi->m_tunnel, &m_hmdi->m_mysql) == wyTrue) + { + query.Sprintf("ALTER USER '%s'@'%s' IDENTIFIED BY '%s'", + EscapeMySQLString(m_username.GetString(), tempuser).GetString(), + EscapeMySQLString(m_host.GetString(), temphost).GetString(), + EscapeMySQLString(password.GetString(), temppassword).GetString()); + } + else + { + query.Sprintf("GRANT USAGE ON *.* TO '%s'@'%s' IDENTIFIED BY '%s'", + EscapeMySQLString(m_username.GetString(), tempuser).GetString(), + EscapeMySQLString(m_host.GetString(), temphost).GetString(), + EscapeMySQLString(password.GetString(), temppassword).GetString()); + } if(ExecuteUMQuery(query) == wyFalse) { diff --git a/src/WinMain.cpp b/src/WinMain.cpp index 4aea828..13b1126 100644 --- a/src/WinMain.cpp +++ b/src/WinMain.cpp @@ -259,7 +259,7 @@ wyInt32 WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, ImageList_Destroy(pGlobals->m_hiconlist); VERIFY(FreeLibrary(hrich)); - + #ifdef BLACKBOX VERIFY(FreeLibrary(hblackbox)); #endif