Ejemplo n.º 1
0
void 
EditorBase::GetCompleteTextByPost(wyString &query, MDIWindow *wnd)
{
	wyUInt32		nstrlen;
	wyChar			*data;

	THREAD_MSG_PARAM tmp = {0};

    //set the lparam sent
    
	if(GetWindowThreadProcessId(m_hwnd , NULL) == GetCurrentThreadId())
    {
        nstrlen = SendMessage(m_hwnd, SCI_GETTEXTLENGTH, 0, 0);
		data = AllocateBuff(nstrlen + 1);
		SendMessage(m_hwnd, SCI_GETTEXT, (WPARAM)nstrlen+1, (LPARAM)data);
		query.SetAs(data);

		free(data);
    }
    else
    {
		if(WaitForSingleObject(pGlobals->m_pcmainwin->m_sqlyogcloseevent, 0) != WAIT_OBJECT_0 )
		{
			query.SetAs("");
			return;
		}
		tmp.m_lparam = (LPARAM)&query;
		tmp.m_hevent = CreateEvent(NULL, TRUE, FALSE, NULL);

		//now post the message to ui thread and wait for the event to be set
		PostMessage(wnd->GetHwnd(), UM_GETEDITORTEXT, (WPARAM)this->GetHWND(), (LPARAM)&tmp);
		if(WaitForSingleObject(tmp.m_hevent, 10000) == WAIT_TIMEOUT)
		{
			//CloseHandle(tmp.m_hevent);
			query.SetAs("");
			//return;
		}
		//WaitForSingleObject(tmp.m_hevent, INFINITE);


		//close the event handle
		CloseHandle(tmp.m_hevent);
		tmp.m_hevent = NULL;
		//data = (wyChar*)tmp.m_lparam;
		
	}
	

	return;
}
Ejemplo n.º 2
0
//function to get the banner text 
void 
TableView::GetBanner(wyString& bannertext)
{
    bannertext.Clear();

    //set the text
    if(!m_mydata || !m_mydata->m_table.GetLength() || !m_mydata->m_db.GetLength())
    {
        bannertext.SetAs(_("Select a Table/View from the Object Browser"));
    }
}
Ejemplo n.º 3
0
// Function to get the path the selected item in a  Treeview //
wyBool 
FavoriteBase::SelItemPath(HWND htree, HTREEITEM  item, wyString &fullpath, wyBool bFileFlag)
{	
	wyWChar		data[MAX_PATH + 1] = {0};
	wyWChar		foldpath[MAX_PATH + 1] = {0};
	TVITEM		tvitem;
	wyString	path, temp, temp2, datastr, foldpathstr;
	
	// application data path //
	if(!pGlobals->m_configdirpath.GetLength())
	{
		if(!SUCCEEDED(::SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, foldpath)))
			return OnError(_("Error in favorites"));

		wcscat(foldpath ,L"\\SQLyog");
	}

	else
	{
		//wcscpy(foldpath, pGlobals->m_configdirpath.GetAsWideChar());
		wcsncpy(foldpath, pGlobals->m_configdirpath.GetAsWideChar(), MAX_PATH);
		foldpath[MAX_PATH] = '\0';
	}
	
	while(item)
	{
		tvitem.mask		  = TVIF_TEXT | TVIF_IMAGE;
		tvitem.hItem	  = item;
		tvitem.cchTextMax = MAX_PATH;
		tvitem.pszText	  = data ;

		TreeView_GetItem(htree, &tvitem);
		datastr.SetAs(data);
		if(tvitem.iImage != NFILE || !bFileFlag)
        {
			temp.Sprintf("\\%s", datastr.GetString());
            if(path.GetLength() > 0)
            {
                temp2.SetAs(path);
				path.Sprintf("\\%s%s", datastr.GetString(), temp2.GetString());
            }
            else
				path.Sprintf("\\%s", datastr.GetString());
        }
		
		item = TreeView_GetParent(htree, item);
	}
	
	foldpathstr.SetAs(foldpath);
	fullpath.SetAs(foldpathstr.GetString());
	fullpath.Add(path.GetString());

    return wyTrue;
}
Ejemplo n.º 4
0
wyBool 
InitOpenFile(HWND hwnd, wyString &filename, wyInt32 filter, wyInt32 bufsize)
{
    wyWChar     file[MAX_PATH] = {0};
    wyBool      ret;

    ret = InitOpenFile(hwnd, file, filter, bufsize);
    filename.SetAs(file);

    return ret;
}
Ejemplo n.º 5
0
void
EditorBase::AddResultMsg(Tunnel * tunnel, MYSQL_RES * myres, wyString& errorormsg, wyUInt32 timetaken)
{
	wyUInt32		rowsret;
	wyString		newmsg;

	rowsret		=	(wyUInt32)tunnel->mysql_num_rows(myres);

	VERIFY(newmsg.Sprintf(_("(%lu row(s) returned)\n(%d ms taken)\n\n"), rowsret, timetaken  ) < SIZE_128);

	errorormsg.SetAs(newmsg);
	
	return;
}
Ejemplo n.º 6
0
//get column name
wyBool 
TableView::GetColumnName(wyString& column, wyInt32 col)
{
    if(m_data && m_data->m_datares && col >= 0 && col < m_data->m_datares->field_count)
    {
        if(m_data->m_datares->fields[col].name && m_data->m_datares->fields[col].name[0])
        {
            column.SetAs(m_data->m_datares->fields[col].name, m_wnd->m_ismysql41);
        }

        return column.GetLength() ? wyTrue : wyFalse;
    }

    return wyFalse;
}
Ejemplo n.º 7
0
void 
EditorBase::GetCompleteText(wyString &query)
{
	wyUInt32		nstrlen;
	wyChar			*data;

	nstrlen = SendMessage(m_hwnd, SCI_GETTEXTLENGTH, 0, 0);

	data = AllocateBuff(nstrlen + 1);

	SendMessage(m_hwnd, SCI_GETTEXT, (WPARAM)nstrlen+1, (LPARAM)data);

	query.SetAs(data);

	free(data);

	return;
}
Ejemplo n.º 8
0
//get table name
wyBool 
TableView::GetTableName(wyString& table, wyInt32 col)
{
    table.SetAs(m_data->m_table);
    return table.GetLength() ? wyTrue : wyFalse;
}
Ejemplo n.º 9
0
//get the database name
wyBool 
TableView::GetDBName(wyString& db, wyInt32 col)
{
    db.SetAs(m_data->m_db);
    return db.GetLength() ? wyTrue : wyFalse;
}
wyBool
ExportAsSimpleSQL::AddValues(ExportSQLData *data, wyString &value)
{
	wyInt32		count, last, lenrow;
	wyString	temp, resrow, buffer;
	wyInt32     *lengths = NULL; 
	wyInt32		escapeddatalen;
	wyBool		startflag = wyFalse;

	if(WriteToFile(value) == wyFalse)
		return wyFalse;

	//this condition is true if export from from result tab if result set is not edited
    if(!data->m_tabrec->m_rowarray)
	{
		if(m_isdatafromquery == wyTrue)
		{
			lengths = (wyInt32 *)sja_mysql_fetch_lengths(m_tunnel, m_myres);
		}
		else
		{
			lengths = (wyInt32 *)m_rowlength; 
		}
	}

	for(count = 0; count < data->m_result->field_count; count++)
	{
		if(data->m_selcol[count] == wyFalse)
			continue;

		if(startflag == wyTrue)
			buffer.Add(",");

        /// Check for NULL value or not
        if(!m_myrow[count])
        {
            buffer.Add("NULL");
            startflag = wyTrue;

            continue;
        }

		if(m_escapeddata)
			free(m_escapeddata);

				
		//This condion true if the result tab in table tab or edit mode or result set is edited		
		if(!lengths)		
		{
			resrow.SetAs(m_myrow[count]);
			lenrow = resrow.GetLength();
		}		
		else
		{			
			lenrow = lengths[count];		
		}		
				
		//It requires double buffer bcs the real_escape_string returns 2 char for special chars like '\'
		escapeddatalen = (lenrow * 2) + 1;
		m_escapeddata = AllocateBuff(escapeddatalen);

		last = sja_mysql_real_escape_string(m_tunnel, *m_mysql, m_escapeddata, m_myrow[count], lenrow);
		m_escapeddata[last] = 0;

		buffer.Add("'");
		startflag = wyTrue;

		buffer.Add(m_escapeddata);

		buffer.Add("'");
	}

	//Write to file
	WriteToFile(buffer);

	buffer.SetAs("");
	value.SetAs("");
	return wyTrue;
}