本文整理汇总了C++中DbItem::GetData方法的典型用法代码示例。如果您正苦于以下问题:C++ DbItem::GetData方法的具体用法?C++ DbItem::GetData怎么用?C++ DbItem::GetData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbItem
的用法示例。
在下文中一共展示了DbItem::GetData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnDnDStart
void DbViewerPanel::OnDnDStart(wxTreeEvent& event)
{
ShapeList lstDnD;
lstDnD.DeleteContents(true);
DbItem* item = (DbItem*)m_treeDatabases->GetItemData(event.GetItem());
ErdPanel* pPanel = wxDynamicCast(m_mgr->GetActivePage(), ErdPanel);
if(item != NULL) {
if(pPanel) {
Table* table = wxDynamicCast(item->GetData(), Table);
if(table) {
table = (Table*)table->Clone();
wxSFShapeBase* pShape = new dndTableShape(table);
lstDnD.Append(pShape);
pPanel->GetCanvas()->DoDragDrop(lstDnD);
}
View* view = wxDynamicCast(item->GetData(), View);
if(view) {
view = (View*)view->Clone();
wxSFShapeBase* pShape = new dndTableShape(view);
lstDnD.Append(pShape);
pPanel->GetCanvas()->DoDragDrop(lstDnD);
}
}
}
}
示例2: OnItemRightClick
void DbViewerPanel::OnItemRightClick(wxTreeEvent& event)
{
m_pEditedDatabase = NULL;
m_pEditedConnection = NULL;
m_selectedID = event.GetItem();
DbItem* item = (DbItem*) m_treeDatabases->GetItemData(m_selectedID);
wxMenu menu;
int c = 0;
if (item) {
Database* db = wxDynamicCast(item->GetData(),Database);
if (db) {
// menu.Append(XRCID("IDR_DBVIEWER_ADD_TABLE"),_("Add table"),_("Run SQL command for creating Table"));
menu.Append(XRCID("IDR_DBVIEWER_SQL_DATABASE"), _("Open SQL panel"), _("Open SQL command panel for the database"));
menu.AppendSeparator();
menu.Append(XRCID("IDR_DBVIEWER_DROP_DATABASE"), _("Drop database"), _("Run SQL command for deleting Database"));
menu.AppendSeparator();
menu.Append(XRCID("IDR_DBVIEWER_ERD_DB"), _("Create ERD from DB"),_("Create ERD diagram from the database"));
menu.Append(XRCID("IDR_DBVIEWER_CLASS_DB"), _("Create classes from DB"), _("Create C++ classes for the database"));
menu.AppendSeparator();
menu.Append(XRCID("IDR_DBVIEWER_IMPORT_DATABASE"), _("Import database from file"), _("Run SQL commands stored in *.sql file"));
menu.Append(XRCID("IDR_DBVIEWER_EXPORT_DATABASE"), _("Export database to file"), _("Export database CREATE SQL statements into *.sql file"));
menu.AppendSeparator();
menu.Append(XRCID("IDR_DBVIEWER_DUMP_DATABASE"), _("Dump data to file"), _("Dump data from database into .sql file"));
c++;
m_pEditedDatabase = db;
}
Table* tab = wxDynamicCast(item->GetData(), Table);
if (tab) {
menu.Append(XRCID("IDR_DBVIEWER_SQL_TABLE"),_("Open SQL panel"),_("Open SQL command panel for the table"));
menu.AppendSeparator();
menu.Append(XRCID("IDR_DBVIEWER_DROP_TABLE"),_("Drop table"),_("Run SQL command to delete the table"));
menu.AppendSeparator();
menu.Append(XRCID("IDR_DBVIEWER_ERD_TABLE"), _("Create ERD from Table"),_("Create ERD diagram from the table"));
menu.Append(XRCID("IDR_DBVIEWER_CLASS_TABLE"), _("Create classes from Table"), _("Create C++ classes for the table"));
c++;
}
View* vw = wxDynamicCast(item->GetData(), View);
if (vw) {
menu.Append(XRCID("IDR_DBVIEWER_SQL_VIEW"),_("Open SQL panel"),_("Open SQL command panel for the view"));
menu.AppendSeparator();
menu.Append(XRCID("IDR_DBVIEWER_DROP_VIEW"),_("Drop view"),_("Run SQL command to delete the view"));
c++;
}
}
if ( c > 0 ) {
menu.Connect(wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction)&DbViewerPanel::OnPopupClick, NULL, this);
PopupMenu(&menu);
}
}
示例3: OnItemActivate
void DbViewerPanel::OnItemActivate(wxTreeEvent& event)
{
try {
DbItem* item = (DbItem*) m_treeDatabases->GetItemData(event.GetItem());
if (item) {
wxMouseState cState = ::wxGetMouseState();
wxString pagename;
if (Table* tab = wxDynamicCast(item->GetData(), Table)) {
if( cState.ControlDown() ) {
pagename = CreatePanelName(tab, DbViewerPanel::Erd);
ErdPanel *erdpanel = new ErdPanel(m_pNotebook,tab->GetDbAdapter()->Clone(),m_pConnections, (Table*) tab->Clone() );
AddEditorPage(erdpanel, pagename);
} else {
#if defined (__WXMSW__)
clWindowUpdateLocker locker(m_mgr->GetEditorPaneNotebook());
#endif
pagename = CreatePanelName(tab, DbViewerPanel::Sql);
if(!DoSelectPage(pagename)) {
SQLCommandPanel *sqlpage = new SQLCommandPanel(m_pNotebook,tab->GetDbAdapter()->Clone(),tab->GetParentName(),tab->GetName());
AddEditorPage(sqlpage, pagename);
}
}
}
if (View* pView = wxDynamicCast(item->GetData(), View)) {
pagename = CreatePanelName(pView, DbViewerPanel::Sql);
if(!DoSelectPage(pagename)) {
SQLCommandPanel *sqlpage = new SQLCommandPanel(m_pNotebook,pView->GetDbAdapter()->Clone(),pView->GetParentName(),pView->GetName());
AddEditorPage(sqlpage, pagename);
}
}
if (Database* db = wxDynamicCast(item->GetData(), Database)) {
if( cState.ControlDown() ) {
pagename = CreatePanelName(db, DbViewerPanel::Erd);
ErdPanel *erdpanel = new ErdPanel(m_pNotebook,db->GetDbAdapter()->Clone(),m_pConnections,(Database*)db->Clone());
AddEditorPage(erdpanel, pagename);
} else {
pagename = CreatePanelName(db, DbViewerPanel::Sql);
if(!DoSelectPage(pagename)) {
SQLCommandPanel *sqlpage = new SQLCommandPanel(m_pNotebook,db->GetDbAdapter()->Clone(),db->GetName(),wxT(""));
#ifndef __WXMSW__
sqlpage->Show();
#endif
AddEditorPage(sqlpage, pagename);
}
}
}
}
} catch (DatabaseLayerException &e) {
::wxMessageBox(wxString() << "Error occured while opening SQL panel: " << e.GetErrorMessage(), "Database Explorer", wxOK|wxICON_ERROR|wxCENTER);
}
}
示例4: OnToolCloseClick
void DbViewerPanel::OnToolCloseClick(wxCommandEvent& event)
{
// Close the active connection (there is only one)
// getting selected item data
/*wxTreeItemIdValue cookie;
DbItem* data = (DbItem*) m_treeDatabases->GetItemData(m_treeDatabases->GetFirstChild(m_treeDatabases->GetRootItem(), cookie));*/
wxTreeItemId itemId = m_treeDatabases->GetSelection();
DbItem* data = (DbItem*) m_treeDatabases->GetItemData(itemId);
if (data) {
DbConnection* pCon = wxDynamicCast(data->GetData(), DbConnection);
if (pCon) {
wxMessageDialog dlg(this,_("Close connection?"),_("Close"),wxYES_NO);
if (dlg.ShowModal() == wxID_YES) {
// loop over the editor open pages and close all DbExplorer related
for(size_t i=0; i<m_pagesAdded.Count(); i++) {
m_mgr->ClosePage(m_pagesAdded.Item(i));
}
m_pagesAdded.Clear();
//m_pConnections->GetChildrenList().DeleteContents(true);
m_pConnections->GetChildrenList().DeleteObject(pCon);
m_treeDatabases->Delete(itemId);
RefreshDbView();
}
}
/* else
wxMessageBox( _("Please, select database connection in DbExplorer tree view."), _("Close"), wxOK | wxICON_WARNING ); */
}
}
示例5: OnToolCloseUI
void DbViewerPanel::OnToolCloseUI(wxUpdateUIEvent& event)
{
wxTreeItemId treeId = m_treeDatabases->GetSelection();
if(treeId.IsOk()) {
DbItem* data = (DbItem*)m_treeDatabases->GetItemData(treeId);
event.Enable(data && wxDynamicCast(data->GetData(), DbConnection));
} else
event.Enable(false);
}
示例6: OnPopupClick
void DbViewerPanel::OnPopupClick(wxCommandEvent& evt)
{
if(!m_selectedID.IsOk()) return;
try {
if(evt.GetId() == XRCID("IDR_DBVIEWER_ADD_DATABASE")) {
if(m_pEditedConnection) {
// TODO:LANG:
wxString dbName = wxGetTextFromUser(_("Database name"), _("Add database"));
if(!dbName.IsEmpty()) {
DatabaseLayerPtr pDbLayer = m_pEditedConnection->GetDbAdapter()->GetDatabaseLayer(wxT(""));
wxString sql = m_pEditedConnection->GetDbAdapter()->GetCreateDatabaseSql(dbName);
if(!sql.empty()) {
pDbLayer->RunQuery(sql);
pDbLayer->Close();
// TODO:LANG:
wxMessageBox(_("Database created successfully"));
RefreshDbView();
} else {
// TODO:LANG:
wxMessageDialog dlg(
this, _("Can't create new db in this database engine!"), _("Error"), wxOK | wxICON_ERROR);
dlg.ShowModal();
}
}
}
} else if(evt.GetId() == XRCID("IDR_DBVIEWER_DROP_DATABASE")) {
DbItem* data = (DbItem*)m_treeDatabases->GetItemData(m_selectedID);
if(data) {
Database* pDb = (Database*)wxDynamicCast(data->GetData(), Database);
if(pDb) {
wxString dropSQL = pDb->GetDbAdapter()->GetDropDatabaseSql(pDb);
if(!dropSQL.IsEmpty()) {
// TODO:LANG:
wxMessageDialog dlg(this,
wxString::Format(_("Remove database '%s'?"), pDb->GetName().c_str()),
_("Drop database"),
wxYES_NO);
if(dlg.ShowModal() == wxID_YES) {
DatabaseLayerPtr pDbLayer = pDb->GetDbAdapter()->GetDatabaseLayer(wxT(""));
pDbLayer->RunQuery(dropSQL);
pDbLayer->Close();
// TODO:LANG:
wxMessageBox(_("Database dropped successfully"));
RefreshDbView();
}
}
}
}
} else if(evt.GetId() == XRCID("IDR_DBVIEWER_ERD_TABLE")) {
DbItem* data = (DbItem*)m_treeDatabases->GetItemData(m_selectedID);
if(data) {
Table* pTab = (Table*)wxDynamicCast(data->GetData(), Table);
if(pTab) {
wxString pagename;
pagename = CreatePanelName(pTab, DbViewerPanel::Erd);
ErdPanel* erdpanel =
new ErdPanel(m_pNotebook, pTab->GetDbAdapter()->Clone(), m_pConnections, (Table*)pTab->Clone());
AddEditorPage(erdpanel, pagename);
}
}
} else if(evt.GetId() == XRCID("IDR_DBVIEWER_ERD_DB")) {
DbItem* data = (DbItem*)m_treeDatabases->GetItemData(m_selectedID);
if(data) {
Database* pDb = (Database*)wxDynamicCast(data->GetData(), Database);
if(pDb) {
wxString pagename;
pagename = CreatePanelName(pDb, DbViewerPanel::Erd);
ErdPanel* erdpanel = new ErdPanel(
m_pNotebook, pDb->GetDbAdapter()->Clone(), m_pConnections, (Database*)pDb->Clone());
AddEditorPage(erdpanel, pagename);
}
}
} else if(evt.GetId() == XRCID("IDR_DBVIEWER_CLASS_DB")) {
DbItem* data = (DbItem*)m_treeDatabases->GetItemData(m_selectedID);
if(data) {
Database* pDb = (Database*)wxDynamicCast(data->GetData(), Database);
if(pDb) {
pDb = (Database*)pDb->Clone();
// NOTE: the refresh functions must be here for propper code generation (they translate views into
// tables)
pDb->RefreshChildren(true);
pDb->RefreshChildrenDetails();
ClassGenerateDialog dlg(m_mgr->GetTheApp()->GetTopWindow(), pDb->GetDbAdapter(), pDb, m_mgr);
dlg.ShowModal();
delete pDb;
}
}
} else if(evt.GetId() == XRCID("IDR_DBVIEWER_CLASS_TABLE")) {
DbItem* data = (DbItem*)m_treeDatabases->GetItemData(m_selectedID);
if(data) {
Table* pTab = (Table*)wxDynamicCast(data->GetData(), Table);
if(pTab) {
ClassGenerateDialog dlg(
m_mgr->GetTheApp()->GetTopWindow(), pTab->GetDbAdapter(), (Table*)pTab->Clone(), m_mgr);
dlg.ShowModal();
}
//.........这里部分代码省略.........
示例7: RefreshDbView
void DbViewerPanel::RefreshDbView()
{
// Refresh all connections
wxTreeItemId root = m_treeDatabases->GetRootItem();
if(root.IsOk()) {
wxTreeItemIdValue cookie;
wxTreeItemId child = m_treeDatabases->GetFirstChild(root, cookie);
while(child.IsOk()) {
DbItem* data = (DbItem*)m_treeDatabases->GetItemData(child);
if(data) {
DbConnection* pCon = wxDynamicCast(data->GetData(), DbConnection);
if(pCon) pCon->RefreshChildren();
Database* pDb = wxDynamicCast(data->GetData(), Database);
if(pDb) pDb->RefreshChildren(false);
Table* pTab = wxDynamicCast(data->GetData(), Table);
if(pTab) pTab->RefreshChildren();
}
child = m_treeDatabases->GetNextChild(root, cookie);
}
}
// clear items from tree
m_treeDatabases->DeleteAllItems();
// create imageList for icons
wxImageList* pImageList = new wxImageList(16, 16, true, 3);
pImageList->Add(m_mgr->GetStdIcons()->LoadBitmap(wxT("toolbars/16/standard/file_open"))); // folder icon
pImageList->Add(m_mgr->GetStdIcons()->LoadBitmap(wxT("db-explorer/16/table"))); // table icon
pImageList->Add(m_mgr->GetStdIcons()->LoadBitmap(wxT("toolbars/16/search/find"))); // view icon
pImageList->Add(m_mgr->GetStdIcons()->LoadBitmap(wxT("db-explorer/16/database"))); // database
pImageList->Add(m_mgr->GetStdIcons()->LoadBitmap(wxT("db-explorer/16/column"))); // column
m_treeDatabases->AssignImageList(pImageList);
wxTreeItemId totalRootID = m_treeDatabases->AddRoot(wxString::Format(wxT("Databases")), -1);
// ---------------- load connections ----------------------------
SerializableList::compatibility_iterator connectionNode = m_pConnections->GetFirstChildNode();
while(connectionNode) {
DbConnection* pDbCon = (DbConnection*)wxDynamicCast(connectionNode->GetData(), DbConnection);
if(pDbCon) {
wxTreeItemId rootID =
m_treeDatabases->AppendItem(totalRootID,
wxString::Format(wxT("Databases (%s)"), pDbCon->GetServerName().c_str()),
3,
3,
new DbItem(pDbCon));
// ----------------------- load databases -------------------------------
SerializableList::compatibility_iterator dbNode = pDbCon->GetFirstChildNode();
while(dbNode) {
Database* pDatabase = wxDynamicCast(dbNode->GetData(), Database);
if(pDatabase) {
wxTreeItemId dbID =
m_treeDatabases->AppendItem(rootID, pDatabase->GetName(), 3, 3, new DbItem(pDatabase));
m_treeDatabases->Expand(rootID);
wxTreeItemId idFolder = m_treeDatabases->AppendItem(dbID, wxT("Tables"), 0, 0, NULL);
// m_treeDatabases->Expand(dbID);
// ----------------------------- load tables ----------------------------------
SerializableList::compatibility_iterator tabNode = pDatabase->GetFirstChildNode();
while(tabNode) {
Table* pTable = wxDynamicCast(tabNode->GetData(), Table);
if(pTable) {
// wxTreeItemId tabID = m_treeDatabases->AppendItem(idFolder,pTable->getName(),1,-1,new
// DbItem(NULL,pTable)); //NULL);
wxTreeItemId tabID = m_treeDatabases->AppendItem(idFolder,
pTable->GetName(),
1,
1,
new DbItem(pTable)); // NULL);
///////////////////////////////////////////////////////////
// Add the columns
///////////////////////////////////////////////////////////
SerializableList::compatibility_iterator columnNode = pTable->GetFirstChildNode();
while(columnNode) {
Column* col = wxDynamicCast(columnNode->GetData(), Column);
if(col) {
m_treeDatabases->AppendItem(
tabID, col->FormatName().c_str(), 4, 4, new DbItem(col));
}
columnNode = columnNode->GetNext();
}
}
tabNode = tabNode->GetNext();
}
// ----------------------------------------------------------------------------
idFolder = m_treeDatabases->AppendItem(dbID, wxT("Views"), 0, 0, NULL);
// m_treeDatabases->Expand(dbID);
// ----------------------------- load views ----------------------------------
tabNode = pDatabase->GetFirstChildNode();
while(tabNode) {
View* pView = wxDynamicCast(tabNode->GetData(), View);
if(pView) {
// wxTreeItemId tabID = m_treeDatabases->AppendItem(idFolder,pTable->getName(),1,-1,new
// DbItem(NULL,pTable)); //NULL);
m_treeDatabases->AppendItem(idFolder, pView->GetName(), 2, 2, new DbItem(pView)); // NULL);
}
tabNode = tabNode->GetNext();
//.........这里部分代码省略.........