void CDialogVolumeRename::OnOK(wxCommandEvent &e)
{
  wxString sValue = m_pText->GetValue();
  if(m_pVolumes->Rename(m_pThisVolume,sValue))
  {
    e.Skip(true);
  }
  else
  {
    mainApp::ShowError(m_pVolumes->GetLastError(),this);
  }
}
Exemplo n.º 2
0
void CVolumes::UnitTest()
{
  CVolumes vols;
  SetVolumeNames setNames;
  wxString sText;
  size_t nSize = vols.GetNames(&setNames);
  wxString sRO;
  wxString sLock;
  CVolume *pVolume;
  sText.Alloc(4096);
  sText.Append(wxString::Format(
    "CVolumes::UnitTest()\nVolume count: %d\n\n",(int)nSize));
  for(SetVolumeNames::iterator itr = setNames.begin();
    itr != setNames.end();
    ++itr)
  {
    pVolume = vols.Find(*itr);
    sRO = (pVolume == NULL)
      ? "X"
      : (pVolume->IsReadOnly() ? "R" : "RW");
    sLock = (sRO == "RW")
      ? wxString((pVolume->Lock() ? "Lock" : "NO-LOCK!"))
      : pVolume->GetLockUser();
    sText.Append(wxString::Format(
      "%ls %ls %ls\n",
      (*itr).wc_str(),
      sRO.wc_str(),
      sLock.wc_str() ));    
  }
  // mainApp::ShowAlert(sText,NULL);
  pVolume = vols.Create("[Profiler Plus]","UnitTest");
  sText.Clear();
  if(pVolume == NULL)
  {
    sText.Append("Cannot create " Volume_string ", \"UnitTest\"\n");
  }
  else
  {
    if(!pVolume->Lock())
    {
      sText.Append("Cannot lock " Volume_string ", \"UnitTest\"\n");
    }
    else if(!vols.Remove(pVolume))
    {
      sText.Append("Cannot Remove " Volume_string ", \"UnitTest\"\n");
    }
  }
  wxASSERT_MSG(sText.IsEmpty(),sText);
}
void CDialogVolumeAddNew::OnOK(wxCommandEvent &e)
{
  wxString sCopyFrom = m_pChoiceKit->GetStringSelection();
  m_sName = m_pText->GetValue();
  bool bError = true;
  {
    wxBusyCursor xxx;
    if(m_pVolumes->Create(sCopyFrom,m_sName))
    {
      bError = false;
      e.Skip();
    }
  }

  if(bError) // we want wxBusyCursor out of scope here
  {
    m_sName.Empty();
    mainApp::ShowError(m_pVolumes->GetLastError(),this);
  }
}