Example #1
0
void DbSettingDialog::DoSaveMySQLHistory()
{
    clConfig config(DBE_CONFIG_FILE);
    DbExplorerSettings settings;
    config.ReadItem(&settings);
    DbConnectionInfoVec mysql = settings.GetMySQLConnections();

    DbConnectionInfo conn;
    conn.SetConnectionType(DbConnectionInfo::DbConnTypeMySQL);
    conn.SetDefaultDatabase(wxT(""));
    conn.SetConnectionName(m_txName->GetValue());
    conn.SetPassword(m_txPassword->GetValue());
    conn.SetServer(m_txServer->GetValue());
    conn.SetUsername(m_txUserName->GetValue());

    if(!conn.IsValid()) return;

    // remove any connection with this name
    DbConnectionInfoVec::iterator iter = mysql.begin();
    for(; iter != mysql.end(); ++iter) {
        if(iter->GetConnectionName() == conn.GetConnectionName()) {
            mysql.erase(iter);
            break;
        }
    }

    mysql.insert(mysql.begin(), conn);
    settings.SetMySQLConnections(mysql);
    config.WriteItem(&settings);
}
Example #2
0
void DbSettingDialog::DoSavePgSQLHistory()
{
    clConfig config(DBE_CONFIG_FILE);
    DbExplorerSettings settings;
    config.ReadItem(&settings);
    DbConnectionInfoVec pgconns = settings.GetPgSQLConnections();

    long port = 0;
    DbConnectionInfo conn;
    conn.SetConnectionType(DbConnectionInfo::DbConnTypePgSQL);
    conn.SetConnectionName(m_txPgName->GetValue());
    conn.SetDefaultDatabase(m_txPgDatabase->GetValue());
    conn.SetPassword(m_txPgPassword->GetValue());
    conn.SetServer(m_txPgServer->GetValue());
    m_txPgPort->GetValue().ToLong(&port);
    conn.SetPort(port);
    conn.SetUsername(m_txPgUserName->GetValue());

    if(!conn.IsValid()) return;

    // remove any connection with this name
    DbConnectionInfoVec::iterator iter = pgconns.begin();
    for(; iter != pgconns.end(); iter++) {
        if(iter->GetConnectionName() == conn.GetConnectionName()) {
            pgconns.erase(iter);
            break;
        }
    }

    pgconns.insert(pgconns.begin(), conn);
    settings.SetPgSQLConnections(pgconns);
    config.WriteItem(&settings);
}
Example #3
0
DbConnectionInfoVec DbSettingDialog::DoLoadPgSQLHistory()
{
    clConfig config(DBE_CONFIG_FILE);
    DbExplorerSettings settings;
    config.ReadItem(&settings);
    return settings.GetPgSQLConnections();
}
Example #4
0
wxArrayString DbSettingDialog::DoLoadSqliteHistory()
{
    clConfig config(DBE_CONFIG_FILE);
    DbExplorerSettings settings;
    config.ReadItem(&settings);
    return settings.GetRecentFiles();
}
Example #5
0
void SQLCommandPanel::SaveSqlHistory()
{
    wxArrayString sqls = ParseSql( m_scintillaSQL->GetText() );
    if ( sqls.IsEmpty() )
        return;
    
    DbExplorerSettings s;
    clConfig conf(DBE_CONFIG_FILE);
    conf.ReadItem( &s );
    const wxArrayString &history = s.GetSqlHistory();
    
    // Append the current history to the new sqls (exclude dups)
    for(size_t i=0; i<history.GetCount(); ++i) {
        if ( sqls.Index(history.Item(i) ) == wxNOT_FOUND ) {
            sqls.Add( history.Item(i) );
        }
    }

    // Truncate the buffer
    while( sqls.GetCount() > 15 ) {
        sqls.RemoveAt(sqls.GetCount()-1);
    }
    
    s.SetSqlHistory( sqls );
    conf.WriteItem( &s );
}
Example #6
0
void SQLCommandPanel::OnHistoryToolClicked(wxAuiToolBarEvent& event)
{
    wxAuiToolBar* auibar = dynamic_cast<wxAuiToolBar*>(event.GetEventObject());
    if ( auibar ) {
        clAuiToolStickness ts(auibar, event.GetToolId());
        wxRect rect = auibar->GetToolRect(event.GetId());
        wxPoint pt = auibar->ClientToScreen(rect.GetBottomLeft());
        pt = ScreenToClient(pt);
        
        DbExplorerSettings settings;
        clConfig conf(DBE_CONFIG_FILE);
        conf.ReadItem(&settings);
        settings.GetRecentFiles();
        
        wxArrayString sqls = settings.GetSqlHistory();
        wxMenu menu;
        for(size_t i=0; i<sqls.GetCount(); ++i) {
            menu.Append(wxID_HIGHEST+i, sqls.Item(i));
        }
        
        int pos = GetPopupMenuSelectionFromUser(menu, pt);
        if ( pos == wxID_NONE )
            return;
        
        size_t index = pos - wxID_HIGHEST;
        if ( index > sqls.GetCount() )
            return;
        
        m_scintillaSQL->SetText( sqls.Item(index) );
        CallAfter( &SQLCommandPanel::ExecuteSql );
    }
}
Example #7
0
void DbSettingDialog::DoSaveSqliteHistory()
{
    // Save the recent opened files
    clConfig config(DBE_CONFIG_FILE);
    DbExplorerSettings settings;
    config.ReadItem(&settings);

    wxArrayString files = settings.GetRecentFiles();

    wxString filename = m_filePickerSqlite->GetPath();
    filename.Trim().Trim(false);
    if(filename.IsEmpty()) return;

    files.Insert(filename, 0);
    settings.SetRecentFiles(files);
    config.WriteItem(&settings);
}