예제 #1
0
/**
 * Applique les modifications dans le fichier correspondant au nœud sélectionné
 * @param event un évènement
 */
void PreferenceCouleur::EvtTreeModifNomFin(wxTreeEvent &event)
{
    if (!event.IsEditCancelled())
    {
        //renommer le fichier - event.GetLabel();
        if (wxFileExists(Parametre::Get()->getCheminCouleur(event.GetLabel())))
        {
            wxLogMessage(_T("Fichier Existant !"));
            m_treeFiles->EndEditLabel(event.GetItem(), true);
            m_treeFiles->SetFocus();
        }
        else
        {
            if (wxFileExists(Parametre::Get()->getCheminCouleur(m_treeFiles->GetItemText(event.GetItem()))))
            {
                ModifierFiltre(event.GetLabel().BeforeLast('.'), m_treeFiles->GetItemText(event.GetItem()));
                wxRemoveFile(Parametre::Get()->getCheminCouleur(m_treeFiles->GetItemText(event.GetItem())));
                m_textNomSet->ChangeValue(event.GetLabel().BeforeLast('.'));
                m_treeFiles->SortChildren(m_nodeExistant);
                CallListeners();
            }
        }
    }
    m_nomAvantModif.Clear();
}
void E_Scene_Groupesurfaces_Groupe::OnEndLabelEdit(wxTreeEvent& treeEvent)
{
	if(treeEvent.GetLabel()!="")
	{
		this->elementInfo.libelleElement=treeEvent.GetLabel();
		this->Modified(this); //Indique le l'element a été modifié
	}
}
예제 #3
0
void RegTreeCtrl::OnEndEdit(wxTreeEvent& event)
{
    bool ok;

    wxString name = event.GetLabel();

    TreeNode *pNode = GetNode(event);
    if ( pNode->IsKey() )
    {
        wxRegKey& key = pNode->Key();
        ok = key.Rename(name);
    }
    else
    {
        pNode = pNode->Parent();
        wxRegKey& key = pNode->Key();

        ok = key.RenameValue(m_nameOld, name);
    }

    if ( !ok )
    {
        wxLogError(wxT("Failed to rename '%s' to '%s'."),
            m_nameOld.c_str(), name.c_str());
    }
#if 0   // MSW tree ctrl doesn't like this at all, it hangs
    else
    {
        pNode->Refresh();
    }
#endif // 0
}
예제 #4
0
///////////////////////////////////////////////////////////////////////////////
// GUI callback for when a label is done being edited by the user.  Creates a
// command to change the name of the dependency node associated with the item.
// 
void SceneOutliner::OnEndLabelEdit( wxTreeEvent& args )
{
    if ( !args.IsEditCancelled() )
    {
        SceneOutlinerItemData* data = GetTreeItemData( args.GetItem() );
        Reflect::Object* object = data->GetObject();
        SceneGraph::SceneNode* node = Reflect::SafeCast< SceneGraph::SceneNode >( object );
        if ( node )
        {
            const tstring newName = args.GetLabel().c_str();
            if ( node->GetName() != newName )
            {
                // Create an undoable command to rename the object
                m_CurrentScene->Push( new PropertyUndoCommand<tstring>( new Helium::MemberProperty<SceneGraph::SceneNode, tstring> (node, &SceneGraph::SceneNode::GetName, &SceneGraph::SceneNode::SetGivenName), newName) );
                m_CurrentScene->Execute( false );

                // Sort
                Sort( m_TreeCtrl->GetItemParent( args.GetItem() ) );

                // Keep the item in view
                if ( !m_TreeCtrl->IsVisible( args.GetItem() ) )
                {
                    m_TreeCtrl->EnsureVisible( args.GetItem() );
                }
            }
            args.Veto();
            OnSelectionChanged( (wxTreeEvent)NULL );
        }
    }
}
void PWSTreeCtrl::FinishAddingGroup(wxTreeEvent& evt, wxTreeItemId groupItem)
{
  if (evt.IsEditCancelled()) {
    // New item, not yet in db.  So we could just remove from the tree
    Delete(groupItem);
  }
  else {
    // Can't call GetItemGroup here since the item doesn't actually have the new label
    wxString groupName = evt.GetLabel();
    for (wxTreeItemId parent = GetItemParent(groupItem);
                      parent != GetRootItem(); parent = GetItemParent(parent)) {
      groupName = GetItemText(parent) + wxT(".") + groupName;
    }
    StringX sxGroup = tostringx(groupName);

    // The new item we just added above will get removed once the update GUI callback from core happens.
    DBEmptyGroupsCommand* cmd = DBEmptyGroupsCommand::Create(&m_core,
                                                             sxGroup,
                                                             DBEmptyGroupsCommand::EG_ADD);
    if (cmd)
      m_core.Execute(cmd);

    // evt.GetItem() is not valid anymore.  A new item has been inserted instead.
    // We can select it using the full path we computed earlier
    wxTreeItemId newItem = Find(groupName, GetRootItem());
    if (newItem.IsOk())
      wxTreeCtrl::SelectItem(newItem);
  }
}
예제 #6
0
/**
 * Autorise ou non la modification d'un nœud
 * @param event un évènement
 */
void PreferenceCouleur::EvtTreeModifNomDebut(wxTreeEvent &event)
{
    if (m_treeFiles->GetItemParent(event.GetItem()) == m_nodeExistant)
        m_nomAvantModif = event.GetLabel();
    else
    {
        m_treeFiles->EndEditLabel(event.GetItem(), true);
        m_treeFiles->SetFocus();
        m_treeFiles->SelectItem(event.GetItem());
        m_nomAvantModif.Clear();
    }
}
예제 #7
0
void SkillObjectTree::OnEndLabelEdit(wxTreeEvent& event)
{
	wxLogMessage(wxT("OnEndLabelEdit"));

	// don't allow anything except letters in the labels
	if ( !event.GetLabel().IsWord() )
	{
		wxMessageBox(wxT("The new label should be a single word."));

		event.Veto();
	}
}
예제 #8
0
void CollectionsPanel::OnMyCollectionsEndLabelEdit( wxTreeEvent& event )
{
    // this just makes the code below more generic in case we want to abstract it later
    SortTreeCtrl* treeCtrl = m_MyCollectionsTreeCtrl;

    event.Veto();

    if( event.IsEditCancelled() )
    {
        return;
    }

    wxTreeItemId item = event.GetItem();
    if ( !item )
    {
        return;
    }

    AssetCollectionItemData* baseData = GetItemData( treeCtrl, item );
    if ( !baseData )
    {
        return;
    }

    AssetCollection* collection = baseData->GetCollection<AssetCollection>();
    if ( !collection || !collection->CanRename() )
    {
        return;
    }

    wxString labelValue = event.GetLabel();
    labelValue.Trim(true);  // trim white-space right 
    labelValue.Trim(false); // trim white-space left

    if ( labelValue.empty() )
    {
        return;
    }

    tstring errors;

    collection->Freeze();
    bool renameResult = m_CollectionManager->RenameCollection( collection, (const wxChar*)labelValue.c_str(), errors );
    collection->Thaw();
    if ( !renameResult )
    {
        wxMessageBox( errors.c_str(), TXT( "MyCollection Name Already In Use" ), wxCENTER | wxICON_WARNING | wxOK, this );
        //treeCtrl->EditLabel( item );
        return;
    }
}
예제 #9
0
void wxGxTreeView::OnEndLabelEdit(wxTreeEvent& event)
{
    if ( event.GetLabel().IsEmpty() )
    {        
        event.Veto();
		return;
    }

	wxTreeItemId item = event.GetItem();
	if(!item.IsOk())
	{
		event.Veto();
		return;
	}
	wxGxTreeItemData* pData = (wxGxTreeItemData*)GetItemData(event.GetItem());
	if(pData == NULL)
	{
		event.Veto();
		return;
	}
    
    wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(pData->m_nObjectID);
	IGxObjectEdit* pObjEdit =  dynamic_cast<IGxObjectEdit*>(pGxObject);
	if(pObjEdit == NULL)
	{
		event.Veto();
		return;
	}

	if(!pObjEdit->Rename(event.GetLabel()))
	{
		event.Veto();
		wxMessageBox(_("Rename error!"), _("Error"), wxICON_ERROR | wxOK );
		return;
	}

	m_pCatalog->ObjectChanged(pGxObject->GetId());
}
예제 #10
0
void nsSolutionBrowser::labelEditEvent(wxTreeEvent& evt)
{
	nsTreeItem* item = (nsTreeItem*)m_tree->GetItemData(m_tree->GetSelection());
	if (item && item->m_tree)
	{
		nsNodeTree* ntree = item->m_tree;
		ntree->setName((const char*)evt.GetLabel().mb_str());

		nsTreeEvent change(NS_TREE_CHANGED, this, ntree);

		nsWorkspace::getSingleton().treeEvent(change);
		nsPropertyPage::getSingleton().treeEvent(change);
	}
}
예제 #11
0
void DecisionLogicFrame::TreeOnEndLabelEdit(wxTreeEvent& event)
{
    // don't allow anything except letters in the labels
	wstring newName = event.GetLabel().wc_str();
    if (!m_worker->ValidateFolderName(newName))
    {
        event.Veto();
    }
	else
	{
		m_worker->RenameTable(m_lastName, newName);
	}
	m_lastName = L"";
}
예제 #12
0
파일: TreeView.cpp 프로젝트: kamalsirsa/vtp
void MyTreeCtrl::OnEndLabelEdit(wxTreeEvent& event)
{
#if 0
	wxLogMessage("OnEndLabelEdit");

	// don't allow anything except letters in the labels
	if ( !event.GetLabel().IsWord() )
	{
		wxMessageBox("The label should contain only letters.");

		event.Veto();
	}
#endif
}
예제 #13
0
void DecisionLogicFrame::TreeOnBeginLabelEdit(wxTreeEvent& event)
{
    // for testing, prevent this item's label editing
    wxTreeItemId itemId = event.GetItem();
    if ( EditNotAllowed(itemId) )
    {
        event.Veto();
    }
	else
	{
		m_lastName = event.GetLabel();
	}

}
예제 #14
0
void
SamplesTreeCtrl::onEndEditLabel( wxTreeEvent &event )
{
	// The item will be renamed by onRenameSample
	event.Veto();

	wxTreeItemId selectedItem = event.GetItem();

	SamplesTreeData *data = (SamplesTreeData *)GetItemData( selectedItem );

	// Don't allow speakers to be renamed (yet!)
	// TODO allow speakers to be renamed this way.
	if ( data == NULL )
		return;

	smp::sampleManager->renameSample( data->m_sample, event.GetLabel() );
}
예제 #15
0
//------------------------------------------------------------------------------
void OutputTree::OnEndLabelEdit(wxTreeEvent &event)
{
   wxString newLabel = event.GetLabel();
   
   // check to see if label is a single word
   if (newLabel.IsWord())
   {
      GmatTreeItemData *selItem = (GmatTreeItemData *)
         GetItemData(GetSelection());
      
      wxString oldLabel = selItem->GetName();
      selItem->SetName(newLabel);
   }
   else
   {
      event.Veto();
   }
}
예제 #16
0
void frmMDFEditor::OnTreectrlSelChanged( wxTreeEvent& event )
{
    wxString strPage;
    strPage = _("<html><body><h3>");
    wxTreeItemId itemID = event.GetItem();
    //MyTreeItemData *item = itemId.IsOk() ? (MyTreeItemData *)GetItemData(itemId)
    //                                     : NULL;
    if ( itemID.IsOk() ) {
        strPage += m_mdfTree->GetItemText( itemID );
        strPage += event.GetLabel();
    }
    else {
        strPage += _("????");
    }
    strPage += _("</h3></body></html>");
    m_htmlInfoWnd->SetPage( strPage );
    event.Skip();
}
예제 #17
0
void CBookmarksDialog::OnEndLabelEdit(wxTreeEvent& event)
{
	if (event.IsEditCancelled())
		return;

	wxTreeItemId item = event.GetItem();
	if (item != m_pTree->GetSelection())
	{
		if (!Verify())
		{
			event.Veto();
			return;
		}
	}

	if (!item || item == m_bookmarks_global || item == m_bookmarks_site)
	{
		event.Veto();
		return;
	}

	wxString name = event.GetLabel();

	wxTreeItemId parent = m_pTree->GetItemParent(item);

	wxTreeItemIdValue cookie;
	for (wxTreeItemId child = m_pTree->GetFirstChild(parent, cookie); child.IsOk(); child = m_pTree->GetNextChild(parent, cookie))
	{
		if (child == item)
			continue;
		if (!name.CmpNoCase(m_pTree->GetItemText(child)))
		{
			wxMessageBoxEx(_("Name already exists"), _("Cannot rename entry"), wxICON_EXCLAMATION, this);
			event.Veto();
			return;
		}
	}

	m_pTree->SortChildren(parent);
}
예제 #18
0
파일: dirctrlg.cpp 프로젝트: drvo/wxWidgets
void wxGenericDirCtrl::OnEndEditItem(wxTreeEvent &event)
{
    if (event.IsEditCancelled())
        return;

    if ((event.GetLabel().empty()) ||
        (event.GetLabel() == wxT(".")) ||
        (event.GetLabel() == wxT("..")) ||
        (event.GetLabel().Find(wxT('/')) != wxNOT_FOUND) ||
        (event.GetLabel().Find(wxT('\\')) != wxNOT_FOUND) ||
        (event.GetLabel().Find(wxT('|')) != wxNOT_FOUND))
    {
        wxMessageDialog dialog(this, _("Illegal directory name."), _("Error"), wxOK | wxICON_ERROR );
        dialog.ShowModal();
        event.Veto();
        return;
    }

    wxTreeItemId treeid = event.GetItem();
    wxDirItemData *data = (wxDirItemData*)m_treeCtrl->GetItemData( treeid );
    wxASSERT( data );

    wxString new_name( wxPathOnly( data->m_path ) );
    new_name += wxString(wxFILE_SEP_PATH);
    new_name += event.GetLabel();

    wxLogNull log;

    if (wxFileExists(new_name))
    {
        wxMessageDialog dialog(this, _("File name exists already."), _("Error"), wxOK | wxICON_ERROR );
        dialog.ShowModal();
        event.Veto();
    }

    if (wxRenameFile(data->m_path,new_name))
    {
        data->SetNewDirName( new_name );
    }
    else
    {
        wxMessageDialog dialog(this, _("Operation not permitted."), _("Error"), wxOK | wxICON_ERROR );
        dialog.ShowModal();
        event.Veto();
    }
}
void PWSTreeCtrl::OnEndLabelEdit( wxTreeEvent& evt )
{
  switch (evt.GetId()) {
    case ID_TREECTRL:
    {
      if (evt.GetLabel().Find(wxT('.')) == wxNOT_FOUND) {
      // Not safe to modify the tree ctrl in any way.  Wait for the stack to unwind.
      wxTreeEvent newEvt(evt);
      newEvt.SetId(ID_TREECTRL_1);
      AddPendingEvent(newEvt);
      }
      else {
        evt.Veto();
        wxMessageBox(_("Dots are not allowed in group names"), _("Invalid Character"), wxOK|wxICON_ERROR);
      }
      break;
    }
    case ID_TREECTRL_1:
    {
      wxTreeItemId groupItem = evt.GetItem();
      if (groupItem.IsOk()) {
        PWTreeItemData* data = dynamic_cast<PWTreeItemData *>(GetItemData(groupItem));
        if (data && data->BeingAdded()) {
          // A new group being added
          FinishAddingGroup(evt, groupItem);
        }
        else if (data && data->BeingEdited()) {
          // An existing group being renamed
          FinishRenamingGroup(evt, groupItem, data->GetOldPath());
        }
      }
      break;
    }
    default:
      wxFAIL_MSG(wxString::Format(wxT("End Label Edit handler received an unexpected identifier: %d"), evt.GetId()));
      break;
  }
}
예제 #20
0
void WatchWindow::OnEndLabelEdit(wxTreeEvent& event)
{
    if (!event.IsEditCancelled())
    {

        wxTreeItemId item = event.GetItem();
        wxTreeItemId next = GetNextSibling(item);

        wxString expression = event.GetLabel();
        expression.Trim().Trim(false);

        if (expression.empty())
        {
            Delete(item);
            event.Veto();
        }
        else
        {
            SetItemText(item, expression);
            UpdateItem(item);
        }

        CreateEmptySlotIfNeeded();

        // Select the next item.

        if (!next.IsOk())
        {
            wxTreeItemIdValue cookie;
            next = GetLastChild(GetRootItem(), cookie);
        }

        SelectItem(next);

    }

    m_editing = false;
}
예제 #21
0
void PanelObjectList::OnTreeEndLabelEdit(wxTreeEvent& event)
{
    wxTreeItemId id = event.GetItem();
    TreeItemDataGenericObjectInfo* pData = (TreeItemDataGenericObjectInfo*)m_pTree_Objects->GetItemData( id );

    if( pData && pData->m_pLabelEditFunction )
    {
        //// end the edit to commit the new name
        //m_pTree_Objects->EndEditLabel( id );

        wxString newlabel = event.GetLabel();

        if( event.IsEditCancelled() == false )
        {
            // manually set the item to the new name, so the callback func can query for the name.
            //    the edit process seems to happen later
            RenameObject( pData->m_pObject, newlabel );

            // Call the callback and let game code handle the new name
            pData->m_pLabelEditFunction( pData->m_pObject_LabelEdit ? pData->m_pObject_LabelEdit : pData->m_pObject, id, newlabel );
        }
    }
}
예제 #22
0
void SceneBrowser::OnEndLabelEdit(wxTreeEvent& event)
{
    wxTreeItemId item = event.GetItem();
    wxASSERT(item.IsOk());

    if (event.IsEditCancelled())
        return;

    String newName = AS_STRING(event.GetLabel());
    if (mSceneManipulator->getSceneInfo()->isAutoName(newName))
    {
        event.Veto();
        wxMessageBox(
            wxString::Format(_("Cannot rename %s: The name is reserved for auto naming object. Specify a different name."), newName.c_str()),
            _("Error Renaming Object"),
            wxOK|wxCENTRE|wxICON_ERROR, this);
        return;
    }

    ObjectItemData* data = static_cast<ObjectItemData*>(mObjectsTree->GetItemData(item));
    if (!data)
    {
        event.Veto();
        return;
    }

    ObjectPtr object = data->object.lock();
    if (!object)
    {
        event.Veto();
        return;
    }

    if (newName.empty())
    {
        // Always veto
        event.Veto();
        if (mSceneManipulator->getSceneInfo()->isAutoName(object->getName()))
            return;

        // Generate auto name and set tree item text manual
        newName = mSceneManipulator->getSceneInfo()->generateAutoName(object);
        mObjectsTree->SetItemText(item, AS_STRING(newName));
    }
    else
    {
        if (object->getName() == newName)
        {
            event.Veto();
            return;
        }

        ObjectPtr other = mSceneManipulator->getSceneInfo()->findObjectByName(newName);
        if (other)
        {
            wxASSERT(other != object);
            event.Veto();
            wxMessageBox(
                wxString::Format(_("Cannot rename %s: An object with the name you specified already exists. Specify a different name."), newName.c_str()),
                _("Error Renaming Object"),
                wxOK|wxCENTRE|wxICON_ERROR, this);
            return;
        }
    }

    mSceneManipulator->renameObject(object, newName, this);
}
void BFBackupTree::OnEndLabelEdit (wxTreeEvent& rEvent)
{
    if (rEvent.GetItem() == GetRootItem())
        BFProject::Instance().SetName(rEvent.GetLabel());
}
예제 #24
0
void CLocalTreeView::OnEndLabelEdit(wxTreeEvent& event)
{
	if (event.IsEditCancelled())
	{
		event.Veto();
		return;
	}

	wxTreeItemId item = event.GetItem();

#ifdef __WXMSW__
	if (item == m_desktop || item == m_documents)
	{
		wxBell();
		event.Veto();
		return;
	}
#endif

	wxString path = GetDirFromItem(item);

#ifdef __WXMSW__
	if (path.Len() == 3 && path.Mid(1) == _T(":\\"))
	{
		wxBell();
		event.Veto();
		return;
	}
#endif
	if (!m_pState->LocalDirHasParent(path) || !m_pState->LocalDirIsWriteable(path))
	{
		wxBell();
		event.Veto();
		return;
	}

	if (path.Last() == wxFileName::GetPathSeparator())
		path.RemoveLast();

	int pos = path.Find(wxFileName::GetPathSeparator(), true);
	wxASSERT(pos != -1);

	wxString parent = path.Left(pos + 1);

	const wxString& oldName = GetItemText(item);
	const wxString& newName = event.GetLabel();

	wxASSERT(parent + oldName == path);

	if (oldName == newName)
		return;

	if (!Rename(this, parent, oldName, newName))
	{
		event.Veto();
		return;
	}

	wxTreeItemId currentSel = GetSelection();
	if (currentSel == wxTreeItemId())
	{
		Refresh();
		return;
	}

	if (item == currentSel)
	{
		m_pState->SetLocalDir(parent + newName);
		return;
	}

	wxString sub;

	wxTreeItemId tmp = currentSel;
	while (tmp != GetRootItem() && tmp != item)
	{
		sub = wxFileName::GetPathSeparator() + GetItemText(tmp) + sub;
		tmp = GetItemParent(tmp);
	}

	if (tmp == GetRootItem())
	{
		// Rename unrelated to current selection
		return;
	}

	// Current selection below renamed item
	m_pState->SetLocalDir(parent + newName + sub);
}
예제 #25
0
void CRemoteTreeView::OnEndLabelEdit(wxTreeEvent& event)
{
	if (event.IsEditCancelled())
	{
		event.Veto();
		return;
	}

	if (!m_pState->IsRemoteIdle())
	{
		event.Veto();
		return;
	}

	CItemData* const pData = (CItemData*)GetItemData(event.GetItem());
	if (pData)
	{
		event.Veto();
		return;
	}

	CServerPath old_path = GetPathFromItem(event.GetItem());
	CServerPath parent = old_path.GetParent();

	const wxString& oldName = GetItemText(event.GetItem());
	const wxString& newName = event.GetLabel();
	if (oldName == newName)
	{
		event.Veto();
		return;
	}

	m_pState->m_pCommandQueue->ProcessCommand(new CRenameCommand(parent, oldName, parent, newName));
	m_pState->ChangeRemoteDir(parent);

	CServerPath currentPath;
	const wxTreeItemId selected = GetSelection();
	if (selected)
		currentPath = GetPathFromItem(selected);
	if (currentPath.empty())
		return;

	if (currentPath == old_path || currentPath.IsSubdirOf(old_path, false))
	{
		// Previously selected path was below renamed one, list the new one

		std::list<wxString> subdirs;
		while (currentPath != old_path)
		{
			if (!currentPath.HasParent())
			{
				// Abort just in case
				return;
			}
			subdirs.push_front(currentPath.GetLastSegment());
			currentPath = currentPath.GetParent();
		}
		currentPath = parent;
		currentPath.AddSegment(newName);
		for (std::list<wxString>::const_iterator iter = subdirs.begin(); iter != subdirs.end(); ++iter)
			currentPath.AddSegment(*iter);
		m_pState->ChangeRemoteDir(currentPath);
	}
	else if (currentPath != parent)
		m_pState->ChangeRemoteDir(currentPath);
}
예제 #26
0
void MainFrame::OnTreeEndLabel(wxTreeEvent& evt)
{
	if (evt.IsEditCancelled())
		return;

	wxTreeItemId tree_id = m_pTree->GetItemParent(evt.GetItem());
	if (!tree_id)
	{
		evt.Veto();
		return;
	}

	TreeItemData* pItem = (TreeItemData*)m_pTree->GetItemData(tree_id);
	if (!pItem)
	{
		evt.Veto();
		return;
	}

	wxString strOld = m_pTree->GetItemText(evt.GetItem());

	SetCursor(*wxHOURGLASS_CURSOR);
	try
	{
		pItem->RenameKey(Omega::string_t(strOld.wc_str(),Omega::string_t::npos),Omega::string_t(evt.GetLabel().wc_str(),Omega::string_t::npos),(TreeItemData*)m_pTree->GetItemData(evt.GetItem()));
	}
	catch (Omega::IAlreadyExistsException* pE)
	{
		pE->Release();

		wxMessageBox(wxString::Format(_("Cannot rename %s: The specified value name already exists. Type another name and try again."),strOld.c_str()),_("Error Renaming Value"),wxOK|wxICON_ERROR,this);
		evt.Veto();
		m_pTree->EditLabel(evt.GetItem());
	}
	catch (Omega::Registry::IBadNameException* pE)
	{
		pE->Release();

		wxMessageBox(wxString::Format(_("Cannot rename %s: The specified value name is invalid. Type another name and try again."),strOld.c_str()),_("Error Renaming Value"),wxOK|wxICON_ERROR,this);
		evt.Veto();
		m_pTree->EditLabel(evt.GetItem());
	}
	catch (Omega::Registry::IAccessDeniedException* pE)
	{
		pE->Release();

		wxMessageBox(wxString::Format(_("Cannot rename %s: You do not have permission to edit this part of the registry."),strOld.c_str()),_("Error Renaming Value"),wxOK|wxICON_ERROR,this);
		evt.Veto();
		m_pTree->EditLabel(evt.GetItem());
	}
	catch (Omega::IException* pE)
	{
		wxMessageBox(pE->GetDescription().c_wstr(),_("System Error"),wxOK|wxICON_ERROR,this);
		pE->Release();
		SetCursor(*wxSTANDARD_CURSOR);
		evt.Veto();
		m_pTree->EditLabel(evt.GetItem());
	}
	catch(...)
	{
		SetCursor(*wxSTANDARD_CURSOR);
		evt.Veto();
		throw;
	}
	SetCursor(*wxSTANDARD_CURSOR);

	pItem = (TreeItemData*)m_pTree->GetItemData(evt.GetItem());
	pItem->Refresh(m_pList,m_pTree,evt.GetItem());
}
예제 #27
0
void CLocalTreeView::OnEndLabelEdit(wxTreeEvent& event)
{
	if (event.IsEditCancelled())
	{
		event.Veto();
		return;
	}

	wxTreeItemId item = event.GetItem();

#ifdef __WXMSW__
	if (item == m_desktop || item == m_documents)
	{
		wxBell();
		event.Veto();
		return;
	}
#endif

	wxString path = GetDirFromItem(item);

	CLocalPath local_path(path);
	if (!local_path.HasParent() || !local_path.IsWriteable())
	{
		wxBell();
		event.Veto();
		return;
	}

	if (path.Last() == wxFileName::GetPathSeparator())
		path.RemoveLast();

	int pos = path.Find(wxFileName::GetPathSeparator(), true);
	wxASSERT(pos != -1);

	wxString parent = path.Left(pos + 1);

	const wxString& oldName = GetItemText(item);
	const wxString& newName = event.GetLabel();
	if (newName == _T(""))
	{
		wxBell();
		event.Veto();
		return;
	}

	wxASSERT(parent + oldName == path);

	if (oldName == newName)
		return;

	if (!Rename(this, parent, oldName, newName))
	{
		event.Veto();
		return;
	}

	// We may call SetLocalDir, item might be deleted by it, so
	// if we don't rename item now and veto the event, wxWidgets
	// might access deleted item.
	event.Veto();
	SetItemText(item, newName);

	wxTreeItemId currentSel = GetSelection();
	if (currentSel == wxTreeItemId())
	{
		Refresh();
		return;
	}

	if (item == currentSel)
	{
		m_pState->SetLocalDir(parent + newName);
		return;
	}

	wxString sub;

	wxTreeItemId tmp = currentSel;
	while (tmp != GetRootItem() && tmp != item)
	{
		sub = wxFileName::GetPathSeparator() + GetItemText(tmp) + sub;
		tmp = GetItemParent(tmp);
	}

	if (tmp == GetRootItem())
	{
		// Rename unrelated to current selection
		return;
	}

	// Current selection below renamed item
	m_pState->SetLocalDir(parent + newName + sub);
}