Пример #1
0
void CSetBugTraqAdv::OnBnClickedOptions()
{
    m_provider_clsid = GUID_NULL;

    int index = m_cProviderCombo.GetCurSel();
    if (index != CB_ERR)
    {
        CBugTraqProvider *provider = (CBugTraqProvider *)m_cProviderCombo.GetItemDataPtr(index);
        m_provider_clsid = provider->clsid;
    }

    CComPtr<IBugTraqProvider2> pProvider;
    HRESULT hr = pProvider.CoCreateInstance(m_provider_clsid);

    if (SUCCEEDED(hr))
    {
        ATL::CComBSTR temp;
        CString p;
        GetDlgItemText(IDC_BUGTRAQPARAMETERS, p);
        ATL::CComBSTR params;
        params.Attach(p.AllocSysString());
        hr = pProvider->ShowOptionsDialog(GetSafeHwnd(), params, &temp);
        if (SUCCEEDED(hr))
        {
            SetDlgItemText(IDC_BUGTRAQPARAMETERS, temp == 0 ? "" : temp);
        }
        else
        {
            COMError ce(hr);
            CString sErr;
            sErr.FormatMessage(IDS_ERR_FAILEDISSUETRACKERCOM, ce.GetSource().c_str(), ce.GetMessageAndDescription().c_str());
            ::MessageBox(m_hWnd, sErr, L"TortoiseSVN", MB_ICONERROR);
        }
    }
}
Пример #2
0
void CSetBugTraqAdv::OnOK()
{
    UpdateData();

    m_provider_clsid = GUID_NULL;

    int index = m_cProviderCombo.GetCurSel();
    if (index != CB_ERR)
    {
        CBugTraqProvider *provider = (CBugTraqProvider *)m_cProviderCombo.GetItemDataPtr(index);
        m_provider_clsid = provider->clsid;
    }

    CComPtr<IBugTraqProvider> pProvider;
    HRESULT hr = pProvider.CoCreateInstance(m_provider_clsid);

    if (FAILED(hr))
    {
        m_tooltips.ShowBalloon(IDC_BUGTRAQPROVIDERCOMBO, IDS_ERR_MISSING_PROVIDER, IDS_ERR_ERROR, TTI_ERROR);
        return;
    }

    VARIANT_BOOL valid;
    ATL::CComBSTR parameters;
    parameters.Attach(m_sParameters.AllocSysString());
    hr = pProvider->ValidateParameters(GetSafeHwnd(), parameters, &valid);
    if (FAILED(hr))
    {
        ShowEditBalloon(IDC_BUGTRAQPARAMETERS, IDS_ERR_PROVIDER_VALIDATE_FAILED, IDS_ERR_ERROR, TTI_ERROR);
        return;
    }

    if (valid == VARIANT_FALSE)
        return; // It's assumed that the provider will have done this.

    if (m_pAssociations)
    {
        CBugTraqAssociation bugtraq_association;
        if (m_pAssociations->FindProvider(CTSVNPathList(CTSVNPath(m_sPath)), &bugtraq_association))
        {
            if (bugtraq_association.GetPath().IsEquivalentToWithoutCase(CTSVNPath(m_sPath)))
            {
                ShowEditBalloon(IDC_BUGTRAQPATH, IDS_ERR_PROVIDER_PATH_ALREADY_CONFIGURED, IDS_ERR_ERROR, TTI_ERROR);
                return;
            }
        }
    }

    CResizableStandAloneDialog::OnOK();
}
Пример #3
0
void CCopyDlg::OnBnClickedBugtraqbutton()
{
    m_tooltips.Pop();   // hide the tooltips
    CString sMsg = m_cLogMessage.GetText();

    if (m_BugTraqProvider == NULL)
        return;

    ATL::CComBSTR parameters;
    parameters.Attach(m_bugtraq_association.GetParameters().AllocSysString());
    ATL::CComBSTR commonRoot;
    commonRoot.Attach(m_path.GetWinPathString().AllocSysString());
    CBstrSafeVector pathList(1);
    pathList.PutElement(0, m_path.GetSVNPathString());

    ATL::CComBSTR originalMessage;
    originalMessage.Attach(sMsg.AllocSysString());
    ATL::CComBSTR temp;
    m_revProps.clear();

    // first try the IBugTraqProvider2 interface
    CComPtr<IBugTraqProvider2> pProvider2 = NULL;
    HRESULT hr = m_BugTraqProvider.QueryInterface(&pProvider2);
    if (SUCCEEDED(hr))
    {
        ATL::CComBSTR repositoryRoot;
        repositoryRoot.Attach(m_wcURL.AllocSysString());
        ATL::CComBSTR bugIDOut;
        GetDlgItemText(IDC_BUGID, m_sBugID);
        ATL::CComBSTR bugID;
        bugID.Attach(m_sBugID.AllocSysString());
        CBstrSafeVector revPropNames;
        CBstrSafeVector revPropValues;
        if (FAILED(hr = pProvider2->GetCommitMessage2(GetSafeHwnd(), parameters, repositoryRoot, commonRoot, pathList, originalMessage, bugID, &bugIDOut, &revPropNames, &revPropValues, &temp)))
        {
            OnComError(hr);
        }
        else
        {
            if (bugIDOut)
            {
                m_sBugID = bugIDOut;
                SetDlgItemText(IDC_BUGID, m_sBugID);
            }
            m_cLogMessage.SetText((LPCTSTR)temp);
            BSTR HUGEP *pbRevNames;
            BSTR HUGEP *pbRevValues;

            HRESULT hr1 = SafeArrayAccessData(revPropNames, (void HUGEP**)&pbRevNames);
            if (SUCCEEDED(hr1))
            {
                HRESULT hr2 = SafeArrayAccessData(revPropValues, (void HUGEP**)&pbRevValues);
                if (SUCCEEDED(hr2))
                {
                    if (revPropNames->rgsabound->cElements == revPropValues->rgsabound->cElements)
                    {
                        for (ULONG i = 0; i < revPropNames->rgsabound->cElements; i++)
                        {
                            m_revProps[pbRevNames[i]] = pbRevValues[i];
                        }
                    }
                    SafeArrayUnaccessData(revPropValues);
                }
                SafeArrayUnaccessData(revPropNames);
            }
        }
    }
    else
    {
        // if IBugTraqProvider2 failed, try IBugTraqProvider
        CComPtr<IBugTraqProvider> pProvider = NULL;
        hr = m_BugTraqProvider.QueryInterface(&pProvider);
        if (FAILED(hr))
        {
            OnComError(hr);
            return;
        }

        if (FAILED(hr = pProvider->GetCommitMessage(GetSafeHwnd(), parameters, commonRoot, pathList, originalMessage, &temp)))
        {
            OnComError(hr);
        }
        else
            m_cLogMessage.SetText((LPCTSTR)temp);
    }
    m_sLogMessage = m_cLogMessage.GetText();
    if (!m_ProjectProperties.sMessage.IsEmpty())
    {
        CString sBugID = m_ProjectProperties.FindBugID(m_sLogMessage);
        if (!sBugID.IsEmpty())
        {
            SetDlgItemText(IDC_BUGID, sBugID);
        }
    }

    m_cLogMessage.SetFocus();
}
Пример #4
0
void CCopyDlg::OnOK()
{
    if (::IsWindow(m_pLogDlg->GetSafeHwnd())&&(m_pLogDlg->IsWindowVisible()))
    {
        m_pLogDlg->SendMessage(WM_CLOSE);
        return;
    }
    m_bCancelled = true;
    // check if the status thread has already finished
    if ((m_pThread)&&(m_bThreadRunning))
    {
        WaitForSingleObject(m_pThread->m_hThread, 1000);
        if (m_bThreadRunning)
        {
            // we gave the thread a chance to quit. Since the thread didn't
            // listen to us we have to kill it.
            TerminateThread(m_pThread->m_hThread, (DWORD)-1);
            InterlockedExchange(&m_bThreadRunning, FALSE);
        }
    }

    CString id;
    GetDlgItemText(IDC_BUGID, id);
    CString sRevText;
    GetDlgItemText(IDC_COPYREVTEXT, sRevText);
    if (!m_ProjectProperties.CheckBugID(id))
    {
        ShowEditBalloon(IDC_BUGID, IDS_COMMITDLG_ONLYNUMBERS, IDS_ERR_ERROR, TTI_ERROR);
        return;
    }
    m_sLogMessage = m_cLogMessage.GetText();
    if ((m_ProjectProperties.bWarnIfNoIssue) && (id.IsEmpty() && !m_ProjectProperties.HasBugID(m_sLogMessage)))
    {
        CTaskDialog taskdlg(CString(MAKEINTRESOURCE(IDS_COMMITDLG_WARNNOISSUE_TASK1)),
                            CString(MAKEINTRESOURCE(IDS_COMMITDLG_WARNNOISSUE_TASK2)),
                            L"TortoiseSVN",
                            0,
                            TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW | TDF_SIZE_TO_CONTENT);
        taskdlg.AddCommandControl(1, CString(MAKEINTRESOURCE(IDS_COMMITDLG_WARNNOISSUE_TASK3)));
        taskdlg.AddCommandControl(2, CString(MAKEINTRESOURCE(IDS_COMMITDLG_WARNNOISSUE_TASK4)));
        taskdlg.SetCommonButtons(TDCBF_CANCEL_BUTTON);
        taskdlg.SetDefaultCommandControl(2);
        taskdlg.SetMainIcon(TD_WARNING_ICON);
        if (taskdlg.DoModal(m_hWnd) != 1)
            return;
    }
    UpdateData(TRUE);

    if (GetCheckedRadioButton(IDC_COPYHEAD, IDC_COPYREV) == IDC_COPYHEAD)
        m_CopyRev = SVNRev(SVNRev::REV_HEAD);
    else if (GetCheckedRadioButton(IDC_COPYHEAD, IDC_COPYREV) == IDC_COPYWC)
        m_CopyRev = SVNRev(SVNRev::REV_WC);
    else
        m_CopyRev = SVNRev(sRevText);

    if (!m_CopyRev.IsValid())
    {
        ShowEditBalloon(IDC_COPYREVTEXT, IDS_ERR_INVALIDREV, IDS_ERR_ERROR, TTI_ERROR);
        return;
    }

    CString combourl = m_URLCombo.GetWindowString();
    if (combourl.IsEmpty())
        combourl = m_URLCombo.GetString();

    if ((m_wcURL.CompareNoCase(combourl)==0)&&(m_CopyRev.IsHead()))
    {
        CString temp;
        temp.FormatMessage(IDS_ERR_COPYITSELF, (LPCTSTR)m_wcURL, (LPCTSTR)m_URLCombo.GetString());
        ::MessageBox(this->m_hWnd, temp, L"TortoiseSVN", MB_ICONERROR);
        return;
    }

    m_URLCombo.SaveHistory();
    m_URL = CPathUtils::CombineUrls(m_repoRoot, m_URLCombo.GetString());
    if (!CTSVNPath(m_URL).IsValidOnWindows())
    {
        CString sInfo;
        sInfo.Format(IDS_WARN_NOVALIDPATH_TASK1, (LPCTSTR)m_URL);
        CTaskDialog taskdlg(sInfo,
                            CString(MAKEINTRESOURCE(IDS_WARN_NOVALIDPATH_TASK2)),
                            L"TortoiseSVN",
                            0,
                            TDF_ENABLE_HYPERLINKS | TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW | TDF_SIZE_TO_CONTENT);
        taskdlg.AddCommandControl(1, CString(MAKEINTRESOURCE(IDS_WARN_NOVALIDPATH_TASK3)));
        taskdlg.AddCommandControl(2, CString(MAKEINTRESOURCE(IDS_WARN_NOVALIDPATH_TASK4)));
        taskdlg.SetCommonButtons(TDCBF_CANCEL_BUTTON);
        taskdlg.SetExpansionArea(CString(MAKEINTRESOURCE(IDS_WARN_NOVALIDPATH_TASK5)));
        taskdlg.SetDefaultCommandControl(2);
        taskdlg.SetMainIcon(TD_WARNING_ICON);
        if (taskdlg.DoModal(m_hWnd) != 1)
            return;
    }
    CStringUtils::WriteAsciiStringToClipboard(m_URL);

    // now let the bugtraq plugin check the commit message
    CComPtr<IBugTraqProvider2> pProvider2 = NULL;
    if (m_BugTraqProvider)
    {
        HRESULT hr = m_BugTraqProvider.QueryInterface(&pProvider2);
        if (SUCCEEDED(hr))
        {
            ATL::CComBSTR temp;
            ATL::CComBSTR sourceURL;
            sourceURL.Attach(m_wcURL.AllocSysString());
            ATL::CComBSTR parameters;
            parameters.Attach(m_bugtraq_association.GetParameters().AllocSysString());
            ATL::CComBSTR targetURL;
            targetURL.Attach(m_URL.AllocSysString());
            ATL::CComBSTR commitMessage;
            commitMessage.Attach(m_sLogMessage.AllocSysString());
            CBstrSafeVector pathList(1);
            pathList.PutElement(0, m_path.GetSVNPathString());

            hr = pProvider2->CheckCommit(GetSafeHwnd(), parameters, sourceURL, targetURL, pathList, commitMessage, &temp);
            if (FAILED(hr))
            {
                OnComError(hr);
            }
            else
            {
                CString sError = temp == 0 ? L"" : temp;
                if (!sError.IsEmpty())
                {
                    CAppUtils::ReportFailedHook(m_hWnd, sError);
                    return;
                }
            }
        }
    }

    CTSVNPathList checkedItems;
    checkedItems.AddPath(m_path);
    DWORD exitcode = 0;
    CString error;
    CHooks::Instance().SetProjectProperties(m_path, m_ProjectProperties);
    if (CHooks::Instance().CheckCommit(m_hWnd, checkedItems, m_sLogMessage, exitcode, error))
    {
        if (exitcode)
        {
            CString sErrorMsg;
            sErrorMsg.Format(IDS_HOOK_ERRORMSG, (LPCWSTR)error);

            CTaskDialog taskdlg(sErrorMsg,
                                CString(MAKEINTRESOURCE(IDS_HOOKFAILED_TASK2)),
                                L"TortoiseSVN",
                                0,
                                TDF_ENABLE_HYPERLINKS | TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW | TDF_SIZE_TO_CONTENT);
            taskdlg.AddCommandControl(1, CString(MAKEINTRESOURCE(IDS_HOOKFAILED_TASK3)));
            taskdlg.AddCommandControl(2, CString(MAKEINTRESOURCE(IDS_HOOKFAILED_TASK4)));
            taskdlg.SetDefaultCommandControl(1);
            taskdlg.SetMainIcon(TD_ERROR_ICON);
            bool retry = (taskdlg.DoModal(GetSafeHwnd()) == 1);

            if (retry)
                return;
        }
    }

    if (!m_sLogMessage.IsEmpty())
    {
        m_History.AddEntry(m_sLogMessage);
        m_History.Save();
    }

    m_sBugID.Trim();
    if (!m_sBugID.IsEmpty())
    {
        m_sBugID.Replace(L", ", L",");
        m_sBugID.Replace(L" ,", L",");
        CString sBugID = m_ProjectProperties.sMessage;
        sBugID.Replace(L"%BUGID%", m_sBugID);
        if (m_ProjectProperties.bAppend)
            m_sLogMessage += L"\n" + sBugID + L"\n";
        else
            m_sLogMessage = sBugID + L"\n" + m_sLogMessage;
        UpdateData(FALSE);
    }
    CResizableStandAloneDialog::OnOK();
}
Пример #5
0
BOOL CCopyDlg::OnInitDialog()
{
    CResizableStandAloneDialog::OnInitDialog();
    CAppUtils::MarkWindowAsUnpinnable(m_hWnd);

    ExtendFrameIntoClientArea(IDC_EXTGROUP);
    m_aeroControls.SubclassControl(this, IDC_DOSWITCH);
    m_aeroControls.SubclassControl(this, IDC_MAKEPARENTS);
    m_aeroControls.SubclassOkCancelHelp(this);
    m_bCancelled = false;

    DWORD exStyle = LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_CHECKBOXES;
    m_ExtList.SetExtendedStyle(exStyle);
    SetWindowTheme(m_ExtList.GetSafeHwnd(), L"Explorer", NULL);
    m_ExtList.ShowText(CString(MAKEINTRESOURCE(IDS_COPY_WAITFOREXTERNALS)));

    AdjustControlSize(IDC_COPYHEAD);
    AdjustControlSize(IDC_COPYREV);
    AdjustControlSize(IDC_COPYWC);
    AdjustControlSize(IDC_DOSWITCH);
    AdjustControlSize(IDC_MAKEPARENTS);

    CTSVNPath path(m_path);
    CString sWindowTitle;
    GetWindowText(sWindowTitle);
    CAppUtils::SetWindowTitle(m_hWnd, path.GetUIPathString(), sWindowTitle);

    m_History.SetMaxHistoryItems((LONG)CRegDWORD(L"Software\\TortoiseSVN\\MaxHistoryItems", 25));

    SetRevision(m_CopyRev);

    m_tooltips.AddTool(IDC_HISTORY, IDS_COMMITDLG_HISTORY_TT);

    if (SVN::PathIsURL(path))
    {
        DialogEnableWindow(IDC_COPYWC, FALSE);
        DialogEnableWindow(IDC_DOSWITCH, FALSE);
        SetDlgItemText(IDC_COPYSTARTLABEL, CString(MAKEINTRESOURCE(IDS_COPYDLG_FROMURL)));
    }

    SVN svn;
    CString sUUID;
    m_repoRoot = svn.GetRepositoryRootAndUUID(path, true, sUUID);
    m_repoRoot.TrimRight('/');
    m_wcURL = svn.GetURLFromPath(path);
    if (m_wcURL.IsEmpty() || (!path.IsUrl() && !path.Exists()))
    {
        CString Wrong_URL=path.GetSVNPathString();
        CString temp;
        temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)Wrong_URL);
        ::MessageBox(this->m_hWnd, temp, L"TortoiseSVN", MB_ICONERROR);
        this->EndDialog(IDCANCEL);      //exit
    }
    m_URLCombo.LoadHistory(L"Software\\TortoiseSVN\\History\\repoPaths\\"+sUUID, L"url");
    m_URLCombo.SetCurSel(0);
    CString relPath = m_wcURL.Mid(m_repoRoot.GetLength());
    if (!m_URL.IsEmpty())
    {
        // allow the use of urls relative to the repo root
        if (m_URL[0] != '^')
            relPath = m_URL.Mid(m_repoRoot.GetLength());
        else
            relPath = m_URL.Mid(1);
    }
    CTSVNPath r = CTSVNPath(relPath);
    relPath = r.GetUIPathString();
    relPath.Replace('\\', '/');
    m_URLCombo.AddString(relPath, 0);
    m_URLCombo.SelectString(-1, relPath);
    m_URL = m_wcURL;
    SetDlgItemText(IDC_DESTURL, CPathUtils::CombineUrls(m_repoRoot, relPath));
    SetDlgItemText(IDC_FROMURL, m_wcURL);

    CString reg;
    reg.Format(L"Software\\TortoiseSVN\\History\\commit%s", (LPCTSTR)sUUID);
    m_History.Load(reg, L"logmsgs");

    m_ProjectProperties.ReadProps(m_path);
    if (CRegDWORD(L"Software\\TortoiseSVN\\AlwaysWarnIfNoIssue", FALSE))
        m_ProjectProperties.bWarnIfNoIssue = TRUE;

    m_cLogMessage.Init(m_ProjectProperties);
    m_cLogMessage.SetFont((CString)CRegString(L"Software\\TortoiseSVN\\LogFontName", L"Courier New"), (DWORD)CRegDWORD(L"Software\\TortoiseSVN\\LogFontSize", 8));

    GetDlgItem(IDC_BUGTRAQBUTTON)->ShowWindow(SW_HIDE);
    GetDlgItem(IDC_BUGTRAQBUTTON)->EnableWindow(FALSE);
    CBugTraqAssociations bugtraq_associations;
    bugtraq_associations.Load(m_ProjectProperties.GetProviderUUID(), m_ProjectProperties.sProviderParams);

    if (bugtraq_associations.FindProvider(CTSVNPathList(m_path), &m_bugtraq_association))
    {
        CComPtr<IBugTraqProvider> pProvider;
        HRESULT hr = pProvider.CoCreateInstance(m_bugtraq_association.GetProviderClass());
        if (SUCCEEDED(hr))
        {
            m_BugTraqProvider = pProvider;
            ATL::CComBSTR temp;
            ATL::CComBSTR parameters;
            parameters.Attach(m_bugtraq_association.GetParameters().AllocSysString());
            hr = pProvider->GetLinkText(GetSafeHwnd(), parameters, &temp);
            if (SUCCEEDED(hr))
            {
                SetDlgItemText(IDC_BUGTRAQBUTTON, temp == 0 ? L"" : temp);
                GetDlgItem(IDC_BUGTRAQBUTTON)->EnableWindow(TRUE);
                GetDlgItem(IDC_BUGTRAQBUTTON)->ShowWindow(SW_SHOW);
            }
        }

        GetDlgItem(IDC_LOGMESSAGE)->SetFocus();
    }
    if (m_ProjectProperties.sMessage.IsEmpty())
    {
        GetDlgItem(IDC_BUGID)->ShowWindow(SW_HIDE);
        GetDlgItem(IDC_BUGIDLABEL)->ShowWindow(SW_HIDE);
        GetDlgItem(IDC_LOGMESSAGE)->SetFocus();
    }
    else
    {
        GetDlgItem(IDC_BUGID)->ShowWindow(SW_SHOW);
        GetDlgItem(IDC_BUGIDLABEL)->ShowWindow(SW_SHOW);
        if (!m_ProjectProperties.sLabel.IsEmpty())
            SetDlgItemText(IDC_BUGIDLABEL, m_ProjectProperties.sLabel);
        GetDlgItem(IDC_BUGID)->SetFocus();
    }

    if (!m_sLogMessage.IsEmpty())
        m_cLogMessage.SetText(m_sLogMessage);
    else
        m_cLogMessage.SetText(m_ProjectProperties.GetLogMsgTemplate(PROJECTPROPNAME_LOGTEMPLATEBRANCH));

    OnEnChangeLogmessage();

    m_linkControl.ConvertStaticToLink(m_hWnd, IDC_CHECKALL);
    m_linkControl.ConvertStaticToLink(m_hWnd, IDC_CHECKNONE);

    // line up all controls and adjust their sizes.
#define LINKSPACING 9
    RECT rc = AdjustControlSize(IDC_SELECTLABEL);
    rc.right -= 15; // AdjustControlSize() adds 20 pixels for the checkbox/radio button bitmap, but this is a label...
    rc = AdjustStaticSize(IDC_CHECKALL, rc, LINKSPACING);
    rc = AdjustStaticSize(IDC_CHECKNONE, rc, LINKSPACING);

    CAppUtils::SetAccProperty(m_cLogMessage.GetSafeHwnd(), PROPID_ACC_ROLE, ROLE_SYSTEM_TEXT);
    CAppUtils::SetAccProperty(m_cLogMessage.GetSafeHwnd(), PROPID_ACC_HELP, CString(MAKEINTRESOURCE(IDS_INPUT_ENTERLOG)));
    CAppUtils::SetAccProperty(m_cLogMessage.GetSafeHwnd(), PROPID_ACC_KEYBOARDSHORTCUT, L"Alt+"+CString(CAppUtils::FindAcceleratorKey(this, IDC_INVISIBLE)));

    CAppUtils::SetAccProperty(GetDlgItem(IDC_CHECKALL)->GetSafeHwnd(), PROPID_ACC_ROLE, ROLE_SYSTEM_LINK);
    CAppUtils::SetAccProperty(GetDlgItem(IDC_CHECKNONE)->GetSafeHwnd(), PROPID_ACC_ROLE, ROLE_SYSTEM_LINK);

    CAppUtils::SetAccProperty(m_URLCombo.GetSafeHwnd(), PROPID_ACC_KEYBOARDSHORTCUT, L"Alt+"+CString(CAppUtils::FindAcceleratorKey(this, IDC_TOURLLABEL)));
    CAppUtils::SetAccProperty(GetDlgItem(IDC_FROMURL)->GetSafeHwnd(), PROPID_ACC_KEYBOARDSHORTCUT, L"Alt+"+CString(CAppUtils::FindAcceleratorKey(this, IDC_COPYSTARTLABEL)));
    CAppUtils::SetAccProperty(GetDlgItem(IDC_DESTURL)->GetSafeHwnd(), PROPID_ACC_KEYBOARDSHORTCUT, L"Alt+"+CString(CAppUtils::FindAcceleratorKey(this, IDC_DESTLABEL)));

    AddAnchor(IDC_REPOGROUP, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_COPYSTARTLABEL, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_FROMURL, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_TOURLLABEL, TOP_LEFT);
    AddAnchor(IDC_URLCOMBO, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_BROWSE, TOP_RIGHT);
    AddAnchor(IDC_DESTLABEL, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_DESTURL, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_MSGGROUP, TOP_LEFT, MIDDLE_RIGHT);
    AddAnchor(IDC_HISTORY, TOP_LEFT);
    AddAnchor(IDC_BUGTRAQBUTTON, TOP_LEFT);
    AddAnchor(IDC_BUGIDLABEL, TOP_RIGHT);
    AddAnchor(IDC_BUGID, TOP_RIGHT);
    AddAnchor(IDC_INVISIBLE, TOP_RIGHT);
    AddAnchor(IDC_LOGMESSAGE, TOP_LEFT, MIDDLE_RIGHT);
    AddAnchor(IDC_FROMGROUP, MIDDLE_LEFT, MIDDLE_RIGHT);
    AddAnchor(IDC_COPYHEAD, MIDDLE_LEFT);
    AddAnchor(IDC_COPYREV, MIDDLE_LEFT);
    AddAnchor(IDC_COPYREVTEXT, MIDDLE_RIGHT);
    AddAnchor(IDC_BROWSEFROM, MIDDLE_RIGHT);
    AddAnchor(IDC_COPYWC, MIDDLE_LEFT);
    AddAnchor(IDC_EXTGROUP, MIDDLE_LEFT, BOTTOM_RIGHT);
    AddAnchor(IDC_SELECTLABEL, MIDDLE_LEFT);
    AddAnchor(IDC_CHECKALL, MIDDLE_LEFT);
    AddAnchor(IDC_CHECKNONE, MIDDLE_LEFT);
    AddAnchor(IDC_EXTERNALSLIST, MIDDLE_LEFT, BOTTOM_RIGHT);
    AddAnchor(IDC_DOSWITCH, BOTTOM_LEFT);
    AddAnchor(IDC_MAKEPARENTS, BOTTOM_LEFT);
    AddAnchor(IDOK, BOTTOM_RIGHT);
    AddAnchor(IDCANCEL, BOTTOM_RIGHT);
    AddAnchor(IDHELP, BOTTOM_RIGHT);

    if ((m_pParentWnd==NULL)&&(GetExplorerHWND()))
        CenterWindow(CWnd::FromHandle(GetExplorerHWND()));
    EnableSaveRestore(L"CopyDlg");

    m_bSettingChanged = false;
    if (!m_path.IsUrl())
    {
        // start a thread to obtain the highest revision number of the working copy
        // without blocking the dialog
        if ((m_pThread = AfxBeginThread(FindRevThreadEntry, this))==NULL)
        {
            OnCantStartThread();
        }
    }

    return TRUE;
}
Пример #6
0
BOOL CInputLogDlg::OnInitDialog()
{
    CResizableStandAloneDialog::OnInitDialog();
    CAppUtils::MarkWindowAsUnpinnable(m_hWnd);

    ExtendFrameIntoClientArea(IDC_GROUPBOX);
    m_aeroControls.SubclassControl(this, IDC_CHECKBOX);
    m_aeroControls.SubclassOkCancel(this);

#ifdef DEBUG
    if (m_pProjectProperties == NULL)
        TRACE("InputLogDlg: project properties not set\n");
    if (m_sActionText.IsEmpty())
        TRACE("InputLogDlg: action text not set\n");
    if (m_sUUID.IsEmpty())
        TRACE("InputLogDlg: repository UUID not set\n");
#endif

    if (m_pProjectProperties)
        m_cInput.Init(*m_pProjectProperties);
    else
        m_cInput.Init();

    m_cInput.SetFont((CString)CRegString(_T("Software\\TortoiseSVN\\LogFontName"), _T("Courier New")), (DWORD)CRegDWORD(_T("Software\\TortoiseSVN\\LogFontSize"), 8));

    if (m_pProjectProperties)
    {
        if (m_pProjectProperties->nLogWidthMarker)
        {
            m_cInput.Call(SCI_SETWRAPMODE, SC_WRAP_NONE);
            m_cInput.Call(SCI_SETEDGEMODE, EDGE_LINE);
            m_cInput.Call(SCI_SETEDGECOLUMN, m_pProjectProperties->nLogWidthMarker);
        }
        else
        {
            m_cInput.Call(SCI_SETEDGEMODE, EDGE_NONE);
            m_cInput.Call(SCI_SETWRAPMODE, SC_WRAP_WORD);
        }
        m_cInput.SetText(m_pProjectProperties->GetLogMsgTemplate(m_sSVNAction));
    }

    UpdateOKButton();

    CAppUtils::SetAccProperty(m_cInput.GetSafeHwnd(), PROPID_ACC_ROLE, ROLE_SYSTEM_TEXT);
    CAppUtils::SetAccProperty(m_cInput.GetSafeHwnd(), PROPID_ACC_HELP, CString(MAKEINTRESOURCE(IDS_INPUT_ENTERLOG)));

    SetDlgItemText(IDC_ACTIONLABEL, m_sActionText);
    if (!m_sTitleText.IsEmpty())
        SetWindowText(m_sTitleText);
    if (!m_sCheckText.IsEmpty())
    {
        SetDlgItemText(IDC_CHECKBOX, m_sCheckText);
        GetDlgItem(IDC_CHECKBOX)->ShowWindow(SW_SHOW);
    }
    else
    {
        GetDlgItem(IDC_CHECKBOX)->ShowWindow(SW_HIDE);
    }
    if (!m_sLogMsg.IsEmpty())
        m_cInput.SetText(m_sLogMsg);

    if (m_pProjectProperties && (!m_rootpath.IsEmpty() || m_pathlist.GetCount()))
    {
        CBugTraqAssociations bugtraq_associations;
        bugtraq_associations.Load(m_pProjectProperties->GetProviderUUID(), m_pProjectProperties->sProviderParams);

        bool bExtendUrlControl = true;
        bool bFound = bugtraq_associations.FindProvider(m_pathlist, &m_bugtraq_association);
        if (!bFound)
            bFound = bugtraq_associations.FindProvider(CTSVNPathList(m_rootpath), &m_bugtraq_association);
        if (bFound)
        {
            CComPtr<IBugTraqProvider> pProvider;
            HRESULT hr = pProvider.CoCreateInstance(m_bugtraq_association.GetProviderClass());
            if (SUCCEEDED(hr))
            {
                m_BugTraqProvider = pProvider;
                ATL::CComBSTR temp;
                ATL::CComBSTR parameters;
                parameters.Attach(m_bugtraq_association.GetParameters().AllocSysString());
                hr = pProvider->GetLinkText(GetSafeHwnd(), parameters, &temp);
                if (SUCCEEDED(hr))
                {
                    SetDlgItemText(IDC_BUGTRAQBUTTON, temp == 0 ? _T("") : temp);
                    GetDlgItem(IDC_BUGTRAQBUTTON)->ShowWindow(SW_SHOW);
                    bExtendUrlControl = false;
                }
            }

            m_cInput.SetFocus();
        }
        if (bExtendUrlControl)
            CAppUtils::ExtendControlOverHiddenControl(this, IDC_ACTIONLABEL, IDC_BUGTRAQBUTTON);

        if (!m_pProjectProperties->sMessage.IsEmpty())
        {
            GetDlgItem(IDC_BUGID)->ShowWindow(SW_SHOW);
            GetDlgItem(IDC_BUGIDLABEL)->ShowWindow(SW_SHOW);
            if (!m_pProjectProperties->sLabel.IsEmpty())
                SetDlgItemText(IDC_BUGIDLABEL, m_pProjectProperties->sLabel);
            GetDlgItem(IDC_BUGID)->SetFocus();
            CString sBugID = m_pProjectProperties->GetBugIDFromLog(m_sLogMsg);
            if (!sBugID.IsEmpty())
            {
                SetDlgItemText(IDC_BUGID, sBugID);
            }
        }
        else
        {
            GetDlgItem(IDC_BUGID)->ShowWindow(SW_HIDE);
            GetDlgItem(IDC_BUGIDLABEL)->ShowWindow(SW_HIDE);
            m_cInput.SetFocus();
        }
    }
    else
    {
        GetDlgItem(IDC_BUGID)->ShowWindow(SW_HIDE);
        GetDlgItem(IDC_BUGIDLABEL)->ShowWindow(SW_HIDE);
        CAppUtils::ExtendControlOverHiddenControl(this, IDC_ACTIONLABEL, IDC_BUGTRAQBUTTON);
        m_cInput.SetFocus();
    }

    m_bLock = m_sSVNAction.Compare(PROJECTPROPNAME_LOGTEMPLATELOCK)==0;

    AddAnchor(IDC_ACTIONLABEL, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_BUGIDLABEL, TOP_RIGHT);
    AddAnchor(IDC_BUGID, TOP_RIGHT);
    AddAnchor(IDC_BUGTRAQBUTTON, TOP_RIGHT);
    AddAnchor(IDC_GROUPBOX, TOP_LEFT, BOTTOM_RIGHT);
    AddAnchor(IDC_HISTORY, TOP_LEFT);
    AddAnchor(IDC_INPUTTEXT, TOP_LEFT, BOTTOM_RIGHT);
    AddAnchor(IDC_CHECKBOX, BOTTOM_LEFT, BOTTOM_RIGHT);
    AddAnchor(IDCANCEL, BOTTOM_RIGHT);
    AddAnchor(IDOK, BOTTOM_RIGHT);
    EnableSaveRestore(_T("InputLogDlg"));
    if (FindParentWindow(0))
        CenterWindow(CWnd::FromHandle(FindParentWindow(0)));

    m_cInput.SetFocus();
    return FALSE;
}
Пример #7
0
void CInputLogDlg::OnOK()
{
    UpdateData();
    m_sLogMsg = m_cInput.GetText();

    if (m_pProjectProperties)
    {
        CString id;
        GetDlgItemText(IDC_BUGID, id);
        id.Trim(_T("\n\r"));
        if (!m_bLock && !m_pProjectProperties->CheckBugID(id))
        {
            ShowEditBalloon(IDC_BUGID, IDS_COMMITDLG_ONLYNUMBERS, TTI_ERROR);
            return;
        }
        if (!m_bLock && (m_pProjectProperties->bWarnIfNoIssue) && (id.IsEmpty() && !m_pProjectProperties->HasBugID(m_sLogMsg)))
        {
            if (CTaskDialog::IsSupported())
            {
                CTaskDialog taskdlg(CString(MAKEINTRESOURCE(IDS_COMMITDLG_WARNNOISSUE_TASK1)),
                                    CString(MAKEINTRESOURCE(IDS_COMMITDLG_WARNNOISSUE_TASK2)),
                                    L"TortoiseSVN",
                                    0,
                                    TDF_USE_COMMAND_LINKS|TDF_ALLOW_DIALOG_CANCELLATION|TDF_POSITION_RELATIVE_TO_WINDOW);
                taskdlg.AddCommandControl(1, CString(MAKEINTRESOURCE(IDS_COMMITDLG_WARNNOISSUE_TASK3)));
                taskdlg.AddCommandControl(2, CString(MAKEINTRESOURCE(IDS_COMMITDLG_WARNNOISSUE_TASK4)));
                taskdlg.SetCommonButtons(TDCBF_CANCEL_BUTTON);
                taskdlg.SetDefaultCommandControl(2);
                taskdlg.SetMainIcon(TD_WARNING_ICON);
                if (taskdlg.DoModal(m_hWnd) != 1)
                    return;
            }
            else
            {
                if (TSVNMessageBox(this->m_hWnd, IDS_COMMITDLG_NOISSUEWARNING, IDS_APPNAME, MB_YESNO | MB_ICONWARNING)!=IDYES)
                    return;
            }
        }
        m_sBugID.Trim();
        CString sExistingBugID = m_pProjectProperties->FindBugID(m_sLogMsg);
        sExistingBugID.Trim();
        if (!m_sBugID.IsEmpty() && m_sBugID.Compare(sExistingBugID))
        {
            m_sBugID.Replace(_T(", "), _T(","));
            m_sBugID.Replace(_T(" ,"), _T(","));
            CString sBugID = m_pProjectProperties->sMessage;
            sBugID.Replace(_T("%BUGID%"), m_sBugID);
            if (m_pProjectProperties->bAppend)
                m_sLogMsg += _T("\n") + sBugID + _T("\n");
            else
                m_sLogMsg = sBugID + _T("\n") + m_sLogMsg;
        }
        if (!m_bLock)
        {
            // now let the bugtraq plugin check the commit message
            CComPtr<IBugTraqProvider2> pProvider2 = NULL;
            if (m_BugTraqProvider)
            {
                HRESULT hr = m_BugTraqProvider.QueryInterface(&pProvider2);
                if (SUCCEEDED(hr))
                {
                    ATL::CComBSTR temp;
                    CString common = m_rootpath.GetSVNPathString();
                    ATL::CComBSTR repositoryRoot;
                    repositoryRoot.Attach(common.AllocSysString());
                    ATL::CComBSTR parameters;
                    parameters.Attach(m_bugtraq_association.GetParameters().AllocSysString());
                    ATL::CComBSTR commonRoot(m_pathlist.GetCommonRoot().GetDirectory().GetWinPath());
                    ATL::CComBSTR commitMessage;
                    commitMessage.Attach(m_sLogMsg.AllocSysString());
                    CBstrSafeVector pathList(m_pathlist.GetCount());

                    for (LONG index = 0; index < m_pathlist.GetCount(); ++index)
                        pathList.PutElement(index, m_pathlist[index].GetSVNPathString());

                    hr = pProvider2->CheckCommit(GetSafeHwnd(), parameters, repositoryRoot, commonRoot, pathList, commitMessage, &temp);
                    if (FAILED(hr))
                    {
                        OnComError(hr);
                    }
                    else
                    {
                        CString sError = temp == 0 ? _T("") : temp;
                        if (!sError.IsEmpty())
                        {
                            CAppUtils::ReportFailedHook(m_hWnd, sError);
                            return;
                        }
                    }
                }
            }
        }
    }

    CString reg;
    reg.Format(_T("Software\\TortoiseSVN\\History\\commit%s"), (LPCTSTR)m_sUUID);

    CRegHistory history;
    history.Load(reg, _T("logmsgs"));
    history.AddEntry(m_sLogMsg);
    history.Save();

    CResizableStandAloneDialog::OnOK();
}